@dexterai/connect 0.34.0 → 0.36.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/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import {
2
+ SESSION_TTL_30D,
2
3
  WalletAccountRelationController,
4
+ authoredPolicy,
3
5
  ceremonyPhaseLabel,
4
6
  connectDexterIdentity,
5
7
  createDexterControlModel,
@@ -8,22 +10,21 @@ import {
8
10
  passkeySignalSupport,
9
11
  prunePasskey,
10
12
  renamePasskey,
11
- syncAcceptedPasskeys
12
- } from "./chunk-SLI2QCWN.js";
13
+ syncAcceptedPasskeys,
14
+ usdToAtomic
15
+ } from "./chunk-5B3IO3JU.js";
13
16
  import {
14
17
  recoverMissingVaultForAccount,
15
18
  recoverWallet
16
- } from "./chunk-3SBEND6T.js";
19
+ } from "./chunk-ZVUFVXUG.js";
17
20
  import {
18
21
  ACCOUNT_IDENTITY_API_PATH,
19
22
  ConnectError,
20
23
  DEXTER_API_BASE,
21
24
  DEXTER_RP_ID,
22
- SESSION_TTL_30D,
23
25
  WALLET_ACCOUNT_BINDING_PATH,
24
26
  WALLET_PROOF_SESSION_STORAGE_PREFIX,
25
27
  accountBindingCandidate,
26
- authoredPolicy,
27
28
  bytesEqual,
28
29
  createWallet,
29
30
  createWalletAccountBindingClient,
@@ -38,10 +39,9 @@ import {
38
39
  shouldUsePopup,
39
40
  signInAccountAccess,
40
41
  signInAccountIdentity,
41
- usdToAtomic,
42
42
  walletBindingCandidate,
43
43
  walletProofSessionStore
44
- } from "./chunk-Q7HTBUJF.js";
44
+ } from "./chunk-SGWYN67U.js";
45
45
  import {
46
46
  base64ToBytes,
47
47
  base64urlToBytes,
@@ -233,6 +233,8 @@ var AccountOperationUnsettledError = class extends ConnectError {
233
233
  this.step = step;
234
234
  }
235
235
  };
236
+ var SETUP_ROUTE = { flow: "setup", prepare: "/setup/prepare", complete: "/setup/complete" };
237
+ var SEND_ROUTE = { flow: "send", prepare: "/send/prepare", complete: "/send/complete" };
236
238
  function record(value) {
237
239
  return value !== null && typeof value === "object" && !Array.isArray(value);
238
240
  }
@@ -311,7 +313,44 @@ function detailsFrom(value) {
311
313
  to: value.to ?? null
312
314
  });
313
315
  }
314
- function preparedFrom(value, identity) {
316
+ var isFlowName = (value) => value === "setup" || value === "send" || value === "connection";
317
+ var connectionKey = (value) => typeof value === "string" && /^[A-Za-z0-9_-]{1,128}$/.test(value);
318
+ function amountFrom(value) {
319
+ if (!record(value) || !units(value.amount) || !address(value.mint) || typeof value.decimals !== "number" || !Number.isInteger(value.decimals) || value.decimals < 0 || value.decimals > 18 || value.symbol !== null && value.symbol !== void 0 && !text(value.symbol, 20)) malformed();
320
+ return Object.freeze({
321
+ amount: value.amount,
322
+ mint: value.mint,
323
+ decimals: value.decimals,
324
+ symbol: value.symbol ?? null
325
+ });
326
+ }
327
+ function limitsFrom(value) {
328
+ if (!record(value) || typeof value.days !== "number" || !Number.isInteger(value.days) || value.days < 1 || value.days > 3660) malformed();
329
+ return Object.freeze({ perPayment: amountFrom(value.perPayment), per30Days: amountFrom(value.per30Days), days: value.days });
330
+ }
331
+ function clientFrom(value) {
332
+ if (!record(value) || !text(value.name, 80)) malformed();
333
+ const kind = value.kind === "chatgpt" || value.kind === "claude" ? value.kind : "other";
334
+ return Object.freeze({ name: value.name, kind });
335
+ }
336
+ function payeeFrom(value) {
337
+ if (value === null || value === void 0) return null;
338
+ if (!record(value) || !address(value.address) || value.name !== null && value.name !== void 0 && !text(value.name, 80)) malformed();
339
+ return Object.freeze({ name: value.name ?? null, address: value.address });
340
+ }
341
+ var CONNECTION_STATES = ["pending", "active", "stopped", "revoked"];
342
+ var connectionState = (value) => CONNECTION_STATES.includes(value) ? value : null;
343
+ function connectionDetailsFrom(value) {
344
+ if (!record(value) || !connectionKey(value.connectionId)) malformed();
345
+ return Object.freeze({
346
+ connectionId: value.connectionId,
347
+ limits: value.limits === void 0 || value.limits === null ? null : limitsFrom(value.limits),
348
+ payee: payeeFrom(value.payee),
349
+ client: value.client === void 0 || value.client === null ? null : clientFrom(value.client),
350
+ state: connectionState(value.state)
351
+ });
352
+ }
353
+ function preparedFrom(value, identity, flow) {
315
354
  if (record(value) && value.status === "complete" && (value.next === null || value.next === void 0)) return null;
316
355
  if (!record(value) || !text(value.operationId) || !text(value.step, 80) || typeof value.summary !== "string" || value.summary.length > 300 || !record(value.publicKey)) malformed();
317
356
  const options = value.publicKey;
@@ -333,7 +372,8 @@ function preparedFrom(value, identity) {
333
372
  summary: value.summary,
334
373
  statement: text(value.statement, 1e3) ? value.statement : null,
335
374
  stepsRemaining: typeof remaining === "number" && Number.isInteger(remaining) && remaining >= 0 ? remaining : null,
336
- details: detailsFrom(value.details),
375
+ details: flow === "connection" ? null : detailsFrom(value.details),
376
+ connection: flow === "connection" ? connectionDetailsFrom(value.details) : null,
337
377
  publicKey: Object.freeze({
338
378
  challenge: options.challenge,
339
379
  rpId: DEXTER_RP_ID,
@@ -350,12 +390,13 @@ function assertApprovalContext() {
350
390
  if (!browserSupportsWebAuthn()) throw new ConnectError("webauthn_unsupported");
351
391
  }
352
392
  var approvalInProgress = false;
353
- async function prepare(config, flow, body) {
393
+ async function prepare(config, route, body) {
354
394
  for (let attempt = 0; ; attempt += 1) {
355
395
  try {
356
396
  return preparedFrom(
357
- await call(config.identity, "POST", `/${flow}/prepare`, body, false, config.signal),
358
- config.identity
397
+ await call(config.identity, "POST", route.prepare, body, false, config.signal),
398
+ config.identity,
399
+ route.flow
359
400
  );
360
401
  } catch (cause) {
361
402
  if (!(cause instanceof ConnectError) || cause.code !== "chain_not_ready" || attempt >= NOT_READY_RETRIES) throw cause;
@@ -363,20 +404,31 @@ async function prepare(config, flow, body) {
363
404
  }
364
405
  }
365
406
  }
366
- async function complete(config, flow, body) {
407
+ async function complete(config, route, body) {
367
408
  try {
368
- return await call(config.identity, "POST", `/${flow}/complete`, body, true);
409
+ return await call(config.identity, "POST", route.complete, body, true);
369
410
  } catch (cause) {
370
411
  if (!(cause instanceof ConnectError) || cause.code !== "account_operation_uncertain") throw cause;
371
- return call(config.identity, "POST", `/${flow}/complete`, body, true);
412
+ return call(config.identity, "POST", route.complete, body, true);
372
413
  }
373
414
  }
415
+ function outcomeFrom(value) {
416
+ const outcome = {};
417
+ for (const key of ["connectionId", "state", "redirectUrl"]) {
418
+ if (text(value[key], 2048)) outcome[key] = value[key];
419
+ }
420
+ return Object.freeze(outcome);
421
+ }
374
422
  function confirmedFrom(value, flow) {
375
423
  if (!record(value) || value.status !== "confirmed") malformed();
376
424
  const held = flow === "setup" && (value.signature === null || value.signature === void 0);
377
425
  if (!held && !text(value.signature)) malformed();
378
426
  if (value.next !== null && value.next !== void 0 && !text(value.next, 80)) malformed();
379
- return { signature: held ? null : value.signature, next: value.next ?? null };
427
+ return {
428
+ signature: held ? null : value.signature,
429
+ next: value.next ?? null,
430
+ outcome: outcomeFrom(value)
431
+ };
380
432
  }
381
433
  async function settle(config, flow, step, operationId, cause) {
382
434
  let state;
@@ -385,13 +437,16 @@ async function settle(config, flow, step, operationId, cause) {
385
437
  } catch {
386
438
  throw new AccountOperationUnsettledError(operationId, flow, step);
387
439
  }
388
- if (state.status === "confirmed" && (state.signature || flow === "setup")) return { signature: state.signature, next: state.next };
440
+ if (state.status === "confirmed" && (state.signature || flow === "setup")) {
441
+ return { signature: state.signature, next: state.next, outcome: state.outcome };
442
+ }
389
443
  if (state.status === "failed" || state.status === "prepared" || state.status === "expired") {
390
444
  throw cause instanceof ConnectError && cause.code !== "account_operation_uncertain" ? cause : new ConnectError("account_operation_failed");
391
445
  }
392
446
  throw new AccountOperationUnsettledError(operationId, flow, step);
393
447
  }
394
- async function runFlow(config, flow, body, check) {
448
+ async function runFlow(config, route, body, check) {
449
+ const { flow } = route;
395
450
  assertApprovalContext();
396
451
  if (approvalInProgress) throw new ConnectError("account_operation_in_progress");
397
452
  approvalInProgress = true;
@@ -399,15 +454,16 @@ async function runFlow(config, flow, body, check) {
399
454
  try {
400
455
  for (let count = 0; count < MAX_STEPS; count += 1) {
401
456
  cancelled(config.signal);
402
- const prepared = await prepare(config, flow, body);
403
- if (prepared === null) return Object.freeze({ signatures: Object.freeze(signatures) });
404
- check?.(prepared.step, prepared.details);
457
+ const prepared = await prepare(config, route, body);
458
+ if (prepared === null) return Object.freeze({ signatures: Object.freeze(signatures), outcome: Object.freeze({}) });
459
+ check?.(prepared.step, { details: prepared.details, connection: prepared.connection });
405
460
  const view = {
406
461
  step: prepared.step,
407
462
  summary: prepared.summary,
408
463
  statement: prepared.statement,
409
464
  stepsRemaining: prepared.stepsRemaining,
410
465
  details: prepared.details,
466
+ connection: prepared.connection,
411
467
  signature: null
412
468
  };
413
469
  if (config.confirmStep) {
@@ -433,7 +489,7 @@ async function runFlow(config, flow, body, check) {
433
489
  config.onStep?.({ ...view, phase: "sending" });
434
490
  let result;
435
491
  try {
436
- result = confirmedFrom(await complete(config, flow, {
492
+ result = confirmedFrom(await complete(config, route, {
437
493
  operationId: prepared.operationId,
438
494
  assertion: {
439
495
  credentialId: credential.id,
@@ -449,13 +505,14 @@ async function runFlow(config, flow, body, check) {
449
505
  if (result.signature) signatures.push(result.signature);
450
506
  config.onStep?.({ ...view, phase: "confirmed", signature: result.signature });
451
507
  const next = result.next;
452
- if (next === null) return Object.freeze({ signatures: Object.freeze(signatures) });
508
+ if (next === null) return Object.freeze({ signatures: Object.freeze(signatures), outcome: result.outcome });
453
509
  config.onStep?.({
454
510
  step: next,
455
511
  summary: "",
456
512
  statement: null,
457
513
  stepsRemaining: null,
458
514
  details: null,
515
+ connection: null,
459
516
  signature: null,
460
517
  phase: "preparing"
461
518
  });
@@ -477,21 +534,22 @@ async function getAccountOverview(config) {
477
534
  const created = record(raw) && text(raw.createdAt, 40) && !Number.isNaN(Date.parse(raw.createdAt)) ? raw.createdAt : null;
478
535
  const passkey = record(raw) ? Object.freeze({ name: text(raw.name, 80) ? raw.name : null, createdAt: created }) : null;
479
536
  const pending = body.unsettled;
480
- const unsettled = record(pending) && text(pending.operationId) && (pending.flow === "setup" || pending.flow === "send") && text(pending.step, 80) ? Object.freeze({ operationId: pending.operationId, flow: pending.flow, step: pending.step }) : null;
537
+ const unsettled = record(pending) && text(pending.operationId) && isFlowName(pending.flow) && text(pending.step, 80) ? Object.freeze({ operationId: pending.operationId, flow: pending.flow, step: pending.step }) : null;
481
538
  return Object.freeze({ account, network, passkey, unsettled });
482
539
  }
483
540
  async function getAccountOperation(config) {
484
541
  if (!text(config.operationId) || !/^[A-Za-z0-9_-]+$/.test(config.operationId)) throw new ConnectError("invalid_account_operation");
485
542
  const value = await call(config.identity, "GET", `/operations/${config.operationId}`, void 0, false, config.signal);
486
543
  const statuses = ["prepared", "sending", "confirmed", "failed", "expired"];
487
- if (!record(value) || value.operationId !== config.operationId || value.flow !== "setup" && value.flow !== "send" || !text(value.step, 80) || typeof value.status !== "string" || !statuses.includes(value.status) || value.signature !== null && value.signature !== void 0 && !text(value.signature) || value.next !== null && value.next !== void 0 && !text(value.next, 80) || value.status === "confirmed" && value.flow === "send" && !text(value.signature)) malformed();
544
+ if (!record(value) || value.operationId !== config.operationId || !isFlowName(value.flow) || !text(value.step, 80) || typeof value.status !== "string" || !statuses.includes(value.status) || value.signature !== null && value.signature !== void 0 && !text(value.signature) || value.next !== null && value.next !== void 0 && !text(value.next, 80) || value.status === "confirmed" && value.flow !== "setup" && !text(value.signature)) malformed();
488
545
  return Object.freeze({
489
546
  operationId: value.operationId,
490
547
  flow: value.flow,
491
548
  step: value.step,
492
549
  status: value.status,
493
550
  signature: value.signature ?? null,
494
- next: value.next ?? null
551
+ next: value.next ?? null,
552
+ outcome: outcomeFrom(value)
495
553
  });
496
554
  }
497
555
  async function getAccountBalances(config) {
@@ -523,10 +581,11 @@ async function openAccount(config) {
523
581
  statement: null,
524
582
  stepsRemaining: null,
525
583
  details: null,
584
+ connection: null,
526
585
  signature: null,
527
586
  phase: "preparing"
528
587
  });
529
- await runFlow(config, "setup", {});
588
+ await runFlow(config, SETUP_ROUTE, {});
530
589
  const account = await getAccount(config);
531
590
  if (!account) malformed();
532
591
  return account;
@@ -537,7 +596,7 @@ async function sendFromAccount(config) {
537
596
  throw new ConnectError("invalid_account_send");
538
597
  }
539
598
  const request = { mint: send.mint, amount: send.amount, to: send.to };
540
- return runFlow(config, "send", request, (step, details) => {
599
+ return runFlow(config, SEND_ROUTE, request, (step, { details }) => {
541
600
  const sameToken = details !== null && details.mint === request.mint;
542
601
  if (step === "prepare-token" ? !sameToken || details.amount !== null || details.to !== null : !sameToken || details.amount !== request.amount || details.to !== request.to) {
543
602
  throw new ConnectError("account_operation_mismatch");
@@ -562,6 +621,94 @@ function parseAccountAmount(input, decimals) {
562
621
  const value = BigInt(`${match[1] || "0"}${fraction.padEnd(decimals, "0")}`);
563
622
  return value > 0n && value < 1n << 64n ? value.toString() : null;
564
623
  }
624
+ var hostName = (value) => typeof value === "string" && /^[a-z0-9.-]{1,253}(:[0-9]{1,5})?$/i.test(value);
625
+ var time = (value) => text(value, 40) && !Number.isNaN(Date.parse(value)) ? value : null;
626
+ function connectionFrom(value) {
627
+ if (!record(value) || !connectionKey(value.connectionId)) malformed();
628
+ const state = connectionState(value.state);
629
+ if (state === null) malformed();
630
+ return Object.freeze({
631
+ connectionId: value.connectionId,
632
+ client: clientFrom(value.client),
633
+ limits: limitsFrom(value.limits),
634
+ spent30Days: value.spent30Days === null || value.spent30Days === void 0 ? null : amountFrom(value.spent30Days),
635
+ state,
636
+ createdAt: time(value.createdAt),
637
+ stoppedAt: time(value.stoppedAt),
638
+ revokedAt: time(value.revokedAt)
639
+ });
640
+ }
641
+ async function getConnectionRequest(config) {
642
+ if (!connectionKey(config.requestId)) throw new ConnectError("invalid_connection_request");
643
+ const value = await call(config.identity, "GET", `/connections/requests/${config.requestId}`, void 0, false, config.signal);
644
+ if (!record(value) || value.requestId !== config.requestId || !record(value.client) || !hostName(value.client.redirectHost) || !text(value.scope, 80)) malformed();
645
+ return Object.freeze({
646
+ requestId: value.requestId,
647
+ client: Object.freeze({ ...clientFrom(value.client), redirectHost: value.client.redirectHost.toLowerCase() }),
648
+ scope: value.scope,
649
+ limits: limitsFrom(value.limits),
650
+ payee: payeeFrom(value.payee),
651
+ expiresAt: time(value.expiresAt)
652
+ });
653
+ }
654
+ async function listConnections(config) {
655
+ const value = await call(config.identity, "GET", "/connections", void 0, false, config.signal);
656
+ if (!record(value) || !Array.isArray(value.connections)) malformed();
657
+ return Object.freeze(value.connections.map(connectionFrom));
658
+ }
659
+ async function getConnection(config) {
660
+ if (!connectionKey(config.connectionId)) throw new ConnectError("invalid_connection");
661
+ const value = connectionFrom(await call(config.identity, "GET", `/connections/${config.connectionId}`, void 0, false, config.signal));
662
+ if (value.connectionId !== config.connectionId) malformed();
663
+ return value;
664
+ }
665
+ async function grantConnection(config) {
666
+ const { request } = config;
667
+ if (!record(request) || !connectionKey(request.requestId) || !record(request.client) || !hostName(request.client.redirectHost)) {
668
+ throw new ConnectError("invalid_connection_request");
669
+ }
670
+ let promised = null;
671
+ const result = await runFlow(
672
+ config,
673
+ { flow: "connection", prepare: "/connections/grant/prepare", complete: "/connections/grant/complete" },
674
+ { requestId: request.requestId },
675
+ (step, { connection }) => {
676
+ if (step !== "grant-permission" || connection === null || promised !== null && connection.connectionId !== promised) {
677
+ throw new ConnectError("account_operation_mismatch");
678
+ }
679
+ promised = connection.connectionId;
680
+ }
681
+ );
682
+ const connectionId = result.outcome.connectionId;
683
+ const redirectUrl = result.outcome.redirectUrl;
684
+ if (!connectionKey(connectionId) || promised !== null && connectionId !== promised || !text(redirectUrl, 2048)) malformed();
685
+ let target;
686
+ try {
687
+ target = new URL(redirectUrl);
688
+ } catch {
689
+ throw new ConnectError("connection_redirect_refused");
690
+ }
691
+ if (target.protocol !== "https:" || target.host.toLowerCase() !== request.client.redirectHost.toLowerCase()) {
692
+ throw new ConnectError("connection_redirect_refused");
693
+ }
694
+ return Object.freeze({ ...result, connectionId, redirectUrl: target.toString() });
695
+ }
696
+ async function revokeConnection(config) {
697
+ const { connectionId } = config;
698
+ if (!connectionKey(connectionId)) throw new ConnectError("invalid_connection");
699
+ const result = await runFlow(
700
+ config,
701
+ { flow: "connection", prepare: `/connections/${connectionId}/revoke/prepare`, complete: "/connections/revoke/complete" },
702
+ {},
703
+ (step, { connection }) => {
704
+ if (step !== "revoke-permission" || connection?.connectionId !== connectionId) {
705
+ throw new ConnectError("account_operation_mismatch");
706
+ }
707
+ }
708
+ );
709
+ if (result.outcome.connectionId !== connectionId || result.outcome.state !== "revoked") malformed();
710
+ return Object.freeze({ ...result, state: "revoked" });
711
+ }
565
712
 
566
713
  // src/agentSpend.ts
567
714
  import { PublicKey as PublicKey2 } from "@solana/web3.js";
@@ -1279,6 +1426,50 @@ async function readAgentAuthority(input) {
1279
1426
  }
1280
1427
  return payload;
1281
1428
  }
1429
+
1430
+ // src/accountChallenge.ts
1431
+ import { browserSupportsWebAuthn as browserSupportsWebAuthn2, startAuthentication as startAuthentication2 } from "@simplewebauthn/browser";
1432
+ var MAX_CHALLENGE_BYTES = 1024;
1433
+ async function signAccountChallenge(config) {
1434
+ const { connectionRequest, principal } = config;
1435
+ const refused = (reason, detail) => ({ status: "refused", reason, ...detail ? { detail } : {}, ...connectionRequest ? { connectionRequest } : {} });
1436
+ if (!(config.challenge instanceof Uint8Array) || config.challenge.length < 16 || config.challenge.length > MAX_CHALLENGE_BYTES) {
1437
+ return refused("invalid_challenge", "challenge must be 16 to 1024 bytes");
1438
+ }
1439
+ if (!browserSupportsWebAuthn2()) return refused("webauthn_unavailable");
1440
+ const allow = config.allowCredentialIds?.filter((id) => typeof id === "string" && id.length > 0) ?? [];
1441
+ let credential;
1442
+ try {
1443
+ credential = await startAuthentication2({
1444
+ optionsJSON: {
1445
+ challenge: bytesToBase64url(config.challenge),
1446
+ ...config.rpId ? { rpId: config.rpId } : {},
1447
+ ...allow.length ? { allowCredentials: allow.map((id) => ({ id, type: "public-key" })) } : {},
1448
+ userVerification: "required",
1449
+ ...config.timeoutMs ? { timeout: config.timeoutMs } : {}
1450
+ }
1451
+ });
1452
+ } catch (cause) {
1453
+ const name = cause instanceof Error ? cause.name : "";
1454
+ if (name === "NotAllowedError" || name === "AbortError") {
1455
+ return { status: "cancelled", ...connectionRequest ? { connectionRequest } : {} };
1456
+ }
1457
+ return refused("webauthn_failed", cause instanceof Error ? cause.message : String(cause));
1458
+ }
1459
+ if (allow.length && !allow.includes(credential.id)) return refused("credential_not_allowed");
1460
+ return {
1461
+ status: "signed",
1462
+ assertion: {
1463
+ credentialId: credential.id,
1464
+ authenticatorData: credential.response.authenticatorData,
1465
+ clientDataJSON: credential.response.clientDataJSON,
1466
+ signature: credential.response.signature,
1467
+ userHandle: credential.response.userHandle ?? null
1468
+ },
1469
+ ...connectionRequest ? { connectionRequest } : {},
1470
+ ...principal ? { principal } : {}
1471
+ };
1472
+ }
1282
1473
  export {
1283
1474
  ACCOUNT_API_PATH,
1284
1475
  ACCOUNT_IDENTITY_API_PATH,
@@ -1329,6 +1520,10 @@ export {
1329
1520
  getAccountBalances,
1330
1521
  getAccountOperation,
1331
1522
  getAccountOverview,
1523
+ getConnection,
1524
+ getConnectionRequest,
1525
+ grantConnection,
1526
+ listConnections,
1332
1527
  noCustomX402Limits,
1333
1528
  openAccount,
1334
1529
  parseAccountAmount,
@@ -1339,7 +1534,9 @@ export {
1339
1534
  recoverWallet,
1340
1535
  renamePasskey,
1341
1536
  revokeAgentSpend,
1537
+ revokeConnection,
1342
1538
  sendFromAccount,
1539
+ signAccountChallenge,
1343
1540
  signInAccountAccess,
1344
1541
  signInAccountIdentity,
1345
1542
  stageAgentAuthority,
package/dist/react.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { f as ConnectError, S as SignInResult, I as PasskeyLoginConfig, A as AccountIdentityResult, C as CreateWalletResult, m as AgentDelegationMode } from './accountIdentity-DQ_C-WAi.js';
2
- export { d as ConnectVault, R as RecoverOutcome, t as RecoverVault, g as WalletIdentityProof } from './accountIdentity-DQ_C-WAi.js';
3
- import { i as DexterControlModel, a as WalletAccountRelationSnapshot, g as DexterConnectionIntent, e as AccountSessionInstaller, d as AccountSessionClearer, B as BindingFetch } from './connectionContract-BA03zq2D.js';
4
- export { D as DexterConnectionCapability, h as DexterConnectionPermissions, j as DexterControlPrimaryAction, k as DexterControlStage } from './connectionContract-BA03zq2D.js';
1
+ import { f as ConnectError, S as SignInResult, I as PasskeyLoginConfig, A as AccountIdentityResult, C as CreateWalletResult, m as AgentDelegationMode } from './accountIdentity-BHazSkuz.js';
2
+ export { d as ConnectVault, R as RecoverOutcome, t as RecoverVault, g as WalletIdentityProof } from './accountIdentity-BHazSkuz.js';
3
+ import { i as DexterControlModel, a as WalletAccountRelationSnapshot, g as DexterConnectionIntent, e as AccountSessionInstaller, d as AccountSessionClearer, B as BindingFetch } from './connectionContract-CSZiddpS.js';
4
+ export { D as DexterConnectionCapability, h as DexterConnectionPermissions, j as DexterControlPrimaryAction, k as DexterControlStage } from './connectionContract-CSZiddpS.js';
5
5
  import * as react from 'react';
6
6
  import { ButtonHTMLAttributes, ReactNode, ReactElement, ComponentType, AnchorHTMLAttributes } from 'react';
7
7
 
@@ -140,6 +140,20 @@ interface CreateWalletPanelProps {
140
140
  terminology?: 'wallet' | 'account';
141
141
  /** Hide when the containing panel already carries Dexter's mark. */
142
142
  withMark?: boolean;
143
+ /**
144
+ * Account wording only: fired with the new Account when the host has no
145
+ * credential handler. Dexter Wallet is now Dexter Account, so account wording always
146
+ * enrolls an Account; without either handler the panel says where it works.
147
+ */
148
+ onAccountCreated?: (result: AccountIdentityResult) => void;
149
+ /** An equal-weight second choice shown beside the create button (e.g. Sign in). */
150
+ secondaryAction?: {
151
+ label: string;
152
+ onClick: () => void;
153
+ disabled?: boolean;
154
+ };
155
+ /** Replaces the passkey hint under the buttons. */
156
+ passkeyHintText?: string;
143
157
  }
144
158
  /** The turnkey consent-at-birth create panel. */
145
159
  declare function CreateWalletPanel(props: CreateWalletPanelProps): ReactElement;
package/dist/react.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import {
2
+ authoredPolicy,
2
3
  ceremonyPhaseLabel,
3
4
  connectDexterIdentity,
4
5
  createDexterControlModel,
@@ -7,10 +8,9 @@ import {
7
8
  passkeySignalSupport,
8
9
  prunePasskey,
9
10
  renamePasskey
10
- } from "./chunk-SLI2QCWN.js";
11
+ } from "./chunk-5B3IO3JU.js";
11
12
  import {
12
13
  ConnectError,
13
- authoredPolicy,
14
14
  createWallet,
15
15
  disconnectActiveWallet,
16
16
  ejectActiveWallet,
@@ -26,7 +26,7 @@ import {
26
26
  subscribe,
27
27
  switchWallet,
28
28
  walletProofSessionStore
29
- } from "./chunk-Q7HTBUJF.js";
29
+ } from "./chunk-SGWYN67U.js";
30
30
  import {
31
31
  DexterButton,
32
32
  DexterMark,
@@ -716,6 +716,8 @@ function CreateWalletPanel(props) {
716
716
  } = props;
717
717
  const account = terminology === "account";
718
718
  const credentialOnly = !!props.onCredentialCreated;
719
+ const { secondaryAction } = props;
720
+ const [accountReady, setAccountReady] = useState5(false);
719
721
  useEffect5(ensureConsentStyles, []);
720
722
  useEffect5(ensureDexterButtonStyles, []);
721
723
  const nameInputId = useId2();
@@ -732,7 +734,7 @@ function CreateWalletPanel(props) {
732
734
  }, [transport]);
733
735
  const hosted = resolvedTransport === "popup";
734
736
  const ownerOnly = credentialOnly || agentDelegation === "deferred";
735
- const passkeyHint = account && ownerOnly && resolvedTransport === "inline";
737
+ const passkeyHint = Boolean(secondaryAction) || account && ownerOnly && resolvedTransport === "inline";
736
738
  const policy = resolvedTransport === "inline" && !ownerOnly ? authoredPolicy(value ?? "") : null;
737
739
  const canContinue = hosted || ownerOnly || Boolean(policy);
738
740
  const statusText = running ? phase ? ceremonyPhaseLabel(phase) : "Starting your passkey\u2026" : resolvedTransport === "unknown" ? account ? "Preparing account setup..." : "Preparing wallet setup\u2026" : hosted ? account ? "Account setup continues in Dexter." : "Wallet setup continues in Dexter Wallet." : ownerOnly ? "" : policy ? "Ready to create." : "Choose an agent allowance.";
@@ -743,9 +745,11 @@ function CreateWalletPanel(props) {
743
745
  setRunning(true);
744
746
  setPhase(null);
745
747
  try {
746
- if (props.onCredentialCreated) {
748
+ if (props.onCredentialCreated || account) {
747
749
  const result2 = await enrollAccountIdentity({ name: hosted ? void 0 : name.trim() || void 0, apiBase, transport, onPhase: setPhase });
748
- props.onCredentialCreated(result2);
750
+ if (props.onCredentialCreated) props.onCredentialCreated(result2);
751
+ else if (props.onAccountCreated) props.onAccountCreated(result2);
752
+ else setAccountReady(true);
749
753
  return;
750
754
  }
751
755
  const result = await createWallet({
@@ -793,7 +797,33 @@ function CreateWalletPanel(props) {
793
797
  ] }) : null : null,
794
798
  error && /* @__PURE__ */ jsx2("div", { className: "dx-cwp__err", role: "alert", "aria-live": "assertive", children: error.message || error.code }),
795
799
  statusText && /* @__PURE__ */ jsx2("p", { className: "dx-cwp__status", role: "status", "aria-live": "polite", children: statusText }),
796
- /* @__PURE__ */ jsx2(
800
+ accountReady ? /* @__PURE__ */ jsx2("p", { className: "dx-cwp__status", role: "status", "aria-live": "polite", children: "Your Dexter Account is ready. It works at dexter.cash; this app can't use it yet." }) : secondaryAction ? /* @__PURE__ */ jsxs2("div", { className: "dx-cwp__choices", children: [
801
+ /* @__PURE__ */ jsx2(
802
+ "button",
803
+ {
804
+ type: "button",
805
+ className: "dx-cwp__secondary",
806
+ "aria-describedby": `${nameInputId}-hint`,
807
+ disabled: running || secondaryAction.disabled,
808
+ onClick: secondaryAction.onClick,
809
+ children: secondaryAction.label
810
+ }
811
+ ),
812
+ /* @__PURE__ */ jsx2(
813
+ DexterButton,
814
+ {
815
+ block: true,
816
+ withMark,
817
+ className: "dx-cwp__cta",
818
+ "aria-describedby": passkeyHint ? `${nameInputId}-hint` : void 0,
819
+ loading: running,
820
+ loadingLabel: phase ? ceremonyPhaseLabel(phase) : "Creating\u2026",
821
+ disabled: !canContinue || resolvedTransport === "unknown",
822
+ onClick: handleCreate,
823
+ children: error ? "Retry" : account ? "Create my account" : "Create your Dexter Wallet"
824
+ }
825
+ )
826
+ ] }) : /* @__PURE__ */ jsx2(
797
827
  DexterButton,
798
828
  {
799
829
  block: true,
@@ -807,11 +837,11 @@ function CreateWalletPanel(props) {
807
837
  children: error ? "Retry" : hosted ? account ? "Continue to Dexter" : "Continue to Dexter Wallet" : account ? ownerOnly ? "Create my account" : "Create account" : "Create your Dexter Wallet"
808
838
  }
809
839
  ),
810
- passkeyHint && /* @__PURE__ */ jsx2("p", { className: "dx-cwp__hint", id: `${nameInputId}-hint`, children: "Your device will ask for a passkey." }),
840
+ passkeyHint && !accountReady && /* @__PURE__ */ jsx2("p", { className: "dx-cwp__hint", id: `${nameInputId}-hint`, children: props.passkeyHintText ?? "Your device will ask for a passkey." }),
811
841
  showName === "on-request" && resolvedTransport === "inline" && /* @__PURE__ */ jsxs2("details", { className: "dx-cwp__naming", children: [
812
842
  /* @__PURE__ */ jsxs2("summary", { children: [
813
843
  "Name this ",
814
- credentialOnly ? "passkey" : account ? "account" : "wallet"
844
+ credentialOnly || account ? "passkey" : "wallet"
815
845
  ] }),
816
846
  nameField
817
847
  ] })
@@ -972,6 +1002,43 @@ var ACCOUNT_CONTROL_CSS = `.dx-account-control,.dx-account-panel,.dx-account-pan
972
1002
  letter-spacing: -.01em;
973
1003
  }
974
1004
  .dx-account-creation .dx-cwp__cta:hover:enabled { filter: brightness(1.045); }
1005
+ .dx-account-creation .dx-cwp__choices {
1006
+ display: grid;
1007
+ grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr));
1008
+ gap: 10px;
1009
+ width: 100%;
1010
+ }
1011
+ .dx-account-creation .dx-cwp__choices .dx-cwp__cta { width: 100%; min-width: 0; }
1012
+ .dx-account-creation .dx-cwp__secondary {
1013
+ box-sizing: border-box;
1014
+ width: 100%;
1015
+ min-width: 0;
1016
+ min-height: 48px;
1017
+ margin: 0;
1018
+ padding: 12px 22px;
1019
+ border: 1px solid #2b1b12;
1020
+ border-radius: 2px;
1021
+ background: #2b1b12;
1022
+ box-shadow: inset 0 1px 0 #ffffff1f, 0 1px 0 #2b1b1226;
1023
+ color: #fff8f1;
1024
+ font: inherit;
1025
+ font-size: 16px;
1026
+ font-weight: 700;
1027
+ line-height: 1.25;
1028
+ letter-spacing: -.01em;
1029
+ text-align: center;
1030
+ cursor: pointer;
1031
+ transition: background-color 140ms;
1032
+ }
1033
+ .dx-account-creation .dx-cwp__secondary:hover:enabled { background: #3d2a1f; }
1034
+ .dx-account-creation .dx-cwp__secondary:active:enabled,
1035
+ .dx-account-creation .dx-cwp__cta:active:enabled { transform: translateY(1px); }
1036
+ .dx-account-creation .dx-cwp__choices + .dx-cwp__hint { margin-top: 8px; text-align: center; }
1037
+ @media (prefers-reduced-motion: reduce) {
1038
+ .dx-account-creation .dx-cwp__secondary { transition: none; }
1039
+ .dx-account-creation .dx-cwp__secondary:active:enabled,
1040
+ .dx-account-creation .dx-cwp__cta:active:enabled { transform: none; }
1041
+ }
975
1042
  .dx-account-creation .dx-cwp__hint,
976
1043
  .dx-account-creation .dx-cwp__status,
977
1044
  .dx-account-creation .dx-cwp__hosted {
@@ -1520,6 +1587,15 @@ function DexterAccountControl({
1520
1587
  terminology: "account",
1521
1588
  showName: "on-request",
1522
1589
  withMark: false,
1590
+ secondaryAction: {
1591
+ label: "Sign in",
1592
+ disabled: busy,
1593
+ onClick: () => {
1594
+ setCreateOpen(false);
1595
+ void run(credentialEntry ? "credential" : "connect");
1596
+ }
1597
+ },
1598
+ passkeyHintText: "Either way, your device asks for a passkey.",
1523
1599
  onCredentialCreated: credentialEntry ? (result) => {
1524
1600
  credentialEntry.accept(result);
1525
1601
  setCreateOpen(false);
@@ -1536,8 +1612,7 @@ function DexterAccountControl({
1536
1612
  setCreateOpen(false);
1537
1613
  }
1538
1614
  }
1539
- ),
1540
- /* @__PURE__ */ jsx6("button", { type: "button", className: "dx-welcome-link", onClick: () => setCreateOpen(false), children: "Sign in instead" })
1615
+ )
1541
1616
  ] }),
1542
1617
  /* @__PURE__ */ jsxs5("footer", { className: "dx-welcome-terms", children: [
1543
1618
  "By creating an account, you agree to the",
package/package.json CHANGED
@@ -1,7 +1,15 @@
1
1
  {
2
2
  "name": "@dexterai/connect",
3
- "version": "0.34.0",
3
+ "version": "0.36.0",
4
4
  "description": "Connect apps and agents to a self-custodial Dexter Wallet with passkey identity, governed authority, hosted signing, and verifiable sessions.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/Dexter-DAO/dexter-connect.git"
8
+ },
9
+ "homepage": "https://github.com/Dexter-DAO/dexter-connect#readme",
10
+ "bugs": {
11
+ "url": "https://github.com/Dexter-DAO/dexter-connect/issues"
12
+ },
5
13
  "type": "module",
6
14
  "packageManager": "npm@10.9.3",
7
15
  "exports": {
@@ -65,5 +73,9 @@
65
73
  "@simplewebauthn/browser": "^13.3.0",
66
74
  "framer-motion": "^12.43.0",
67
75
  "jose": "^6.2.3"
76
+ },
77
+ "publishConfig": {
78
+ "access": "public",
79
+ "provenance": true
68
80
  }
69
81
  }