@econ-v1/domain 7.6.133 → 7.6.139

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.
@@ -8,6 +8,9 @@ export class InviteRedemptionService {
8
8
  redeem(code: string, confirmation?: string): Promise<InviteRedemptionOutcome>;
9
9
  /** @returns {Promise<InviteRedemptionOutcome>} */
10
10
  resume(): Promise<InviteRedemptionOutcome>;
11
+ /** Read only progress, with a fresh purpose-bound claimant proof on every poll.
12
+ * @returns {Promise<Record<string, unknown> | null>} */
13
+ progress(): Promise<Record<string, unknown> | null>;
11
14
  #private;
12
15
  }
13
16
  export type HomeNodeClient = import("@econ-v1/ports").HomeNodeClient;
@@ -17,8 +20,11 @@ export type InviteRedemptionOutcome = {
17
20
  readonly receiverName: string;
18
21
  } | {
19
22
  readonly kind: "rejected";
23
+ readonly memberError?: string;
24
+ readonly reason?: "invite-expired" | "issuer-refused" | "invalid-code" | "invite-used" | "node-already-claimed" | "proof-invalid" | "no-admission";
20
25
  } | {
21
26
  readonly kind: "unavailable";
27
+ readonly reason?: "join-in-progress" | "storage-busy" | "issuer-unreachable" | "storage" | "state" | "peer" | "malformed-receipt" | "malformed-challenge" | "transport" | "unknown";
22
28
  } | {
23
29
  readonly kind: "node-starting";
24
30
  } | {
@@ -1 +1 @@
1
- {"version":3,"file":"invite-redemption-service.d.ts","sourceRoot":"","sources":["../../src/services/invite-redemption-service.js"],"names":[],"mappings":"AAEA,wEAAwE;AACxE,oFAAoF;AAEpF,wFAAwF;AACxF;IAIE,sDAAsD;IACtD,qBADY,8BAA8B,EAKzC;IACD,sGAAsG;IACtG,aADY,MAAM,iBAAe,MAAM,GAA2B,OAAO,CAAC,uBAAuB,CAAC,CAKjG;IACD,kDAAkD;IAClD,UADc,OAAO,CAAC,uBAAuB,CAAC,CAG7C;;CAmCF;6BA1Da,OAAO,gBAAgB,EAAE,cAAc;mCACvC,OAAO,gBAAgB,EAAE,oBAAoB;sCA0D7C;IAAE,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EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,gBAAgB,GAAG,cAAc,GAAG,aAAa,GAAG,sBAAsB,GAAG,eAAe,GAAG,cAAc,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,kBAAkB,GAAG,cAAc,GAAG,oBAAoB,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,mBAAmB,GAAG,qBAAqB,GAAG,WAAW,GAAG,SAAS,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,uBAAuB,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;CAAE;;UAGrnB,IAAI,CAAC,cAAc,EAAE,QAAQ,CAAC;;;;UAC9B,oBAAoB;;;;cACpB,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC"}
@@ -98,7 +98,7 @@ export type OnboardingFlowApprovalState = "waiting" | "approved" | "rejected" |
98
98
  * node's outright refusal of this device's claim — the code is already bound to a different
99
99
  * device, or the supplied/missing code did not match.
100
100
  */
101
- export type OnboardingFlowReasonCode = "approval-expired" | "approval-rejected" | "wifi-credentials-rejected" | "wifi-scan-failed" | "wifi-unreachable" | "invitation-invalid" | "invitation-unavailable" | "invitation-node-starting" | "invitation-busy" | "claim-failed" | "code-already-bound" | "access-code-invalid";
101
+ export type OnboardingFlowReasonCode = "approval-expired" | "approval-rejected" | "wifi-credentials-rejected" | "wifi-scan-failed" | "wifi-unreachable" | "invitation-invalid" | "invitation-unavailable" | "invitation-node-starting" | "invitation-invite-expired" | "invitation-issuer-refused" | "invitation-join-in-progress" | "invitation-storage-busy" | "invitation-busy" | "invitation-invalid-code" | "invitation-invite-used" | "invitation-node-already-claimed" | "invitation-proof-invalid" | "invitation-confirmation-required" | "invitation-issuer-unreachable" | "invitation-storage" | "invitation-state" | "invitation-peer" | "invitation-malformed-receipt" | "invitation-malformed-challenge" | "invitation-no-admission" | "invitation-transport" | "invitation-unknown" | "claim-failed" | "code-already-bound" | "access-code-invalid";
102
102
  export type OnboardingFlowRow = OnboardingFlowRowBase & ({
103
103
  readonly networks: readonly OnboardingFlowNetwork[];
104
104
  readonly probing: boolean;
@@ -131,7 +131,7 @@ export type OnboardingFlowRow = OnboardingFlowRowBase & ({
131
131
  readonly stepId: Exclude<OnboardingFlowStepId, "choose-network" | "handoff" | "identity" | "invitation" | "match-code" | "network-password" | "trusted">;
132
132
  });
133
133
  export type OnboardingFlowClaimPort = Pick<OwnerClaimService, "awaitConfirmation" | "cancel" | "completeClaim" | "prepareClaim">;
134
- export type OnboardingFlowInvitePort = Pick<InviteRedemptionService, "redeem" | "resume">;
134
+ export type OnboardingFlowInvitePort = Pick<InviteRedemptionService, "redeem" | "resume"> & Partial<Pick<InviteRedemptionService, "progress">>;
135
135
  export type OnboardingFlowWifiPort = Pick<WifiProvisioningService, "awaitHandoff" | "awaitReconnect" | "configure" | "scan" | "status">;
136
136
  export type OnboardingFlowLcdPort = Pick<LcdDecisionService, "confirm" | "reject">;
137
137
  export type OnboardingFlowNetwork = {
@@ -142,6 +142,18 @@ export type OnboardingFlowNetwork = {
142
142
  export type OnboardingFlowRowBase = {
143
143
  lcdScreenId: OnboardingFlowLcdScreenId;
144
144
  phase: OnboardingFlowPhase;
145
+ invitationProgress?: {
146
+ readonly steps: readonly {
147
+ readonly id: string;
148
+ readonly state: "done" | "active" | "retrying" | "failed" | "pending";
149
+ readonly detail?: string;
150
+ readonly attempt?: number;
151
+ readonly maxAttempts?: number;
152
+ readonly reason?: string;
153
+ readonly nextRetryAt?: number;
154
+ }[];
155
+ readonly startedAt: string;
156
+ };
145
157
  reasonCode?: OnboardingFlowReasonCode;
146
158
  stepIndex: number;
147
159
  totalSteps: number;
@@ -168,6 +180,10 @@ export type OnboardingFlowServiceOptions = {
168
180
  invitationsEnabled: () => boolean;
169
181
  invites: OnboardingFlowInvitePort;
170
182
  lcd?: OnboardingFlowLcdPort;
183
+ /**
184
+ * Waits between invitation progress polls; absent = no live progress.
185
+ */
186
+ delay?: (ms: number) => Promise<void>;
171
187
  now: () => string;
172
188
  presence?: OnboardingPresencePort;
173
189
  publish: (stepId: OnboardingFlowStepId) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"onboarding-flow-service.d.ts","sourceRoot":"","sources":["../../src/services/onboarding-flow-service.js"],"names":[],"mappings":"AAaA,8KAA8K;AAC9K,uCADW,SAAS,CAAC,SAAS,EAAE,cAAc,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,CAAC,CAaxK;AA0DF;IA4FE;;OAEG;IACH,qBAFW,4BAA4B,EActC;IACD;;OAEG;IACH,QAFa,iBAAiB,CAkE7B;IACD;;OAEG;IACH,SAFa,IAAI,CAyFhB;IACD;;OAEG;IACH,WAFa,OAAO,CAAC,IAAI,CAAC,CAoBzB;IACD;;;OAGG;IACH,0BAHW,qBAAqB,GAAG,WAAW,GACjC,OAAO,CAAC,IAAI,CAAC,CAMzB;IACD;;OAEG;IACH,aAFa,uBAAuB,CAUnC;IACD;;;OAGG;IACH,oBAHW,MAAM,GACJ,OAAO,CAAC,IAAI,CAAC,CAsBzB;IACD;;OAEG;IACH,kBAFa,OAAO,CAAC,IAAI,CAAC,CAKzB;IACD;;;OAGG;IACH,uBAHW,MAAM,GACJ,OAAO,CAAC,IAAI,CAAC,CA+CzB;IAqCD;;;;OAIG;IACH,oBAJW,MAAM,YACN,0BAA0B,GACxB,OAAO,CAAC,IAAI,CAAC,CAUzB;IACD;;OAEG;IACH,mBAFa,OAAO,CAAC,IAAI,CAAC,CAK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BAAuB,GAAG,QAAQ,GAAG,eAAe,GAAG,cAAc,CAClE;uCAEU,IAAI,CAAC,uBAAuB,EAAE,QAAQ,GAAG,QAAQ,CAAC;qCAEnD,IAAI,CACZ,uBAAuB,EAC3B,cAAkB,GAAG,gBAAgB,GAAG,WAAW,GAAG,MAAM,GAAG,QAAQ,CACpE;oCAEU,IAAI,CAAC,kBAAkB,EAAE,SAAS,GAAG,QAAQ,CAAC;;cAG9C,0BAA0B;YAC1B,MAAM;UACN,MAAM;;;iBAIN,yBAAyB;WACzB,mBAAmB;iBACnB,wBAAwB;eACxB,MAAM;gBACN,MAAM;;;kBAIN,OAAO;qBACP,OAAO;cACP,yBAAyB;WACzB,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;;;;;;;;;;;iBAIzC,yBAAyB;iBAMzB,IAAI,CAAC,yBAAyB,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;WAC3D,uBAAuB;yBACvB,MAAM,OAAO;wBACb,MAAM,OAAO;aACb,wBAAwB;UACxB,qBAAqB;SACrB,MAAM,MAAM;eACZ,sBAAsB;aACtB,CAAC,MAAM,EAAE,oBAAoB,KAAK,IAAI;UACtC,sBAAsB;;;WAItB,aAAa;QACb,oBAAoB;iBACpB,yBAAyB;WACzB,mBAAmB"}
1
+ {"version":3,"file":"onboarding-flow-service.d.ts","sourceRoot":"","sources":["../../src/services/onboarding-flow-service.js"],"names":[],"mappings":"AAaA,8KAA8K;AAC9K,uCADW,SAAS,CAAC,SAAS,EAAE,cAAc,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,CAAC,CAaxK;AA0DF;IAiGE;;OAEG;IACH,qBAFW,4BAA4B,EAetC;IACD;;OAEG;IACH,QAFa,iBAAiB,CAmE7B;IACD;;OAEG;IACH,SAFa,IAAI,CAyFhB;IACD;;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O,CAAC,cAAc,CAAC,CAAA;CAAE;0BAClF;IAAE,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAA;CAAE;0BAC1F;IAAE,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAA;CAAE"}
1
+ {"version":3,"file":"transport-manager.d.ts","sourceRoot":"","sources":["../../src/services/transport-manager.js"],"names":[],"mappings":"AAsaA,sFAAsF;AACtF,+CADY,cAAc,QAAkB,cAAc,GAAiB,OAAO,CAqBjF;AA6ED;;;GAGG;AACH,oDAHW,MAAM,GACJ,MAAM,CAoBlB;AAKD,iDAAiD;AACjD,oDADY,UAAU,GAAgB,OAAO,CAW5C;AAzhBD,oYAAoY;AACpY,qKAAqK;AACrK,gGAAgG;AAChG,yFAAyF;AACzF,kKAAkK;AAClK,8GAA8G;AAC9G,wHAAwH;AACxH,wFAAwF;AAExF;IA4CE,+CAA+C;IAC/C,qBADY,uBAAuB,EAWlC;IAED,gCAAgC;IAChC,aADc,cAAc,CAG3B;IAED,qDAAqD;IACrD,yBADc,uBAAuB,GAAG,SAAS,CAKhD;IAED,oFAAoF;IACpF,qBADY,cAAc,GAAmB,uBAAuB,GAAG,SAAS,CAI/E;IAED,4EAA4E;IAC5E,0BADY,OAAO,GAAkB,uBAAuB,GAAG,SAAS,CAIvE;IAED;;;OAGG;IACH,oBAHW,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,GAC7B,MAAM,IAAI,CAKtB;IAED;;;;;;OAMG;IACH,kBAFa,SAAS,uBAAuB,EAAE,CAI9C;IAED;;;OAGG;IACH,8BAHW,SAAS,uBAAuB,EAAE,GAChC,IAAI,CAIhB;IAED;;;OAGG;IACH,kBAHW,uBAAuB,GACrB,OAAO,CAAC,cAAc,CAAC,CA0BnC;IAED;;;;OAIG;IACH,oBAHW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mBAAmB,CAAC;IAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAA;CAAE;qCAC3H,cAAc,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE;kCACvD;IAAE,KAAK,IAAI,IAAI,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAA;CAAE;0BACnD;IAAE,QAAQ,CAAC,SAAS,EAAE,uBAAuB,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,mBAAmB,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;CAAE;wBACpI;IAAE,QAAQ,CAAC,KAAK,EAAE,mBAAmB,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;CAAE;0BAClF;IAAE,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAA;CAAE;0BAC1F;IAAE,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAA;CAAE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@econ-v1/domain",
3
- "version": "7.6.133",
3
+ "version": "7.6.139",
4
4
  "description": "Platform-neutral domain contracts and errors for Node clients",
5
5
  "license": "MIT OR Apache-2.0",
6
6
  "author": "Node contributors",
@@ -57,6 +57,6 @@
57
57
  "access": "public"
58
58
  },
59
59
  "dependencies": {
60
- "@econ-v1/ports": "7.6.133"
60
+ "@econ-v1/ports": "7.6.139"
61
61
  }
62
62
  }
@@ -1,5 +1,5 @@
1
1
  // @ts-check
2
- import { DomainError } from "../errors/index.js";
2
+ import { DomainError, TransportError } from "../errors/index.js";
3
3
  /** @typedef {import('@econ-v1/ports').HomeNodeClient} HomeNodeClient */
4
4
  /** @typedef {import('@econ-v1/ports').OwnerClaimCryptoPort} OwnerClaimCryptoPort */
5
5
 
@@ -17,49 +17,84 @@ export class InviteRedemptionService {
17
17
  /** @param {string} code @param {string} [confirmation] @returns {Promise<InviteRedemptionOutcome>} */
18
18
  async redeem(code, confirmation) {
19
19
  const trimmed = code.trim();
20
- if (trimmed.length === 0 || trimmed.length > 2900) return { kind: "rejected" };
20
+ if (trimmed.length === 0 || trimmed.length > 2900) return { kind: "rejected", reason: "invalid-code" };
21
21
  return await this.#prove("redeem", trimmed, confirmation);
22
22
  }
23
23
  /** @returns {Promise<InviteRedemptionOutcome>} */
24
24
  async resume() {
25
25
  return await this.#prove("resume", "");
26
26
  }
27
- /** @param {"redeem" | "resume"} purpose @param {string} code @param {string} [confirmation] @returns {Promise<InviteRedemptionOutcome>} */
28
- async #prove(purpose, code, confirmation) {
27
+ /** Read only progress, with a fresh purpose-bound claimant proof on every poll.
28
+ * @returns {Promise<Record<string, unknown> | null>} */
29
+ async progress() {
29
30
  try {
31
+ const value = await this.#request("status", "");
32
+ return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
33
+ } catch { return null; }
34
+ }
35
+ /** @param {"redeem" | "resume" | "status"} purpose @param {string} code @param {string} [confirmation] */
36
+ async #request(purpose, code, confirmation) {
30
37
  const publicKey = await this.#keys.publicKey();
31
38
  const codeHash = purpose === "redeem" ? await this.#hashCode(code) : "";
32
39
  const challenge = await this.#node.invoke({
33
40
  operation: "POST /api/v2/invite/challenge",
34
41
  payload: { public_key: publicKey, purpose, code_hash: codeHash, ...(purpose === "redeem" && confirmation !== undefined ? { onboarding_confirmation: confirmation } : {}) },
35
42
  });
36
- if (typeof challenge.challenge_id !== "string" || typeof challenge.challenge !== "string")
37
- return { kind: "unavailable" };
43
+ if (challenge === null || typeof challenge !== "object" || typeof challenge.challenge_id !== "string" || typeof challenge.challenge !== "string")
44
+ throw new Error("malformed-challenge");
38
45
  const signature = await this.#keys.sign(challenge.challenge);
39
- const wire = await this.#node.invoke({
46
+ return await this.#node.invoke({
40
47
  operation: `POST /api/v2/invite/${purpose}`,
41
48
  payload: { public_key: publicKey, challenge_id: challenge.challenge_id, signature,
42
49
  ...(purpose === "redeem" ? { code, ...(confirmation !== undefined ? { onboarding_confirmation: confirmation } : {}) } : {}) },
43
50
  });
51
+ }
52
+ /** @param {"redeem" | "resume"} purpose @param {string} code @param {string} [confirmation] @returns {Promise<InviteRedemptionOutcome>} */
53
+ async #prove(purpose, code, confirmation) {
54
+ try {
55
+ const wire = await this.#request(purpose, code, confirmation);
56
+ if (wire === null || typeof wire !== "object") return { kind: "unavailable", reason: "malformed-receipt" };
44
57
  if (purpose === "resume" && wire.ok === true && ["legacy_recovery", "genesis"].includes(wire.source)) return { kind: "recovery" };
45
- if (wire.ok === false) return { kind: "rejected" };
58
+ if (wire.ok === false) return { kind: "rejected", reason: purpose === "resume" ? "no-admission" : "invalid-code" };
46
59
  if (wire.ok !== true || typeof wire.receiver_name !== "string" || !wire.receiver_name.trim())
47
- return { kind: "unavailable" };
60
+ return { kind: "unavailable", reason: "malformed-receipt" };
48
61
  return { kind: "redeemed", receiverName: wire.receiver_name.trim() };
49
62
  } catch (error) {
50
- if (error instanceof DomainError && error.code === "capability_unavailable") {
51
- if (error.details?.reason === "identity_not_ready") return { kind: "node-starting" };
52
- if (error.details?.reason === "busy") return { kind: "busy" };
63
+ if (error instanceof DomainError) {
64
+ const reason = error.details?.reason;
65
+ switch (reason) {
66
+ case "identity_not_ready": return { kind: "node-starting" };
67
+ case "invite_expired": return { kind: "rejected", reason: "invite-expired" };
68
+ case "issuer_refused": return { kind: "rejected", reason: "issuer-refused", ...(typeof error.details?.memberError === "string" ? { memberError: error.details.memberError } : {}) };
69
+ case "join_in_progress": return { kind: "unavailable", reason: "join-in-progress" };
70
+ case "storage_busy": return { kind: "unavailable", reason: "storage-busy" };
71
+ case "busy": return { kind: "busy" };
72
+ case "invalid_invite": return { kind: "rejected", reason: "invalid-code" };
73
+ case "invite_used": return { kind: "rejected", reason: "invite-used" };
74
+ case "node_already_claimed": return { kind: "rejected", reason: "node-already-claimed" };
75
+ case "proof_invalid": return { kind: "rejected", reason: "proof-invalid" };
76
+ case "confirmation_required": return { kind: "confirmation-required" };
77
+ case "issuer_unreachable": return { kind: "unavailable", reason: "issuer-unreachable" };
78
+ case "storage_unavailable": return { kind: "unavailable", reason: "storage" };
79
+ case "state_unavailable": return { kind: "unavailable", reason: "state" };
80
+ case "peer_unavailable": return { kind: "unavailable", reason: "peer" };
81
+ case "malformed_receipt": return { kind: "unavailable", reason: "malformed-receipt" };
82
+ }
83
+ // Older nodes have no machine reason. Never infer one from human text.
84
+ if (reason === undefined) {
85
+ if (error.code === "forbidden") return { kind: "confirmation-required" };
86
+ if (error.code === "unauthorized") return { kind: "rejected", reason: "proof-invalid" };
87
+ if (error.code === "conflict") return { kind: "rejected", reason: "node-already-claimed" };
88
+ if (["invalid_request", "invalid_payload", "validation_failed", "not_found"].includes(error.code))
89
+ return { kind: "rejected", reason: "invalid-code" };
90
+ }
53
91
  }
54
- if (purpose === "redeem" && error instanceof DomainError && error.code === "forbidden") return { kind: "confirmation-required" };
55
- // Only explicit refusals mean invalid admission. Network/provider/store failures can retry.
56
- if (error instanceof DomainError && ["invalid_request", "invalid_payload", "validation_failed", "not_found", "conflict", "unauthorized", "forbidden"].includes(error.code))
57
- return { kind: "rejected" };
58
- return { kind: "unavailable" };
92
+ if (error instanceof Error && error.message === "malformed-challenge") return { kind: "unavailable", reason: "malformed-challenge" };
93
+ return { kind: "unavailable", reason: error instanceof TransportError ? "transport" : "unknown" };
59
94
  }
60
95
  }
61
96
  }
