@dexterai/connect 0.26.3 → 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +185 -188
- package/dist/chunk-EMCGL64H.js +59 -0
- package/dist/{chunk-TLCQSAE5.js → chunk-T62F36N2.js} +2 -2
- package/dist/chunk-XKOVUW5P.js +1872 -0
- package/dist/connectionContract-QGRidIHM.d.ts +470 -0
- package/dist/index.d.ts +434 -10
- package/dist/index.js +816 -39
- package/dist/react.d.ts +69 -191
- package/dist/react.js +551 -490
- package/dist/server.d.ts +2 -1
- package/dist/server.js +80 -5
- package/dist/worldid.d.ts +2 -4
- package/dist/worldid.js +1 -1
- package/package.json +3 -2
- package/dist/chunk-XQ7RKJMI.js +0 -1126
- package/dist/signals-Dx090EYY.d.ts +0 -375
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<h1 align="center">@dexterai/connect</h1>
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
|
-
<strong>
|
|
8
|
+
<strong>Add Dexter identity, Wallet access, or governed agent authority to a web app.</strong>
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
11
|
<p align="center">
|
|
@@ -14,25 +14,19 @@
|
|
|
14
14
|
<a href="https://www.w3.org/TR/webauthn-2/"><img src="https://img.shields.io/badge/auth-passkey-00FF88" alt="Passkey"></a>
|
|
15
15
|
</p>
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
## One Dexter identity
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
Each signed-in person has one active Dexter identity and one canonical Dexter
|
|
20
|
+
Wallet. A full connection returns the Wallet and account session from the same
|
|
21
|
+
passkey ceremony. Connect asks the Dexter API to verify that exact pair before
|
|
22
|
+
the app receives account-owned data or actions.
|
|
20
23
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
it under on-chain limits. The user holds their own keys; only their passkey
|
|
25
|
-
moves funds, enforced on-chain. Composes
|
|
26
|
-
[`@dexterai/vault`](https://www.npmjs.com/package/@dexterai/vault).
|
|
24
|
+
The browser may remember earlier Wallet passkeys for recovery. That roster stays
|
|
25
|
+
inside Connect. The product action is **Use another Dexter Wallet**, which runs a
|
|
26
|
+
fresh passkey ceremony and replaces the active identity only after verification.
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
| Entry point | Runs in | What it gives you |
|
|
31
|
-
|---|---|---|
|
|
32
|
-
| `@dexterai/connect` | browser | framework-free core: `passkeyLogin`, `createWallet`, `continueWithDexter`, the wallet store, agent-spend controls |
|
|
33
|
-
| `@dexterai/connect/react` | browser | `<SignInWithDexter/>`, the branded wallet kit, hooks |
|
|
34
|
-
| `@dexterai/connect/server` | Node 18+, Workers, Vercel edge | `verifyDexterSession`: offline session verification |
|
|
35
|
-
| `@dexterai/connect/worldid` | browser | `<VerifyPersonhood/>` World ID proof-of-personhood button |
|
|
28
|
+
Agent authority always requires a separate owner grant. Creating or connecting a
|
|
29
|
+
Wallet grants no agent spending authority.
|
|
36
30
|
|
|
37
31
|
## Install
|
|
38
32
|
|
|
@@ -40,157 +34,207 @@ Four entry points cover the whole flow:
|
|
|
40
34
|
npm install @dexterai/connect @dexterai/vault react
|
|
41
35
|
```
|
|
42
36
|
|
|
43
|
-
`@solana/web3.js`
|
|
44
|
-
|
|
37
|
+
`@solana/web3.js` is optional and supports signing paths.
|
|
38
|
+
`@worldcoin/idkit` is optional and supports the World ID entry point.
|
|
45
39
|
|
|
46
|
-
##
|
|
40
|
+
## Entry points
|
|
41
|
+
|
|
42
|
+
| Import | Purpose |
|
|
43
|
+
|---|---|
|
|
44
|
+
| `@dexterai/connect` | Passkey ceremonies, hosted signing, lifecycle operations, and agent authority |
|
|
45
|
+
| `@dexterai/connect/react` | The canonical React control, hooks, and Dexter UI primitives |
|
|
46
|
+
| `@dexterai/connect/server` | Local verification of Dexter account sessions |
|
|
47
|
+
| `@dexterai/connect/worldid` | Optional World ID proof-of-personhood control |
|
|
48
|
+
|
|
49
|
+
## Canonical React integration
|
|
50
|
+
|
|
51
|
+
`useDexterConnection` is the controlled integration for a product header,
|
|
52
|
+
account menu, or connection screen. The host owns its account-session storage.
|
|
53
|
+
Connect owns the Wallet ceremony, pair verification, and display permissions.
|
|
47
54
|
|
|
48
55
|
```tsx
|
|
49
|
-
import {
|
|
50
|
-
|
|
51
|
-
function
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
import { useDexterConnection } from '@dexterai/connect/react';
|
|
57
|
+
|
|
58
|
+
function DexterControl({ loading, session }: Props) {
|
|
59
|
+
const dexter = useDexterConnection({
|
|
60
|
+
intent: 'wallet',
|
|
61
|
+
accountSession: loading
|
|
62
|
+
? { status: 'loading' }
|
|
63
|
+
: session
|
|
64
|
+
? {
|
|
65
|
+
status: 'authenticated',
|
|
66
|
+
accessToken: session.access_token,
|
|
67
|
+
}
|
|
68
|
+
: { status: 'signed_out' },
|
|
69
|
+
installAccountSession: async (next) => {
|
|
70
|
+
await auth.setSession({
|
|
71
|
+
access_token: next.accessToken,
|
|
72
|
+
refresh_token: next.refreshToken,
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
clearAccountSession: async () => {
|
|
76
|
+
await auth.signOut();
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
if (dexter.model.stage === 'checking') return <Spinner />;
|
|
81
|
+
if (dexter.model.stage === 'connect') {
|
|
82
|
+
return <button onClick={() => void dexter.connect()}>Connect Dexter</button>;
|
|
83
|
+
}
|
|
84
|
+
if (dexter.model.stage === 'repair') {
|
|
85
|
+
return <button onClick={() => void dexter.connect()}>Reconnect Dexter</button>;
|
|
86
|
+
}
|
|
87
|
+
if (dexter.model.stage === 'offline' || dexter.model.stage === 'error') {
|
|
88
|
+
return <button onClick={() => void dexter.retry()}>Try again</button>;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return <WalletMenu dexter={dexter} />;
|
|
60
92
|
}
|
|
61
93
|
```
|
|
62
94
|
|
|
63
|
-
|
|
64
|
-
the wallet chip: address plus **"$X.XX available."**
|
|
65
|
-
|
|
66
|
-
## Works on any website
|
|
67
|
-
|
|
68
|
-
The ceremony is not limited to dexter.cash. On a foreign origin, `passkeyLogin`
|
|
69
|
-
opens a hosted popup on `dexter.cash/connect`, runs the ceremony there, and
|
|
70
|
-
posts the result back to your page. A browser-stamped hello/ack binds the exact
|
|
71
|
-
popup window, hosted origin, caller origin, request nonce, and requested
|
|
72
|
-
operation; the caller-origin may be any HTTPS website and is not allowlisted.
|
|
73
|
-
The default `transport: 'auto'` picks the right mode; `'popup'` and `'inline'`
|
|
74
|
-
force it.
|
|
75
|
-
|
|
76
|
-
The connected `passkeySigner.signOperation(rawOperation)` follows the same
|
|
77
|
-
cross-origin rule. On an unrelated website it opens the pinned Dexter consent
|
|
78
|
-
window and sends the raw operation plus the selected vault identity only after
|
|
79
|
-
the exact hello/ack handshake. Those bytes are structured-cloned in a
|
|
80
|
-
`sign-request`; they are never put in the URL. The Dexter window displays the
|
|
81
|
-
requesting origin and operation-specific consent before returning the
|
|
82
|
-
on-chain-ready assertion bytes.
|
|
83
|
-
|
|
84
|
-
WebAuthn challenge and verification calls are pinned to
|
|
85
|
-
`https://api.dexter.cash`. The legacy `apiBase` option remains source-compatible
|
|
86
|
-
only for that exact value (an optional trailing slash is normalized); any other
|
|
87
|
-
server fails before a popup, fetch, or authenticator call. `apiBase` is never
|
|
88
|
-
placed in the hosted popup URL. The legacy `connectHost` option is likewise
|
|
89
|
-
compatibility-only and may name only `https://dexter.cash/connect`; this pins
|
|
90
|
-
the credential-handling window without restricting the embedding website.
|
|
95
|
+
The host callbacks are part of the identity transition:
|
|
91
96
|
|
|
92
|
-
|
|
93
|
-
|
|
97
|
+
- `installAccountSession` receives the session from the verified ceremony. The
|
|
98
|
+
callback should resolve only after the host store publishes that exact access
|
|
99
|
+
token.
|
|
100
|
+
- `clearAccountSession` removes that host session during **Disconnect Dexter**.
|
|
101
|
+
- `accountSession` maps the host store back into `loading`, `signed_out`, or
|
|
102
|
+
`authenticated` with an access token.
|
|
94
103
|
|
|
95
|
-
|
|
96
|
-
|
|
104
|
+
If account installation fails, Connect restores the previous active Wallet. The
|
|
105
|
+
new identity stays hidden until the host session is installed.
|
|
106
|
+
|
|
107
|
+
## Integration intents
|
|
108
|
+
|
|
109
|
+
Choose one intent for each control.
|
|
110
|
+
|
|
111
|
+
| Intent | Capabilities requested | Ready state |
|
|
112
|
+
|---|---|---|
|
|
113
|
+
| `identity` | `identity` | Exact Wallet/account pair is bound |
|
|
114
|
+
| `wallet` | `identity`, `wallet.read`, `wallet.use` | Owner Wallet is present; account content still requires `bound` |
|
|
115
|
+
| `agent` | `identity`, `wallet.read`, `agent.authority` | Exact pair is bound; authority is granted in a separate owner flow |
|
|
116
|
+
|
|
117
|
+
`wallet.use` means the owner can use their own Wallet in the current app.
|
|
118
|
+
`agent.authority` means the app may offer a governed grant for an agent. The two
|
|
119
|
+
permissions are separate.
|
|
120
|
+
|
|
121
|
+
## Stage and permission model
|
|
122
|
+
|
|
123
|
+
Render from `dexter.model`, rather than inferring connection from a cached Wallet
|
|
124
|
+
or account token.
|
|
125
|
+
|
|
126
|
+
| Stage | Product response |
|
|
127
|
+
|---|---|
|
|
128
|
+
| `connect` | Offer the configured Dexter connection action |
|
|
129
|
+
| `checking` | Keep private content closed while the exact pair is verified |
|
|
130
|
+
| `ready` | Render only the fields enabled in `model.permissions` |
|
|
131
|
+
| `repair` | Offer the fresh passkey reconnect path |
|
|
132
|
+
| `offline` | Keep private Wallet and account content closed; offer retry |
|
|
133
|
+
| `error` | Show a concise error and offer retry |
|
|
134
|
+
|
|
135
|
+
The permission fields are:
|
|
136
|
+
|
|
137
|
+
| Field | Meaning |
|
|
138
|
+
|---|---|
|
|
139
|
+
| `walletIdentityVisible` | The active Wallet identity may be shown |
|
|
140
|
+
| `walletDataVisible` | Wallet balances and related data may be shown |
|
|
141
|
+
| `ownerWalletUseEnabled` | The owner may use this Wallet in the current app |
|
|
142
|
+
| `accountContentVisible` | The API verified `bound`; account-owned content may be shown |
|
|
143
|
+
| `agentAuthorityVisible` | A bound `agent` integration may present agent-authority controls |
|
|
144
|
+
|
|
145
|
+
Only `bound` unlocks account profile, roles, credit, servers, or other
|
|
146
|
+
account-owned content. A conflict enters the repair stage with private account
|
|
147
|
+
access closed.
|
|
148
|
+
|
|
149
|
+
## Lifecycle actions
|
|
150
|
+
|
|
151
|
+
The canonical control presents three identity actions:
|
|
152
|
+
|
|
153
|
+
| Action | Effect |
|
|
154
|
+
|---|---|
|
|
155
|
+
| **Use another Dexter Wallet** | Runs a fresh ceremony and keeps the replacement hidden until the API verifies the pair and the host installs the matching account session |
|
|
156
|
+
| **Disconnect Dexter** | Clears the host account session and active Wallet; the passkey remains on the device for a later sign-in |
|
|
157
|
+
| **Remove from this device** | Requires explicit confirmation, removes the local Wallet record, and asks the browser to remove its passkey |
|
|
158
|
+
|
|
159
|
+
Connect keeps the browser Wallet roster, raw switching methods, and partial
|
|
160
|
+
Wallet/account disconnects inside its recovery plumbing.
|
|
97
161
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
162
|
+
## Framework-neutral transition
|
|
163
|
+
|
|
164
|
+
Apps without React can use the same full transition directly:
|
|
101
165
|
|
|
102
166
|
```ts
|
|
103
|
-
import {
|
|
167
|
+
import {
|
|
168
|
+
connectDexterIdentity,
|
|
169
|
+
disconnectDexterIdentity,
|
|
170
|
+
} from '@dexterai/connect';
|
|
104
171
|
|
|
105
|
-
const result = await
|
|
172
|
+
const result = await connectDexterIdentity({
|
|
106
173
|
transport: 'auto',
|
|
107
|
-
|
|
174
|
+
installAccountSession: (session) => auth.setSession(session),
|
|
108
175
|
});
|
|
109
176
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
result.vault.userHandle,
|
|
114
|
-
result.vault.walletLabel ?? undefined,
|
|
115
|
-
result.vault.credentialId,
|
|
116
|
-
);
|
|
117
|
-
}
|
|
177
|
+
await disconnectDexterIdentity({
|
|
178
|
+
clearAccountSession: () => auth.signOut(),
|
|
179
|
+
});
|
|
118
180
|
```
|
|
119
181
|
|
|
120
|
-
`
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
182
|
+
`connectDexterIdentity` keeps the passkey result provisional, verifies its exact
|
|
183
|
+
Wallet/account relation, then publishes the Wallet and asks the host to install
|
|
184
|
+
the matching account session.
|
|
185
|
+
|
|
186
|
+
## Hosted ceremonies
|
|
187
|
+
|
|
188
|
+
On another HTTPS origin, Connect opens the ceremony on `dexter.cash/connect` and
|
|
189
|
+
returns the result to the calling app. The browser handshake binds the popup,
|
|
190
|
+
hosted origin, caller origin, nonce, and requested operation. The hosted window
|
|
191
|
+
also handles consent for Wallet signing.
|
|
125
192
|
|
|
126
|
-
|
|
193
|
+
WebAuthn challenge and verification calls use `https://api.dexter.cash`. The
|
|
194
|
+
default `transport: 'auto'` selects inline or popup transport. Integrators can
|
|
195
|
+
force `popup` or `inline` when their environment requires it.
|
|
196
|
+
|
|
197
|
+
## Server verification
|
|
127
198
|
|
|
128
199
|
```ts
|
|
129
200
|
import { createDexterClient } from '@dexterai/connect/server';
|
|
130
201
|
|
|
131
|
-
const dexter = createDexterClient();
|
|
202
|
+
const dexter = createDexterClient();
|
|
132
203
|
|
|
133
204
|
export async function handler(req: Request) {
|
|
134
205
|
const auth = await dexter.authenticateRequest(req);
|
|
135
206
|
if (!auth.isSignedIn) return new Response('unauthorized', { status: 401 });
|
|
136
|
-
auth.
|
|
137
|
-
|
|
138
|
-
|
|
207
|
+
if (!auth.userHandle) {
|
|
208
|
+
return new Response('wallet identity required', { status: 403 });
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
auth.userHandle; // stable Dexter Wallet principal
|
|
212
|
+
auth.vaultAddress; // Wallet capability
|
|
213
|
+
auth.sub; // account subject
|
|
214
|
+
auth.claims; // verified JWT payload
|
|
139
215
|
}
|
|
140
216
|
```
|
|
141
217
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
network (measured at ~0.6ms). The algorithm list is pinned to ES256, and
|
|
145
|
-
issuer plus audience are always checked. `verifyDexterSession(token, options)`
|
|
146
|
-
does the same for a bare token string, and `jwtKey` accepts a public JWK for
|
|
147
|
-
fully networkless deployments.
|
|
148
|
-
|
|
149
|
-
## Hook (full control)
|
|
150
|
-
|
|
151
|
-
```tsx
|
|
152
|
-
import { useSignInWithDexter } from '@dexterai/connect/react';
|
|
153
|
-
|
|
154
|
-
const c = useSignInWithDexter();
|
|
155
|
-
await c.signIn(); // run the passkey ceremony
|
|
156
|
-
c.status; // idle -> pending -> done -> error
|
|
157
|
-
c.vaultAddress; // the Dexter Wallet address (base58)
|
|
158
|
-
c.usdcBalance; // USD available (via Dexter's RPC), or null
|
|
159
|
-
c.disconnect();
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
| Field | What it is |
|
|
163
|
-
|---|---|
|
|
164
|
-
| `signIn()` / `disconnect()` | run the passkey ceremony / clear state |
|
|
165
|
-
| `status` / `isVaultConnected` | `idle->pending->done->error` / connected flag |
|
|
166
|
-
| `session` | auth session tokens (camelCase) |
|
|
167
|
-
| `vaultAddress` / `vaultPda` | the Dexter Wallet address / PDA |
|
|
168
|
-
| `usdcBalance` / `refreshBalance()` | USD available, best-effort via Dexter's RPC |
|
|
169
|
-
| `vault` / `credentialId` / `error` | raw vault payload / credential id / typed error |
|
|
218
|
+
The server entry verifies ES256 signatures against Dexter's JWKS and checks the
|
|
219
|
+
issuer and audience. `verifyDexterSession` verifies a token directly.
|
|
170
220
|
|
|
171
|
-
##
|
|
221
|
+
## Wallet creation and recovery
|
|
172
222
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
the
|
|
223
|
+
`createWallet` creates an owner Wallet and passkey. Agent authority remains a
|
|
224
|
+
later, explicit owner action. `recoverWallet` runs a fresh Wallet ceremony for a
|
|
225
|
+
device that already holds a Dexter passkey. Product integrations should route
|
|
226
|
+
full account connection through `useDexterConnection` or
|
|
227
|
+
`connectDexterIdentity`, so the account and Wallet are verified together.
|
|
178
228
|
|
|
179
|
-
## Agent
|
|
229
|
+
## Agent authority
|
|
180
230
|
|
|
181
|
-
|
|
231
|
+
Agent integrations build, present, and stage a separate owner grant. The grant
|
|
232
|
+
can include x402 payment rules or other governed actions. It is bound to the
|
|
233
|
+
selected Wallet and remains revocable.
|
|
182
234
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
enableAgentSpend, // the on switch
|
|
187
|
-
revokeAgentSpend, // the off switch
|
|
188
|
-
createPasskeySigner, // @dexterai/vault guest signer for x402 / tab flows
|
|
189
|
-
} from '@dexterai/connect';
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
The verbs are framework-free and take `apiOrigin` as a parameter; the SDK
|
|
193
|
-
reads no environment variables.
|
|
235
|
+
Key helpers include `buildAgentAuthorityRequest`, `beginAgentAuthority`,
|
|
236
|
+
`stageAgentAuthority`, and `readAgentAuthority`. The bounded x402 helpers provide
|
|
237
|
+
the equivalent hosted setup path for x402-only grants.
|
|
194
238
|
|
|
195
239
|
## World ID
|
|
196
240
|
|
|
@@ -200,66 +244,19 @@ import { VerifyPersonhood } from '@dexterai/connect/worldid';
|
|
|
200
244
|
<VerifyPersonhood onSuccess={(proof) => sendToYourVerifier(proof)} />
|
|
201
245
|
```
|
|
202
246
|
|
|
203
|
-
`useVerifyPersonhood` is the headless
|
|
247
|
+
`useVerifyPersonhood` is the headless form. This entry requires the optional
|
|
204
248
|
`@worldcoin/idkit` peer.
|
|
205
249
|
|
|
206
|
-
## Wallet-only sign-in (no account session)
|
|
207
|
-
|
|
208
|
-
`recoverWallet` re-points a browser at an existing Dexter Wallet — the wallet
|
|
209
|
-
IS the sign-in; nothing else is minted. Use it when your surface treats the
|
|
210
|
-
wallet as the identity (the dexter.cash header does exactly this):
|
|
211
|
-
|
|
212
|
-
```ts
|
|
213
|
-
import { recoverWallet } from '@dexterai/connect';
|
|
214
|
-
|
|
215
|
-
const outcome = await recoverWallet({ preferImmediate: true }); // fire on TAP, never on mount
|
|
216
|
-
if (outcome.ok) {
|
|
217
|
-
// outcome.vault.swigAddress, outcome.vault.walletLabel — the store + every
|
|
218
|
-
// useIdentity/useDexterWallet surface is already updated.
|
|
219
|
-
} else if (outcome.reason === 'no_credential') {
|
|
220
|
-
// this device has no wallet passkey → offer your create flow
|
|
221
|
-
} else if (outcome.reason === 'cancelled') {
|
|
222
|
-
// the user dismissed the sheet → stay silent
|
|
223
|
-
}
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
It returns a discriminated outcome instead of throwing: user cancel is a
|
|
227
|
-
normal result in WebAuthn, not an exception. `preferImmediate` uses Chrome
|
|
228
|
-
149+'s immediate UI mode to fast-fail instantly when the device holds no
|
|
229
|
-
passkey (no empty account-picker sheet); everywhere else it falls back to the
|
|
230
|
-
normal modal. Works from any website — off dexter.cash the ceremony runs in
|
|
231
|
-
the hosted popup automatically.
|
|
232
|
-
|
|
233
|
-
React: `<SignInWithDexter mode="recover" preferImmediate onRecovered={…} />`
|
|
234
|
-
(after a successful recover the element renders null — show identity with
|
|
235
|
-
`DexterWalletChip` over `useIdentity`), or `useSignInWithDexter().recover()`.
|
|
236
|
-
|
|
237
|
-
## Wallet lifecycle
|
|
238
|
-
|
|
239
|
-
- `createWallet` mints a brand-new named passkey + vault; `passkeyLogin` signs
|
|
240
|
-
an existing one in; `continueWithDexter` resumes a known wallet;
|
|
241
|
-
`recoverWallet` restores the wallet with no account session.
|
|
242
|
-
- The **wallet store** (`getActiveHandle`, `listWallets`, `switchWallet`,
|
|
243
|
-
`ejectActiveWallet`, `forgetWallet`, `subscribeWallet`) is the canonical
|
|
244
|
-
owner of the active-wallet handle. Read and write through it rather than
|
|
245
|
-
touching localStorage.
|
|
246
|
-
- The **WebAuthn Signal API** helpers (`renamePasskey`, `prunePasskey`,
|
|
247
|
-
`syncAcceptedPasskeys`, `passkeySignalSupport`) keep the OS keychain in sync
|
|
248
|
-
where the browser supports it.
|
|
249
|
-
- `resolveIdentity` combines the wallet handle with whatever account token you
|
|
250
|
-
pass in; `ceremonyPhaseLabel` gives shared copy for connecting-step UI;
|
|
251
|
-
`createAnonServerPolicy` builds the anonymous server policy for the signer.
|
|
252
|
-
|
|
253
250
|
## Peer dependencies
|
|
254
251
|
|
|
255
|
-
| Peer | Required |
|
|
252
|
+
| Peer | Required | Purpose |
|
|
256
253
|
|---|---|---|
|
|
257
|
-
| `react` >=18 | yes |
|
|
258
|
-
| `@dexterai/vault` ^0.43 | yes |
|
|
259
|
-
| `@solana/web3.js` | optional |
|
|
260
|
-
| `@worldcoin/idkit` | optional |
|
|
254
|
+
| `react` >=18 | yes | React and World ID entry points |
|
|
255
|
+
| `@dexterai/vault` ^0.43 | yes | Wallet signer and governed authority messages |
|
|
256
|
+
| `@solana/web3.js` | optional | Passkey and agent signing paths |
|
|
257
|
+
| `@worldcoin/idkit` | optional | World ID controls |
|
|
261
258
|
|
|
262
|
-
The
|
|
259
|
+
The server entry depends only on `jose`.
|
|
263
260
|
|
|
264
261
|
## License
|
|
265
262
|
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// src/base64.ts
|
|
2
|
+
function base64ToBytes(s) {
|
|
3
|
+
const bin = atob(s);
|
|
4
|
+
const out = new Uint8Array(bin.length);
|
|
5
|
+
for (let i = 0; i < bin.length; i += 1) out[i] = bin.charCodeAt(i);
|
|
6
|
+
return out;
|
|
7
|
+
}
|
|
8
|
+
function base64urlToBytes(s) {
|
|
9
|
+
const pad = s.length % 4 === 0 ? "" : "=".repeat(4 - s.length % 4);
|
|
10
|
+
const b64 = s.replace(/-/g, "+").replace(/_/g, "/") + pad;
|
|
11
|
+
return base64ToBytes(b64);
|
|
12
|
+
}
|
|
13
|
+
function bytesToBase64(bytes) {
|
|
14
|
+
let bin = "";
|
|
15
|
+
for (let i = 0; i < bytes.length; i += 1) bin += String.fromCharCode(bytes[i]);
|
|
16
|
+
return btoa(bin);
|
|
17
|
+
}
|
|
18
|
+
function bytesToBase64url(bytes) {
|
|
19
|
+
return bytesToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
20
|
+
}
|
|
21
|
+
function compactSignatureToDer(compact) {
|
|
22
|
+
if (compact.length !== 64) {
|
|
23
|
+
throw new Error(`expected 64-byte compact signature, got ${compact.length}`);
|
|
24
|
+
}
|
|
25
|
+
const r = derInteger(compact.subarray(0, 32));
|
|
26
|
+
const s = derInteger(compact.subarray(32, 64));
|
|
27
|
+
const body = new Uint8Array(r.length + s.length);
|
|
28
|
+
body.set(r, 0);
|
|
29
|
+
body.set(s, r.length);
|
|
30
|
+
const out = new Uint8Array(2 + body.length);
|
|
31
|
+
out[0] = 48;
|
|
32
|
+
out[1] = body.length;
|
|
33
|
+
out.set(body, 2);
|
|
34
|
+
return out;
|
|
35
|
+
}
|
|
36
|
+
function derInteger(component) {
|
|
37
|
+
let start = 0;
|
|
38
|
+
while (start < component.length - 1 && component[start] === 0) start += 1;
|
|
39
|
+
let content = component.subarray(start);
|
|
40
|
+
if (content[0] & 128) {
|
|
41
|
+
const padded = new Uint8Array(content.length + 1);
|
|
42
|
+
padded[0] = 0;
|
|
43
|
+
padded.set(content, 1);
|
|
44
|
+
content = padded;
|
|
45
|
+
}
|
|
46
|
+
const out = new Uint8Array(2 + content.length);
|
|
47
|
+
out[0] = 2;
|
|
48
|
+
out[1] = content.length;
|
|
49
|
+
out.set(content, 2);
|
|
50
|
+
return out;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export {
|
|
54
|
+
base64ToBytes,
|
|
55
|
+
base64urlToBytes,
|
|
56
|
+
bytesToBase64,
|
|
57
|
+
bytesToBase64url,
|
|
58
|
+
compactSignatureToDer
|
|
59
|
+
};
|
|
@@ -10,7 +10,7 @@ var BUTTON_CSS = `
|
|
|
10
10
|
min-height:48px; padding:11px 22px; border:1px solid color-mix(in srgb,var(--dx-ember,#f26c18) 55%,transparent);
|
|
11
11
|
border-radius:var(--dx-radius,0px);
|
|
12
12
|
background:linear-gradient(135deg,var(--dx-ember,#f26c18),var(--dx-ember-2,#ba3a00));
|
|
13
|
-
color:var(--dx-fg,#fff4ea); font:inherit; font-weight:600; font-size:.
|
|
13
|
+
color:var(--dx-fg,#fff4ea); font:inherit; font-weight:600; font-size:.875rem; letter-spacing:.1em;
|
|
14
14
|
text-transform:uppercase; cursor:pointer; -webkit-tap-highlight-color:transparent;
|
|
15
15
|
box-shadow:0 14px 26px color-mix(in srgb,var(--dx-ember,#f26c18) 24%,transparent);
|
|
16
16
|
transition:transform .16s ease, box-shadow .16s ease, filter .16s ease, background .16s ease;
|
|
@@ -50,7 +50,7 @@ var BUTTON_CSS = `
|
|
|
50
50
|
.dx-btn--sm:hover{ box-shadow:0 12px 22px color-mix(in srgb,var(--dx-ember,#f26c18) 26%,transparent); }
|
|
51
51
|
.dx-btn--sm .dx-btn__mark{ width:14px; height:14px; }
|
|
52
52
|
.dx-btn--sm .dx-btn__spin{ width:12px; height:12px; }
|
|
53
|
-
.dx-btn__mark{ flex-shrink:0; }
|
|
53
|
+
.dx-btn__mark{ width:20px; height:20px; flex-shrink:0; }
|
|
54
54
|
.dx-btn__spin{ width:15px; height:15px; flex-shrink:0; border-radius:50%;
|
|
55
55
|
border:2px solid color-mix(in srgb,currentColor 30%,transparent); border-top-color:currentColor;
|
|
56
56
|
animation:dx-spin .7s linear infinite; }
|