@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/dist/react.js CHANGED
@@ -2,288 +2,73 @@ import {
2
2
  ConnectError,
3
3
  authoredPolicy,
4
4
  ceremonyPhaseLabel,
5
- continueWithDexter,
6
- createPasskeySigner,
5
+ connectDexterIdentity,
6
+ createDexterControlModel,
7
+ createDexterIdentityCoordinator,
7
8
  createWallet,
9
+ disconnectActiveWallet,
10
+ disconnectDexterIdentity,
8
11
  ejectActiveWallet,
12
+ forgetWallet,
9
13
  getActiveHandle,
10
- getCredentialId,
11
14
  listWallets,
12
- passkeyLogin,
13
15
  passkeySignalSupport,
14
16
  prunePasskey,
15
- recoverWallet,
17
+ removeWalletFromDeviceRoster,
16
18
  renamePasskey,
17
- resolveIdentity,
18
19
  setActiveHandle,
20
+ setActiveWallet,
19
21
  shouldUsePopup,
20
22
  subscribe,
21
- switchWallet
22
- } from "./chunk-XQ7RKJMI.js";
23
+ switchWallet,
24
+ walletProofSessionStore
25
+ } from "./chunk-XKOVUW5P.js";
23
26
  import {
24
27
  DexterButton,
25
28
  DexterMark,
26
29
  cx,
27
30
  ensureDexterButtonStyles
28
- } from "./chunk-TLCQSAE5.js";
31
+ } from "./chunk-T62F36N2.js";
32
+ import "./chunk-EMCGL64H.js";
29
33
 
30
- // src/useSignInWithDexter.ts
31
- import { useCallback, useEffect, useMemo, useState } from "react";
34
+ // src/useDexterConnection.ts
35
+ import { useCallback as useCallback2, useEffect as useEffect3, useMemo as useMemo2, useRef as useRef2, useState as useState3 } from "react";
32
36
 
