File tree 6 files changed +28
-12
lines changed
arduino-ide-extension/src
6 files changed +28
-12
lines changed Original file line number Diff line number Diff line change @@ -43,15 +43,14 @@ export class AuthenticationClientService
43
43
44
44
readonly onSessionDidChange = this . onSessionDidChangeEmitter . event ;
45
45
46
- onStart ( ) : void {
46
+ async onStart ( ) : Promise < void > {
47
47
this . toDispose . push ( this . onSessionDidChangeEmitter ) ;
48
48
this . service . setClient ( this ) ;
49
49
this . service
50
50
. session ( )
51
51
. then ( ( session ) => this . notifySessionDidChange ( session ) ) ;
52
52
53
- this . setOptions ( ) ;
54
- this . service . initAuthSession ( )
53
+ this . setOptions ( ) . then ( ( ) => this . service . initAuthSession ( ) ) ;
55
54
56
55
this . arduinoPreferences . onPreferenceChanged ( ( event ) => {
57
56
if ( event . preferenceName . startsWith ( 'arduino.auth.' ) ) {
@@ -60,8 +59,8 @@ export class AuthenticationClientService
60
59
} ) ;
61
60
}
62
61
63
- setOptions ( ) : void {
64
- this . service . setOptions ( {
62
+ setOptions ( ) : Promise < void > {
63
+ return this . service . setOptions ( {
65
64
redirectUri : `http://localhost:${ serverPort } /callback` ,
66
65
responseType : 'code' ,
67
66
clientID : this . arduinoPreferences [ 'arduino.auth.clientID' ] ,
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ export interface AuthenticationService
22
22
logout ( ) : Promise < void > ;
23
23
session ( ) : Promise < AuthenticationSession | undefined > ;
24
24
disposeClient ( client : AuthenticationServiceClient ) : void ;
25
- setOptions ( authOptions : AuthOptions ) : void ;
25
+ setOptions ( authOptions : AuthOptions ) : Promise < void > ;
26
26
initAuthSession ( ) : Promise < void > ;
27
27
}
28
28
Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ export class ArduinoAuthenticationProvider implements AuthenticationProvider {
89
89
setInterval ( checkToken , REFRESH_INTERVAL ) ;
90
90
}
91
91
92
- public setOptions ( authOptions : AuthOptions ) {
92
+ public async setOptions ( authOptions : AuthOptions ) : Promise < void > {
93
93
this . authOptions = authOptions ;
94
94
}
95
95
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ export class AuthenticationServiceImpl
20
20
protected readonly clients : AuthenticationServiceClient [ ] = [ ] ;
21
21
protected readonly toDispose = new DisposableCollection ( ) ;
22
22
23
- private initialized = false ;
23
+ private initialized = false ;
24
24
25
25
async onStart ( ) : Promise < void > {
26
26
this . toDispose . pushAll ( [
@@ -49,12 +49,12 @@ export class AuthenticationServiceImpl
49
49
async initAuthSession ( ) : Promise < void > {
50
50
if ( ! this . initialized ) {
51
51
await this . delegate . init ( ) ;
52
- this . initialized = true
52
+ this . initialized = true ;
53
53
}
54
54
}
55
55
56
- setOptions ( authOptions : AuthOptions ) {
57
- this . delegate . setOptions ( authOptions ) ;
56
+ setOptions ( authOptions : AuthOptions ) : Promise < void > {
57
+ return this . delegate . setOptions ( authOptions ) ;
58
58
}
59
59
60
60
async login ( ) : Promise < AuthenticationSession > {
Original file line number Diff line number Diff line change @@ -47,6 +47,15 @@ export class Keychain {
47
47
return false ;
48
48
}
49
49
try {
50
+ const stringifiedTokenLength = stringifiedToken . length ;
51
+ const tokenLengthNotSupported =
52
+ stringifiedTokenLength > 2500 && process . platform === 'win32' ;
53
+
54
+ if ( tokenLengthNotSupported ) {
55
+ // TODO manage this specific error appropriately
56
+ return false ;
57
+ }
58
+
50
59
await keytar . setPassword (
51
60
this . credentialsSection ,
52
61
this . account ,
Original file line number Diff line number Diff line change @@ -44,7 +44,15 @@ export function token2IToken(token: Token): IToken {
44
44
( token . id_token && jwt_decode ( token . id_token ) ) || { } ;
45
45
46
46
return {
47
- idToken : token . id_token ,
47
+ /*
48
+ * ".id_token" is already decoded for account details above
49
+ * so we probably don't need to keep it around as "idToken".
50
+ * If we do, and subsequently try to store it with
51
+ * Windows Credential Manager (WCM) it's probable we'll
52
+ * exceed WCMs' 2500 password character limit breaking
53
+ * our auth functionality
54
+ */
55
+ // ! idToken: token.id_token,
48
56
expiresIn : token . expires_in ,
49
57
expiresAt : token . expires_in
50
58
? Date . now ( ) + token . expires_in * 1000
You can’t perform that action at this time.
0 commit comments