@seams/wallet-server 0.7.1 → 0.7.3

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 (259) hide show
  1. package/THIRD_PARTY_NOTICES.md +1 -105
  2. package/artifact-manifest.json +21 -21
  3. package/cloudflare-router-ab/build/deriver-a/build-stamp.json +1 -1
  4. package/cloudflare-router-ab/build/deriver-a/index_bg.wasm +0 -0
  5. package/cloudflare-router-ab/build/deriver-b/build-stamp.json +1 -1
  6. package/cloudflare-router-ab/build/deriver-b/index_bg.wasm +0 -0
  7. package/cloudflare-router-ab/build/local-tools/darwin-arm64/router_ab_local_init +0 -0
  8. package/cloudflare-router-ab/build/local-tools/darwin-x64/router_ab_local_init +0 -0
  9. package/cloudflare-router-ab/build/local-tools/linux-x64/router_ab_local_init +0 -0
  10. package/cloudflare-router-ab/build/router/build-stamp.json +1 -1
  11. package/cloudflare-router-ab/build/router/index_bg.wasm +0 -0
  12. package/cloudflare-router-ab/build/signing-worker/build-stamp.json +1 -1
  13. package/cloudflare-router-ab/build/signing-worker/index_bg.wasm +0 -0
  14. package/cloudflare-router-ab/build/tenant-root-control-plane/build-stamp.json +1 -1
  15. package/cloudflare-router-ab/build/tenant-root-control-plane/index_bg.wasm +0 -0
  16. package/dist/esm/authorization/service.js +8 -0
  17. package/dist/esm/authorization/vaultProxyUse.js +2 -6
  18. package/dist/esm/cloud-host.js +4 -4
  19. package/dist/esm/core/IdentityStore.js +23 -110
  20. package/dist/esm/core/SessionService.js +7 -30
  21. package/dist/esm/core/ThresholdService/routerAbNormalSigningPolicy.js +3 -10
  22. package/dist/esm/core/ThresholdService/stores/WalletSessionStore.js +21 -97
  23. package/dist/esm/core/ThresholdService/stores/exportReplayGuard.js +7 -0
  24. package/dist/esm/core/WalletStore.js +4 -6
  25. package/dist/esm/core/authService/bytes.js +1 -4
  26. package/dist/esm/core/authService/emailOtpChallengeOperations.js +2 -5
  27. package/dist/esm/core/authService/emailOtpChallengeProof.js +9 -40
  28. package/dist/esm/core/authService/emailOtpChallengeVerification.js +19 -90
  29. package/dist/esm/core/authService/emailOtpChallenges.js +10 -45
  30. package/dist/esm/core/authService/emailOtpDelivery.js +10 -45
  31. package/dist/esm/core/authService/emailOtpEnrollment.js +9 -40
  32. package/dist/esm/core/authService/emailOtpGrant.js +9 -40
  33. package/dist/esm/core/authService/emailOtpRegistrationEnrollment.js +9 -40
  34. package/dist/esm/core/authService/emailOtpSeal.js +5 -20
  35. package/dist/esm/core/authService/emailOtpUnlock.js +20 -110
  36. package/dist/esm/core/authService/googleEmailOtpRegistration.js +28 -115
  37. package/dist/esm/core/authService/identity.js +5 -20
  38. package/dist/esm/core/authService/nearPublicKeyMetadata.js +6 -25
  39. package/dist/esm/core/authService/oidcVerification.js +22 -34
  40. package/dist/esm/core/authService/rateLimits.js +2 -5
  41. package/dist/esm/core/authService/thresholdEcdsaKeyInventory.js +2 -1
  42. package/dist/esm/core/authService/webauthn.js +37 -191
  43. package/dist/esm/core/authService/webauthnVerificationOutcomes.js +5 -24
  44. package/dist/esm/core/d1EcdsaSignerRead.js +76 -0
  45. package/dist/esm/core/d1IdentityStore.js +16 -75
  46. package/dist/esm/core/d1TenantStore.js +1 -1
  47. package/dist/esm/core/d1WalletStore.js +15 -25
  48. package/dist/esm/core/deviceLinking/linkedDeviceEmailOtpGrant.js +1 -5
  49. package/dist/esm/core/deviceLinking/linkedDeviceSessionApproval.js +1 -3
  50. package/dist/esm/core/deviceLinking/linkedDeviceSessionRecord.js +2 -8
  51. package/dist/esm/core/deviceLinking/requestProof.js +13 -4
  52. package/dist/esm/core/ecdsaMaterialReadSnapshot.js +85 -0
  53. package/dist/esm/core/nearRelayerAccountProvisioning.js +2 -5
  54. package/dist/esm/core/signingLanes/WalletExecutionLaneProjection.js +3 -6
  55. package/dist/esm/core/signingMaterial/ordinaryInactiveSignerMaterialReservation.js +2 -5
  56. package/dist/esm/core/storeBackends.js +1 -1
  57. package/dist/esm/core/thresholdEcdsaChainTarget.js +1 -3
  58. package/dist/esm/hosted-wallet-gateway.js +2 -2
  59. package/dist/esm/localHostedWalletGatewayHandler.js +13 -0
  60. package/dist/esm/localIntendedMaterialAdmissionFault.js +176 -0
  61. package/dist/esm/localIntendedPresignCancellation.js +44 -0
  62. package/dist/esm/router/auth/commonRouterUtils.js +24 -10
  63. package/dist/esm/router/auth/walletSessionFailure.js +2 -5
  64. package/dist/esm/router/auth/webAuthnCredentialCodecs.js +4 -15
  65. package/dist/esm/router/cloudflare/d1/auth/d1AuthorizedOperationRouteService.js +1 -0
  66. package/dist/esm/router/cloudflare/d1/auth/d1RouterApiAuthBoundary.js +2 -6
  67. package/dist/esm/router/cloudflare/d1/auth/d1RouterApiAuthService.js +5 -27
  68. package/dist/esm/router/cloudflare/d1/auth/walletSessionCredentialReaders.js +76 -0
  69. package/dist/esm/router/cloudflare/d1/authorization/authorizedOperationStatements.js +28 -21
  70. package/dist/esm/router/cloudflare/d1/authorization/d1AuthorizationStore.js +209 -44
  71. package/dist/esm/router/cloudflare/d1/authorization/d1VaultProxyStore.js +8 -12
  72. package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceAuthorityInstallService.js +50 -8
  73. package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceTargetCredentialProvider.js +1 -1
  74. package/dist/esm/router/cloudflare/d1/deviceLinking/index.js +3 -3
  75. package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeIssuer.js +12 -55
  76. package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeService.js +17 -80
  77. package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpDeliveryRuntime.js +6 -25
  78. package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpRecords.js +12 -47
  79. package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpRecoveryService.js +24 -85
  80. package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpRegistrationEnrollmentFinalizer.js +7 -30
  81. package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpServerSealRuntime.js +5 -20
  82. package/dist/esm/router/cloudflare/d1/emailOtp/d1GoogleEmailOtpSessionResolver.js +23 -110
  83. package/dist/esm/router/cloudflare/d1/identity/d1IdentityService.js +9 -40
  84. package/dist/esm/router/cloudflare/d1/near/d1NearPublicKeyStore.js +3 -10
  85. package/dist/esm/router/cloudflare/d1/oidc/d1OidcBoundary.js +18 -91
  86. package/dist/esm/router/cloudflare/d1/oidc/d1OidcVerificationService.js +6 -30
  87. package/dist/esm/router/cloudflare/d1/passkeyCustody/d1PasskeyCustodyRouteService.js +4 -15
  88. package/dist/esm/router/cloudflare/d1/passkeyCustody/d1WalletCustodyCommitStore.js +2 -7
  89. package/dist/esm/router/cloudflare/d1/passkeyCustody/d1WalletRecoveryGoogleEmailOtpRecords.js +9 -13
  90. package/dist/esm/router/cloudflare/d1/passkeyCustody/d1WalletRecoveryGoogleEmailOtpService.js +11 -50
  91. package/dist/esm/router/cloudflare/d1/registration/d1EvmFamilyEcdsaRegistrationBranch.js +5 -20
  92. package/dist/esm/router/cloudflare/d1/registration/d1RegistrationCeremonyRecordStore.js +4 -7
  93. package/dist/esm/router/cloudflare/d1/registration/d1RegistrationCeremonyRecords.js +2 -1
  94. package/dist/esm/router/cloudflare/d1/registration/d1RegistrationIntentService.js +7 -30
  95. package/dist/esm/router/cloudflare/d1/registration/d1WalletRegistrationService.js +32 -22
  96. package/dist/esm/router/cloudflare/d1/registration/walletRegistrationSessionCommitReceipt.js +1 -4
  97. package/dist/esm/router/cloudflare/d1/signingAdmission/d1RouterAbNormalSigningAdmissionStore.js +119 -25
  98. package/dist/esm/router/cloudflare/d1/webauthn/d1WebAuthnAuthService.js +31 -168
  99. package/dist/esm/router/cloudflare/d1/webauthn/d1WebAuthnRecords.js +6 -9
  100. package/dist/esm/router/cloudflare/durableObjects/thresholdStore.js +59 -66
  101. package/dist/esm/router/cloudflare/runtime/routerAbPrewarm.js +2 -2
  102. package/dist/esm/router/cloudflare/runtime/staticWalletConsoleBinding.js +5 -20
  103. package/dist/esm/router/cloudflare/runtime/tenantRootCreationGrant.js +2 -9
  104. package/dist/esm/router/cloudflare/runtime/walletControlOps.js +2 -1
  105. package/dist/esm/router/cloudflare/signingLanes/cloudflareLaneCurveExecution.js +2 -1
  106. package/dist/esm/router/cloudflare/signingLanes/cloudflareLaneProtocolCommitter.js +2 -2
  107. package/dist/esm/router/cloudflare.js +2146 -1802
  108. package/dist/esm/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistrationPersistence.js +5 -8
  109. package/dist/esm/router/domains/ed25519Yao/recovery/routerAbEd25519YaoRecoveryWalletSessionAuthorization.js +3 -6
  110. package/dist/esm/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistrationIntentAuthorization.js +6 -25
  111. package/dist/esm/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistrationSideEffectBoundary.js +39 -55
  112. package/dist/esm/router/domains/emailOtp/emailOtpRouteHandlers.js +15 -62
  113. package/dist/esm/router/domains/signingOperations/routerAbEcdsaDerivationNormalSigningRoute.js +83 -74
  114. package/dist/esm/router/domains/signingOperations/routerAbNormalSigningAdmission.js +1 -0
  115. package/dist/esm/router/domains/signingOperations/routerAbOperationStepUp.js +1 -0
  116. package/dist/esm/router/domains/signingOperations/walletExecutionAdmission.js +1 -4
  117. package/dist/esm/router/domains/tenantRoot/tenantRootIdentityResolution.js +7 -13
  118. package/dist/esm/router/domains/walletUnlock/walletUnlockRouteHandlers.js +41 -200
  119. package/dist/esm/router/express.js +317 -699
  120. package/dist/esm/router/framework/http.js +5 -1
  121. package/dist/esm/router/framework/runtimeSnapshotConsumer.js +8 -35
  122. package/dist/esm/router/transport/fetch/createFetchRouter.js +3 -6
  123. package/dist/esm/router/transport/fetch/routes/auth.js +9 -41
  124. package/dist/esm/router/transport/fetch/routes/deviceLinkingOwnerAuthorization.js +5 -22
  125. package/dist/esm/router/transport/fetch/routes/nearPublicKeys.js +4 -16
  126. package/dist/esm/router/transport/fetch/routes/sessions.js +1 -0
  127. package/dist/esm/router/transport/fetch/routes/syncAccount.js +8 -36
  128. package/dist/esm/router/transport/fetch/routes/thresholdEcdsa.js +27 -79
  129. package/dist/esm/router/transport/fetch/routes/walletExecutionLanePreflight.js +4 -1
  130. package/dist/esm/router/transport/fetch/routes/webauthnAuthenticators.js +4 -16
  131. package/dist/esm/shared-ts/src/authorization/walletSignerActivationEquality.js +12 -0
  132. package/dist/esm/shared-ts/src/device-linking/committedSignerPackages.js +2 -5
  133. package/dist/esm/shared-ts/src/device-linking/delegatedActivationPlan.js +1 -5
  134. package/dist/esm/shared-ts/src/device-linking/ed25519ExportRoot.js +12 -16
  135. package/dist/esm/shared-ts/src/device-linking/sourceContribution.js +5 -8
  136. package/dist/esm/shared-ts/src/passkey-custody/primitives.js +5 -1
  137. package/dist/esm/shared-ts/src/signing-lanes/ownerContinuity.js +4 -8
  138. package/dist/esm/shared-ts/src/tenant-root/tenantRootIdentifier.js +12 -0
  139. package/dist/esm/shared-ts/src/tenant-root/tenantRootIdentity.js +2 -9
  140. package/dist/esm/shared-ts/src/tenant-root/tenantRootOperationRecord.js +1 -4
  141. package/dist/esm/shared-ts/src/utils/ecdsaKeyFactsInventory.js +2 -4
  142. package/dist/esm/shared-ts/src/utils/ecdsaServerTiming.js +0 -1
  143. package/dist/esm/shared-ts/src/utils/emailOtpDomain.js +3 -1
  144. package/dist/esm/shared-ts/src/utils/exactKeys.js +17 -0
  145. package/dist/esm/shared-ts/src/utils/failure.js +20 -0
  146. package/dist/esm/shared-ts/src/utils/registrationIntent.js +3 -12
  147. package/dist/esm/shared-ts/src/utils/registrationSignerPlan.js +2 -5
  148. package/dist/esm/shared-ts/src/utils/routerAbEcdsaDerivation.js +1 -1
  149. package/dist/esm/shared-ts/src/utils/routerAbEd25519Yao.js +1 -1
  150. package/dist/esm/shared-ts/src/utils/thresholdEcdsaChainTarget.js +9 -0
  151. package/dist/esm/shared-ts/src/wallet-recovery/walletRecoveryCommittedProjection.js +1 -4
  152. package/dist/esm/threshold/session/signingSessionSeal/crypto/cipher.js +10 -32
  153. package/dist/esm/threshold/session/signingSessionSeal/idempotencyBackends.js +3 -3
  154. package/dist/esm/threshold/session/signingSessionSeal/idempotencyRecords.js +3 -9
  155. package/dist/esm/threshold/session/signingSessionSeal/service.js +8 -35
  156. package/dist/esm/threshold/session/signingSessionSeal/transport/express.js +18 -94
  157. package/dist/esm/threshold/session/signingSessionSeal/transport/fetch.js +6 -30
  158. package/dist/esm/threshold/session/signingSessionSeal/transport/shared.js +5 -20
  159. package/dist/esm/wasm/evm_crypto/pkg/evm_crypto_bg.wasm +0 -0
  160. package/dist/esm/wasm/near_signer/pkg/wasm_signer_worker_bg.wasm +0 -0
  161. package/dist/types/shared-ts/src/authorization/delegatedAuthority.d.ts +2 -1
  162. package/dist/types/shared-ts/src/authorization/walletSessionIssuance.d.ts +9 -2
  163. package/dist/types/shared-ts/src/authorization/walletSignerActivationEquality.d.ts +4 -0
  164. package/dist/types/shared-ts/src/device-linking/committedSignerPackages.d.ts +3 -4
  165. package/dist/types/shared-ts/src/device-linking/contracts.d.ts +5 -63
  166. package/dist/types/shared-ts/src/device-linking/sourceContribution.d.ts +2 -0
  167. package/dist/types/shared-ts/src/passkey-custody/custodyEnvelope.d.ts +5 -12
  168. package/dist/types/shared-ts/src/passkey-custody/primitives.d.ts +9 -0
  169. package/dist/types/shared-ts/src/signing-lanes/execution.d.ts +11 -1
  170. package/dist/types/shared-ts/src/signing-lanes/ids.d.ts +1 -10
  171. package/dist/types/shared-ts/src/signing-lanes/rotation.d.ts +3 -5
  172. package/dist/types/shared-ts/src/tenant-root/tenantRootIdentifier.d.ts +3 -0
  173. package/dist/types/shared-ts/src/tenant-root/tenantRootOperationRecord.d.ts +2 -1
  174. package/dist/types/shared-ts/src/threshold/ecdsaDerivationRoleLocalBootstrap.d.ts +6 -0
  175. package/dist/types/shared-ts/src/threshold/signingRootScope.d.ts +1 -0
  176. package/dist/types/shared-ts/src/utils/ecdsaKeyFactsInventory.d.ts +2 -11
  177. package/dist/types/shared-ts/src/utils/eip1559TxWasmJson.d.ts +16 -0
  178. package/dist/types/shared-ts/src/utils/emailOtpDomain.d.ts +2 -0
  179. package/dist/types/shared-ts/src/utils/exactKeys.d.ts +11 -0
  180. package/dist/types/shared-ts/src/utils/failure.d.ts +12 -0
  181. package/dist/types/shared-ts/src/utils/jsonRpc.d.ts +3 -4
  182. package/dist/types/shared-ts/src/utils/nearRpcResults.d.ts +1 -0
  183. package/dist/types/shared-ts/src/utils/registrationAuthMethodInput.d.ts +3 -8
  184. package/dist/types/shared-ts/src/utils/registrationSignerPlan.d.ts +7 -19
  185. package/dist/types/shared-ts/src/utils/routerAbEcdsaDerivation.d.ts +3 -1
  186. package/dist/types/shared-ts/src/utils/routerAbEd25519Yao.d.ts +1 -0
  187. package/dist/types/shared-ts/src/utils/routerAbEd25519YaoDigests.d.ts +3 -4
  188. package/dist/types/shared-ts/src/utils/routerAbNormalSigningIdentity.d.ts +30 -8
  189. package/dist/types/shared-ts/src/utils/routerApiKeyAuth.d.ts +2 -0
  190. package/dist/types/shared-ts/src/utils/signingSessionSeal.d.ts +10 -11
  191. package/dist/types/shared-ts/src/utils/thresholdEcdsaChainTarget.d.ts +25 -0
  192. package/dist/types/shared-ts/src/utils/variant.d.ts +18 -0
  193. package/dist/types/shared-ts/src/utils/walletAuthMethodRecord.d.ts +3 -6
  194. package/dist/types/shared-ts/src/utils/webauthnDeviceInfo.d.ts +4 -2
  195. package/dist/types/shared-ts/src/wallet-recovery/recoveryEnvelopes.d.ts +3 -16
  196. package/dist/types/shared-ts/src/wallet-recovery/walletRecoveryPreparation.d.ts +15 -0
  197. package/dist/types/shared-ts/src/wallet-recovery/walletRecoveryTarget.d.ts +3 -4
  198. package/dist/types/wallet-server/src/authorization/domain.d.ts +13 -2
  199. package/dist/types/wallet-server/src/authorization/ecdsaWalletSessionAdmission.d.ts +27 -3
  200. package/dist/types/wallet-server/src/authorization/service.d.ts +19 -0
  201. package/dist/types/wallet-server/src/core/ThresholdService/stores/SessionStore.d.ts +2 -2
  202. package/dist/types/wallet-server/src/core/ThresholdService/stores/WalletSessionStore.d.ts +1 -1
  203. package/dist/types/wallet-server/src/core/ThresholdService/stores/exportReplayGuard.d.ts +3 -0
  204. package/dist/types/wallet-server/src/core/ThresholdService/validation.d.ts +8 -101
  205. package/dist/types/wallet-server/src/core/WebAuthnAuthenticatorStore.d.ts +8 -0
  206. package/dist/types/wallet-server/src/core/authService/bytes.d.ts +0 -1
  207. package/dist/types/wallet-server/src/core/authService/emailOtpChallenges.d.ts +2 -10
  208. package/dist/types/wallet-server/src/core/authService/emailOtpSeal.d.ts +1 -1
  209. package/dist/types/wallet-server/src/core/authService/emailOtpUnlock.d.ts +3 -10
  210. package/dist/types/wallet-server/src/core/d1EcdsaSignerRead.d.ts +39 -0
  211. package/dist/types/wallet-server/src/core/d1WalletStore.d.ts +10 -0
  212. package/dist/types/wallet-server/src/core/deviceLinking/linkedDeviceSessionRecord.d.ts +3 -4
  213. package/dist/types/wallet-server/src/core/ecdsaMaterialReadSnapshot.d.ts +19 -0
  214. package/dist/types/wallet-server/src/core/routerAbSigning/RouterAbNormalSigningRuntime.d.ts +3 -5
  215. package/dist/types/wallet-server/src/core/rpcClients/near/NearClient.d.ts +1 -2
  216. package/dist/types/wallet-server/src/core/signingLanes/WalletExecutionLaneProjection.d.ts +2 -11
  217. package/dist/types/wallet-server/src/core/signingLanes/signingWorkerLaneMaterialIdentity.d.ts +2 -19
  218. package/dist/types/wallet-server/src/core/thresholdEcdsaChainTarget.d.ts +3 -11
  219. package/dist/types/wallet-server/src/core/types.d.ts +2 -6
  220. package/dist/types/wallet-server/src/localIntendedMaterialAdmissionFault.d.ts +38 -0
  221. package/dist/types/wallet-server/src/localIntendedPresignCancellation.d.ts +4 -0
  222. package/dist/types/wallet-server/src/router/auth/authRequestValidation.d.ts +4 -9
  223. package/dist/types/wallet-server/src/router/auth/commonRouterUtils.d.ts +15 -1
  224. package/dist/types/wallet-server/src/router/cloudflare/d1/auth/d1RouterApiAuthBoundary.d.ts +0 -1
  225. package/dist/types/wallet-server/src/router/cloudflare/d1/auth/d1RouterApiAuthService.d.ts +1 -1
  226. package/dist/types/wallet-server/src/router/cloudflare/d1/auth/walletSessionCredentialReaders.d.ts +9 -0
  227. package/dist/types/wallet-server/src/router/cloudflare/d1/authorization/authorizedOperationStatements.d.ts +4 -0
  228. package/dist/types/wallet-server/src/router/cloudflare/d1/authorization/d1AuthorizationStore.d.ts +10 -1
  229. package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceAuthorityInstallService.d.ts +19 -2
  230. package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceSessionStore.d.ts +2 -6
  231. package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceTargetCredentialProvider.d.ts +5 -8
  232. package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpEnrollmentStore.d.ts +2 -8
  233. package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpRateLimitStore.d.ts +2 -9
  234. package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpRecords.d.ts +5 -5
  235. package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpServerSealRuntime.d.ts +4 -14
  236. package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1RegistrationCeremonyRecordStore.d.ts +2 -6
  237. package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1WalletRegistrationService.d.ts +8 -6
  238. package/dist/types/wallet-server/src/router/cloudflare/d1/signingAdmission/d1RouterAbNormalSigningAdmissionStore.d.ts +14 -1
  239. package/dist/types/wallet-server/src/router/cloudflare/d1/webauthn/d1WebAuthnRecords.d.ts +10 -39
  240. package/dist/types/wallet-server/src/router/cloudflare/runtime/walletConsoleOps.d.ts +8 -34
  241. package/dist/types/wallet-server/src/router/domains/ecdsa/thresholdEcdsaRequestValidation.d.ts +3 -15
  242. package/dist/types/wallet-server/src/router/domains/ed25519Yao/session/routerAbEd25519YaoWalletSession.d.ts +9 -50
  243. package/dist/types/wallet-server/src/router/domains/passkeyCustody/walletRecoveryKeyManifest.d.ts +1 -13
  244. package/dist/types/wallet-server/src/router/domains/signingOperations/routerAbEcdsaDerivationNormalSigningRoute.d.ts +8 -9
  245. package/dist/types/wallet-server/src/router/domains/signingOperations/routerAbNormalSigningAdmission.d.ts +13 -0
  246. package/dist/types/wallet-server/src/router/domains/signingOperations/routerAbOperationStepUp.d.ts +3 -4
  247. package/dist/types/wallet-server/src/router/domains/signingOperations/routerAbPrivateSigningWorker.d.ts +7 -16
  248. package/dist/types/wallet-server/src/router/domains/syncAccount/syncAccountRequestValidation.d.ts +2 -7
  249. package/dist/types/wallet-server/src/router/framework/apiCredentialPorts.d.ts +3 -1
  250. package/dist/types/wallet-server/src/router/framework/authServicePort.d.ts +25 -4
  251. package/dist/types/wallet-server/src/router/framework/http.d.ts +1 -0
  252. package/dist/types/wallet-server/src/router/framework/ror/normalize.d.ts +1 -9
  253. package/dist/types/wallet-server/src/router/transport/fetch/routes/deviceLinkingOwnerAuthorization.d.ts +3 -6
  254. package/dist/types/wallet-server/src/router/transport/fetch/routes/syncAccountBootstrap.d.ts +3 -5
  255. package/dist/types/wallet-server/src/router/transport/fetch/routes/thresholdEcdsa.d.ts +0 -1
  256. package/dist/types/wallet-server/src/threshold/session/signingSessionSeal/idempotencyRecords.d.ts +1 -2
  257. package/dist/types/wallet-server/src/threshold/session/signingSessionSeal/signingSessionSeal.types.d.ts +6 -8
  258. package/package.json +1 -1
  259. package/dist/esm/wasm/router_ab_ecdsa_signing_worker/pkg/router_ab_ecdsa_signing_worker_bg.wasm +0 -0
