feat: add requestAttributes for signed user attributes#85
Merged
Conversation
899b643 to
15bf417
Compare
3247078 to
9fcfdf9
Compare
9fcfdf9 to
e1ebd89
Compare
There was a problem hiding this comment.
Pull request overview
This pull request adds a requestAttributes method to AuthClient that enables requesting signed user attributes from the identity provider via a JSON-RPC interface. The method can be called during login or separately, allowing attributes like email and name to be requested and verified with cryptographic signatures.
Changes:
- Added
requestAttributesmethod toAuthClientclass for requesting signed user attributes with optional custom nonce - Added
SignedAttributesinterface to represent the signed attribute response (data and signature as Uint8Array) - Exported
OPENID_PROVIDER_URLSconstant to support documentation examples - Implemented base64 encoding/decoding helper functions with fallback support for native Uint8Array methods
- Added comprehensive tests covering normal flow, custom nonce, random nonce generation, error handling, and validation
- Updated README and quick-start documentation with usage examples
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/client/auth-client.ts | Added requestAttributes method, SignedAttributes interface, and base64 helper functions; exported OPENID_PROVIDER_URLS |
| tests/client/auth-client.test.ts | Added mocking for sendRequest method and comprehensive tests for requestAttributes functionality |
| README.md | Added documentation section with usage examples for requesting user attributes |
| docs/src/content/docs/quick-start.md | Updated quick-start guide to show parallel login and attribute request pattern |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f76aa6f to
f6ea3fe
Compare
cbb903d to
dbad5ab
Compare
c0bf998 to
d92b50e
Compare
dbad5ab to
aa0e82b
Compare
aterga
reviewed
Apr 15, 2026
aterga
reviewed
Apr 15, 2026
aterga
reviewed
Apr 15, 2026
aterga
reviewed
Apr 15, 2026
aterga
reviewed
Apr 15, 2026
aa0e82b to
259e84f
Compare
13d4689 to
dbc54d2
Compare
sea-snake
added a commit
that referenced
this pull request
Apr 16, 2026
Reorganizes `auth-client.ts` for clarity: - Class moved before free functions (public API is the first thing you see) - Within the class: constructor → public methods → private methods - Free functions ordered: key helpers → chain helpers → storage helpers → migration - Removed unused `#key` field - Renamed `#createOptions` to `#options` - Simplified `#hydrate()` — delegates key restoration and migration to `restoreKey()` which calls `migrateFromLocalStorage()` as a fallback - Cleaned up JSDoc throughout - Removed `localStorage` try/catch wrappers (assumed always available) - Disabled `pnpm audit` CI workflow due to [pnpm/pnpm#11265](pnpm/pnpm#11265) --- Prev: #83 | Next: #85 --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Simplify internetIdentityCanisterId in quick-start (remove unnecessary branching) - Rename "user attributes" to "identity attributes" in README and JSDoc Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
dbc54d2 to
21622bc
Compare
The nonce parameter is now mandatory to enforce that it originates from the RP canister, preventing replay attacks from compromised frontends. README examples updated to use the nonce-based flow as the default pattern, with documentation of all implicit verification fields. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
aterga
approved these changes
Apr 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
requestAttributesmethod toAuthClientthat requests signed user attributes from the identity provider via the signer's JSON-RPC interface. Attributes can be requested in parallel with sign-in.The method requires a canister-issued
nonceto prevent replay attacks and bind attributes to a specific backend action. The signed attribute bundle also includesimplicit:originandimplicit:issued_at_timestamp_nsfor the backend canister to verify.The method sends an
ii-icrc3-attributesJSON-RPC request with the requested attribute keys and the provided nonce, and returns the base64-decodeddataandsignatureasUint8Array. Throws on error responses or invalid results.Breaking changes
AuthClient.login()is renamed toAuthClient.signIn().AuthClientLoginOptionsis renamed toAuthClientSignInOptions.Prev: #84