diff --git a/packages/core/src/api/apis/implementations/auth/google/GoogleAuth.ts b/packages/core/src/api/apis/implementations/auth/google/GoogleAuth.ts index d1d5da1a02..ccf99772fc 100644 --- a/packages/core/src/api/apis/implementations/auth/google/GoogleAuth.ts +++ b/packages/core/src/api/apis/implementations/auth/google/GoogleAuth.ts @@ -99,7 +99,7 @@ class GoogleAuth implements OAuthApi, OpenIdConnectApi { const normalizedScopes = GoogleAuth.normalizeScopes(scope); const session = await this.sessionManager.getSession({ optional: false, - scope: normalizedScopes, + scopes: normalizedScopes, }); return session.accessToken; } diff --git a/packages/core/src/api/apis/implementations/lib/AuthSessionManager/RefreshingAuthSessionManager.test.ts b/packages/core/src/api/apis/implementations/lib/AuthSessionManager/RefreshingAuthSessionManager.test.ts index 6841934357..8684c932b2 100644 --- a/packages/core/src/api/apis/implementations/lib/AuthSessionManager/RefreshingAuthSessionManager.test.ts +++ b/packages/core/src/api/apis/implementations/lib/AuthSessionManager/RefreshingAuthSessionManager.test.ts @@ -51,13 +51,13 @@ describe('RefreshingAuthSessionManager', () => { scopes: new Set(['a']), expired: false, }); - await manager.getSession({ scope: new Set(['a']) }); + await manager.getSession({ scopes: new Set(['a']) }); expect(createSession).toBeCalledTimes(1); - await manager.getSession({ scope: new Set(['a']) }); + await manager.getSession({ scopes: new Set(['a']) }); expect(createSession).toBeCalledTimes(1); - await manager.getSession({ scope: new Set(['b']) }); + await manager.getSession({ scopes: new Set(['b']) }); expect(createSession).toBeCalledTimes(2); }); @@ -77,11 +77,11 @@ describe('RefreshingAuthSessionManager', () => { expired: true, }); - await manager.getSession({ scope: new Set(['a']) }); + await manager.getSession({ scopes: new Set(['a']) }); expect(createSession).toBeCalledTimes(1); expect(refreshSession).toBeCalledTimes(1); - await manager.getSession({ scope: new Set(['a']) }); + await manager.getSession({ scopes: new Set(['a']) }); expect(createSession).toBeCalledTimes(1); expect(refreshSession).toBeCalledTimes(2); }); @@ -95,9 +95,9 @@ describe('RefreshingAuthSessionManager', () => { } as any); createSession.mockRejectedValueOnce(new Error('some error')); - await expect(manager.getSession({ scope: new Set(['a']) })).rejects.toThrow( - 'some error', - ); + await expect( + manager.getSession({ scopes: new Set(['a']) }), + ).rejects.toThrow('some error'); }); it('should not get optional session', async () => { diff --git a/packages/core/src/api/apis/implementations/lib/AuthSessionManager/RefreshingAuthSessionManager.ts b/packages/core/src/api/apis/implementations/lib/AuthSessionManager/RefreshingAuthSessionManager.ts index 147d9f4b49..34415ea615 100644 --- a/packages/core/src/api/apis/implementations/lib/AuthSessionManager/RefreshingAuthSessionManager.ts +++ b/packages/core/src/api/apis/implementations/lib/AuthSessionManager/RefreshingAuthSessionManager.ts @@ -70,17 +70,17 @@ export class RefreshingAuthSessionManager async getSession(options: { optional: false; - scope?: Set; + scopes?: Set; }): Promise; async getSession(options: { optional?: boolean; - scope?: Set; + scopes?: Set; }): Promise; async getSession(options: { optional?: boolean; - scope?: Set; + scopes?: Set; }): Promise { - if (this.sessionExistsAndHasScope(this.currentSession, options.scope)) { + if (this.sessionExistsAndHasScope(this.currentSession, options.scopes)) { const shouldRefresh = this.sessionShouldRefreshFunc(this.currentSession!); if (!shouldRefresh) { return this.currentSession!; @@ -122,7 +122,7 @@ export class RefreshingAuthSessionManager // We can call authRequester multiple times, the returned session will contain all requested scopes. this.currentSession = await this.connector.createSession( - this.getExtendedScope(options.scope), + this.getExtendedScope(options.scopes), ); return this.currentSession; } @@ -134,16 +134,16 @@ export class RefreshingAuthSessionManager private sessionExistsAndHasScope( session: AuthSession | undefined, - scope?: Set, + scopes?: Set, ): boolean { if (!session) { return false; } - if (!scope) { + if (!scopes) { return true; } const sessionScopes = this.sessionScopesFunc(session); - return hasScopes(sessionScopes, scope); + return hasScopes(sessionScopes, scopes); } private getExtendedScope(scopes?: Set) { diff --git a/packages/core/src/api/apis/implementations/lib/AuthSessionManager/types.ts b/packages/core/src/api/apis/implementations/lib/AuthSessionManager/types.ts index 440944cce0..5c5f700047 100644 --- a/packages/core/src/api/apis/implementations/lib/AuthSessionManager/types.ts +++ b/packages/core/src/api/apis/implementations/lib/AuthSessionManager/types.ts @@ -22,11 +22,11 @@ export type SessionManager = { getSession(options: { optional: false; - scope?: Set; + scopes?: Set; }): Promise; getSession(options: { optional?: boolean; - scope?: Set; + scopes?: Set; }): Promise; removeSession(): Promise;