@@ -1,7 +1,7 @@
1
1
  import { isPlainObject } from "../../../shared-ts/src/utils/validation.js";
2
+ import { failure } from "../../../shared-ts/src/utils/failure.js";
3
+ import { EXPORT_REPLAY_GUARD_CLOCK_SKEW_MS, EXPORT_REPLAY_GUARD_MIN_RETENTION_MS } from "../../../core/ThresholdService/stores/exportReplayGuard.js";
2
4
  //#region src/router/cloudflare/durableObjects/thresholdStore.ts
3
- const EXPORT_REPLAY_GUARD_CLOCK_SKEW_MS = 5 * 6e4;
4
- const EXPORT_REPLAY_GUARD_MIN_RETENTION_MS = 1440 * 6e4;
5
5
  const ECDSA_SHARED_IDENTITY_CONFLICT_MESSAGE = "[threshold-ecdsa] EVM-family key identity already exists for wallet/subject/rp/signing root";
6
6
  const ECDSA_KEY_HANDLE_CONFLICT_MESSAGE = "[threshold-ecdsa] ECDSA key handle already exists in this namespace";
7
7
  function json(body, init) {
@@ -19,13 +19,6 @@ function ok(value) {
19
19
  value
20
20
  };
21
21
  }
22
- function err(code, message) {
23
- return {
24
- ok: false,
25
- code,
26
- message
27
- };
28
- }
29
22
  function toKey(input) {
30
23
  return typeof input === "string" ? input.trim() : "";
31
24
  }