33
- // src/balance.ts
34
- async function fetchUsdcBalance(rpcUrl, usdcAta) {
35
- try {
36
- const res = await fetch(rpcUrl, {
37
- method: "POST",
38
- headers: { "content-type": "application/json" },
39
- body: JSON.stringify({
40
- jsonrpc: "2.0",
41
- id: 1,
42
- method: "getAccountInfo",
43
- params: [usdcAta, { encoding: "base64", commitment: "confirmed" }]
44
- })
45
- });
46
- if (!res.ok) return null;
47
- const json = await res.json();
48
- const value = json?.result?.value;
49
- if (!value || !value.data) return 0;
50
- const b64 = Array.isArray(value.data) ? value.data[0] : value.data;
51
- const bytes = base64ToBytes(b64);
52
- if (bytes.length < 72) return 0;
53
- return Number(readU64LE(bytes, 64)) / 1e6;
54
- } catch {
55
- return null;
56
- }
57
- }
58
- function readU64LE(bytes, offset) {
59
- let v = 0n;
60
- for (let i = 7; i >= 0; i -= 1) v = v << 8n | BigInt(bytes[offset + i]);
61
- return v;
37
+ // src/identity.ts
38
+ function presentOrNull(value) {
39
+ return value && value.length > 0 ? value : null;
62
40
  }
63
- function base64ToBytes(s) {
64
- const bin = atob(s);
65
- const out = new Uint8Array(bin.length);
66
- for (let i = 0; i < bin.length; i += 1) out[i] = bin.charCodeAt(i);
67
- return out;
68
- }
69
-
70
- // src/useSignInWithDexter.ts
71
- var DEFAULT_RPC = "https://api.dexter.cash/proxy/helius/rpc";
72
- function useSignInWithDexter(config = {}) {
73
- const { apiBase, rpcUrl = DEFAULT_RPC, transport, connectHost, preferImmediate } = config;
74
- const [status, setStatus] = useState("idle");
75
- const [phase, setPhase] = useState(null);
76
- const [session, setSession] = useState(null);
77
- const [vault, setVault] = useState(null);
78
- const [usdcBalance, setUsdcBalance] = useState(null);
79
- const [error, setError] = useState(null);
80
- const [recovered, setRecovered] = useState(null);
81
- const refreshBalance = useCallback(async () => {
82
- const ata = vault?.usdcAta;
83
- if (!ata) return;
84
- setUsdcBalance(await fetchUsdcBalance(rpcUrl, ata));
85
- }, [vault, rpcUrl]);
86
- const signIn = useCallback(async () => {
87
- setError(null);
88
- setPhase(null);
89
- setStatus("pending");
90
- try {
91
- const result = await passkeyLogin(
92
- {
93
- ...apiBase ? { apiBase } : {},
94
- ...transport ? { transport } : {},
95
- ...connectHost ? { connectHost } : {}
96
- },
97
- setPhase
98
- );
99
- setSession(result.session);
100
- setVault(result.vault ?? null);
101
- setStatus("done");
102
- setPhase(null);
103
- return result;
104
- } catch (err) {
105
- const e = err instanceof ConnectError ? err : new ConnectError("sign_in_failed", String(err));
106
- setError(e);
107
- setStatus("error");
108
- setPhase(null);
109
- throw e;
110
- }
111
- }, [apiBase, transport, connectHost]);
112
- const recover = useCallback(async () => {
113
- setError(null);
114
- setPhase(null);
115
- setStatus("pending");
116
- const outcome = await recoverWallet({
117
- ...apiBase ? { apiBase } : {},
118
- ...transport ? { transport } : {},
119
- ...connectHost ? { connectHost } : {},
120
- ...preferImmediate ? { preferImmediate } : {},
121
- onPhase: setPhase
122
- });
123
- setPhase(null);
124
- setRecovered(outcome);
125
- if (outcome.ok) {
126
- setStatus("done");
127
- } else if (outcome.reason === "error") {
128
- setError(outcome.error ?? new ConnectError("recover_failed"));
129
- setStatus("error");
130
- } else {
131
- setStatus("idle");
132
- }
133
- return outcome;
134
- }, [apiBase, transport, connectHost, preferImmediate]);
135
- const continueWith = useCallback(async () => {
136
- setError(null);
137
- setPhase(null);
138
- setStatus("pending");
139
- try {
140
- const result = await continueWithDexter(
141
- {
142
- ...apiBase ? { apiBase } : {},
143
- ...transport ? { transport } : {},
144
- ...connectHost ? { connectHost } : {}
145
- },
146
- setPhase
147
- );
148
- setPhase(null);
149
- if (result.kind === "signin") {
150
- setSession(result.session);
151
- setVault(result.vault ?? null);
152
- setStatus("done");
153
- } else if (result.kind === "create") {
154
- setVault(result.vault);
155
- setStatus("done");
156
- } else {
157
- setStatus("idle");
158
- }
159
- return result;
160
- } catch (err) {
161
- const e = err instanceof ConnectError ? err : new ConnectError("continue_failed", String(err));
162
- setError(e);
163
- setStatus("error");
164
- setPhase(null);
165
- throw e;
166
- }
167
- }, [apiBase, transport, connectHost]);
168
- const disconnect = useCallback(() => {
169
- setSession(null);
170
- setVault(null);
171
- setUsdcBalance(null);
172
- setError(null);
173
- setRecovered(null);
174
- setStatus("idle");
175
- }, []);
176
- const passkeySigner = useMemo(
177
- () => vault ? createPasskeySigner(vault, apiBase, {
178
- ...connectHost ? { connectHost } : {}
179
- }) : null,
180
- [vault, apiBase, connectHost]
181
- );
182
- useEffect(() => {
183
- void refreshBalance();
184
- }, [refreshBalance]);
41
+ function resolveIdentity(input) {
42
+ const hasPasskeyVault = input.relation.walletPresent;
43
+ const hasAccount = input.relation.accountPresent;
44
+ const userHandle = hasPasskeyVault ? presentOrNull(input.userHandle) : null;
45
+ const walletLabel = userHandle ? presentOrNull(input.walletLabel ?? null) : null;
46
+ const hasAccountAccess = input.relation.privateAccountAccess;
47
+ const accountToken = hasAccountAccess ? presentOrNull(input.accountToken) : null;
185
48
  return {
186
- status,
187
- phase,
188
- isVaultConnected: status === "done" && vault !== null,
189
- signIn,
190
- recover,
191
- continueWith,
192
- recovered,
193
- disconnect,
194
- session,
195
- vault,
196
- vaultAddress: vault?.swigAddress ?? null,
197
- vaultPda: vault?.vaultPda ?? null,
198
- credentialId: vault?.credentialId ?? null,
199
- passkeySigner,
200
- usdcBalance,
201
- refreshBalance,
202
- error
49
+ kind: input.relation.relation,
50
+ userHandle,
51
+ walletLabel,
52
+ accountToken,
53
+ hasPasskeyVault,
54
+ hasAccount,
55
+ hasWallet: hasPasskeyVault,
56
+ hasAccountAccess,
57
+ quarantined: input.relation.quarantined
203
58
  };
204
59
  }
205
60
 
206
- // src/SignInWithDexter.tsx
207
- import { useEffect as useEffect2 } from "react";
208
- import { jsx, jsxs } from "react/jsx-runtime";
209
- function shortAddress(addr) {
210
- return addr.length > 10 ? `${addr.slice(0, 4)}\u2026${addr.slice(-4)}` : addr;
211
- }
212
- function formatUsd(n) {
213
- return n.toLocaleString("en-US", { style: "currency", currency: "USD" });
214
- }
215
- function SignInWithDexter(props) {
216
- const {
217
- mode = "signin",
218
- onSuccess,
219
- onError,
220
- onRecovered,
221
- onContinue,
222
- label = "Sign in with Dexter",
223
- variant = "primary",
224
- block = false,
225
- size = "md",
226
- className,
227
- showConnectedChip = true,
228
- ...config
229
- } = props;
230
- useEffect2(ensureDexterButtonStyles, []);
231
- const c = useSignInWithDexter(config);
232
- const handleClick = async () => {
233
- if (mode === "recover") {
234
- onRecovered?.(await c.recover());
235
- return;
236
- }
237
- if (mode === "continue") {
238
- try {
239
- onContinue?.(await c.continueWith());
240
- } catch (err) {
241
- onError?.(err);
242
- }
243
- return;
244
- }
245
- try {
246
- onSuccess?.(await c.signIn());
247
- } catch (err) {
248
- onError?.(err);
249
- }
250
- };
251
- if (mode === "recover" && c.recovered?.ok) return null;
252
- if (c.isVaultConnected) {
253
- if (!showConnectedChip) return null;
254
- return /* @__PURE__ */ jsxs("span", { className: cx("dx-chip", className), children: [
255
- /* @__PURE__ */ jsx("span", { className: "dx-chip__dot", "aria-hidden": true }),
256
- /* @__PURE__ */ jsx("span", { children: c.vault?.walletLabel ?? (c.vaultAddress ? shortAddress(c.vaultAddress) : "Connected") }),
257
- c.usdcBalance !== null && /* @__PURE__ */ jsxs("span", { className: "dx-chip__bal", children: [
258
- formatUsd(c.usdcBalance),
259
- " available"
260
- ] }),
261
- /* @__PURE__ */ jsx("button", { type: "button", className: "dx-chip__x", onClick: c.disconnect, "aria-label": "Disconnect", children: "\xD7" })
262
- ] });
263
- }
264
- return /* @__PURE__ */ jsx(
265
- DexterButton,
266
- {
267
- loading: c.status === "pending",
268
- loadingLabel: c.phase ? ceremonyPhaseLabel(c.phase) : "Connecting\u2026",
269
- variant,
270
- block,
271
- size,
272
- className,
273
- onClick: handleClick,
274
- children: label
275
- }
276
- );
277
- }
61
+ // src/useDexterIdentity.ts
62
+ import { useEffect as useEffect2, useMemo, useRef, useState as useState2, useSyncExternalStore } from "react";
278
63
 
279
64
  // src/useDexterWallet.ts
280
- import { useCallback as useCallback2, useEffect as useEffect3, useState as useState2 } from "react";
65
+ import { useCallback, useEffect, useState } from "react";
281
66
  var NO_SUPPORT = { rename: false, prune: false, syncAccepted: false };
282
67
  function useDexterWallet() {
283
- const [activeHandle, setHandle] = useState2(() => getActiveHandle());
284
- const [wallets, setWallets] = useState2(() => listWallets());
285
- const [support, setSupport] = useState2(NO_SUPPORT);
286
- useEffect3(() => {
68
+ const [activeHandle, setHandle] = useState(() => getActiveHandle());
69
+ const [wallets, setWallets] = useState(() => listWallets());
70
+ const [support, setSupport] = useState(NO_SUPPORT);
71
+ useEffect(() => {
287
72
  const sync = () => {
288
73
  setHandle(getActiveHandle());
289
74
  setWallets(listWallets());
@@ -292,192 +77,461 @@ function useDexterWallet() {
292
77
  sync();
293
78
  return subscribe(sync);
294
79
  }, []);
295
- const eject = useCallback2((opts) => {
296
- const handle = getActiveHandle();
297
- const credentialId = handle ? getCredentialId(handle) : void 0;
298
- ejectActiveWallet(opts);
299
- if (credentialId) void prunePasskey({ credentialId });
300
- }, []);
301
- const rename = useCallback2(async (name, displayName) => {
80
+ const disconnect = useCallback(() => disconnectActiveWallet(), []);
81
+ const forget = useCallback((handle) => forgetWallet(handle), []);
82
+ const eject = useCallback((opts) => ejectActiveWallet(opts), []);
83
+ const removeFromDevice = useCallback(
84
+ async (handle, confirmation) => {
85
+ const removed = removeWalletFromDeviceRoster(handle, confirmation);
86
+ if (!removed) return { removedFromRoster: false, passkeyPruned: false };
87
+ walletProofSessionStore.handleLifecycle({
88
+ type: "wallet_removed_from_device",
89
+ handle
90
+ });
91
+ const passkeyPruned = removed.credentialId ? await prunePasskey({ credentialId: removed.credentialId }) : false;
92
+ return { removedFromRoster: true, passkeyPruned };
93
+ },
94
+ []
95
+ );
96
+ const rename = useCallback(async (name, displayName) => {
302
97
  const handle = getActiveHandle();
303
98
  if (!handle) return false;
304
99
  const ok = await renamePasskey({ userId: handle, name, displayName });
305
100
  if (ok) setActiveHandle(handle, name);
306
101
  return ok;
307
102
  }, []);
103
+ const switchTo = useCallback((handle) => switchWallet(handle), []);
104
+ const setActive = useCallback(
105
+ (handle, label, credentialId) => setActiveHandle(handle, label, credentialId),
106
+ []
107
+ );
108
+ const activate = useCallback((wallet) => setActiveWallet(wallet), []);
308
109
  return {
309
110
  activeHandle,
310
111
  activeWallet: activeHandle ? wallets.find((w) => w.handle === activeHandle) ?? null : null,
311
112
  wallets,
312
113
  support,
114
+ disconnect,
115
+ forget,
313
116
  eject,
314
- switchTo: useCallback2((handle) => switchWallet(handle), []),
315
- setActive: useCallback2(
316
- (handle, label, credentialId) => setActiveHandle(handle, label, credentialId),
317
- []
318
- ),
117
+ removeFromDevice,
118
+ switchTo,
119
+ setActive,
120
+ activate,
319
121
  rename
320
122
  };
321
123
  }
322
124
 
323
- // src/DexterWalletChip.tsx
324
- import { useEffect as useEffect4 } from "react";
325
-
326
- // src/walletKitStyles.ts
327
- var STYLE_ID = "dexter-connect-wallet-kit-styles";
328
- var WALLET_KIT_CSS = `
329
- .dx-wchip{
330
- display:inline-flex; align-items:center; gap:9px; max-width:240px;
331
- padding:6px 12px 6px 7px; font:inherit; font-weight:600; font-size:.74rem;
332
- letter-spacing:.1em; text-transform:uppercase; cursor:pointer; background:transparent;
333
- color:inherit; border:1px solid color-mix(in srgb,var(--dx-ember,#f26c18) 42%,transparent);
334
- border-radius:var(--dx-radius,0px); -webkit-tap-highlight-color:transparent;
335
- transition:filter .16s ease, box-shadow .16s ease, border-color .16s ease;
336
- }
337
- .dx-wchip:hover{ filter:brightness(1.08); box-shadow:0 8px 18px color-mix(in srgb,var(--dx-ember,#f26c18) 18%,transparent); }
338
- .dx-wchip:focus-visible{ outline:none; box-shadow:0 0 0 3px color-mix(in srgb,var(--dx-ember,#f26c18) 34%,transparent); }
339
- .dx-wchip--signedout{ border-color:color-mix(in srgb,currentColor 22%,transparent); padding-left:12px; }
340
- .dx-wchip__avatar{
341
- width:22px; height:22px; flex-shrink:0; display:inline-flex; align-items:center; justify-content:center;
342
- border-radius:50%; overflow:hidden; font-size:.72rem; font-weight:700; letter-spacing:0; line-height:1;
343
- background:linear-gradient(135deg,var(--dx-ember,#f26c18),var(--dx-ember-2,#ba3a00)); color:var(--dx-fg,#fff4ea);
125
+ // src/useDexterIdentity.ts
126
+ function relationForPresence(walletPresent, accountPresent) {
127
+ if (walletPresent) return "wallet_only";
128
+ if (accountPresent) return "account_only";
129
+ return "none";
344
130
  }
345
- .dx-wchip__avatar img{ width:100%; height:100%; object-fit:cover; }
346
- .dx-wchip__label{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
347
-
348
- .dx-wmenu{ display:flex; flex-direction:column; min-width:248px; }
349
- .dx-wmenu__id{ display:flex; align-items:center; gap:10px; padding:13px 15px; border-bottom:1px solid color-mix(in srgb,currentColor 12%,transparent); }
350
- .dx-wmenu__avatar{ width:32px; height:32px; flex-shrink:0; display:inline-flex; align-items:center; justify-content:center; border-radius:50%; font-weight:700; font-size:.85rem; line-height:1; background:linear-gradient(135deg,var(--dx-ember,#f26c18),var(--dx-ember-2,#ba3a00)); color:var(--dx-fg,#fff4ea); }
351
- .dx-wmenu__meta{ display:flex; flex-direction:column; gap:2px; min-width:0; }
352
- .dx-wmenu__name{ font-weight:700; font-size:.9rem; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
353
- .dx-wmenu__sub{ font-size:.66rem; letter-spacing:.12em; text-transform:uppercase; opacity:.55; }
354
- .dx-wmenu__list{ display:flex; flex-direction:column; padding:6px; }
355
- .dx-wmenu__item{ display:flex; align-items:center; justify-content:space-between; gap:10px; width:100%; padding:10px 12px; font:inherit; font-size:.82rem; font-weight:600; text-align:left; background:transparent; border:none; color:inherit; cursor:pointer; transition:background .12s ease; }
356
- .dx-wmenu__item:hover{ background:color-mix(in srgb,var(--dx-ember,#f26c18) 10%,transparent); }
357
- .dx-wmenu__item--danger{ color:var(--dx-danger,#e5552e); }
358
- .dx-wmenu__icon{ opacity:.45; font-size:.9rem; }
359
- .dx-wmenu__back{ border-bottom:1px solid color-mix(in srgb,currentColor 10%,transparent); opacity:.85; }
360
- .dx-wmenu__save{ display:flex; flex-direction:column; gap:9px; padding:13px 15px; }
361
- .dx-wmenu__savehint{ font-size:.78rem; line-height:1.4; opacity:.7; }
362
- `;
363
- function ensureWalletKitStyles() {
364
- if (typeof document === "undefined") return;
365
- if (document.getElementById(STYLE_ID)) return;
366
- const el = document.createElement("style");
367
- el.id = STYLE_ID;
368
- el.textContent = WALLET_KIT_CSS;
369
- document.head.appendChild(el);
131
+ function transitionSnapshot(current, accountSession, walletPresent, initial) {
132
+ const accountPresent = accountSession.status === "authenticated";
133
+ const runtime = initial || accountSession.status === "loading" ? { phase: "hydrating" } : walletPresent && accountPresent ? { phase: "checking", reason: "account_change" } : { phase: "ready" };
134
+ return Object.freeze({
135
+ relation: relationForPresence(walletPresent, accountPresent),
136
+ runtime: Object.freeze(runtime),
137
+ walletPresent,
138
+ accountPresent,
139
+ privateAccountAccess: false,
140
+ quarantined: false,
141
+ verifiedAt: null,
142
+ revision: current.revision
143
+ });
370
144
  }
371
- ensureWalletKitStyles();
372
-
373
- // src/DexterWalletChip.tsx
374
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
375
- function DexterWalletChip(props) {
376
- const { connected, label, avatarUrl, avatarInitial, onClick, className, ariaExpanded } = props;
377
- useEffect4(ensureWalletKitStyles, []);
378
- const initial = (avatarInitial ?? label.trim().charAt(0) ?? "D").toUpperCase();
379
- return /* @__PURE__ */ jsxs2(
380
- "button",
381
- {
382
- type: "button",
383
- className: cx("dx-wchip", !connected && "dx-wchip--signedout", className),
384
- onClick,
385
- "aria-expanded": ariaExpanded,
386
- children: [
387
- connected ? /* @__PURE__ */ jsx2("span", { className: "dx-wchip__avatar", "aria-hidden": "true", children: avatarUrl ? /* @__PURE__ */ jsx2("img", { src: avatarUrl, alt: "" }) : initial }) : null,
388
- /* @__PURE__ */ jsx2("span", { className: "dx-wchip__label", children: label })
389
- ]
145
+ function useDexterIdentity({
146
+ accountSession,
147
+ ...coordinatorOptions
148
+ }) {
149
+ const [coordinator] = useState2(
150
+ () => createDexterIdentityCoordinator(coordinatorOptions)
151
+ );
152
+ const relation = useSyncExternalStore(
153
+ coordinator.subscribe,
154
+ coordinator.getSnapshot,
155
+ coordinator.getSnapshot
156
+ );
157
+ const { activeHandle, activeWallet } = useDexterWallet();
158
+ const initialized = useRef(false);
159
+ const lifecycleGeneration = useRef(0);
160
+ const desired = useRef({
161
+ status: accountSession.status,
162
+ accessToken: accountSession.status === "authenticated" ? accountSession.accessToken : null,
163
+ marker: /* @__PURE__ */ Symbol("account-session")
164
+ });
165
+ const nextAccessToken = accountSession.status === "authenticated" ? accountSession.accessToken : null;
166
+ if (desired.current.status !== accountSession.status || desired.current.accessToken !== nextAccessToken) {
167
+ desired.current = {
168
+ status: accountSession.status,
169
+ accessToken: nextAccessToken,
170
+ marker: /* @__PURE__ */ Symbol("account-session")
171
+ };
172
+ }
173
+ const desiredMarker = desired.current.marker;
174
+ const [settledMarker, setSettledMarker] = useState2(null);
175
+ useEffect2(() => {
176
+ let cancelled = false;
177
+ const marker = desiredMarker;
178
+ if (accountSession.status === "loading") {
179
+ coordinator.setAccountLoading();
180
+ setSettledMarker(marker);
181
+ return () => {
182
+ cancelled = true;
183
+ };
390
184
  }
185
+ const accessToken = accountSession.status === "authenticated" ? accountSession.accessToken : null;
186
+ const pending = initialized.current ? coordinator.setAccountSession(accessToken) : coordinator.restore(accessToken);
187
+ initialized.current = true;
188
+ void pending.then(() => {
189
+ if (!cancelled) setSettledMarker(marker);
190
+ });
191
+ return () => {
192
+ cancelled = true;
193
+ };
194
+ }, [accountSession.status, coordinator, desiredMarker, nextAccessToken]);
195
+ useEffect2(() => {
196
+ const generation = lifecycleGeneration.current + 1;
197
+ lifecycleGeneration.current = generation;
198
+ return () => {
199
+ queueMicrotask(() => {
200
+ if (lifecycleGeneration.current === generation) {
201
+ coordinator.dispose();
202
+ }
203
+ });
204
+ };
205
+ }, [coordinator]);
206
+ const visibleRelation = settledMarker === desiredMarker ? relation : transitionSnapshot(
207
+ relation,
208
+ accountSession,
209
+ activeHandle !== null,
210
+ !initialized.current
211
+ );
212
+ const accountToken = accountSession.status === "authenticated" ? accountSession.accessToken : null;
213
+ const identity = useMemo(
214
+ () => resolveIdentity({
215
+ relation: visibleRelation,
216
+ accountToken,
217
+ userHandle: activeHandle,
218
+ walletLabel: activeWallet?.label ?? null
219
+ }),
220
+ [visibleRelation, accountToken, activeHandle, activeWallet?.label]
391
221
  );
222
+ return {
223
+ identity,
224
+ relation: visibleRelation,
225
+ retry: async () => {
226
+ await coordinator.retry();
227
+ },
228
+ reconcile: async () => {
229
+ if (accountSession.status === "loading") {
230
+ coordinator.setAccountLoading();
231
+ return;
232
+ }
233
+ await coordinator.restore(
234
+ accountSession.status === "authenticated" ? accountSession.accessToken : null
235
+ );
236
+ },
237
+ allowAccountSession: coordinator.allowAccountSession,
238
+ settleAccountSession: (accessToken) => coordinator.setAccountSession(accessToken)
239
+ };
392
240
  }
393
241
 
394
- // src/DexterWalletMenu.tsx
395
- import { useEffect as useEffect5, useState as useState3 } from "react";
396
- import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
397
- function DexterWalletMenu(props) {
242
+ // src/useDexterConnection.ts
243
+ var REMOVE_DEXTER_FROM_DEVICE_CONFIRMATION = "remove-dexter-from-device";
244
+ function checkingSnapshot(snapshot, reason) {
245
+ return Object.freeze({
246
+ ...snapshot,
247
+ relation: "none",
248
+ runtime: Object.freeze({ phase: "checking", reason }),
249
+ walletPresent: false,
250
+ accountPresent: false,
251
+ privateAccountAccess: false,
252
+ quarantined: false,
253
+ verifiedAt: null
254
+ });
255
+ }
256
+ function errorSnapshot(snapshot, error) {
257
+ return Object.freeze({
258
+ ...snapshot,
259
+ runtime: Object.freeze({ phase: "error", code: error.code }),
260
+ privateAccountAccess: false
261
+ });
262
+ }
263
+ function unsettledBindingError(snapshot) {
264
+ if (snapshot.relation === "bound" && snapshot.runtime.phase === "ready" && snapshot.privateAccountAccess) {
265
+ return null;
266
+ }
267
+ if (snapshot.relation === "conflict") {
268
+ return new ConnectError("identity_binding_conflict");
269
+ }
270
+ if (snapshot.runtime.phase === "offline") {
271
+ return new ConnectError("identity_binding_offline");
272
+ }
273
+ if (snapshot.runtime.phase === "expired") {
274
+ return new ConnectError(`identity_${snapshot.runtime.subject}_expired`);
275
+ }
276
+ if (snapshot.runtime.phase === "error") {
277
+ return new ConnectError(snapshot.runtime.code);
278
+ }
279
+ return new ConnectError("identity_binding_unverified");
280
+ }
281
+ function useDexterConnection(config) {
398
282
  const {
399
- walletLabel,
400
- avatarInitial,
401
- onManageWallet,
402
- onStartFresh,
403
- startFreshLabel = "Eject wallet",
404
- saveSlot,
405
- saveHint,
406
- className
407
- } = props;
408
- useEffect5(ensureWalletKitStyles, []);
409
- const [showSave, setShowSave] = useState3(false);
410
- const initial = (avatarInitial ?? walletLabel.trim().charAt(0) ?? "D").toUpperCase();
411
- if (showSave && saveSlot) {
412
- return /* @__PURE__ */ jsxs3("div", { className: cx("dx-wmenu", className), children: [
413
- /* @__PURE__ */ jsx3(
414
- "button",
415
- {
416
- type: "button",
417
- className: "dx-wmenu__item dx-wmenu__back",
418
- onClick: () => setShowSave(false),
419
- children: /* @__PURE__ */ jsx3("span", { children: "\u2190 Back to wallet" })
283
+ intent,
284
+ accountSession,
285
+ installAccountSession,
286
+ clearAccountSession,
287
+ passkey,
288
+ apiBase,
289
+ fetch
290
+ } = config;
291
+ const dexterIdentity = useDexterIdentity({
292
+ ...apiBase ? { apiBase } : {},
293
+ ...fetch ? { fetch } : {},
294
+ accountSession
295
+ });
296
+ const wallet = useDexterWallet();
297
+ const [operation, setOperation] = useState3("idle");
298
+ const [targetHandle, setTargetHandle] = useState3(null);
299
+ const [targetAccessToken, setTargetAccessToken] = useState3(null);
300
+ const [error, setError] = useState3(null);
301
+ const action = useRef2("idle");
302
+ const beginAction = useCallback2(
303
+ (next) => {
304
+ if (action.current !== "idle") {
305
+ throw new ConnectError("identity_operation_in_progress");
306
+ }
307
+ action.current = next;
308
+ if (next !== "retrying") setOperation(next);
309
+ },
310
+ []
311
+ );
312
+ const finishAction = useCallback2(
313
+ (expected) => {
314
+ if (action.current !== expected) return;
315
+ action.current = "idle";
316
+ if (expected !== "retrying") setOperation("idle");
317
+ },
318
+ []
319
+ );
320
+ useEffect3(() => {
321
+ if (operation === "connecting" && targetHandle !== null && targetAccessToken !== null && wallet.activeHandle === targetHandle && accountSession.status === "authenticated" && accountSession.accessToken === targetAccessToken && dexterIdentity.relation.relation === "bound" && dexterIdentity.relation.privateAccountAccess) {
322
+ finishAction("connecting");
323
+ setTargetHandle(null);
324
+ setTargetAccessToken(null);
325
+ }
326
+ if ((operation === "disconnecting" || operation === "removing") && dexterIdentity.relation.relation === "none") {
327
+ finishAction(operation);
328
+ }
329
+ }, [
330
+ dexterIdentity.relation,
331
+ operation,
332
+ targetHandle,
333
+ targetAccessToken,
334
+ wallet.activeHandle,
335
+ accountSession,
336
+ finishAction
337
+ ]);
338
+ const operationRelation = operation === "idle" ? dexterIdentity.relation : checkingSnapshot(
339
+ dexterIdentity.relation,
340
+ operation === "connecting" ? "wallet_change" : "account_change"
341
+ );
342
+ const modelRelation = error !== null && operation === "idle" ? errorSnapshot(operationRelation, error) : operationRelation;
343
+ const model = useMemo2(
344
+ () => createDexterControlModel(intent, modelRelation),
345
+ [intent, modelRelation]
346
+ );
347
+ const relation = modelRelation;
348
+ const accountToken = accountSession.status === "authenticated" ? accountSession.accessToken : null;
349
+ const identity = useMemo2(() => {
350
+ const resolved = resolveIdentity({
351
+ relation,
352
+ accountToken,
353
+ userHandle: wallet.activeHandle,
354
+ walletLabel: wallet.activeWallet?.label ?? null
355
+ });
356
+ return {
357
+ kind: resolved.kind,
358
+ userHandle: model.permissions.walletIdentityVisible ? resolved.userHandle : null,
359
+ walletLabel: model.permissions.walletIdentityVisible ? resolved.walletLabel : null,
360
+ hasPasskeyVault: resolved.hasPasskeyVault,
361
+ hasAccount: resolved.hasAccount,
362
+ hasWallet: resolved.hasWallet,
363
+ hasAccountAccess: model.permissions.accountContentVisible && resolved.hasAccountAccess,
364
+ quarantined: resolved.quarantined
365
+ };
366
+ }, [
367
+ accountToken,
368
+ relation,
369
+ model.permissions.accountContentVisible,
370
+ model.permissions.walletIdentityVisible,
371
+ wallet.activeHandle,
372
+ wallet.activeWallet?.label
373
+ ]);
374
+ const activeWallet = useMemo2(() => {
375
+ if (!model.permissions.walletIdentityVisible) return null;
376
+ const active = wallet.activeWallet;
377
+ if (!active) return null;
378
+ return {
379
+ userHandle: active.handle,
380
+ label: active.label ?? null,
381
+ vaultPda: active.vaultPda ?? null,
382
+ swigAddress: active.swigAddress ?? null,
383
+ walletAddress: active.walletAddress ?? null,
384
+ receiveAddress: active.receiveAddress ?? null,
385
+ network: active.network ?? null
386
+ };
387
+ }, [model.permissions.walletIdentityVisible, wallet.activeWallet]);
388
+ const connect = useCallback2(async () => {
389
+ beginAction("connecting");
390
+ setError(null);
391
+ setTargetHandle(null);
392
+ setTargetAccessToken(null);
393
+ try {
394
+ const result = await connectDexterIdentity({
395
+ ...passkey,
396
+ ...apiBase ? { apiBase } : {},
397
+ ...fetch ? { bindingFetch: fetch } : {},
398
+ installAccountSession: async (session) => {
399
+ dexterIdentity.allowAccountSession(session.accessToken);
400
+ await installAccountSession(session);
401
+ const settled = await dexterIdentity.settleAccountSession(
402
+ session.accessToken
403
+ );
404
+ const settleError = unsettledBindingError(settled);
405
+ if (settleError) {
406
+ try {
407
+ await clearAccountSession();
408
+ } catch (cause) {
409
+ throw new ConnectError(
410
+ "account_session_clear_failed",
411
+ cause instanceof Error ? cause.message : String(cause)
412
+ );
413
+ }
414
+ throw settleError;
415
+ }
420
416
  }
421
- ),
422
- /* @__PURE__ */ jsxs3("div", { className: "dx-wmenu__save", children: [
423
- saveHint ? /* @__PURE__ */ jsx3("span", { className: "dx-wmenu__savehint", children: saveHint }) : null,
424
- saveSlot
425
- ] })
426
- ] });
427
- }
428
- return /* @__PURE__ */ jsxs3("div", { className: cx("dx-wmenu", className), children: [
429
- /* @__PURE__ */ jsxs3("div", { className: "dx-wmenu__id", children: [
430
- /* @__PURE__ */ jsx3("span", { className: "dx-wmenu__avatar", "aria-hidden": "true", children: initial }),
431
- /* @__PURE__ */ jsxs3("span", { className: "dx-wmenu__meta", children: [
432
- /* @__PURE__ */ jsx3("span", { className: "dx-wmenu__name", children: walletLabel }),
433
- /* @__PURE__ */ jsx3("span", { className: "dx-wmenu__sub", children: "Your Dexter Wallet" })
434
- ] })
435
- ] }),
436
- /* @__PURE__ */ jsxs3("div", { className: "dx-wmenu__list", children: [
437
- onManageWallet ? /* @__PURE__ */ jsxs3("button", { type: "button", className: "dx-wmenu__item", onClick: onManageWallet, children: [
438
- /* @__PURE__ */ jsx3("span", { children: "Manage wallet" }),
439
- /* @__PURE__ */ jsx3("span", { className: "dx-wmenu__icon", "aria-hidden": "true", children: "\u2197" })
440
- ] }) : null,
441
- saveSlot ? /* @__PURE__ */ jsxs3("button", { type: "button", className: "dx-wmenu__item", onClick: () => setShowSave(true), children: [
442
- /* @__PURE__ */ jsx3("span", { children: "Save your wallet" }),
443
- /* @__PURE__ */ jsx3("span", { className: "dx-wmenu__icon", "aria-hidden": "true", children: "\u2197" })
444
- ] }) : null,
445
- onStartFresh ? /* @__PURE__ */ jsxs3(
446
- "button",
447
- {
448
- type: "button",
449
- className: "dx-wmenu__item dx-wmenu__item--danger",
450
- onClick: onStartFresh,
451
- children: [
452
- /* @__PURE__ */ jsx3("span", { children: startFreshLabel }),
453
- /* @__PURE__ */ jsx3("span", { className: "dx-wmenu__icon", "aria-hidden": "true", children: "\u27F5" })
454
- ]
417
+ });
418
+ setTargetHandle(result.vault.userHandle);
419
+ setTargetAccessToken(result.session.accessToken);
420
+ return result;
421
+ } catch (cause) {
422
+ await dexterIdentity.reconcile().catch(() => void 0);
423
+ const nextError = cause instanceof ConnectError ? cause : new ConnectError("identity_transition_failed", String(cause));
424
+ setError(nextError);
425
+ setTargetHandle(null);
426
+ setTargetAccessToken(null);
427
+ finishAction("connecting");
428
+ throw nextError;
429
+ }
430
+ }, [
431
+ dexterIdentity,
432
+ apiBase,
433
+ fetch,
434
+ installAccountSession,
435
+ clearAccountSession,
436
+ passkey,
437
+ beginAction,
438
+ finishAction
439
+ ]);
440
+ const disconnectDexter = useCallback2(async () => {
441
+ beginAction("disconnecting");
442
+ setError(null);
443
+ try {
444
+ const disconnected = await disconnectDexterIdentity({
445
+ clearAccountSession
446
+ });
447
+ if (!disconnected) finishAction("disconnecting");
448
+ return disconnected;
449
+ } catch (cause) {
450
+ await dexterIdentity.reconcile().catch(() => void 0);
451
+ const nextError = cause instanceof ConnectError ? cause : new ConnectError("identity_disconnect_failed", String(cause));
452
+ setError(nextError);
453
+ finishAction("disconnecting");
454
+ throw nextError;
455
+ }
456
+ }, [
457
+ beginAction,
458
+ clearAccountSession,
459
+ dexterIdentity,
460
+ finishAction
461
+ ]);
462
+ const removeFromThisDevice = useCallback2(
463
+ async (confirmation) => {
464
+ if (confirmation !== REMOVE_DEXTER_FROM_DEVICE_CONFIRMATION) {
465
+ return { removedFromRoster: false, passkeyPruned: false };
466
+ }
467
+ const handle = wallet.activeHandle;
468
+ if (!handle) {
469
+ return { removedFromRoster: false, passkeyPruned: false };
470
+ }
471
+ beginAction("removing");
472
+ setError(null);
473
+ try {
474
+ const result = await wallet.removeFromDevice(
475
+ handle,
476
+ "remove-wallet-from-device"
477
+ );
478
+ if (!result.removedFromRoster) {
479
+ throw new ConnectError("identity_device_removal_failed");
455
480
  }
456
- ) : null
457
- ] })
458
- ] });
459
- }
460
-
461
- // src/useIdentity.ts
462
- import { useMemo as useMemo2 } from "react";
463
- function useIdentity({ accountToken }) {
464
- const { activeHandle, activeWallet } = useDexterWallet();
465
- const walletLabel = activeWallet?.label ?? null;
466
- return useMemo2(
467
- () => resolveIdentity({
468
- accountToken: accountToken ?? null,
469
- userHandle: activeHandle ?? null,
470
- walletLabel
471
- }),
472
- [accountToken, activeHandle, walletLabel]
481
+ await clearAccountSession();
482
+ return result;
483
+ } catch (cause) {
484
+ await dexterIdentity.reconcile().catch(() => void 0);
485
+ const nextError = cause instanceof ConnectError ? cause : new ConnectError(
486
+ "identity_device_removal_failed",
487
+ String(cause)
488
+ );
489
+ setError(nextError);
490
+ finishAction("removing");
491
+ throw nextError;
492
+ }
493
+ },
494
+ [
495
+ beginAction,
496
+ clearAccountSession,
497
+ dexterIdentity,
498
+ finishAction,
499
+ wallet
500
+ ]
473
501
  );
502
+ const retry = useCallback2(async () => {
503
+ beginAction("retrying");
504
+ setError(null);
505
+ try {
506
+ await dexterIdentity.retry();
507
+ } catch (cause) {
508
+ const nextError = cause instanceof ConnectError ? cause : new ConnectError("identity_retry_failed", String(cause));
509
+ setError(nextError);
510
+ throw nextError;
511
+ } finally {
512
+ finishAction("retrying");
513
+ }
514
+ }, [beginAction, dexterIdentity, finishAction]);
515
+ return {
516
+ model,
517
+ identity,
518
+ relation,
519
+ operation,
520
+ activeWallet,
521
+ error,
522
+ connect,
523
+ useAnotherDexterWallet: connect,
524
+ disconnectDexter,
525
+ removeFromThisDevice,
526
+ retry
527
+ };
474
528
  }
475
529
 
476
530
  // src/AllowanceChips.tsx
477
- import { useEffect as useEffect6, useId, useState as useState4 } from "react";
531
+ import { useEffect as useEffect4, useId, useState as useState4 } from "react";
478
532
 
479
533
  // src/consentStyles.ts
480
- var STYLE_ID2 = "dexter-connect-consent-styles";
534
+ var STYLE_ID = "dexter-connect-consent-styles";
481
535
  var CONSENT_CSS = `
482
536
  .dx-allow{
483
537
  display:flex; flex-wrap:wrap; gap:8px; align-items:center; min-width:0;
@@ -529,7 +583,7 @@ var CONSENT_CSS = `
529
583
  display:flex; flex-direction:column; gap:16px; font:inherit;
530
584
  }
531
585
  .dx-cwp__field{ display:flex; flex-direction:column; gap:8px; }
532
- .dx-cwp__label{ font-size:.7rem; font-weight:700; letter-spacing:.14em; text-transform:uppercase; opacity:.62; }
586
+ .dx-cwp__label{ font-size:.8rem; font-weight:700; letter-spacing:.12em; text-transform:uppercase; opacity:.66; }
533
587
  .dx-cwp__name{
534
588
  min-height:48px; padding:10px 13px; font:inherit; font-size:1rem; color:inherit; background:transparent;
535
589
  border:1px solid color-mix(in srgb,currentColor 22%,transparent); border-radius:var(--dx-radius,0px);
@@ -540,10 +594,10 @@ var CONSENT_CSS = `
540
594
  box-shadow:0 0 0 3px color-mix(in srgb,var(--dx-ember,#f26c18) 26%,transparent);
541
595
  }
542
596
  .dx-cwp__name::placeholder{ color:currentColor; opacity:.42; }
543
- .dx-cwp__hosted{ margin:0; font-size:.9rem; line-height:1.55; opacity:.82; }
544
- .dx-cwp__fine{ font-size:.76rem; line-height:1.5; opacity:.66; }
545
- .dx-cwp__err{ font-size:.78rem; line-height:1.45; color:var(--dx-danger,#e5552e); }
546
- .dx-cwp__status{ min-height:1.25rem; margin:0; font-size:.78rem; line-height:1.45; opacity:.72; }
597
+ .dx-cwp__hosted{ margin:0; font-size:.95rem; line-height:1.55; opacity:.82; }
598
+ .dx-cwp__fine{ margin:0; font-size:.875rem; line-height:1.5; opacity:.68; }
599
+ .dx-cwp__err{ font-size:.875rem; line-height:1.45; color:var(--dx-danger,#e5552e); }
600
+ .dx-cwp__status{ margin:0; font-size:.875rem; line-height:1.45; opacity:.74; }
547
601
  @media (max-width:380px){
548
602
  .dx-allow__option{ flex:1 1 calc(50% - 4px); }
549
603
  .dx-allow__chip{ width:100%; }
@@ -556,16 +610,16 @@ var CONSENT_CSS = `
556
610
  `;
557
611
  function ensureConsentStyles() {
558
612
  if (typeof document === "undefined") return;
559
- if (document.getElementById(STYLE_ID2)) return;
613
+ if (document.getElementById(STYLE_ID)) return;
560
614
  const el = document.createElement("style");
561
- el.id = STYLE_ID2;
615
+ el.id = STYLE_ID;
562
616
  el.textContent = CONSENT_CSS;
563
617
  document.head.appendChild(el);
564
618
  }
565
619
  ensureConsentStyles();
566
620
 
567
621
  // src/AllowanceChips.tsx
568
- import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
622
+ import { jsx, jsxs } from "react/jsx-runtime";
569
623
  var PRESETS = [
570
624
  { label: "$5", num: "5" },
571
625
  { label: "$20", num: "20" },
@@ -575,7 +629,7 @@ var PRESET_NUMS = PRESETS.map((p) => p.num);
575
629
  var isPreset = (v) => v !== null && PRESET_NUMS.includes(v);
576
630
  function AllowanceChips(props) {
577
631
  const { value, onChange, className, disabled = false } = props;
578
- useEffect6(ensureConsentStyles, []);
632
+ useEffect4(ensureConsentStyles, []);
579
633
  const [customOpen, setCustomOpen] = useState4(false);
580
634
  const groupName = useId();
581
635
  const customActive = customOpen || value !== null && !isPreset(value);
@@ -589,12 +643,12 @@ function AllowanceChips(props) {
589
643
  setCustomOpen(true);
590
644
  onChange(isPreset(value) ? null : value);
591
645
  };
592
- return /* @__PURE__ */ jsxs4("fieldset", { className: cx("dx-allow", className), disabled, children: [
593
- /* @__PURE__ */ jsx4("legend", { className: "dx-sr-only", children: "Monthly agent allowance" }),
646
+ return /* @__PURE__ */ jsxs("fieldset", { className: cx("dx-allow", className), disabled, children: [
647
+ /* @__PURE__ */ jsx("legend", { className: "dx-sr-only", children: "Monthly agent allowance" }),
594
648
  PRESETS.map(({ label, num }) => {
595
649
  const checked = !customActive && value === num;
596
- return /* @__PURE__ */ jsxs4("label", { className: "dx-allow__option", children: [
597
- /* @__PURE__ */ jsx4(
650
+ return /* @__PURE__ */ jsxs("label", { className: "dx-allow__option", children: [
651
+ /* @__PURE__ */ jsx(
598
652
  "input",
599
653
  {
600
654
  className: "dx-allow__radio",
@@ -605,11 +659,11 @@ function AllowanceChips(props) {
605
659
  onChange: () => selectPreset(num)
606
660
  }
607
661
  ),
608
- /* @__PURE__ */ jsx4("span", { className: "dx-allow__chip", children: label })
662
+ /* @__PURE__ */ jsx("span", { className: "dx-allow__chip", children: label })
609
663
  ] }, num);
610
664
  }),
611
- /* @__PURE__ */ jsxs4("label", { className: "dx-allow__option", children: [
612
- /* @__PURE__ */ jsx4(
665
+ /* @__PURE__ */ jsxs("label", { className: "dx-allow__option", children: [
666
+ /* @__PURE__ */ jsx(
613
667
  "input",
614
668
  {
615
669
  className: "dx-allow__radio",
@@ -620,9 +674,9 @@ function AllowanceChips(props) {
620
674
  onChange: selectCustom
621
675
  }
622
676
  ),
623
- /* @__PURE__ */ jsx4("span", { className: "dx-allow__chip", children: "Custom" })
677
+ /* @__PURE__ */ jsx("span", { className: "dx-allow__chip", children: "Custom" })
624
678
  ] }),
625
- customActive && /* @__PURE__ */ jsx4(
679
+ customActive && /* @__PURE__ */ jsx(
626
680
  "input",
627
681
  {
628
682
  className: "dx-allow__input",
@@ -640,13 +694,21 @@ function AllowanceChips(props) {
640
694
  }
641
695
 
642
696
  // src/CreateWalletPanel.tsx
643
- import { useEffect as useEffect7, useId as useId2, useState as useState5 } from "react";
644
- import { Fragment, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
697
+ import { useEffect as useEffect5, useId as useId2, useState as useState5 } from "react";
698
+ import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
645
699
  var FINE_PRINT = "This is the wallet-wide agent allowance. You can revoke it anytime. Starter credit, if available, is separate and never raises this limit.";
646
700
  function CreateWalletPanel(props) {
647
- const { onCreated, onError, apiBase, transport, showName = true, className } = props;
648
- useEffect7(ensureConsentStyles, []);
649
- useEffect7(ensureDexterButtonStyles, []);
701
+ const {
702
+ onCreated,
703
+ onError,
704
+ apiBase,
705
+ transport,
706
+ showName = true,
707
+ agentDelegation = "deferred",
708
+ className
709
+ } = props;
710
+ useEffect5(ensureConsentStyles, []);
711
+ useEffect5(ensureDexterButtonStyles, []);
650
712
  const nameInputId = useId2();
651
713
  const [name, setName] = useState5("");
652
714
  const [value, setValue] = useState5(null);
@@ -656,15 +718,17 @@ function CreateWalletPanel(props) {
656
718
  const [resolvedTransport, setResolvedTransport] = useState5(
657
719
  transport === "inline" ? "inline" : transport === "popup" ? "popup" : "unknown"
658
720
  );
659
- useEffect7(() => {
721
+ useEffect5(() => {
660
722
  setResolvedTransport(shouldUsePopup(transport) ? "popup" : "inline");
661
723
  }, [transport]);
662
724
  const hosted = resolvedTransport === "popup";
663
- const policy = resolvedTransport === "inline" ? authoredPolicy(value ?? "") : null;
664
- const canContinue = hosted || Boolean(policy);
725
+ const ownerOnly = agentDelegation === "deferred";
726
+ const policy = resolvedTransport === "inline" && !ownerOnly ? authoredPolicy(value ?? "") : null;
727
+ const canContinue = hosted || ownerOnly || Boolean(policy);
728
+ const statusText = running ? phase ? ceremonyPhaseLabel(phase) : "Starting your passkey\u2026" : resolvedTransport === "unknown" ? "Preparing wallet setup\u2026" : hosted ? "Wallet setup continues in Dexter Wallet." : ownerOnly ? "" : policy ? "Ready to create." : "Choose an agent allowance.";
665
729
  const handleCreate = async () => {
666
730
  if (running) return;
667
- if (resolvedTransport === "unknown" || !hosted && !policy) return;
731
+ if (resolvedTransport === "unknown" || !hosted && !ownerOnly && !policy) return;
668
732
  setError(null);
669
733
  setRunning(true);
670
734
  setPhase(null);
@@ -672,6 +736,7 @@ function CreateWalletPanel(props) {
672
736
  const result = await createWallet({
673
737
  name: hosted ? void 0 : name.trim() || "Dexter Wallet",
674
738
  spendPolicy: hosted ? void 0 : policy ?? void 0,
739
+ agentDelegation,
675
740
  apiBase,
676
741
  transport,
677
742
  onPhase: setPhase
@@ -686,10 +751,10 @@ function CreateWalletPanel(props) {
686
751
  setPhase(null);
687
752
  }
688
753
  };
689
- return /* @__PURE__ */ jsxs5("div", { className: cx("dx-cwp", className), children: [
690
- !hosted && resolvedTransport === "inline" && showName && /* @__PURE__ */ jsxs5("div", { className: "dx-cwp__field", children: [
691
- /* @__PURE__ */ jsx5("label", { className: "dx-cwp__label", htmlFor: nameInputId, children: "Name your wallet" }),
692
- /* @__PURE__ */ jsx5(
754
+ return /* @__PURE__ */ jsxs2("div", { className: cx("dx-cwp", className), children: [
755
+ !hosted && resolvedTransport === "inline" && showName && /* @__PURE__ */ jsxs2("div", { className: "dx-cwp__field", children: [
756
+ /* @__PURE__ */ jsx2("label", { className: "dx-cwp__label", htmlFor: nameInputId, children: "Name your wallet" }),
757
+ /* @__PURE__ */ jsx2(
693
758
  "input",
694
759
  {
695
760
  id: nameInputId,
@@ -703,16 +768,16 @@ function CreateWalletPanel(props) {
703
768
  }
704
769
  )
705
770
  ] }),
706
- hosted ? /* @__PURE__ */ jsx5("p", { className: "dx-cwp__hosted", children: "Dexter will open its secure wallet window. Choose the wallet name and agent allowance there before your passkey creates anything." }) : resolvedTransport === "inline" ? /* @__PURE__ */ jsxs5(Fragment, { children: [
707
- /* @__PURE__ */ jsxs5("div", { className: "dx-cwp__field", children: [
708
- /* @__PURE__ */ jsx5("span", { className: "dx-cwp__label", children: "What agents may spend automatically, per 30 days" }),
709
- /* @__PURE__ */ jsx5(AllowanceChips, { value, onChange: setValue, disabled: running })
771
+ hosted ? /* @__PURE__ */ jsx2("p", { className: "dx-cwp__hosted", children: ownerOnly ? "Finish setup in Dexter Wallet." : "Choose a name and agent allowance in Dexter Wallet." }) : resolvedTransport === "inline" ? !ownerOnly ? /* @__PURE__ */ jsxs2(Fragment, { children: [
772
+ /* @__PURE__ */ jsxs2("div", { className: "dx-cwp__field", children: [
773
+ /* @__PURE__ */ jsx2("span", { className: "dx-cwp__label", children: "What agents may spend automatically, per 30 days" }),
774
+ /* @__PURE__ */ jsx2(AllowanceChips, { value, onChange: setValue, disabled: running })
710
775
  ] }),
711
- /* @__PURE__ */ jsx5("p", { className: "dx-cwp__fine", children: FINE_PRINT })
712
- ] }) : null,
713
- error && /* @__PURE__ */ jsx5("div", { className: "dx-cwp__err", role: "alert", "aria-live": "assertive", children: error.message || error.code }),
714
- /* @__PURE__ */ jsx5("p", { className: "dx-cwp__status", role: "status", "aria-live": "polite", children: running ? phase ? ceremonyPhaseLabel(phase) : "Starting your passkey\u2026" : resolvedTransport === "unknown" ? "Preparing secure wallet setup\u2026" : hosted ? "Name, allowance, and passkey confirmation happen in the Dexter window." : policy ? "Allowance selected. Your passkey will create and secure the wallet." : "Choose an allowance to continue." }),
715
- /* @__PURE__ */ jsx5(
776
+ /* @__PURE__ */ jsx2("p", { className: "dx-cwp__fine", children: FINE_PRINT })
777
+ ] }) : null : null,
778
+ error && /* @__PURE__ */ jsx2("div", { className: "dx-cwp__err", role: "alert", "aria-live": "assertive", children: error.message || error.code }),
779
+ statusText && /* @__PURE__ */ jsx2("p", { className: "dx-cwp__status", role: "status", "aria-live": "polite", children: statusText }),
780
+ /* @__PURE__ */ jsx2(
716
781
  DexterButton,
717
782
  {
718
783
  block: true,
@@ -728,9 +793,9 @@ function CreateWalletPanel(props) {
728
793
  }
729
794
 
730
795
  // src/AppInstallButtons.tsx
731
- import { useEffect as useEffect8, useId as useId3, useState as useState6 } from "react";
732
- import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
733
- var STYLE_ID3 = "dexter-connect-appinstall-styles";
796
+ import { useEffect as useEffect6, useId as useId3, useState as useState6 } from "react";
797
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
798
+ var STYLE_ID2 = "dexter-connect-appinstall-styles";
734
799
  var APPINSTALL_CSS = `
735
800
  .dx-appinstall{ display:flex; flex-wrap:wrap; gap:10px; }
736
801
  .dx-appinstall--block{ flex-direction:column; }
@@ -803,9 +868,9 @@ var APPINSTALL_CSS = `
803
868
  `;
804
869
  function ensureAppInstallStyles() {
805
870
  if (typeof document === "undefined") return;
806
- if (document.getElementById(STYLE_ID3)) return;
871
+ if (document.getElementById(STYLE_ID2)) return;
807
872
  const el = document.createElement("style");
808
- el.id = STYLE_ID3;
873
+ el.id = STYLE_ID2;
809
874
  el.textContent = APPINSTALL_CSS;
810
875
  document.head.appendChild(el);
811
876
  }
@@ -870,7 +935,7 @@ function AppInstallButtons(props) {
870
935
  className,
871
936
  onAction
872
937
  } = props;
873
- useEffect8(ensureAppInstallStyles, []);
938
+ useEffect6(ensureAppInstallStyles, []);
874
939
  const statusId = useId3();
875
940
  const hermesCommand = hermesInstallCommand(serverName, mcpUrl);
876
941
  const claudeCommand = claudeCodeInstallCommand(serverName, mcpUrl);
@@ -879,7 +944,7 @@ function AppInstallButtons(props) {
879
944
  const hermesErrorId = `${statusId}-hermes-error`;
880
945
  const claudeErrorId = `${statusId}-claude-error`;
881
946
  const buttons = {
882
- claude: /* @__PURE__ */ jsxs6(
947
+ claude: /* @__PURE__ */ jsxs3(
883
948
  "a",
884
949
  {
885
950
  className: appCx(block),
@@ -888,13 +953,13 @@ function AppInstallButtons(props) {
888
953
  rel: "noopener noreferrer",
889
954
  onClick: () => onAction?.("claude", "deeplink"),
890
955
  children: [
891
- /* @__PURE__ */ jsx6("img", { className: "dx-appbtn__logo", src: CLAUDE_MARK, alt: "", "aria-hidden": true }),
956
+ /* @__PURE__ */ jsx3("img", { className: "dx-appbtn__logo", src: CLAUDE_MARK, alt: "", "aria-hidden": true }),
892
957
  "Open in Claude"
893
958
  ]
894
959
  },
895
960
  "claude"
896
961
  ),
897
- chatgpt: /* @__PURE__ */ jsxs6(
962
+ chatgpt: /* @__PURE__ */ jsxs3(
898
963
  "a",
899
964
  {
900
965
  className: appCx(block),
@@ -903,39 +968,39 @@ function AppInstallButtons(props) {
903
968
  rel: "noopener noreferrer",
904
969
  onClick: () => onAction?.("chatgpt", "deeplink"),
905
970
  children: [
906
- /* @__PURE__ */ jsx6("img", { className: "dx-appbtn__logo", src: CHATGPT_MARK, alt: "", "aria-hidden": true }),
971
+ /* @__PURE__ */ jsx3("img", { className: "dx-appbtn__logo", src: CHATGPT_MARK, alt: "", "aria-hidden": true }),
907
972
  "Open ChatGPT plugins"
908
973
  ]
909
974
  },
910
975
  "chatgpt"
911
976
  ),
912
- cursor: /* @__PURE__ */ jsxs6(
977
+ cursor: /* @__PURE__ */ jsxs3(
913
978
  "a",
914
979
  {
915
980
  className: appCx(block),
916
981
  href: cursorInstallUrl(serverName, mcpUrl),
917
982
  onClick: () => onAction?.("cursor", "deeplink"),
918
983
  children: [
919
- /* @__PURE__ */ jsx6("img", { className: "dx-appbtn__logo", src: CURSOR_MARK, alt: "", "aria-hidden": true }),
984
+ /* @__PURE__ */ jsx3("img", { className: "dx-appbtn__logo", src: CURSOR_MARK, alt: "", "aria-hidden": true }),
920
985
  "Add to Cursor"
921
986
  ]
922
987
  },
923
988
  "cursor"
924
989
  ),
925
- vscode: /* @__PURE__ */ jsxs6(
990
+ vscode: /* @__PURE__ */ jsxs3(
926
991
  "a",
927
992
  {
928
993
  className: appCx(block),
929
994
  href: vscodeInstallUrl(serverName, mcpUrl),
930
995
  onClick: () => onAction?.("vscode", "deeplink"),
931
996
  children: [
932
- /* @__PURE__ */ jsx6("img", { className: "dx-appbtn__logo", src: VSCODE_MARK, alt: "", "aria-hidden": true }),
997
+ /* @__PURE__ */ jsx3("img", { className: "dx-appbtn__logo", src: VSCODE_MARK, alt: "", "aria-hidden": true }),
933
998
  "Add to VS Code"
934
999
  ]
935
1000
  },
936
1001
  "vscode"
937
1002
  ),
938
- hermes: /* @__PURE__ */ jsxs6(
1003
+ hermes: /* @__PURE__ */ jsxs3(
939
1004
  "button",
940
1005
  {
941
1006
  type: "button",
@@ -953,13 +1018,13 @@ function AppInstallButtons(props) {
953
1018
  }
954
1019
  },
955
1020
  children: [
956
- /* @__PURE__ */ jsx6("img", { className: "dx-appbtn__logo", src: HERMES_MARK, alt: "", "aria-hidden": true }),
957
- hermesStatus === "copied" ? /* @__PURE__ */ jsx6("span", { className: "dx-appbtn__copied", children: "Copied. Run it in your terminal" }) : hermesStatus === "copying" ? "Copying OAuth setup\u2026" : hermesStatus === "failed" ? "Try copying for Hermes" : "Copy OAuth setup for Hermes"
1021
+ /* @__PURE__ */ jsx3("img", { className: "dx-appbtn__logo", src: HERMES_MARK, alt: "", "aria-hidden": true }),
1022
+ hermesStatus === "copied" ? /* @__PURE__ */ jsx3("span", { className: "dx-appbtn__copied", children: "Copied. Run it in your terminal" }) : hermesStatus === "copying" ? "Copying OAuth setup\u2026" : hermesStatus === "failed" ? "Try copying for Hermes" : "Copy OAuth setup for Hermes"
958
1023
  ]
959
1024
  },
960
1025
  "hermes"
961
1026
  ),
962
- "claude-code": /* @__PURE__ */ jsxs6(
1027
+ "claude-code": /* @__PURE__ */ jsxs3(
963
1028
  "button",
964
1029
  {
965
1030
  type: "button",
@@ -977,14 +1042,14 @@ function AppInstallButtons(props) {
977
1042
  }
978
1043
  },
979
1044
  children: [
980
- /* @__PURE__ */ jsx6("img", { className: "dx-appbtn__logo", src: CLAUDE_MARK, alt: "", "aria-hidden": true }),
981
- claudeStatus === "copied" ? /* @__PURE__ */ jsx6("span", { className: "dx-appbtn__copied", children: "Copied. Run it in your terminal" }) : claudeStatus === "copying" ? "Copying setup\u2026" : claudeStatus === "failed" ? "Try copying for Claude Code" : "Copy for Claude Code"
1045
+ /* @__PURE__ */ jsx3("img", { className: "dx-appbtn__logo", src: CLAUDE_MARK, alt: "", "aria-hidden": true }),
1046
+ claudeStatus === "copied" ? /* @__PURE__ */ jsx3("span", { className: "dx-appbtn__copied", children: "Copied. Run it in your terminal" }) : claudeStatus === "copying" ? "Copying setup\u2026" : claudeStatus === "failed" ? "Try copying for Claude Code" : "Copy for Claude Code"
982
1047
  ]
983
1048
  },
984
1049
  "claude-code"
985
1050
  )
986
1051
  };
987
- return /* @__PURE__ */ jsxs6(
1052
+ return /* @__PURE__ */ jsxs3(
988
1053
  "div",
989
1054
  {
990
1055
  className: ["dx-appinstall", block ? "dx-appinstall--block" : "", className ?? ""].filter(Boolean).join(" "),
@@ -992,13 +1057,13 @@ function AppInstallButtons(props) {
992
1057
  "aria-label": `Add ${displayName} to an agent app`,
993
1058
  children: [
994
1059
  apps.map((app) => buttons[app] ?? null),
995
- /* @__PURE__ */ jsx6("span", { className: "dx-appinstall__sr-only", "aria-live": "polite", "aria-atomic": "true", children: [
1060
+ /* @__PURE__ */ jsx3("span", { className: "dx-appinstall__sr-only", "aria-live": "polite", "aria-atomic": "true", children: [
996
1061
  hermesStatus === "copied" ? "Hermes OAuth setup command copied." : "",
997
1062
  claudeStatus === "copied" ? "Claude Code setup command copied." : ""
998
1063
  ].filter(Boolean).join(" ") }),
999
- hermesStatus === "copied" ? /* @__PURE__ */ jsxs6("div", { className: "dx-appinstall__notice", children: [
1000
- /* @__PURE__ */ jsx6("p", { children: "Run the command in your terminal. It adds the hosted MCP with OAuth." }),
1001
- /* @__PURE__ */ jsx6(
1064
+ hermesStatus === "copied" ? /* @__PURE__ */ jsxs3("div", { className: "dx-appinstall__notice", children: [
1065
+ /* @__PURE__ */ jsx3("p", { children: "Run the command in your terminal. It adds the hosted MCP with OAuth." }),
1066
+ /* @__PURE__ */ jsx3(
1002
1067
  "a",
1003
1068
  {
1004
1069
  className: "dx-appinstall__open",
@@ -1009,9 +1074,9 @@ function AppInstallButtons(props) {
1009
1074
  }
1010
1075
  )
1011
1076
  ] }) : null,
1012
- hermesStatus === "failed" ? /* @__PURE__ */ jsxs6("div", { id: hermesErrorId, className: "dx-appinstall__error", role: "alert", children: [
1013
- /* @__PURE__ */ jsx6("label", { htmlFor: `${hermesErrorId}-command`, children: "Couldn't copy. Select this Hermes command and run it in your terminal." }),
1014
- /* @__PURE__ */ jsx6(
1077
+ hermesStatus === "failed" ? /* @__PURE__ */ jsxs3("div", { id: hermesErrorId, className: "dx-appinstall__error", role: "alert", children: [
1078
+ /* @__PURE__ */ jsx3("label", { htmlFor: `${hermesErrorId}-command`, children: "Couldn't copy. Select this Hermes command and run it in your terminal." }),
1079
+ /* @__PURE__ */ jsx3(
1015
1080
  "input",
1016
1081
  {
1017
1082
  id: `${hermesErrorId}-command`,
@@ -1022,14 +1087,14 @@ function AppInstallButtons(props) {
1022
1087
  }
1023
1088
  )
1024
1089
  ] }) : null,
1025
- claudeStatus === "copied" ? /* @__PURE__ */ jsx6("div", { className: "dx-appinstall__notice", children: /* @__PURE__ */ jsxs6("p", { children: [
1090
+ claudeStatus === "copied" ? /* @__PURE__ */ jsx3("div", { className: "dx-appinstall__notice", children: /* @__PURE__ */ jsxs3("p", { children: [
1026
1091
  "Run the command in your terminal. If sign-in is required, finish it from Claude Code's ",
1027
- /* @__PURE__ */ jsx6("code", { children: "/mcp" }),
1092
+ /* @__PURE__ */ jsx3("code", { children: "/mcp" }),
1028
1093
  " menu."
1029
1094
  ] }) }) : null,
1030
- claudeStatus === "failed" ? /* @__PURE__ */ jsxs6("div", { id: claudeErrorId, className: "dx-appinstall__error", role: "alert", children: [
1031
- /* @__PURE__ */ jsx6("label", { htmlFor: `${claudeErrorId}-command`, children: "Couldn't copy. Select this Claude Code command and run it in your terminal." }),
1032
- /* @__PURE__ */ jsx6(
1095
+ claudeStatus === "failed" ? /* @__PURE__ */ jsxs3("div", { id: claudeErrorId, className: "dx-appinstall__error", role: "alert", children: [
1096
+ /* @__PURE__ */ jsx3("label", { htmlFor: `${claudeErrorId}-command`, children: "Couldn't copy. Select this Claude Code command and run it in your terminal." }),
1097
+ /* @__PURE__ */ jsx3(
1033
1098
  "input",
1034
1099
  {
1035
1100
  id: `${claudeErrorId}-command`,
@@ -1050,17 +1115,13 @@ export {
1050
1115
  CreateWalletPanel,
1051
1116
  DexterButton,
1052
1117
  DexterMark,
1053
- DexterWalletChip,
1054
- DexterWalletMenu,
1055
- SignInWithDexter,
1118
+ REMOVE_DEXTER_FROM_DEVICE_CONFIRMATION,
1056
1119
  chatgptPluginsUrl,
1057
1120
  claudeCodeInstallCommand,
1058
1121
  claudeWebConnectorUrl,
1059
1122
  cursorInstallUrl,
1060
1123
  hermesInstallCommand,
1061
1124
  hermesOpenUrl,
1062
- useDexterWallet,
1063
- useIdentity,
1064
- useSignInWithDexter,
1125
+ useDexterConnection,
1065
1126
  vscodeInstallUrl
1066
1127
  };