@seams/wallet-server 0.6.2 → 0.7.1

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 (705) hide show
  1. package/artifact-manifest.json +147 -32
  2. package/cloudflare-router-ab/build/deriver-a/build-stamp.json +1 -0
  3. package/cloudflare-router-ab/build/deriver-a/index.js +2 -2
  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 -0
  6. package/cloudflare-router-ab/build/deriver-b/index.js +2 -2
  7. package/cloudflare-router-ab/build/deriver-b/index_bg.wasm +0 -0
  8. package/cloudflare-router-ab/build/local-tools/darwin-arm64/router_ab_local_init +0 -0
  9. package/cloudflare-router-ab/build/local-tools/darwin-x64/router_ab_local_init +0 -0
  10. package/cloudflare-router-ab/build/local-tools/linux-x64/router_ab_local_init +0 -0
  11. package/cloudflare-router-ab/build/router/build-stamp.json +1 -0
  12. package/cloudflare-router-ab/build/router/index.js +2 -2
  13. package/cloudflare-router-ab/build/router/index_bg.wasm +0 -0
  14. package/cloudflare-router-ab/build/signing-worker/build-stamp.json +1 -0
  15. package/cloudflare-router-ab/build/signing-worker/index.js +2 -2
  16. package/cloudflare-router-ab/build/signing-worker/index_bg.wasm +0 -0
  17. package/cloudflare-router-ab/build/tenant-root-control-plane/build-stamp.json +1 -0
  18. package/cloudflare-router-ab/build/tenant-root-control-plane/index.js +2 -2
  19. package/cloudflare-router-ab/build/tenant-root-control-plane/index_bg.wasm +0 -0
  20. package/cloudflare-router-ab/migrations/deriver-a/0012_tenant_root_creation_tombstones.sql +20 -0
  21. package/cloudflare-router-ab/migrations/deriver-a/0013_tenant_root_root_use_admissions.sql +32 -0
  22. package/cloudflare-router-ab/migrations/deriver-a/0014_tenant_root_refresh_supersessions.sql +24 -0
  23. package/cloudflare-router-ab/migrations/deriver-a/0015_tenant_root_root_use_attempts.sql +56 -0
  24. package/cloudflare-router-ab/migrations/deriver-a/0016_tenant_root_root_use_admission_settlement.sql +5 -0
  25. package/cloudflare-router-ab/migrations/deriver-a/0017_tenant_root_root_use_admission_claims.sql +64 -0
  26. package/cloudflare-router-ab/migrations/deriver-a/0018_tenant_root_recovery_retention_keys.sql +12 -0
  27. package/cloudflare-router-ab/migrations/deriver-b/0012_tenant_root_creation_tombstones.sql +20 -0
  28. package/cloudflare-router-ab/migrations/deriver-b/0013_tenant_root_root_use_admissions.sql +32 -0
  29. package/cloudflare-router-ab/migrations/deriver-b/0014_tenant_root_refresh_supersessions.sql +24 -0
  30. package/cloudflare-router-ab/migrations/deriver-b/0015_tenant_root_root_use_attempts.sql +56 -0
  31. package/cloudflare-router-ab/migrations/deriver-b/0016_tenant_root_root_use_admission_settlement.sql +5 -0
  32. package/cloudflare-router-ab/migrations/deriver-b/0017_tenant_root_root_use_admission_claims.sql +64 -0
  33. package/cloudflare-router-ab/migrations/deriver-b/0018_tenant_root_recovery_retention_keys.sql +12 -0
  34. package/cloudflare-router-ab/scripts/bootstrap-local-tenant-root.mjs +81 -16
  35. package/cloudflare-router-ab/scripts/prepare-local-runtime-config.mjs +102 -9
  36. package/cloudflare-router-ab/scripts/start-local-role-workers.mjs +4 -1
  37. package/cloudflare-router-ab/wrangler.deriver-a.toml +24 -0
  38. package/cloudflare-router-ab/wrangler.router.toml +13 -0
  39. package/dist/esm/authorization/capabilityPolicy.js +1 -1
  40. package/dist/esm/authorization/domain.js +2 -2
  41. package/dist/esm/authorization/factorEvidence.js +6 -100
  42. package/dist/esm/authorization/service.js +34 -2
  43. package/dist/esm/authorization/vaultProxyUse.js +3 -4
  44. package/dist/esm/cloud-host.js +16 -11
  45. package/dist/esm/core/EmailOtpRecords.js +19 -1
  46. package/dist/esm/core/EmailOtpStores.js +323 -924
  47. package/dist/esm/core/IdentityStore.js +44 -235
  48. package/dist/esm/core/NearPublicKeyStore.js +21 -63
  49. package/dist/esm/core/RegistrationCeremonyStore.js +3 -1793
  50. package/dist/esm/core/ThresholdService/config.js +1 -82
  51. package/dist/esm/core/ThresholdService/kv.js +3 -3
  52. package/dist/esm/core/ThresholdService/routerAb/ecdsaDerivationPoolFillHandlers.js +37 -5
  53. package/dist/esm/core/ThresholdService/routerAb/ecdsaDerivationPresignBridge.js +4 -74
  54. package/dist/esm/core/ThresholdService/stores/CloudflareDurableObjectStore.js +15 -51
  55. package/dist/esm/core/ThresholdService/stores/KeyStore.js +3 -3
  56. package/dist/esm/core/ThresholdService/stores/SessionStore.js +5 -81
  57. package/dist/esm/core/ThresholdService/stores/WalletSessionStore.js +185 -290
  58. package/dist/esm/core/ThresholdService/validation.js +18 -230
  59. package/dist/esm/core/WalletAuthMethodStore.js +22 -79
  60. package/dist/esm/core/WalletStore.js +58 -185
  61. package/dist/esm/core/WebAuthnAuthenticatorStore.js +57 -340
  62. package/dist/esm/core/WebAuthnCredentialBindingStore.js +90 -369
  63. package/dist/esm/core/WebAuthnLoginChallengeStore.js +17 -397
  64. package/dist/esm/core/WebAuthnSyncChallengeStore.js +17 -397
  65. package/dist/esm/core/authService/AuthService.js +2 -19
  66. package/dist/esm/core/authService/emailOtpChallengeProof.js +1 -1
  67. package/dist/esm/core/authService/emailOtpChallenges.js +1 -1
  68. package/dist/esm/core/authService/emailOtpConfig.js +1 -32
  69. package/dist/esm/core/authService/emailOtpRegistrationEnrollment.js +6 -153
  70. package/dist/esm/core/authService/googleEmailOtpRegistration.js +1 -1
  71. package/dist/esm/core/authService/nearPrivateKeySigning.js +7 -15
  72. package/dist/esm/core/authService/nearTransactions.js +2 -1
  73. package/dist/esm/core/authService/oidcVerification.js +3 -4
  74. package/dist/esm/core/authService/rateLimits.js +1 -31
  75. package/dist/esm/core/authService/registrationThresholdHelpers.js +2 -103
  76. package/dist/esm/core/authService/storeRegistry.js +2 -13
  77. package/dist/esm/core/authService/thresholdEcdsaKeyInventory.js +4 -5
  78. package/dist/esm/core/authService/webauthn.js +15 -50
  79. package/dist/esm/core/authService/webauthnOidcHelpers.js +1 -6
  80. package/dist/esm/core/authService/webauthnVerificationOutcomes.js +60 -0
  81. package/dist/esm/core/authService/webauthnWalletBinding.js +2 -122
  82. package/dist/esm/core/d1IdentityStore.js +32 -66
  83. package/dist/esm/core/d1TenantStore.js +82 -0
  84. package/dist/esm/core/d1WalletAuthMethodStore.js +92 -143
  85. package/dist/esm/core/d1WalletStore.js +14 -12
  86. package/dist/esm/core/deviceLinking/linkedDeviceEmailOtpGrant.js +10 -8
  87. package/dist/esm/core/deviceLinking/linkedDeviceManagement.js +25 -3
  88. package/dist/esm/core/deviceLinking/linkedDeviceSession.js +6 -895
  89. package/dist/esm/core/deviceLinking/linkedDeviceSessionApproval.js +102 -0
  90. package/dist/esm/core/deviceLinking/linkedDeviceSessionRecord.js +668 -0
  91. package/dist/esm/core/emailOtpD1Statements.js +383 -0
  92. package/dist/esm/core/hostedAccountIds.js +2 -2
  93. package/dist/esm/core/keyMaterialBrands.js +2 -48
  94. package/dist/esm/core/nearRelayerAccountProvisioning.js +25 -150
  95. package/dist/esm/core/nearSignerWasmRuntime.js +1 -4
  96. package/dist/esm/core/rpcClients/near/NearClient.js +15 -218
  97. package/dist/esm/core/signingLanes/LaneEnrollmentActivation.js +1 -1
  98. package/dist/esm/core/signingLanes/LaneLifecycleApplicationService.js +2 -4
  99. package/dist/esm/core/signingLanes/LaneLifecycleStore.js +0 -24
  100. package/dist/esm/core/signingLanes/WalletExecutionLaneProjection.js +5 -5
  101. package/dist/esm/core/signingLanes/ecdsaServerRetirement.js +3 -8
  102. package/dist/esm/core/signingLanes/ed25519ServerRetirement.js +1 -4
  103. package/dist/esm/core/storeBackends.js +208 -0
  104. package/dist/esm/core/thresholdEcdsaChainTarget.js +1 -7
  105. package/dist/esm/core/webAuthnD1Statements.js +92 -0
  106. package/dist/esm/core/webAuthnStoreBackends.js +198 -0
  107. package/dist/esm/hosted-wallet-gateway.js +33 -16
  108. package/dist/esm/index.js +2 -2
  109. package/dist/esm/local-hosted-wallet-gateway-worker.js +2 -23
  110. package/dist/esm/localHostedWalletGatewayHandler.js +299 -0
  111. package/dist/esm/localIntendedEcdsaFinalizeFault.js +85 -0
  112. package/dist/esm/localIntendedLinkExecuteFault.js +140 -0
  113. package/dist/esm/localIntendedRevokeFault.js +106 -0
  114. package/dist/esm/localIntendedSessionAdmissionFault.js +139 -0
  115. package/dist/esm/localIntendedYaoExportFault.js +117 -0
  116. package/dist/esm/localIntendedYaoFault.js +13 -16
  117. package/dist/esm/localIntendedYaoFinalizeFault.js +99 -0
  118. package/dist/esm/localIntendedYaoRecoveryFault.js +102 -0
  119. package/dist/esm/localIntendedYaoSigningFault.js +127 -0
  120. package/dist/esm/router/auth/authRequestValidation.js +1 -1
  121. package/dist/esm/router/auth/commonRouterUtils.js +10 -2
  122. package/dist/esm/router/auth/walletSessionFailure.js +1 -14
  123. package/dist/esm/router/cloudflare/d1/auth/d1AuthorizedOperationRouteService.js +23 -0
  124. package/dist/esm/router/cloudflare/d1/auth/d1RouterApiAuthService.js +86 -66
  125. package/dist/esm/router/cloudflare/d1/authorization/authorizedOperationStatements.js +208 -0
  126. package/dist/esm/router/cloudflare/d1/authorization/d1AuthorizationStore.js +246 -296
  127. package/dist/esm/router/cloudflare/d1/authorization/persistedWalletSessionAuthorization.js +14 -0
  128. package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceAuthorityInstallService.js +62 -63
  129. package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceEmailOtpGrantStore.js +3 -6
  130. package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceEmailOtpTargetFactor.js +1 -19
  131. package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceManagementService.js +4 -3
  132. package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceOwnerAuthorizationProvider.js +52 -9
  133. package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceRequestProofNonceStore.js +3 -6
  134. package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceRevocation.js +100 -0
  135. package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceSessionRecords.js +7 -10
  136. package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceSessionStore.js +33 -124
  137. package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceSourceContributionPreparationPlanner.js +2 -2
  138. package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceTargetCredentialProvider.js +9 -17
  139. package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceVerifiedLinkBuilder.js +6 -6
  140. package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceVerifiedLinkSourceReader.js +3 -1
  141. package/dist/esm/router/cloudflare/d1/deviceLinking/index.js +3 -3
  142. package/dist/esm/router/cloudflare/d1/deviceLinking/installedEcdsaAuthority.js +69 -0
  143. package/dist/esm/router/cloudflare/d1/ed25519Yao/d1Ed25519YaoCapabilityPersistence.js +39 -68
  144. package/dist/esm/router/cloudflare/d1/ed25519Yao/d1Ed25519YaoLifecycleDecisionStore.js +69 -0
  145. package/dist/esm/router/cloudflare/d1/ed25519Yao/d1Ed25519YaoProductRegistrationPartitionedStateStore.js +2 -2
  146. package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeStore.js +26 -71
  147. package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeVerifier.js +20 -3
  148. package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpEnrollmentStore.js +7 -94
  149. package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpGrantStore.js +5 -47
  150. package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpRecords.js +26 -123
  151. package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpRecoveryService.js +0 -2
  152. package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpRegistrationEnrollmentFinalizer.js +2 -2
  153. package/dist/esm/router/cloudflare/d1/emailOtp/d1GoogleEmailOtpRegistrationAttemptStore.js +15 -134
  154. package/dist/esm/router/cloudflare/d1/emailOtp/d1GoogleEmailOtpRegistrationRecords.js +54 -260
  155. package/dist/esm/router/cloudflare/d1/emailOtp/d1GoogleEmailOtpSessionResolver.js +1 -1
  156. package/dist/esm/router/cloudflare/d1/identity/d1IdentityRecords.js +1 -28
  157. package/dist/esm/router/cloudflare/d1/near/d1NearPublicKeyStore.js +2 -8
  158. package/dist/esm/router/cloudflare/d1/passkeyCustody/d1PasskeyCustodyEnvelopeStore.js +1 -1
  159. package/dist/esm/router/cloudflare/d1/passkeyCustody/d1PasskeyCustodyRouteService.js +3 -3
  160. package/dist/esm/router/cloudflare/d1/passkeyCustody/d1WalletCustodyCommitStore.js +23 -73
  161. package/dist/esm/router/cloudflare/d1/passkeyCustody/d1WalletRecoveryGoogleEmailOtpRecords.js +15 -2
  162. package/dist/esm/router/cloudflare/d1/passkeyCustody/d1WalletRecoveryGoogleEmailOtpService.js +12 -203
  163. package/dist/esm/router/cloudflare/d1/registration/d1RegistrationCeremonyRecordStore.js +16 -32
  164. package/dist/esm/router/cloudflare/d1/registration/d1RegistrationCeremonyRecords.js +29 -72
  165. package/dist/esm/router/cloudflare/d1/registration/d1RegistrationCeremonyStore.js +4 -1
  166. package/dist/esm/router/cloudflare/d1/registration/d1RegistrationIntentService.js +3 -1
  167. package/dist/esm/router/cloudflare/d1/registration/d1WalletRegistrationCommitStore.js +6 -30
  168. package/dist/esm/router/cloudflare/d1/registration/d1WalletRegistrationService.js +261 -205
  169. package/dist/esm/router/cloudflare/d1/registration/d1WalletRegistrationSetup.js +5 -3
  170. package/dist/esm/router/cloudflare/d1/registration/walletRegistrationEstablishedSessionIssuer.js +2 -2
  171. package/dist/esm/router/cloudflare/d1/registration/walletRegistrationSessionCommitReceipt.js +3 -3
  172. package/dist/esm/router/cloudflare/d1/signingAdmission/d1RouterAbNormalSigningAdmissionStore.js +43 -25
  173. package/dist/esm/router/cloudflare/d1/signingLanes/d1LaneEffectJournalStore.js +0 -1
  174. package/dist/esm/router/cloudflare/d1/signingLanes/d1LaneLifecycleStore.js +1 -1
  175. package/dist/esm/router/cloudflare/d1/signingLanes/d1LaneRecords.js +2 -1
  176. package/dist/esm/router/cloudflare/d1/versionedJson/d1VersionedJsonRecordStore.js +2 -60
  177. package/dist/esm/router/cloudflare/d1/wallet/d1WalletAddSignerService.js +158 -19
  178. package/dist/esm/router/cloudflare/d1/wallet/d1WalletAuthMethodBoundary.js +19 -49
  179. package/dist/esm/router/cloudflare/d1/wallet/d1WalletAuthMethodRevocationReplayStore.js +100 -0
  180. package/dist/esm/router/cloudflare/d1/wallet/d1WalletAuthMethodService.js +132 -33
  181. package/dist/esm/router/cloudflare/d1/wallet/d1WalletAuthorityStore.js +83 -4
  182. package/dist/esm/router/cloudflare/d1/webauthn/d1WebAuthnAuthService.js +14 -49
  183. package/dist/esm/router/cloudflare/d1/webauthn/d1WebAuthnRecords.js +4 -4
  184. package/dist/esm/router/cloudflare/d1/webauthn/d1WebAuthnStore.js +22 -116
  185. package/dist/esm/router/cloudflare/runtime/createSelfHostedCloudflareSigningWorker.js +1 -2
  186. package/dist/esm/router/cloudflare/runtime/walletConsoleTenantRootLineage.js +11 -2
  187. package/dist/esm/router/cloudflare/runtime/walletGateway.js +1 -1
  188. package/dist/esm/router/cloudflare/signingLanes/cloudflareLaneCurveExecution.js +5 -6
  189. package/dist/esm/router/cloudflare/signingLanes/cloudflareLaneProtocolCommitter.js +2 -1
  190. package/dist/esm/router/cloudflare/signingLanes/cloudflareOrdinaryInactiveSignerMaterialReservation.js +48 -21
  191. package/dist/esm/router/cloudflare.js +11480 -12853
  192. package/dist/esm/router/domains/ecdsa/routerAbEcdsaStrictRegistration.js +16 -5
  193. package/dist/esm/router/domains/ecdsa/thresholdEcdsaRequestValidation.js +2 -8
  194. package/dist/esm/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoLifecycleDecision.js +33 -0
  195. package/dist/esm/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistration.js +17 -9
  196. package/dist/esm/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistrationPartitionedStateStore.js +29 -431
  197. package/dist/esm/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistrationPartitioning.js +7 -2
  198. package/dist/esm/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistrationRequestScopedRunner.js +2 -1
  199. package/dist/esm/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistrationRequestScopedRuntime.js +70 -2
  200. package/dist/esm/router/domains/ed25519Yao/export/routerAbEd25519YaoExport.js +134 -169
  201. package/dist/esm/router/domains/ed25519Yao/export/routerAbEd25519YaoExportRequestScopedCloudflare.js +77 -162
  202. package/dist/esm/router/domains/ed25519Yao/recovery/routerAbEd25519YaoRecovery.js +205 -51
  203. package/dist/esm/router/domains/ed25519Yao/recovery/routerAbEd25519YaoRecoveryRequestScopedCloudflare.js +29 -11
  204. package/dist/esm/router/domains/ed25519Yao/registration/routerAbEd25519YaoHttpRegistrationBackend.js +182 -55
  205. package/dist/esm/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistration.js +2 -1
  206. package/dist/esm/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistrationExecutionRecord.js +63 -247
  207. package/dist/esm/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistrationIntentAuthorization.js +3 -2
  208. package/dist/esm/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistrationRequestScopedCloudflare.js +87 -132
  209. package/dist/esm/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistrationTwoPhaseRunner.js +5 -4
  210. package/dist/esm/router/domains/ed25519Yao/routerAbEd25519YaoGatewayEnvelope.js +45 -0
  211. package/dist/esm/router/domains/ed25519Yao/session/thresholdEd25519RequestValidation.js +1 -1
  212. package/dist/esm/router/domains/emailOtp/emailOtpExportPolicy.js +1 -42
  213. package/dist/esm/router/domains/emailOtp/emailOtpRequestValidation.js +1 -6
  214. package/dist/esm/router/domains/emailOtp/emailOtpSessionRouteHelpers.js +1 -142
  215. package/dist/esm/router/domains/passkeyCustody/passkeyCustodyEnvelopeRetrievalRoute.js +1 -1
  216. package/dist/esm/router/domains/passkeyCustody/walletCustodyRegistrationCommit.js +2 -2
  217. package/dist/esm/router/domains/passkeyCustody/walletRecoveryFinalization.js +23 -45
  218. package/dist/esm/router/domains/passkeyCustody/walletRecoveryKeyManifest.js +5 -5
  219. package/dist/esm/router/domains/signingOperations/ed25519AuthorizedOperationReceipt.js +1 -1
  220. package/dist/esm/router/domains/signingOperations/routerAbEcdsaDerivationNormalSigningRoute.js +827 -0
  221. package/dist/esm/router/domains/signingOperations/routerAbEd25519NormalSigningRoute.js +698 -0
  222. package/dist/esm/router/domains/signingOperations/routerAbNormalSigningAdmission.js +209 -0
  223. package/dist/esm/router/domains/signingOperations/routerAbNormalSigningAdmissionCore.js +16 -15
  224. package/dist/esm/router/domains/signingOperations/routerAbOperationStepUp.js +313 -0
  225. package/dist/esm/router/domains/signingOperations/routerAbPrivateSigningWorker.js +62 -2159
  226. package/dist/esm/router/domains/tenantRoot/tenantRootIdentityResolution.js +1 -1
  227. package/dist/esm/router/domains/walletRegistration/walletRegistrationRoutes.js +18 -22
  228. package/dist/esm/router/domains/walletRegistration/walletRegistrationSetupPayload.js +3 -4
  229. package/dist/esm/router/domains/walletUnlock/walletUnlockRequestedCapabilitiesValidation.js +2 -2
  230. package/dist/esm/router/domains/walletUnlock/walletUnlockRouteHandlers.js +97 -150
  231. package/dist/esm/router/express.js +5967 -6410
  232. package/dist/esm/router/framework/http.js +1 -4
  233. package/dist/esm/router/framework/ror/normalize.js +1 -1
  234. package/dist/esm/router/framework/routerApiRouteSurface.js +1 -1
  235. package/dist/esm/router/node/nodeHostedWalletGateway.js +64 -0
  236. package/dist/esm/router/node/nodeHostedWalletGatewayCheck.js +163 -0
  237. package/dist/esm/router/node/nodeHostedWalletGatewayMain.js +120 -0
  238. package/dist/esm/router/node/nodeHttp.js +79 -0
  239. package/dist/esm/router/node/nodeSqlite.js +43 -0
  240. package/dist/esm/router/node/signerSqlMigrations.js +48 -0
  241. package/dist/esm/router/transport/fetch/createFetchRouter.js +1 -1
  242. package/dist/esm/router/transport/fetch/routes/deviceLinking.js +16 -18
  243. package/dist/esm/router/transport/fetch/routes/deviceLinkingOwnerAuthorization.js +3 -5
  244. package/dist/esm/router/transport/fetch/routes/deviceManagement.js +15 -24
  245. package/dist/esm/router/transport/fetch/routes/normalSigningRouterProxy.js +3 -16
  246. package/dist/esm/router/transport/fetch/routes/passkeyCustody.js +144 -461
  247. package/dist/esm/router/transport/fetch/routes/sessions.js +4 -4
  248. package/dist/esm/router/transport/fetch/routes/syncAccount.js +4 -6
  249. package/dist/esm/router/transport/fetch/routes/syncAccountBootstrap.js +2 -2
  250. package/dist/esm/router/transport/fetch/routes/thresholdEcdsa.js +69 -23
  251. package/dist/esm/router/transport/fetch/routes/thresholdEd25519.js +52 -27
  252. package/dist/esm/shared-ts/src/authorization/capabilityKinds.js +1 -1
  253. package/dist/esm/shared-ts/src/authorization/delegatedAuthority.js +1 -1
  254. package/dist/esm/shared-ts/src/authorization/operationFingerprint.js +1 -2
  255. package/dist/esm/shared-ts/src/authorization/walletAuthority.js +99 -227
  256. package/dist/esm/shared-ts/src/authorization/walletCustodyOperation.js +4 -6
  257. package/dist/esm/shared-ts/src/device-linking/activeWalletSession.js +74 -0
  258. package/dist/esm/shared-ts/src/device-linking/authorityActivation.js +50 -0
  259. package/dist/esm/shared-ts/src/device-linking/committedSignerPackages.js +8 -9
  260. package/dist/esm/shared-ts/src/device-linking/delegatedActivationPlan.js +3 -1
  261. package/dist/esm/shared-ts/src/device-linking/deviceManagement.js +55 -0
  262. package/dist/esm/shared-ts/src/device-linking/digests.js +10 -65
  263. package/dist/esm/shared-ts/src/device-linking/ed25519ExportRoot.js +3 -1
  264. package/dist/esm/shared-ts/src/device-linking/index.js +4 -1
  265. package/dist/esm/shared-ts/src/device-linking/parsers.js +510 -1063
  266. package/dist/esm/shared-ts/src/device-linking/requestProof.js +5 -14
  267. package/dist/esm/shared-ts/src/device-linking/sourceContribution.js +6 -9
  268. package/dist/esm/shared-ts/src/device-linking/walletSessionCredentialDelivery.js +9 -9
  269. package/dist/esm/shared-ts/src/device-linking/wireFields.js +59 -0
  270. package/dist/esm/shared-ts/src/near/nearClient.js +252 -0
  271. package/dist/esm/shared-ts/src/passkey-custody/credentialActivity.js +3 -1
  272. package/dist/esm/shared-ts/src/passkey-custody/custodyEnvelope.js +7 -5
  273. package/dist/esm/shared-ts/src/passkey-custody/custodySecretBinding.js +6 -4
  274. package/dist/esm/shared-ts/src/passkey-custody/primitives.js +5 -39
  275. package/dist/esm/shared-ts/src/signing-lanes/evmFamilySigningKeySlotId.js +1 -5
  276. package/dist/esm/shared-ts/src/signing-lanes/index.js +3 -3
  277. package/dist/esm/shared-ts/src/signing-lanes/ownerContinuity.js +5 -12
  278. package/dist/esm/shared-ts/src/signing-lanes/participantDigest.js +5 -14
  279. package/dist/esm/shared-ts/src/signing-lanes/participants.js +2 -5
  280. package/dist/esm/shared-ts/src/signing-lanes/recordParsers.js +7 -5
  281. package/dist/esm/shared-ts/src/signing-lanes/rotationDigests.js +6 -45
  282. package/dist/esm/shared-ts/src/signing-lanes/rotationParsers.js +423 -1511
  283. package/dist/esm/shared-ts/src/signing-lanes/rotationProtocolParsers.js +323 -0
  284. package/dist/esm/shared-ts/src/signing-lanes/rotationWireFields.js +59 -0
  285. package/dist/esm/shared-ts/src/tenant-root/tenantRootOperationRecord.js +1 -1
  286. package/dist/esm/shared-ts/src/threshold/ecdsaDerivationRoleLocalBootstrap.js +1 -2
  287. package/dist/esm/shared-ts/src/threshold/keyMaterialBrands.js +49 -0
  288. package/dist/esm/shared-ts/src/utils/addAuthMethodRegistration.js +3 -4
  289. package/dist/esm/shared-ts/src/utils/canonicalPrimitives.js +8 -1
  290. package/dist/esm/shared-ts/src/utils/digestEncoding.js +63 -0
  291. package/dist/esm/shared-ts/src/utils/emailOtpDomain.js +2 -2
  292. package/dist/esm/shared-ts/src/utils/exactRecord.js +44 -0
  293. package/dist/esm/shared-ts/src/utils/registrationAuthMethodInput.js +127 -0
  294. package/dist/esm/shared-ts/src/utils/registrationEstablishedSession.js +2 -2
  295. package/dist/esm/shared-ts/src/utils/registrationIds.js +280 -0
  296. package/dist/esm/shared-ts/src/utils/registrationIntent.js +4 -1170
  297. package/dist/esm/shared-ts/src/utils/registrationSignerPlan.js +429 -0
  298. package/dist/esm/shared-ts/src/utils/routerAbEcdsaDerivation.js +11 -136
  299. package/dist/esm/shared-ts/src/utils/routerAbEd25519Yao.js +3 -163
  300. package/dist/esm/shared-ts/src/utils/routerAbEd25519YaoDigests.js +160 -0
  301. package/dist/esm/shared-ts/src/utils/routerAbNormalSigningIdentity.js +1 -4
  302. package/dist/esm/shared-ts/src/utils/routerAbPublicKeyset.js +7 -15
  303. package/dist/esm/shared-ts/src/utils/validation.js +37 -6
  304. package/dist/esm/shared-ts/src/utils/walletAuthMethodRecord.js +362 -0
  305. package/dist/esm/shared-ts/src/utils/wireSchema.js +77 -0
  306. package/dist/esm/shared-ts/src/wallet-recovery/recoveryCodeLocator.js +1 -1
  307. package/dist/esm/shared-ts/src/wallet-recovery/recoveryCodeReservation.js +1 -1
  308. package/dist/esm/shared-ts/src/wallet-recovery/walletRecoveryCommittedProjection.js +7 -11
  309. package/dist/esm/shared-ts/src/wallet-recovery/walletRecoveryEcdsaPossession.js +4 -8
  310. package/dist/esm/shared-ts/src/wallet-recovery/walletRecoveryEnvelopeSet.js +3 -1
  311. package/dist/esm/storage/d1Sql.js +10 -1
  312. package/dist/esm/storage/syncSqlite.js +79 -0
  313. package/dist/esm/threshold/session/signingSessionSeal/crypto/cipher.js +1 -1
  314. package/dist/esm/threshold/session/signingSessionSeal/crypto/shamir3PassWasm.js +1 -1
  315. package/dist/esm/threshold/session/signingSessionSeal/idempotencyRecords.js +1 -2
  316. package/dist/esm/threshold/session/signingSessionSeal/options.js +1 -1
  317. package/dist/esm/threshold/session/signingSessionSeal/transport/shared.js +18 -55
  318. package/dist/esm/threshold/statusCodes.js +1 -1
  319. package/dist/esm/wasm/near_signer/pkg/wasm_signer_worker.js +3 -3
  320. package/dist/esm/wasm/near_signer/pkg/wasm_signer_worker_bg.wasm +0 -0
  321. package/dist/esm/wasm/router_ab_ecdsa_signing_worker/pkg/router_ab_ecdsa_signing_worker_bg.wasm +0 -0
  322. package/dist/types/shared-ts/src/authorization/capabilityKinds.d.ts +8 -26
  323. package/dist/types/shared-ts/src/authorization/delegatedAuthority.d.ts +0 -8
  324. package/dist/types/shared-ts/src/authorization/operationFingerprint.d.ts +1 -3
  325. package/dist/types/shared-ts/src/authorization/walletAuthority.d.ts +25 -12
  326. package/dist/types/shared-ts/src/authorization/walletSessionIssuance.d.ts +2 -1
  327. package/dist/types/shared-ts/src/device-linking/activeWalletSession.d.ts +3 -2
  328. package/dist/types/shared-ts/src/device-linking/authorityActivation.d.ts +5 -0
  329. package/dist/types/shared-ts/src/device-linking/committedSignerPackages.d.ts +2 -5
  330. package/dist/types/shared-ts/src/device-linking/contracts.d.ts +8 -11
  331. package/dist/types/shared-ts/src/device-linking/contracts.typecheck.d.ts +2 -1
  332. package/dist/types/shared-ts/src/device-linking/deviceManagement.d.ts +7 -0
  333. package/dist/types/shared-ts/src/device-linking/digests.d.ts +0 -5
  334. package/dist/types/shared-ts/src/device-linking/ed25519ExportRoot.d.ts +3 -2
  335. package/dist/types/shared-ts/src/device-linking/index.d.ts +2 -0
  336. package/dist/types/shared-ts/src/device-linking/parsers.d.ts +4 -41
  337. package/dist/types/shared-ts/src/device-linking/requestProof.d.ts +0 -1
  338. package/dist/types/shared-ts/src/device-linking/sourceContribution.d.ts +3 -2
  339. package/dist/types/shared-ts/src/device-linking/walletSessionCredentialDelivery.d.ts +2 -1
  340. package/dist/types/shared-ts/src/device-linking/wireFields.d.ts +26 -0
  341. package/dist/types/shared-ts/src/near/actions.d.ts +4 -4
  342. package/dist/types/shared-ts/src/near/delegate.d.ts +3 -2
  343. package/dist/types/shared-ts/src/near/nearClient.d.ts +145 -0
  344. package/dist/types/shared-ts/src/passkey-custody/ceremonyCommitPayload.d.ts +0 -22
  345. package/dist/types/shared-ts/src/passkey-custody/credentialActivity.d.ts +2 -4
  346. package/dist/types/shared-ts/src/passkey-custody/custodyEnvelope.d.ts +9 -18
  347. package/dist/types/shared-ts/src/passkey-custody/custodySecretBinding.d.ts +8 -24
  348. package/dist/types/shared-ts/src/passkey-custody/index.d.ts +0 -2
  349. package/dist/types/shared-ts/src/passkey-custody/primitives.d.ts +0 -14
  350. package/dist/types/shared-ts/src/signing-lanes/evmFamilySigningKeySlotId.d.ts +0 -15
  351. package/dist/types/shared-ts/src/signing-lanes/execution.d.ts +2 -51
  352. package/dist/types/shared-ts/src/signing-lanes/index.d.ts +1 -2
  353. package/dist/types/shared-ts/src/signing-lanes/ownerContinuity.d.ts +1 -2
  354. package/dist/types/shared-ts/src/signing-lanes/participantDigest.d.ts +5 -27
  355. package/dist/types/shared-ts/src/signing-lanes/participants.d.ts +0 -11
  356. package/dist/types/shared-ts/src/signing-lanes/recordParsers.d.ts +6 -53
  357. package/dist/types/shared-ts/src/signing-lanes/records.d.ts +1 -2
  358. package/dist/types/shared-ts/src/signing-lanes/rotation.d.ts +15 -37
  359. package/dist/types/shared-ts/src/signing-lanes/rotationDigests.d.ts +1 -20
  360. package/dist/types/shared-ts/src/signing-lanes/rotationLifecycle.d.ts +4 -25
  361. package/dist/types/shared-ts/src/signing-lanes/rotationParsers.d.ts +1 -41
  362. package/dist/types/shared-ts/src/signing-lanes/rotationProtocolParsers.d.ts +6 -0
  363. package/dist/types/shared-ts/src/signing-lanes/rotationWireFields.d.ts +20 -0
  364. package/dist/types/shared-ts/src/threshold/ecdsaDerivationRoleLocalBootstrap.d.ts +2 -35
  365. package/dist/types/shared-ts/src/threshold/ed25519OperationFingerprint.d.ts +8 -35
  366. package/dist/types/shared-ts/src/threshold/keyMaterialBrands.d.ts +25 -0
  367. package/dist/types/shared-ts/src/threshold/participants.d.ts +3 -9
  368. package/dist/types/shared-ts/src/threshold/secp256k1.d.ts +0 -37
  369. package/dist/types/shared-ts/src/threshold/sessionPolicy.d.ts +24 -0
  370. package/dist/types/shared-ts/src/threshold/signingRootScope.d.ts +2 -5
  371. package/dist/types/shared-ts/src/utils/addAuthMethodRegistration.d.ts +3 -4
  372. package/dist/types/shared-ts/src/utils/addWalletAuthMethod.d.ts +7 -108
  373. package/dist/types/shared-ts/src/utils/addWalletAuthMethod.typecheck.d.ts +16 -3
  374. package/dist/types/shared-ts/src/utils/canonicalPrimitives.d.ts +2 -0
  375. package/dist/types/shared-ts/src/utils/digestEncoding.d.ts +9 -0
  376. package/dist/types/shared-ts/src/utils/domainIds.d.ts +1 -2
  377. package/dist/types/shared-ts/src/utils/ecdsaKeyFactsInventory.d.ts +1 -2
  378. package/dist/types/shared-ts/src/utils/emailOtpDomain.d.ts +5 -5
  379. package/dist/types/shared-ts/src/utils/emailOtpRecoveryKey.d.ts +0 -2
  380. package/dist/types/shared-ts/src/utils/errors.d.ts +0 -7
  381. package/dist/types/shared-ts/src/utils/exactRecord.d.ts +12 -0
  382. package/dist/types/shared-ts/src/utils/index.d.ts +5 -2
  383. package/dist/types/shared-ts/src/utils/jsonRpc.d.ts +3 -2
  384. package/dist/types/shared-ts/src/utils/near.d.ts +2 -1
  385. package/dist/types/shared-ts/src/utils/nearRpcResults.d.ts +7 -7
  386. package/dist/types/shared-ts/src/utils/normalize.d.ts +0 -4
  387. package/dist/types/shared-ts/src/utils/registrationAuthMethodInput.d.ts +184 -0
  388. package/dist/types/shared-ts/src/utils/registrationContracts.d.ts +76 -0
  389. package/dist/types/shared-ts/src/utils/registrationEstablishedSession.d.ts +1 -2
  390. package/dist/types/shared-ts/src/utils/registrationIds.d.ts +56 -0
  391. package/dist/types/shared-ts/src/utils/registrationIntent.d.ts +9 -514
  392. package/dist/types/shared-ts/src/utils/registrationSignerPlan.d.ts +142 -0
  393. package/dist/types/shared-ts/src/utils/routerAbEcdsaDerivation.d.ts +21 -92
  394. package/dist/types/shared-ts/src/utils/routerAbEd25519Yao.d.ts +14 -99
  395. package/dist/types/shared-ts/src/utils/routerAbEd25519YaoDigests.d.ts +39 -0
  396. package/dist/types/shared-ts/src/utils/routerAbPublicKeyset.d.ts +10 -15
  397. package/dist/types/shared-ts/src/utils/routerAbTraceContext.d.ts +2 -1
  398. package/dist/types/shared-ts/src/utils/secureRandomId.d.ts +0 -2
  399. package/dist/types/shared-ts/src/utils/signerDomain.d.ts +3 -35
  400. package/dist/types/shared-ts/src/utils/signerSlot.d.ts +0 -4
  401. package/dist/types/shared-ts/src/utils/signingSessionSeal.d.ts +1 -7
  402. package/dist/types/shared-ts/src/utils/validation.d.ts +10 -10
  403. package/dist/types/shared-ts/src/utils/variant.d.ts +11 -0
  404. package/dist/types/shared-ts/src/utils/variant.typecheck.d.ts +22 -0
  405. package/dist/types/shared-ts/src/utils/walletAddSignerActivation.d.ts +2 -2
  406. package/dist/types/shared-ts/src/utils/walletAuthAuthority.d.ts +1 -58
  407. package/dist/types/shared-ts/src/utils/walletAuthMethodRecord.d.ts +104 -0
  408. package/dist/types/shared-ts/src/utils/walletCapabilityBindings.d.ts +3 -7
  409. package/dist/types/shared-ts/src/utils/webauthnDeviceInfo.d.ts +3 -4
  410. package/dist/types/shared-ts/src/utils/wireSchema.d.ts +60 -0
  411. package/dist/types/shared-ts/src/wallet-recovery/backupAcknowledgement.d.ts +2 -1
  412. package/dist/types/shared-ts/src/wallet-recovery/index.d.ts +0 -1
  413. package/dist/types/shared-ts/src/wallet-recovery/recoveryCodeLocator.d.ts +0 -16
  414. package/dist/types/shared-ts/src/wallet-recovery/recoveryCodeReservation.d.ts +2 -11
  415. package/dist/types/shared-ts/src/wallet-recovery/walletRecoveryCommittedProjection.d.ts +6 -18
  416. package/dist/types/shared-ts/src/wallet-recovery/walletRecoveryEcdsaPossession.d.ts +0 -2
  417. package/dist/types/shared-ts/src/wallet-recovery/walletRecoveryEnvelopeSet.d.ts +1 -3
  418. package/dist/types/wallet-server/src/authorization/capabilityPolicy.d.ts +0 -1
  419. package/dist/types/wallet-server/src/authorization/domain.d.ts +25 -5
  420. package/dist/types/wallet-server/src/authorization/ecdsaWalletSessionAdmission.d.ts +37 -0
  421. package/dist/types/wallet-server/src/authorization/ecdsaWalletSessionAdmission.typecheck.d.ts +2 -0
  422. package/dist/types/wallet-server/src/authorization/factorEvidence.d.ts +6 -7
  423. package/dist/types/wallet-server/src/authorization/service.d.ts +52 -3
  424. package/dist/types/wallet-server/src/cloud-host.d.ts +6 -2
  425. package/dist/types/wallet-server/src/core/EmailOtpRecords.d.ts +10 -1
  426. package/dist/types/wallet-server/src/core/EmailOtpStores.d.ts +16 -116
  427. package/dist/types/wallet-server/src/core/IdentityStore.d.ts +2 -7
  428. package/dist/types/wallet-server/src/core/NearPublicKeyStore.d.ts +6 -16
  429. package/dist/types/wallet-server/src/core/RegistrationCeremonyStore.d.ts +29 -90
  430. package/dist/types/wallet-server/src/core/ThresholdService/config.d.ts +0 -12
  431. package/dist/types/wallet-server/src/core/ThresholdService/routerAb/ecdsaDerivationPoolFillHandlers.d.ts +10 -3
  432. package/dist/types/wallet-server/src/core/ThresholdService/routerAb/ecdsaDerivationPresignBridge.d.ts +17 -48
  433. package/dist/types/wallet-server/src/core/ThresholdService/routerAb/internalServiceHttp.d.ts +2 -1
  434. package/dist/types/wallet-server/src/core/ThresholdService/stores/CloudflareDurableObjectStore.d.ts +4 -71
  435. package/dist/types/wallet-server/src/core/ThresholdService/stores/KeyStore.d.ts +2 -1
  436. package/dist/types/wallet-server/src/core/ThresholdService/stores/SessionStore.d.ts +4 -8
  437. package/dist/types/wallet-server/src/core/ThresholdService/stores/StoreConfig.d.ts +2 -1
  438. package/dist/types/wallet-server/src/core/ThresholdService/stores/WalletSessionStore.d.ts +1 -3
  439. package/dist/types/wallet-server/src/core/ThresholdService/validation.d.ts +14 -47
  440. package/dist/types/wallet-server/src/core/WalletAuthMethodStore.d.ts +2 -7
  441. package/dist/types/wallet-server/src/core/WalletStore.d.ts +3 -8
  442. package/dist/types/wallet-server/src/core/WebAuthnAuthenticatorStore.d.ts +7 -22
  443. package/dist/types/wallet-server/src/core/WebAuthnCredentialBindingStore.d.ts +14 -36
  444. package/dist/types/wallet-server/src/core/WebAuthnLoginChallengeStore.d.ts +9 -34
  445. package/dist/types/wallet-server/src/core/WebAuthnSyncChallengeStore.d.ts +9 -34
  446. package/dist/types/wallet-server/src/core/authService/AuthService.d.ts +0 -3
  447. package/dist/types/wallet-server/src/core/authService/emailOtpChallengeOperations.d.ts +6 -5
  448. package/dist/types/wallet-server/src/core/authService/emailOtpChallengeProof.d.ts +9 -17
  449. package/dist/types/wallet-server/src/core/authService/emailOtpChallengeVerification.d.ts +3 -2
  450. package/dist/types/wallet-server/src/core/authService/emailOtpChallenges.d.ts +7 -23
  451. package/dist/types/wallet-server/src/core/authService/emailOtpConfig.d.ts +3 -10
  452. package/dist/types/wallet-server/src/core/authService/emailOtpDelivery.d.ts +4 -3
  453. package/dist/types/wallet-server/src/core/authService/emailOtpGrant.d.ts +4 -3
  454. package/dist/types/wallet-server/src/core/authService/emailOtpRegistrationEnrollment.d.ts +3 -70
  455. package/dist/types/wallet-server/src/core/authService/emailOtpSeal.d.ts +3 -2
  456. package/dist/types/wallet-server/src/core/authService/emailOtpUnlock.d.ts +4 -3
  457. package/dist/types/wallet-server/src/core/authService/googleEmailOtpRegistration.d.ts +5 -8
  458. package/dist/types/wallet-server/src/core/authService/nearPrivateKeySigning.d.ts +3 -2
  459. package/dist/types/wallet-server/src/core/authService/nearPublicKeyMetadata.d.ts +2 -1
  460. package/dist/types/wallet-server/src/core/authService/nearTransactions.d.ts +2 -1
  461. package/dist/types/wallet-server/src/core/authService/oidcVerification.d.ts +4 -3
  462. package/dist/types/wallet-server/src/core/authService/rateLimits.d.ts +0 -3
  463. package/dist/types/wallet-server/src/core/authService/registrationThresholdHelpers.d.ts +0 -26
  464. package/dist/types/wallet-server/src/core/authService/storeRegistry.d.ts +0 -5
  465. package/dist/types/wallet-server/src/core/authService/thresholdEcdsaKeyInventory.d.ts +0 -23
  466. package/dist/types/wallet-server/src/core/authService/webauthn.d.ts +8 -16
  467. package/dist/types/wallet-server/src/core/authService/webauthnOidcHelpers.d.ts +7 -7
  468. package/dist/types/wallet-server/src/core/authService/webauthnVerificationOutcomes.d.ts +43 -0
  469. package/dist/types/wallet-server/src/core/authService/webauthnWalletBinding.d.ts +1 -28
  470. package/dist/types/wallet-server/src/core/d1IdentityStore.d.ts +6 -16
  471. package/dist/types/wallet-server/src/core/d1TenantStore.d.ts +51 -0
  472. package/dist/types/wallet-server/src/core/d1WalletAuthMethodStore.d.ts +11 -29
  473. package/dist/types/wallet-server/src/core/d1WalletStore.d.ts +6 -1
  474. package/dist/types/wallet-server/src/core/deviceLinking/linkedDeviceEd25519ExportRoot.d.ts +2 -1
  475. package/dist/types/wallet-server/src/core/deviceLinking/linkedDeviceEmailOtpGrant.d.ts +2 -1
  476. package/dist/types/wallet-server/src/core/deviceLinking/linkedDeviceManagement.d.ts +44 -26
  477. package/dist/types/wallet-server/src/core/deviceLinking/linkedDeviceSession.d.ts +19 -217
  478. package/dist/types/wallet-server/src/core/deviceLinking/linkedDeviceSessionApproval.d.ts +8 -0
  479. package/dist/types/wallet-server/src/core/deviceLinking/linkedDeviceSessionRecord.d.ts +259 -0
  480. package/dist/types/wallet-server/src/core/deviceLinking/requestProof.d.ts +2 -2
  481. package/dist/types/wallet-server/src/core/emailOtpD1Statements.d.ts +54 -0
  482. package/dist/types/wallet-server/src/core/hostedAccountIds.d.ts +0 -15
  483. package/dist/types/wallet-server/src/core/keyMaterialBrands.d.ts +4 -24
  484. package/dist/types/wallet-server/src/core/nearRelayerAccountProvisioning.d.ts +2 -3
  485. package/dist/types/wallet-server/src/core/nearSignerWasmRuntime.d.ts +0 -1
  486. package/dist/types/wallet-server/src/core/registrationContracts.d.ts +37 -108
  487. package/dist/types/wallet-server/src/core/routerAbSigning/RouterAbNormalSigningRuntime.d.ts +5 -4
  488. package/dist/types/wallet-server/src/core/rpcClients/near/NearClient.d.ts +10 -106
  489. package/dist/types/wallet-server/src/core/signingLanes/LaneAggregateRevocationApplicationService.d.ts +4 -3
  490. package/dist/types/wallet-server/src/core/signingLanes/LaneEffectJournalStore.d.ts +2 -3
  491. package/dist/types/wallet-server/src/core/signingLanes/LaneLifecycleStore.d.ts +2 -3
  492. package/dist/types/wallet-server/src/core/signingLanes/WalletExecutionLaneProjection.d.ts +3 -9
  493. package/dist/types/wallet-server/src/core/signingLanes/ecdsaServerRetirement.d.ts +4 -4
  494. package/dist/types/wallet-server/src/core/signingLanes/ed25519ServerRetirement.d.ts +3 -3
  495. package/dist/types/wallet-server/src/core/storeBackends.d.ts +83 -0
  496. package/dist/types/wallet-server/src/core/threeRouteRegistrationContracts.d.ts +13 -59
  497. package/dist/types/wallet-server/src/core/threeRouteRegistrationContracts.typecheck.d.ts +51 -3
  498. package/dist/types/wallet-server/src/core/thresholdEcdsaChainTarget.d.ts +0 -1
  499. package/dist/types/wallet-server/src/core/types.d.ts +3 -24
  500. package/dist/types/wallet-server/src/core/webAuthnD1Statements.d.ts +29 -0
  501. package/dist/types/wallet-server/src/core/webAuthnStoreBackends.d.ts +96 -0
  502. package/dist/types/wallet-server/src/hosted-wallet-gateway.d.ts +11 -7
  503. package/dist/types/wallet-server/src/index.d.ts +1 -1
  504. package/dist/types/wallet-server/src/local-hosted-wallet-gateway-worker.d.ts +1 -4
  505. package/dist/types/wallet-server/src/localHostedWalletGatewayHandler.d.ts +12 -0
  506. package/dist/types/wallet-server/src/localIntendedEcdsaFinalizeFault.d.ts +33 -0
  507. package/dist/types/wallet-server/src/localIntendedLinkExecuteFault.d.ts +47 -0
  508. package/dist/types/wallet-server/src/localIntendedRevokeFault.d.ts +40 -0
  509. package/dist/types/wallet-server/src/localIntendedSessionAdmissionFault.d.ts +41 -0
  510. package/dist/types/wallet-server/src/localIntendedYaoExportFault.d.ts +41 -0
  511. package/dist/types/wallet-server/src/localIntendedYaoFault.d.ts +7 -1
  512. package/dist/types/wallet-server/src/localIntendedYaoFinalizeFault.d.ts +37 -0
  513. package/dist/types/wallet-server/src/localIntendedYaoRecoveryFault.d.ts +45 -0
  514. package/dist/types/wallet-server/src/localIntendedYaoSigningFault.d.ts +51 -0
  515. package/dist/types/wallet-server/src/router/auth/authRequestValidation.d.ts +10 -21
  516. package/dist/types/wallet-server/src/router/auth/commonRouterUtils.d.ts +5 -10
  517. package/dist/types/wallet-server/src/router/auth/walletSessionFailure.d.ts +1 -4
  518. package/dist/types/wallet-server/src/router/auth/webAuthnCredentialCodecs.d.ts +3 -2
  519. package/dist/types/wallet-server/src/router/cloudflare/d1/auth/d1AuthorizedOperationRouteService.d.ts +12 -0
  520. package/dist/types/wallet-server/src/router/cloudflare/d1/auth/d1RouterApiAuthBoundary.d.ts +3 -2
  521. package/dist/types/wallet-server/src/router/cloudflare/d1/auth/d1RouterApiAuthConfig.d.ts +2 -2
  522. package/dist/types/wallet-server/src/router/cloudflare/d1/auth/d1RouterApiAuthService.d.ts +1 -1
  523. package/dist/types/wallet-server/src/router/cloudflare/d1/authorization/authorizedOperationStatements.d.ts +30 -0
  524. package/dist/types/wallet-server/src/router/cloudflare/d1/authorization/d1AuthorizationStore.d.ts +45 -21
  525. package/dist/types/wallet-server/src/router/cloudflare/d1/authorization/persistedWalletSessionAuthorization.d.ts +3 -0
  526. package/dist/types/wallet-server/src/router/cloudflare/d1/authorization/walletSessionAuthorityProjection.d.ts +2 -1
  527. package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceAuthorityInstallService.d.ts +57 -6
  528. package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceEmailOtpGrantStore.d.ts +2 -3
  529. package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceEmailOtpTargetFactor.d.ts +8 -21
  530. package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceOwnerAuthorizationProvider.d.ts +14 -1
  531. package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceRevocation.d.ts +49 -0
  532. package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceSessionRecords.d.ts +1 -1
  533. package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceSessionStore.d.ts +4 -2
  534. package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceSourceContributionPreparationPlanner.d.ts +1 -1
  535. package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceTargetCredentialProvider.d.ts +2 -2
  536. package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceTargetPlanner.d.ts +8 -4
  537. package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceVerifiedLinkBuilder.d.ts +3 -5
  538. package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/installedEcdsaAuthority.d.ts +7 -0
  539. package/dist/types/wallet-server/src/router/cloudflare/d1/ed25519Yao/d1Ed25519YaoCapabilityPersistence.d.ts +1 -2
  540. package/dist/types/wallet-server/src/router/cloudflare/d1/ed25519Yao/d1Ed25519YaoLifecycleDecisionStore.d.ts +33 -0
  541. package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeIssuer.d.ts +1 -1
  542. package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeStore.d.ts +13 -3
  543. package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeVerifier.d.ts +24 -5
  544. package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpEnrollmentStore.d.ts +2 -3
  545. package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpGrantStore.d.ts +1 -3
  546. package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpRateLimitStore.d.ts +3 -4
  547. package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpRecords.d.ts +9 -8
  548. package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpRecoveryService.d.ts +0 -2
  549. package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpRegistrationEnrollmentFinalizer.d.ts +5 -4
  550. package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1GoogleEmailOtpRegistrationAttemptStore.d.ts +1 -3
  551. package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1GoogleEmailOtpRegistrationRecords.d.ts +3 -21
  552. package/dist/types/wallet-server/src/router/cloudflare/d1/identity/d1IdentityRecords.d.ts +0 -23
  553. package/dist/types/wallet-server/src/router/cloudflare/d1/near/d1NearPublicKeyStore.d.ts +1 -2
  554. package/dist/types/wallet-server/src/router/cloudflare/d1/passkeyCustody/d1PasskeyCustodyEnvelopeStore.d.ts +11 -19
  555. package/dist/types/wallet-server/src/router/cloudflare/d1/passkeyCustody/d1PasskeyCustodyRouteService.d.ts +5 -54
  556. package/dist/types/wallet-server/src/router/cloudflare/d1/passkeyCustody/d1WalletCustodyCommitStore.d.ts +7 -19
  557. package/dist/types/wallet-server/src/router/cloudflare/d1/passkeyCustody/d1WalletRecoveryGoogleEmailOtpRecords.d.ts +4 -3
  558. package/dist/types/wallet-server/src/router/cloudflare/d1/passkeyCustody/d1WalletRecoveryGoogleEmailOtpService.d.ts +8 -12
  559. package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1RegistrationCeremonyRecordStore.d.ts +5 -8
  560. package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1RegistrationCeremonyRecords.d.ts +10 -22
  561. package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1RegistrationCeremonyStore.d.ts +6 -2
  562. package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1WalletRegistrationCommitStore.d.ts +10 -6
  563. package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1WalletRegistrationService.d.ts +15 -22
  564. package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1WalletRegistrationSetup.d.ts +5 -3
  565. package/dist/types/wallet-server/src/router/cloudflare/d1/registration/walletRegistrationEstablishedSessionIssuer.d.ts +4 -3
  566. package/dist/types/wallet-server/src/router/cloudflare/d1/registration/walletRegistrationSessionCommitReceipt.d.ts +5 -5
  567. package/dist/types/wallet-server/src/router/cloudflare/d1/signingAdmission/d1RouterAbNormalSigningAdmissionStore.d.ts +3 -5
  568. package/dist/types/wallet-server/src/router/cloudflare/d1/signingLanes/d1LaneEffectJournalStore.d.ts +0 -1
  569. package/dist/types/wallet-server/src/router/cloudflare/d1/versionedJson/d1VersionedJsonRecordStore.d.ts +0 -16
  570. package/dist/types/wallet-server/src/router/cloudflare/d1/wallet/d1WalletAddSignerService.d.ts +29 -14
  571. package/dist/types/wallet-server/src/router/cloudflare/d1/wallet/d1WalletAuthMethodBoundary.d.ts +15 -12
  572. package/dist/types/wallet-server/src/router/cloudflare/d1/wallet/d1WalletAuthMethodRevocationReplayStore.d.ts +71 -0
  573. package/dist/types/wallet-server/src/router/cloudflare/d1/wallet/d1WalletAuthMethodService.d.ts +34 -24
  574. package/dist/types/wallet-server/src/router/cloudflare/d1/wallet/d1WalletAuthorityStore.d.ts +44 -26
  575. package/dist/types/wallet-server/src/router/cloudflare/d1/webauthn/d1WebAuthnRecords.d.ts +3 -7
  576. package/dist/types/wallet-server/src/router/cloudflare/d1/webauthn/d1WebAuthnStore.d.ts +8 -19
  577. package/dist/types/wallet-server/src/router/cloudflare/runtime/walletConsoleTenantRootLineage.d.ts +2 -1
  578. package/dist/types/wallet-server/src/router/cloudflare/runtime/walletGateway.d.ts +1 -0
  579. package/dist/types/wallet-server/src/router/cloudflare/signingLanes/cloudflareOrdinaryInactiveSignerMaterialReservation.d.ts +15 -2
  580. package/dist/types/wallet-server/src/router/cloudflare-adaptor.d.ts +2 -2
  581. package/dist/types/wallet-server/src/router/domains/ecdsa/routerAbEcdsaStrictRegistration.d.ts +9 -7
  582. package/dist/types/wallet-server/src/router/domains/ecdsa/thresholdEcdsaRequestValidation.d.ts +4 -4
  583. package/dist/types/wallet-server/src/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoLifecycleDecision.d.ts +46 -0
  584. package/dist/types/wallet-server/src/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistration.d.ts +5 -3
  585. package/dist/types/wallet-server/src/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistrationPartitionedStateStore.d.ts +20 -79
  586. package/dist/types/wallet-server/src/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistrationPartitioning.d.ts +2 -0
  587. package/dist/types/wallet-server/src/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistrationRequestScopedRunner.d.ts +1 -1
  588. package/dist/types/wallet-server/src/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistrationRequestScopedRuntime.d.ts +4 -3
  589. package/dist/types/wallet-server/src/router/domains/ed25519Yao/export/routerAbEd25519YaoExport.d.ts +62 -42
  590. package/dist/types/wallet-server/src/router/domains/ed25519Yao/recovery/routerAbEd25519YaoRecovery.d.ts +108 -32
  591. package/dist/types/wallet-server/src/router/domains/ed25519Yao/recovery/routerAbEd25519YaoRecoveryActivation.typecheck.d.ts +5 -0
  592. package/dist/types/wallet-server/src/router/domains/ed25519Yao/registration/routerAbEd25519YaoHttpRegistrationBackend.d.ts +36 -5
  593. package/dist/types/wallet-server/src/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistration.d.ts +5 -4
  594. package/dist/types/wallet-server/src/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistrationExecutionRecord.d.ts +41 -50
  595. package/dist/types/wallet-server/src/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistrationIntentAuthorization.d.ts +2 -2
  596. package/dist/types/wallet-server/src/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistrationRequestScopedCloudflare.d.ts +3 -3
  597. package/dist/types/wallet-server/src/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistrationSideEffectBoundary.d.ts +6 -5
  598. package/dist/types/wallet-server/src/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistrationTwoPhaseRunner.d.ts +14 -4
  599. package/dist/types/wallet-server/src/router/domains/ed25519Yao/routerAbEd25519YaoGatewayEnvelope.d.ts +12 -1
  600. package/dist/types/wallet-server/src/router/domains/ed25519Yao/session/routerAbEd25519YaoWalletSession.d.ts +5 -5
  601. package/dist/types/wallet-server/src/router/domains/ed25519Yao/session/thresholdEd25519RequestValidation.d.ts +3 -4
  602. package/dist/types/wallet-server/src/router/domains/emailOtp/emailOtpExportPolicy.d.ts +2 -27
  603. package/dist/types/wallet-server/src/router/domains/emailOtp/emailOtpRequestValidation.d.ts +1 -2
  604. package/dist/types/wallet-server/src/router/domains/emailOtp/emailOtpRouteHandlers.d.ts +2 -1
  605. package/dist/types/wallet-server/src/router/domains/emailOtp/emailOtpSessionRouteHelpers.d.ts +2 -102
  606. package/dist/types/wallet-server/src/router/domains/passkeyCustody/envelopeRevocationAdmission.d.ts +2 -1
  607. package/dist/types/wallet-server/src/router/domains/passkeyCustody/passkeyCustodyEnvelopeRetrieval.d.ts +3 -2
  608. package/dist/types/wallet-server/src/router/domains/passkeyCustody/passkeyCustodyEnvelopeRetrievalRoute.d.ts +1 -9
  609. package/dist/types/wallet-server/src/router/domains/passkeyCustody/registrationCustodyOutcome.d.ts +2 -1
  610. package/dist/types/wallet-server/src/router/domains/passkeyCustody/verifiedCustodyFactor.d.ts +2 -1
  611. package/dist/types/wallet-server/src/router/domains/passkeyCustody/walletCustodyRegistrationAdmission.d.ts +2 -1
  612. package/dist/types/wallet-server/src/router/domains/passkeyCustody/walletCustodyRegistrationCommit.d.ts +2 -28
  613. package/dist/types/wallet-server/src/router/domains/passkeyCustody/walletRecoveryFinalization.d.ts +43 -1
  614. package/dist/types/wallet-server/src/router/domains/passkeyCustody/walletRecoveryKeyManifest.d.ts +7 -7
  615. package/dist/types/wallet-server/src/router/domains/signingOperations/ed25519AuthorizedOperationReceipt.d.ts +0 -3
  616. package/dist/types/wallet-server/src/router/domains/signingOperations/routerAbEcdsaDerivationNormalSigningRoute.d.ts +165 -0
  617. package/dist/types/wallet-server/src/router/domains/signingOperations/routerAbEd25519NormalSigningRoute.d.ts +110 -0
  618. package/dist/types/wallet-server/src/router/domains/signingOperations/routerAbNormalSigningAdmission.d.ts +360 -0
  619. package/dist/types/wallet-server/src/router/domains/signingOperations/routerAbNormalSigningAdmissionCore.d.ts +11 -10
  620. package/dist/types/wallet-server/src/router/domains/signingOperations/routerAbNormalSigningAdmissionCore.typecheck.d.ts +2 -0
  621. package/dist/types/wallet-server/src/router/domains/signingOperations/routerAbOperationStepUp.d.ts +165 -0
  622. package/dist/types/wallet-server/src/router/domains/signingOperations/routerAbPrivateSigningWorker.d.ts +16 -702
  623. package/dist/types/wallet-server/src/router/domains/signingOperations/walletExecutionAdmission.d.ts +5 -12
  624. package/dist/types/wallet-server/src/router/domains/syncAccount/syncAccountRequestValidation.d.ts +5 -4
  625. package/dist/types/wallet-server/src/router/domains/tenantRoot/tenantRootCustodyLineage.d.ts +6 -1
  626. package/dist/types/wallet-server/src/router/domains/tenantRoot/tenantRootIdentityResolution.d.ts +4 -7
  627. package/dist/types/wallet-server/src/router/domains/walletRegistration/walletRegistrationInputs.d.ts +2 -1
  628. package/dist/types/wallet-server/src/router/domains/walletRegistration/walletRegistrationRoutes.d.ts +8 -8
  629. package/dist/types/wallet-server/src/router/domains/walletRegistration/walletRegistrationSetupPayload.d.ts +4 -4
  630. package/dist/types/wallet-server/src/router/domains/walletUnlock/walletUnlockRequestedCapabilitiesValidation.d.ts +4 -4
  631. package/dist/types/wallet-server/src/router/domains/walletUnlock/walletUnlockRouteHandlers.d.ts +4 -62
  632. package/dist/types/wallet-server/src/router/express-adaptor.d.ts +2 -2
  633. package/dist/types/wallet-server/src/router/framework/authServicePort.d.ts +64 -61
  634. package/dist/types/wallet-server/src/router/framework/http.d.ts +0 -1
  635. package/dist/types/wallet-server/src/router/framework/ror/normalize.d.ts +2 -2
  636. package/dist/types/wallet-server/src/router/framework/routeMeteringPolicy.d.ts +3 -2
  637. package/dist/types/wallet-server/src/router/framework/routerApi.d.ts +1 -1
  638. package/dist/types/wallet-server/src/router/framework/routerApiRouteSurface.d.ts +3 -3
  639. package/dist/types/wallet-server/src/router/node/nodeHostedWalletGateway.d.ts +34 -0
  640. package/dist/types/wallet-server/src/router/node/nodeHostedWalletGatewayCheck.d.ts +21 -0
  641. package/dist/types/wallet-server/src/router/node/nodeHostedWalletGatewayMain.d.ts +2 -0
  642. package/dist/types/wallet-server/src/router/node/nodeHttp.d.ts +13 -0
  643. package/dist/types/wallet-server/src/router/node/nodeSqlite.d.ts +22 -0
  644. package/dist/types/wallet-server/src/router/node/signerSqlMigrations.d.ts +20 -0
  645. package/dist/types/wallet-server/src/router/transport/fetch/createFetchRouter.d.ts +1 -3
  646. package/dist/types/wallet-server/src/router/transport/fetch/routes/deviceLinking.d.ts +5 -6
  647. package/dist/types/wallet-server/src/router/transport/fetch/routes/deviceLinkingOwnerAuthorization.d.ts +2 -2
  648. package/dist/types/wallet-server/src/router/transport/fetch/routes/deviceManagement.d.ts +14 -16
  649. package/dist/types/wallet-server/src/router/transport/fetch/routes/normalSigningRouterProxy.d.ts +0 -12
  650. package/dist/types/wallet-server/src/router/transport/fetch/routes/passkeyCustody.d.ts +1 -1
  651. package/dist/types/wallet-server/src/router/transport/fetch/routes/sessions.d.ts +2 -1
  652. package/dist/types/wallet-server/src/router/transport/fetch/routes/syncAccountBootstrap.d.ts +7 -13
  653. package/dist/types/wallet-server/src/router/transport/fetch/routes/thresholdEcdsa.d.ts +3 -57
  654. package/dist/types/wallet-server/src/router/transport/fetch/routes/thresholdEd25519.d.ts +0 -44
  655. package/dist/types/wallet-server/src/storage/d1Sql.d.ts +7 -0
  656. package/dist/types/wallet-server/src/storage/syncSqlite.d.ts +28 -0
  657. package/dist/types/wallet-server/src/threshold/session/signingSessionSeal/crypto/shamir3PassWasm.d.ts +0 -1
  658. package/dist/types/wallet-server/src/threshold/session/signingSessionSeal/idempotencyRecords.d.ts +5 -6
  659. package/dist/types/wallet-server/src/threshold/session/signingSessionSeal/transport/shared.d.ts +1 -0
  660. package/dist/types/wallet-server/src/threshold/statusCodes.d.ts +4 -4
  661. package/migrations/d1-signer/0036_r150_yao_lifecycle_decisions.sql +22 -0
  662. package/migrations/d1-signer/0037_r150_wallet_auth_method_revocation_replays.sql +26 -0
  663. package/migrations/d1-signer/0038_r150_registration_ceremony_cas_guard_seed.sql +8 -0
  664. package/migrations/d1-signer/0039_r150_revocation_replay_answer_kind.sql +9 -0
  665. package/package.json +1 -1
  666. package/dist/esm/core/ThresholdService/ecdsaClientRootProof.js +0 -27
  667. package/dist/esm/core/ThresholdService/routerAbEcdsaSigningWorkerWasm.js +0 -115
  668. package/dist/esm/core/ThresholdService/secureRandomId.js +0 -9
  669. package/dist/esm/core/authService/record.js +0 -8
  670. package/dist/esm/core/authService/thresholdRuntimePolicy.js +0 -19
  671. package/dist/esm/core/authService/walletRegistrationPlanning.js +0 -49
  672. package/dist/esm/core/deviceLinking/index.js +0 -5
  673. package/dist/esm/core/errors.js +0 -54
  674. package/dist/esm/core/routerAbSigning/createCloudflareDurableObjectRouterAbSigningRuntimes.js +0 -39
  675. package/dist/esm/core/signingLanes/WalletKeyStore.js +0 -0
  676. package/dist/esm/core/signingLanes/index.js +0 -8
  677. package/dist/esm/router/domains/tenantRoot/tenantRootEcdsaWalletSessionComposition.js +0 -55
  678. package/dist/esm/router/domains/tenantRoot/tenantRootEd25519WalletSessionComposition.js +0 -56
  679. package/dist/esm/shared-ts/src/signing-lanes/linkedEcdsaScope.js +0 -1
  680. package/dist/esm/wasm/router_ab_ecdsa_signing_worker/pkg/router_ab_ecdsa_signing_worker.js +0 -414
  681. package/dist/types/shared-ts/src/passkey-custody/credentialObservations.d.ts +0 -74
  682. package/dist/types/shared-ts/src/passkey-custody/kekContext.d.ts +0 -34
  683. package/dist/types/shared-ts/src/signing-lanes/linkedEcdsaScope.d.ts +0 -62
  684. package/dist/types/shared-ts/src/signing-lanes/linkedEcdsaScope.typecheck.d.ts +0 -2
  685. package/dist/types/shared-ts/src/signing-lanes/validation.d.ts +0 -11
  686. package/dist/types/shared-ts/src/utils/bigint.d.ts +0 -3
  687. package/dist/types/shared-ts/src/utils/paillier.d.ts +0 -37
  688. package/dist/types/shared-ts/src/utils/recoveryDomain.d.ts +0 -12
  689. package/dist/types/shared-ts/src/utils/signerDomain.typecheck.d.ts +0 -2
  690. package/dist/types/shared-ts/src/wallet-recovery/recoveryKekContext.d.ts +0 -37
  691. package/dist/types/wallet-server/src/core/ThresholdService/ecdsaClientRootProof.d.ts +0 -12
  692. package/dist/types/wallet-server/src/core/ThresholdService/routerAbEcdsaSigningWorkerWasm.d.ts +0 -17
  693. package/dist/types/wallet-server/src/core/ThresholdService/secureRandomId.d.ts +0 -2
  694. package/dist/types/wallet-server/src/core/authService/record.d.ts +0 -2
  695. package/dist/types/wallet-server/src/core/authService/thresholdRuntimePolicy.d.ts +0 -4
  696. package/dist/types/wallet-server/src/core/authService/walletRegistrationPlanning.d.ts +0 -19
  697. package/dist/types/wallet-server/src/core/deviceLinking/index.d.ts +0 -5
  698. package/dist/types/wallet-server/src/core/errors.d.ts +0 -10
  699. package/dist/types/wallet-server/src/core/routerAbSigning/createCloudflareDurableObjectRouterAbSigningRuntimes.d.ts +0 -28
  700. package/dist/types/wallet-server/src/core/signingLanes/SigningLaneStore.d.ts +0 -15
  701. package/dist/types/wallet-server/src/core/signingLanes/WalletKeyStore.d.ts +0 -13
  702. package/dist/types/wallet-server/src/core/signingLanes/index.d.ts +0 -11
  703. package/dist/types/wallet-server/src/router/domains/tenantRoot/tenantRootEcdsaWalletSessionComposition.d.ts +0 -35
  704. package/dist/types/wallet-server/src/router/domains/tenantRoot/tenantRootEd25519WalletSessionComposition.d.ts +0 -35
  705. /package/dist/esm/{core/signingLanes/SigningLaneStore.js → authorization/ecdsaWalletSessionAdmission.js} +0 -0