@@ -94,25 +87,25 @@ var ThresholdStoreDurableObject = class {
94
87
  this.state = state;
95
88
  }
96
89
  async fetch(request) {
97
- if (request.method.toUpperCase() !== "POST") return json(err("method_not_allowed", "POST required"), { status: 405 });
90
+ if (request.method.toUpperCase() !== "POST") return json(failure("method_not_allowed", "POST required"), { status: 405 });
98
91
  let body;
99
92
  try {
100
93
  body = await request.json();
101
94
  } catch {
102
95
  body = null;
103
96
  }
104
- if (!isPlainObject(body)) return json(err("invalid_body", "Expected JSON object"));
97
+ if (!isPlainObject(body)) return json(failure("invalid_body", "Expected JSON object"));
105
98
  const op = body.op;
106
- if (typeof op !== "string") return json(err("invalid_body", "Missing op"));
99
+ if (typeof op !== "string") return json(failure("invalid_body", "Missing op"));
107
100
  const req = body;
108
101
  if (op === "get") {
109
102
  const key = toKey(req.key);
110
- if (!key) return json(err("invalid_body", "Missing key"));
103
+ if (!key) return json(failure("invalid_body", "Missing key"));
111
104
  return json(ok(await this.state.storage.get(key) ?? null));
112
105
  }
113
106
  if (op === "readVersioned") {
114
107
  const key = toKey(req.key);
115
- if (!key) return json(err("invalid_body", "Missing key"));
108
+ if (!key) return json(failure("invalid_body", "Missing key"));
116
109
  const value = await this.state.storage.get(key);
117
110
  if (value === null || value === void 0) return json(ok(null));
118
111
  return json(ok({
@@ -122,7 +115,7 @@ var ThresholdStoreDurableObject = class {
122
115
  }
123
116
  if (op === "readVersionedJson") {
124
117
  const key = toKey(req.key);
125
- if (!key) return json(err("invalid_body", "Missing key"));
118
+ if (!key) return json(failure("invalid_body", "Missing key"));
126
119
  const stored = await this.state.storage.get(key);
127
120
  if (stored === null || stored === void 0) return json(ok({ status: "missing" }));
128
121
  if (!isVersionedJsonRecordEnvelope(stored)) return json(ok({ status: "invalid_record" }));
@@ -134,12 +127,12 @@ var ThresholdStoreDurableObject = class {
134
127
  }
135
128
  if (op === "putVersionedJson") {
136
129
  const key = toKey(req.key);
137
- if (!key) return json(err("invalid_body", "Missing key"));
130
+ if (!key) return json(failure("invalid_body", "Missing key"));
138
131
  const expectedVersion = req.expectedVersion;
139
- if (expectedVersion !== null && typeof expectedVersion !== "string") return json(err("invalid_body", "expectedVersion must be null or a non-empty string"));
140
- if (typeof expectedVersion === "string" && !toKey(expectedVersion)) return json(err("invalid_body", "expectedVersion must be null or a non-empty string"));
132
+ if (expectedVersion !== null && typeof expectedVersion !== "string") return json(failure("invalid_body", "expectedVersion must be null or a non-empty string"));
133
+ if (typeof expectedVersion === "string" && !toKey(expectedVersion)) return json(failure("invalid_body", "expectedVersion must be null or a non-empty string"));
141
134
  const value = req.value;
142
- if (!isJsonValue(value)) return json(err("invalid_body", "value must be JSON serializable"));
135
+ if (!isJsonValue(value)) return json(failure("invalid_body", "value must be JSON serializable"));
143
136
  const ttl = toTtlSeconds(req.ttlMs);
144
137
  return json(ok(await withRequiredTxn(this.state, async (store) => {
145
138
  const current = await store.get(key);
@@ -163,7 +156,7 @@ var ThresholdStoreDurableObject = class {
163
156
  }
164
157
  if (op === "set") {
165
158
  const key = toKey(req.key);
166
- if (!key) return json(err("invalid_body", "Missing key"));
159
+ if (!key) return json(failure("invalid_body", "Missing key"));
167
160
  const ttl = toTtlSeconds(req.ttlMs);
168
161
  await this.state.storage.put(key, req.value, ttl ? { expirationTtl: ttl } : void 0);
169
162
  return json(ok(true));
@@ -171,8 +164,8 @@ var ThresholdStoreDurableObject = class {
171
164
  if (op === "claimVersioned") {
172
165
  const key = toKey(req.key);
173
166
  const expectedVersion = toKey(req.expectedVersion);
174
- if (!key) return json(err("invalid_body", "Missing key"));
175
- if (!expectedVersion) return json(err("invalid_body", "Missing expectedVersion"));
167
+ if (!key) return json(failure("invalid_body", "Missing key"));
168
+ if (!expectedVersion) return json(failure("invalid_body", "Missing expectedVersion"));
176
169
  return json(ok(await withTxn(this.state, async (store) => {
177
170
  const value = await store.get(key);
178
171
  if (value === null || value === void 0) return { status: "not_found" };
@@ -195,17 +188,17 @@ var ThresholdStoreDurableObject = class {
195
188
  const identityValue = toKey(req.identityValue);
196
189
  const keyHandleKey = toKey(req.keyHandleKey);
197
190
  const keyHandleValue = toKey(req.keyHandleValue);
198
- if (!key) return json(err("invalid_body", "Missing key"));
199
- if (!identityKey) return json(err("invalid_body", "Missing identityKey"));
200
- if (!identityValue) return json(err("invalid_body", "Missing identityValue"));
201
- if (!keyHandleKey) return json(err("invalid_body", "Missing keyHandleKey"));
202
- if (!keyHandleValue) return json(err("invalid_body", "Missing keyHandleValue"));
191
+ if (!key) return json(failure("invalid_body", "Missing key"));
192
+ if (!identityKey) return json(failure("invalid_body", "Missing identityKey"));
193
+ if (!identityValue) return json(failure("invalid_body", "Missing identityValue"));
194
+ if (!keyHandleKey) return json(failure("invalid_body", "Missing keyHandleKey"));
195
+ if (!keyHandleValue) return json(failure("invalid_body", "Missing keyHandleValue"));
203
196
  const ttl = toTtlSeconds(req.ttlMs);
204
197
  return json(await withTxn(this.state, async (store) => {
205
198
  const existing = await store.get(identityKey);
206
- if (existing !== null && existing !== void 0 && existing !== identityValue) return err("conflict", ECDSA_SHARED_IDENTITY_CONFLICT_MESSAGE);
199
+ if (existing !== null && existing !== void 0 && existing !== identityValue) return failure("conflict", ECDSA_SHARED_IDENTITY_CONFLICT_MESSAGE);
207
200
  const existingKeyHandle = await store.get(keyHandleKey);
208
- if (existingKeyHandle !== null && existingKeyHandle !== void 0 && existingKeyHandle !== keyHandleValue) return err("conflict", ECDSA_KEY_HANDLE_CONFLICT_MESSAGE);
201
+ if (existingKeyHandle !== null && existingKeyHandle !== void 0 && existingKeyHandle !== keyHandleValue) return failure("conflict", ECDSA_KEY_HANDLE_CONFLICT_MESSAGE);
209
202
  await store.put(key, req.value, ttl ? { expirationTtl: ttl } : void 0);
210
203
  await store.put(identityKey, identityValue);
211
204
  await store.put(keyHandleKey, keyHandleValue);
@@ -214,7 +207,7 @@ var ThresholdStoreDurableObject = class {
214
207
  }
215
208
  if (op === "del") {
216
209
  const key = toKey(req.key);
217
- if (!key) return json(err("invalid_body", "Missing key"));
210
+ if (!key) return json(failure("invalid_body", "Missing key"));
218
211
  return json(ok(await this.state.storage.delete(key)));
219
212
  }
220
213
  if (op === "delWithIdentityGuard") {
@@ -223,11 +216,11 @@ var ThresholdStoreDurableObject = class {
223
216
  const identityValue = toKey(req.identityValue);
224
217
  const keyHandleKey = toKey(req.keyHandleKey);
225
218
  const keyHandleValue = toKey(req.keyHandleValue);
226
- if (!key) return json(err("invalid_body", "Missing key"));
227
- if (!identityKey) return json(err("invalid_body", "Missing identityKey"));
228
- if (!identityValue) return json(err("invalid_body", "Missing identityValue"));
229
- if (!keyHandleKey) return json(err("invalid_body", "Missing keyHandleKey"));
230
- if (!keyHandleValue) return json(err("invalid_body", "Missing keyHandleValue"));
219
+ if (!key) return json(failure("invalid_body", "Missing key"));
220
+ if (!identityKey) return json(failure("invalid_body", "Missing identityKey"));
221
+ if (!identityValue) return json(failure("invalid_body", "Missing identityValue"));
222
+ if (!keyHandleKey) return json(failure("invalid_body", "Missing keyHandleKey"));
223
+ if (!keyHandleValue) return json(failure("invalid_body", "Missing keyHandleValue"));
231
224
  await withTxn(this.state, async (store) => {
232
225
  await store.delete(key);
233
226
  if (await store.get(identityKey) === identityValue) await store.delete(identityKey);
@@ -237,7 +230,7 @@ var ThresholdStoreDurableObject = class {
237
230
  }
238
231
  if (op === "getdel") {
239
232
  const key = toKey(req.key);
240
- if (!key) return json(err("invalid_body", "Missing key"));
233
+ if (!key) return json(failure("invalid_body", "Missing key"));
241
234
  return json(ok(await withTxn(this.state, async (store) => {
242
235
  const v = await store.get(key);
243
236
  await store.delete(key);
@@ -247,8 +240,8 @@ var ThresholdStoreDurableObject = class {
247
240
  if (op === "getdelIfRelatedMatches") {
248
241
  const key = toKey(req.key);
249
242
  const relatedKey = toKey(req.relatedKey);
250
- if (!key) return json(err("invalid_body", "Missing key"));
251
- if (!relatedKey) return json(err("invalid_body", "Missing relatedKey"));
243
+ if (!key) return json(failure("invalid_body", "Missing key"));
244
+ if (!relatedKey) return json(failure("invalid_body", "Missing relatedKey"));
252
245
  const expectedRelated = req.expectedRelated;
253
246
  return json(ok(await withTxn(this.state, async (store) => {
254
247
  if (!jsonValueContains(await store.get(relatedKey), expectedRelated)) return {
@@ -266,9 +259,9 @@ var ThresholdStoreDurableObject = class {
266
259
  if (op === "walletTakeEcdsaPendingSessionActivationPair") {
267
260
  const recoveryKey = toKey(req.recoveryKey);
268
261
  const refreshKey = toKey(req.refreshKey);
269
- if (!recoveryKey) return json(err("invalid_body", "Missing recoveryKey"));
270
- if (!refreshKey) return json(err("invalid_body", "Missing refreshKey"));
271
- if (recoveryKey === refreshKey) return json(err("invalid_body", "Recovery and refresh keys must be distinct"));
262
+ if (!recoveryKey) return json(failure("invalid_body", "Missing recoveryKey"));
263
+ if (!refreshKey) return json(failure("invalid_body", "Missing refreshKey"));
264
+ if (recoveryKey === refreshKey) return json(failure("invalid_body", "Recovery and refresh keys must be distinct"));
272
265
  return json(ok(await withRequiredTxn(this.state, async (store) => {
273
266
  const recovery = await store.get(recoveryKey);
274
267
  const refresh = await store.get(refreshKey);
@@ -285,9 +278,9 @@ var ThresholdStoreDurableObject = class {
285
278
  const ceremonyKey = toKey(req.ceremonyKey);
286
279
  const registrationCeremonyId = toKey(req.registrationCeremonyId);
287
280
  const walletId = toKey(req.walletId);
288
- if (!ceremonyKey) return json(err("invalid_body", "Missing terminal registration ceremony key"));
289
- if (!registrationCeremonyId) return json(err("invalid_body", "Missing terminal registration ceremony ID"));
290
- if (!walletId) return json(err("invalid_body", "Missing terminal registration walletId"));
281
+ if (!ceremonyKey) return json(failure("invalid_body", "Missing terminal registration ceremony key"));
282
+ if (!registrationCeremonyId) return json(failure("invalid_body", "Missing terminal registration ceremony ID"));
283
+ if (!walletId) return json(failure("invalid_body", "Missing terminal registration walletId"));
291
284
  return json(await withRequiredTxn(this.state, async (store) => {
292
285
  const ceremony = await store.get(ceremonyKey);
293
286
  if (ceremony === null || ceremony === void 0) return ok({
@@ -298,7 +291,7 @@ var ThresholdStoreDurableObject = class {
298
291
  raw: ceremony,
299
292
  registrationCeremonyId,
300
293
  walletId
301
- })) return err("registration_ceremony_identity_mismatch", "Terminal registration cancellation does not match the stored ceremony");
294
+ })) return failure("registration_ceremony_identity_mismatch", "Terminal registration cancellation does not match the stored ceremony");
302
295
  await store.delete(ceremonyKey);
303
296
  return ok({
304
297
  kind: "cancelled",
@@ -308,15 +301,15 @@ var ThresholdStoreDurableObject = class {
308
301
  }
309
302
  if (op === "authConsumeUseCount") {
310
303
  const key = toKey(req.key);
311
- if (!key) return json(err("invalid_body", "Missing key"));
304
+ if (!key) return json(failure("invalid_body", "Missing key"));
312
305
  return json(await withTxn(this.state, async (store) => {
313
306
  const entry = parseAuthEntry(await store.get(key));
314
- if (!entry) return err("wallet_session_missing", "Wallet Session is missing");
307
+ if (!entry) return failure("wallet_session_missing", "Wallet Session is missing");
315
308
  if (entry.expiresAtMs <= Date.now()) {
316
309
  await store.delete(key);
317
- return err("wallet_session_expired", "Wallet Session expired");
310
+ return failure("wallet_session_expired", "Wallet Session expired");
318
311
  }
319
- if (entry.remainingUses <= 0) return err("wallet_budget_exhausted", "Wallet Session exhausted");
312
+ if (entry.remainingUses <= 0) return failure("wallet_budget_exhausted", "Wallet Session exhausted");
320
313
  entry.remainingUses -= 1;
321
314
  const ttlSeconds = Math.max(1, Math.ceil(Math.max(0, entry.expiresAtMs - Date.now()) / 1e3));
322
315
  await store.put(key, entry, { expirationTtl: ttlSeconds });
@@ -326,18 +319,18 @@ var ThresholdStoreDurableObject = class {
326
319
  if (op === "authConsumeUseCountOnce") {
327
320
  const key = toKey(req.key);
328
321
  const idempotencyKey = toKey(req.idempotencyKey);
329
- if (!key) return json(err("invalid_body", "Missing key"));
330
- if (!idempotencyKey) return json(err("invalid_body", "Missing idempotencyKey"));
322
+ if (!key) return json(failure("invalid_body", "Missing key"));
323
+ if (!idempotencyKey) return json(failure("invalid_body", "Missing idempotencyKey"));
331
324
  return json(await withTxn(this.state, async (store) => {
332
325
  const entry = parseAuthEntry(await store.get(key));
333
- if (!entry) return err("wallet_session_missing", "Wallet Session is missing");
326
+ if (!entry) return failure("wallet_session_missing", "Wallet Session is missing");
334
327
  if (entry.expiresAtMs <= Date.now()) {
335
328
  await store.delete(key);
336
- return err("wallet_session_expired", "Wallet Session expired");
329
+ return failure("wallet_session_expired", "Wallet Session expired");
337
330
  }
338
331
  const consumedIdempotencyKeys = entry.consumedIdempotencyKeys || {};
339
332
  if (consumedIdempotencyKeys[idempotencyKey]) return ok({ remainingUses: entry.remainingUses });
340
- if (entry.remainingUses <= 0) return err("wallet_budget_exhausted", "Wallet Session exhausted");
333
+ if (entry.remainingUses <= 0) return failure("wallet_budget_exhausted", "Wallet Session exhausted");
341
334
  entry.remainingUses -= 1;
342
335
  entry.consumedIdempotencyKeys = {
343
336
  ...consumedIdempotencyKeys,
@@ -351,26 +344,26 @@ var ThresholdStoreDurableObject = class {
351
344
  if (op === "authHasConsumedUseCountOnce") {
352
345
  const key = toKey(req.key);
353
346
  const idempotencyKey = toKey(req.idempotencyKey);
354
- if (!key) return json(err("invalid_body", "Missing key"));
355
- if (!idempotencyKey) return json(err("invalid_body", "Missing idempotencyKey"));
347
+ if (!key) return json(failure("invalid_body", "Missing key"));
348
+ if (!idempotencyKey) return json(failure("invalid_body", "Missing idempotencyKey"));
356
349
  return json(await withTxn(this.state, async (store) => {
357
350
  const entry = parseAuthEntry(await store.get(key));
358
- if (!entry) return err("wallet_session_missing", "Wallet Session is missing");
351
+ if (!entry) return failure("wallet_session_missing", "Wallet Session is missing");
359
352
  if (entry.expiresAtMs <= Date.now()) {
360
353
  await store.delete(key);
361
- return err("wallet_session_expired", "Wallet Session expired");
354
+ return failure("wallet_session_expired", "Wallet Session expired");
362
355
  }
363
356
  return ok({ consumed: (entry.consumedIdempotencyKeys || {})[idempotencyKey] === true });
364
357
  }));
365
358
  }
366
359
  if (op === "authGetSessionStatus") {
367
360
  const key = toKey(req.key);
368
- if (!key) return json(err("invalid_body", "Missing key"));
361
+ if (!key) return json(failure("invalid_body", "Missing key"));
369
362
  const entry = parseAuthEntry(await this.state.storage.get(key));
370
- if (!entry) return json(err("wallet_session_missing", "Wallet Session is missing"));
363
+ if (!entry) return json(failure("wallet_session_missing", "Wallet Session is missing"));
371
364
  if (entry.expiresAtMs <= Date.now()) {
372
365
  await this.state.storage.delete(key);
373
- return json(err("wallet_session_expired", "Wallet Session expired"));
366
+ return json(failure("wallet_session_expired", "Wallet Session expired"));
374
367
  }
375
368
  return json(ok({
376
369
  record: entry.record,
@@ -381,21 +374,21 @@ var ThresholdStoreDurableObject = class {
381
374
  if (op === "authReserveReplayGuard") {
382
375
  const key = toKey(req.key);
383
376
  const expiresAtMs = Number(req.expiresAtMs);
384
- if (!key) return json(err("invalid_body", "Missing key"));
385
- if (!Number.isFinite(expiresAtMs)) return json(err("invalid_body", "Invalid expiresAtMs"));
377
+ if (!key) return json(failure("invalid_body", "Missing key"));
378
+ if (!Number.isFinite(expiresAtMs)) return json(failure("invalid_body", "Invalid expiresAtMs"));
386
379
  return json(await withTxn(this.state, async (store) => {
387
380
  const nowMs = Date.now();
388
- if (expiresAtMs <= nowMs) return err("export_authorization_expired", "Export authorization expired");
381
+ if (expiresAtMs <= nowMs) return failure("export_authorization_expired", "Export authorization expired");
389
382
  const raw = await store.get(key);
390
383
  const existingExpiresAtMs = raw && typeof raw === "object" && "expiresAtMs" in raw ? Number(raw.expiresAtMs) : NaN;
391
- if (Number.isFinite(existingExpiresAtMs) && existingExpiresAtMs > nowMs) return err("export_nonce_replay", "Export authorization nonce already used");
384
+ if (Number.isFinite(existingExpiresAtMs) && existingExpiresAtMs > nowMs) return failure("export_nonce_replay", "Export authorization nonce already used");
392
385
  const retainedUntilMs = Math.max(nowMs + EXPORT_REPLAY_GUARD_MIN_RETENTION_MS, expiresAtMs + EXPORT_REPLAY_GUARD_CLOCK_SKEW_MS);
393
386
  const ttlSeconds = Math.max(1, Math.ceil((retainedUntilMs - nowMs) / 1e3));
394
387
  await store.put(key, { expiresAtMs: retainedUntilMs }, { expirationTtl: ttlSeconds });
395
388
  return ok({ reserved: true });
396
389
  }));
397
390
  }
398
- return json(err("invalid_body", `Unknown op: ${op}`));
391
+ return json(failure("invalid_body", `Unknown op: ${op}`));
399
392
  }
400
393
  };
401
394
  //#endregion
@@ -1,8 +1,8 @@
1
+ import { ROUTER_AB_INTERNAL_SERVICE_AUTH_HEADER_V1 } from "../../../core/ThresholdService/routerAb/internalServiceHttp.js";
1
2
  import { ROUTER_AB_MPC_ROUTER_ORIGIN } from "./routerAbServiceBindings.js";
2
3
  //#region src/router/cloudflare/runtime/routerAbPrewarm.ts
3
4
  const ROUTER_AB_PREWARM_CRON = "* * * * *";
4
5
  const ROUTER_AB_PREWARM_PATH = "/internal/prewarm";
5
- const ROUTER_AB_INTERNAL_SERVICE_AUTH_HEADER = "x-router-ab-internal-service-auth";
6
6
  function parseRouterAbPrewarmEnabled(value) {
7
7
  if (value === "true") return true;
8
8
  if (value === "false") return false;
@@ -23,7 +23,7 @@ async function runRouterAbPrewarmScheduledV1(event, env) {
23
23
  if (!parseRouterAbPrewarmEnabled(env.ROUTER_AB_PREWARM_ENABLED)) return;
24
24
  const response = await env.MPC_ROUTER.fetch(new Request(`${ROUTER_AB_MPC_ROUTER_ORIGIN}${ROUTER_AB_PREWARM_PATH}`, {
25
25
  method: "POST",
26
- headers: { [ROUTER_AB_INTERNAL_SERVICE_AUTH_HEADER]: requireRouterAbInternalServiceAuthSecret(env) }
26
+ headers: { [ROUTER_AB_INTERNAL_SERVICE_AUTH_HEADER_V1]: requireRouterAbInternalServiceAuthSecret(env) }
27
27
  }));
28
28
  if (!response.ok) throw new Error(`Router A/B prewarm failed with HTTP ${response.status}`);
29
29
  if (!isSuccessfulRouterAbPrewarmResponse(await response.json())) throw new Error("Router A/B prewarm returned an invalid response");
@@ -1,3 +1,4 @@
1
+ import { failure } from "../../../shared-ts/src/utils/failure.js";
1
2
  import { ROUTER_API_CREDENTIAL_SCOPES } from "../../framework/apiCredentialPorts.js";
2
3
  import { WALLET_CONSOLE_OP_PATHS_V1, decodeWalletConsoleTenantRootActiveLineageRequestV1 } from "./walletConsoleOps.js";
3
4
  //#region src/router/cloudflare/runtime/staticWalletConsoleBinding.ts
@@ -101,11 +102,7 @@ function includesScope(scopes, value) {
101
102
  }
102
103
  function projectEnvironmentsResponse(config, value) {
103
104
  const context = record(record(value)?.context);
104
- if (!context || context.orgId !== config.deployment.orgId) return json({
105
- ok: false,
106
- code: "environment_not_found",
107
- message: "Environment not found"
108
- }, 404);
105
+ if (!context || context.orgId !== config.deployment.orgId) return json(failure("environment_not_found", "Environment not found"), 404);
109
106
  return json({
110
107
  ok: true,
111
108
  environments: [{
@@ -119,17 +116,9 @@ function projectEnvironmentsResponse(config, value) {
119
116
  }
120
117
  function activeLineageResponse(config, value) {
121
118
  const decoded = decodeWalletConsoleTenantRootActiveLineageRequestV1(value);
122
- if (!decoded.ok) return json({
123
- ok: false,
124
- code: "invalid_body",
125
- message: "Identity is invalid"
126
- }, 400);
119
+ if (!decoded.ok) return json(failure("invalid_body", "Identity is invalid"), 400);
127
120
  const identity = decoded.value;
128
- if (identity.orgId !== config.deployment.orgId || identity.projectId !== config.deployment.projectId || identity.envId !== config.deployment.environmentId || identity.signingRootId !== config.tenantRoot.signingRootId || identity.signingRootVersion !== config.deployment.signingRootVersion) return json({
129
- ok: false,
130
- code: "tenant_root_active_lineage_not_found",
131
- message: "Active tenant-root lineage was not found"
132
- }, 404);
121
+ if (identity.orgId !== config.deployment.orgId || identity.projectId !== config.deployment.projectId || identity.envId !== config.deployment.environmentId || identity.signingRootId !== config.tenantRoot.signingRootId || identity.signingRootVersion !== config.deployment.signingRootVersion) return json(failure("tenant_root_active_lineage_not_found", "Active tenant-root lineage was not found"), 404);
133
122
  return json({
134
123
  ok: true,
135
124
  identityDigestB64u: config.tenantRoot.identityDigestB64u,
@@ -147,11 +136,7 @@ function principal(config) {
147
136
  };
148
137
  }
149
138
  function authFailure(code, message, status = 401) {
150
- return json({
151
- ok: false,
152
- code,
153
- message
154
- }, status);
139
+ return json(failure(code, message), status);
155
140
  }
156
141
  function record(value) {
157
142
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
@@ -1,4 +1,5 @@
1
1
  import { base64UrlDecode, base64UrlEncode } from "../../../shared-ts/src/utils/base64.js";
2
+ import { hasControlCharacters } from "../../../shared-ts/src/tenant-root/tenantRootIdentifier.js";
2
3
  import { encodeTenantRootIdentityV1 } from "../../../shared-ts/src/tenant-root/tenantRootIdentity.js";
3
4
  //#region src/router/cloudflare/runtime/tenantRootCreationGrant.ts
4
5
  const GRANT_DOMAIN = new TextEncoder().encode("tenant_root_creation_grant_v1");
@@ -22,7 +23,6 @@ const ED25519_PKCS8_SEED_PREFIX = Uint8Array.from([
22
23
  4,
23
24
  32
24
25
  ]);
25
- const MAX_IDENTIFIER_BYTES = 256;
26
26
  const MAX_GRANT_LIFETIME_MS = 3e5;
27
27
  function concatBytes(parts) {
28
28
  const length = parts.reduce((sum, part) => sum + part.length, 0);
@@ -47,17 +47,10 @@ function u64(value, label) {
47
47
  new DataView(output.buffer).setBigUint64(0, BigInt(value), false);
48
48
  return output;
49
49
  }
50
- function hasControlCharacters(value) {
51
- for (const character of value) {
52
- const codePoint = character.codePointAt(0) ?? 0;
53
- if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) return true;
54
- }
55
- return false;
56
- }
57
50
  function identifierBytes(value, label) {
58
51
  if (!value || value.trim() !== value || hasControlCharacters(value)) throw new Error(`${label} is invalid`);
59
52
  const bytes = new TextEncoder().encode(value);
60
- if (bytes.length > MAX_IDENTIFIER_BYTES) throw new Error(`${label} exceeds ${MAX_IDENTIFIER_BYTES} UTF-8 bytes`);
53
+ if (bytes.length > 256) throw new Error(`${label} exceeds 256 UTF-8 bytes`);
61
54
  return bytes;
62
55
  }
63
56
  async function tenantRootIdentityDigestB64uV1(identity) {
@@ -1,3 +1,4 @@
1
+ import { ROUTER_AB_INTERNAL_SERVICE_AUTH_HEADER_V1 } from "../../../core/ThresholdService/routerAb/internalServiceHttp.js";
1
2
  //#region src/router/cloudflare/runtime/walletControlOps.ts
2
3
  const WALLET_CONTROL_SERVICE_ORIGIN_V1 = "https://wallet-runtime.internal";
3
4
  const WALLET_CONTROL_BASE_PATH_V1 = "/internal/wallet-runtime/v1/tenant-root-control";
@@ -74,7 +75,7 @@ async function handleWalletControlRequest(request, env) {
74
75
  redirect: "manual",
75
76
  headers: {
76
77
  "content-type": contentType,
77
- "x-router-ab-internal-service-auth": requireInternalServiceAuth(env)
78
+ [ROUTER_AB_INTERNAL_SERVICE_AUTH_HEADER_V1]: requireInternalServiceAuth(env)
78
79
  },
79
80
  body
80
81
  }));
@@ -6,6 +6,7 @@ import { routerAbMpcMaterialActivationRefToWire, sameRouterAbMpcMaterialActivati
6
6
  import { parseEcdsaLifecycleId } from "../../../shared-ts/src/utils/ecdsaCapabilityActivation.js";
7
7
  import { parseLaneProtocolCommitReceiptV1, parseLaneServerActivationReceiptV1, parseRevokeSigningLaneV1 } from "../../../shared-ts/src/signing-lanes/rotationParsers.js";
8
8
  import { encodeLaneProtocolCommitReceiptV1 } from "../../../shared-ts/src/signing-lanes/rotationDigests.js";
9
+ import { ROUTER_AB_INTERNAL_SERVICE_AUTH_HEADER_V1 } from "../../../core/ThresholdService/routerAb/internalServiceHttp.js";
9
10
  import { buildEcdsaServerRetirementRequestV1, parseAndVerifyEcdsaServerRetirementEffectV1 } from "../../../core/signingLanes/ecdsaServerRetirement.js";
10
11
  import { buildEd25519ServerRetirementRequestV1, parseAndVerifyEd25519ServerRetirementEffectV1 } from "../../../core/signingLanes/ed25519ServerRetirement.js";
11
12
  //#region src/router/cloudflare/signingLanes/cloudflareLaneCurveExecution.ts
@@ -569,7 +570,7 @@ async function postSigningWorkerJsonV1(input) {
569
570
  method: "POST",
570
571
  headers: {
571
572
  "content-type": "application/json",
572
- "x-router-ab-internal-service-auth": input.internalServiceAuth
573
+ [ROUTER_AB_INTERNAL_SERVICE_AUTH_HEADER_V1]: input.internalServiceAuth
573
574
  },
574
575
  body: JSON.stringify(input.body)
575
576
  }));
@@ -1,10 +1,10 @@
1
1
  import { mpcMaterialActivationRefsEqual } from "../../../shared-ts/src/utils/domainIds.js";
2
2
  import { parseLaneProtocolCommitReceiptV1 } from "../../../shared-ts/src/signing-lanes/rotationParsers.js";
3
3
  import { LaneLifecycleApplicationService } from "../../../core/signingLanes/LaneLifecycleApplicationService.js";
4
+ import { ROUTER_AB_INTERNAL_SERVICE_AUTH_HEADER_V1 } from "../../../core/ThresholdService/routerAb/internalServiceHttp.js";
4
5
  import { parseRotatableSigningLaneJobV1 } from "../../../shared-ts/src/signing-lanes/rotationProtocolParsers.js";
5
6
  //#region src/router/cloudflare/signingLanes/cloudflareLaneProtocolCommitter.ts
6
7
  const ROUTER_AB_ED25519_YAO_LANE_EXECUTE_PATH_V1 = "/router-ab/internal/ed25519-yao/lane/execute";
7
- const INTERNAL_SERVICE_AUTH_HEADER = "x-router-ab-internal-service-auth";
8
8
  const REPLAY_HEADER = "x-seams-lane-replay";
9
9
  const INTERNAL_ROUTER_ORIGIN = "https://router.router-ab.internal";
10
10
  var CloudflareEd25519LaneProtocolTransportV1 = class {
@@ -155,7 +155,7 @@ function boundedLaneWorkerErrorBodyV1(body) {
155
155
  async function fetchInternal(input, body, replay) {
156
156
  const headers = {
157
157
  "content-type": "application/json",
158
- [INTERNAL_SERVICE_AUTH_HEADER]: input.internalServiceAuth
158
+ [ROUTER_AB_INTERNAL_SERVICE_AUTH_HEADER_V1]: input.internalServiceAuth
159
159
  };
160
160
  if (replay) headers[REPLAY_HEADER] = "1";
161
161
  return await input.binding.fetch(new Request(`${INTERNAL_ROUTER_ORIGIN}${input.path}`, {