Skip to content

add request ids to iframe stamper #467

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

Merged
merged 3 commits into from
Jan 23, 2025
Merged

Conversation

andrewkmin
Copy link
Collaborator

@andrewkmin andrewkmin commented Jan 7, 2025

Summary & Motivation

$title

iframe counterpart: tkhq/frames#59

This mainly serves the case where there are concurrent, or serial, requests. Request IDs are used to disambiguate between multiple requests.

Latency implications: roughly ~4 seconds for 100 parallel signing requests, compared to ~0.7 seconds if signing 100 payloads using an im-memory API key stamper. The difference comes in overhead cost of the iframe communications.

How I Tested These Changes

Did you add a changeset?

  • yes

If updating one of our packages, you'll likely need to add a changeset to your PR. To do so, run pnpm changeset. pnpm changeset will generate a file where you should write a human friendly message about the changes. Note how this (example) includes the package name (should be auto added by the command) along with the type of semver change (major.minor.patch) (which you should set).

These changes will be used at release time to determine what packages to publish and how to bump their version. For more context see this comment.

}

function generateUUID(): string {
return crypto.randomUUID();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The iframe stamper will be used strictly in the web browser context, so crypto should be an available resource. randomUUID is pretty readily available for most modern web browsers.

If we're worried about compatibility, there's an implementation that relies on the older getRandomValues (see https://stackoverflow.com/a/2117523)

Copy link

codesandbox-ci bot commented Jan 7, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@andrewkmin andrewkmin force-pushed the andrew/iframe-idempotency branch from fa1f11c to dbe3d37 Compare January 23, 2025 15:43
@andrewkmin andrewkmin merged commit e988ba5 into main Jan 23, 2025
5 checks passed
@andrewkmin andrewkmin deleted the andrew/iframe-idempotency branch January 23, 2025 17:57
@andrewkmin andrewkmin mentioned this pull request Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants