@dexterai/connect 0.33.0 → 0.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -62,7 +62,7 @@ returns only the ordinary identity result to the requesting app.
62
62
  These exports need the matching API identity profile and hosted page. Source
63
63
  checks do not establish package publication or production availability.
64
64
 
65
- ## Dexter Account operations (unreleased)
65
+ ## Dexter Account operations
66
66
 
67
67
  An Account session opens and uses a Dexter Account through one approval step.
68
68
  The API prepares one exact operation, the owner approves it with the passkey
@@ -89,6 +89,8 @@ await sendFromAccount({ identity, send: { mint, amount: '2500000', to } });
89
89
  - Once an approval has gone out, the step may land even if the reply never comes. Any failure of `complete` is checked against the API's record of the operation. A confirmed step carries on. A step the API records as failed, still prepared or expired throws its error, and only then has nothing been sent. Anything else throws `AccountOperationUnsettledError`, which carries `operationId`. Don't say nothing was sent, and don't offer the same send again. Read the outcome with `getAccountOperation({ identity, operationId })`. `getAccountOverview` returns `unsettled` after a reload or a new sign-in.
90
90
  - The caller's `signal` stops a flow up to the approval. After that the flow waits for the API's answer, so leaving the page can't turn an unknown outcome into a reported failure.
91
91
  - `statement` is the kit's own text for what the passkey signs, when the API sends it.
92
+ - With lazy opening, sign-up's approvals are checked and held, not sent. Each setup step can be confirmed with `signature: null`, and the Account's status is then `held`: its address takes money at once and it opens on the chain by itself on the first money or the first action. Show a `held` Account exactly like a `ready` one; `openAccount` returns it without prompting. A send is never taken as confirmed without the signature of what it sent.
93
+ - The first action on a held Account finishes the opening inside that request, so it can take a minute. Connect sets no timeout of its own on these requests.
92
94
 
93
95
  ## Interrupted wallet setup
94
96
 
package/dist/index.d.ts CHANGED
@@ -86,7 +86,11 @@ declare const ACCOUNT_API_PATH = "/api/account/v1";
86
86
  interface DexterAccount {
87
87
  readonly principal: string;
88
88
  readonly wallet: string | null;
89
- readonly status: 'ready' | 'setting-up';
89
+ /**
90
+ * `held`: the Account's address is real and takes money now; it opens on the
91
+ * chain by itself on the first money or the first action. Show it as `ready`.
92
+ */
93
+ readonly status: 'ready' | 'held' | 'setting-up';
90
94
  readonly nextStep: string | null;
91
95
  }
92
96
  /** The passkey the session is bound to, as its owner would recognise it. */
@@ -177,7 +181,7 @@ interface AccountOperationConfig {
177
181
  readonly signal?: AbortSignal;
178
182
  }
179
183
  interface AccountFlowResult {
180
- /** Transaction signatures, one per approved step, in order. */
184
+ /** Signatures of the transactions the flow sent, in order. A held setup step sends none. */
181
185
  readonly signatures: readonly string[];
182
186
  }
183
187
  /**
package/dist/index.js CHANGED
@@ -291,7 +291,7 @@ function accountFrom(value) {
291
291
  if (!record(value) || !("account" in value)) malformed();
292
292
  const account = value.account;
293
293
  if (account === null) return null;
294
- if (!record(account) || !address(account.principal) || account.wallet !== null && account.wallet !== void 0 && !address(account.wallet) || account.status !== "ready" && account.status !== "setting-up" || account.nextStep !== null && account.nextStep !== void 0 && !text(account.nextStep, 80)) malformed();
294
+ if (!record(account) || !address(account.principal) || account.wallet !== null && account.wallet !== void 0 && !address(account.wallet) || account.status !== "ready" && account.status !== "held" && account.status !== "setting-up" || account.nextStep !== null && account.nextStep !== void 0 && !text(account.nextStep, 80)) malformed();
295
295
  return Object.freeze({
296
296
  principal: account.principal,
297
297
  wallet: account.wallet ?? null,
@@ -371,10 +371,12 @@ async function complete(config, flow, body) {
371
371
  return call(config.identity, "POST", `/${flow}/complete`, body, true);
372
372
  }
373
373
  }
374
- function confirmedFrom(value) {
375
- if (!record(value) || value.status !== "confirmed" || !text(value.signature)) malformed();
374
+ function confirmedFrom(value, flow) {
375
+ if (!record(value) || value.status !== "confirmed") malformed();
376
+ const held = flow === "setup" && (value.signature === null || value.signature === void 0);
377
+ if (!held && !text(value.signature)) malformed();
376
378
  if (value.next !== null && value.next !== void 0 && !text(value.next, 80)) malformed();
377
- return { signature: value.signature, next: value.next ?? null };
379
+ return { signature: held ? null : value.signature, next: value.next ?? null };
378
380
  }
379
381
  async function settle(config, flow, step, operationId, cause) {
380
382
  let state;
@@ -383,7 +385,7 @@ async function settle(config, flow, step, operationId, cause) {
383
385
  } catch {
384
386
  throw new AccountOperationUnsettledError(operationId, flow, step);
385
387
  }
386
- if (state.status === "confirmed" && state.signature) return { signature: state.signature, next: state.next };
388
+ if (state.status === "confirmed" && (state.signature || flow === "setup")) return { signature: state.signature, next: state.next };
387
389
  if (state.status === "failed" || state.status === "prepared" || state.status === "expired") {
388
390
  throw cause instanceof ConnectError && cause.code !== "account_operation_uncertain" ? cause : new ConnectError("account_operation_failed");
389
391
  }
@@ -440,11 +442,11 @@ async function runFlow(config, flow, body, check) {
440
442
  signature: credential.response.signature,
441
443
  userHandle: credential.response.userHandle ?? null
442
444
  }
443
- }));
445
+ }), flow);
444
446
  } catch (cause) {
445
447
  result = await settle(config, flow, prepared.step, prepared.operationId, cause);
446
448
  }
447
- signatures.push(result.signature);
449
+ if (result.signature) signatures.push(result.signature);
448
450
  config.onStep?.({ ...view, phase: "confirmed", signature: result.signature });
449
451
  const next = result.next;
450
452
  if (next === null) return Object.freeze({ signatures: Object.freeze(signatures) });
@@ -482,7 +484,7 @@ async function getAccountOperation(config) {
482
484
  if (!text(config.operationId) || !/^[A-Za-z0-9_-]+$/.test(config.operationId)) throw new ConnectError("invalid_account_operation");
483
485
  const value = await call(config.identity, "GET", `/operations/${config.operationId}`, void 0, false, config.signal);
484
486
  const statuses = ["prepared", "sending", "confirmed", "failed", "expired"];
485
- 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" && !text(value.signature)) malformed();
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();
486
488
  return Object.freeze({
487
489
  operationId: value.operationId,
488
490
  flow: value.flow,
@@ -514,7 +516,7 @@ async function getAccountBalances(config) {
514
516
  }
515
517
  async function openAccount(config) {
516
518
  const existing = await getAccount(config);
517
- if (existing?.status === "ready") return existing;
519
+ if (existing?.status === "ready" || existing?.status === "held") return existing;
518
520
  config.onStep?.({
519
521
  step: existing?.nextStep ?? "create-account",
520
522
  summary: "",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dexterai/connect",
3
- "version": "0.33.0",
3
+ "version": "0.34.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
5
  "type": "module",
6
6
  "packageManager": "npm@10.9.3",