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

Custom TTL for iframe #535

Merged
merged 5 commits into from
Mar 12, 2025
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
prettier
  • Loading branch information
moe-dev committed Mar 11, 2025
commit ddaa7d97acbe5e681faf16d3d6eb257c8f6ead25
9 changes: 7 additions & 2 deletions packages/iframe-stamper/src/index.ts
Original file line number Diff line number Diff line change
@@ -221,7 +221,9 @@ export class IframeStamper {
/**
* Inserts the iframe on the page and returns a promise resolving to the iframe's public key
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a bit of context on why dangerouslyOverrideIframeKeyTtl is named "dangerously" in this docstring.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotchu!

async init(dangerouslyOverrideIframeKeyTtl?: number | undefined): Promise<string> {
async init(
dangerouslyOverrideIframeKeyTtl?: number | undefined,
): Promise<string> {
return new Promise((resolve, reject) => {
this.container.appendChild(this.iframe);

@@ -236,7 +238,10 @@ export class IframeStamper {
}

this.iframe.contentWindow.postMessage(
{ type: IframeEventType.TurnkeyInitMessageChannel, dangerouslyOverrideIframeKeyTtl: dangerouslyOverrideIframeKeyTtl},
{
type: IframeEventType.TurnkeyInitMessageChannel,
dangerouslyOverrideIframeKeyTtl: dangerouslyOverrideIframeKeyTtl,
},
this.iframeOrigin,
[this.messageChannel.port2],
);
4 changes: 3 additions & 1 deletion packages/sdk-browser/src/sdk-client.ts
Original file line number Diff line number Diff line change
@@ -171,7 +171,9 @@ export class TurnkeyBrowserSDK {
iframeElementId: TurnkeyIframeElementId,
});

await this.stamper.init(params.dangerouslyOverrideIframeKeyTtl ?? undefined);
await this.stamper.init(
params.dangerouslyOverrideIframeKeyTtl ?? undefined,
);

return new TurnkeyIframeClient({
stamper: this.stamper,
3 changes: 2 additions & 1 deletion packages/sdk-react/src/contexts/TurnkeyContext.tsx
Original file line number Diff line number Diff line change
@@ -125,7 +125,8 @@ export const TurnkeyProvider: React.FC<TurnkeyProviderProps> = ({
),
iframeUrl: config.iframeUrl || "https://auth.turnkey.com",
...(config.dangerouslyOverrideIframeKeyTtl && {
dangerouslyOverrideIframeKeyTtl: config.dangerouslyOverrideIframeKeyTtl,
dangerouslyOverrideIframeKeyTtl:
config.dangerouslyOverrideIframeKeyTtl,
}),
iframeElementId: TurnkeyAuthIframeElementId,
});
Loading
Oops, something went wrong.