@@ -22,16 +22,18 @@ export type StoredOAuthTokens = Omit<TokenResponse, "expires_in"> & {
2222
2323export interface SessionAuth {
2424 url : string ;
25- sessionToken : string ;
25+ token : string ;
2626}
2727
2828export interface OAuthData {
2929 oauthClientRegistration ?: ClientRegistrationResponse ;
3030 oauthTokens ?: StoredOAuthTokens ;
3131}
3232
33- export type SessionAuthMap = Record < string , SessionAuth > ;
34- export type OAuthDataMap = Record < string , OAuthData > ;
33+ // TODO not sure if I love this bulk saving of data
34+ // How do we clear out outdated info? How do we deal with race conditions across windows?
35+ type SessionAuthMap = Record < string , SessionAuth > ;
36+ type OAuthDataMap = Record < string , OAuthData > ;
3537
3638interface OAuthCallbackData {
3739 state : string ;
@@ -59,7 +61,7 @@ export class SecretsManager {
5961 // Initialize previous session tokens
6062 this . getSessionAuthMap ( ) . then ( ( map ) => {
6163 for ( const [ label , auth ] of Object . entries ( map ) ) {
62- this . previousSessionTokens . set ( label , auth . sessionToken ) ;
64+ this . previousSessionTokens . set ( label , auth . token ) ;
6365 }
6466 } ) ;
6567 }
@@ -162,7 +164,7 @@ export class SecretsManager {
162164 ) : Disposable {
163165 return this . onDidChangeSessionAuthMap ( async ( map ) => {
164166 const auth = map [ label ] ;
165- const newToken = auth ?. sessionToken ?? "" ;
167+ const newToken = auth ?. token ?? "" ;
166168 const previousToken = this . previousSessionTokens . get ( label ) ?? "" ;
167169
168170 // Only fire listener if session token actually changed
@@ -199,15 +201,23 @@ export class SecretsManager {
199201 */
200202 public async getSessionToken ( label : string ) : Promise < string | undefined > {
201203 const map = await this . getSessionAuthMap ( ) ;
202- return map [ label ] ?. sessionToken ;
204+ return map [ label ] ?. token ;
205+ }
206+
207+ /**
208+ * Get URL for a specific deployment.
209+ */
210+ public async getUrl ( label : string ) : Promise < string | undefined > {
211+ const map = await this . getSessionAuthMap ( ) ;
212+ return map [ label ] ?. url ;
203213 }
204214
205215 /**
206216 * Set session token for a specific deployment.
207217 */
208218 public async setSessionToken (
209219 label : string ,
210- auth : { url : string ; sessionToken : string } | undefined ,
220+ auth : { url : string ; token : string } | undefined ,
211221 ) : Promise < void > {
212222 await this . updateSessionAuthMap ( ( map ) => {
213223 if ( auth === undefined ) {
@@ -406,7 +416,7 @@ export class SecretsManager {
406416 const sessionAuthMap : SessionAuthMap = {
407417 [ label ] : {
408418 url : url ,
409- sessionToken : oldToken ,
419+ token : oldToken ,
410420 } ,
411421 } ;
412422
0 commit comments