@seams/wallet-server 0.10.2 → 0.11.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.
Files changed (96) hide show
  1. package/THIRD_PARTY_NOTICES.md +33 -1812
  2. package/artifact-manifest.json +30 -30
  3. package/cloudflare-router-ab/build/deriver-a/build-stamp.json +1 -1
  4. package/cloudflare-router-ab/build/deriver-a/index.js +2 -2
  5. package/cloudflare-router-ab/build/deriver-a/index_bg.wasm +0 -0
  6. package/cloudflare-router-ab/build/deriver-b/build-stamp.json +1 -1
  7. package/cloudflare-router-ab/build/deriver-b/index.js +2 -2
  8. package/cloudflare-router-ab/build/deriver-b/index_bg.wasm +0 -0
  9. package/cloudflare-router-ab/build/local-tools/darwin-arm64/router_ab_local_init +0 -0
  10. package/cloudflare-router-ab/build/local-tools/darwin-x64/router_ab_local_init +0 -0
  11. package/cloudflare-router-ab/build/local-tools/linux-x64/router_ab_local_init +0 -0
  12. package/cloudflare-router-ab/build/router/build-stamp.json +1 -1
  13. package/cloudflare-router-ab/build/router/index.js +2 -2
  14. package/cloudflare-router-ab/build/router/index_bg.wasm +0 -0
  15. package/cloudflare-router-ab/build/signing-worker/build-stamp.json +1 -1
  16. package/cloudflare-router-ab/build/signing-worker/index.js +2 -2
  17. package/cloudflare-router-ab/build/signing-worker/index_bg.wasm +0 -0
  18. package/cloudflare-router-ab/build/tenant-root-control-plane/build-stamp.json +1 -1
  19. package/cloudflare-router-ab/build/tenant-root-control-plane/index.js +2 -2
  20. package/cloudflare-router-ab/build/tenant-root-control-plane/index_bg.wasm +0 -0
  21. package/dist/esm/cloud-host.js +7 -6
  22. package/dist/esm/hosted-wallet-gateway.js +1 -1
  23. package/dist/esm/index.js +1 -2
  24. package/dist/esm/localHostedWalletGatewayHandler.js +17 -11
  25. package/dist/esm/localIntendedYaoFault.js +34 -3
  26. package/dist/esm/localIntendedYaoRecoveryFault.js +19 -16
  27. package/dist/esm/localIntendedYaoSigningFault.js +31 -16
  28. package/dist/esm/router/auth/routerApiKeyAuth.js +1 -13
  29. package/dist/esm/router/cloudflare/d1/auth/d1RouterApiAuthService.js +3 -3
  30. package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceOwnerAuthorizationProvider.js +1 -1
  31. package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpRecords.js +1 -1
  32. package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpRecoveryService.js +1 -1
  33. package/dist/esm/router/cloudflare/d1/emailOtp/d1GoogleEmailOtpSessionResolver.js +1 -1
  34. package/dist/esm/router/cloudflare/d1/registration/d1RegistrationCeremonyRecordStore.js +19 -0
  35. package/dist/esm/router/cloudflare/d1/registration/d1RegistrationCeremonyRecords.js +5 -5
  36. package/dist/esm/router/cloudflare/d1/registration/d1RegistrationCeremonyStore.js +5 -2
  37. package/dist/esm/router/cloudflare/d1/registration/d1RegistrationSetupSupport.js +7 -1
  38. package/dist/esm/router/cloudflare/d1/registration/d1WalletRegistrationCommitStore.js +29 -4
  39. package/dist/esm/router/cloudflare/d1/registration/d1WalletRegistrationRead.js +6 -3
  40. package/dist/esm/router/cloudflare/d1/registration/d1WalletRegistrationService.js +51 -29
  41. package/dist/esm/router/cloudflare/d1/registration/d1WalletRegistrationSetupExecution.js +23 -7
  42. package/dist/esm/router/cloudflare/d1/wallet/d1WalletAddSignerFinalizeRecord.js +1 -1
  43. package/dist/esm/router/cloudflare/d1/wallet/d1WalletAddSignerService.js +2 -2
  44. package/dist/esm/router/cloudflare/d1/wallet/d1WalletAuthMethodService.js +3 -3
  45. package/dist/esm/router/cloudflare/d1/webauthn/d1WebAuthnAuthService.js +1 -1
  46. package/dist/esm/router/cloudflare/d1/webauthn/d1WebAuthnRecords.js +1 -1
  47. package/dist/esm/router/cloudflare-adaptor.js +2 -2
  48. package/dist/esm/router/cloudflare.js +2477 -2438
  49. package/dist/esm/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistration.js +1 -1
  50. package/dist/esm/router/domains/walletRegistration/walletRegistrationRoutes.js +39 -32
  51. package/dist/esm/router/framework/registrationSetupDispatch.js +11 -3
  52. package/dist/esm/router/framework/routeResponses.js +1 -5
  53. package/dist/esm/router/transport/fetch/routes/deviceLinkingOwnerAuthorization.js +1 -1
  54. package/dist/esm/router/transport/fetch/routes/passkeyCustody.js +2 -2
  55. package/dist/esm/router/transport/fetch/routes/thresholdEd25519.js +51 -24
  56. package/dist/esm/shared-ts/src/utils/validation.js +5 -1
  57. package/dist/esm/threshold/session/signingSessionSeal/index.js +1 -2
  58. package/dist/esm/wasm/evm_crypto/pkg/evm_crypto_bg.wasm +0 -0
  59. package/dist/esm/wasm/near_signer/pkg/wasm_signer_worker_bg.wasm +0 -0
  60. package/dist/esm/wasm/shamir3pass_runtime/pkg/shamir3pass_runtime_bg.wasm +0 -0
  61. package/dist/types/wallet-server/src/cloud-host.d.ts +1 -0
  62. package/dist/types/wallet-server/src/localHostedWalletGatewayHandler.d.ts +1 -1
  63. package/dist/types/wallet-server/src/localIntendedYaoFault.d.ts +13 -3
  64. package/dist/types/wallet-server/src/localIntendedYaoRecoveryFault.d.ts +4 -2
  65. package/dist/types/wallet-server/src/localIntendedYaoSigningFault.d.ts +4 -2
  66. package/dist/types/wallet-server/src/router/auth/routerApiKeyAuth.d.ts +0 -8
  67. package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1RegistrationCeremonyRecordStore.d.ts +2 -0
  68. package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1RegistrationCeremonyStore.d.ts +1 -0
  69. package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1RegistrationSetupSupport.d.ts +2 -0
  70. package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1WalletRegistrationCommitStore.d.ts +25 -5
  71. package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1WalletRegistrationRead.d.ts +15 -0
  72. package/dist/types/wallet-server/src/router/cloudflare-adaptor.d.ts +1 -1
  73. package/dist/types/wallet-server/src/router/domains/walletRegistration/walletRegistrationInputs.d.ts +2 -0
  74. package/dist/types/wallet-server/src/router/framework/routeResponses.d.ts +0 -2
  75. package/dist/types/wallet-server/src/threshold/session/signingSessionSeal/index.d.ts +1 -2
  76. package/package.json +2 -9
  77. package/src/README.md +5 -3
  78. package/dist/esm/router/express-adaptor.js +0 -84
  79. package/dist/esm/router/express.js +0 -26400
  80. package/dist/esm/router/node/nodeHostedWalletGateway.js +0 -64
  81. package/dist/esm/router/node/nodeHostedWalletGatewayCheck.js +0 -163
  82. package/dist/esm/router/node/nodeHostedWalletGatewayMain.js +0 -120
  83. package/dist/esm/router/node/nodeHttp.js +0 -79
  84. package/dist/esm/router/node/nodeSqlite.js +0 -43
  85. package/dist/esm/router/node/signerSqlMigrations.js +0 -48
  86. package/dist/esm/storage/syncSqlite.js +0 -79
  87. package/dist/esm/threshold/session/signingSessionSeal/transport/express.js +0 -75
  88. package/dist/types/wallet-server/src/router/express-adaptor.d.ts +0 -22
  89. package/dist/types/wallet-server/src/router/node/nodeHostedWalletGateway.d.ts +0 -34
  90. package/dist/types/wallet-server/src/router/node/nodeHostedWalletGatewayCheck.d.ts +0 -21
  91. package/dist/types/wallet-server/src/router/node/nodeHostedWalletGatewayMain.d.ts +0 -2
  92. package/dist/types/wallet-server/src/router/node/nodeHttp.d.ts +0 -13
  93. package/dist/types/wallet-server/src/router/node/nodeSqlite.d.ts +0 -22
  94. package/dist/types/wallet-server/src/router/node/signerSqlMigrations.d.ts +0 -20
  95. package/dist/types/wallet-server/src/storage/syncSqlite.d.ts +0 -28
  96. package/dist/types/wallet-server/src/threshold/session/signingSessionSeal/transport/express.d.ts +0 -12
