@@ -110,7 +110,12 @@ async function clusterEditorMessageListener (event: any ): Promise<any> {
110110 } else {
111111 if ( signupStatus . status . ready ) {
112112 const oauthInfo = await sandboxAPI . getOauthServerInfo ( signupStatus . apiEndpoint ) ;
113- panel . webview . postMessage ( { action : 'sandboxPageProvisioned' , statusInfo : signupStatus . username , consoleDashboard : signupStatus . consoleURL , apiEndpoint : signupStatus . apiEndpoint , oauthTokenEndpoint : oauthInfo . token_endpoint } ) ;
113+ let errCode = '' ;
114+ if ( ! await Cluster . validateLoginToken ( signupStatus . apiEndpoint , await vscode . env . clipboard . readText ( ) ) ) {
115+ errCode = 'invalidToken' ;
116+ }
117+ panel . webview . postMessage ( { action : 'sandboxPageProvisioned' , statusInfo : signupStatus . username , consoleDashboard : signupStatus . consoleURL , apiEndpoint : signupStatus . apiEndpoint , oauthTokenEndpoint : oauthInfo . token_endpoint , errorCode : errCode } ) ;
118+ pollClipboard ( signupStatus ) ;
114119 } else {
115120 // cluster is not ready and the reason is
116121 if ( signupStatus . status . verificationRequired ) {
@@ -185,6 +190,22 @@ async function clusterEditorMessageListener (event: any ): Promise<any> {
185190 }
186191}
187192
193+ async function pollClipboard ( signupStatus ) {
194+ while ( panel ) {
195+ const previousContent = await vscode . env . clipboard . readText ( ) ;
196+ await new Promise ( r => setTimeout ( r , 500 ) ) ;
197+ const currentContent = await vscode . env . clipboard . readText ( ) ;
198+ if ( previousContent && previousContent !== currentContent ) {
199+ const oauthInfo = await sandboxAPI . getOauthServerInfo ( signupStatus . apiEndpoint ) ;
200+ let errCode = '' ;
201+ if ( ! await Cluster . validateLoginToken ( signupStatus . apiEndpoint , currentContent ) ) {
202+ errCode = 'invalidToken' ;
203+ }
204+ panel . webview . postMessage ( { action : 'sandboxPageProvisioned' , statusInfo : signupStatus . username , consoleDashboard : signupStatus . consoleURL , apiEndpoint : signupStatus . apiEndpoint , oauthTokenEndpoint : oauthInfo . token_endpoint , errorCode : errCode } ) ;
205+ }
206+ }
207+ }
208+
188209export default class ClusterViewLoader {
189210 // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
190211 static get extensionPath ( ) {
0 commit comments