Skip to content

Commit 62be127

Browse files
fix: access and metadata token refresh
1 parent 473382e commit 62be127

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

packages/seedless-onboarding-controller/src/SeedlessOnboardingController.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ const seedlessOnboardingMetadata: StateMetadata<SeedlessOnboardingControllerStat
130130
// stays outside of vault as this token is accessed by the metadata service
131131
// before the vault is created or unlocked.
132132
metadataAccessToken: {
133-
persist: false,
133+
persist: true,
134134
anonymous: true,
135135
},
136136
encryptedSeedlessEncryptionKey: {
@@ -229,22 +229,22 @@ export class SeedlessOnboardingController<EncryptionKey> extends BaseController<
229229
* @param params.socialLoginEmail - The user email from Social login.
230230
* @param params.refreshToken - refresh token for refreshing expired nodeAuthTokens.
231231
* @param params.revokeToken - revoke token for revoking refresh token and get new refresh token and new revoke token.
232-
* @param params.accessToken - access token for pairing with profile sync auth service and to access other services.
233-
* @param params.metadataAccessToken - metadata access token for accessing the metadata service before the vault is created or unlocked.
232+
* @param params.accessToken - Access token for pairing with profile sync auth service and to access other services.
233+
* @param params.metadataAccessToken - Metadata access token for accessing the metadata service before the vault is created or unlocked.
234234
* @param params.skipLock - Optional flag to skip acquiring the controller lock. (to prevent deadlock in case the caller already acquired the lock)
235235
* @returns A promise that resolves to the authentication result.
236236
*/
237237
async authenticate(params: {
238238
idTokens: string[];
239+
accessToken: string;
240+
metadataAccessToken: string;
239241
authConnection: AuthConnection;
240242
authConnectionId: string;
241243
userId: string;
242244
groupedAuthConnectionId?: string;
243245
socialLoginEmail?: string;
244246
refreshToken?: string;
245247
revokeToken?: string;
246-
accessToken?: string;
247-
metadataAccessToken?: string;
248248
skipLock?: boolean;
249249
}) {
250250
const doAuthenticateWithNodes = async () => {
@@ -1677,10 +1677,12 @@ export class SeedlessOnboardingController<EncryptionKey> extends BaseController<
16771677
connection: this.state.authConnection,
16781678
refreshToken,
16791679
});
1680-
const { idTokens } = res;
1680+
const { idTokens, accessToken, metadataAccessToken } = res;
16811681
// re-authenticate with the new id tokens to set new node auth tokens
16821682
await this.authenticate({
16831683
idTokens,
1684+
accessToken,
1685+
metadataAccessToken,
16841686
authConnection: this.state.authConnection,
16851687
authConnectionId: this.state.authConnectionId,
16861688
groupedAuthConnectionId: this.state.groupedAuthConnectionId,

packages/seedless-onboarding-controller/src/types.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,11 @@ export type ToprfKeyDeriver = {
236236
export type RefreshJWTToken = (params: {
237237
connection: AuthConnection;
238238
refreshToken: string;
239-
}) => Promise<{ idTokens: string[] }>;
239+
}) => Promise<{
240+
idTokens: string[];
241+
accessToken: string;
242+
metadataAccessToken: string;
243+
}>;
240244

241245
export type RevokeRefreshToken = (params: {
242246
connection: AuthConnection;

0 commit comments

Comments
 (0)