@@ -1,21 +1,5 @@
1
- import { parseChallengeSubjectId, parseEmailOtpChallengeId, parseOrgId, parseProviderSubject, parseRootShareEpoch, parseWalletAuthMethodId, parseWalletAuthorityId, parseWalletId, parseWebAuthnCredentialIdB64u, parseWebAuthnRpId } from "../shared-ts/src/utils/domainIds.js";
2
- import { parseDeviceId } from "../shared-ts/src/authorization/capabilityKinds.js";
3
- import { parseDigestB64u } from "../shared-ts/src/utils/canonicalPrimitives.js";
4
- import { parseWalletAddAuthMethodRegistrationOptions } from "../shared-ts/src/utils/addAuthMethodRegistration.js";
5
- import { addAuthMethodIntentGrantFromString, addSignerIntentGrantFromString, normalizeAddAuthMethodInput, normalizeAddAuthMethodIntentCaller, normalizeAddSignerSelection, normalizeRegistrationAuthMethodInput, normalizeRegistrationSignerPlan, registrationSignerBranchKeyFromString, registrationSignerPlanFromSelection, registrationSignerSetSelectionFromPlan } from "../shared-ts/src/utils/registrationIntent.js";
6
- import { parseWebAuthnAuthenticatorDeviceInfo } from "../shared-ts/src/utils/webauthnDeviceInfo.js";
7
- import { parseRouterAbEd25519YaoRegistrationActivationAdmissionReceiptV1, parseRouterAbEd25519YaoRegistrationActivationResultV1, parseRouterAbEd25519YaoRegistrationAdmissionRequestV1 } from "../shared-ts/src/utils/routerAbEd25519Yao.js";
8
- import { derivationClientSharePublicKey33B64uFromString, ecdsaClientRootPublicKey33B64uFromString } from "../shared-ts/src/threshold/ecdsaDerivationRoleLocalBootstrap.js";
9
- import { parseWalletAuthAuthorityRef } from "../shared-ts/src/utils/walletAuthAuthority.js";
10
- import { parseRouterAbEcdsaDerivationNormalSigningStateV1, parseRouterAbEcdsaDerivationPublicCapabilityV1, parseRouterAbEcdsaRegistrationActivationReceiptV1, parseRouterAbEcdsaRegistrationRequestFactsV1, parseRouterAbEcdsaRegistrationRequestV1, parseRouterAbEcdsaStrictForwardedRegistrationResponseV1, parseRouterAbEcdsaVerifiedClientActivationFactsV1 } from "../shared-ts/src/utils/routerAbEcdsaDerivation.js";
11
- import { thresholdEcdsaChainTargetFromValue, thresholdEcdsaChainTargetKey } from "./thresholdEcdsaChainTarget.js";
12
- import "./defaultConfigsServer.js";
13
- import { parseWalletEd25519SignerRecord } from "./d1WalletStore.js";
14
- import { registrationPreparationIdFromString } from "./types.js";
15
- import { parsePasskeyCustodyEnvelopeRecord } from "../shared-ts/src/passkey-custody/custodyEnvelope.js";
16
- import "../shared-ts/src/passkey-custody/index.js";
17
- import { parseEcdsaDerivationPublicIdentity } from "./ThresholdService/validation.js";
18
- import { parseStoredRouterAbEcdsaPendingActivationV1 } from "../router/domains/ecdsa/routerAbEcdsaStrictRegistration.js";
1
+ import { thresholdEcdsaChainTargetFromValue } from "./thresholdEcdsaChainTarget.js";
2
+ import { normalizeRegistrationSignerPlan, registrationSignerPlanFromSelection } from "../shared-ts/src/utils/registrationSignerPlan.js";
19
3
  //#region src/core/RegistrationCeremonyStore.ts
