From efab24b017b91b1629423697ef5f33903cdc5211 Mon Sep 17 00:00:00 2001 From: Dimitris Klouvas Date: Wed, 22 Nov 2023 17:24:58 +0200 Subject: [PATCH] chore(clerk-js): Drop session tokens legacy integration handling --- .changeset/little-apes-notice.md | 5 +++ .../clerk-js/src/core/resources/Session.ts | 33 ------------------- 2 files changed, 5 insertions(+), 33 deletions(-) create mode 100644 .changeset/little-apes-notice.md diff --git a/.changeset/little-apes-notice.md b/.changeset/little-apes-notice.md new file mode 100644 index 0000000000..7020f738c1 --- /dev/null +++ b/.changeset/little-apes-notice.md @@ -0,0 +1,5 @@ +--- +'@clerk/clerk-js': minor +--- + +Drop firebase legacy integration code and start using sessions/:sid/tokens/:template endpoint for the firebase tokens. diff --git a/packages/clerk-js/src/core/resources/Session.ts b/packages/clerk-js/src/core/resources/Session.ts index 8f6be3c598..a153414c41 100644 --- a/packages/clerk-js/src/core/resources/Session.ts +++ b/packages/clerk-js/src/core/resources/Session.ts @@ -136,35 +136,6 @@ export class Session extends BaseResource implements SessionResource { return `${template ? `${this.id}-${template}` : this.id}-${this.updatedAt.getTime()}`; } - #isLegacyIntegrationRequest = (template: string | undefined): boolean => { - return !!template && template.startsWith('integration_'); - }; - - #removeLegacyIntegrationPrefix = (template: string | undefined): string => { - return (template || '').replace('integration_', ''); - }; - - // Can be removed once `integration_firebase` are no longer supported - #handleLegacyIntegrationToken = async (options: GetTokenOptions): Promise => { - const { template, leewayInSeconds } = options; - const cachedEntry = SessionTokenCache.get({ tokenId: this.user!.id, audience: template }, leewayInSeconds); - if (cachedEntry) { - return cachedEntry.tokenResolver.then(res => res.getRawString()); - } - const tokenResolver = Token.create(this.user!.pathRoot + '/tokens', { - service: this.#removeLegacyIntegrationPrefix(template), - }); - SessionTokenCache.set({ - tokenId: this.user!.id, - audience: template, - tokenResolver, - }); - return tokenResolver.then(token => { - eventBus.dispatch(events.TokenUpdate, { token }); - return token.getRawString(); - }); - }; - protected fromJSON(data: SessionJSON | null): this { if (!data) { return this; @@ -200,10 +171,6 @@ export class Session extends BaseResource implements SessionResource { throw new Error('Leeway can not exceed the token lifespan (60 seconds)'); } - if (this.#isLegacyIntegrationRequest(template)) { - return this.#handleLegacyIntegrationToken({ template, leewayInSeconds, skipCache }); - } - const tokenId = this.#getCacheId(template); const cachedEntry = skipCache ? undefined : SessionTokenCache.get({ tokenId }, leewayInSeconds);