62
- /** @typedef {{ readonly kind: "redeemed"; readonly receiverName: string } | { readonly kind: "rejected" } | { readonly kind: "unavailable" } | { readonly kind: "node-starting" } | { readonly kind: "busy" } | { readonly kind: "confirmation-required" } | { readonly kind: "recovery" }} InviteRedemptionOutcome */
97
+ /** @typedef {{ readonly kind: "redeemed"; readonly receiverName: string } | { readonly kind: "rejected"; readonly memberError?: string; readonly reason?: "invite-expired" | "issuer-refused" | "invalid-code" | "invite-used" | "node-already-claimed" | "proof-invalid" | "no-admission" } | { readonly kind: "unavailable"; readonly reason?: "join-in-progress" | "storage-busy" | "issuer-unreachable" | "storage" | "state" | "peer" | "malformed-receipt" | "malformed-challenge" | "transport" | "unknown" } | { readonly kind: "node-starting" } | { readonly kind: "busy" } | { readonly kind: "confirmation-required" } | { readonly kind: "recovery" }} InviteRedemptionOutcome */
63
98
  /**
64
99
  * @typedef {object} InviteRedemptionServiceOptions
65
100
  * @property {Pick<HomeNodeClient, "invoke">} node
@@ -96,6 +96,11 @@ export class OnboardingFlowService {
96
96
  /** @readonly @type {OnboardingFlowInvitePort} */