20
4
  function buildStoredWalletRegistrationPreparedContext(input) {
21
5
  const signingRootId = String(input.signingRootId || "").trim();
@@ -40,17 +24,6 @@ function buildStoredWalletRegistrationPreparedContext(input) {
40
24
  } : { kind: "evm_family_ecdsa_absent" }
41
25
  };
42
26
  }
43
- function storedWalletRegistrationPreparedContextsMatch(left, right) {
44
- if (left.kind !== right.kind || left.signingRootId !== right.signingRootId || left.signingRootVersion !== right.signingRootVersion || left.runtimePolicy.kind !== right.runtimePolicy.kind || left.ecdsa.kind !== right.ecdsa.kind) return false;
45
- if (left.runtimePolicy.kind === "runtime_policy_scope" && right.runtimePolicy.kind === "runtime_policy_scope" && (left.runtimePolicy.scope.orgId !== right.runtimePolicy.scope.orgId || left.runtimePolicy.scope.projectId !== right.runtimePolicy.scope.projectId || left.runtimePolicy.scope.envId !== right.runtimePolicy.scope.envId || left.runtimePolicy.scope.signingRootVersion !== right.runtimePolicy.scope.signingRootVersion)) return false;
46
- if (left.ecdsa.kind === "evm_family_ecdsa_requested" && right.ecdsa.kind === "evm_family_ecdsa_requested") {
47
- const leftTargets = left.ecdsa.chainTargets;
48
- const rightTargets = right.ecdsa.chainTargets;
49
- if (leftTargets.length !== rightTargets.length) return false;
50
- return leftTargets.every((target, index) => thresholdEcdsaChainTargetKey(target) === thresholdEcdsaChainTargetKey(rightTargets[index]));
51
- }
52
- return true;
53
- }
54
27
  function storedRegistrationAuthoritiesMatch(left, right) {
55
28
  if (left.kind !== right.kind) return false;
56
29
  switch (left.kind) {
@@ -108,206 +81,12 @@ function replaceStoredWalletRegistrationSignerBranch(input) {
108
81
  function verifiedRegistrationCeremonyAuthority(ceremony) {
109
82
  return ceremony.authorityState.kind === "verified" ? ceremony.authorityState.authority : null;
110
83
  }
111
- function registrationCeremonyAuthorityRpId(authorityState) {
112
- switch (authorityState.kind) {
113
- case "awaiting_proof": return authorityState.authMethod.kind === "passkey" ? String(authorityState.authMethod.rpId) : null;
114
- case "verified": return authorityState.authority.kind === "passkey" ? String(authorityState.authority.rpId) : null;
115
- default: return authorityState;
116
- }
117
- }
118
- function parseTerminalRegistrationCeremonyCancellationResult(value) {
119
- const parsed = parseJsonValue(value);
120
- if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) return null;
121
- const record = parsed;
122
- switch (record.kind) {
123
- case "cancelled": return record.ceremonyDeleted === true ? {
124
- kind: "cancelled",
125
- ceremonyDeleted: true
126
- } : null;
127
- case "not_found": return record.ceremonyDeleted === false ? {
128
- kind: "not_found",
129
- ceremonyDeleted: false
130
- } : null;
131
- default: return null;
132
- }
133
- }
134
- var MemoryRegistrationCeremonyStore = class {
135
- constructor() {
136
- this.addAuthMethodIntents = /* @__PURE__ */ new Map();
137
- this.addSignerIntents = /* @__PURE__ */ new Map();
138
- this.ceremonies = /* @__PURE__ */ new Map();
139
- this.addSignerFinalizeReplays = /* @__PURE__ */ new Map();
140
- this.addSignerFinalizeReplayClaims = /* @__PURE__ */ new Map();
141
- this.addAuthMethodCeremonies = /* @__PURE__ */ new Map();
142
- this.addSignerCeremonies = /* @__PURE__ */ new Map();
143
- }
144
- async putAddAuthMethodIntent(intent) {
145
- this.pruneExpired();
146
- this.addAuthMethodIntents.set(intent.grant, intent);
147
- }
148
- async getAddAuthMethodIntent(grant) {
149
- this.pruneExpired();
150
- const intent = this.addAuthMethodIntents.get(String(grant || "").trim()) || null;
151
- if (!intent || intent.expiresAtMs <= Date.now()) return null;
152
- return intent;
153
- }
154
- async takeAddAuthMethodIntent(grant) {
155
- this.pruneExpired();
156
- const key = String(grant || "").trim();
157
- const intent = this.addAuthMethodIntents.get(key) || null;
158
- if (!intent) return null;
159
- this.addAuthMethodIntents.delete(key);
160
- if (intent.expiresAtMs <= Date.now()) return null;
161
- return {
162
- ...intent,
163
- kind: "add_auth_method_intent_consumed",
164
- consumedAtMs: Date.now()
165
- };
166
- }
167
- async putAddSignerIntent(intent) {
168
- this.pruneExpired();
169
- this.addSignerIntents.set(intent.grant, intent);
170
- }
171
- async getAddSignerIntent(grant) {
172
- this.pruneExpired();
173
- const intent = this.addSignerIntents.get(String(grant || "").trim()) || null;
174
- if (!intent || intent.expiresAtMs <= Date.now()) return null;
175
- return intent;
176
- }
177
- async takeAddSignerIntent(grant) {
178
- this.pruneExpired();
179
- const key = String(grant || "").trim();
180
- const intent = this.addSignerIntents.get(key) || null;
181
- if (!intent) return null;
182
- this.addSignerIntents.delete(key);
183
- if (intent.expiresAtMs <= Date.now()) return null;
184
- return {
185
- ...intent,
186
- kind: "add_signer_intent_consumed",
187
- consumedAtMs: Date.now()
188
- };
189
- }
190
- async putCeremony(ceremony) {
191
- this.pruneExpired();
192
- this.ceremonies.set(ceremony.registrationCeremonyId, ceremony);
193
- }
194
- async getCeremony(registrationCeremonyId) {
195
- this.pruneExpired();
196
- const ceremony = this.ceremonies.get(String(registrationCeremonyId || "").trim()) || null;
197
- if (!ceremony || ceremony.expiresAtMs <= Date.now()) return null;
198
- return ceremony;
199
- }
200
- async updateCeremony(ceremony) {
201
- this.pruneExpired();
202
- if (ceremony.expiresAtMs <= Date.now()) return;
203
- this.ceremonies.set(ceremony.registrationCeremonyId, ceremony);
204
- }
205
- async takeCeremony(registrationCeremonyId) {
206
- this.pruneExpired();
207
- const key = String(registrationCeremonyId || "").trim();
208
- const ceremony = this.ceremonies.get(key) || null;
209
- this.ceremonies.delete(key);
210
- if (!ceremony || ceremony.expiresAtMs <= Date.now()) return null;
211
- return ceremony;
212
- }
213
- async cancelTerminalCeremony(input) {
214
- this.pruneExpired();
215
- const registrationCeremonyId = trimString(input.registrationCeremonyId);
216
- const ceremony = this.ceremonies.get(registrationCeremonyId);
217
- if (!ceremony) return {
218
- kind: "not_found",
219
- ceremonyDeleted: false
220
- };
221
- if (ceremony.intent.walletId !== input.walletId) throw new Error("Terminal registration cancellation walletId mismatch");
222
- this.ceremonies.delete(registrationCeremonyId);
223
- return {
224
- kind: "cancelled",
225
- ceremonyDeleted: true
226
- };
227
- }
228
- async putAddSignerFinalizeReplay(replay) {
229
- this.pruneExpired();
230
- this.addSignerFinalizeReplays.set(addSignerFinalizeReplayKey(replay), replay);
231
- this.addSignerFinalizeReplayClaims.set(replay.addSignerCeremonyId, replay);
232
- }
233
- async getAddSignerFinalizeReplay(input) {
234
- this.pruneExpired();
235
- const replay = this.addSignerFinalizeReplays.get(addSignerFinalizeReplayKey(input)) || null;
236
- if (!replay || replay.expiresAtMs <= Date.now()) return null;
237
- return replay;
238
- }
239
- async getAddSignerFinalizeReplayForCeremony(addSignerCeremonyId) {
240
- this.pruneExpired();
241
- const replay = this.addSignerFinalizeReplayClaims.get(trimString(addSignerCeremonyId)) || null;
242
- if (!replay || replay.expiresAtMs <= Date.now()) return null;
243
- return replay;
244
- }
245
- async putAddAuthMethodCeremony(ceremony) {
246
- this.pruneExpired();
247
- this.addAuthMethodCeremonies.set(ceremony.addAuthMethodCeremonyId, ceremony);
248
- }
249
- async getAddAuthMethodCeremony(addAuthMethodCeremonyId) {
250
- this.pruneExpired();
251
- const ceremony = this.addAuthMethodCeremonies.get(String(addAuthMethodCeremonyId || "").trim()) || null;
252
- if (!ceremony || ceremony.expiresAtMs <= Date.now()) return null;
253
- return ceremony;
254
- }
255
- async updateAddAuthMethodCeremony(ceremony) {
256
- this.pruneExpired();
257
- if (ceremony.expiresAtMs <= Date.now()) return;
258
- this.addAuthMethodCeremonies.set(ceremony.addAuthMethodCeremonyId, ceremony);
259
- }
260
- async takeAddAuthMethodCeremony(addAuthMethodCeremonyId) {
261
- this.pruneExpired();
262
- const key = String(addAuthMethodCeremonyId || "").trim();
263
- const ceremony = this.addAuthMethodCeremonies.get(key) || null;
264
- this.addAuthMethodCeremonies.delete(key);
265
- if (!ceremony || ceremony.expiresAtMs <= Date.now()) return null;
266
- return ceremony;
267
- }
268
- async putAddSignerCeremony(ceremony) {
269
- this.pruneExpired();
270
- this.addSignerCeremonies.set(ceremony.addSignerCeremonyId, ceremony);
271
- }
272
- async getAddSignerCeremony(addSignerCeremonyId) {
273
- this.pruneExpired();
274
- const ceremony = this.addSignerCeremonies.get(String(addSignerCeremonyId || "").trim()) || null;
275
- if (!ceremony || ceremony.expiresAtMs <= Date.now()) return null;
276
- return ceremony;
277
- }
278
- async updateAddSignerCeremony(ceremony) {
279
- this.pruneExpired();
280
- if (ceremony.expiresAtMs <= Date.now()) return;
281
- this.addSignerCeremonies.set(ceremony.addSignerCeremonyId, ceremony);
282
- }
283
- async takeAddSignerCeremony(addSignerCeremonyId) {
284
- this.pruneExpired();
285
- const key = String(addSignerCeremonyId || "").trim();
286
- const ceremony = this.addSignerCeremonies.get(key) || null;
287
- this.addSignerCeremonies.delete(key);
288
- if (!ceremony || ceremony.expiresAtMs <= Date.now()) return null;
289
- return ceremony;
290
- }
291
- pruneExpired() {
292
- const now = Date.now();
293
- for (const [key, intent] of this.addAuthMethodIntents) if (intent.expiresAtMs <= now) this.addAuthMethodIntents.delete(key);
294
- for (const [key, intent] of this.addSignerIntents) if (intent.expiresAtMs <= now) this.addSignerIntents.delete(key);
295
- for (const [key, ceremony] of this.ceremonies) if (ceremony.expiresAtMs <= now) this.ceremonies.delete(key);
296
- for (const [key, replay] of this.addSignerFinalizeReplays) if (replay.expiresAtMs <= now) this.addSignerFinalizeReplays.delete(key);
297
- for (const [key, replay] of this.addSignerFinalizeReplayClaims) if (replay.expiresAtMs <= now) this.addSignerFinalizeReplayClaims.delete(key);
298
- for (const [key, ceremony] of this.addAuthMethodCeremonies) if (ceremony.expiresAtMs <= now) this.addAuthMethodCeremonies.delete(key);
299
- for (const [key, ceremony] of this.addSignerCeremonies) if (ceremony.expiresAtMs <= now) this.addSignerCeremonies.delete(key);
300
- }
301
- };
302
84
  function assertNever(value) {
303
85
  throw new Error(`Unexpected registration ceremony store branch: ${String(value)}`);
304
86
  }
305
87
  function trimString(value) {
306
88
  return typeof value === "string" ? value.trim() : "";
307
89
  }
308
- function addSignerFinalizeReplayKey(input) {
309
- return `${trimString(input.addSignerCeremonyId)}:${trimString(input.idempotencyKey)}`;
310
- }
311
90
  function parseJsonValue(value) {
312
91
  if (typeof value !== "string") return value;
313
92
  try {
@@ -316,225 +95,6 @@ function parseJsonValue(value) {
316
95
  return null;
317
96
  }
318
97
  }
319
- function parseStoredWalletAddSignerFinalizeParticipantIds(value) {
320
- if (!Array.isArray(value) || value.length !== 2) return null;
321
- const first = value[0];
322
- const second = value[1];
323
- if (typeof first !== "number" || !Number.isSafeInteger(first) || first <= 0 || typeof second !== "number" || !Number.isSafeInteger(second) || second <= 0) return null;
324
- return [first, second];
325
- }
326
- function parseStoredWalletAddSignerFinalizeEd25519Result(value) {
327
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
328
- const record = value;
329
- const signerSlot = Number(record.signerSlot);
330
- const nearAccountId = trimString(record.nearAccountId);
331
- const nearEd25519SigningKeyId = trimString(record.nearEd25519SigningKeyId);
332
- const publicKey = trimString(record.publicKey);
333
- const relayerKeyId = trimString(record.relayerKeyId);
334
- const keyVersion = trimString(record.keyVersion);
335
- const participantIds = parseStoredWalletAddSignerFinalizeParticipantIds(record.participantIds);
336
- if (record.recoveryExportCapable !== true || !Number.isSafeInteger(signerSlot) || signerSlot <= 0 || !nearAccountId || !nearEd25519SigningKeyId || !publicKey.startsWith("ed25519:") || !relayerKeyId || !keyVersion || !participantIds) return null;
337
- return {
338
- signerSlot,
339
- nearAccountId,
340
- nearEd25519SigningKeyId,
341
- publicKey,
342
- relayerKeyId,
343
- keyVersion,
344
- recoveryExportCapable: true,
345
- participantIds
346
- };
347
- }
348
- function parseStoredWalletAddSignerFinalizeEcdsaWalletKey(value) {
349
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
350
- const record = value;
351
- if (record.keyScope !== "evm-family") return null;
352
- const chainTarget = thresholdEcdsaChainTargetFromValue(record.chainTarget);
353
- const walletId = trimString(record.walletId);
354
- const evmFamilySigningKeySlotId = trimString(record.evmFamilySigningKeySlotId);
355
- const keyHandle = trimString(record.keyHandle);
356
- const ecdsaThresholdKeyId = trimString(record.ecdsaThresholdKeyId);
357
- const signingRootId = trimString(record.signingRootId);
358
- const signingRootVersion = trimString(record.signingRootVersion);
359
- const thresholdEcdsaPublicKeyB64u = trimString(record.thresholdEcdsaPublicKeyB64u);
360
- const thresholdOwnerAddress = trimString(record.thresholdOwnerAddress);
361
- const relayerKeyId = trimString(record.relayerKeyId);
362
- const relayerVerifyingShareB64u = trimString(record.relayerVerifyingShareB64u);
363
- const contextBinding32B64u = trimString(record.contextBinding32B64u);
364
- const derivationClientSharePublicKey33B64u = trimString(record.derivationClientSharePublicKey33B64u);
365
- const clientShareRetryCounter = Number(record.clientShareRetryCounter);
366
- const relayerShareRetryCounter = Number(record.relayerShareRetryCounter);
367
- const participantIds = parseStoredWalletAddSignerFinalizeParticipantIds(record.participantIds);
368
- let publicCapability;
369
- let parsedDerivationClientSharePublicKey33B64u;
370
- try {
371
- publicCapability = parseRouterAbEcdsaDerivationPublicCapabilityV1(record.publicCapability);
372
- parsedDerivationClientSharePublicKey33B64u = derivationClientSharePublicKey33B64uFromString(derivationClientSharePublicKey33B64u);
373
- } catch {
374
- return null;
375
- }
376
- if (!chainTarget || !walletId || !evmFamilySigningKeySlotId || !keyHandle || !ecdsaThresholdKeyId || !signingRootId || !signingRootVersion || !thresholdEcdsaPublicKeyB64u || !thresholdOwnerAddress || !relayerKeyId || !relayerVerifyingShareB64u || !contextBinding32B64u || !derivationClientSharePublicKey33B64u || !Number.isSafeInteger(clientShareRetryCounter) || clientShareRetryCounter < 0 || !Number.isSafeInteger(relayerShareRetryCounter) || relayerShareRetryCounter < 0 || !participantIds || participantIds[0] !== 1 || participantIds[1] !== 2) return null;
377
- return {
378
- keyScope: "evm-family",
379
- chainTarget,
380
- walletId,
381
- evmFamilySigningKeySlotId,
382
- keyHandle,
383
- ecdsaThresholdKeyId,
384
- signingRootId,
385
- signingRootVersion,
386
- thresholdEcdsaPublicKeyB64u,
387
- thresholdOwnerAddress,
388
- relayerKeyId,
389
- relayerVerifyingShareB64u,
390
- contextBinding32B64u,
391
- derivationClientSharePublicKey33B64u: parsedDerivationClientSharePublicKey33B64u,
392
- clientShareRetryCounter,
393
- relayerShareRetryCounter,
394
- participantIds: [1, 2],
395
- publicCapability
396
- };
397
- }
398
- function parseStoredWalletAddSignerFinalizeEcdsaResult(value) {
399
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
400
- const record = value;
401
- if (!Array.isArray(record.walletKeys) || record.walletKeys.length === 0) return null;
402
- const walletKeys = [];
403
- for (const rawWalletKey of record.walletKeys) {
404
- const walletKey = parseStoredWalletAddSignerFinalizeEcdsaWalletKey(rawWalletKey);
405
- if (!walletKey) return null;
406
- walletKeys.push(walletKey);
407
- }
408
- return { walletKeys };
409
- }
410
- function parseStoredWalletAddSignerFinalizeSuccess(value) {
411
- const parsed = parseJsonValue(value);
412
- if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) return null;
413
- const record = parsed;
414
- if (record.ok !== true) return null;
415
- const walletId = parseWalletId(record.walletId);
416
- if (!walletId.ok) return null;
417
- if (record.kind === "near_ed25519") {
418
- if (!trimString(record.rpId) || !trimString(record.credentialIdB64u)) return null;
419
- const ed25519 = parseStoredWalletAddSignerFinalizeEd25519Result(record.ed25519);
420
- return ed25519 ? {
421
- ok: true,
422
- kind: "near_ed25519",
423
- walletId: walletId.value,
424
- rpId: trimString(record.rpId),
425
- credentialIdB64u: trimString(record.credentialIdB64u),
426
- ed25519
427
- } : null;
428
- }
429
- if (record.kind !== "evm_family_ecdsa") return null;
430
- const ecdsa = parseStoredWalletAddSignerFinalizeEcdsaResult(record.ecdsa);
431
- if (!ecdsa) return null;
432
- const rpId = trimString(record.rpId);
433
- return rpId ? {
434
- ok: true,
435
- kind: "evm_family_ecdsa",
436
- walletId: walletId.value,
437
- rpId,
438
- ecdsa
439
- } : {
440
- ok: true,
441
- kind: "evm_family_ecdsa",
442
- walletId: walletId.value,
443
- ecdsa
444
- };
445
- }
446
- function parseStoredWalletAddSignerFinalizeReplay(value) {
447
- const parsed = parseJsonValue(value);
448
- if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) return null;
449
- const record = parsed;
450
- if (record.kind !== "wallet_add_signer_finalize_replay_v1") return null;
451
- const addSignerCeremonyId = trimString(record.addSignerCeremonyId);
452
- const idempotencyKey = trimString(record.idempotencyKey);
453
- const createdAtMs = Number(record.createdAtMs);
454
- const expiresAtMs = Number(record.expiresAtMs);
455
- const request = parseStoredWalletAddSignerFinalizeRequest(record.request);
456
- const response = parseStoredWalletAddSignerFinalizeSuccess(record.response);
457
- if (!addSignerCeremonyId || !idempotencyKey || !request || request.addSignerCeremonyId !== addSignerCeremonyId || request.idempotencyKey !== idempotencyKey || !response || request.kind !== response.kind || !Number.isSafeInteger(createdAtMs) || createdAtMs <= 0 || !Number.isSafeInteger(expiresAtMs) || expiresAtMs <= 0) return null;
458
- return {
459
- kind: "wallet_add_signer_finalize_replay_v1",
460
- addSignerCeremonyId,
461
- idempotencyKey,
462
- request,
463
- response,
464
- createdAtMs,
465
- expiresAtMs
466
- };
467
- }
468
- function parseStoredWalletAddSignerFinalizeRequest(value) {
469
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
470
- const record = value;
471
- const addSignerCeremonyId = trimString(record.addSignerCeremonyId);
472
- const idempotencyKey = trimString(record.idempotencyKey);
473
- if (!addSignerCeremonyId || !idempotencyKey) return null;
474
- if (record.kind === "near_ed25519") {
475
- if (record.custodyKeySet === null || typeof record.custodyKeySet !== "object" || Array.isArray(record.custodyKeySet) || record.activationReference === null || typeof record.activationReference !== "object" || Array.isArray(record.activationReference)) return null;
476
- const custodyKeySet = record.custodyKeySet;
477
- const activationReference = record.activationReference;
478
- const lifecycleId = trimString(activationReference.lifecycleId);
479
- const sessionId = parseStoredBytes32(activationReference.sessionId);
480
- if (custodyKeySet.kind !== "near_ed25519_v1" || !lifecycleId || !sessionId) return null;
481
- let keyManifestDigestB64u;
482
- try {
483
- keyManifestDigestB64u = parseDigestB64u(custodyKeySet.keyManifestDigestB64u);
484
- } catch {
485
- return null;
486
- }
487
- const registeredPublicKeyB64u = trimString(custodyKeySet.registeredPublicKeyB64u);
488
- if (!registeredPublicKeyB64u) return null;
489
- return {
490
- kind: "near_ed25519",
491
- addSignerCeremonyId,
492
- idempotencyKey,
493
- custodyKeySet: {
494
- kind: "near_ed25519_v1",
495
- keyManifestDigestB64u,
496
- registeredPublicKeyB64u
497
- },
498
- activationReference: {
499
- lifecycleId,
500
- sessionId
501
- }
502
- };
503
- }
504
- if (record.kind !== "evm_family_ecdsa" || !Array.isArray(record.expectedKeyHandles) || record.expectedKeyHandles.length !== 1) return null;
505
- const expectedKeyHandle = trimString(record.expectedKeyHandles[0]);
506
- if (record.custodyKeySet === null || typeof record.custodyKeySet !== "object" || Array.isArray(record.custodyKeySet)) return null;
507
- const custodyKeySet = record.custodyKeySet;
508
- if (!expectedKeyHandle || custodyKeySet.kind !== "evm_family_ecdsa_v1") return null;
509
- let keyManifestDigestB64u;
510
- let clientRootPublicKey33B64u;
511
- try {
512
- keyManifestDigestB64u = parseDigestB64u(custodyKeySet.keyManifestDigestB64u);
513
- clientRootPublicKey33B64u = ecdsaClientRootPublicKey33B64uFromString(trimString(custodyKeySet.clientRootPublicKey33B64u));
514
- } catch {
515
- return null;
516
- }
517
- return {
518
- kind: "evm_family_ecdsa",
519
- addSignerCeremonyId,
520
- idempotencyKey,
521
- custodyKeySet: {
522
- kind: "evm_family_ecdsa_v1",
523
- keyManifestDigestB64u,
524
- clientRootPublicKey33B64u
525
- },
526
- expectedKeyHandles: [expectedKeyHandle]
527
- };
528
- }
529
- function parseStoredBytes32(value) {
530
- if (!Array.isArray(value) || value.length !== 32) return null;
531
- const bytes = [];
532
- for (const byte of value) {
533
- if (typeof byte !== "number" || !Number.isInteger(byte) || byte < 0 || byte > 255) return null;
534
- bytes.push(byte);
535
- }
536
- return bytes;
537
- }
538
98
  function parseStoredRegistrationSignerPlan(value) {
539
99
  const parsed = normalizeRegistrationSignerPlan(value);
540
100
  if (parsed.ok) return parsed.value;
@@ -722,99 +282,6 @@ function assertNeverStoredRegistrationSignerPlanBranch(branch) {
722
282
  function assertNeverStoredRegistrationNearAccountProvisioning(provisioning) {
723
283
  throw new Error(`Unexpected stored registration account provisioning: ${String(provisioning)}`);
724
284
  }
725
- function parseStoredAddSignerIntent(value) {
726
- const decoded = parseJsonValue(value);
727
- if (decoded === null || typeof decoded !== "object" || Array.isArray(decoded)) return null;
728
- const record = decoded;
729
- if (record.kind !== "add_signer_intent_allocated") return null;
730
- const grant = trimString(record.grant);
731
- const digestB64u = trimString(record.digestB64u);
732
- const orgId = trimString(record.orgId);
733
- const expiresAtMs = Number(record.expiresAtMs);
734
- if (!grant || !digestB64u || !orgId || !Number.isSafeInteger(expiresAtMs)) return null;
735
- if (record.intent === null || typeof record.intent !== "object" || Array.isArray(record.intent)) return null;
736
- const intent = record.intent;
737
- if (intent.version !== "add_signer_intent_v1") return null;
738
- const walletId = parseWalletId(intent.walletId);
739
- const signerSelection = normalizeAddSignerSelection(intent.signerSelection, { normalizeEcdsaChainTarget: thresholdEcdsaChainTargetFromValue });
740
- const nonceB64u = trimString(intent.nonceB64u);
741
- if (!walletId.ok || !signerSelection.ok || !nonceB64u) return null;
742
- const runtimePolicyScope = Object.prototype.hasOwnProperty.call(intent, "runtimePolicyScope") ? parseStoredAddAuthMethodRuntimePolicyScope(intent.runtimePolicyScope) : void 0;
743
- if (Object.prototype.hasOwnProperty.call(intent, "runtimePolicyScope") && !runtimePolicyScope) return null;
744
- const parsedIntent = runtimePolicyScope ? {
745
- version: "add_signer_intent_v1",
746
- walletId: walletId.value,
747
- signerSelection: signerSelection.value,
748
- runtimePolicyScope,
749
- nonceB64u
750
- } : {
751
- version: "add_signer_intent_v1",
752
- walletId: walletId.value,
753
- signerSelection: signerSelection.value,
754
- nonceB64u
755
- };
756
- return {
757
- kind: "add_signer_intent_allocated",
758
- grant: addSignerIntentGrantFromString(grant),
759
- intent: parsedIntent,
760
- digestB64u,
761
- orgId,
762
- expiresAtMs,
763
- ...trimString(record.signingRootId) ? { signingRootId: trimString(record.signingRootId) } : {},
764
- ...trimString(record.signingRootVersion) ? { signingRootVersion: trimString(record.signingRootVersion) } : {},
765
- ...trimString(record.expectedOrigin) ? { expectedOrigin: trimString(record.expectedOrigin) } : {}
766
- };
767
- }
768
- function parseStoredAddAuthMethodIntent(value) {
769
- const decoded = parseJsonValue(value);
770
- if (decoded === null || typeof decoded !== "object" || Array.isArray(decoded)) return null;
771
- const record = decoded;
772
- if (record.kind !== "add_auth_method_intent_allocated") return null;
773
- const grant = trimString(record.grant);
774
- const digestB64u = trimString(record.digestB64u);
775
- const orgId = trimString(record.orgId);
776
- const expiresAtMs = Number(record.expiresAtMs);
777
- if (!grant || !digestB64u || !orgId || !Number.isSafeInteger(expiresAtMs)) return null;
778
- if (record.intent === null || typeof record.intent !== "object" || Array.isArray(record.intent)) return null;
779
- const intent = record.intent;
780
- const walletId = parseWalletId(intent.walletId);
781
- const authMethod = normalizeAddAuthMethodInput(intent.authMethod);
782
- const targetWalletAuthMethodId = parseWalletAuthMethodId(intent.targetWalletAuthMethodId);
783
- const caller = normalizeAddAuthMethodIntentCaller(intent);
784
- const nonceB64u = trimString(intent.nonceB64u);
785
- if (intent.version !== "add_auth_method_intent_v1" || !walletId.ok || !authMethod || !targetWalletAuthMethodId.ok || !caller || !nonceB64u) return null;
786
- const runtimePolicyScope = Object.prototype.hasOwnProperty.call(intent, "runtimePolicyScope") ? parseStoredAddAuthMethodRuntimePolicyScope(intent.runtimePolicyScope) : void 0;
787
- if (Object.prototype.hasOwnProperty.call(intent, "runtimePolicyScope") && !runtimePolicyScope) return null;
788
- const parsedIntent = caller.caller === "same_device_addition" ? {
789
- version: "add_auth_method_intent_v1",
790
- walletId: walletId.value,
791
- authMethod,
792
- targetWalletAuthMethodId: targetWalletAuthMethodId.value,
793
- ...runtimePolicyScope ? { runtimePolicyScope } : {},
794
- nonceB64u,
795
- caller: "same_device_addition",
796
- source: caller.source
797
- } : {
798
- version: "add_auth_method_intent_v1",
799
- walletId: walletId.value,
800
- authMethod,
801
- targetWalletAuthMethodId: targetWalletAuthMethodId.value,
802
- ...runtimePolicyScope ? { runtimePolicyScope } : {},
803
- nonceB64u,
804
- caller: "linked_device_ceremony"
805
- };
806
- return {
807
- kind: "add_auth_method_intent_allocated",
808
- grant: addAuthMethodIntentGrantFromString(grant),
809
- intent: parsedIntent,
810
- digestB64u,
811
- orgId,
812
- expiresAtMs,
813
- ...trimString(record.signingRootId) ? { signingRootId: trimString(record.signingRootId) } : {},
814
- ...trimString(record.signingRootVersion) ? { signingRootVersion: trimString(record.signingRootVersion) } : {},
815
- ...trimString(record.expectedOrigin) ? { expectedOrigin: trimString(record.expectedOrigin) } : {}
816
- };
817
- }
818
285
  function parseStoredAddAuthMethodRuntimePolicyScope(value) {
819
286
  if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
820
287
  const record = value;
@@ -835,1264 +302,7 @@ function parseStoredAddAuthMethodRuntimePolicyScope(value) {
835
302
  envId
836
303
  };
837
304
  }
838
- function parseStoredRegistrationAuthority(value) {
839
- const decoded = parseJsonValue(value);
840
- if (decoded === null || typeof decoded !== "object" || Array.isArray(decoded)) return null;
841
- const record = decoded;
842
- const walletId = parseWalletId(record.walletId);
843
- const registrationIntentDigestB64u = trimString(record.registrationIntentDigestB64u);
844
- if (!walletId.ok || !registrationIntentDigestB64u) return null;
845
- switch (record.kind) {
846
- case "passkey": {
847
- if (record.emailHashHex !== void 0 || record.challengeId !== void 0) return null;
848
- const rpId = parseWebAuthnRpId(record.rpId);
849
- const credentialIdB64u = parseWebAuthnCredentialIdB64u(record.credentialIdB64u);
850
- const credentialPublicKeyB64u = trimString(record.credentialPublicKeyB64u);
851
- const counter = Number(record.counter);
852
- const device = parseWebAuthnAuthenticatorDeviceInfo(record.device);
853
- if (!rpId.ok || !credentialIdB64u.ok || !credentialPublicKeyB64u || !Number.isSafeInteger(counter) || counter < 0 || !device) return null;
854
- return {
855
- kind: "passkey",
856
- walletId: walletId.value,
857
- rpId: rpId.value,
858
- credentialIdB64u: credentialIdB64u.value,
859
- credentialPublicKeyB64u,
860
- counter,
861
- device,
862
- registrationIntentDigestB64u
863
- };
864
- }
865
- case "email_otp": {
866
- if (record.rpId !== void 0 || record.credentialIdB64u !== void 0 || record.credentialPublicKeyB64u !== void 0 || record.counter !== void 0) return null;
867
- const emailHashHex = trimString(record.emailHashHex);
868
- const proofKind = trimString(record.proofKind);
869
- const providerSubject = parseProviderSubject(record.providerSubject);
870
- const email = trimString(record.email).toLowerCase();
871
- const finalWalletId = parseWalletId(record.finalWalletId);
872
- const orgId = parseOrgId(record.orgId);
873
- const ownerProofBindingDigest = trimString(record.ownerProofBindingDigest);
874
- if (!providerSubject.ok || !email || !emailHashHex || !finalWalletId.ok || !orgId.ok || !ownerProofBindingDigest) return null;
875
- if (proofKind === "otp_challenge") {
876
- const parsedChallengeId = parseEmailOtpChallengeId(record.challengeId);
877
- const registrationAuthorityId = parseEmailOtpChallengeId(record.registrationAuthorityId);
878
- const challengeSubjectId = parseChallengeSubjectId(record.challengeSubjectId);
879
- const originalWalletId = parseWalletId(record.originalWalletId);
880
- const challengePurpose = record.challengePurpose === "registration" || record.challengePurpose === "registration_reroll" ? record.challengePurpose : null;
881
- if (!challengeSubjectId.ok || !parsedChallengeId.ok || !registrationAuthorityId.ok || parsedChallengeId.value !== registrationAuthorityId.value || !originalWalletId.ok || !challengePurpose) return null;
882
- return {
883
- kind: "email_otp",
884
- proofKind: "otp_challenge",
885
- walletId: walletId.value,
886
- providerSubject: providerSubject.value,
887
- challengeSubjectId: challengeSubjectId.value,
888
- email,
889
- emailHashHex,
890
- challengeId: parsedChallengeId.value,
891
- registrationAuthorityId: registrationAuthorityId.value,
892
- originalWalletId: originalWalletId.value,
893
- finalWalletId: finalWalletId.value,
894
- orgId: orgId.value,
895
- ownerProofBindingDigest,
896
- challengePurpose,
897
- registrationIntentDigestB64u
898
- };
899
- }
900
- if (proofKind === "google_sso_registration") {
901
- const registrationAttemptId = trimString(record.googleEmailOtpRegistrationAttemptId);
902
- const registrationOfferId = trimString(record.googleEmailOtpRegistrationOfferId);
903
- const registrationCandidateId = trimString(record.googleEmailOtpRegistrationCandidateId);
904
- const registrationAuthorityId = trimString(record.registrationAuthorityId);
905
- if (!registrationAttemptId || !registrationOfferId || !registrationCandidateId || !registrationAuthorityId || registrationAuthorityId !== registrationAttemptId || record.challengeId !== void 0 || record.challengeSubjectId !== void 0 || record.originalWalletId !== void 0 || record.challengePurpose !== void 0) return null;
906
- return {
907
- kind: "email_otp",
908
- proofKind: "google_sso_registration",
909
- walletId: walletId.value,
910
- providerSubject: providerSubject.value,
911
- email,
912
- emailHashHex,
913
- googleEmailOtpRegistrationAttemptId: registrationAttemptId,
914
- googleEmailOtpRegistrationOfferId: registrationOfferId,
915
- googleEmailOtpRegistrationCandidateId: registrationCandidateId,
916
- registrationAuthorityId,
917
- finalWalletId: finalWalletId.value,
918
- orgId: orgId.value,
919
- ownerProofBindingDigest,
920
- registrationIntentDigestB64u
921
- };
922
- }
923
- return null;
924
- }
925
- }
926
- return null;
927
- }
928
- function parseStoredRegistrationIntent(value) {
929
- const decoded = parseJsonValue(value);
930
- if (decoded === null || typeof decoded !== "object" || Array.isArray(decoded)) return null;
931
- const record = decoded;
932
- if (record.version !== "registration_intent_v1") return null;
933
- const walletId = parseWalletId(record.walletId);
934
- const authMethod = normalizeRegistrationAuthMethodInput(record.authMethod);
935
- const signerPlan = parseStoredRegistrationSignerPlan(record.signerSelection);
936
- const foundingWalletAuthMethodId = parseWalletAuthMethodId(record.foundingWalletAuthMethodId);
937
- const nonceB64u = trimString(record.nonceB64u);
938
- if (!walletId.ok || !authMethod || !signerPlan || !foundingWalletAuthMethodId.ok || !nonceB64u) return null;
939
- const signerSelection = registrationSignerSetSelectionFromPlan(signerPlan, { normalizeEcdsaChainTarget: thresholdEcdsaChainTargetFromValue });
940
- if (!signerSelection.ok) return null;
941
- const runtimePolicyScope = Object.prototype.hasOwnProperty.call(record, "runtimePolicyScope") ? parseStoredAddAuthMethodRuntimePolicyScope(record.runtimePolicyScope) : void 0;
942
- if (Object.prototype.hasOwnProperty.call(record, "runtimePolicyScope") && !runtimePolicyScope) return null;
943
- return runtimePolicyScope ? {
944
- version: "registration_intent_v1",
945
- walletId: walletId.value,
946
- authMethod,
947
- signerSelection: signerSelection.value,
948
- foundingWalletAuthMethodId: foundingWalletAuthMethodId.value,
949
- runtimePolicyScope,
950
- nonceB64u
951
- } : {
952
- version: "registration_intent_v1",
953
- walletId: walletId.value,
954
- authMethod,
955
- signerSelection: signerSelection.value,
956
- foundingWalletAuthMethodId: foundingWalletAuthMethodId.value,
957
- nonceB64u
958
- };
959
- }
960
- function parseStoredRegistrationSignerBranchKey(value) {
961
- const branchKey = trimString(value);
962
- if (!branchKey) return null;
963
- try {
964
- return registrationSignerBranchKeyFromString(branchKey);
965
- } catch {
966
- return null;
967
- }
968
- }
969
- function parseStoredRegistrationEcdsaChainTargets(value) {
970
- if (!Array.isArray(value) || value.length === 0) return null;
971
- const chainTargets = [];
972
- const seen = /* @__PURE__ */ new Set();
973
- for (const rawTarget of value) {
974
- const chainTarget = thresholdEcdsaChainTargetFromValue(rawTarget);
975
- if (!chainTarget) return null;
976
- const key = thresholdEcdsaChainTargetKey(chainTarget);
977
- if (seen.has(key)) return null;
978
- seen.add(key);
979
- chainTargets.push(chainTarget);
980
- }
981
- const first = chainTargets[0];
982
- return first ? [first, ...chainTargets.slice(1)] : null;
983
- }
984
- function parseStoredRegistrationEcdsaParticipantPair(value) {
985
- if (!Array.isArray(value) || value.length !== 2 || value[0] !== 1 || value[1] !== 2) return null;
986
- return [1, 2];
987
- }
988
- function parseStoredWalletRegistrationEcdsaPrepare(value) {
989
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
990
- const record = value;
991
- if (record.formatVersion !== "ecdsa-derivation-role-local") return null;
992
- const walletId = trimString(record.walletId);
993
- const evmFamilySigningKeySlotId = trimString(record.evmFamilySigningKeySlotId);
994
- const ecdsaThresholdKeyId = trimString(record.ecdsaThresholdKeyId);
995
- const signingRootId = trimString(record.signingRootId);
996
- const signingRootVersion = trimString(record.signingRootVersion);
997
- const relayerKeyId = trimString(record.relayerKeyId);
998
- const registrationPreparationId = trimString(record.registrationPreparationId);
999
- const requestId = trimString(record.requestId);
1000
- const thresholdSessionId = trimString(record.thresholdSessionId);
1001
- const ttlMs = Number(record.ttlMs);
1002
- const remainingUses = Number(record.remainingUses);
1003
- const participantIds = parseStoredRegistrationEcdsaParticipantPair(record.participantIds);
1004
- const runtimePolicyScope = parseStoredRuntimePolicyScope(record.runtimePolicyScope);
1005
- if (!walletId || !evmFamilySigningKeySlotId || !ecdsaThresholdKeyId || !signingRootId || !signingRootVersion || record.keyScope !== "evm-family" || !relayerKeyId || !registrationPreparationId || !requestId || !thresholdSessionId || !Number.isSafeInteger(ttlMs) || !Number.isSafeInteger(remainingUses) || !participantIds || !runtimePolicyScope) return null;
1006
- try {
1007
- return {
1008
- formatVersion: "ecdsa-derivation-role-local",
1009
- walletId,
1010
- evmFamilySigningKeySlotId,
1011
- ecdsaThresholdKeyId,
1012
- signingRootId,
1013
- signingRootVersion,
1014
- keyScope: "evm-family",
1015
- relayerKeyId,
1016
- registrationPreparationId: registrationPreparationIdFromString(registrationPreparationId),
1017
- requestId,
1018
- thresholdSessionId,
1019
- ttlMs,
1020
- remainingUses,
1021
- participantIds,
1022
- runtimePolicyScope
1023
- };
1024
- } catch {
1025
- return null;
1026
- }
1027
- }
1028
- function parseStoredEcdsaDerivationPublicIdentity(value) {
1029
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
1030
- const record = value;
1031
- const derivationClientSharePublicKey33B64u = trimString(record.derivationClientSharePublicKey33B64u);
1032
- const relayerPublicKey33B64u = trimString(record.relayerPublicKey33B64u);
1033
- const groupPublicKey33B64u = trimString(record.groupPublicKey33B64u);
1034
- const ethereumAddress = trimString(record.ethereumAddress);
1035
- if (!derivationClientSharePublicKey33B64u || !relayerPublicKey33B64u || !groupPublicKey33B64u || !ethereumAddress) return null;
1036
- return parseEcdsaDerivationPublicIdentity({
1037
- derivationClientSharePublicKey33B64u,
1038
- relayerPublicKey33B64u,
1039
- groupPublicKey33B64u,
1040
- ethereumAddress
1041
- });
1042
- }
1043
- function parseStoredEcdsaDerivationServerBootstrapResponse(value) {
1044
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
1045
- const record = value;
1046
- if (record.formatVersion !== "ecdsa-derivation-role-local") return null;
1047
- const publicIdentity = parseStoredEcdsaDerivationPublicIdentity(record.publicIdentity);
1048
- const walletId = trimString(record.walletId);
1049
- const evmFamilySigningKeySlotId = trimString(record.evmFamilySigningKeySlotId);
1050
- const ecdsaThresholdKeyId = trimString(record.ecdsaThresholdKeyId);
1051
- const relayerKeyId = trimString(record.relayerKeyId);
1052
- const applicationBindingDigestB64u = trimString(record.applicationBindingDigestB64u);
1053
- const contextBinding32B64u = trimString(record.contextBinding32B64u);
1054
- const clientShareRetryCounter = Number(record.clientShareRetryCounter);
1055
- const relayerShareRetryCounter = Number(record.relayerShareRetryCounter);
1056
- const publicTranscriptDigest32B64u = trimString(record.publicTranscriptDigest32B64u);
1057
- const keyHandle = trimString(record.keyHandle);
1058
- const signingRootId = trimString(record.signingRootId);
1059
- const signingRootVersion = trimString(record.signingRootVersion);
1060
- const thresholdEcdsaPublicKeyB64u = trimString(record.thresholdEcdsaPublicKeyB64u);
1061
- const ethereumAddress = trimString(record.ethereumAddress);
1062
- const relayerVerifyingShareB64u = trimString(record.relayerVerifyingShareB64u);
1063
- const participantIds = parseStoredRegistrationEcdsaParticipantPair(record.participantIds);
1064
- const thresholdSessionId = trimString(record.thresholdSessionId);
1065
- const activationEpoch = parseRootShareEpoch(record.activationEpoch);
1066
- const expiresAtMs = Number(record.expiresAtMs);
1067
- const expiresAt = trimString(record.expiresAt);
1068
- const remainingUses = Number(record.remainingUses);
1069
- let routerAbEcdsaDerivationNormalSigning;
1070
- try {
1071
- routerAbEcdsaDerivationNormalSigning = parseRouterAbEcdsaDerivationNormalSigningStateV1(record.routerAbEcdsaDerivationNormalSigning);
1072
- } catch {
1073
- return null;
1074
- }
1075
- if (!walletId || !evmFamilySigningKeySlotId || !ecdsaThresholdKeyId || !relayerKeyId || !applicationBindingDigestB64u || !contextBinding32B64u || !publicIdentity || !Number.isSafeInteger(clientShareRetryCounter) || clientShareRetryCounter < 0 || !Number.isSafeInteger(relayerShareRetryCounter) || relayerShareRetryCounter < 0 || !publicTranscriptDigest32B64u || !keyHandle || !signingRootId || !signingRootVersion || !thresholdEcdsaPublicKeyB64u || !ethereumAddress || !relayerVerifyingShareB64u || !participantIds || !thresholdSessionId || !activationEpoch.ok || !Number.isSafeInteger(expiresAtMs) || !expiresAt || !Number.isSafeInteger(remainingUses) || remainingUses < 0 || !routerAbEcdsaDerivationNormalSigning) return null;
1076
- return {
1077
- formatVersion: "ecdsa-derivation-role-local",
1078
- walletId,
1079
- evmFamilySigningKeySlotId,
1080
- ecdsaThresholdKeyId,
1081
- relayerKeyId,
1082
- applicationBindingDigestB64u,
1083
- contextBinding32B64u,
1084
- publicIdentity,
1085
- clientShareRetryCounter,
1086
- relayerShareRetryCounter,
1087
- publicTranscriptDigest32B64u,
1088
- keyHandle,
1089
- signingRootId,
1090
- signingRootVersion,
1091
- thresholdEcdsaPublicKeyB64u,
1092
- ethereumAddress,
1093
- relayerVerifyingShareB64u,
1094
- participantIds: [1, 2],
1095
- thresholdSessionId,
1096
- activationEpoch: activationEpoch.value,
1097
- expiresAtMs,
1098
- expiresAt,
1099
- remainingUses,
1100
- routerAbEcdsaDerivationNormalSigning
1101
- };
1102
- }
1103
- function parseStoredWalletRegistrationEcdsaBranchBase(value) {
1104
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
1105
- const record = value;
1106
- const branchKey = parseStoredRegistrationSignerBranchKey(record.branchKey);
1107
- const chainTargets = parseStoredRegistrationEcdsaChainTargets(record.chainTargets);
1108
- const prepare = parseStoredWalletRegistrationEcdsaPrepare(record.prepare);
1109
- const strictRegistrationBindingJson = trimString(record.strictRegistrationBindingJson);
1110
- if (!branchKey || record.derivationKind !== "evm_family_ecdsa_keygen" || !chainTargets || !prepare || !strictRegistrationBindingJson) return null;
1111
- let strictRegistration;
1112
- try {
1113
- strictRegistration = parseRouterAbEcdsaRegistrationRequestFactsV1(record.strictRegistration);
1114
- } catch {
1115
- return null;
1116
- }
1117
- return strictRegistration.registration_purpose === "wallet_registration" ? {
1118
- branchKey,
1119
- derivationKind: "evm_family_ecdsa_keygen",
1120
- chainTargets,
1121
- prepare,
1122
- strictRegistration,
1123
- strictRegistrationBindingJson
1124
- } : null;
1125
- }
1126
- function parseStoredWalletRegistrationSignerBranch(value) {
1127
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
1128
- const record = value;
1129
- switch (record.kind) {
1130
- case "near_ed25519_yao_authorized": {
1131
- const branchKey = parseStoredRegistrationSignerBranchKey(record.branchKey);
1132
- const admissionRequest = parseRouterAbEd25519YaoRegistrationAdmissionRequestV1(record.admissionRequest);
1133
- return branchKey && admissionRequest.ok ? {
1134
- kind: "near_ed25519_yao_authorized",
1135
- branchKey,
1136
- admissionRequest: admissionRequest.value
1137
- } : null;
1138
- }
1139
- case "evm_family_ecdsa_prepared": {
1140
- const base = parseStoredWalletRegistrationEcdsaBranchBase(record);
1141
- return base ? {
1142
- kind: "evm_family_ecdsa_prepared",
1143
- branchKey: base.branchKey,
1144
- derivationKind: base.derivationKind,
1145
- chainTargets: base.chainTargets,
1146
- prepare: base.prepare,
1147
- strictRegistration: base.strictRegistration,
1148
- strictRegistrationBindingJson: base.strictRegistrationBindingJson
1149
- } : null;
1150
- }
1151
- case "evm_family_ecdsa_response_claimed": {
1152
- const base = parseStoredWalletRegistrationEcdsaBranchBase(record);
1153
- if (!base) return null;
1154
- try {
1155
- const registrationRequest = parseRouterAbEcdsaRegistrationRequestV1(record.registrationRequest);
1156
- return registrationRequest.registration_purpose === "wallet_registration" ? {
1157
- kind: "evm_family_ecdsa_response_claimed",
1158
- branchKey: base.branchKey,
1159
- derivationKind: base.derivationKind,
1160
- chainTargets: base.chainTargets,
1161
- prepare: base.prepare,
1162
- strictRegistration: base.strictRegistration,
1163
- strictRegistrationBindingJson: base.strictRegistrationBindingJson,
1164
- registrationRequest
1165
- } : null;
1166
- } catch {
1167
- return null;
1168
- }
1169
- }
1170
- case "evm_family_ecdsa_pending_activation": {
1171
- const base = parseStoredWalletRegistrationEcdsaBranchBase(record);
1172
- if (!base) return null;
1173
- try {
1174
- const registrationRequest = parseRouterAbEcdsaRegistrationRequestV1(record.registrationRequest);
1175
- const pendingActivation = parseStoredRouterAbEcdsaPendingActivationV1(record.pendingActivation);
1176
- const publicResponse = parseRouterAbEcdsaStrictForwardedRegistrationResponseV1(record.publicResponse);
1177
- return registrationRequest.registration_purpose === "wallet_registration" ? {
1178
- kind: "evm_family_ecdsa_pending_activation",
1179
- branchKey: base.branchKey,
1180
- derivationKind: base.derivationKind,
1181
- chainTargets: base.chainTargets,
1182
- prepare: base.prepare,
1183
- strictRegistration: base.strictRegistration,
1184
- strictRegistrationBindingJson: base.strictRegistrationBindingJson,
1185
- registrationRequest,
1186
- pendingActivation,
1187
- publicResponse
1188
- } : null;
1189
- } catch {
1190
- return null;
1191
- }
1192
- }
1193
- case "evm_family_ecdsa_activation_claimed": {
1194
- const base = parseStoredWalletRegistrationEcdsaBranchBase(record);
1195
- const activationRequestDigestB64u = parseStoredRegistrationDigest(record.activationRequestDigestB64u);
1196
- const activationOwner = trimString(record.activationOwner);
1197
- if (!base || !activationRequestDigestB64u || !activationOwner) return null;
1198
- try {
1199
- const registrationRequest = parseRouterAbEcdsaRegistrationRequestV1(record.registrationRequest);
1200
- const pendingActivation = parseStoredRouterAbEcdsaPendingActivationV1(record.pendingActivation);
1201
- const publicResponse = parseRouterAbEcdsaStrictForwardedRegistrationResponseV1(record.publicResponse);
1202
- const publicFacts = parseRouterAbEcdsaVerifiedClientActivationFactsV1(record.publicFacts);
1203
- return registrationRequest.registration_purpose === "wallet_registration" ? {
1204
- kind: "evm_family_ecdsa_activation_claimed",
1205
- branchKey: base.branchKey,
1206
- derivationKind: base.derivationKind,
1207
- chainTargets: base.chainTargets,
1208
- prepare: base.prepare,
1209
- strictRegistration: base.strictRegistration,
1210
- strictRegistrationBindingJson: base.strictRegistrationBindingJson,
1211
- registrationRequest,
1212
- pendingActivation,
1213
- publicResponse,
1214
- publicFacts,
1215
- activationRequestDigestB64u,
1216
- activationOwner
1217
- } : null;
1218
- } catch {
1219
- return null;
1220
- }
1221
- }
1222
- case "evm_family_ecdsa_activated":
1223
- case "evm_family_ecdsa_finalized": {
1224
- const base = parseStoredWalletRegistrationEcdsaBranchBase(record);
1225
- const bootstrap = parseStoredEcdsaDerivationServerBootstrapResponse(record.bootstrap);
1226
- if (!base || !bootstrap) return null;
1227
- try {
1228
- const registrationRequest = parseRouterAbEcdsaRegistrationRequestV1(record.registrationRequest);
1229
- const publicFacts = parseRouterAbEcdsaVerifiedClientActivationFactsV1(record.publicFacts);
1230
- const activation = parseRouterAbEcdsaRegistrationActivationReceiptV1(record.activation);
1231
- const publicCapability = parseRouterAbEcdsaDerivationPublicCapabilityV1(record.publicCapability);
1232
- if (registrationRequest.registration_purpose !== "wallet_registration") return null;
1233
- if (record.kind === "evm_family_ecdsa_activated") {
1234
- const activationOwner = trimString(record.activationOwner);
1235
- return activationOwner ? {
1236
- kind: "evm_family_ecdsa_activated",
1237
- branchKey: base.branchKey,
1238
- derivationKind: base.derivationKind,
1239
- chainTargets: base.chainTargets,
1240
- prepare: base.prepare,
1241
- strictRegistration: base.strictRegistration,
1242
- strictRegistrationBindingJson: base.strictRegistrationBindingJson,
1243
- registrationRequest,
1244
- publicFacts,
1245
- activation,
1246
- publicCapability,
1247
- bootstrap,
1248
- activationOwner
1249
- } : null;
1250
- }
1251
- const finalizedAtMs = Number(record.finalizedAtMs);
1252
- return Number.isSafeInteger(finalizedAtMs) && finalizedAtMs > 0 ? {
1253
- kind: "evm_family_ecdsa_finalized",
1254
- branchKey: base.branchKey,
1255
- derivationKind: base.derivationKind,
1256
- chainTargets: base.chainTargets,
1257
- prepare: base.prepare,
1258
- strictRegistration: base.strictRegistration,
1259
- strictRegistrationBindingJson: base.strictRegistrationBindingJson,
1260
- registrationRequest,
1261
- publicFacts,
1262
- activation,
1263
- publicCapability,
1264
- bootstrap,
1265
- finalizedAtMs
1266
- } : null;
1267
- } catch {
1268
- return null;
1269
- }
1270
- }
1271
- default: return null;
1272
- }
1273
- }
1274
- function parseStoredWalletRegistrationSignerState(value) {
1275
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
1276
- const record = value;
1277
- if (record.kind === "signer_set_registration") {
1278
- if (!Array.isArray(record.branches)) return null;
1279
- const branches = [];
1280
- for (const rawBranch of record.branches) {
1281
- const branch = parseStoredWalletRegistrationSignerBranch(rawBranch);
1282
- if (!branch) return null;
1283
- branches.push(branch);
1284
- }
1285
- return {
1286
- kind: "signer_set_registration",
1287
- branches
1288
- };
1289
- }
1290
- if (record.kind !== "registration_failed") return null;
1291
- const failedAtMs = Number(record.failedAtMs);
1292
- if (!Number.isSafeInteger(failedAtMs) || failedAtMs <= 0 || record.failure === null || typeof record.failure !== "object" || Array.isArray(record.failure)) return null;
1293
- const failure = record.failure;
1294
- const code = trimString(failure.code);
1295
- const message = trimString(failure.message);
1296
- return code && message ? {
1297
- kind: "registration_failed",
1298
- failedAtMs,
1299
- failure: {
1300
- code,
1301
- message
1302
- }
1303
- } : null;
1304
- }
1305
- function parseStoredRegistrationDigest(value) {
1306
- try {
1307
- return parseDigestB64u(value);
1308
- } catch {
1309
- return null;
1310
- }
1311
- }
1312
- function parseStoredWalletRegistrationCeremony(value) {
1313
- const decoded = parseJsonValue(value);
1314
- if (decoded === null || typeof decoded !== "object" || Array.isArray(decoded)) return null;
1315
- const record = decoded;
1316
- const registrationCeremonyId = trimString(record.registrationCeremonyId);
1317
- const foundingWalletAuthorityId = parseWalletAuthorityId(record.foundingWalletAuthorityId);
1318
- const foundingDeviceId = parseDeviceId(record.foundingDeviceId);
1319
- const foundingWalletAuthMethodId = parseWalletAuthMethodId(record.foundingWalletAuthMethodId);
1320
- const intent = parseStoredRegistrationIntent(record.intent);
1321
- const digestB64u = trimString(record.digestB64u);
1322
- const signerPlan = parseStoredRegistrationSignerPlan(record.signerPlan);
1323
- const preparedContext = parseStoredWalletRegistrationPreparedContext(record.preparedContext);
1324
- const orgId = trimString(record.orgId);
1325
- const signingRootId = trimString(record.signingRootId);
1326
- const signingRootVersion = trimString(record.signingRootVersion);
1327
- const expectedOrigin = trimString(record.expectedOrigin);
1328
- const expiresAtMs = Number(record.expiresAtMs);
1329
- const authorityState = parseStoredWalletRegistrationCeremonyAuthorityState(record.authorityState);
1330
- const signerState = parseStoredWalletRegistrationSignerState(record.signerState);
1331
- const intentSignerPlan = intent ? parseStoredRegistrationSignerPlan(intent.signerSelection) : null;
1332
- if (!registrationCeremonyId || !authorityState || !foundingWalletAuthorityId.ok || !foundingDeviceId.ok || !foundingWalletAuthMethodId.ok || !intent || !digestB64u || !orgId || !Number.isSafeInteger(expiresAtMs) || !signerPlan || !preparedContext || !intentSignerPlan || !storedRegistrationSignerPlansMatch(signerPlan, intentSignerPlan) || signingRootId && preparedContext.signingRootId !== signingRootId || signingRootVersion && preparedContext.signingRootVersion !== signingRootVersion || !signerState) return null;
1333
- return {
1334
- registrationCeremonyId,
1335
- foundingWalletAuthorityId: foundingWalletAuthorityId.value,
1336
- foundingDeviceId: foundingDeviceId.value,
1337
- foundingWalletAuthMethodId: foundingWalletAuthMethodId.value,
1338
- intent,
1339
- digestB64u,
1340
- signerPlan,
1341
- preparedContext,
1342
- orgId,
1343
- ...signingRootId ? { signingRootId } : {},
1344
- ...signingRootVersion ? { signingRootVersion } : {},
1345
- ...expectedOrigin ? { expectedOrigin } : {},
1346
- expiresAtMs,
1347
- authorityState,
1348
- signerState
1349
- };
1350
- }
1351
- function parseStoredWalletRegistrationCeremonyAuthorityState(value) {
1352
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
1353
- const record = value;
1354
- switch (record.kind) {
1355
- case "awaiting_proof": {
1356
- const authMethod = parseStoredRegistrationCeremonyAuthMethod(record.authMethod);
1357
- return authMethod ? {
1358
- kind: "awaiting_proof",
1359
- authMethod
1360
- } : null;
1361
- }
1362
- case "verified": {
1363
- const authority = parseStoredRegistrationAuthority(record.authority);
1364
- return authority ? {
1365
- kind: "verified",
1366
- authority
1367
- } : null;
1368
- }
1369
- default: return null;
1370
- }
1371
- }
1372
- function parseStoredRegistrationCeremonyAuthMethod(value) {
1373
- return normalizeRegistrationAuthMethodInput(parseJsonValue(value));
1374
- }
1375
- function parseStoredWalletAddSignerAuth(value) {
1376
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
1377
- const record = value;
1378
- if (record.kind !== "webauthn_assertion") return null;
1379
- const rpId = parseWebAuthnRpId(record.rpId);
1380
- const credentialIdB64u = parseWebAuthnCredentialIdB64u(record.credentialIdB64u);
1381
- return rpId.ok && credentialIdB64u.ok ? {
1382
- kind: "webauthn_assertion",
1383
- rpId: rpId.value,
1384
- credentialIdB64u: credentialIdB64u.value
1385
- } : null;
1386
- }
1387
- function parseStoredWalletAddSignerEcdsaStateBase(value) {
1388
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
1389
- const record = value;
1390
- const chainTargets = parseStoredRegistrationEcdsaChainTargets(record.chainTargets);
1391
- const prepare = parseStoredWalletRegistrationEcdsaPrepare(record.prepare);
1392
- if (record.derivationKind !== "evm_family_ecdsa_keygen" || !chainTargets || !prepare) return null;
1393
- let strictRegistration;
1394
- try {
1395
- strictRegistration = parseRouterAbEcdsaRegistrationRequestFactsV1(record.strictRegistration);
1396
- } catch {
1397
- return null;
1398
- }
1399
- return strictRegistration.registration_purpose === "wallet_add_signer" ? {
1400
- derivationKind: "evm_family_ecdsa_keygen",
1401
- chainTargets,
1402
- prepare,
1403
- strictRegistration
1404
- } : null;
1405
- }
1406
- function parseStoredWalletAddSignerNearActivation(value) {
1407
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
1408
- const record = value;
1409
- if (record.finalizeRequest === null || typeof record.finalizeRequest !== "object" || Array.isArray(record.finalizeRequest) || record.activation === null || typeof record.activation !== "object" || Array.isArray(record.activation)) return null;
1410
- const finalizeRequest = parseStoredWalletAddSignerFinalizeRequest(record.finalizeRequest);
1411
- const activation = record.activation;
1412
- const admissionRequest = parseRouterAbEd25519YaoRegistrationAdmissionRequestV1(activation.admissionRequest);
1413
- const admissionReceipt = parseRouterAbEd25519YaoRegistrationActivationAdmissionReceiptV1(activation.admissionReceipt);
1414
- const result = parseRouterAbEd25519YaoRegistrationActivationResultV1(activation.result);
1415
- if (!finalizeRequest || finalizeRequest.kind !== "near_ed25519" || !admissionRequest.ok || !admissionReceipt.ok || !result.ok) return null;
1416
- const { lifecycleId, sessionId } = finalizeRequest.activationReference;
1417
- if (lifecycleId !== admissionRequest.value.scope.lifecycle_id || !storedWalletAddSignerByteArraysEqual(sessionId, admissionReceipt.value.binding.session_id) || !storedWalletAddSignerByteArraysEqual(sessionId, result.value.binding.session_id)) return null;
1418
- return {
1419
- finalizeRequest,
1420
- activation: {
1421
- admissionRequest: admissionRequest.value,
1422
- admissionReceipt: admissionReceipt.value,
1423
- result: result.value
1424
- }
1425
- };
1426
- }
1427
- function parseStoredWalletAddSignerSignerState(value) {
1428
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
1429
- const record = value;
1430
- switch (record.kind) {
1431
- case "near_ed25519_yao_add_signer_authorized": {
1432
- const admissionRequest = parseRouterAbEd25519YaoRegistrationAdmissionRequestV1(record.admissionRequest);
1433
- return admissionRequest.ok ? {
1434
- kind: "near_ed25519_yao_add_signer_authorized",
1435
- admissionRequest: admissionRequest.value
1436
- } : null;
1437
- }
1438
- case "near_ed25519_yao_add_signer_activated": {
1439
- const activation = parseStoredWalletAddSignerNearActivation(record);
1440
- return activation ? {
1441
- kind: "near_ed25519_yao_add_signer_activated",
1442
- finalizeRequest: activation.finalizeRequest,
1443
- activation: activation.activation
1444
- } : null;
1445
- }
1446
- case "near_ed25519_yao_add_signer_finalizing": {
1447
- const activation = parseStoredWalletAddSignerNearActivation(record);
1448
- const response = parseStoredWalletAddSignerFinalizeSuccess(record.response);
1449
- if (!activation || !response || response.kind !== "near_ed25519") return null;
1450
- const signer = parseWalletEd25519SignerRecord(record.signer);
1451
- const finalizingAtMs = Number(record.finalizingAtMs);
1452
- return signer && Number.isSafeInteger(finalizingAtMs) && finalizingAtMs > 0 ? {
1453
- kind: "near_ed25519_yao_add_signer_finalizing",
1454
- finalizeRequest: activation.finalizeRequest,
1455
- activation: activation.activation,
1456
- response,
1457
- signer,
1458
- finalizingAtMs
1459
- } : null;
1460
- }
1461
- case "ecdsa_add_signer_prepared": {
1462
- const base = parseStoredWalletAddSignerEcdsaStateBase(record);
1463
- return base ? {
1464
- kind: "ecdsa_add_signer_prepared",
1465
- derivationKind: base.derivationKind,
1466
- chainTargets: base.chainTargets,
1467
- prepare: base.prepare,
1468
- strictRegistration: base.strictRegistration
1469
- } : null;
1470
- }
1471
- case "ecdsa_add_signer_pending_activation": {
1472
- const base = parseStoredWalletAddSignerEcdsaStateBase(record);
1473
- if (!base) return null;
1474
- try {
1475
- const registrationRequest = parseRouterAbEcdsaRegistrationRequestV1(record.registrationRequest);
1476
- const pendingActivation = parseStoredRouterAbEcdsaPendingActivationV1(record.pendingActivation);
1477
- const publicResponse = parseRouterAbEcdsaStrictForwardedRegistrationResponseV1(record.publicResponse);
1478
- return registrationRequest.registration_purpose === "wallet_add_signer" ? {
1479
- kind: "ecdsa_add_signer_pending_activation",
1480
- derivationKind: base.derivationKind,
1481
- chainTargets: base.chainTargets,
1482
- prepare: base.prepare,
1483
- strictRegistration: base.strictRegistration,
1484
- registrationRequest,
1485
- pendingActivation,
1486
- publicResponse
1487
- } : null;
1488
- } catch {
1489
- return null;
1490
- }
1491
- }
1492
- case "ecdsa_add_signer_activation_claimed": {
1493
- const base = parseStoredWalletAddSignerEcdsaStateBase(record);
1494
- const activationRequestDigestB64u = parseStoredRegistrationDigest(record.activationRequestDigestB64u);
1495
- if (!base || !activationRequestDigestB64u) return null;
1496
- try {
1497
- const registrationRequest = parseRouterAbEcdsaRegistrationRequestV1(record.registrationRequest);
1498
- const pendingActivation = parseStoredRouterAbEcdsaPendingActivationV1(record.pendingActivation);
1499
- const publicResponse = parseRouterAbEcdsaStrictForwardedRegistrationResponseV1(record.publicResponse);
1500
- const publicFacts = parseRouterAbEcdsaVerifiedClientActivationFactsV1(record.publicFacts);
1501
- return registrationRequest.registration_purpose === "wallet_add_signer" ? {
1502
- kind: "ecdsa_add_signer_activation_claimed",
1503
- derivationKind: base.derivationKind,
1504
- chainTargets: base.chainTargets,
1505
- prepare: base.prepare,
1506
- strictRegistration: base.strictRegistration,
1507
- registrationRequest,
1508
- pendingActivation,
1509
- publicResponse,
1510
- publicFacts,
1511
- activationRequestDigestB64u
1512
- } : null;
1513
- } catch {
1514
- return null;
1515
- }
1516
- }
1517
- case "ecdsa_add_signer_activated": {
1518
- const base = parseStoredWalletAddSignerEcdsaStateBase(record);
1519
- const activationRequestDigestB64u = parseStoredRegistrationDigest(record.activationRequestDigestB64u);
1520
- const bootstrap = parseStoredEcdsaDerivationServerBootstrapResponse(record.bootstrap);
1521
- if (!base || !activationRequestDigestB64u || !bootstrap) return null;
1522
- try {
1523
- const registrationRequest = parseRouterAbEcdsaRegistrationRequestV1(record.registrationRequest);
1524
- const publicFacts = parseRouterAbEcdsaVerifiedClientActivationFactsV1(record.publicFacts);
1525
- const activation = parseRouterAbEcdsaRegistrationActivationReceiptV1(record.activation);
1526
- const publicCapability = parseRouterAbEcdsaDerivationPublicCapabilityV1(record.publicCapability);
1527
- return registrationRequest.registration_purpose === "wallet_add_signer" ? {
1528
- kind: "ecdsa_add_signer_activated",
1529
- derivationKind: base.derivationKind,
1530
- chainTargets: base.chainTargets,
1531
- prepare: base.prepare,
1532
- strictRegistration: base.strictRegistration,
1533
- registrationRequest,
1534
- publicFacts,
1535
- activationRequestDigestB64u,
1536
- activation,
1537
- publicCapability,
1538
- bootstrap
1539
- } : null;
1540
- } catch {
1541
- return null;
1542
- }
1543
- }
1544
- default: return null;
1545
- }
1546
- }
1547
- function storedWalletAddSignerByteArraysEqual(left, right) {
1548
- return left.length === right.length && left.every((byte, index) => byte === right[index]);
1549
- }
1550
- function parseStoredWalletAddSignerCeremony(value) {
1551
- const decoded = parseJsonValue(value);
1552
- if (decoded === null || typeof decoded !== "object" || Array.isArray(decoded)) return null;
1553
- const record = decoded;
1554
- const addSignerCeremonyId = trimString(record.addSignerCeremonyId);
1555
- const digestB64u = trimString(record.digestB64u);
1556
- const orgId = trimString(record.orgId);
1557
- const signingRootId = trimString(record.signingRootId);
1558
- const signingRootVersion = trimString(record.signingRootVersion);
1559
- const expiresAtMs = Number(record.expiresAtMs);
1560
- const intentRecord = parseStoredAddSignerIntent({
1561
- kind: "add_signer_intent_allocated",
1562
- grant: "ignored",
1563
- intent: record.intent,
1564
- digestB64u,
1565
- orgId,
1566
- expiresAtMs
1567
- });
1568
- const auth = parseStoredWalletAddSignerAuth(record.auth);
1569
- const signerState = parseStoredWalletAddSignerSignerState(record.signerState);
1570
- if (!addSignerCeremonyId || !digestB64u || !orgId || !signingRootId || !signingRootVersion || !Number.isSafeInteger(expiresAtMs) || !intentRecord || !auth || !signerState) return null;
1571
- if ((signerState.kind === "near_ed25519_yao_add_signer_activated" || signerState.kind === "near_ed25519_yao_add_signer_finalizing") && signerState.finalizeRequest.addSignerCeremonyId !== addSignerCeremonyId) return null;
1572
- return {
1573
- addSignerCeremonyId,
1574
- intent: intentRecord.intent,
1575
- digestB64u,
1576
- orgId,
1577
- signingRootId,
1578
- signingRootVersion,
1579
- expiresAtMs,
1580
- auth,
1581
- signerState
1582
- };
1583
- }
1584
- function parseStoredWalletAddAuthMethodCeremonyAuth(value) {
1585
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
1586
- const record = value;
1587
- if (record.kind === "email_otp") {
1588
- const providerUserId = trimString(record.providerUserId);
1589
- const enrollmentId = trimString(record.enrollmentId);
1590
- const enrollmentSealKeyVersion = trimString(record.enrollmentSealKeyVersion);
1591
- const authorityRef = parseWalletAuthAuthorityRef(record.authorityRef);
1592
- if (!providerUserId || !enrollmentId || !enrollmentSealKeyVersion || !authorityRef) return null;
1593
- return {
1594
- kind: "email_otp",
1595
- providerUserId,
1596
- enrollmentId,
1597
- enrollmentSealKeyVersion,
1598
- authorityRef
1599
- };
1600
- }
1601
- if (record.kind === "wallet_session") {
1602
- const walletSessionId = trimString(record.walletSessionId);
1603
- const authorizationId = trimString(record.authorizationId);
1604
- const rpId = trimString(record.rpId);
1605
- const credentialIdB64u = trimString(record.credentialIdB64u);
1606
- if (!walletSessionId || !authorizationId || !rpId || !credentialIdB64u) return null;
1607
- return {
1608
- kind: "wallet_session",
1609
- walletSessionId,
1610
- authorizationId,
1611
- rpId,
1612
- credentialIdB64u
1613
- };
1614
- }
1615
- if (record.kind !== "webauthn_assertion") return null;
1616
- const rpId = trimString(record.rpId);
1617
- const credentialIdB64u = trimString(record.credentialIdB64u);
1618
- if (!rpId || !credentialIdB64u) return null;
1619
- return {
1620
- kind: "webauthn_assertion",
1621
- rpId,
1622
- credentialIdB64u
1623
- };
1624
- }
1625
- function addAuthMethodCustodyFactorMatches(auth, custodyEnvelope) {
1626
- switch (auth.kind) {
1627
- case "webauthn_assertion":
1628
- case "wallet_session": return custodyEnvelope.factor.kind === "passkey" && custodyEnvelope.factor.rpId === auth.rpId && custodyEnvelope.factor.credentialIdB64u === auth.credentialIdB64u;
1629
- case "email_otp": return custodyEnvelope.factor.kind === "email_otp" && custodyEnvelope.factor.enrollmentId === auth.enrollmentId && custodyEnvelope.factor.enrollmentSealKeyVersion === auth.enrollmentSealKeyVersion;
1630
- default: return assertNever(auth);
1631
- }
1632
- }
1633
- /**
1634
- * Nullable wrapper over the canonical parser. Reading these options a second,
1635
- * looser way here is what would let a stored ceremony and a live one disagree.
1636
- */
1637
- function parseStoredWalletAddAuthMethodRegistrationOptions(value) {
1638
- try {
1639
- return parseWalletAddAuthMethodRegistrationOptions(value);
1640
- } catch {
1641
- return null;
1642
- }
1643
- }
1644
- function parseStoredWalletAddAuthMethodCeremony(value) {
1645
- const decoded = parseJsonValue(value);
1646
- if (decoded === null || typeof decoded !== "object" || Array.isArray(decoded)) return null;
1647
- const record = decoded;
1648
- const addAuthMethodCeremonyId = trimString(record.addAuthMethodCeremonyId);
1649
- const digestB64u = trimString(record.digestB64u);
1650
- const orgId = trimString(record.orgId);
1651
- const expiresAtMs = Number(record.expiresAtMs);
1652
- const sourceWalletAuthMethodId = parseWalletAuthMethodId(record.sourceWalletAuthMethodId);
1653
- const sourceWalletAuthorityId = parseWalletAuthorityId(record.sourceWalletAuthorityId);
1654
- const targetWalletAuthMethodId = parseWalletAuthMethodId(record.targetWalletAuthMethodId);
1655
- let sourceAuthorityDigestB64u;
1656
- try {
1657
- sourceAuthorityDigestB64u = parseDigestB64u(record.sourceAuthorityDigestB64u);
1658
- } catch {
1659
- return null;
1660
- }
1661
- const sourceAuthorityRevocationEpoch = Number(record.sourceAuthorityRevocationEpoch);
1662
- if (!addAuthMethodCeremonyId || !digestB64u || !orgId || !Number.isSafeInteger(expiresAtMs) || !sourceWalletAuthMethodId.ok || !sourceWalletAuthorityId.ok || !Number.isSafeInteger(sourceAuthorityRevocationEpoch) || sourceAuthorityRevocationEpoch < 0 || !targetWalletAuthMethodId.ok) return null;
1663
- const auth = parseStoredWalletAddAuthMethodCeremonyAuth(record.auth);
1664
- const intentRecord = parseStoredAddAuthMethodIntent({
1665
- kind: "add_auth_method_intent_allocated",
1666
- grant: "ignored",
1667
- intent: record.intent,
1668
- digestB64u,
1669
- orgId,
1670
- expiresAtMs
1671
- });
1672
- if (!auth || !intentRecord) return null;
1673
- let custodyEnvelope;
1674
- try {
1675
- custodyEnvelope = parsePasskeyCustodyEnvelopeRecord(record.custodyEnvelope);
1676
- } catch {
1677
- return null;
1678
- }
1679
- if (custodyEnvelope.walletId !== intentRecord.intent.walletId || !addAuthMethodCustodyFactorMatches(auth, custodyEnvelope) || custodyEnvelope.lifecycle.state !== "active") return null;
1680
- const kind = record.kind;
1681
- if (kind === "email_otp") {
1682
- const authority = parseStoredRegistrationAuthority(record.authority);
1683
- if (!authority || authority.kind !== "email_otp") return null;
1684
- return {
1685
- kind: "email_otp",
1686
- custodyEnvelope,
1687
- addAuthMethodCeremonyId,
1688
- intent: intentRecord.intent,
1689
- digestB64u,
1690
- orgId,
1691
- sourceWalletAuthMethodId: sourceWalletAuthMethodId.value,
1692
- sourceWalletAuthorityId: sourceWalletAuthorityId.value,
1693
- sourceAuthorityDigestB64u,
1694
- sourceAuthorityRevocationEpoch,
1695
- targetWalletAuthMethodId: targetWalletAuthMethodId.value,
1696
- expiresAtMs: Math.floor(expiresAtMs),
1697
- auth,
1698
- authority,
1699
- ...trimString(record.expectedOrigin) ? { expectedOrigin: trimString(record.expectedOrigin) } : {}
1700
- };
1701
- }
1702
- if (kind !== "passkey" || record.passkeyRegistration === null || typeof record.passkeyRegistration !== "object" || Array.isArray(record.passkeyRegistration)) return null;
1703
- const passkeyRegistration = record.passkeyRegistration;
1704
- const rpId = parseWebAuthnRpId(passkeyRegistration.rpId);
1705
- const challengeB64u = trimString(passkeyRegistration.challengeB64u);
1706
- const options = parseStoredWalletAddAuthMethodRegistrationOptions(passkeyRegistration.options);
1707
- if (!rpId.ok || !challengeB64u || !options || options.rpId !== rpId.value || options.challengeB64u !== challengeB64u || intentRecord.intent.authMethod.kind !== "passkey" || intentRecord.intent.authMethod.rpId !== rpId.value) return null;
1708
- return {
1709
- kind: "passkey",
1710
- addAuthMethodCeremonyId,
1711
- intent: intentRecord.intent,
1712
- digestB64u,
1713
- orgId,
1714
- sourceWalletAuthMethodId: sourceWalletAuthMethodId.value,
1715
- sourceWalletAuthorityId: sourceWalletAuthorityId.value,
1716
- sourceAuthorityDigestB64u,
1717
- sourceAuthorityRevocationEpoch,
1718
- targetWalletAuthMethodId: targetWalletAuthMethodId.value,
1719
- expiresAtMs: Math.floor(expiresAtMs),
1720
- auth,
1721
- passkeyRegistration: {
1722
- rpId: rpId.value,
1723
- challengeB64u,
1724
- options
1725
- },
1726
- custodyEnvelope,
1727
- ...trimString(record.expectedOrigin) ? { expectedOrigin: trimString(record.expectedOrigin) } : {}
1728
- };
1729
- }
1730
- function isDurableObjectNamespaceLike(value) {
1731
- if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
1732
- return "idFromName" in value && typeof value.idFromName === "function" && "get" in value && typeof value.get === "function";
1733
- }
1734
- function resolveDoNamespaceFromConfig(config) {
1735
- const direct = config.namespace;
1736
- if (isDurableObjectNamespaceLike(direct)) return direct;
1737
- const durableObjectNamespace = config.durableObjectNamespace;
1738
- if (isDurableObjectNamespaceLike(durableObjectNamespace)) return durableObjectNamespace;
1739
- const envStyle = config.THRESHOLD_DO_NAMESPACE;
1740
- if (isDurableObjectNamespaceLike(envStyle)) return envStyle;
1741
- return null;
1742
- }
1743
- function resolveDoStub(input) {
1744
- const id = input.namespace.idFromName(input.objectName);
1745
- return input.namespace.get(id);
1746
- }
1747
- async function callDo(stub, request) {
1748
- const response = await stub.fetch("https://threshold-store.invalid/", {
1749
- method: "POST",
1750
- headers: { "content-type": "application/json" },
1751
- body: JSON.stringify(request)
1752
- });
1753
- const text = await response.text();
1754
- if (!response.ok) throw new Error(`Registration ceremony DO store HTTP ${response.status}: ${text}`);
1755
- let json;
1756
- try {
1757
- json = text ? JSON.parse(text) : null;
1758
- } catch {
1759
- throw new Error(`Registration ceremony DO store returned non-JSON response: ${text.slice(0, 200)}`);
1760
- }
1761
- if (json === null || typeof json !== "object" || Array.isArray(json)) throw new Error("Registration ceremony DO store returned invalid JSON shape");
1762
- const responseKeys = Reflect.ownKeys(json);
1763
- if (Reflect.get(json, "ok") === true && responseKeys.length === 2 && responseKeys.includes("ok") && responseKeys.includes("value")) return {
1764
- ok: true,
1765
- value: Reflect.get(json, "value")
1766
- };
1767
- if (Reflect.get(json, "ok") !== false || responseKeys.length !== 3 || !responseKeys.includes("ok") || !responseKeys.includes("code") || !responseKeys.includes("message")) throw new Error("Registration ceremony DO store returned invalid JSON shape");
1768
- const code = trimString(Reflect.get(json, "code"));
1769
- const message = trimString(Reflect.get(json, "message"));
1770
- return {
1771
- ok: false,
1772
- code: code || "internal",
1773
- message: message || "Registration ceremony DO store error"
1774
- };
1775
- }
1776
- var CloudflareDurableObjectRegistrationCeremonyStore = class {
1777
- constructor(input) {
1778
- this.stub = resolveDoStub({
1779
- namespace: input.namespace,
1780
- objectName: input.objectName
1781
- });
1782
- this.prefix = input.prefix;
1783
- }
1784
- key(scope, id) {
1785
- return `${this.prefix}${scope}:${id}`;
1786
- }
1787
- async putAddSignerIntent(intent) {
1788
- const parsed = parseStoredAddSignerIntent(intent);
1789
- if (!parsed) throw new Error("Invalid add-signer intent record");
1790
- const ttlMs = Math.max(1, parsed.expiresAtMs - Date.now());
1791
- const response = await callDo(this.stub, {
1792
- op: "set",
1793
- key: this.key("add-signer-intent", parsed.grant),
1794
- value: parsed,
1795
- ttlMs
1796
- });
1797
- if (!response.ok) throw new Error(response.message);
1798
- }
1799
- async getAddSignerIntent(grant) {
1800
- const key = trimString(grant);
1801
- if (!key) return null;
1802
- const response = await callDo(this.stub, {
1803
- op: "get",
1804
- key: this.key("add-signer-intent", key)
1805
- });
1806
- if (!response.ok) return null;
1807
- const intent = parseStoredAddSignerIntent(response.value);
1808
- if (!intent || intent.expiresAtMs <= Date.now()) return null;
1809
- return intent;
1810
- }
1811
- async takeAddSignerIntent(grant) {
1812
- const key = trimString(grant);
1813
- if (!key) return null;
1814
- const response = await callDo(this.stub, {
1815
- op: "getdel",
1816
- key: this.key("add-signer-intent", key)
1817
- });
1818
- if (!response.ok) return null;
1819
- const intent = parseStoredAddSignerIntent(response.value);
1820
- if (!intent || intent.expiresAtMs <= Date.now()) return null;
1821
- return {
1822
- ...intent,
1823
- kind: "add_signer_intent_consumed",
1824
- consumedAtMs: Date.now()
1825
- };
1826
- }
1827
- async putAddAuthMethodIntent(intent) {
1828
- const parsed = parseStoredAddAuthMethodIntent(intent);
1829
- if (!parsed) throw new Error("Invalid add-auth-method intent record");
1830
- const ttlMs = Math.max(1, parsed.expiresAtMs - Date.now());
1831
- const response = await callDo(this.stub, {
1832
- op: "set",
1833
- key: this.key("add-auth-method-intent", parsed.grant),
1834
- value: parsed,
1835
- ttlMs
1836
- });
1837
- if (!response.ok) throw new Error(response.message);
1838
- }
1839
- async getAddAuthMethodIntent(grant) {
1840
- const key = trimString(grant);
1841
- if (!key) return null;
1842
- const response = await callDo(this.stub, {
1843
- op: "get",
1844
- key: this.key("add-auth-method-intent", key)
1845
- });
1846
- if (!response.ok) return null;
1847
- const intent = parseStoredAddAuthMethodIntent(response.value);
1848
- if (!intent || intent.expiresAtMs <= Date.now()) return null;
1849
- return intent;
1850
- }
1851
- async takeAddAuthMethodIntent(grant) {
1852
- const key = trimString(grant);
1853
- if (!key) return null;
1854
- const response = await callDo(this.stub, {
1855
- op: "getdel",
1856
- key: this.key("add-auth-method-intent", key)
1857
- });
1858
- if (!response.ok) return null;
1859
- const intent = parseStoredAddAuthMethodIntent(response.value);
1860
- if (!intent || intent.expiresAtMs <= Date.now()) return null;
1861
- return {
1862
- ...intent,
1863
- kind: "add_auth_method_intent_consumed",
1864
- consumedAtMs: Date.now()
1865
- };
1866
- }
1867
- async putCeremony(ceremony) {
1868
- const parsed = parseStoredWalletRegistrationCeremony(ceremony);
1869
- if (!parsed) throw new Error("Invalid registration ceremony record");
1870
- const ttlMs = Math.max(1, parsed.expiresAtMs - Date.now());
1871
- const response = await callDo(this.stub, {
1872
- op: "set",
1873
- key: this.key("ceremony", parsed.registrationCeremonyId),
1874
- value: parsed,
1875
- ttlMs
1876
- });
1877
- if (!response.ok) throw new Error(response.message);
1878
- }
1879
- async getCeremony(registrationCeremonyId) {
1880
- const key = trimString(registrationCeremonyId);
1881
- if (!key) return null;
1882
- const response = await callDo(this.stub, {
1883
- op: "get",
1884
- key: this.key("ceremony", key)
1885
- });
1886
- if (!response.ok) return null;
1887
- const ceremony = parseStoredWalletRegistrationCeremony(response.value);
1888
- if (!ceremony || ceremony.expiresAtMs <= Date.now()) return null;
1889
- return ceremony;
1890
- }
1891
- async updateCeremony(ceremony) {
1892
- const parsed = parseStoredWalletRegistrationCeremony(ceremony);
1893
- if (!parsed) throw new Error("Invalid registration ceremony record");
1894
- if (parsed.expiresAtMs <= Date.now()) return;
1895
- const ttlMs = Math.max(1, parsed.expiresAtMs - Date.now());
1896
- const response = await callDo(this.stub, {
1897
- op: "set",
1898
- key: this.key("ceremony", parsed.registrationCeremonyId),
1899
- value: parsed,
1900
- ttlMs
1901
- });
1902
- if (!response.ok) throw new Error(response.message);
1903
- }
1904
- async takeCeremony(registrationCeremonyId) {
1905
- const key = trimString(registrationCeremonyId);
1906
- if (!key) return null;
1907
- const response = await callDo(this.stub, {
1908
- op: "getdel",
1909
- key: this.key("ceremony", key)
1910
- });
1911
- if (!response.ok) return null;
1912
- const ceremony = parseStoredWalletRegistrationCeremony(response.value);
1913
- if (!ceremony || ceremony.expiresAtMs <= Date.now()) return null;
1914
- return ceremony;
1915
- }
1916
- async cancelTerminalCeremony(input) {
1917
- const registrationCeremonyId = trimString(input.registrationCeremonyId);
1918
- const walletId = trimString(input.walletId);
1919
- if (!registrationCeremonyId || !walletId) throw new Error("Terminal registration cancellation requires ceremony and wallet IDs");
1920
- const response = await callDo(this.stub, {
1921
- op: "registrationCancelTerminal",
1922
- ceremonyKey: this.key("ceremony", registrationCeremonyId),
1923
- registrationCeremonyId,
1924
- walletId
1925
- });
1926
- if (!response.ok) throw new Error(response.message);
1927
- const result = parseTerminalRegistrationCeremonyCancellationResult(response.value);
1928
- if (!result) throw new Error("Terminal registration cancellation returned an invalid result");
1929
- return result;
1930
- }
1931
- async putAddSignerFinalizeReplay(replay) {
1932
- const parsed = parseStoredWalletAddSignerFinalizeReplay(replay);
1933
- if (!parsed) throw new Error("Invalid wallet add-signer finalize replay record");
1934
- const ttlMs = Math.max(1, parsed.expiresAtMs - Date.now());
1935
- const response = await callDo(this.stub, {
1936
- op: "set",
1937
- key: this.key("add-signer-finalize-replay", addSignerFinalizeReplayKey(parsed)),
1938
- value: parsed,
1939
- ttlMs
1940
- });
1941
- if (!response.ok) throw new Error(response.message);
1942
- const claimResponse = await callDo(this.stub, {
1943
- op: "set",
1944
- key: this.key("add-signer-finalize-claim", parsed.addSignerCeremonyId),
1945
- value: parsed,
1946
- ttlMs
1947
- });
1948
- if (!claimResponse.ok) throw new Error(claimResponse.message);
1949
- }
1950
- async getAddSignerFinalizeReplay(input) {
1951
- if (!trimString(input.addSignerCeremonyId) || !trimString(input.idempotencyKey)) return null;
1952
- const response = await callDo(this.stub, {
1953
- op: "get",
1954
- key: this.key("add-signer-finalize-replay", addSignerFinalizeReplayKey(input))
1955
- });
1956
- if (!response.ok) return null;
1957
- const replay = parseStoredWalletAddSignerFinalizeReplay(response.value);
1958
- if (!replay || replay.expiresAtMs <= Date.now()) return null;
1959
- return replay;
1960
- }
1961
- async getAddSignerFinalizeReplayForCeremony(addSignerCeremonyId) {
1962
- const ceremonyId = trimString(addSignerCeremonyId);
1963
- if (!ceremonyId) return null;
1964
- const response = await callDo(this.stub, {
1965
- op: "get",
1966
- key: this.key("add-signer-finalize-claim", ceremonyId)
1967
- });
1968
- if (!response.ok) return null;
1969
- const replay = parseStoredWalletAddSignerFinalizeReplay(response.value);
1970
- if (!replay || replay.expiresAtMs <= Date.now()) return null;
1971
- return replay;
1972
- }
1973
- async putAddAuthMethodCeremony(ceremony) {
1974
- const parsed = parseStoredWalletAddAuthMethodCeremony(ceremony);
1975
- if (!parsed) throw new Error("Invalid add-auth-method ceremony record");
1976
- const ttlMs = Math.max(1, parsed.expiresAtMs - Date.now());
1977
- const response = await callDo(this.stub, {
1978
- op: "set",
1979
- key: this.key("add-auth-method", parsed.addAuthMethodCeremonyId),
1980
- value: parsed,
1981
- ttlMs
1982
- });
1983
- if (!response.ok) throw new Error(response.message);
1984
- }
1985
- async getAddAuthMethodCeremony(addAuthMethodCeremonyId) {
1986
- const key = trimString(addAuthMethodCeremonyId);
1987
- if (!key) return null;
1988
- const response = await callDo(this.stub, {
1989
- op: "get",
1990
- key: this.key("add-auth-method", key)
1991
- });
1992
- if (!response.ok) return null;
1993
- const ceremony = parseStoredWalletAddAuthMethodCeremony(response.value);
1994
- if (!ceremony || ceremony.expiresAtMs <= Date.now()) return null;
1995
- return ceremony;
1996
- }
1997
- async updateAddAuthMethodCeremony(ceremony) {
1998
- const parsed = parseStoredWalletAddAuthMethodCeremony(ceremony);
1999
- if (!parsed) throw new Error("Invalid add-auth-method ceremony record");
2000
- if (parsed.expiresAtMs <= Date.now()) return;
2001
- const ttlMs = Math.max(1, parsed.expiresAtMs - Date.now());
2002
- const response = await callDo(this.stub, {
2003
- op: "set",
2004
- key: this.key("add-auth-method", parsed.addAuthMethodCeremonyId),
2005
- value: parsed,
2006
- ttlMs
2007
- });
2008
- if (!response.ok) throw new Error(response.message);
2009
- }
2010
- async takeAddAuthMethodCeremony(addAuthMethodCeremonyId) {
2011
- const key = trimString(addAuthMethodCeremonyId);
2012
- if (!key) return null;
2013
- const response = await callDo(this.stub, {
2014
- op: "getdel",
2015
- key: this.key("add-auth-method", key)
2016
- });
2017
- if (!response.ok) return null;
2018
- const ceremony = parseStoredWalletAddAuthMethodCeremony(response.value);
2019
- if (!ceremony || ceremony.expiresAtMs <= Date.now()) return null;
2020
- return ceremony;
2021
- }
2022
- async putAddSignerCeremony(ceremony) {
2023
- const parsed = parseStoredWalletAddSignerCeremony(ceremony);
2024
- if (!parsed) throw new Error("Invalid add-signer ceremony record");
2025
- const ttlMs = Math.max(1, parsed.expiresAtMs - Date.now());
2026
- const response = await callDo(this.stub, {
2027
- op: "set",
2028
- key: this.key("add-signer", parsed.addSignerCeremonyId),
2029
- value: parsed,
2030
- ttlMs
2031
- });
2032
- if (!response.ok) throw new Error(response.message);
2033
- }
2034
- async getAddSignerCeremony(addSignerCeremonyId) {
2035
- const key = trimString(addSignerCeremonyId);
2036
- if (!key) return null;
2037
- const response = await callDo(this.stub, {
2038
- op: "get",
2039
- key: this.key("add-signer", key)
2040
- });
2041
- if (!response.ok) return null;
2042
- const ceremony = parseStoredWalletAddSignerCeremony(response.value);
2043
- if (!ceremony || ceremony.expiresAtMs <= Date.now()) return null;
2044
- return ceremony;
2045
- }
2046
- async updateAddSignerCeremony(ceremony) {
2047
- const parsed = parseStoredWalletAddSignerCeremony(ceremony);
2048
- if (!parsed) throw new Error("Invalid add-signer ceremony record");
2049
- if (parsed.expiresAtMs <= Date.now()) return;
2050
- const ttlMs = Math.max(1, parsed.expiresAtMs - Date.now());
2051
- const response = await callDo(this.stub, {
2052
- op: "set",
2053
- key: this.key("add-signer", parsed.addSignerCeremonyId),
2054
- value: parsed,
2055
- ttlMs
2056
- });
2057
- if (!response.ok) throw new Error(response.message);
2058
- }
2059
- async takeAddSignerCeremony(addSignerCeremonyId) {
2060
- const key = trimString(addSignerCeremonyId);
2061
- if (!key) return null;
2062
- const response = await callDo(this.stub, {
2063
- op: "getdel",
2064
- key: this.key("add-signer", key)
2065
- });
2066
- if (!response.ok) return null;
2067
- const ceremony = parseStoredWalletAddSignerCeremony(response.value);
2068
- if (!ceremony || ceremony.expiresAtMs <= Date.now()) return null;
2069
- return ceremony;
2070
- }
2071
- };
2072
- function resolveRegistrationDoPrefix(config) {
2073
- const base = trimString(config.WALLET_REGISTRATION_PREFIX) || trimString(config.walletRegistrationPrefix) || trimString(config.keyPrefix) || trimString(config.THRESHOLD_PREFIX);
2074
- if (!base) return "wallet-registration:";
2075
- return base.endsWith(":") ? `${base}wallet-registration:` : `${base}:wallet-registration:`;
2076
- }
2077
- function createRegistrationCeremonyStore(input = {}) {
2078
- const config = input.config || {};
2079
- const kind = typeof config.kind === "string" ? config.kind.trim() : "";
2080
- if (kind === "cloudflare-do") {
2081
- const namespace = resolveDoNamespaceFromConfig(config);
2082
- if (!namespace) throw new Error("cloudflare-do registration ceremony store selected but no Durable Object namespace was provided (expected config.namespace)");
2083
- const objectName = trimString(config.objectName) || trimString(config.name) || "threshold-store";
2084
- input.logger?.info("[wallet-registration] Using Cloudflare Durable Object store for registration ceremonies");
2085
- return new CloudflareDurableObjectRegistrationCeremonyStore({
2086
- namespace,
2087
- objectName,
2088
- prefix: resolveRegistrationDoPrefix(config)
2089
- });
2090
- }
2091
- if (kind && kind !== "memory" && kind !== "in-memory") throw new Error(`[wallet-registration] Unknown registration ceremony store kind: ${kind}`);
2092
- input.logger?.warn?.("[wallet-registration] Using in-memory registration ceremony store; configure Cloudflare Durable Object storage for durable registration ceremonies");
2093
- return new MemoryRegistrationCeremonyStore();
2094
- }
2095
305
  //#endregion
2096
- export { MemoryRegistrationCeremonyStore, buildStoredWalletRegistrationEvmFamilyEcdsaFinalizedBranch, buildStoredWalletRegistrationEvmFamilyEcdsaPreparedBranch, buildStoredWalletRegistrationNearEd25519YaoAuthorizedBranch, buildStoredWalletRegistrationPreparedContext, createRegistrationCeremonyStore, findStoredWalletRegistrationEvmFamilyEcdsaBranch, findStoredWalletRegistrationNearEd25519YaoBranch, parseStoredRegistrationSignerPlan, parseStoredWalletRegistrationPreparedContext, parseTerminalRegistrationCeremonyCancellationResult, registrationCeremonyAuthorityRpId, replaceStoredWalletRegistrationSignerBranch, storedRegistrationAuthoritiesMatch, storedRegistrationSignerPlansMatch, storedWalletRegistrationPreparedContextsMatch, verifiedRegistrationCeremonyAuthority };
306
+ export { buildStoredWalletRegistrationEvmFamilyEcdsaFinalizedBranch, buildStoredWalletRegistrationEvmFamilyEcdsaPreparedBranch, buildStoredWalletRegistrationNearEd25519YaoAuthorizedBranch, buildStoredWalletRegistrationPreparedContext, findStoredWalletRegistrationEvmFamilyEcdsaBranch, findStoredWalletRegistrationNearEd25519YaoBranch, parseStoredRegistrationSignerPlan, parseStoredWalletRegistrationPreparedContext, replaceStoredWalletRegistrationSignerBranch, storedRegistrationAuthoritiesMatch, storedRegistrationSignerPlansMatch, verifiedRegistrationCeremonyAuthority };
2097
307
 
2098
308
  //# sourceMappingURL=RegistrationCeremonyStore.js.map