Repository navigation
feat(offchain-manager): add Universal Usernames connection methods - #51
Closed
HAPPYS1NGH wants to merge 3 commits into
Closed
HAPPYS1NGH wants to merge 3 commits into
HAPPYS1NGH wants to merge 3 commits into
Conversation
Adds typed methods for the offchain-manager Universal Usernames API to the flat offchain client: reads use an owner SIWE session, every change is signed by the owner's wallet with a fresh server nonce and a resource bound to the parent, action and expected revision. The wallet comes from the new `provider` config option (viem, ethers or WalletProvider, as in the avatar SDK) or a per-call override. API errors map to NotParentOwnerError, ConnectionRevisionConflictError, EndpointValidationError or a generic UniversalUsernamesError with code, status, details and a retryable hint. The mapping applies only to the new methods and never keeps the AxiosError, whose config holds the auth token and the endpoint credential. Types for profiles and validation reports come from `@thenamespace/universal-usernames` (type-only, no runtime import). EIP-4361 messages are formatted like viem's createSiweMessage so Unicode parent names stay signable; `@noble/hashes` provides keccak for namehash and EIP-55 checksums. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019oGqmTa3TRAEt8JZnPPL6p
…s and errors msw tests for every method's path, method, body and auth header; the operation signature's statement, resource URN, chain, server nonce and expiry, verified with viem the way the API verifies them; session reuse and renewal; wallet adapters and chain checks; 403/404/409/412/422/429/503 error mapping; and that no response, error or fixture carries the endpoint credential or the auth token. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019oGqmTa3TRAEt8JZnPPL6p
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019oGqmTa3TRAEt8JZnPPL6p
Contributor
Author
|
Closing: Universal Usernames won't ship an SDK package, docs or skill changes for now. Branch kept. |
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.
Changes
getUsernameConnection,inspectUsernameParent,validateUsernameEndpoint,saveUsernameConnection,activateUsernameConnection,previewUsername,rotateUsernameCredential,pauseUsernameConnection,resumeUsernameConnection,disconnectUsernameConnection,getUsernameConnectionEvents) pluscreateUsernameOwnerSession, so brands can run the whole setup from code.providerconfig option (viemWalletClient, ethersSignerorWalletProvider, same adapter pattern as the avatar SDK). Reads sign one SIWE session and reuse it in memory until it nears expiry or the wallet switches account; a session or wallet can also be passed per call.GET /api/v1/auth/nonce: statementAuthorize <action> for Universal Usernames on <parentName>, chain 1 or 11155111, 5-minute expiry, resourceurn:namespace:uun:<parentNode>:<action>:<expectedRevision>, sent asx-auth-token: siwe:<base64 utf8 message>.<base64 utf8 signature>.offchain-manager.namespace.ninja/staging.…), withsiweDomainandsiweUrioverrides for custom deployments.UniversalUsernamesError(code,status,details,retryableforUPSTREAM_UNAVAILABLEandRATE_LIMITED) withNotParentOwnerError,ConnectionRevisionConflictErrorandEndpointValidationErrorsubclasses. The mapping applies only to the new methods and drops the AxiosError, whose config holds the auth token and the endpoint credential.UsernameConnection,UsernameConnectionStatus,UsernameConnectionRevision,ParentInspection,UsernameConnectionEvent,UsernameValidationReportand request types); report and issue types are re-exported from@thenamespace/universal-usernamesas type-only imports.Notes
@thenamespace/universal-usernames0.1.0). The API routes are in thenamespace/offchain-manager#61, not deployed yet. Docs: docs(universal-usernames): add integration guide, endpoint reference and adapter template docs#20, whose examples match these signatures.@thenamespace/universal-usernames0.1.0 first, then this package as 1.2.0 through the publish workflow (it bumps the version and changelog, so neither is changed here). The workflow already builds@thenamespace/*workspace dependencies before the package.@signinwithethereum/siwe(the avatar SDK's choice). That library checks messages against the EIP-4361 grammar, whose statement rule is ASCII-only, so it throws onAuthorize save for Universal Usernames on 🦊.eth. The output matches viem'screateSiweMessagebyte for byte, which is what offchain-manager parses; the tests parse and verify with viem.@noble/hashes^1.8.0 (keccak for namehash and EIP-55 checksums, already in the lockfile through siwe-parser; v1 because v2 is ESM-only),@thenamespace/universal-usernames^0.1.0 (types only, nothing is required at runtime), andviemas a dev dependency for tests (already in the lockfile through mint-manager).engines.node >=18.3.0for universal-usernames, which feat(universal-usernames): add profile schema, validator and adapter package #50's lockfile still listed as>=18.0.0.npm ciat the root; inpackages/offchain-manager:npm run build,npm test(94 passed, 36 before),npm run type-check,npx tsc --noEmit -p tsconfig.test.json(also enforces that response types have nocredentialfield); README sample type-checked against the source;packages/universal-usernames:npm run build,npm test(229 passed),npm run type-check.npm run lintandnpm run format, because eslint and prettier aren't installed or configured in this repo (true before this change). No live API test: the routes aren't deployed.siweVerifyand the operation signature decoder useatob, which reads the token as Latin-1. ASCII names work, but a Unicode parent name's statement and signature won't match until it decodes UTF-8 (Buffer.from(part, 'base64').toString('utf8')).🤖 Generated with Claude Code
https://claude.ai/code/session_019oGqmTa3TRAEt8JZnPPL6p