Skip to content

feat(js-sdk)!: Grant auth#405

Open
SeverinAlexB wants to merge 17 commits into
mainfrom
feat/grant-js-sdk
Open

feat(js-sdk)!: Grant auth#405
SeverinAlexB wants to merge 17 commits into
mainfrom
feat/grant-js-sdk

Conversation

@SeverinAlexB
Copy link
Copy Markdown
Collaborator

@SeverinAlexB SeverinAlexB commented May 27, 2026

Adds grant-backed auth support to the JS SDK to make it feature complete to the rust SDK.
Updates JS examples to make them work with the new SDK.

What changed

  • Added GrantAuthFlow bindings for starting, resuming, saving, polling, and awaiting grant-backed pubkyauth flows.
  • Added Pubky.startGrantAuthFlow(...) and Pubky.resumeGrantAuthFlow(...).
  • Added grant deep-link wrappers:
    • SigninGrantDeepLink
    • SignupGrantDeepLink
  • Added Session.exportSecret() and updated Pubky.restoreSession(...) to restore grant credentials by minting a fresh bearer.
  • Marked legacy cookie auth APIs/docs as deprecated where applicable.
  • Extracted shared InFlightGuard logic so auth flows reject overlapping async calls cleanly.
  • Updated JS SDK docs to prefer grant auth and direct signer signup(...) + signin(clientId).
  • Refreshed examples/javascript:
    • uses the local SDK package from the repo
    • removes npm script shortcuts in favor of explicit node <script>.mjs
    • renames the testnet smoke helper to 0-check-testnet.mjs
    • updates examples for grant-backed sessions and optional signup token handling

What this is not doing: It is not adding more examples or optimizing the examples really. This will be done in another task. See #401 .

Caveats

I am not 100% content with the API surface yet. Nonetheless at the moment, I rather ship something working than delay the project. In subsequent versions, we should optimize it further.

@SeverinAlexB SeverinAlexB marked this pull request as ready for review May 28, 2026 12:19
@SeverinAlexB SeverinAlexB requested a review from andrei-21 May 29, 2026 07:17
Copy link
Copy Markdown
Contributor

@andrei-21 andrei-21 left a comment

Choose a reason for hiding this comment

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

I reviewed Rust code. Later I will try to run JS code.

Comment thread pubky-sdk/bindings/js/src/actors/grant_auth_flow.rs
Comment thread pubky-sdk/bindings/js/src/actors/cookie_session.rs Outdated
Comment thread pubky-sdk/bindings/js/src/actors/in_flight.rs Outdated
@SeverinAlexB SeverinAlexB requested a review from andrei-21 May 29, 2026 12:07
Copy link
Copy Markdown
Contributor

@andrei-21 andrei-21 left a comment

Choose a reason for hiding this comment

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

I played with that, seems to work. Just a couple of comments to make the readme correct.

Comment thread pubky-sdk/bindings/js/pkg/README.md Outdated
Comment thread pubky-sdk/bindings/js/pkg/README.md Outdated
Comment thread pubky-sdk/bindings/js/pkg/README.md Outdated
@SeverinAlexB SeverinAlexB requested a review from andrei-21 May 29, 2026 15:27
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