Skip to content

Commit b937cdf

Browse files
✨ adds identity provider token management
Adds methods for managing identity provider access tokens. This provides a centralized location within the SDK for storing these tokens, which may be generated during OpenID Connect single sign-on experiences.
1 parent 8c7278d commit b937cdf

2 files changed

Lines changed: 46 additions & 0 deletions

File tree

codegen/templates/api/Tokens.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ class Tokens {
3030
private impersonationTokenCookieName = '.impersonation-token'
3131
private refreshTokenCookieName = '.refresh-token'
3232
private identityTokenCookieName = '.identity-token'
33+
private identityProviderAccessTokenCookieName = '.idp-access-token'
3334

3435
private accessToken?: string = null
3536
private impersonationToken?: string = null
3637
private refreshToken?: string = null
3738
private identityToken?: string = null
39+
private identityProviderAccessToken?: string = null
3840

3941
/**
4042
* @ignore
@@ -145,6 +147,27 @@ class Tokens {
145147
: cookies.remove(this.identityTokenCookieName)
146148
}
147149

150+
/**
151+
* Manage Identity Provider Tokens
152+
*/
153+
public GetIdpAccessToken(): string | undefined {
154+
return isServer
155+
? this.identityProviderAccessToken
156+
: cookies.get(this.identityProviderAccessTokenCookieName)
157+
}
158+
159+
public SetIdpAccessToken(token: string): void {
160+
isServer
161+
? (this.identityProviderAccessToken = token)
162+
: cookies.set(this.identityProviderAccessTokenCookieName, token)
163+
}
164+
165+
public RemoveIdpAccessToken(): void {
166+
isServer
167+
? (this.identityProviderAccessToken = null)
168+
: cookies.remove(this.identityProviderAccessTokenCookieName)
169+
}
170+
148171
/**
149172
* If no token is provided will attempt to get and validate token
150173
* stored in sdk. If token is invalid or missing it will also attempt

src/api/Tokens.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ class Tokens {
3030
private impersonationTokenCookieName = '.impersonation-token'
3131
private refreshTokenCookieName = '.refresh-token'
3232
private identityTokenCookieName = '.identity-token'
33+
private identityProviderAccessTokenCookieName = '.idp-access-token'
3334

3435
private accessToken?: string = null
3536
private impersonationToken?: string = null
3637
private refreshToken?: string = null
3738
private identityToken?: string = null
39+
private identityProviderAccessToken?: string = null
3840

3941
/**
4042
* @ignore
@@ -145,6 +147,27 @@ class Tokens {
145147
: cookies.remove(this.identityTokenCookieName)
146148
}
147149

150+
/**
151+
* Manage Identity Provider Tokens
152+
*/
153+
public GetIdpAccessToken(): string | undefined {
154+
return isServer
155+
? this.identityProviderAccessToken
156+
: cookies.get(this.identityProviderAccessTokenCookieName)
157+
}
158+
159+
public SetIdpAccessToken(token: string): void {
160+
isServer
161+
? (this.identityProviderAccessToken = token)
162+
: cookies.set(this.identityProviderAccessTokenCookieName, token)
163+
}
164+
165+
public RemoveIdpAccessToken(): void {
166+
isServer
167+
? (this.identityProviderAccessToken = null)
168+
: cookies.remove(this.identityProviderAccessTokenCookieName)
169+
}
170+
148171
/**
149172
* If no token is provided will attempt to get and validate token
150173
* stored in sdk. If token is invalid or missing it will also attempt

0 commit comments

Comments
 (0)