Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(clerk-js): Drop session tokens legacy integration handling #2190

Merged
merged 2 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/little-apes-notice.md
Original file line number Diff line number Diff line change
@@ -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.
33 changes: 0 additions & 33 deletions packages/clerk-js/src/core/resources/Session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> => {
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;
Expand Down Expand Up @@ -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);

Expand Down
Loading