97
97
  #invites;
98
98
  #admissionGeneration = 0;
99
+ /** @readonly @type {((ms: number) => Promise<void>) | undefined} */
100
+ #delay;
101
+ /** @type {OnboardingFlowRowBase["invitationProgress"]} */
102
+ #invitationProgress;
103
+ #invitationPollGeneration = 0;
99
104
  /** @readonly @type {OnboardingFlowLcdPort | undefined} */
100
105
  #lcd;
101
106
  /** @readonly @type {() => string} */
@@ -186,6 +191,7 @@ export class OnboardingFlowService {
186
191
  this.#invites = options.invites;
187
192
  this.#lcd = options.lcd;
188
193
  this.#now = options.now;
194
+ this.#delay = options.delay;
189
195
  this.#presence = options.presence ?? createNullOnboardingPresence();
190
196
  this.#publish = options.publish;
191
197
  this.#wifi = options.wifi;
@@ -200,6 +206,7 @@ export class OnboardingFlowService {
200
206
  /** @type {OnboardingFlowRowBase} */
201
207
  /** @type {OnboardingFlowRowBase} */
202
208
  const base = {
209
+ ...(this.#invitationProgress === undefined ? {} : { invitationProgress: this.#invitationProgress }),
203
210
  lcdScreenId: this.#lcdScreenId(step),
204
211
  phase: step.phase,
205
212
  stepIndex: steps.findIndex((row) => row.id === stepId) + 1,
@@ -436,7 +443,20 @@ export class OnboardingFlowService {
436
443
  this.#submittingIdentity = true;
437
444
  this.#publish(this.#stepId);
438
445
  /** @type {Awaited<ReturnType<OnboardingFlowInvitePort["redeem"]>>} */
439
- const outcome = await this.#invites.redeem(code, this.#operationHash);
446
+ this.#reasonCode = undefined;
447
+ this.#invitationProgress = { steps: [], startedAt: this.#now() };
448
+ this.#publish(this.#stepId);
449
+ this.#startInvitationPolling();
450
+ let outcome;
451
+ try {
452
+ outcome = await this.#invites.redeem(code, this.#operationHash);
453
+ // The last poll can race the terminal write; fetch once after redeem settles.
454
+ await this.#readInvitationProgress(this.#invitationPollGeneration);
455
+ } catch {
456
+ outcome = /** @type {const} */ ({ kind: "unavailable", reason: "transport" });
457
+ } finally {
458
+ this.#stopInvitationPolling();
459
+ }
440
460
  if (generation !== this.#admissionGeneration) return;
441
461
  this.#submittingIdentity = false;
442
462
  if (this.#stepId !== "invitation") return;
@@ -445,12 +465,15 @@ export class OnboardingFlowService {
445
465
  const prepared = await this.#prepareCode();
446
466
  if (generation !== this.#admissionGeneration) return;
447
467
  this.#submittingIdentity = false;
448
- if (prepared) this.#enterMatchCode();
449
- else this.#publish(this.#stepId);
468
+ if (prepared) {
469
+ this.#enterMatchCode();
470
+ this.#reasonCode = "invitation-confirmation-required";
471
+ this.#publish(this.#stepId);
472
+ } else this.#publish(this.#stepId);
450
473
  return;
451
474
  }
452
475
  if (outcome.kind !== "redeemed") {
453
- this.#reasonCode = outcome.kind === "node-starting" ? "invitation-node-starting" : outcome.kind === "busy" ? "invitation-busy" : outcome.kind === "unavailable" ? "invitation-unavailable" : "invitation-invalid";
476
+ this.#reasonCode = invitationReasonCode(outcome);
454
477
  this.#publish(this.#stepId);
455
478
  return;
456
479
  }
@@ -474,6 +497,51 @@ export class OnboardingFlowService {
474
497
  }
475
498
  this.#moveTo(this.#nextStepAfter("invitation"));
476
499
  }
500
+ #stopInvitationPolling() {
501
+ this.#invitationPollGeneration += 1;
502
+ }
503
+ #startInvitationPolling() {
504
+ this.#stopInvitationPolling();
505
+ const delay = this.#delay;
506
+ if (delay === undefined) return;
507
+ const generation = this.#invitationPollGeneration;
508
+ const live = () => generation === this.#invitationPollGeneration && this.#stepId === "invitation" && this.#submittingIdentity;
509
+ // A generation bump (stop, or a newer start) ends this loop at its next wake-up.
510
+ void (async () => {
511
+ for (;;) {
512
+ await delay(1000);
513
+ if (!live()) return;
514
+ await this.#readInvitationProgress(generation);
515
+ if (!live()) return;
516
+ }
517
+ })();
518
+ }
519
+ /** @param {number} generation */
520
+ async #readInvitationProgress(generation) {
521
+ if (this.#invites.progress === undefined) return;
522
+ let status;
523
+ try { status = await this.#invites.progress(); } catch { return; }
524
+ if (status === null || generation !== this.#invitationPollGeneration || this.#stepId !== "invitation") return;
525
+ const ids = ["invitation_checked", "own_identity", "contacting", "saving", "publishing"];
526
+ const aliases = /** @type {Record<string, string>} */ ({ send: "contacting", snapshot: "contacting", sign: "own_identity", reserve: "saving", publish: "publishing" });
527
+ const step = typeof status.step === "string" ? (aliases[status.step] ?? status.step) : "";
528
+ const index = ids.indexOf(step);
529
+ if (!["in_progress", "done", "failed"].includes(String(status.state)) || (index < 0 && status.state !== "done")) return;
530
+ const steps = ids.map((id, i) => {
531
+ /** @type {"done" | "active" | "retrying" | "failed" | "pending"} */
532
+ const state = status.state === "done" || i < index ? "done" : i > index ? "pending" : status.state === "failed" ? "failed" : typeof status.next_retry_at === "number" ? "retrying" : "active";
533
+ return { id, state, ...(i !== index ? {} : {
534
+ ...(typeof status.wait_reason === "string" ? { detail: status.wait_reason } : {}),
535
+ ...(typeof status.attempt === "number" ? { attempt: status.attempt } : {}),
536
+ ...(typeof status.max_attempts === "number" ? { maxAttempts: status.max_attempts } : {}),
537
+ ...(typeof status.reason === "string" ? { reason: status.reason } : {}),
538
+ ...(typeof status.next_retry_at === "number" ? { nextRetryAt: status.next_retry_at } : {}),
539
+ }) };
540
+ });
541
+ this.#invitationProgress = { steps, startedAt: this.#invitationProgress?.startedAt ?? this.#now() };
542
+ this.#publish(this.#stepId);
543
+ if (status.state !== "in_progress") this.#stopInvitationPolling();
544
+ }
477
545
  /** Restore only host-authorized identity; a checkpoint never grants admission.
478
546
  * @returns {Promise<boolean>} */
479
547
  async #restoreAdmission() {
@@ -485,11 +553,11 @@ export class OnboardingFlowService {
485
553
  this.#submittingIdentity = false;
486
554
  if (this.#stepId !== "identity" && this.#stepId !== "invitation") return false;
487
555
  if (outcome.kind === "rejected" || outcome.kind === "confirmation-required") {
488
- this.#moveTo("invitation");
556
+ this.#moveTo("invitation", invitationReasonCode(outcome));
489
557
  return false;
490
558
  }
491
559
  if (outcome.kind === "unavailable" || outcome.kind === "node-starting" || outcome.kind === "busy") {
492
- this.#reasonCode = outcome.kind === "node-starting" ? "invitation-node-starting" : outcome.kind === "busy" ? "invitation-busy" : "invitation-unavailable";
560
+ this.#reasonCode = invitationReasonCode(outcome);
493
561
  this.#publish(this.#stepId);
494
562
  return false;
495
563
  }
@@ -652,6 +720,8 @@ export class OnboardingFlowService {
652
720
  * @returns {void}
653
721
  */
654
722
  cancel() {
723
+ this.#stopInvitationPolling();
724
+ this.#invitationProgress = undefined;
655
725
  this.#admissionGeneration += 1;
656
726
  this.#submittingIdentity = false;
657
727
  this.#claimGeneration += 1;
@@ -936,6 +1006,7 @@ export class OnboardingFlowService {
936
1006
  * @returns {void}
937
1007
  */
938
1008
  #moveTo(stepId, reasonCode) {
1009
+ if (stepId !== this.#stepId) this.#stopInvitationPolling();
939
1010
  this.#stepId = stepId;
940
1011
  this.#reasonCode = reasonCode;
941
1012
  this.#writeCheckpoint();
@@ -1071,6 +1142,19 @@ export class OnboardingFlowService {
1071
1142
  });
1072
1143
  }
1073
1144
  }
1145
+ /** @param {import("./invite-redemption-service.js").InviteRedemptionOutcome} outcome
1146
+ * @returns {OnboardingFlowReasonCode} */
1147
+ function invitationReasonCode(outcome) {
1148
+ if (outcome.kind === "node-starting") return "invitation-node-starting";
1149
+ if (outcome.kind === "busy") return "invitation-busy";
1150
+ if (outcome.kind === "confirmation-required") return "invitation-confirmation-required";
1151
+ if (outcome.kind === "rejected" || outcome.kind === "unavailable") {
1152
+ if (outcome.reason !== undefined) return `invitation-${outcome.reason}`;
1153
+ return outcome.kind === "rejected" ? "invitation-invalid" : "invitation-unavailable";
1154
+ }
1155
+ return "invitation-unknown";
1156
+ }
1157
+
1074
1158
  /**
1075
1159
  * Maps a `prepareClaim()` rejection onto the access-code rail's two specific reason codes
1076
1160
  * (design §5.4), so `#prepareCode()` can surface "the code is bound to another device" or "that
@@ -1124,7 +1208,25 @@ function accessCodeReasonCode(error) {
1124
1208
  * | "invitation-invalid"
1125
1209
  * | "invitation-unavailable"
1126
1210
  * | "invitation-node-starting"
1211
+ * | "invitation-invite-expired"
1212
+ * | "invitation-issuer-refused"
1213
+ * | "invitation-join-in-progress"
1214
+ * | "invitation-storage-busy"
1127
1215
  * | "invitation-busy"
1216
+ * | "invitation-invalid-code"
1217
+ * | "invitation-invite-used"
1218
+ * | "invitation-node-already-claimed"
1219
+ * | "invitation-proof-invalid"
1220
+ * | "invitation-confirmation-required"
1221
+ * | "invitation-issuer-unreachable"
1222
+ * | "invitation-storage"
1223
+ * | "invitation-state"
1224
+ * | "invitation-peer"
1225
+ * | "invitation-malformed-receipt"
1226
+ * | "invitation-malformed-challenge"
1227
+ * | "invitation-no-admission"
1228
+ * | "invitation-transport"
1229
+ * | "invitation-unknown"
1128
1230
  * | "claim-failed"
1129
1231
  * | "code-already-bound"
1130
1232
  * | "access-code-invalid"} OnboardingFlowReasonCode
@@ -1184,7 +1286,7 @@ function accessCodeReasonCode(error) {
1184
1286
  * "awaitConfirmation" | "cancel" | "completeClaim" | "prepareClaim"
1185
1287
  * >} OnboardingFlowClaimPort
1186
1288
  */
1187
- /** @typedef {Pick<InviteRedemptionService, "redeem" | "resume">} OnboardingFlowInvitePort */
1289
+ /** @typedef {Pick<InviteRedemptionService, "redeem" | "resume"> & Partial<Pick<InviteRedemptionService, "progress">>} OnboardingFlowInvitePort */
1188
1290
  /**
1189
1291
  * @typedef {Pick<
1190
1292
  * WifiProvisioningService,
@@ -1202,6 +1304,7 @@ function accessCodeReasonCode(error) {
1202
1304
  * @typedef {object} OnboardingFlowRowBase
1203
1305
  * @property {OnboardingFlowLcdScreenId} lcdScreenId
1204
1306
  * @property {OnboardingFlowPhase} phase
1307
+ * @property {{readonly steps: readonly {readonly id: string; readonly state: "done" | "active" | "retrying" | "failed" | "pending"; readonly detail?: string; readonly attempt?: number; readonly maxAttempts?: number; readonly reason?: string; readonly nextRetryAt?: number}[]; readonly startedAt: string}} [invitationProgress]
1205
1308
  * @property {OnboardingFlowReasonCode} [reasonCode]
1206
1309
  * @property {number} stepIndex
1207
1310
  * @property {number} totalSteps
@@ -1227,6 +1330,7 @@ function accessCodeReasonCode(error) {
1227
1330
  * @property {() => boolean} invitationsEnabled
1228
1331
  * @property {OnboardingFlowInvitePort} invites
1229
1332
  * @property {OnboardingFlowLcdPort} [lcd]
1333
+ * @property {(ms: number) => Promise<void>} [delay] Waits between invitation progress polls; absent = no live progress.
1230
1334
  * @property {() => string} now
1231
1335
  * @property {OnboardingPresencePort} [presence]
1232
1336
  * @property {(stepId: OnboardingFlowStepId) => void} publish
@@ -408,7 +408,12 @@ export class TransportManager {
408
408
  * @returns {void}
409
409
  */
410
410
  #setState(next) {
411
- if (!transportStateChanged(this.#state, next)) return;
411
+ if (!transportStateChanged(this.#state, next)) {
412
+ // Keep carrier timing current without notifying connection subscribers.
413
+ if (this.#state.status === "connected" && next.status === "connected" && this.#state.rttMs !== next.rttMs)
414
+ this.#state = next;
415
+ return;
416
+ }
412
417
  this.#state = next;
413
418
  this.#onState(next);
414
419
  for (const listener of [...this.#listeners]) listener(next);
@@ -424,8 +429,7 @@ export function transportStateChanged(current, next) {
424
429
  current.relayMember?.name !== next.relayMember?.name ||
425
430
  current.punch?.status !== next.punch?.status ||
426
431
  current.punch?.reason !== next.punch?.reason ||
427
- current.punch?.retryAt !== next.punch?.retryAt ||
428
- current.rttMs !== next.rttMs
432
+ current.punch?.retryAt !== next.punch?.retryAt
429
433
  );
430
434
  if (current.status === "connecting" && next.status === "connecting")
431
435
  return current.attempt !== next.attempt;