@@ -7,8 +7,8 @@ import { secureRandomBase64Url } from "../../../../shared-ts/src/utils/secureRan
7
7
  import { ROUTER_AB_ED25519_NORMAL_SIGNING_STATE_KIND } from "../../../../shared-ts/src/utils/signingSessionSeal.js";
8
8
  import { computeAddSignerNearEd25519SigningKeyId, computeRegistrationNearEd25519SigningKeyId } from "../../../../shared-ts/src/utils/registrationIds.js";
9
9
  import { registrationNearEd25519BranchKey } from "../../../../shared-ts/src/utils/registrationSignerPlan.js";
10
- import "../../../../shared-ts/src/threshold/sessionPolicy.js";
11
10
  import { thresholdEd25519AuthorityScopeFromWalletAuthAuthority } from "../../../../core/ThresholdService/validation.js";
11
+ import "../../../../shared-ts/src/threshold/sessionPolicy.js";
12
12
  import { createRouterApiModule } from "../../../framework/modules.js";
13
13
  import { InMemoryRouterAbEd25519YaoRegistrationStateV1, createRouterAbEd25519YaoRegistrationModule } from "../registration/routerAbEd25519YaoRegistration.js";
14
14
  import { InMemoryRouterAbEd25519YaoRegistrationIntentAuthorizationStateV1 } from "../registration/routerAbEd25519YaoRegistrationIntentAuthorization.js";
@@ -14,6 +14,13 @@ import { parseHostedWalletSessionOperationCredentialToken, parsePrimaryWalletSes
14
14
  import { normalizeCorsOrigin } from "../../../core/SessionService.js";
15
15
  import { thresholdEcdsaChainTargetFromValue } from "../../../core/thresholdEcdsaChainTarget.js";
16
16
  import { walletIdFromString } from "../../../shared-ts/src/utils/registrationIds.js";
17
+ import { deriveImplicitNearAccountIdFromEd25519PublicKey, parseImplicitNearAccountId } from "../../../shared-ts/src/utils/near.js";
18
+ import { normalizeRegistrationSignerPlan, registrationSignerSetSelectionFromPlan } from "../../../shared-ts/src/utils/registrationSignerPlan.js";
19
+ import { addAuthMethodIntentGrantFromString, addSignerIntentGrantFromString, computeAddAuthMethodIntentDigestB64u, computeAddSignerIntentDigestB64u, normalizeAddAuthMethodIntentCaller } from "../../../shared-ts/src/utils/registrationIntent.js";
20
+ import { parsePasskeyCustodyEnvelopeRecord } from "../../../shared-ts/src/passkey-custody/custodyEnvelope.js";
21
+ import "../../../shared-ts/src/passkey-custody/index.js";
22
+ import { parseRouterAbTraceContextV1 } from "../../../shared-ts/src/utils/routerAbTraceContext.js";
23
+ import { recordRegistrationServerTiming, registrationServerTimingHeaders } from "../../cloudflare/d1/registration/d1RegistrationSetupSupport.js";
17
24
  import { parseRegistrationSetupOperationId } from "../../../shared-ts/src/utils/registrationSetupOperation.js";
18
25
  import { extractBearerCredential, extractRouterApiEnvironmentId } from "../../auth/routerApiKeyAuth.js";
19
26
  import { publishableKeyRoutePrincipal, resolvePublishableKeyApiCredentialAuth, resolveWalletRegistrationContext } from "../../auth/routerApiCredentialAuth.js";
@@ -21,13 +28,7 @@ import { resolveActiveRuntimePolicyScopeForEnvironment, resolveWalletSessionAdmi
21
28
  import { enforceRoutePolicy } from "../../framework/enforceRoutePolicy.js";
22
29
  import { parseRegistrationPreparedSessionSeal } from "./registrationSessionSeal.js";
23
30
  import { routeError, routeJson } from "../../framework/routeResponses.js";
24
- import { parsePasskeyCustodyEnvelopeRecord } from "../../../shared-ts/src/passkey-custody/custodyEnvelope.js";
25
- import "../../../shared-ts/src/passkey-custody/index.js";
26
31
  import { computeWalletEcdsaKeyFactsInventoryChallengeDigestB64u } from "../../../shared-ts/src/utils/ecdsaKeyFactsInventory.js";
27
- import { deriveImplicitNearAccountIdFromEd25519PublicKey, parseImplicitNearAccountId } from "../../../shared-ts/src/utils/near.js";
28
- import { normalizeRegistrationSignerPlan, registrationSignerSetSelectionFromPlan } from "../../../shared-ts/src/utils/registrationSignerPlan.js";
29
- import { addAuthMethodIntentGrantFromString, addSignerIntentGrantFromString, computeAddAuthMethodIntentDigestB64u, computeAddSignerIntentDigestB64u, normalizeAddAuthMethodIntentCaller } from "../../../shared-ts/src/utils/registrationIntent.js";
30
- import { parseRouterAbTraceContextV1 } from "../../../shared-ts/src/utils/routerAbTraceContext.js";
31
32
  //#region src/router/domains/walletRegistration/walletRegistrationRoutes.ts
32
33
  function parseRegistrationTraceContext(headers) {
33
34
  const parsed = parseRouterAbTraceContextV1(headers["x-seams-trace-id"] ?? headers["X-Seams-Trace-Id"]);
@@ -1573,6 +1574,8 @@ async function handleRouterApiWalletRegistrationSetup(input) {
1573
1574
  if (!registrationContext) return routeError(500, "route_auth_not_configured", "Wallet registration context is not configured");
1574
1575
  const request = parseWalletRegistrationSetupRequest(input.body);
1575
1576
  if (!request.ok) return routeError(400, request.code, request.message);
1577
+ const serverTiming = [];
1578
+ const contextStartedAtMs = Date.now();
1576
1579
  const context = await resolveWalletRegistrationContext({
1577
1580
  registration: request.value,
1578
1581
  environmentId: extractRouterApiEnvironmentId(input.headers) || void 0,
@@ -1585,11 +1588,13 @@ async function handleRouterApiWalletRegistrationSetup(input) {
1585
1588
  route: input.route,
1586
1589
  routeAuthNotConfiguredMessage: "Wallet registration setup requires API credential auth policy"
1587
1590
  });
1591
+ recordRegistrationServerTiming(serverTiming, "setup_context", contextStartedAtMs);
1588
1592
  if (!context.ok) {
1589
1593
  if (context.status === 401) return routeError(401, "unauthorized", `${context.code}: ${context.message}`);
1590
1594
  if (context.status === 403) return routeError(403, "forbidden", `${context.code}: ${context.message}`);
1591
1595
  return routeError(context.status, "internal", `${context.code}: ${context.message}`);
1592
1596
  }
1597
+ const policyStartedAtMs = Date.now();
1593
1598
  const resolved = await enforceRoutePolicy({
1594
1599
  headers: input.headers,
1595
1600
  logger: input.logger,
@@ -1602,23 +1607,29 @@ async function handleRouterApiWalletRegistrationSetup(input) {
1602
1607
  sourceIp: input.sourceIp,
1603
1608
  resolvers: { apiCredentials: publishableKeyRoutePrincipal.bind(void 0, context.principal) }
1604
1609
  });
1610
+ recordRegistrationServerTiming(serverTiming, "setup_route_policy", policyStartedAtMs);
1605
1611
  if (!resolved.ok) return routeJson(resolved.status, resolved.body);
1606
1612
  const principal = context.principal;
1607
- if (input.services.registrationSetupRateLimit) try {
1608
- if (!(await input.services.registrationSetupRateLimit({
1609
- apiKeyId: principal.apiKeyId,
1610
- orgId: principal.orgId,
1611
- projectId: context.environment.projectId,
1612
- envId: context.environment.key,
1613
- sourceIp: input.sourceIp || "unknown"
1614
- })).allowed) return routeJson(429, {
1615
- ok: false,
1616
- code: "rate_limited",
1617
- message: "Too many registration attempts. Wait one minute and try again.",
1618
- retryAfterMs: 6e4
1619
- });
1620
- } catch {
1621
- return routeError(503, "internal", "Registration setup rate limit is unavailable");
1613
+ if (input.services.registrationSetupRateLimit) {
1614
+ const limitStartedAtMs = Date.now();
1615
+ try {
1616
+ const limit = await input.services.registrationSetupRateLimit({
1617
+ apiKeyId: principal.apiKeyId,
1618
+ orgId: principal.orgId,
1619
+ projectId: context.environment.projectId,
1620
+ envId: context.environment.key,
1621
+ sourceIp: input.sourceIp || "unknown"
1622
+ });
1623
+ recordRegistrationServerTiming(serverTiming, "setup_rate_limit", limitStartedAtMs);
1624
+ if (!limit.allowed) return routeJson(429, {
1625
+ ok: false,
1626
+ code: "rate_limited",
1627
+ message: "Too many registration attempts. Wait one minute and try again.",
1628
+ retryAfterMs: 6e4
1629
+ });
1630
+ } catch {
1631
+ return routeError(503, "internal", "Registration setup rate limit is unavailable");
1632
+ }
1622
1633
  }
1623
1634
  const runtimePolicyScope = {
1624
1635
  orgId: principal.orgId,
@@ -1635,7 +1646,8 @@ async function handleRouterApiWalletRegistrationSetup(input) {
1635
1646
  signer: session,
1636
1647
  runtimePolicyScope,
1637
1648
  signingRootId: `${runtimePolicyScope.projectId}:${runtimePolicyScope.envId}`,
1638
- signingRootVersion: runtimePolicyScope.signingRootVersion
1649
+ signingRootVersion: runtimePolicyScope.signingRootVersion,
1650
+ serverTiming
1639
1651
  });
1640
1652
  }
1641
1653
  /**
@@ -1659,7 +1671,7 @@ async function handleRouterApiWalletRegistrationRespond(input) {
1659
1671
  verifier: session,
1660
1672
  ...registrationUserAgentFromHeaders(input.headers) ? { userAgent: registrationUserAgentFromHeaders(input.headers) } : {}
1661
1673
  }, traceContext.value ?? void 0, serverTiming, input.waitUntil);
1662
- return routeJson(result.ok ? 200 : result.code === "storage_unavailable" ? 503 : 400, result, { headers: ecdsaGatewayServerTimingHeaders(serverTiming) });
1674
+ return routeJson(result.ok ? 200 : result.code === "storage_unavailable" ? 503 : 400, result, { headers: registrationServerTimingHeaders(serverTiming) });
1663
1675
  }
1664
1676
  async function handleRouterApiWalletRegistrationNearAdmission(input) {
1665
1677
  const traceContext = parseRegistrationTraceContext(input.headers);
@@ -1882,7 +1894,7 @@ async function handleRouterApiWalletRegistrationActivate(input) {
1882
1894
  }, traceContext.value ?? void 0, serverTiming);
1883
1895
  if (!result.ok) return routeJson(400, result);
1884
1896
  if (!isEmailOtpWalletRegistrationActivateSuccessV2(result) && !isPasskeyWalletRegistrationActivateSuccessV2(result)) return routeError(500, "internal", "Wallet registration activation returned an invalid authority");
1885
- return routeJson(200, result, { headers: ecdsaGatewayServerTimingHeaders(serverTiming) });
1897
+ return routeJson(200, result, { headers: registrationServerTimingHeaders(serverTiming) });
1886
1898
  }
1887
1899
  /**
1888
1900
  * Commits a NEAR-only wallet or completes a mixed wallet's deferred signer.
@@ -1922,18 +1934,13 @@ async function handleRouterApiWalletRegistrationNearProvisioning(input) {
1922
1934
  ok: false,
1923
1935
  code: sealed.code,
1924
1936
  message: sealed.message
1925
- }, { headers: ecdsaGatewayServerTimingHeaders(serverTiming) });
1937
+ }, { headers: registrationServerTimingHeaders(serverTiming) });
1926
1938
  return routeJson(200, {
1927
1939
  ...result,
1928
1940
  sessionSeal: sealed.value
1929
- }, { headers: ecdsaGatewayServerTimingHeaders(serverTiming) });
1941
+ }, { headers: registrationServerTimingHeaders(serverTiming) });
1930
1942
  }
1931
- return routeJson(200, result, { headers: ecdsaGatewayServerTimingHeaders(serverTiming) });
1932
- }
1933
- function ecdsaGatewayServerTimingHeaders(serverTiming) {
1934
- if (serverTiming.length === 0) return void 0;
1935
- const header = serverTiming.map(([name, durationMs]) => `${name};dur=${Math.max(0, durationMs).toFixed(1)}`).join(", ");
1936
- return { "Server-Timing": header };
1943
+ return routeJson(200, result, { headers: registrationServerTimingHeaders(serverTiming) });
1937
1944
  }
1938
1945
  async function handleRouterApiWalletAddSignerStart(input) {
1939
1946
  if (!isPlainObject(input.body)) return routeError(400, "invalid_body", "JSON body required");
@@ -1,3 +1,4 @@
1
+ import { recordRegistrationServerTiming, registrationServerTimingHeaders } from "../cloudflare/d1/registration/d1RegistrationSetupSupport.js";
1
2
  //#region src/router/framework/registrationSetupDispatch.ts
2
3
  /** A transient storage fault outlived its retries. The same request can succeed later. */
3
4
  const SETUP_STORAGE_UNAVAILABLE = {
@@ -9,17 +10,23 @@ const SETUP_INTERNAL_FAILURE = {
9
10
  message: "Wallet registration setup failed"
10
11
  };
11
12
  async function dispatchWalletRegistrationSetup(context, input) {
13
+ const serverTiming = input.serverTiming ?? [];
14
+ const dispatchStartedAtMs = Date.now();
12
15
  const forwarded = await context.dispatcher?.dispatch(input);
13
16
  if (forwarded) return forwarded;
17
+ recordRegistrationServerTiming(serverTiming, "setup_dispatch", dispatchStartedAtMs);
14
18
  const result = await context.local.setupWalletRegistration(input);
19
+ const headers = registrationServerTimingHeaders(serverTiming);
15
20
  if (result.ok) return {
16
21
  status: 200,
17
- body: result
22
+ body: result,
23
+ ...headers ? { headers } : {}
18
24
  };
19
25
  const serverFailure = result.code === "storage_unavailable" ? SETUP_STORAGE_UNAVAILABLE : result.code === "internal" ? SETUP_INTERNAL_FAILURE : null;
20
26
  if (!serverFailure) return {
21
27
  status: 400,
22
- body: result
28
+ body: result,
29
+ ...headers ? { headers } : {}
23
30
  };
24
31
  console.error("[wallet-registration] setup failed", {
25
32
  code: result.code,
@@ -31,7 +38,8 @@ async function dispatchWalletRegistrationSetup(context, input) {
31
38
  ok: false,
32
39
  code: result.code,
33
40
  message: serverFailure.message
34
- }
41
+ },
42
+ ...headers ? { headers } : {}
35
43
  };
36
44
  }
37
45
  //#endregion
@@ -14,10 +14,6 @@ function routeError(status, code, message) {
14
14
  message
15
15
  });
16
16
  }
17
- function sendExpressRouteResponse(res, response) {
18
- for (const [name, value] of Object.entries(response.headers || {})) res.set(name, value);
19
- res.status(response.status).json(response.body);
20
- }
21
17
  function toFetchRouteResponse(response) {
22
18
  return new Response(JSON.stringify(response.body), {
23
19
  status: response.status,
@@ -28,6 +24,6 @@ function toFetchRouteResponse(response) {
28
24
  });
29
25
  }
30
26
  //#endregion
31
- export { routeError, routeJson, sendExpressRouteResponse, toFetchRouteResponse };
27
+ export { routeError, routeJson, toFetchRouteResponse };
32
28
 
33
29
  //# sourceMappingURL=routeResponses.js.map
@@ -4,9 +4,9 @@ import { sha256DigestB64u } from "../../../../shared-ts/src/utils/canonicalPrimi
4
4
  import { buildEmailOtpWalletAuthAuthority, buildPasskeyWalletAuthAuthority, walletAuthAuthorityRef } from "../../../../shared-ts/src/utils/walletAuthAuthority.js";
5
5
  import { parseLinkedDeviceOwnerAuthorizationRequestV1 } from "../../../../shared-ts/src/device-linking/parsers.js";
6
6
  import { buildWalletSessionCapabilitySubjectsV1, walletSessionCapabilitySubjectsV1Equal } from "../../../../authorization/domain.js";
7
+ import { thresholdEd25519AuthorityScopeFromWalletAuthAuthority } from "../../../../core/ThresholdService/validation.js";
7
8
  import { extractBearerCredential } from "../../../auth/routerApiKeyAuth.js";
8
9
  import { json, jsonFailure, readJson } from "../../../framework/http.js";
9
- import { thresholdEd25519AuthorityScopeFromWalletAuthAuthority } from "../../../../core/ThresholdService/validation.js";
10
10
  //#region src/router/transport/fetch/routes/deviceLinkingOwnerAuthorization.ts
11
11
  const LINKED_DEVICE_OWNER_AUTHORIZATION_PATH_V1 = "/wallet/device-linking/v1/owner-authorization";
12
12
  /**
@@ -10,10 +10,10 @@ import { buildPasskeyWalletAuthAuthority, walletAuthAuthorityRef } from "../../.
10
10
  import { parseSessionOrigin, parseVerifiedOwnerProofId } from "../../../../authorization/domain.js";
11
11
  import { buildVerifiedWalletOperationEmailOtpFactorResult, buildVerifiedWalletOperationPasskeyFactorResult } from "../../../../authorization/factorEvidence.js";
12
12
  import { findRouteDefinitionById, matchesRouteDefinitionRequest } from "../../../framework/routeDefinitions.js";
13
- import { extractBearerCredential, resolveSourceIpFromFetchHeaders } from "../../../auth/routerApiKeyAuth.js";
14
- import { toFetchRouteResponse } from "../../../framework/routeResponses.js";
15
13
  import { parsePasskeyCustodyEnvelopeRecord } from "../../../../shared-ts/src/passkey-custody/custodyEnvelope.js";
16
14
  import "../../../../shared-ts/src/passkey-custody/index.js";
15
+ import { extractBearerCredential, resolveSourceIpFromFetchHeaders } from "../../../auth/routerApiKeyAuth.js";
16
+ import { toFetchRouteResponse } from "../../../framework/routeResponses.js";
17
17
  import { readJson } from "../../../framework/http.js";
18
18
  import { isHostWithinRpId, originHostnameOrEmpty } from "../../../../core/authService/webauthnOidcHelpers.js";
19
19
  import { parseRecoveryCodeReservationId } from "../../../../shared-ts/src/wallet-recovery/recoveryCodeReservation.js";
@@ -890,7 +890,34 @@ async function proxyEd25519OwnerLaneExecution(input) {
890
890
  });
891
891
  }
892
892
  async function handleRouterAbEd25519NormalSigningRoute(input) {
893
- const authorization = await authorizeRouterAbEd25519NormalSigningRoute({
893
+ const startedAt = performance.now();
894
+ const timing = {
895
+ authorize: null,
896
+ admit: null,
897
+ proxy: null,
898
+ complete: null,
899
+ total: null
900
+ };
901
+ const response = await executeRouterAbEd25519NormalSigningRoute(input, timing);
902
+ timing.total = performance.now() - startedAt;
903
+ const headers = new Headers(response.headers);
904
+ for (const [stage, duration] of Object.entries(timing)) if (duration !== null) headers.append("Server-Timing", `ed25519_sign_${stage};dur=${Math.max(0, duration).toFixed(1)}`);
905
+ return new Response(response.body, {
906
+ status: response.status,
907
+ statusText: response.statusText,
908
+ headers
909
+ });
910
+ }
911
+ async function timeEd25519SigningStage(timing, stage, pending) {
912
+ const startedAt = performance.now();
913
+ try {
914
+ return await pending;
915
+ } finally {
916
+ timing[stage] = performance.now() - startedAt;
917
+ }
918
+ }
919
+ async function executeRouterAbEd25519NormalSigningRoute(input, timing) {
920
+ const authorization = await timeEd25519SigningStage(timing, "authorize", authorizeRouterAbEd25519NormalSigningRoute({
894
921
  body: input.body,
895
922
  rawBody: input.body,
896
923
  headers: Object.fromEntries(input.ctx.request.headers.entries()),
@@ -900,7 +927,7 @@ async function handleRouterAbEd25519NormalSigningRoute(input) {
900
927
  admissionAdapter: input.ctx.opts.routerAbNormalSigningAdmission,
901
928
  resolveEd25519MaterialActivation: input.ctx.service.walletRegistration.resolveEd25519MaterialActivation.bind(input.ctx.service.walletRegistration),
902
929
  phase: input.phase
903
- });
930
+ }));
904
931
  if (!authorization.ok) return json(authorization.result.body, { status: authorization.result.status });
905
932
  if (authorization.kind === "operation_step_up") {
906
933
  if (input.phase === "prepare") {
@@ -910,7 +937,7 @@ async function handleRouterAbEd25519NormalSigningRoute(input) {
910
937
  operation: authorization.operation
911
938
  });
912
939
  if (execution.kind !== "execute") return execution.response;
913
- const upstream = await proxyEd25519OwnerLaneExecution({
940
+ const upstream = await timeEd25519SigningStage(timing, "proxy", proxyEd25519OwnerLaneExecution({
914
941
  ctx: input.ctx,
915
942
  authorization,
916
943
  authorizedOperation: execution.operation,
@@ -921,7 +948,7 @@ async function handleRouterAbEd25519NormalSigningRoute(input) {
921
948
  binding: await ed25519OperationStepUpBinding(input.ctx, authorization.session, execution.operation)
922
949
  })
923
950
  }
924
- });
951
+ }));
925
952
  const upstreamBodyText = await upstream.clone().text().catch(() => "");
926
953
  let upstreamBody = null;
927
954
  try {
@@ -933,7 +960,7 @@ async function handleRouterAbEd25519NormalSigningRoute(input) {
933
960
  status: upstream.status,
934
961
  bodyText: upstreamBodyText
935
962
  })) return upstream;
936
- if (!upstream.ok || !isPlainObject(upstreamBody)) return requireCompletedEd25519OperationResponse(await completeEd25519Operation({
963
+ if (!upstream.ok || !isPlainObject(upstreamBody)) return requireCompletedEd25519OperationResponse(await timeEd25519SigningStage(timing, "complete", completeEd25519Operation({
937
964
  ctx: input.ctx,
938
965
  operation: execution.operation,
939
966
  result: upstream.status < 500 ? "failed_before_side_effect" : "failed_after_side_effect",
@@ -941,7 +968,7 @@ async function handleRouterAbEd25519NormalSigningRoute(input) {
941
968
  response: upstream,
942
969
  bodyText: upstreamBodyText
943
970
  })
944
- }));
971
+ })));
945
972
  const headers = new Headers(upstream.headers);
946
973
  headers.delete("content-length");
947
974
  return new Response(JSON.stringify(signingPrepareSessionResponse({
@@ -954,15 +981,15 @@ async function handleRouterAbEd25519NormalSigningRoute(input) {
954
981
  });
955
982
  }
956
983
  if (authorization.phase !== "finalize") throw new Error("Operation step-up finalize authorization phase changed");
957
- const validatedAuthorization = await validateEd25519VerifiedStepUpAuthorizedOperation({
984
+ const validatedAuthorization = await timeEd25519SigningStage(timing, "admit", validateEd25519VerifiedStepUpAuthorizedOperation({
958
985
  ctx: input.ctx,
959
986
  body: input.body,
960
987
  authorization
961
- });
988
+ }));
962
989
  if (!validatedAuthorization.ok) return validatedAuthorization.response;
963
990
  const replay = replayCompletedEd25519Operation(validatedAuthorization.operation);
964
991
  if (replay) return replay;
965
- const upstream = await proxyEd25519OwnerLaneExecution({
992
+ const upstream = await timeEd25519SigningStage(timing, "proxy", proxyEd25519OwnerLaneExecution({
966
993
  ctx: input.ctx,
967
994
  authorization,
968
995
  authorizedOperation: validatedAuthorization.operation,
@@ -973,13 +1000,13 @@ async function handleRouterAbEd25519NormalSigningRoute(input) {
973
1000
  binding: await ed25519OperationStepUpBinding(input.ctx, authorization.session, validatedAuthorization.operation)
974
1001
  })
975
1002
  }
976
- });
1003
+ }));
977
1004
  const upstreamBodyText = await upstream.clone().text().catch(() => "");
978
1005
  if (isRouterAbEd25519OperationInProgressResponse({
979
1006
  status: upstream.status,
980
1007
  bodyText: upstreamBodyText
981
1008
  })) return upstream;
982
- return requireCompletedEd25519OperationResponse(await completeEd25519Operation({
1009
+ return requireCompletedEd25519OperationResponse(await timeEd25519SigningStage(timing, "complete", completeEd25519Operation({
983
1010
  ctx: input.ctx,
984
1011
  operation: validatedAuthorization.operation,
985
1012
  result: upstream.ok ? "succeeded" : upstream.status < 500 ? "failed_before_side_effect" : "failed_after_side_effect",
@@ -987,14 +1014,14 @@ async function handleRouterAbEd25519NormalSigningRoute(input) {
987
1014
  response: upstream,
988
1015
  bodyText: upstreamBodyText
989
1016
  })
990
- }));
1017
+ })));
991
1018
  }
992
1019
  if (input.phase === "prepare") {
993
- const authorized = await authorizeEd25519ReusableWalletSessionOperation({
1020
+ const authorized = await timeEd25519SigningStage(timing, "admit", authorizeEd25519ReusableWalletSessionOperation({
994
1021
  ctx: input.ctx,
995
1022
  body: input.body,
996
1023
  authorization
997
- });
1024
+ }));
998
1025
  if (!authorized.ok) return authorized.response;
999
1026
  const execution = decideEd25519NormalSigningExecution({
1000
1027
  phase: "prepare",
@@ -1016,7 +1043,7 @@ async function handleRouterAbEd25519NormalSigningRoute(input) {
1016
1043
  }
1017
1044
  }
1018
1045
  }, { status: 403 });
1019
- const upstream = await proxyEd25519OwnerLaneExecution({
1046
+ const upstream = await timeEd25519SigningStage(timing, "proxy", proxyEd25519OwnerLaneExecution({
1020
1047
  ctx: input.ctx,
1021
1048
  authorization,
1022
1049
  authorizedOperation: execution.operation,
@@ -1027,7 +1054,7 @@ async function handleRouterAbEd25519NormalSigningRoute(input) {
1027
1054
  binding: buildEd25519GatewayOwnerWalletSessionBinding(authorization, pinnedEd25519WalletScope(authorization, authorized.admission.ownerScope))
1028
1055
  })
1029
1056
  }
1030
- });
1057
+ }));
1031
1058
  const upstreamBodyText = await upstream.clone().text().catch(() => "");
1032
1059
  let upstreamBody = null;
1033
1060
  try {
@@ -1039,7 +1066,7 @@ async function handleRouterAbEd25519NormalSigningRoute(input) {
1039
1066
  status: upstream.status,
1040
1067
  bodyText: upstreamBodyText
1041
1068
  })) return upstream;
1042
- if (!upstream.ok || !isPlainObject(upstreamBody)) return requireCompletedEd25519OperationResponse(await completeEd25519Operation({
1069
+ if (!upstream.ok || !isPlainObject(upstreamBody)) return requireCompletedEd25519OperationResponse(await timeEd25519SigningStage(timing, "complete", completeEd25519Operation({
1043
1070
  ctx: input.ctx,
1044
1071
  operation: execution.operation,
1045
1072
  result: upstream.status < 500 ? "failed_before_side_effect" : "failed_after_side_effect",
@@ -1047,7 +1074,7 @@ async function handleRouterAbEd25519NormalSigningRoute(input) {
1047
1074
  response: upstream,
1048
1075
  bodyText: upstreamBodyText
1049
1076
  })
1050
- }));
1077
+ })));
1051
1078
  const headers = new Headers(upstream.headers);
1052
1079
  headers.delete("content-length");
1053
1080
  return new Response(JSON.stringify(signingPrepareSessionResponse({
@@ -1059,16 +1086,16 @@ async function handleRouterAbEd25519NormalSigningRoute(input) {
1059
1086
  headers
1060
1087
  });
1061
1088
  }
1062
- const validatedAuthorization = await validateEd25519ReusableAuthorizedOperation({
1089
+ const validatedAuthorization = await timeEd25519SigningStage(timing, "admit", validateEd25519ReusableAuthorizedOperation({
1063
1090
  ctx: input.ctx,
1064
1091
  body: input.body,
1065
1092
  authorization
1066
- });
1093
+ }));
1067
1094
  if (!validatedAuthorization.ok) return validatedAuthorization.response;
1068
1095
  const replay = replayCompletedEd25519Operation(validatedAuthorization.operation);
1069
1096
  if (replay) return replay;
1070
1097
  if (!validatedAuthorization.ownerScope) throw new Error("Pinned owner Wallet Session scope is unavailable");
1071
- const upstream = await proxyEd25519OwnerLaneExecution({
1098
+ const upstream = await timeEd25519SigningStage(timing, "proxy", proxyEd25519OwnerLaneExecution({
1072
1099
  ctx: input.ctx,
1073
1100
  authorization,
1074
1101
  authorizedOperation: validatedAuthorization.operation,
@@ -1079,13 +1106,13 @@ async function handleRouterAbEd25519NormalSigningRoute(input) {
1079
1106
  binding: buildEd25519GatewayOwnerWalletSessionBinding(authorization, pinnedEd25519WalletScope(authorization, validatedAuthorization.ownerScope))
1080
1107
  })
1081
1108
  }
1082
- });
1109
+ }));
1083
1110
  const upstreamBodyText = await upstream.clone().text().catch(() => "");
1084
1111
  if (isRouterAbEd25519OperationInProgressResponse({
1085
1112
  status: upstream.status,
1086
1113
  bodyText: upstreamBodyText
1087
1114
  })) return upstream;
1088
- return requireCompletedEd25519OperationResponse(await completeEd25519Operation({
1115
+ return requireCompletedEd25519OperationResponse(await timeEd25519SigningStage(timing, "complete", completeEd25519Operation({
1089
1116
  ctx: input.ctx,
1090
1117
  operation: validatedAuthorization.operation,
1091
1118
  result: upstream.ok ? "succeeded" : upstream.status < 500 ? "failed_before_side_effect" : "failed_after_side_effect",
@@ -1093,7 +1120,7 @@ async function handleRouterAbEd25519NormalSigningRoute(input) {
1093
1120
  response: upstream,
1094
1121
  bodyText: upstreamBodyText
1095
1122
  })
1096
- }));
1123
+ })));
1097
1124
  }
1098
1125
  async function handleThresholdEd25519(ctx) {
1099
1126
  if (ctx.method === "GET" && ctx.pathname === "/router-ab/ed25519/healthz") {
@@ -44,7 +44,11 @@ function requireArray(value, label) {
44
44
  if (!Array.isArray(value)) throw new Error(`${label} must be an array`);
45
45
  return value;
46
46
  }
47
+ function assertString(val, name = "value") {
48
+ if (typeof val !== "string") throw new Error(`Invalid ${name}: expected string`);
49
+ return val;
50
+ }
47
51
  //#endregion
48
- export { asRecord, coerceNonEmptyString, isFunction, isObject, isPlainObject, requireArray, requireCanonicalString, requireNonEmptyString, requireRecord, requireRecordCopy, requireRecordOrArray, requireTrimmedString };
52
+ export { asRecord, assertString, coerceNonEmptyString, isFunction, isObject, isPlainObject, requireArray, requireCanonicalString, requireNonEmptyString, requireRecord, requireRecordCopy, requireRecordOrArray, requireTrimmedString };
49
53
 
50
54
  //# sourceMappingURL=validation.js.map
@@ -9,5 +9,4 @@ import { createSigningSessionSealOptions, parseSigningSessionSealRootConfig } fr
9
9
  import { createInMemorySigningSessionSealIdempotencyStore } from "./idempotency.js";
10
10
  import { createRedisTcpSigningSessionSealRateLimiter, createUpstashSigningSessionSealRateLimiter, resolveSigningSessionSealRateLimitFromEnv } from "./guards/backends.js";
11
11
  import { createRedisTcpSigningSessionSealIdempotencyStore, createUpstashSigningSessionSealIdempotencyStore, resolveSigningSessionSealIdempotencyFromEnv } from "./idempotencyBackends.js";
12
- import { registerSigningSessionSealRoutes } from "./transport/express.js";
13
- export { authorizeSigningSessionSealRequest, buildSigningSessionSealApplyPath, buildSigningSessionSealRemovePath, composeSigningSessionSealGuards, createInMemorySigningSessionSealIdempotencyStore, createInMemorySigningSessionSealRateLimiter, createPassthroughSigningSessionSealCipherAdapter, createRedisTcpSigningSessionSealIdempotencyStore, createRedisTcpSigningSessionSealRateLimiter, createSigningSessionSealAuditLogger, createSigningSessionSealCipherAdapter, createSigningSessionSealOptions, createSigningSessionSealRateLimitGuard, createSigningSessionSealRoutesOptions, createSigningSessionSealService, createSigningSessionSealShamir3PassCipherAdapter, createUpstashSigningSessionSealIdempotencyStore, createUpstashSigningSessionSealRateLimiter, encodeSigningSessionSealServerLockContext, handleSigningSessionSealRoutes, parseSigningSessionSealApplyBody, parseSigningSessionSealRemoveBody, parseSigningSessionSealRootConfig, registerSigningSessionSealRoutes, resolveSigningSessionSealBasePath, resolveSigningSessionSealIdempotencyFromEnv, resolveSigningSessionSealRateLimitFromEnv, signingSessionSealAuthorizeStatusCode, signingSessionSealStatusCode };
12
+ export { authorizeSigningSessionSealRequest, buildSigningSessionSealApplyPath, buildSigningSessionSealRemovePath, composeSigningSessionSealGuards, createInMemorySigningSessionSealIdempotencyStore, createInMemorySigningSessionSealRateLimiter, createPassthroughSigningSessionSealCipherAdapter, createRedisTcpSigningSessionSealIdempotencyStore, createRedisTcpSigningSessionSealRateLimiter, createSigningSessionSealAuditLogger, createSigningSessionSealCipherAdapter, createSigningSessionSealOptions, createSigningSessionSealRateLimitGuard, createSigningSessionSealRoutesOptions, createSigningSessionSealService, createSigningSessionSealShamir3PassCipherAdapter, createUpstashSigningSessionSealIdempotencyStore, createUpstashSigningSessionSealRateLimiter, encodeSigningSessionSealServerLockContext, handleSigningSessionSealRoutes, parseSigningSessionSealApplyBody, parseSigningSessionSealRemoveBody, parseSigningSessionSealRootConfig, resolveSigningSessionSealBasePath, resolveSigningSessionSealIdempotencyFromEnv, resolveSigningSessionSealRateLimitFromEnv, signingSessionSealAuthorizeStatusCode, signingSessionSealStatusCode };
@@ -6,6 +6,7 @@ export * from './core/logger';
6
6
  export * from './core/routerAbSigning/RouterAbEcdsaPresignRuntime';
7
7
  export * from './core/types';
8
8
  export * from './delegateAction';
9
+ export { LocalRegistrationSetupAuthority } from './localRegistrationSetupAuthority';
9
10
  export * from './router/framework/apiCredentialPorts';
10
11
  export { createWalletRegistrationContextResolver, unavailableRegistrationContext, walletRegistrationContext, } from './router/auth/walletRegistrationContext';
11
12
  export { parseWalletRegistrationSetupRequest } from './router/domains/walletRegistration/walletRegistrationRoutes';
@@ -6,7 +6,7 @@ export type LocalHostedWalletGatewayEnv = CloudflareD1GatewayBaseEnv & {
6
6
  /**
7
7
  * The local Gateway: the hosted Gateway handler plus the intended-suite
8
8
  * transport faults, which a request arms with local-only headers. The local
9
- * Worker and the local Node host both serve through this.
9
+ * Worker serves through this handler.
10
10
  */
11
11
  export declare function handleLocalHostedWalletGatewayRequestV1(request: Request, env: LocalHostedWalletGatewayEnv, ctx: CfExecutionContext, dependencies?: HostedWalletGatewayDependenciesV1): Promise<Response>;
12
12
  //# sourceMappingURL=localHostedWalletGatewayHandler.d.ts.map
@@ -5,9 +5,13 @@ export declare const LOCAL_INTENDED_YAO_FAULT_TOKEN_HEADER_V1 = "x-seams-intende
5
5
  * execute, and expects the Gateway to send the identical request again.
6
6
  * - `return_terminal_burned_once` has the Router end the first execute
7
7
  * burned, and expects the Gateway to answer that failure without retrying.
8
+ * - `answer_retryable_while_running_once` lets the Router keep running the
9
+ * first execute, and answers the Gateway at once that it failed
10
+ * recoverably, as a Deriver that refused a late preparation does. The
11
+ * Router's claim stays held until that run records its answer.
8
12
  */
9
- type LocalIntendedYaoFaultModeV1 = 'drop_router_response_once' | 'return_terminal_burned_once';
10
- type LocalIntendedYaoFaultProofV1 = 'exact_request_replayed' | 'terminal_failure_not_retried';
13
+ type LocalIntendedYaoFaultModeV1 = 'drop_router_response_once' | 'return_terminal_burned_once' | 'answer_retryable_while_running_once';
14
+ type LocalIntendedYaoFaultProofV1 = 'exact_request_replayed' | 'terminal_failure_not_retried' | 'execution_left_running';
11
15
  type LocalIntendedYaoFaultViolationV1 = 'fault_already_armed' | 'router_execute_not_observed' | 'router_first_response_failed' | 'router_retry_not_observed' | 'router_retry_body_changed' | 'router_retry_trace_changed' | 'router_retry_marked_as_replay' | 'router_retry_response_failed' | 'router_terminal_not_recorded' | 'unexpected_additional_execute';
12
16
  type LocalIntendedYaoFaultOutcomeV1 = {
13
17
  readonly kind: 'proved';
@@ -22,10 +26,16 @@ type LocalIntendedYaoFaultTokenV1 = {
22
26
  export declare function parseLocalIntendedYaoFaultModeV1(value: string | null): LocalIntendedYaoFaultModeV1 | null;
23
27
  export declare function parseLocalIntendedYaoFaultTokenV1(value: string | null): LocalIntendedYaoFaultTokenV1 | null;
24
28
  export declare function isLocalIntendedYaoFaultTokenV1(value: string | null): value is string;
29
+ /** Reconstructs a local fault request from its persisted boundary value. */
30
+ export declare function parseLocalIntendedKeptRouterRequestV1(value: unknown): Request;
25
31
  export declare class LocalIntendedYaoFaultControllerV1 {
26
32
  private readonly baseFetch;
33
+ /** Keeps a Router call alive after the Gateway answered without it. */
34
+ private readonly keepRunning;
27
35
  private state;
28
- constructor(baseFetch: typeof globalThis.fetch);
36
+ constructor(baseFetch: typeof globalThis.fetch,
37
+ /** Keeps a Router call alive after the Gateway answered without it. */
38
+ keepRunning: (running: Promise<unknown>) => void);
29
39
  arm(mode: LocalIntendedYaoFaultModeV1): void;
30
40
  fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
31
41
  consumeOutcome(): LocalIntendedYaoFaultOutcomeV1;
@@ -1,3 +1,4 @@
1
+ import type { D1RegistrationCeremonyRecordStore } from './router/cloudflare/d1/registration/d1RegistrationCeremonyRecordStore';
1
2
  export declare const LOCAL_INTENDED_YAO_RECOVERY_FAULT_HEADER_V1 = "x-seams-intended-yao-recovery-fault-v1";
2
3
  export declare const LOCAL_INTENDED_YAO_RECOVERY_FAULT_TOKEN_HEADER_V1 = "x-seams-intended-yao-recovery-fault-token-v1";
3
4
  /**
@@ -28,17 +29,18 @@ export declare class LocalIntendedYaoRecoveryFaultControllerV1 {
28
29
  private readonly baseFetch;
29
30
  private readonly mode;
30
31
  private readonly token;
32
+ private readonly storage;
31
33
  private executed;
32
34
  private failed;
33
35
  private kept;
34
- constructor(baseFetch: typeof globalThis.fetch, mode: 'lose_router_recovery_replies' | 'withhold_router_recovery_execute', token: string);
36
+ constructor(baseFetch: typeof globalThis.fetch, mode: 'lose_router_recovery_replies' | 'withhold_router_recovery_execute', token: string, storage: D1RegistrationCeremonyRecordStore);
35
37
  fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
36
38
  outcome(): LocalIntendedYaoRecoveryFaultOutcomeV1;
37
39
  }
38
40
  /** Sends the execution kept under `token` to the Router, exactly. */
39
41
  export declare function releaseLocalIntendedYaoRecoveryExecuteV1(router: {
40
42
  fetch(request: Request): Promise<Response>;
41
- }, token: string): Promise<Response>;
43
+ }, token: string, storage: D1RegistrationCeremonyRecordStore): Promise<Response>;
42
44
  export declare function requestWithoutLocalIntendedYaoRecoveryFaultHeadersV1(request: Request): Request;
43
45
  export declare function responseWithLocalIntendedYaoRecoveryFaultOutcomeV1(response: Response, outcome: LocalIntendedYaoRecoveryFaultOutcomeV1, token: string): Response;
44
46
  export {};
@@ -1,3 +1,4 @@
1
+ import type { D1RegistrationCeremonyRecordStore } from './router/cloudflare/d1/registration/d1RegistrationCeremonyRecordStore';
1
2
  export declare const LOCAL_INTENDED_YAO_SIGNING_FAULT_HEADER_V1 = "x-seams-intended-yao-signing-fault-v1";
2
3
  export declare const LOCAL_INTENDED_YAO_SIGNING_FAULT_TOKEN_HEADER_V1 = "x-seams-intended-yao-signing-fault-token-v1";
3
4
  export declare const ROUTER_AB_ED25519_SIGNING_FINALIZE_PATH_V1 = "/router-ab/ed25519/sign";
@@ -20,8 +21,9 @@ export declare class LocalIntendedYaoSigningFaultControllerV1 {
20
21
  private readonly baseFetch;
21
22
  private readonly mode;
22
23
  private readonly token;
24
+ private readonly storage;
23
25
  private kept;
24
- constructor(baseFetch: typeof globalThis.fetch, mode: 'capture_signing_finalize' | 'withhold_signing_finalize', token: string);
26
+ constructor(baseFetch: typeof globalThis.fetch, mode: 'capture_signing_finalize' | 'withhold_signing_finalize', token: string, storage: D1RegistrationCeremonyRecordStore);
25
27
  fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
26
28
  private keep;
27
29
  outcome(): string;
@@ -29,7 +31,7 @@ export declare class LocalIntendedYaoSigningFaultControllerV1 {
29
31
  /** Sends the finalize kept under `token` to the Router again, exactly. */
30
32
  export declare function releaseLocalIntendedYaoSigningFinalizeV1(router: {
31
33
  fetch(request: Request): Promise<Response>;
32
- }, token: string): Promise<Response>;
34
+ }, token: string, storage: D1RegistrationCeremonyRecordStore): Promise<Response>;
33
35
  export declare function requestWithoutLocalIntendedYaoSigningFaultHeadersV1(request: Request): Request;
34
36
  export declare function responseWithLocalIntendedYaoSigningFaultOutcomeV1(response: Response, outcome: string): Response;
35
37
  export {};
@@ -2,15 +2,7 @@ type HeaderBag = Headers | Record<string, unknown>;
2
2
  export declare function extractBearerCredential(headers: HeaderBag): string | null;
3
3
  export declare function normalizeSourceIp(raw: string | undefined): string | null;
4
4
  export declare function extractRouterApiEnvironmentId(headers: HeaderBag): string | null;
5
- export declare function resolveSourceIpFromExpressRequest(input: {
6
- headers: Record<string, unknown>;
7
- ip?: string | null;
8
- }): string | null;
9
5
  export declare function resolveSourceIpFromFetchHeaders(headers: HeaderBag): string | null;
10
- export declare function resolveRequestOriginRateLimitKeyFromExpressRequest(input: {
11
- headers: Record<string, unknown>;
12
- ip?: string | null;
13
- }): string;
14
6
  export declare function resolveRequestOriginRateLimitKeyFromFetchHeaders(headers: HeaderBag): string;
15
7
  export {};
16
8
  //# sourceMappingURL=routerApiKeyAuth.d.ts.map
@@ -40,6 +40,8 @@ export declare class D1RegistrationCeremonyRecordStore {
40
40
  constructor(options: D1RegistrationCeremonyRecordStoreOptions);
41
41
  get(scope: string, id: string): Promise<D1RegistrationCeremonyStoredRecord | null>;
42
42
  prepareGet(scope: string, id: string): D1PreparedStatementLike;
43
+ /** Load the ceremony's immutable founding identities and their current records together. */
44
+ prepareFoundingRecordsRead(id: string): D1PreparedStatementLike;
43
45
  parseGet(scope: string, id: string, row: StoredRow | null): Promise<D1RegistrationCeremonyStoredRecord | null>;
44
46
  putExact(mutation: D1RegistrationCeremonyRecordMutation): Promise<void>;
45
47
  insertOrRead(mutation: D1RegistrationCeremonyRecordMutation): Promise<D1RegistrationCeremonyStoredRecord>;
@@ -32,6 +32,7 @@ export declare class CloudflareD1RegistrationCeremonyIntentStore {
32
32
  reserveSetupCeremony(proposed: StoredWalletRegistrationCeremony, ownershipGeneration: number): Promise<StoredWalletRegistrationCeremony>;
33
33
  getCeremony(registrationCeremonyId: string): Promise<StoredWalletRegistrationCeremony | null>;
34
34
  prepareCeremonyRead(registrationCeremonyId: string): D1PreparedStatementLike;
35
+ prepareFoundingRecordsRead(registrationCeremonyId: string): D1PreparedStatementLike;
35
36
  parseCeremonyRead(registrationCeremonyId: string, result: D1ResultLike<Record<string, unknown>>): Promise<StoredWalletRegistrationCeremony | null>;
36
37
  parseCeremonySnapshotRead(registrationCeremonyId: string, result: D1ResultLike<Record<string, unknown>>): Promise<D1WalletRegistrationEcdsaCeremonyClaimV1 | null>;
37
38
  getCeremonySnapshot(registrationCeremonyId: string): Promise<D1WalletRegistrationEcdsaCeremonyClaimV1 | null>;