@seams/wallet-server 0.7.3 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRD_PARTY_NOTICES.md +7 -9
- package/artifact-manifest.json +241 -41
- package/cloudflare-router-ab/build/deriver-a/build-stamp.json +1 -1
- package/cloudflare-router-ab/build/deriver-a/index.js +2 -2
- package/cloudflare-router-ab/build/deriver-a/index_bg.wasm +0 -0
- package/cloudflare-router-ab/build/deriver-b/build-stamp.json +1 -1
- package/cloudflare-router-ab/build/deriver-b/index.js +2 -2
- package/cloudflare-router-ab/build/deriver-b/index_bg.wasm +0 -0
- package/cloudflare-router-ab/build/local-tools/darwin-arm64/router_ab_local_init +0 -0
- package/cloudflare-router-ab/build/local-tools/darwin-x64/router_ab_local_init +0 -0
- package/cloudflare-router-ab/build/local-tools/linux-x64/router_ab_local_init +0 -0
- package/cloudflare-router-ab/build/router/build-stamp.json +1 -1
- package/cloudflare-router-ab/build/router/index.js +2 -2
- package/cloudflare-router-ab/build/router/index_bg.wasm +0 -0
- package/cloudflare-router-ab/build/signing-worker/build-stamp.json +1 -1
- package/cloudflare-router-ab/build/signing-worker/index.js +2 -2
- package/cloudflare-router-ab/build/signing-worker/index_bg.wasm +0 -0
- package/cloudflare-router-ab/build/tenant-root-control-plane/build-stamp.json +1 -1
- package/cloudflare-router-ab/build/tenant-root-control-plane/index.js +2 -2
- package/cloudflare-router-ab/build/tenant-root-control-plane/index_bg.wasm +0 -0
- package/cloudflare-router-ab/migrations/deriver-a/0019_wallet_object_addresses.sql +10 -0
- package/cloudflare-router-ab/migrations/deriver-b/0019_wallet_object_addresses.sql +10 -0
- package/cloudflare-router-ab/scripts/prepare-local-runtime-config.mjs +3 -119
- package/cloudflare-router-ab/scripts/start-local-role-workers.mjs +77 -20
- package/cloudflare-router-ab/wrangler.deriver-a.toml +0 -8
- package/cloudflare-router-ab/wrangler.deriver-b.toml +24 -8
- package/cloudflare-router-ab/wrangler.router.toml +0 -2
- package/cloudflare-router-ab/wrangler.signing-worker.toml +29 -0
- package/dist/esm/authorization/domain.js +3 -2
- package/dist/esm/authorization/lifecycleRouting.js +62 -0
- package/dist/esm/authorization/service.js +86 -35
- package/dist/esm/cloud-host.js +42 -39
- package/dist/esm/core/EmailOtpRecords.js +29 -222
- package/dist/esm/core/EmailOtpStores.js +0 -859
- package/dist/esm/core/IdentityStore.js +2 -339
- package/dist/esm/core/ThresholdService/config.js +1 -9
- package/dist/esm/core/ThresholdService/index.js +0 -4
- package/dist/esm/core/ThresholdService/kv.js +1 -66
- package/dist/esm/core/ThresholdService/routerAb/ecdsaDerivationPoolFillHandlers.js +3 -13
- package/dist/esm/core/ThresholdService/routerAb/ecdsaDerivationPresignBridge.js +10 -0
- package/dist/esm/core/ThresholdService/routerAb/internalServiceHttp.js +1 -0
- package/dist/esm/core/ThresholdService/routerAbNormalSigningPolicy.js +1 -11
- package/dist/esm/core/ThresholdService/stores/WalletSessionStore.js +0 -541
- package/dist/esm/core/ThresholdService/validation.js +3 -347
- package/dist/esm/core/WalletAuthMethodStore.js +2 -123
- package/dist/esm/core/WalletStore.js +3 -209
- package/dist/esm/core/WebAuthnAuthenticatorStore.js +0 -202
- package/dist/esm/core/WebAuthnCredentialBindingStore.js +2 -182
- package/dist/esm/core/WebAuthnLoginChallengeStore.js +0 -52
- package/dist/esm/core/WebAuthnSyncChallengeStore.js +0 -54
- package/dist/esm/core/authService/emailOtpConfig.js +1 -195
- package/dist/esm/core/authService/emailOtpEnrollment.js +0 -110
- package/dist/esm/core/authService/emailOtpSeal.js +0 -63
- package/dist/esm/core/authService/nearPrivateKeySigning.js +1 -1
- package/dist/esm/core/authService/nearTransactions.js +3 -98
- package/dist/esm/core/authService/rateLimits.js +0 -84
- package/dist/esm/core/authService/webauthn.js +3 -299
- package/dist/esm/core/authService/webauthnOidcHelpers.js +1 -24
- package/dist/esm/core/authService/webauthnWalletBinding.js +0 -37
- package/dist/esm/core/config.js +1 -95
- package/dist/esm/core/d1EcdsaSignerRead.js +1 -1
- package/dist/esm/core/d1Ed25519SignerRead.js +55 -0
- package/dist/esm/core/d1IdentityStore.js +1 -2
- package/dist/esm/core/d1TenantStore.js +1 -24
- package/dist/esm/core/d1WalletAuthMethodStore.js +2 -5
- package/dist/esm/core/d1WalletStore.js +16 -13
- package/dist/esm/core/deviceLinking/linkedDeviceBootstrap.js +13 -0
- package/dist/esm/core/deviceLinking/linkedDeviceEmailOtpGrant.js +2 -2
- package/dist/esm/core/deviceLinking/linkedDeviceManagement.js +1 -1
- package/dist/esm/core/deviceLinking/linkedDeviceSession.js +20 -14
- package/dist/esm/core/deviceLinking/linkedDeviceSessionRecord.js +2 -2
- package/dist/esm/core/deviceLinking/requestProof.js +9 -6
- package/dist/esm/core/emailOtpD1Statements.js +108 -94
- package/dist/esm/core/keyMaterialBrands.js +2 -12
- package/dist/esm/core/nearKeys.js +0 -1
- package/dist/esm/core/nearRelayerAccountProvisioning.js +7 -10
- package/dist/esm/core/passkeyCredentialClaims.js +8 -0
- package/dist/esm/core/routerAbSigning/RouterAbEcdsaPresignRuntime.js +6 -6
- package/dist/esm/core/routerAbSigning/RouterAbNormalSigningRuntime.js +2 -30
- package/dist/esm/core/signingLanes/WalletExecutionLaneProjection.js +1 -1
- package/dist/esm/core/signingMaterial/ordinaryInactiveSignerMaterialReservation.js +1 -0
- package/dist/esm/core/thresholdEcdsaChainTarget.js +1 -4
- package/dist/esm/hosted-wallet-gateway.js +158 -52
- package/dist/esm/index.js +6 -19
- package/dist/esm/localHostedWalletGatewayHandler.js +18 -3
- package/dist/esm/localIntendedYaoSigningFault.js +2 -30
- package/dist/esm/localRegistrationSetupAuthority.js +96 -0
- package/dist/esm/router/auth/authRequestValidation.js +8 -16
- package/dist/esm/router/auth/commonRouterUtils.js +17 -10
- package/dist/esm/router/auth/routerApiCredentialAuth.js +26 -7
- package/dist/esm/router/auth/walletRegistrationContext.js +49 -0
- package/dist/esm/router/auth/webAuthnCredentialCodecs.js +1 -2
- package/dist/esm/router/cloudflare/d1/auth/d1AuthorizationAssembly.js +88 -0
- package/dist/esm/router/cloudflare/d1/auth/d1AuthorizedOperationRouteService.js +2 -0
- package/dist/esm/router/cloudflare/d1/auth/d1EmailOtpRouteService.js +25 -0
- package/dist/esm/router/cloudflare/d1/auth/d1RouterApiAuthConfig.js +24 -6
- package/dist/esm/router/cloudflare/d1/auth/d1RouterApiAuthService.js +75 -320
- package/dist/esm/router/cloudflare/d1/auth/walletSessionCredentialReaders.js +17 -1
- package/dist/esm/router/cloudflare/d1/authorization/authorizedOperationStatements.js +57 -25
- package/dist/esm/router/cloudflare/d1/authorization/d1AuthorizationStore.js +265 -104
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceAuthorityInstallService.js +43 -17
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceEd25519ExportRootStore.js +6 -1
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceEmailOtpGrantStore.js +12 -2
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceEmailOtpTargetFactor.js +4 -4
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceOwnerAuthorizationProvider.js +2 -2
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceRequestProofNonceStore.js +3 -9
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceRouteService.js +2 -1
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceSessionRecords.js +1 -1
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceSessionStore.js +89 -7
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceTargetCredentialProvider.js +24 -15
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceTargetPlanner.js +1 -1
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceVerifiedLinkBuilder.js +1 -1
- package/dist/esm/router/cloudflare/d1/ed25519Yao/d1Ed25519YaoCapabilityPersistence.js +9 -6
- package/dist/esm/router/cloudflare/d1/ed25519Yao/d1Ed25519YaoLifecycleDecisionStore.js +11 -2
- package/dist/esm/router/cloudflare/d1/ed25519Yao/d1Ed25519YaoProductRegistrationPartitionedStateStore.js +100 -10
- package/dist/esm/router/cloudflare/d1/ed25519Yao/d1Ed25519YaoStateWriteFence.js +92 -0
- package/dist/esm/router/cloudflare/d1/ed25519Yao/d1WalletCeremonyActivity.js +77 -0
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeIssuer.js +14 -9
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeService.js +0 -1
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeStore.js +15 -9
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeVerifier.js +3 -2
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpEnrollmentStore.js +1 -1
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpGrantStore.js +1 -7
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpRateLimitStore.js +62 -36
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpRecords.js +27 -21
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpRecoveryService.js +1 -1
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpRegistrationEnrollmentFinalizer.js +2 -2
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpServerSealRuntime.js +0 -1
- package/dist/esm/router/cloudflare/d1/emailOtp/d1GoogleEmailOtpRegistrationAttemptStore.js +44 -12
- package/dist/esm/router/cloudflare/d1/emailOtp/d1GoogleEmailOtpRegistrationRecords.js +1 -49
- package/dist/esm/router/cloudflare/d1/emailOtp/d1GoogleEmailOtpSessionResolver.js +20 -31
- package/dist/esm/router/cloudflare/d1/emailOtp/d1GoogleRegistrationCompletion.js +85 -0
- package/dist/esm/router/cloudflare/d1/identity/d1IdentityRecords.js +0 -1
- package/dist/esm/router/cloudflare/d1/identity/d1IdentityService.js +0 -48
- package/dist/esm/router/cloudflare/d1/near/d1SponsoredNearAccount.js +242 -0
- package/dist/esm/router/cloudflare/d1/oidc/d1OidcBoundary.js +1 -2
- package/dist/esm/router/cloudflare/d1/oidc/d1OidcVerificationService.js +2 -29
- package/dist/esm/router/cloudflare/d1/oidc/googleOidcToken.js +41 -0
- package/dist/esm/router/cloudflare/d1/passkeyCustody/d1PasskeyCustodyRouteService.js +5 -0
- package/dist/esm/router/cloudflare/d1/passkeyCustody/d1WalletCustodyCommitStore.js +52 -7
- package/dist/esm/router/cloudflare/d1/registration/d1RegistrationCeremonyRecordStore.js +83 -16
- package/dist/esm/router/cloudflare/d1/registration/d1RegistrationCeremonyRecords.js +8 -14
- package/dist/esm/router/cloudflare/d1/registration/d1RegistrationCeremonyStore.js +60 -28
- package/dist/esm/router/cloudflare/d1/registration/d1RegistrationIntentService.js +0 -1
- package/dist/esm/router/cloudflare/d1/registration/d1RegistrationSessionTransaction.js +28 -0
- package/dist/esm/router/cloudflare/d1/registration/d1RegistrationSetupSupport.js +84 -0
- package/dist/esm/router/cloudflare/d1/registration/d1WalletExecutionAuthority.js +168 -0
- package/dist/esm/router/cloudflare/d1/registration/d1WalletOperationStore.js +53 -0
- package/dist/esm/router/cloudflare/d1/registration/d1WalletRegistrationCommitStore.js +85 -38
- package/dist/esm/router/cloudflare/d1/registration/d1WalletRegistrationInitialSession.js +33 -0
- package/dist/esm/router/cloudflare/d1/registration/d1WalletRegistrationPreparation.js +16 -0
- package/dist/esm/router/cloudflare/d1/registration/d1WalletRegistrationRead.js +58 -0
- package/dist/esm/router/cloudflare/d1/registration/d1WalletRegistrationService.js +478 -708
- package/dist/esm/router/cloudflare/d1/registration/d1WalletRegistrationSetup.js +13 -57
- package/dist/esm/router/cloudflare/d1/registration/d1WalletRegistrationSetupExecution.js +169 -0
- package/dist/esm/router/cloudflare/d1/registration/walletRegistrationEstablishedSessionIssuer.js +79 -47
- package/dist/esm/router/cloudflare/d1/registration/walletRegistrationSessionCommitReceipt.js +11 -35
- package/dist/esm/router/cloudflare/d1/signingAdmission/d1RouterAbNormalSigningAdmissionStore.js +110 -45
- package/dist/esm/router/cloudflare/d1/versionedJson/d1VersionedJsonRecordStore.js +12 -9
- package/dist/esm/router/cloudflare/d1/wallet/authorizationSnapshotLayout.js +168 -0
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletAddSignerFinalizeRecord.js +68 -0
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletAddSignerService.js +22 -60
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletAuthMethodService.js +12 -48
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletAuthorityStore.js +56 -143
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletAuthorizationCleanup.js +157 -0
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletAuthorizationFreeze.js +56 -0
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletAuthorizationHistory.js +238 -0
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletAuthorizationIntake.js +287 -0
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletAuthorizationSnapshot.js +295 -0
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletRelocationApprovals.js +140 -0
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletRelocationChallenges.js +170 -0
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletRelocationEmailOtp.js +60 -0
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletRelocationOwner.js +33 -0
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletRelocationOwnerRequest.js +74 -0
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletRelocationPasskey.js +77 -0
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletRelocationReadAccess.js +37 -0
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletRelocationSessions.js +97 -0
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletRelocationWriteBlock.js +133 -0
- package/dist/esm/router/cloudflare/d1/walletObjectAddresses.js +47 -0
- package/dist/esm/router/cloudflare/d1/webauthn/d1WebAuthnAuthService.js +26 -5
- package/dist/esm/router/cloudflare/d1/webauthn/d1WebAuthnRecords.js +4 -70
- package/dist/esm/router/cloudflare/d1/webauthn/d1WebAuthnStore.js +23 -7
- package/dist/esm/router/cloudflare/runtime/routerAbServiceBindings.js +32 -1
- package/dist/esm/router/cloudflare/runtime/staticWalletConsoleBinding.js +20 -7
- package/dist/esm/router/cloudflare/runtime/walletAuthorizationRelocationRoutes.js +488 -0
- package/dist/esm/router/cloudflare/runtime/walletConsoleOps.js +1 -0
- package/dist/esm/router/cloudflare/runtime/walletConsoleOpsClient.js +26 -1
- package/dist/esm/router/cloudflare/runtime/walletControlOps.js +3 -0
- package/dist/esm/router/cloudflare/runtime/walletGateway.js +1 -1
- package/dist/esm/router/cloudflare/runtime/walletObjectAddresses.js +105 -0
- package/dist/esm/router/cloudflare/runtime/walletPlacementRoutes.js +339 -0
- package/dist/esm/router/cloudflare/runtime/walletRelocationDeriver.js +244 -0
- package/dist/esm/router/cloudflare/runtime/walletRelocationEcdsa.js +212 -0
- package/dist/esm/router/cloudflare/runtime/walletRelocationEd25519.js +172 -0
- package/dist/esm/router/cloudflare/runtime/walletRelocationOps.js +183 -0
- package/dist/esm/router/cloudflare/runtime/walletRelocationPresign.js +185 -0
- package/dist/esm/router/cloudflare/runtime/walletRelocationSource.js +221 -0
- package/dist/esm/router/cloudflare/runtime/walletRuntimeOps.js +16 -4
- package/dist/esm/router/cloudflare/signingLanes/cloudflareOrdinaryInactiveSignerMaterialReservation.js +30 -8
- package/dist/esm/router/cloudflare-adaptor.js +8 -9
- package/dist/esm/router/cloudflare.js +33043 -31559
- package/dist/esm/router/domains/ecdsa/routerAbEcdsaStrictRegistration.js +35 -9
- package/dist/esm/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoCapabilityCommit.js +42 -0
- package/dist/esm/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistration.js +42 -13
- package/dist/esm/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistrationPartitionedStateStore.js +64 -3
- package/dist/esm/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistrationPartitioning.js +6 -6
- package/dist/esm/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistrationPersistence.js +70 -3
- package/dist/esm/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistrationRequestScopedRuntime.js +59 -87
- package/dist/esm/router/domains/ed25519Yao/export/routerAbEd25519YaoExport.js +58 -28
- package/dist/esm/router/domains/ed25519Yao/export/routerAbEd25519YaoExportRequestScopedCloudflare.js +13 -7
- package/dist/esm/router/domains/ed25519Yao/recovery/routerAbEd25519YaoRecovery.js +108 -78
- package/dist/esm/router/domains/ed25519Yao/recovery/routerAbEd25519YaoRecoveryRequestScopedCloudflare.js +27 -5
- package/dist/esm/router/domains/ed25519Yao/recovery/routerAbEd25519YaoRecoveryWalletSessionAuthorization.js +71 -22
- package/dist/esm/router/domains/ed25519Yao/registration/routerAbEd25519YaoHttpRegistrationBackend.js +37 -25
- package/dist/esm/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistration.js +3 -3
- package/dist/esm/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistrationExecutionRecord.js +2 -1
- package/dist/esm/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistrationIntentAuthorization.js +24 -3
- package/dist/esm/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistrationRequestScopedCloudflare.js +4 -3
- package/dist/esm/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistrationSideEffectBoundary.js +20 -7
- package/dist/esm/router/domains/ed25519Yao/routerAbEd25519YaoGatewayEnvelope.js +7 -1
- package/dist/esm/router/domains/emailOtp/emailOtpRequestValidation.js +0 -1
- package/dist/esm/router/domains/emailOtp/emailOtpRouteHandlers.js +2 -2
- package/dist/esm/router/domains/passkeyCustody/passkeyCustodyEnvelopeRetrieval.js +3 -9
- package/dist/esm/router/domains/passkeyCustody/registrationCustodyOutcome.js +34 -18
- package/dist/esm/router/domains/passkeyCustody/walletCustodyRegistrationAdmission.js +2 -2
- package/dist/esm/router/domains/passkeyCustody/walletCustodyRegistrationCommit.js +18 -14
- package/dist/esm/router/domains/signingOperations/authorizedOperationWire.js +73 -0
- package/dist/esm/router/domains/signingOperations/ecdsaSigningResponse.js +31 -0
- package/dist/esm/router/domains/signingOperations/ed25519AuthorizedOperationReceipt.js +1 -1
- package/dist/esm/router/domains/signingOperations/routerAbEcdsaDerivationNormalSigningRoute.js +2 -1
- package/dist/esm/router/domains/signingOperations/routerAbEd25519NormalSigningRoute.js +31 -121
- package/dist/esm/router/domains/signingOperations/routerAbNormalSigningAdmission.js +2 -93
- package/dist/esm/router/domains/signingOperations/routerAbPrivateSigningWorker.js +6 -20
- package/dist/esm/router/domains/signingOperations/signingPrepareSession.js +33 -0
- package/dist/esm/router/domains/signingOperations/walletExecutionAdmission.js +2 -3
- package/dist/esm/router/domains/walletRegistration/registrationSessionSeal.js +121 -0
- package/dist/esm/router/domains/walletRegistration/walletRegistrationReservation.js +70 -0
- package/dist/esm/router/domains/walletRegistration/walletRegistrationRoutes.js +56 -168
- package/dist/esm/router/domains/walletRegistration/walletRegistrationSetupPayload.js +3 -4
- package/dist/esm/router/domains/walletUnlock/walletUnlockRouteHandlers.js +14 -0
- package/dist/esm/router/express.js +1453 -1488
- package/dist/esm/router/framework/http.js +4 -1
- package/dist/esm/router/framework/registrationSetupDispatch.js +14 -0
- package/dist/esm/router/framework/ror/normalize.js +0 -1
- package/dist/esm/router/framework/ror/options.js +0 -1
- package/dist/esm/router/framework/ror/provider.js +0 -1
- package/dist/esm/router/framework/ror/staticProvider.js +0 -1
- package/dist/esm/router/framework/routeDefinitions.js +1 -2
- package/dist/esm/router/framework/routerApiWebhooks.js +0 -1
- package/dist/esm/router/ror.js +0 -1
- package/dist/esm/router/transport/fetch/createFetchRouter.js +2 -4
- package/dist/esm/router/transport/fetch/routes/auth.js +3 -1
- package/dist/esm/router/transport/fetch/routes/deviceLinking.js +38 -149
- package/dist/esm/router/transport/fetch/routes/deviceLinkingOwnerAuthorization.js +5 -4
- package/dist/esm/router/transport/fetch/routes/deviceLinkingResponses.js +130 -0
- package/dist/esm/router/transport/fetch/routes/ecdsaOperationStepUpFactor.js +171 -0
- package/dist/esm/router/transport/fetch/routes/ed25519AuthorizedOperationRevalidation.js +65 -0
- package/dist/esm/router/transport/fetch/routes/normalSigningRouterProxy.js +13 -3
- package/dist/esm/router/transport/fetch/routes/passkeyCustody.js +4 -3
- package/dist/esm/router/transport/fetch/routes/sessions.js +3 -2
- package/dist/esm/router/transport/fetch/routes/syncAccount.js +7 -2
- package/dist/esm/router/transport/fetch/routes/thresholdEcdsa.js +86 -245
- package/dist/esm/router/transport/fetch/routes/thresholdEd25519.js +76 -212
- package/dist/esm/router/transport/fetch/routes/walletExecutionLanePreflight.js +18 -41
- package/dist/esm/router/transport/fetch/routes/walletRegistration.js +6 -3
- package/dist/esm/router/transport/fetch/routes/webauthnAuthenticators.js +1 -1
- package/dist/esm/shared-ts/src/authorization/index.js +1 -1
- package/dist/esm/shared-ts/src/authorization/walletAuthority.js +2 -2
- package/dist/esm/shared-ts/src/authorization/walletSessionIssuance.js +0 -1
- package/dist/esm/shared-ts/src/device-linking/activeWalletSession.js +12 -2
- package/dist/esm/shared-ts/src/device-linking/authorityActivation.js +0 -2
- package/dist/esm/shared-ts/src/device-linking/contracts.js +16 -1
- package/dist/esm/shared-ts/src/device-linking/digests.js +2 -9
- package/dist/esm/shared-ts/src/device-linking/ed25519ExportRoot.js +1 -1
- package/dist/esm/shared-ts/src/device-linking/index.js +1 -1
- package/dist/esm/shared-ts/src/device-linking/parsers.js +1 -1
- package/dist/esm/shared-ts/src/device-linking/sourceContribution.js +1 -1
- package/dist/esm/shared-ts/src/device-linking/wireFields.js +1 -1
- package/dist/esm/shared-ts/src/near/actions.js +0 -1
- package/dist/esm/shared-ts/src/near/nearClient.js +1 -3
- package/dist/esm/shared-ts/src/signing-lanes/evmFamilySigningKeySlotId.js +1 -1
- package/dist/esm/shared-ts/src/signing-lanes/index.js +1 -6
- package/dist/esm/shared-ts/src/signing-lanes/ownerContinuity.js +3 -3
- package/dist/esm/shared-ts/src/signing-lanes/participantDigest.js +2 -81
- package/dist/esm/shared-ts/src/signing-lanes/participants.js +1 -219
- package/dist/esm/shared-ts/src/signing-lanes/recordParsers.js +0 -3
- package/dist/esm/shared-ts/src/tenant-root/tenantRootOperationRecord.js +1 -2
- package/dist/esm/shared-ts/src/threshold/ecdsaDerivationRoleLocalBootstrap.js +0 -1
- package/dist/esm/shared-ts/src/threshold/keyMaterialBrands.js +1 -22
- package/dist/esm/shared-ts/src/threshold/participants.js +0 -1
- package/dist/esm/shared-ts/src/threshold/signingRootScope.js +0 -1
- package/dist/esm/shared-ts/src/utils/addWalletAuthMethod.js +4 -13
- package/dist/esm/shared-ts/src/utils/canonicalPrimitives.js +1 -7
- package/dist/esm/shared-ts/src/utils/domainIds.js +1 -16
- package/dist/esm/shared-ts/src/utils/ecdsaCapabilityActivation.js +1 -11
- package/dist/esm/shared-ts/src/utils/ecdsaKeyFactsInventory.js +0 -1
- package/dist/esm/shared-ts/src/utils/ecdsaServerTiming.js +6 -1
- package/dist/esm/shared-ts/src/utils/emailOtpDomain.js +4 -2
- package/dist/esm/shared-ts/src/utils/errors.js +1 -19
- package/dist/esm/shared-ts/src/utils/near.js +1 -1
- package/dist/esm/shared-ts/src/utils/registrationEstablishedSession.js +1 -1
- package/dist/esm/shared-ts/src/utils/registrationIds.js +1 -5
- package/dist/esm/shared-ts/src/utils/registrationIntent.js +0 -1
- package/dist/esm/shared-ts/src/utils/registrationSetupOperation.js +8 -0
- package/dist/esm/shared-ts/src/utils/registrationSignerPlan.js +1 -1
- package/dist/esm/shared-ts/src/utils/routerAbEcdsaDerivation.js +1 -2
- package/dist/esm/shared-ts/src/utils/routerAbPublicKeyset.js +0 -27
- package/dist/esm/shared-ts/src/utils/validation.js +1 -5
- package/dist/esm/shared-ts/src/utils/walletAuthAuthority.js +0 -1
- package/dist/esm/shared-ts/src/utils/walletManagementProtocol.js +6 -0
- package/dist/esm/shared-ts/src/utils/wireSchema.js +2 -13
- package/dist/esm/shared-ts/src/wallet-recovery/backupAcknowledgement.js +6 -24
- package/dist/esm/shared-ts/src/wallet-recovery/recoveryCodeLocator.js +0 -1
- package/dist/esm/shared-ts/src/wallet-recovery/recoveryKeyId.js +5 -6
- package/dist/esm/shared-ts/src/wallet-recovery/walletRecoveryEcdsaPossession.js +1 -1
- package/dist/esm/storage/d1Sql.js +1 -7
- package/dist/esm/threshold/session/signingSessionSeal/crypto/cipher.js +0 -1
- package/dist/esm/threshold/session/signingSessionSeal/guards/backends.js +1 -2
- package/dist/esm/threshold/session/signingSessionSeal/idempotencyBackends.js +0 -1
- package/dist/esm/threshold/session/signingSessionSeal/idempotencyRecords.js +0 -1
- package/dist/esm/threshold/session/signingSessionSeal/options.js +1 -2
- package/dist/esm/wasm/evm_crypto/pkg/evm_crypto_bg.wasm +0 -0
- package/dist/esm/wasm/near_signer/pkg/wasm_signer_worker.js +0 -611
- package/dist/esm/wasm/near_signer/pkg/wasm_signer_worker_bg.wasm +0 -0
- package/dist/esm/wasm/shamir3pass_runtime/pkg/shamir3pass_runtime_bg.wasm +0 -0
- package/dist/types/shared-ts/src/authorization/capabilityKinds.d.ts +0 -4
- package/dist/types/shared-ts/src/device-linking/activeWalletSession.d.ts +2 -1
- package/dist/types/shared-ts/src/device-linking/contracts.d.ts +11 -0
- package/dist/types/shared-ts/src/signing-lanes/evmFamilySigningKeySlotId.d.ts +0 -2
- package/dist/types/shared-ts/src/signing-lanes/execution.d.ts +0 -11
- package/dist/types/shared-ts/src/signing-lanes/ids.d.ts +2 -7
- package/dist/types/shared-ts/src/signing-lanes/index.d.ts +0 -4
- package/dist/types/shared-ts/src/signing-lanes/ownerContinuity.d.ts +0 -1
- package/dist/types/shared-ts/src/signing-lanes/participantDigest.d.ts +0 -18
- package/dist/types/shared-ts/src/signing-lanes/participants.d.ts +6 -35
- package/dist/types/shared-ts/src/signing-lanes/rotation.d.ts +6 -843
- package/dist/types/shared-ts/src/threshold/ed25519OperationFingerprint.d.ts +2 -1
- package/dist/types/shared-ts/src/threshold/keyMaterialBrands.d.ts +0 -10
- package/dist/types/shared-ts/src/threshold/participants.d.ts +1 -1
- package/dist/types/shared-ts/src/utils/addWalletAuthMethod.d.ts +1 -133
- package/dist/types/shared-ts/src/utils/addWalletAuthMethod.typecheck.d.ts +4 -18
- package/dist/types/shared-ts/src/utils/domainIds.d.ts +0 -12
- package/dist/types/shared-ts/src/utils/emailOtpDomain.d.ts +3 -1
- package/dist/types/shared-ts/src/utils/errors.d.ts +0 -4
- package/dist/types/shared-ts/src/utils/near.d.ts +0 -20
- package/dist/types/shared-ts/src/utils/normalize.d.ts +0 -2
- package/dist/types/shared-ts/src/utils/registrationSetupOperation.d.ts +3 -0
- package/dist/types/shared-ts/src/utils/routerAbPublicKeyset.d.ts +0 -9
- package/dist/types/shared-ts/src/utils/validation.d.ts +1 -3
- package/dist/types/shared-ts/src/utils/walletCapabilityBindings.d.ts +0 -1
- package/dist/types/shared-ts/src/utils/walletManagementProtocol.d.ts +3 -0
- package/dist/types/shared-ts/src/utils/wireSchema.d.ts +0 -2
- package/dist/types/shared-ts/src/wallet-recovery/backupAcknowledgement.d.ts +0 -1
- package/dist/types/shared-ts/src/wallet-recovery/recoveryCodeReservation.d.ts +1 -10
- package/dist/types/shared-ts/src/wallet-recovery/recoveryCodes.d.ts +1 -3
- package/dist/types/shared-ts/src/wallet-recovery/recoveryKeyId.d.ts +5 -21
- package/dist/types/wallet-server/src/authorization/domain.d.ts +17 -1
- package/dist/types/wallet-server/src/authorization/ecdsaWalletSessionAdmission.d.ts +1 -0
- package/dist/types/wallet-server/src/authorization/ed25519WalletSessionAdmission.d.ts +35 -0
- package/dist/types/wallet-server/src/authorization/ed25519WalletSessionAdmission.typecheck.d.ts +2 -0
- package/dist/types/wallet-server/src/authorization/lifecycleRouting.d.ts +32 -0
- package/dist/types/wallet-server/src/authorization/lifecycleRouting.typecheck.d.ts +2 -0
- package/dist/types/wallet-server/src/authorization/recoveryRouting.d.ts +22 -0
- package/dist/types/wallet-server/src/authorization/recoveryRouting.typecheck.d.ts +2 -0
- package/dist/types/wallet-server/src/authorization/service.d.ts +50 -5
- package/dist/types/wallet-server/src/authorization/sessionRouting.d.ts +22 -0
- package/dist/types/wallet-server/src/authorization/sessionRouting.typecheck.d.ts +2 -0
- package/dist/types/wallet-server/src/cloud-host.d.ts +36 -10
- package/dist/types/wallet-server/src/core/EmailOtpRecords.d.ts +2 -22
- package/dist/types/wallet-server/src/core/EmailOtpStores.d.ts +20 -84
- package/dist/types/wallet-server/src/core/IdentityStore.d.ts +0 -10
- package/dist/types/wallet-server/src/core/RegistrationCeremonyStore.d.ts +0 -1
- package/dist/types/wallet-server/src/core/ThresholdService/config.d.ts +0 -2
- package/dist/types/wallet-server/src/core/ThresholdService/index.d.ts +1 -3
- package/dist/types/wallet-server/src/core/ThresholdService/kv.d.ts +0 -7
- package/dist/types/wallet-server/src/core/ThresholdService/routerAb/ecdsaDerivationPoolFillHandlers.d.ts +1 -3
- package/dist/types/wallet-server/src/core/ThresholdService/routerAb/ecdsaDerivationPresignBridge.d.ts +6 -0
- package/dist/types/wallet-server/src/core/ThresholdService/routerAb/internalServiceHttp.d.ts +1 -0
- package/dist/types/wallet-server/src/core/ThresholdService/routerAbNormalSigningPolicy.d.ts +0 -1
- package/dist/types/wallet-server/src/core/ThresholdService/stores/WalletSessionStore.d.ts +7 -19
- package/dist/types/wallet-server/src/core/ThresholdService/validation.d.ts +0 -34
- package/dist/types/wallet-server/src/core/WalletAuthMethodStore.d.ts +1 -5
- package/dist/types/wallet-server/src/core/WalletStore.d.ts +0 -3
- package/dist/types/wallet-server/src/core/WebAuthnAuthenticatorStore.d.ts +0 -20
- package/dist/types/wallet-server/src/core/WebAuthnCredentialBindingStore.d.ts +1 -27
- package/dist/types/wallet-server/src/core/WebAuthnLoginChallengeStore.d.ts +2 -16
- package/dist/types/wallet-server/src/core/WebAuthnSyncChallengeStore.d.ts +22 -14
- package/dist/types/wallet-server/src/core/authService/emailOtpConfig.d.ts +0 -24
- package/dist/types/wallet-server/src/core/authService/emailOtpEnrollment.d.ts +1 -70
- package/dist/types/wallet-server/src/core/authService/emailOtpSeal.d.ts +0 -13
- package/dist/types/wallet-server/src/core/authService/githubOAuth.d.ts +2 -1
- package/dist/types/wallet-server/src/core/authService/nearTransactions.d.ts +1 -39
- package/dist/types/wallet-server/src/core/authService/rateLimits.d.ts +0 -17
- package/dist/types/wallet-server/src/core/authService/webauthn.d.ts +0 -125
- package/dist/types/wallet-server/src/core/authService/webauthnOidcHelpers.d.ts +0 -3
- package/dist/types/wallet-server/src/core/authService/webauthnVerificationOutcomes.d.ts +1 -1
- package/dist/types/wallet-server/src/core/authService/webauthnWalletBinding.d.ts +0 -12
- package/dist/types/wallet-server/src/core/config.d.ts +0 -10
- package/dist/types/wallet-server/src/core/d1Ed25519SignerRead.d.ts +17 -0
- package/dist/types/wallet-server/src/core/d1IdentityStore.d.ts +0 -2
- package/dist/types/wallet-server/src/core/d1TenantStore.d.ts +0 -7
- package/dist/types/wallet-server/src/core/d1WalletAuthMethodStore.d.ts +0 -1
- package/dist/types/wallet-server/src/core/d1WalletStore.d.ts +6 -0
- package/dist/types/wallet-server/src/core/deviceLinking/linkedDeviceBootstrap.d.ts +19 -0
- package/dist/types/wallet-server/src/core/deviceLinking/linkedDeviceSession.d.ts +8 -6
- package/dist/types/wallet-server/src/core/deviceLinking/requestProof.d.ts +2 -5
- package/dist/types/wallet-server/src/core/emailOtpD1Statements.d.ts +11 -7
- package/dist/types/wallet-server/src/core/keyMaterialBrands.d.ts +1 -5
- package/dist/types/wallet-server/src/core/nearRelayerAccountProvisioning.d.ts +0 -1
- package/dist/types/wallet-server/src/core/passkeyCredentialClaims.d.ts +9 -0
- package/dist/types/wallet-server/src/core/routerAbSigning/RouterAbEcdsaPresignRuntime.d.ts +5 -3
- package/dist/types/wallet-server/src/core/routerAbSigning/RouterAbNormalSigningRuntime.d.ts +0 -2
- package/dist/types/wallet-server/src/core/signingMaterial/ordinaryInactiveSignerMaterialReservation.d.ts +1 -0
- package/dist/types/wallet-server/src/core/threeRouteRegistrationContracts.d.ts +15 -140
- package/dist/types/wallet-server/src/core/threeRouteRegistrationContracts.typecheck.d.ts +4 -52
- package/dist/types/wallet-server/src/core/thresholdEcdsaChainTarget.d.ts +0 -1
- package/dist/types/wallet-server/src/core/types.d.ts +0 -299
- package/dist/types/wallet-server/src/hosted-wallet-gateway.d.ts +18 -5
- package/dist/types/wallet-server/src/index.d.ts +8 -13
- package/dist/types/wallet-server/src/localIntendedYaoSigningFault.d.ts +1 -16
- package/dist/types/wallet-server/src/localRegistrationSetupAuthority.d.ts +13 -0
- package/dist/types/wallet-server/src/router/auth/commonRouterUtils.d.ts +7 -1
- package/dist/types/wallet-server/src/router/auth/routerApiCredentialAuth.d.ts +11 -3
- package/dist/types/wallet-server/src/router/auth/walletRegistrationContext.d.ts +8 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/auth/d1AuthorizationAssembly.d.ts +23 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/auth/d1EmailOtpRouteService.d.ts +16 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/auth/d1RouterApiAuthConfig.d.ts +28 -3
- package/dist/types/wallet-server/src/router/cloudflare/d1/auth/d1RouterApiAuthService.d.ts +4 -1
- package/dist/types/wallet-server/src/router/cloudflare/d1/auth/walletSessionCredentialReaders.d.ts +7 -1
- package/dist/types/wallet-server/src/router/cloudflare/d1/authorization/d1AuthorizationStore.d.ts +33 -2
- package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceAuthorityInstallService.d.ts +5 -1
- package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceEmailOtpGrantStore.d.ts +7 -1
- package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceRequestProofNonceStore.d.ts +1 -10
- package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceRouteService.d.ts +4 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceSessionStore.d.ts +6 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceTargetPlanner.d.ts +1 -13
- package/dist/types/wallet-server/src/router/cloudflare/d1/ed25519Yao/d1Ed25519YaoLifecycleDecisionStore.d.ts +3 -1
- package/dist/types/wallet-server/src/router/cloudflare/d1/ed25519Yao/d1Ed25519YaoProductRegistrationPartitionedStateStore.d.ts +1 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/ed25519Yao/d1Ed25519YaoStateWriteFence.d.ts +8 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/ed25519Yao/d1WalletCeremonyActivity.d.ts +15 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeIssuer.d.ts +6 -1
- package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeService.d.ts +2 -2
- package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeStore.d.ts +2 -1
- package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeVerifier.d.ts +4 -1
- package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpCounters.typecheck.d.ts +2 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpGrantStore.d.ts +0 -2
- package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpRateLimitStore.d.ts +6 -13
- package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpRecords.d.ts +21 -7
- package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1GoogleEmailOtpRegistrationAttemptStore.d.ts +29 -1
- package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1GoogleEmailOtpRegistrationRecords.d.ts +3 -16
- package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1GoogleEmailOtpSessionResolver.d.ts +7 -2
- package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1GoogleRegistrationCompletion.d.ts +23 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/identity/d1IdentityService.d.ts +0 -12
- package/dist/types/wallet-server/src/router/cloudflare/d1/near/d1SponsoredNearAccount.d.ts +24 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/near/d1SponsoredNearAccount.typecheck.d.ts +2 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/oidc/d1OidcVerificationService.d.ts +0 -1
- package/dist/types/wallet-server/src/router/cloudflare/d1/oidc/googleOidcToken.d.ts +4 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/passkeyCustody/d1PasskeyCustodyRouteService.d.ts +5 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/passkeyCustody/d1WalletCustodyCommitStore.d.ts +26 -1
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1RegistrationCeremonyRecordStore.d.ts +33 -8
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1RegistrationCeremonyRecords.d.ts +10 -11
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1RegistrationCeremonyStore.d.ts +17 -7
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1RegistrationSessionTransaction.d.ts +13 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1RegistrationSetupSupport.d.ts +58 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1WalletExecutionAuthority.d.ts +41 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1WalletOperationStore.d.ts +28 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1WalletRegistrationCommitStore.d.ts +9 -9
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1WalletRegistrationInitialSession.d.ts +17 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1WalletRegistrationPreparation.d.ts +12 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1WalletRegistrationRead.d.ts +43 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1WalletRegistrationService.d.ts +52 -90
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1WalletRegistrationSetup.d.ts +3 -30
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1WalletRegistrationSetupExecution.d.ts +16 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/walletRegistrationEstablishedSessionIssuer.d.ts +42 -14
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/walletRegistrationSessionCommitReceipt.d.ts +5 -4
- package/dist/types/wallet-server/src/router/cloudflare/d1/signingAdmission/d1RouterAbNormalSigningAdmissionStore.d.ts +24 -1
- package/dist/types/wallet-server/src/router/cloudflare/d1/versionedJson/d1VersionedJsonRecordStore.d.ts +10 -4
- package/dist/types/wallet-server/src/router/cloudflare/d1/wallet/authorizationSnapshotLayout.d.ts +21 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/wallet/d1WalletAddSignerFinalizeRecord.d.ts +27 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/wallet/d1WalletAddSignerService.d.ts +4 -10
- package/dist/types/wallet-server/src/router/cloudflare/d1/wallet/d1WalletAuthMethodService.d.ts +5 -9
- package/dist/types/wallet-server/src/router/cloudflare/d1/wallet/d1WalletAuthorityStore.d.ts +8 -4
- package/dist/types/wallet-server/src/router/cloudflare/d1/wallet/d1WalletAuthorizationCleanup.d.ts +20 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/wallet/d1WalletAuthorizationFreeze.d.ts +12 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/wallet/d1WalletAuthorizationHistory.d.ts +20 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/wallet/d1WalletAuthorizationIntake.d.ts +29 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/wallet/d1WalletAuthorizationSnapshot.d.ts +31 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/wallet/d1WalletRelocationApprovals.d.ts +49 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/wallet/d1WalletRelocationChallenges.d.ts +47 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/wallet/d1WalletRelocationEmailOtp.d.ts +25 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/wallet/d1WalletRelocationOwner.d.ts +88 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/wallet/d1WalletRelocationOwnerRequest.d.ts +37 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/wallet/d1WalletRelocationPasskey.d.ts +12 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/wallet/d1WalletRelocationReadAccess.d.ts +18 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/wallet/d1WalletRelocationSessions.d.ts +23 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/wallet/d1WalletRelocationWriteBlock.d.ts +16 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/walletObjectAddresses.d.ts +14 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/webauthn/d1WebAuthnAuthService.d.ts +3 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/webauthn/d1WebAuthnRecords.d.ts +0 -13
- package/dist/types/wallet-server/src/router/cloudflare/d1/webauthn/d1WebAuthnStore.d.ts +23 -10
- package/dist/types/wallet-server/src/router/cloudflare/d1/webauthn/d1WebAuthnStore.typecheck.d.ts +2 -0
- package/dist/types/wallet-server/src/router/cloudflare/runtime/cloudflare.types.d.ts +0 -2
- package/dist/types/wallet-server/src/router/cloudflare/runtime/routerAbServiceBindings.d.ts +13 -0
- package/dist/types/wallet-server/src/router/cloudflare/runtime/walletAuthorizationRelocationRoutes.d.ts +21 -0
- package/dist/types/wallet-server/src/router/cloudflare/runtime/walletConsoleOps.d.ts +1 -0
- package/dist/types/wallet-server/src/router/cloudflare/runtime/walletConsoleOpsClient.d.ts +3 -1
- package/dist/types/wallet-server/src/router/cloudflare/runtime/walletControlOps.d.ts +2 -1
- package/dist/types/wallet-server/src/router/cloudflare/runtime/walletGateway.d.ts +3 -1
- package/dist/types/wallet-server/src/router/cloudflare/runtime/walletObjectAddresses.d.ts +45 -0
- package/dist/types/wallet-server/src/router/cloudflare/runtime/walletPlacementRoutes.d.ts +30 -0
- package/dist/types/wallet-server/src/router/cloudflare/runtime/walletRelocationDeriver.d.ts +11 -0
- package/dist/types/wallet-server/src/router/cloudflare/runtime/walletRelocationEcdsa.d.ts +7 -0
- package/dist/types/wallet-server/src/router/cloudflare/runtime/walletRelocationEd25519.d.ts +7 -0
- package/dist/types/wallet-server/src/router/cloudflare/runtime/walletRelocationOps.d.ts +11 -0
- package/dist/types/wallet-server/src/router/cloudflare/runtime/walletRelocationPresign.d.ts +7 -0
- package/dist/types/wallet-server/src/router/cloudflare/runtime/walletRelocationSource.d.ts +26 -0
- package/dist/types/wallet-server/src/router/cloudflare/runtime/walletRuntimeOps.d.ts +3 -0
- package/dist/types/wallet-server/src/router/cloudflare/signingLanes/cloudflareOrdinaryInactiveSignerMaterialReservation.d.ts +5 -0
- package/dist/types/wallet-server/src/router/cloudflare-adaptor.d.ts +0 -1
- package/dist/types/wallet-server/src/router/domains/ecdsa/routerAbEcdsaStrictRegistration.d.ts +3 -0
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoCapabilityCommit.d.ts +7 -0
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistration.d.ts +42 -8
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistrationPartitionedStateStore.d.ts +33 -2
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistrationPartitioning.d.ts +2 -2
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/export/routerAbEd25519YaoExport.d.ts +14 -8
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/export/routerAbEd25519YaoExport.typecheck.d.ts +2 -0
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/export/routerAbEd25519YaoExportRequestScopedCloudflare.d.ts +2 -0
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/recovery/routerAbEd25519YaoRecovery.d.ts +17 -9
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/recovery/routerAbEd25519YaoRecoveryRequestScopedCloudflare.d.ts +2 -0
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/recovery/routerAbEd25519YaoRecoveryWalletSessionAuthorization.d.ts +2 -0
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/registration/routerAbEd25519YaoHttpRegistrationBackend.d.ts +13 -14
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistration.d.ts +7 -3
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistrationExecutionRecord.d.ts +1 -0
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistrationIntentAuthorization.d.ts +6 -1
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistrationSideEffectBoundary.d.ts +11 -0
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/routerAbEd25519YaoGatewayEnvelope.d.ts +12 -3
- package/dist/types/wallet-server/src/router/domains/passkeyCustody/passkeyCustodyEnvelopeRetrieval.d.ts +0 -2
- package/dist/types/wallet-server/src/router/domains/passkeyCustody/registrationCustodyOutcome.d.ts +10 -6
- package/dist/types/wallet-server/src/router/domains/passkeyCustody/walletCustodyRegistrationAdmission.d.ts +10 -3
- package/dist/types/wallet-server/src/router/domains/passkeyCustody/walletCustodyRegistrationCommit.d.ts +12 -8
- package/dist/types/wallet-server/src/router/domains/signingOperations/authorizedOperationWire.d.ts +97 -0
- package/dist/types/wallet-server/src/router/domains/signingOperations/ecdsaSigningResponse.d.ts +13 -0
- package/dist/types/wallet-server/src/router/domains/signingOperations/routerAbNormalSigningAdmission.d.ts +9 -206
- package/dist/types/wallet-server/src/router/domains/signingOperations/routerAbPrivateSigningWorker.d.ts +0 -17
- package/dist/types/wallet-server/src/router/domains/signingOperations/signingPrepareSession.d.ts +23 -0
- package/dist/types/wallet-server/src/router/domains/signingOperations/walletExecutionAdmission.d.ts +1 -2
- package/dist/types/wallet-server/src/router/domains/walletRegistration/registrationSessionSeal.d.ts +36 -0
- package/dist/types/wallet-server/src/router/domains/walletRegistration/walletRegistrationInputs.d.ts +8 -7
- package/dist/types/wallet-server/src/router/domains/walletRegistration/walletRegistrationReservation.d.ts +125 -0
- package/dist/types/wallet-server/src/router/domains/walletRegistration/walletRegistrationRoutes.d.ts +17 -15
- package/dist/types/wallet-server/src/router/domains/walletRegistration/walletRegistrationSetupPayload.d.ts +2 -2
- package/dist/types/wallet-server/src/router/framework/apiCredentialPorts.d.ts +24 -0
- package/dist/types/wallet-server/src/router/framework/authServicePort.d.ts +35 -41
- package/dist/types/wallet-server/src/router/framework/googleLoginResolution.typecheck.d.ts +2 -0
- package/dist/types/wallet-server/src/router/framework/registrationSetupDispatch.d.ts +13 -0
- package/dist/types/wallet-server/src/router/framework/routerApi.d.ts +3 -12
- package/dist/types/wallet-server/src/router/transport/fetch/routes/deviceLinking.d.ts +1 -1
- package/dist/types/wallet-server/src/router/transport/fetch/routes/deviceLinkingResponses.d.ts +17 -0
- package/dist/types/wallet-server/src/router/transport/fetch/routes/ecdsaOperationStepUpFactor.d.ts +37 -0
- package/dist/types/wallet-server/src/router/transport/fetch/routes/ed25519AuthorizedOperationRevalidation.d.ts +37 -0
- package/dist/types/wallet-server/src/router/transport/fetch/routes/thresholdEcdsa.d.ts +1 -17
- package/dist/types/wallet-server/src/storage/d1Sql.d.ts +0 -1
- package/dist/types/wallet-server/src/storage/tenantRoute.d.ts +1 -1
- package/migrations/d1-signer/0040_namespace_home_challenges.sql +16 -0
- package/migrations/d1-signer/0041_step_up_admission_expiry.sql +28 -0
- package/migrations/d1-signer/0042_deployment_resource_challenges.sql +4 -0
- package/migrations/d1-signer/0043_google_registration_candidate_claim.sql +2 -0
- package/migrations/d1-signer/0044_linked_device_bootstrap_imports.sql +6 -0
- package/migrations/d1-signer/0045_wallet_owned_capability_receipts.sql +29 -0
- package/migrations/d1-signer/0046_wallet_owned_signing_abuse.sql +41 -0
- package/migrations/d1-signer/0047_remove_unused_near_public_keys.sql +2 -0
- package/migrations/d1-signer/0048_operation_owner_scope.sql +45 -0
- package/migrations/d1-signer/0049_wallet_relocation_challenges.sql +16 -0
- package/migrations/d1-signer/0050_wallet_relocation_approvals.sql +14 -0
- package/migrations/d1-signer/0051_wallet_relocation_email_otp.sql +92 -0
- package/migrations/d1-signer/0052_wallet_relocation_session_fences.sql +91 -0
- package/migrations/d1-signer/0053_wallet_hosted_history_import.sql +164 -0
- package/migrations/d1-signer/0054_wallet_authorization_freeze.sql +318 -0
- package/migrations/d1-signer/0055_wallet_authorization_snapshot.sql +120 -0
- package/migrations/d1-signer/0056_wallet_authorization_history_import.sql +424 -0
- package/migrations/d1-signer/0057_wallet_authorization_intake.sql +44 -0
- package/migrations/d1-signer/0058_wallet_ceremony_activity.sql +59 -0
- package/migrations/d1-signer/0059_wallet_authorization_activation.sql +45 -0
- package/migrations/d1-signer/0060_wallet_authorization_cleanup.sql +153 -0
- package/migrations/d1-signer/0061_wallet_session_operation_settlement.sql +28 -0
- package/migrations/d1-signer/0062_wallet_step_up_operation_settlement.sql +204 -0
- package/migrations/d1-signer/0063_wallet_operation_history_transfer.sql +466 -0
- package/migrations/d1-signer/0064_wallet_execution_generations.sql +93 -0
- package/migrations/d1-signer/0065_wallet_operation_execution_generation.sql +37 -0
- package/migrations/d1-signer/0066_regional_deployment_admission.sql +59 -0
- package/migrations/d1-signer/0067_registration_completion_decision.sql +12 -0
- package/migrations/d1-signer/0068_registration_cancellation_write_fence.sql +24 -0
- package/migrations/d1-signer/0069_cancelled_registration_session_fence.sql +11 -0
- package/migrations/d1-signer/0070_wallet_passkey_relocation.sql +369 -0
- package/migrations/d1-signer/0071_regional_wallet_otp_counters.sql +98 -0
- package/migrations/d1-signer/0072_linked_device_relocation_history.sql +899 -0
- package/migrations/d1-signer/0073_wallet_recovery_relocation.sql +86 -0
- package/migrations/d1-signer/0074_email_otp_relocation.sql +158 -0
- package/migrations/d1-signer/0075_wallet_authorization_return.sql +107 -0
- package/migrations/d1-signer/0076_wallet_relocation_write_block.sql +406 -0
- package/migrations/d1-signer/0077_wallet_object_addresses.sql +24 -0
- package/package.json +2 -3
- package/src/README.md +33 -3
- package/cloudflare-router-ab/scripts/local-key-material.mjs +0 -29
- package/dist/esm/core/AuthService.js +0 -2
- package/dist/esm/core/NearPublicKeyStore.js +0 -200
- package/dist/esm/core/ThresholdService/stores/CloudflareDurableObjectStore.js +0 -397
- package/dist/esm/core/ThresholdService/stores/KeyStore.js +0 -140
- package/dist/esm/core/ThresholdService/stores/SessionStore.js +0 -361
- package/dist/esm/core/ThresholdService/stores/StoreConfig.js +0 -13
- package/dist/esm/core/ThresholdService/stores/exportReplayGuard.js +0 -7
- package/dist/esm/core/authService/AuthService.js +0 -594
- package/dist/esm/core/authService/bytes.js +0 -19
- package/dist/esm/core/authService/configValues.js +0 -15
- package/dist/esm/core/authService/emailOtpChallengeOperations.js +0 -123
- package/dist/esm/core/authService/emailOtpChallengeProof.js +0 -183
- package/dist/esm/core/authService/emailOtpChallengeVerification.js +0 -264
- package/dist/esm/core/authService/emailOtpChallenges.js +0 -225
- package/dist/esm/core/authService/emailOtpDelivery.js +0 -134
- package/dist/esm/core/authService/emailOtpGrant.js +0 -43
- package/dist/esm/core/authService/emailOtpRegistrationEnrollment.js +0 -144
- package/dist/esm/core/authService/emailOtpUnlock.js +0 -174
- package/dist/esm/core/authService/googleEmailOtpOperations.js +0 -141
- package/dist/esm/core/authService/googleEmailOtpRegistration.js +0 -587
- package/dist/esm/core/authService/identity.js +0 -42
- package/dist/esm/core/authService/identityOperations.js +0 -32
- package/dist/esm/core/authService/nearAccountOperations.js +0 -229
- package/dist/esm/core/authService/nearPublicKeyMetadata.js +0 -108
- package/dist/esm/core/authService/oidcVerification.js +0 -249
- package/dist/esm/core/authService/registrationThresholdHelpers.js +0 -30
- package/dist/esm/core/authService/runtime.js +0 -45
- package/dist/esm/core/authService/storeRegistry.js +0 -102
- package/dist/esm/core/authService/thresholdStoreSummary.js +0 -32
- package/dist/esm/core/authService/webauthnAuthority.js +0 -17
- package/dist/esm/core/defaultConfigsServer.js +0 -9
- package/dist/esm/core/hostedAccountIds.js +0 -225
- package/dist/esm/core/routerAbSigning/createRouterAbSigningRuntimes.js +0 -84
- package/dist/esm/core/signingLanes/LaneAggregateRevocationApplicationService.js +0 -86
- package/dist/esm/core/signingLanes/LaneEnrollmentActivation.js +0 -324
- package/dist/esm/core/signingLanes/LaneEnrollmentRevocation.js +0 -173
- package/dist/esm/core/signingLanes/LaneLifecycleApplicationService.js +0 -198
- package/dist/esm/core/signingLanes/ecdsaServerRetirement.js +0 -73
- package/dist/esm/core/signingLanes/ed25519ServerRetirement.js +0 -68
- package/dist/esm/core/storeBackends.js +0 -208
- package/dist/esm/core/utils.js +0 -14
- package/dist/esm/core/webAuthnStoreBackends.js +0 -198
- package/dist/esm/router/cloudflare/d1/near/d1NearPublicKeyStore.js +0 -49
- package/dist/esm/router/cloudflare/d1/signingLanes/d1EcdsaLanePrivateBindingResolver.js +0 -10
- package/dist/esm/router/cloudflare/d1/signingLanes/d1LaneAggregateRevocationApplicationService.js +0 -22
- package/dist/esm/router/cloudflare/d1/signingLanes/d1LaneEffectJournalStore.js +0 -166
- package/dist/esm/router/cloudflare/d1/signingLanes/d1LaneEnrollmentGateway.js +0 -38
- package/dist/esm/router/cloudflare/d1/signingLanes/d1LaneLifecycleApplicationService.js +0 -20
- package/dist/esm/router/cloudflare/d1/signingLanes/d1LaneLifecycleStore.js +0 -1459
- package/dist/esm/router/cloudflare/d1/signingLanes/d1LaneLockStore.js +0 -114
- package/dist/esm/router/cloudflare/d1/signingLanes/d1LaneProtocolCommitter.js +0 -16
- package/dist/esm/router/cloudflare/d1/signingLanes/d1LaneRecords.js +0 -171
- package/dist/esm/router/cloudflare/d1/signingLanes/index.js +0 -10
- package/dist/esm/router/cloudflare/durableObjects/thresholdStore.js +0 -397
- package/dist/esm/router/cloudflare/signingLanes/cloudflareLaneCurveExecution.js +0 -597
- package/dist/esm/router/cloudflare/signingLanes/cloudflareLaneProtocolCommitter.js +0 -273
- package/dist/esm/router/cloudflare/signingLanes/index.js +0 -4
- package/dist/esm/router/cloudflare/signingLanes/linkedDeviceEd25519CeremonyBinding.js +0 -32
- package/dist/esm/router/transport/fetch/routes/nearPublicKeys.js +0 -27
- package/dist/esm/shared-ts/src/signing-lanes/rotation.js +0 -8
- package/dist/esm/shared-ts/src/signing-lanes/rotationDigests.js +0 -358
- package/dist/esm/shared-ts/src/signing-lanes/rotationLifecycle.js +0 -313
- package/dist/esm/shared-ts/src/signing-lanes/rotationParsers.js +0 -532
- package/dist/esm/shared-ts/src/signing-lanes/rotationProtocolParsers.js +0 -323
- package/dist/esm/shared-ts/src/signing-lanes/rotationWireFields.js +0 -59
- package/dist/types/shared-ts/src/signing-lanes/participantDigest.typecheck.d.ts +0 -2
- package/dist/types/shared-ts/src/signing-lanes/rotation.typecheck.d.ts +0 -2
- package/dist/types/shared-ts/src/signing-lanes/rotationDigests.d.ts +0 -13
- package/dist/types/shared-ts/src/signing-lanes/rotationLifecycle.d.ts +0 -78
- package/dist/types/shared-ts/src/signing-lanes/rotationParsers.d.ts +0 -27
- package/dist/types/shared-ts/src/signing-lanes/rotationProtocolParsers.d.ts +0 -6
- package/dist/types/shared-ts/src/signing-lanes/rotationWireFields.d.ts +0 -20
- package/dist/types/shared-ts/src/wallet-recovery/recoveryCodeAttempt.d.ts +0 -59
- package/dist/types/wallet-server/src/core/AuthService.d.ts +0 -3
- package/dist/types/wallet-server/src/core/NearPublicKeyStore.d.ts +0 -48
- package/dist/types/wallet-server/src/core/ThresholdService/stores/CloudflareDurableObjectStore.d.ts +0 -21
- package/dist/types/wallet-server/src/core/ThresholdService/stores/KeyStore.d.ts +0 -40
- package/dist/types/wallet-server/src/core/ThresholdService/stores/SessionStore.d.ts +0 -98
- package/dist/types/wallet-server/src/core/ThresholdService/stores/StoreConfig.d.ts +0 -4
- package/dist/types/wallet-server/src/core/ThresholdService/stores/ThresholdStoreConfig.typecheck.d.ts +0 -2
- package/dist/types/wallet-server/src/core/ThresholdService/stores/exportReplayGuard.d.ts +0 -3
- package/dist/types/wallet-server/src/core/authService/AuthService.d.ts +0 -490
- package/dist/types/wallet-server/src/core/authService/bytes.d.ts +0 -3
- package/dist/types/wallet-server/src/core/authService/configValues.d.ts +0 -7
- package/dist/types/wallet-server/src/core/authService/emailOtpChallengeOperations.d.ts +0 -109
- package/dist/types/wallet-server/src/core/authService/emailOtpChallengeProof.d.ts +0 -169
- package/dist/types/wallet-server/src/core/authService/emailOtpChallengeVerification.d.ts +0 -47
- package/dist/types/wallet-server/src/core/authService/emailOtpChallenges.d.ts +0 -86
- package/dist/types/wallet-server/src/core/authService/emailOtpDelivery.d.ts +0 -66
- package/dist/types/wallet-server/src/core/authService/emailOtpGrant.d.ts +0 -43
- package/dist/types/wallet-server/src/core/authService/emailOtpRegistrationEnrollment.d.ts +0 -49
- package/dist/types/wallet-server/src/core/authService/emailOtpUnlock.d.ts +0 -64
- package/dist/types/wallet-server/src/core/authService/googleEmailOtpOperations.d.ts +0 -126
- package/dist/types/wallet-server/src/core/authService/googleEmailOtpRegistration.d.ts +0 -169
- package/dist/types/wallet-server/src/core/authService/identity.d.ts +0 -25
- package/dist/types/wallet-server/src/core/authService/identityOperations.d.ts +0 -19
- package/dist/types/wallet-server/src/core/authService/nearAccountOperations.d.ts +0 -55
- package/dist/types/wallet-server/src/core/authService/nearPublicKeyMetadata.d.ts +0 -44
- package/dist/types/wallet-server/src/core/authService/oidcVerification.d.ts +0 -66
- package/dist/types/wallet-server/src/core/authService/registrationThresholdHelpers.d.ts +0 -11
- package/dist/types/wallet-server/src/core/authService/runtime.d.ts +0 -20
- package/dist/types/wallet-server/src/core/authService/storeRegistry.d.ts +0 -53
- package/dist/types/wallet-server/src/core/authService/thresholdStoreSummary.d.ts +0 -3
- package/dist/types/wallet-server/src/core/authService/webauthnAuthority.d.ts +0 -5
- package/dist/types/wallet-server/src/core/defaultConfigsServer.d.ts +0 -5
- package/dist/types/wallet-server/src/core/hostedAccountIds.d.ts +0 -16
- package/dist/types/wallet-server/src/core/routerAbSigning/createRouterAbSigningRuntimes.d.ts +0 -16
- package/dist/types/wallet-server/src/core/signingLanes/LaneAggregateRevocationApplicationService.d.ts +0 -36
- package/dist/types/wallet-server/src/core/signingLanes/LaneEffectJournalStore.d.ts +0 -62
- package/dist/types/wallet-server/src/core/signingLanes/LaneEnrollmentActivation.d.ts +0 -13
- package/dist/types/wallet-server/src/core/signingLanes/LaneEnrollmentRevocation.d.ts +0 -24
- package/dist/types/wallet-server/src/core/signingLanes/LaneLifecycleApplicationService.d.ts +0 -141
- package/dist/types/wallet-server/src/core/signingLanes/LaneLifecycleStore.d.ts +0 -228
- package/dist/types/wallet-server/src/core/signingLanes/ecdsaServerRetirement.d.ts +0 -58
- package/dist/types/wallet-server/src/core/signingLanes/ed25519ServerRetirement.d.ts +0 -30
- package/dist/types/wallet-server/src/core/signingLanes/signingWorkerLaneMaterialIdentity.d.ts +0 -4
- package/dist/types/wallet-server/src/core/storeBackends.d.ts +0 -83
- package/dist/types/wallet-server/src/core/utils.d.ts +0 -3
- package/dist/types/wallet-server/src/core/webAuthnStoreBackends.d.ts +0 -96
- package/dist/types/wallet-server/src/router/cloudflare/d1/near/d1NearPublicKeyStore.d.ts +0 -29
- package/dist/types/wallet-server/src/router/cloudflare/d1/signingLanes/d1EcdsaLanePrivateBindingResolver.d.ts +0 -4
- package/dist/types/wallet-server/src/router/cloudflare/d1/signingLanes/d1LaneAggregateRevocationApplicationService.d.ts +0 -4
- package/dist/types/wallet-server/src/router/cloudflare/d1/signingLanes/d1LaneEffectJournalStore.d.ts +0 -24
- package/dist/types/wallet-server/src/router/cloudflare/d1/signingLanes/d1LaneEnrollmentGateway.d.ts +0 -20
- package/dist/types/wallet-server/src/router/cloudflare/d1/signingLanes/d1LaneLifecycleApplicationService.d.ts +0 -13
- package/dist/types/wallet-server/src/router/cloudflare/d1/signingLanes/d1LaneLifecycleStore.d.ts +0 -51
- package/dist/types/wallet-server/src/router/cloudflare/d1/signingLanes/d1LaneLockStore.d.ts +0 -28
- package/dist/types/wallet-server/src/router/cloudflare/d1/signingLanes/d1LaneProtocolCommitter.d.ts +0 -5
- package/dist/types/wallet-server/src/router/cloudflare/d1/signingLanes/d1LaneRecords.d.ts +0 -107
- package/dist/types/wallet-server/src/router/cloudflare/d1/signingLanes/index.d.ts +0 -10
- package/dist/types/wallet-server/src/router/cloudflare/durableObjects/thresholdStore.d.ts +0 -18
- package/dist/types/wallet-server/src/router/cloudflare/signingLanes/cloudflareLaneCurveExecution.d.ts +0 -217
- package/dist/types/wallet-server/src/router/cloudflare/signingLanes/cloudflareLaneProtocolCommitter.d.ts +0 -73
- package/dist/types/wallet-server/src/router/cloudflare/signingLanes/index.d.ts +0 -4
- package/dist/types/wallet-server/src/router/cloudflare/signingLanes/linkedDeviceEd25519CeremonyBinding.d.ts +0 -6
- package/dist/types/wallet-server/src/router/transport/fetch/routes/nearPublicKeys.d.ts +0 -3
- /package/dist/esm/{core/signingLanes/LaneEffectJournalStore.js → authorization/ed25519WalletSessionAdmission.js} +0 -0
- /package/dist/esm/{core/signingLanes/LaneLifecycleStore.js → authorization/recoveryRouting.js} +0 -0
- /package/dist/esm/{core/signingLanes/signingWorkerLaneMaterialIdentity.js → authorization/sessionRouting.js} +0 -0
|
@@ -1,75 +1,70 @@
|
|
|
1
|
-
import { mpcMaterialActivationRefsEqual, parseThresholdEd25519SessionId,
|
|
2
|
-
import {
|
|
1
|
+
import { mpcMaterialActivationRefsEqual, parseThresholdEd25519SessionId, parseWalletKeyId, parseWebAuthnCredentialIdB64u } from "../../../../shared-ts/src/utils/domainIds.js";
|
|
2
|
+
import { parseWalletSessionMintId } from "../../../../shared-ts/src/authorization/capabilityKinds.js";
|
|
3
|
+
import { normalizeOptionalTrimmedString } from "../../../../shared-ts/src/utils/normalize.js";
|
|
4
|
+
import { buildFullOwnerPermissionsV1 } from "../../../../shared-ts/src/authorization/delegatedAuthority.js";
|
|
3
5
|
import { base64UrlDecode, base64UrlEncode } from "../../../../shared-ts/src/utils/base64.js";
|
|
4
6
|
import { alphabetizeStringify, bytesToUnprefixedHex, sha256BytesUtf8 } from "../../../../shared-ts/src/utils/digests.js";
|
|
5
7
|
import { parseDigestB64u } from "../../../../shared-ts/src/utils/canonicalPrimitives.js";
|
|
6
|
-
import "../../../../shared-ts/src/utils/encoders.js";
|
|
7
|
-
import { normalizeOptionalTrimmedString } from "../../../../shared-ts/src/utils/normalize.js";
|
|
8
|
-
import { parseImplicitNearAccountId, parseNamedNearAccountId } from "../../../../shared-ts/src/utils/near.js";
|
|
9
|
-
import "../../../../shared-ts/src/utils/validation.js";
|
|
10
|
-
import { buildFullOwnerPermissionsV1 } from "../../../../shared-ts/src/authorization/delegatedAuthority.js";
|
|
11
8
|
import { parseEd25519PublicKeyB64u, parseSecp256k1CompressedPublicKeyB64u } from "../../../../shared-ts/src/passkey-custody/primitives.js";
|
|
9
|
+
import "../../../../shared-ts/src/utils/encoders.js";
|
|
12
10
|
import { buildExactAdministeredSignerManifestV1 } from "../../../../shared-ts/src/device-linking/delegatedActivationPlan.js";
|
|
13
11
|
import { routerAbMpcMaterialActivationRefFromWire, routerAbMpcMaterialActivationRefToWire, sameRouterAbMpcMaterialActivationRef } from "../../../../shared-ts/src/utils/routerAbNormalSigningIdentity.js";
|
|
14
12
|
import { deriveRouterAbEd25519YaoRuntimePolicyBindingV1 } from "../../../../shared-ts/src/utils/routerAbEd25519YaoDigests.js";
|
|
15
13
|
import { sameRouterAbEd25519YaoRegistrationAdmissionRequestV1 } from "../../../../shared-ts/src/utils/routerAbEd25519Yao.js";
|
|
16
14
|
import { ecdsaClientRootPublicKey33B64uFromString } from "../../../../shared-ts/src/threshold/ecdsaDerivationRoleLocalBootstrap.js";
|
|
17
|
-
import {
|
|
15
|
+
import { signingRootScopeFromRuntimePolicyScope } from "../../../../shared-ts/src/threshold/signingRootScope.js";
|
|
18
16
|
import { isEmailOtpWalletAuthAuthority, isPasskeyWalletAuthAuthority, walletAuthAuthoritiesMatch } from "../../../../shared-ts/src/utils/walletAuthAuthority.js";
|
|
19
17
|
import { ROUTER_AB_ECDSA_DERIVATION_NORMAL_SIGNING_STATE_KIND_V1, buildRouterAbEcdsaDerivationActiveStateIdV1, buildRouterAbEcdsaDerivationPublicCapabilityV1, parseRouterAbEcdsaDerivationNormalSigningStateV1, sameRouterAbEcdsaDerivationNormalSigningStateV1, sameRouterAbEcdsaDerivationPublicCapabilityV1, sameRouterAbEcdsaRegistrationActivationReceiptV1, sameRouterAbEcdsaVerifiedClientActivationFactsV1, sameRouterAbPublicDigest32V1Wire } from "../../../../shared-ts/src/utils/routerAbEcdsaDerivation.js";
|
|
20
18
|
import { buildWalletAuthMethodRecordV2 } from "../../../../shared-ts/src/utils/walletAuthMethodRecord.js";
|
|
21
19
|
import { buildActiveWalletAuthorityV1, buildWalletSignerActivationSetV1, computeWalletAuthorityDigestB64u, computeWalletSignerActivationSetDigestB64u, extendEcdsaWalletAuthorityWithEd25519, isActiveEcdsaWalletAuthorityV1 } from "../../../../shared-ts/src/authorization/walletAuthority.js";
|
|
22
|
-
import { secureRandomBase64Url } from "../../../../shared-ts/src/utils/secureRandomId.js";
|
|
23
20
|
import { ROUTER_AB_ED25519_NORMAL_SIGNING_STATE_KIND } from "../../../../shared-ts/src/utils/signingSessionSeal.js";
|
|
24
21
|
import { normalizeThresholdEd25519ParticipantIds } from "../../../../shared-ts/src/threshold/participants.js";
|
|
25
|
-
import { parseEcdsaDerivationPublicIdentity, thresholdEd25519AuthorityScopeFromWalletAuthAuthority } from "../../../../core/ThresholdService/validation.js";
|
|
26
22
|
import { nearEd25519SigningKeyIdFromString, registrationEd25519AuthorityScopeFromAuthority, walletIdFromString } from "../../../../shared-ts/src/utils/registrationIds.js";
|
|
27
|
-
import { registrationPreparationIdFromString } from "../../../../core/types.js";
|
|
28
|
-
import { buildTenantRootIdentityFromAuthenticatedDeploymentV1 } from "../../../../shared-ts/src/tenant-root/tenantRootIdentity.js";
|
|
29
23
|
import { walletCustodyCeremonyCommitPayloadFromWire } from "../../../../shared-ts/src/passkey-custody/ceremonyCommitPayload.js";
|
|
30
24
|
import "../../../../shared-ts/src/passkey-custody/index.js";
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
25
|
+
import { parseImplicitNearAccountId, parseNamedNearAccountId } from "../../../../shared-ts/src/utils/near.js";
|
|
26
|
+
import { registrationNearEd25519BranchKey } from "../../../../shared-ts/src/utils/registrationSignerPlan.js";
|
|
33
27
|
import { registrationIntentGrantFromString } from "../../../../shared-ts/src/utils/registrationIntent.js";
|
|
28
|
+
import { buildTenantRootIdentityFromAuthenticatedDeploymentV1 } from "../../../../shared-ts/src/tenant-root/tenantRootIdentity.js";
|
|
34
29
|
import { DEFAULT_WALLET_SESSION_TTL_MS } from "../../../../shared-ts/src/threshold/sessionPolicy.js";
|
|
30
|
+
import { parseEcdsaDerivationPublicIdentity, thresholdEd25519AuthorityScopeFromWalletAuthAuthority } from "../../../../core/ThresholdService/validation.js";
|
|
35
31
|
import { walletAuthAuthorityFromRegistrationAuthority, walletRegistrationFinalizeAuthMethodFromAuthority } from "../wallet/d1WalletAuthMethodBoundary.js";
|
|
36
32
|
import { buildRouterAbEd25519YaoRegistrationCapabilityRecordV1 } from "../../../domains/ed25519Yao/recovery/routerAbEd25519YaoRecovery.js";
|
|
37
33
|
import { buildRouterAbEd25519YaoProductAdmissionRequestV1, createRouterAbEd25519YaoMaterialActivationRefV1, projectRouterAbEd25519YaoExactWalletSession } from "../../../domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistration.js";
|
|
38
34
|
import { runRouterAbEd25519YaoRegistrationSideEffectV2, throwIfRouterAbEd25519YaoRetryableSideEffectFailureV1 } from "../../../domains/ed25519Yao/registration/routerAbEd25519YaoRegistrationSideEffectBoundary.js";
|
|
39
35
|
import { buildYaoEd25519WalletSignerRecord, ed25519NearPublicKeyFromBytes, implicitNearAccountIdFromEd25519PublicKeyBytes } from "../ed25519Yao/d1Ed25519YaoWalletSigner.js";
|
|
36
|
+
import { buildStoredWalletRegistrationEvmFamilyEcdsaFinalizedBranch, buildStoredWalletRegistrationNearEd25519YaoAuthorizedBranch, findStoredWalletRegistrationEvmFamilyEcdsaBranch, findStoredWalletRegistrationNearEd25519YaoBranch, replaceStoredWalletRegistrationSignerBranch, storedRegistrationAuthoritiesMatch, verifiedRegistrationCeremonyAuthority } from "../../../../core/RegistrationCeremonyStore.js";
|
|
37
|
+
import { routerAbEcdsaStrictRegistrationRequestBindingJson } from "../../../domains/ecdsa/routerAbEcdsaStrictRegistration.js";
|
|
38
|
+
import { buildD1EcdsaWalletKeysFromBootstrap, buildD1WalletEcdsaSignerRecords, buildD1WalletRecord, parseWalletIdForIntent, thresholdEcdsaChainTargetsEqual } from "./d1RegistrationCeremonyRecords.js";
|
|
40
39
|
import { deriveThresholdEcdsaKeyHandle } from "../../../../shared-ts/src/utils/thresholdEcdsaKeyHandle.js";
|
|
41
|
-
import {
|
|
42
|
-
import { buildStoredWalletRegistrationEvmFamilyEcdsaFinalizedBranch, buildStoredWalletRegistrationEvmFamilyEcdsaPreparedBranch, buildStoredWalletRegistrationNearEd25519YaoAuthorizedBranch, buildStoredWalletRegistrationPreparedContext, findStoredWalletRegistrationEvmFamilyEcdsaBranch, findStoredWalletRegistrationNearEd25519YaoBranch, replaceStoredWalletRegistrationSignerBranch, storedRegistrationAuthoritiesMatch, verifiedRegistrationCeremonyAuthority } from "../../../../core/RegistrationCeremonyStore.js";
|
|
43
|
-
import { buildD1EcdsaWalletKeysFromBootstrap, buildD1WalletEcdsaSignerRecords, buildD1WalletRecord, buildRegistrationIntent, createD1ServerAllocatedWalletId, inferRuntimePolicyScopeFromSigningRoot, normalizeThresholdEcdsaChainTargets, parseWalletIdForIntent, thresholdEcdsaChainTargetsEqual } from "./d1RegistrationCeremonyRecords.js";
|
|
44
|
-
import { resolveTenantRootIdentityV1 } from "../../../domains/tenantRoot/tenantRootIdentityResolution.js";
|
|
40
|
+
import { admitRegistrationReservationHome, cancelRegistrationHome } from "../../../domains/walletRegistration/walletRegistrationReservation.js";
|
|
45
41
|
import { listThresholdEcdsaKeyIdentityTargetsForUser } from "../../../../core/authService/thresholdEcdsaKeyInventory.js";
|
|
46
|
-
import { buildWalletRegistrationSetupSignature, normalizeWalletRegistrationSetupRequest, resolveWalletRegistrationSetupWalletId, storedRespondEd25519DeferredWork, walletRegistrationRespondResult, walletRegistrationSetupError, walletRegistrationSetupExpiresAtMs, walletRegistrationSetupIds, walletRegistrationSetupIntentDigest } from "./d1WalletRegistrationSetup.js";
|
|
47
|
-
import { commitRegistrationCustody } from "../../../domains/passkeyCustody/registrationCustodyOutcome.js";
|
|
48
|
-
import { buildD1EvmFamilyEcdsaRegistrationPrepare } from "./d1EvmFamilyEcdsaRegistrationBranch.js";
|
|
49
42
|
import { routerAbEd25519YaoLifecycleDecisionLookupV1, routerAbEd25519YaoLifecycleDecisionV1 } from "../../../domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoLifecycleDecision.js";
|
|
50
|
-
import {
|
|
43
|
+
import { reserveRegistrationCustody } from "../../../domains/passkeyCustody/registrationCustodyOutcome.js";
|
|
44
|
+
import { resolveTenantRootIdentityV1 } from "../../../domains/tenantRoot/tenantRootIdentityResolution.js";
|
|
45
|
+
import { walletRegistrationOperationPreparedFromCeremony } from "./d1WalletRegistrationPreparation.js";
|
|
46
|
+
import { computeWalletRegistrationSetupDigestB64u, parseWalletRegistrationSetupClaims, verifySignedWalletRegistrationSetup, verifyWalletRegistrationSetupClaims } from "../../../domains/walletRegistration/walletRegistrationSetupPayload.js";
|
|
47
|
+
import { createD1RegistrationRouteTimingRecorder, errorMessage, finishD1RegistrationRouteTiming, recordRegistrationPromiseTiming, recordRegistrationServerTiming, registrationSignerBranchesFromPlan, startD1RegistrationRouteTiming } from "./d1RegistrationSetupSupport.js";
|
|
48
|
+
import { projectWalletRegistrationSessionCommitReceiptV2, registrationCommitActivation, registrationReplayAuthMethodFields, replayedRegistrationCommit, unissuedRegistrationCommit } from "./walletRegistrationSessionCommitReceipt.js";
|
|
51
49
|
import { assertDirectWalletSessionOwnerProof, buildRegistrationOwnerProof, issueDirectRegistrationEstablishedEcdsaSession, issueDirectRegistrationEstablishedEd25519Session, projectCurrentNearRegistrationSession, replayDirectRegistrationEstablishedEcdsaSession, replayDirectRegistrationEstablishedEd25519Session, walletSessionPrincipalId } from "./walletRegistrationEstablishedSessionIssuer.js";
|
|
50
|
+
import { commitWalletRegistration } from "./d1WalletRegistrationInitialSession.js";
|
|
51
|
+
import { storedRespondEd25519DeferredWork, walletRegistrationRespondResult } from "./d1WalletRegistrationSetup.js";
|
|
52
|
+
import { executeD1WalletRegistrationSetup } from "./d1WalletRegistrationSetupExecution.js";
|
|
52
53
|
//#region src/router/cloudflare/d1/registration/d1WalletRegistrationService.ts
|
|
53
|
-
function
|
|
54
|
-
return {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
kind: "near_ed25519",
|
|
68
|
-
walletId: input.walletId,
|
|
69
|
-
authority: input.authority,
|
|
70
|
-
authMethod: input.authMethod,
|
|
71
|
-
nearProvisioning: { status: "near_pending" }
|
|
72
|
-
};
|
|
54
|
+
async function buildRespondEd25519AdmissionRequest(input) {
|
|
55
|
+
return buildRouterAbEd25519YaoProductAdmissionRequestV1({
|
|
56
|
+
registrationCeremonyId: input.ceremony.registrationCeremonyId,
|
|
57
|
+
walletId: input.ceremony.intent.walletId,
|
|
58
|
+
signingRootId: normalizeOptionalTrimmedString(input.ceremony.signingRootId) || "",
|
|
59
|
+
signingRootVersion: normalizeOptionalTrimmedString(input.ceremony.signingRootVersion) || "",
|
|
60
|
+
authorityScope: registrationEd25519AuthorityScopeFromAuthority(input.authority),
|
|
61
|
+
branch: input.branch,
|
|
62
|
+
signingWorkerId: input.signingWorkerId,
|
|
63
|
+
materialActivation: createRouterAbEd25519YaoMaterialActivationRefV1({
|
|
64
|
+
walletId: input.ceremony.intent.walletId,
|
|
65
|
+
signingWorkerId: input.signingWorkerId
|
|
66
|
+
})
|
|
67
|
+
});
|
|
73
68
|
}
|
|
74
69
|
function sameEd25519ParticipantIds(left, right) {
|
|
75
70
|
return left[0] === right[0] && left[1] === right[1];
|
|
@@ -92,7 +87,7 @@ function sameRouterAbEcdsaRegistrationRequest(left, right) {
|
|
|
92
87
|
return routerAbEcdsaStrictRegistrationRequestBindingJson(left) === routerAbEcdsaStrictRegistrationRequestBindingJson(right) && left.client_ephemeral_public_key === right.client_ephemeral_public_key && sameRouterAbEcdsaRegistrationEnvelope(left.deriver_a_envelope, right.deriver_a_envelope) && sameRouterAbEcdsaRegistrationEnvelope(left.deriver_b_envelope, right.deriver_b_envelope);
|
|
93
88
|
}
|
|
94
89
|
function sameEcdsaDerivationServerBootstrap(left, right) {
|
|
95
|
-
return left.formatVersion === right.formatVersion && left.walletId === right.walletId && left.evmFamilySigningKeySlotId === right.evmFamilySigningKeySlotId && left.ecdsaThresholdKeyId === right.ecdsaThresholdKeyId && left.relayerKeyId === right.relayerKeyId && left.applicationBindingDigestB64u === right.applicationBindingDigestB64u && left.contextBinding32B64u === right.contextBinding32B64u && sameEcdsaDerivationPublicIdentity(left.publicIdentity, right.publicIdentity) && left.clientShareRetryCounter === right.clientShareRetryCounter && left.relayerShareRetryCounter === right.relayerShareRetryCounter && left.
|
|
90
|
+
return left.formatVersion === right.formatVersion && left.walletId === right.walletId && left.evmFamilySigningKeySlotId === right.evmFamilySigningKeySlotId && left.ecdsaThresholdKeyId === right.ecdsaThresholdKeyId && left.relayerKeyId === right.relayerKeyId && left.applicationBindingDigestB64u === right.applicationBindingDigestB64u && left.contextBinding32B64u === right.contextBinding32B64u && sameEcdsaDerivationPublicIdentity(left.publicIdentity, right.publicIdentity) && left.clientShareRetryCounter === right.clientShareRetryCounter && left.relayerShareRetryCounter === right.relayerShareRetryCounter && left.keyHandle === right.keyHandle && left.signingRootId === right.signingRootId && left.signingRootVersion === right.signingRootVersion && left.thresholdEcdsaPublicKeyB64u === right.thresholdEcdsaPublicKeyB64u && left.ethereumAddress === right.ethereumAddress && left.relayerVerifyingShareB64u === right.relayerVerifyingShareB64u && sameEcdsaParticipantIds(left.participantIds, right.participantIds) && left.thresholdSessionId === right.thresholdSessionId && left.activationEpoch === right.activationEpoch && left.expiresAtMs === right.expiresAtMs && left.expiresAt === right.expiresAt && left.remainingUses === right.remainingUses && sameRouterAbEcdsaDerivationNormalSigningStateV1(left.routerAbEcdsaDerivationNormalSigning, right.routerAbEcdsaDerivationNormalSigning);
|
|
96
91
|
}
|
|
97
92
|
function linkedEd25519ProjectionMaterialActivationWire(projection) {
|
|
98
93
|
return routerAbMpcMaterialActivationRefToWire(projection.materialActivation);
|
|
@@ -203,23 +198,6 @@ function requirePreparedRegistrationId(result, label) {
|
|
|
203
198
|
if (!result.ok) throw new Error(`${label} is invalid: ${result.error.message}`);
|
|
204
199
|
return result.value;
|
|
205
200
|
}
|
|
206
|
-
function allocateWalletRegistrationOperationPrepared() {
|
|
207
|
-
return {
|
|
208
|
-
kind: "d1_wallet_registration_operation_prepared_v1",
|
|
209
|
-
walletAuthorityId: requirePreparedRegistrationId(parseWalletAuthorityId(`wallet-authority:${secureRandomBase64Url(32)}`), "walletAuthorityId"),
|
|
210
|
-
deviceId: requirePreparedRegistrationId(parseDeviceId(`device:${secureRandomBase64Url(32)}`), "deviceId"),
|
|
211
|
-
walletAuthMethodId: requirePreparedRegistrationId(parseWalletAuthMethodId(`wallet-auth-method:${secureRandomBase64Url(32)}`), "walletAuthMethodId")
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
function walletRegistrationOperationPreparedFromCeremony(ceremony) {
|
|
215
|
-
if (String(ceremony.foundingWalletAuthMethodId) !== String(ceremony.intent.foundingWalletAuthMethodId)) throw new Error("registration ceremony and intent name different founding auth methods");
|
|
216
|
-
return {
|
|
217
|
-
kind: "d1_wallet_registration_operation_prepared_v1",
|
|
218
|
-
walletAuthorityId: ceremony.foundingWalletAuthorityId,
|
|
219
|
-
deviceId: ceremony.foundingDeviceId,
|
|
220
|
-
walletAuthMethodId: ceremony.foundingWalletAuthMethodId
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
201
|
function committedInstallationProjectionFromCeremony(ceremony) {
|
|
224
202
|
const registrationAuthority = verifiedRegistrationCeremonyAuthority(ceremony);
|
|
225
203
|
if (ceremony.signerState.kind !== "signer_set_registration" || registrationAuthority === null) return null;
|
|
@@ -415,6 +393,16 @@ async function buildFoundingAuthorityRecords(input) {
|
|
|
415
393
|
function assertNeverFoundingSignerFacts(value) {
|
|
416
394
|
throw new Error(`Unsupported founding signer facts: ${String(value)}`);
|
|
417
395
|
}
|
|
396
|
+
function registrationOwnerProofContextFromCeremony(ceremony) {
|
|
397
|
+
const expectedOrigin = normalizeOptionalTrimmedString(ceremony.expectedOrigin);
|
|
398
|
+
const runtimePolicyScope = registrationPreparedContextRuntimePolicyScope(ceremony.preparedContext);
|
|
399
|
+
if (!expectedOrigin || !runtimePolicyScope) throw new Error("Registration is missing its session origin or runtime policy scope");
|
|
400
|
+
return {
|
|
401
|
+
expectedOrigin,
|
|
402
|
+
runtimePolicyScope,
|
|
403
|
+
expiresAtMs: ceremony.expiresAtMs
|
|
404
|
+
};
|
|
405
|
+
}
|
|
418
406
|
function registrationFinalizeCeremonyFromStored(ceremony) {
|
|
419
407
|
if (ceremony.signerState.kind !== "signer_set_registration") throw new Error("signer-set registration state is required");
|
|
420
408
|
return {
|
|
@@ -528,18 +516,12 @@ function ed25519AlreadyCommittedWalletSessionResponse(committed) {
|
|
|
528
516
|
function registrationWalletAuthAuthority(input) {
|
|
529
517
|
return walletAuthAuthorityFromRegistrationAuthority(input);
|
|
530
518
|
}
|
|
531
|
-
function errorMessage(error) {
|
|
532
|
-
return error instanceof Error ? error.message : String(error || "");
|
|
533
|
-
}
|
|
534
519
|
function assertNeverSponsoredNamedNearAccountCreationResult(value) {
|
|
535
520
|
throw new Error(`Unexpected sponsored NEAR account creation result: ${String(value)}`);
|
|
536
521
|
}
|
|
537
522
|
function isRegistrationEcdsaReadyReceipt(receipt) {
|
|
538
523
|
return receipt.committed.kind === "ecdsa_ready";
|
|
539
524
|
}
|
|
540
|
-
function isRegistrationNearPendingReceipt(receipt) {
|
|
541
|
-
return receipt.committed.kind === "near_pending";
|
|
542
|
-
}
|
|
543
525
|
function isRegistrationNearReadyReceipt(receipt) {
|
|
544
526
|
return receipt.committed.kind === "near_ready";
|
|
545
527
|
}
|
|
@@ -551,24 +533,6 @@ async function cleanupFinalizedRegistrationCeremony(input) {
|
|
|
551
533
|
await input.store.deleteCeremony(input.registrationCeremonyId);
|
|
552
534
|
} catch {}
|
|
553
535
|
}
|
|
554
|
-
function createD1RegistrationRouteTimingRecorder(route) {
|
|
555
|
-
return {
|
|
556
|
-
route,
|
|
557
|
-
entries: []
|
|
558
|
-
};
|
|
559
|
-
}
|
|
560
|
-
function startD1RegistrationRouteTiming(name) {
|
|
561
|
-
return {
|
|
562
|
-
name,
|
|
563
|
-
startedAtMs: Date.now()
|
|
564
|
-
};
|
|
565
|
-
}
|
|
566
|
-
function finishD1RegistrationRouteTiming(recorder, mark) {
|
|
567
|
-
recorder.entries.push({
|
|
568
|
-
name: mark.name,
|
|
569
|
-
durationMs: Math.max(0, Date.now() - mark.startedAtMs)
|
|
570
|
-
});
|
|
571
|
-
}
|
|
572
536
|
function d1RegistrationRouteDiagnostics(recorder) {
|
|
573
537
|
return {
|
|
574
538
|
kind: "wallet_registration_route_diagnostics_v1",
|
|
@@ -580,7 +544,6 @@ function d1RegistrationRouteDiagnostics(recorder) {
|
|
|
580
544
|
};
|
|
581
545
|
}
|
|
582
546
|
function withD1RegistrationRouteDiagnostics(response, recorder) {
|
|
583
|
-
if (!response.ok) return response;
|
|
584
547
|
return {
|
|
585
548
|
...response,
|
|
586
549
|
registrationDiagnostics: d1RegistrationRouteDiagnostics(recorder)
|
|
@@ -602,48 +565,6 @@ function hasEcdsaKeyHandleSetMismatch(expectedKeyHandles, actualKeyHandles) {
|
|
|
602
565
|
for (const keyHandle of expected) if (!actual.has(keyHandle)) return true;
|
|
603
566
|
return false;
|
|
604
567
|
}
|
|
605
|
-
function registrationIntentSignerBranches(intent) {
|
|
606
|
-
const plan = registrationSignerPlanFromSelection(intent.signerSelection);
|
|
607
|
-
if (!plan.ok) return plan;
|
|
608
|
-
return {
|
|
609
|
-
ok: true,
|
|
610
|
-
value: registrationSignerBranchesFromPlan(plan.value)
|
|
611
|
-
};
|
|
612
|
-
}
|
|
613
|
-
function registrationSignerBranchesFromPlan(plan) {
|
|
614
|
-
return {
|
|
615
|
-
plan,
|
|
616
|
-
nearEd25519: findRegistrationSignerPlanNearEd25519Branch(plan),
|
|
617
|
-
evmFamilyEcdsa: findRegistrationSignerPlanEvmFamilyEcdsaBranch(plan)
|
|
618
|
-
};
|
|
619
|
-
}
|
|
620
|
-
function resolveRegistrationPreparedContextFromPlan(input) {
|
|
621
|
-
const branches = registrationSignerBranchesFromPlan(input.signerPlan);
|
|
622
|
-
const ecdsaChainTargets = branches.evmFamilyEcdsa ? normalizeThresholdEcdsaChainTargets(branches.evmFamilyEcdsa.chainTargets) : null;
|
|
623
|
-
if (branches.evmFamilyEcdsa && !ecdsaChainTargets) return {
|
|
624
|
-
ok: false,
|
|
625
|
-
code: "invalid_body",
|
|
626
|
-
message: "ECDSA registration contains an invalid chain target"
|
|
627
|
-
};
|
|
628
|
-
try {
|
|
629
|
-
return {
|
|
630
|
-
ok: true,
|
|
631
|
-
preparedContext: buildStoredWalletRegistrationPreparedContext({
|
|
632
|
-
signingRootId: input.signingRootId,
|
|
633
|
-
signingRootVersion: input.signingRootVersion,
|
|
634
|
-
runtimePolicyScope: input.runtimePolicyScope || null,
|
|
635
|
-
ecdsaChainTargets
|
|
636
|
-
}),
|
|
637
|
-
ecdsaChainTargets
|
|
638
|
-
};
|
|
639
|
-
} catch (error) {
|
|
640
|
-
return {
|
|
641
|
-
ok: false,
|
|
642
|
-
code: "invalid_body",
|
|
643
|
-
message: errorMessage(error) || "registration prepared context is invalid"
|
|
644
|
-
};
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
568
|
function registrationPreparedContextRuntimePolicyScope(preparedContext) {
|
|
648
569
|
return preparedContext.runtimePolicy.kind === "runtime_policy_scope" ? preparedContext.runtimePolicy.scope : void 0;
|
|
649
570
|
}
|
|
@@ -659,9 +580,6 @@ function registrationTenantRootIdentity(preparedContext) {
|
|
|
659
580
|
});
|
|
660
581
|
return identity.ok ? identity.value : null;
|
|
661
582
|
}
|
|
662
|
-
function registrationPreparedContextEcdsaChainTargets(preparedContext) {
|
|
663
|
-
return preparedContext.ecdsa.kind === "evm_family_ecdsa_requested" ? preparedContext.ecdsa.chainTargets : null;
|
|
664
|
-
}
|
|
665
583
|
/**
|
|
666
584
|
* A verified authority must name the same wallet the intent does. A ceremony
|
|
667
585
|
* still awaiting its proof has no authority to disagree with, so it matches
|
|
@@ -837,7 +755,6 @@ async function buildActivatedEcdsaFamilyBootstrap(input) {
|
|
|
837
755
|
publicIdentity,
|
|
838
756
|
clientShareRetryCounter: input.publicFacts.clientShareRetryCounter,
|
|
839
757
|
relayerShareRetryCounter: identity.server_share_retry_counter,
|
|
840
|
-
publicTranscriptDigest32B64u: input.publicFacts.proofTranscriptDigestB64u,
|
|
841
758
|
keyHandle,
|
|
842
759
|
signingRootId: prepare.signingRootId,
|
|
843
760
|
signingRootVersion: prepare.signingRootVersion,
|
|
@@ -936,19 +853,14 @@ function mergeRouterServerTiming(target, header) {
|
|
|
936
853
|
}
|
|
937
854
|
}
|
|
938
855
|
}
|
|
939
|
-
function recordRegistrationServerTiming(sink, name, startedAtMs) {
|
|
940
|
-
sink.push([name, Math.max(0, Date.now() - startedAtMs)]);
|
|
941
|
-
}
|
|
942
|
-
async function recordRegistrationPromiseTiming(args) {
|
|
943
|
-
try {
|
|
944
|
-
return await args.promise;
|
|
945
|
-
} finally {
|
|
946
|
-
recordRegistrationServerTiming(args.sink, args.name, args.startedAtMs);
|
|
947
|
-
}
|
|
948
|
-
}
|
|
949
856
|
var CloudflareD1WalletRegistrationService = class {
|
|
950
857
|
constructor(input) {
|
|
858
|
+
this.home = input.home;
|
|
859
|
+
this.executionAuthority = input.executionAuthority;
|
|
860
|
+
this.registrationAuthority = input.registrationAuthority;
|
|
861
|
+
this.startRegistrationWallets = input.startRegistrationWallets;
|
|
951
862
|
this.authorizationService = input.authorizationService;
|
|
863
|
+
this.registrationSessionStore = input.registrationSessionStore;
|
|
952
864
|
this.authorizationTenantId = input.authorizationTenantId;
|
|
953
865
|
this.createSponsoredNamedNearAccount = input.createSponsoredNamedNearAccount;
|
|
954
866
|
this.emailOtpRegistrationEnrollmentFinalizer = input.emailOtpRegistrationEnrollmentFinalizer;
|
|
@@ -958,7 +870,7 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
958
870
|
this.tenantRootCustodyLineage = input.tenantRootCustodyLineage;
|
|
959
871
|
this.getWalletStore = input.getWalletStore;
|
|
960
872
|
this.activateSideEffects = input.activateSideEffects;
|
|
961
|
-
this.
|
|
873
|
+
this.registrationRead = input.registrationRead;
|
|
962
874
|
this.walletRegistrationCommitStore = input.walletRegistrationCommitStore;
|
|
963
875
|
this.walletCustodyCommitStore = input.walletCustodyCommitStore;
|
|
964
876
|
this.walletAuthMethods = input.walletAuthMethods;
|
|
@@ -968,7 +880,7 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
968
880
|
async resolveEd25519MaterialActivation(input) {
|
|
969
881
|
try {
|
|
970
882
|
const walletId = walletIdFromString(input.walletId);
|
|
971
|
-
const signer = await this.getWalletStore().getEd25519SignerByMaterialActivation({
|
|
883
|
+
const signer = input.signerRead ? input.signerRead.resolve(walletId, input.materialActivation) : await this.getWalletStore().getEd25519SignerByMaterialActivation({
|
|
972
884
|
walletId,
|
|
973
885
|
materialActivation: input.materialActivation
|
|
974
886
|
});
|
|
@@ -1029,14 +941,15 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
1029
941
|
exportIdentity: await ed25519ExportIdentityFromLinkedProjection(projection, active.capability)
|
|
1030
942
|
};
|
|
1031
943
|
}
|
|
1032
|
-
const
|
|
944
|
+
const lookup = {
|
|
1033
945
|
kind: "router_ab_ed25519_yao_active_capability_lookup_v1",
|
|
1034
946
|
walletId: input.walletId,
|
|
1035
947
|
nearEd25519SigningKeyId: signer.nearEd25519SigningKeyId,
|
|
1036
948
|
signerSlot: signer.signerSlot,
|
|
1037
949
|
signingWorkerId: signer.signingWorkerId,
|
|
1038
950
|
participantIds: signer.participantIds
|
|
1039
|
-
}
|
|
951
|
+
};
|
|
952
|
+
const active = input.signerRead?.resolveActiveCapability(lookup) ?? await yaoRuntime.resolveActiveCapability(lookup);
|
|
1040
953
|
if (!active.ok) {
|
|
1041
954
|
if (active.code === "unknown_capability") {
|
|
1042
955
|
if (!sameRouterAbMpcMaterialActivationRef(signer.activeYaoCapability.activationResult.binding.material_activation, input.materialActivation)) return {
|
|
@@ -1202,8 +1115,15 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
1202
1115
|
code: "not_found",
|
|
1203
1116
|
message: "ECDSA tenant root is not active"
|
|
1204
1117
|
};
|
|
1118
|
+
const home = await this.executionAuthority.admitEstablishedHome({ walletId: walletIdFromString(input.walletId) });
|
|
1119
|
+
if (!home.ok) return {
|
|
1120
|
+
ok: false,
|
|
1121
|
+
code: "invalid_state",
|
|
1122
|
+
message: home.message
|
|
1123
|
+
};
|
|
1205
1124
|
return {
|
|
1206
1125
|
ok: true,
|
|
1126
|
+
ownershipGeneration: home.ownershipGeneration,
|
|
1207
1127
|
...tenantRoot
|
|
1208
1128
|
};
|
|
1209
1129
|
} catch (error) {
|
|
@@ -1664,148 +1584,14 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
1664
1584
|
};
|
|
1665
1585
|
}
|
|
1666
1586
|
}
|
|
1667
|
-
/**
|
|
1668
|
-
* `/wallets/register/setup` — grant, intent, and start in one request, with
|
|
1669
|
-
* one D1 write.
|
|
1670
|
-
*
|
|
1671
|
-
* Setup runs before the client's WebAuthn create, because it issues the
|
|
1672
|
-
* challenge that create signs. So the ECDSA prepare and the Ed25519
|
|
1673
|
-
* admission — the two Router calls that dominated the measured cold path —
|
|
1674
|
-
* overlap the authenticator prompt instead of being serialized after it.
|
|
1675
|
-
* They are started before either is awaited: they share no state and neither
|
|
1676
|
-
* can invalidate the other.
|
|
1677
|
-
*/
|
|
1678
1587
|
async setupWalletRegistration(input) {
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
parseProvided: parseWalletIdForIntent,
|
|
1687
|
-
createServerAllocated: createD1ServerAllocatedWalletId
|
|
1688
|
-
});
|
|
1689
|
-
if (!wallet.ok) return walletRegistrationSetupError(wallet.code, wallet.message);
|
|
1690
|
-
const runtimePolicyScope = input.runtimePolicyScope || inferRuntimePolicyScopeFromSigningRoot({
|
|
1691
|
-
orgId: input.orgId,
|
|
1692
|
-
signingRootId: input.signingRootId,
|
|
1693
|
-
signingRootVersion: input.signingRootVersion
|
|
1694
|
-
});
|
|
1695
|
-
const signingRootId = normalizeOptionalTrimmedString(input.signingRootId) || (runtimePolicyScope ? deriveSigningRootId(runtimePolicyScope) : "");
|
|
1696
|
-
const signingRootVersion = normalizeOptionalTrimmedString(input.signingRootVersion) || runtimePolicyScope?.signingRootVersion || "default";
|
|
1697
|
-
if (!signingRootId) return walletRegistrationSetupError("invalid_body", "registration requires a signing root");
|
|
1698
|
-
const registrationOperation = allocateWalletRegistrationOperationPrepared();
|
|
1699
|
-
const intent = buildRegistrationIntent({
|
|
1700
|
-
walletId: wallet.walletId,
|
|
1701
|
-
authMethod: normalized.authMethod,
|
|
1702
|
-
signerSelection: normalized.signerSelection,
|
|
1703
|
-
foundingWalletAuthMethodId: registrationOperation.walletAuthMethodId,
|
|
1704
|
-
...runtimePolicyScope ? { runtimePolicyScope } : {}
|
|
1705
|
-
});
|
|
1706
|
-
const digestB64u = await walletRegistrationSetupIntentDigest(intent);
|
|
1707
|
-
const branches = registrationIntentSignerBranches(intent);
|
|
1708
|
-
if (!branches.ok) return walletRegistrationSetupError(branches.code, branches.message);
|
|
1709
|
-
const ecdsaBranch = branches.value.evmFamilyEcdsa;
|
|
1710
|
-
const nearEd25519Branch = branches.value.nearEd25519;
|
|
1711
|
-
if (!ecdsaBranch && !nearEd25519Branch) return walletRegistrationSetupError("invalid_body", "registration signer branch is required");
|
|
1712
|
-
const preparedContext = resolveRegistrationPreparedContextFromPlan({
|
|
1713
|
-
signerPlan: branches.value.plan,
|
|
1714
|
-
runtimePolicyScope,
|
|
1715
|
-
signingRootId,
|
|
1716
|
-
signingRootVersion
|
|
1717
|
-
});
|
|
1718
|
-
if (!preparedContext.ok) return walletRegistrationSetupError(preparedContext.code, preparedContext.message);
|
|
1719
|
-
if (ecdsaBranch && !runtimePolicyScope) return walletRegistrationSetupError("invalid_body", "ECDSA registration requires an exact runtime policy scope");
|
|
1720
|
-
const chainTargets = ecdsaBranch ? registrationPreparedContextEcdsaChainTargets(preparedContext.preparedContext) : null;
|
|
1721
|
-
if (ecdsaBranch && !chainTargets) return walletRegistrationSetupError("invalid_body", "ECDSA chain targets are required");
|
|
1722
|
-
const expiresAtMs = walletRegistrationSetupExpiresAtMs(Date.now());
|
|
1723
|
-
const { registrationCeremonyId, registrationPreparationId } = walletRegistrationSetupIds();
|
|
1724
|
-
const ecdsaPrepared = ecdsaBranch && chainTargets && runtimePolicyScope ? await buildD1EvmFamilyEcdsaRegistrationPrepare({
|
|
1725
|
-
registrationPurpose: "wallet_registration",
|
|
1726
|
-
registrationCeremonyId,
|
|
1727
|
-
registrationPreparationId: registrationPreparationIdFromString(registrationPreparationId),
|
|
1728
|
-
walletId: wallet.walletId,
|
|
1729
|
-
signingRootId,
|
|
1730
|
-
signingRootVersion,
|
|
1731
|
-
chainTargets,
|
|
1732
|
-
participantIds: [...ecdsaBranch.participantIds],
|
|
1733
|
-
strictRegistration: this.ecdsaStrictRegistration,
|
|
1734
|
-
runtimePolicyScope
|
|
1735
|
-
}) : null;
|
|
1736
|
-
if (ecdsaPrepared && !ecdsaPrepared.ok) return walletRegistrationSetupError(ecdsaPrepared.code, ecdsaPrepared.message);
|
|
1737
|
-
const storedBranches = [];
|
|
1738
|
-
if (ecdsaPrepared?.ok && ecdsaBranch) storedBranches.push(buildStoredWalletRegistrationEvmFamilyEcdsaPreparedBranch({
|
|
1739
|
-
branchKey: ecdsaBranch.branchKey,
|
|
1740
|
-
ecdsa: {
|
|
1741
|
-
kind: ecdsaPrepared.ecdsa.kind,
|
|
1742
|
-
chainTargets: ecdsaPrepared.ecdsa.chainTargets,
|
|
1743
|
-
prepare: ecdsaPrepared.ecdsa.prepare,
|
|
1744
|
-
strictRegistration: ecdsaPrepared.ecdsa.strictRegistration,
|
|
1745
|
-
strictRegistrationBindingJson: routerAbEcdsaStrictRegistrationFactsBindingJson(ecdsaPrepared.ecdsa.strictRegistration)
|
|
1746
|
-
}
|
|
1747
|
-
}));
|
|
1748
|
-
const ceremony = {
|
|
1749
|
-
registrationCeremonyId,
|
|
1750
|
-
foundingWalletAuthorityId: registrationOperation.walletAuthorityId,
|
|
1751
|
-
foundingDeviceId: registrationOperation.deviceId,
|
|
1752
|
-
foundingWalletAuthMethodId: registrationOperation.walletAuthMethodId,
|
|
1753
|
-
intent,
|
|
1754
|
-
digestB64u,
|
|
1755
|
-
signerPlan: branches.value.plan,
|
|
1756
|
-
preparedContext: preparedContext.preparedContext,
|
|
1757
|
-
orgId: normalizeOptionalTrimmedString(input.orgId) || "",
|
|
1758
|
-
signingRootId,
|
|
1759
|
-
signingRootVersion,
|
|
1760
|
-
...input.expectedOrigin ? { expectedOrigin: input.expectedOrigin } : {},
|
|
1761
|
-
expiresAtMs,
|
|
1762
|
-
authorityState: {
|
|
1763
|
-
kind: "awaiting_proof",
|
|
1764
|
-
authMethod: normalized.authMethod
|
|
1765
|
-
},
|
|
1766
|
-
signerState: {
|
|
1767
|
-
kind: "signer_set_registration",
|
|
1768
|
-
branches: storedBranches
|
|
1769
|
-
}
|
|
1770
|
-
};
|
|
1771
|
-
const ceremonyWriteTiming = startD1RegistrationRouteTiming("registrationCeremonyInsertMs");
|
|
1772
|
-
try {
|
|
1773
|
-
await this.getRegistrationCeremonyIntentStore().putCeremony(ceremony);
|
|
1774
|
-
} finally {
|
|
1775
|
-
finishD1RegistrationRouteTiming(timing, ceremonyWriteTiming);
|
|
1776
|
-
}
|
|
1777
|
-
const { signedSetup } = await buildWalletRegistrationSetupSignature({
|
|
1778
|
-
signer: input.signer,
|
|
1779
|
-
ceremony,
|
|
1780
|
-
expectedOrigin: input.expectedOrigin
|
|
1781
|
-
});
|
|
1782
|
-
finishD1RegistrationRouteTiming(timing, total);
|
|
1783
|
-
const success = {
|
|
1784
|
-
ok: true,
|
|
1785
|
-
registrationCeremonyId,
|
|
1786
|
-
walletId: String(wallet.walletId),
|
|
1787
|
-
walletAuthMethodId: registrationOperation.walletAuthMethodId,
|
|
1788
|
-
registrationIntentDigestB64u: digestB64u,
|
|
1789
|
-
intent,
|
|
1790
|
-
signedSetup
|
|
1791
|
-
};
|
|
1792
|
-
if (!ecdsaPrepared?.ok || !ecdsaBranch) return {
|
|
1793
|
-
...success,
|
|
1794
|
-
kind: "near_ed25519"
|
|
1795
|
-
};
|
|
1796
|
-
return {
|
|
1797
|
-
...success,
|
|
1798
|
-
kind: nearEd25519Branch ? "near_ed25519_and_evm_family_ecdsa" : "evm_family_ecdsa",
|
|
1799
|
-
ecdsa: {
|
|
1800
|
-
kind: ecdsaPrepared.ecdsa.kind,
|
|
1801
|
-
chainTargets: ecdsaPrepared.ecdsa.chainTargets,
|
|
1802
|
-
prepare: ecdsaPrepared.ecdsa.prepare,
|
|
1803
|
-
strictRegistration: ecdsaPrepared.ecdsa.strictRegistration
|
|
1804
|
-
}
|
|
1805
|
-
};
|
|
1806
|
-
} catch (error) {
|
|
1807
|
-
return walletRegistrationSetupError("internal", errorMessage(error) || "Failed to set up wallet registration");
|
|
1808
|
-
}
|
|
1588
|
+
return executeD1WalletRegistrationSetup(input, {
|
|
1589
|
+
home: this.home,
|
|
1590
|
+
reservation: this.registrationAuthority,
|
|
1591
|
+
store: this.getRegistrationCeremonyIntentStore(),
|
|
1592
|
+
ecdsaStrictRegistration: this.ecdsaStrictRegistration,
|
|
1593
|
+
startRegistrationWallets: this.startRegistrationWallets
|
|
1594
|
+
});
|
|
1809
1595
|
}
|
|
1810
1596
|
async authorizeWalletRegistrationNearAdmission(input) {
|
|
1811
1597
|
try {
|
|
@@ -1847,6 +1633,11 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
1847
1633
|
code: verifiedSetup.code,
|
|
1848
1634
|
message: verifiedSetup.message
|
|
1849
1635
|
};
|
|
1636
|
+
const homeAdmission = await admitRegistrationReservationHome(this.registrationAuthority, {
|
|
1637
|
+
ceremonyId: ceremony.registrationCeremonyId,
|
|
1638
|
+
walletId: ceremony.intent.walletId
|
|
1639
|
+
});
|
|
1640
|
+
if (!homeAdmission.ok) return homeAdmission;
|
|
1850
1641
|
const registrationBearerToken = normalizeOptionalTrimmedString(input.signedSetup);
|
|
1851
1642
|
if (!registrationBearerToken) return {
|
|
1852
1643
|
ok: false,
|
|
@@ -1877,7 +1668,8 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
1877
1668
|
ceremony,
|
|
1878
1669
|
branch: branches.nearEd25519,
|
|
1879
1670
|
authority: verifiedAuthority.authority,
|
|
1880
|
-
registrationBearerToken
|
|
1671
|
+
registrationBearerToken,
|
|
1672
|
+
ownershipGeneration: homeAdmission.ownershipGeneration
|
|
1881
1673
|
});
|
|
1882
1674
|
if (!admitted.ok) return admitted;
|
|
1883
1675
|
if (!admitted.deferred) return {
|
|
@@ -1906,9 +1698,19 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
1906
1698
|
};
|
|
1907
1699
|
try {
|
|
1908
1700
|
const store = this.getRegistrationCeremonyIntentStore();
|
|
1701
|
+
const verifiedSetup = await verifyWalletRegistrationSetupClaims(input.verifier, input.signedSetup, {
|
|
1702
|
+
registrationCeremonyId: input.registrationCeremonyId,
|
|
1703
|
+
nowMs: Date.now()
|
|
1704
|
+
});
|
|
1705
|
+
if (!verifiedSetup.ok) return verifiedSetup;
|
|
1909
1706
|
const loadStartedAtMs = Date.now();
|
|
1910
|
-
const
|
|
1707
|
+
const homeAdmission = await this.registrationRead.readRespond({
|
|
1708
|
+
ceremonyId: verifiedSetup.claims.registrationCeremonyId,
|
|
1709
|
+
walletId: walletIdFromString(verifiedSetup.claims.walletId)
|
|
1710
|
+
});
|
|
1911
1711
|
mark("ecdsa_respond_d1_load", loadStartedAtMs);
|
|
1712
|
+
if (!homeAdmission.ok) return homeAdmission;
|
|
1713
|
+
const snapshot = homeAdmission.snapshot;
|
|
1912
1714
|
if (!snapshot) return {
|
|
1913
1715
|
ok: false,
|
|
1914
1716
|
code: "not_found",
|
|
@@ -1930,24 +1732,23 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
1930
1732
|
signingRootVersion: normalizeOptionalTrimmedString(ceremony.signingRootVersion) || "",
|
|
1931
1733
|
expectedOrigin
|
|
1932
1734
|
});
|
|
1933
|
-
|
|
1934
|
-
registrationCeremonyId: ceremony.registrationCeremonyId,
|
|
1935
|
-
setupDigestB64u,
|
|
1936
|
-
nowMs: Date.now()
|
|
1937
|
-
});
|
|
1938
|
-
if (!verifiedSetup.ok) return {
|
|
1735
|
+
if (verifiedSetup.claims.setupDigestB64u !== setupDigestB64u || verifiedSetup.claims.walletId !== ceremony.intent.walletId) return {
|
|
1939
1736
|
ok: false,
|
|
1940
|
-
code:
|
|
1941
|
-
message:
|
|
1737
|
+
code: "invalid_grant",
|
|
1738
|
+
message: "signedSetup does not match this registration setup"
|
|
1942
1739
|
};
|
|
1740
|
+
const ecdsaBranch = findStoredWalletRegistrationEvmFamilyEcdsaBranch(ceremony.signerState);
|
|
1741
|
+
const planNearEd25519 = registrationSignerBranchesFromPlan(ceremony.signerPlan).nearEd25519;
|
|
1742
|
+
const startedDispatchRoot = !ecdsaBranch && planNearEd25519 && !storedRespondEd25519DeferredWork(ceremony.signerState) ? this.getEd25519YaoProductRegistration()?.startRegistrationDispatchRoot({
|
|
1743
|
+
signing_root_id: normalizeOptionalTrimmedString(ceremony.signingRootId) || "",
|
|
1744
|
+
root_share_epoch: normalizeOptionalTrimmedString(ceremony.signingRootVersion) || ""
|
|
1745
|
+
}) ?? null : null;
|
|
1943
1746
|
const registrationBearerToken = normalizeOptionalTrimmedString(input.signedSetup);
|
|
1944
1747
|
if (!registrationBearerToken) return {
|
|
1945
1748
|
ok: false,
|
|
1946
1749
|
code: "invalid_body",
|
|
1947
1750
|
message: "signedSetup is required"
|
|
1948
1751
|
};
|
|
1949
|
-
const ecdsaBranch = findStoredWalletRegistrationEvmFamilyEcdsaBranch(ceremony.signerState);
|
|
1950
|
-
const planNearEd25519 = registrationSignerBranchesFromPlan(ceremony.signerPlan).nearEd25519;
|
|
1951
1752
|
if (!ecdsaBranch && !planNearEd25519) return {
|
|
1952
1753
|
ok: false,
|
|
1953
1754
|
code: "invalid_state",
|
|
@@ -1965,6 +1766,8 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
1965
1766
|
branch: planNearEd25519,
|
|
1966
1767
|
authorityInput: input.authority,
|
|
1967
1768
|
registrationBearerToken,
|
|
1769
|
+
ownershipGeneration: homeAdmission.ownershipGeneration,
|
|
1770
|
+
startedDispatchRoot,
|
|
1968
1771
|
expectedOrigin,
|
|
1969
1772
|
...input.userAgent ? { userAgent: input.userAgent } : {}
|
|
1970
1773
|
});
|
|
@@ -2078,6 +1881,7 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
2078
1881
|
message: "ECDSA response claim is invalid"
|
|
2079
1882
|
};
|
|
2080
1883
|
const tenantRoot = {
|
|
1884
|
+
ownershipGeneration: homeAdmission.ownershipGeneration,
|
|
2081
1885
|
projectEnvironmentId: claimedBranch.projectEnvironmentId,
|
|
2082
1886
|
identityDigestB64u: claimedBranch.tenantRootIdentityDigestB64u,
|
|
2083
1887
|
custodyLineageB64u: claimedBranch.tenantRootCustodyLineageB64u
|
|
@@ -2099,14 +1903,22 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
2099
1903
|
ceremony,
|
|
2100
1904
|
branch: nearEd25519Branch,
|
|
2101
1905
|
authority,
|
|
2102
|
-
registrationBearerToken
|
|
1906
|
+
registrationBearerToken,
|
|
1907
|
+
ownershipGeneration: homeAdmission.ownershipGeneration
|
|
2103
1908
|
})]);
|
|
2104
1909
|
mark("ecdsa_respond_router", routerStartedAtMs);
|
|
2105
1910
|
if (!strictResult.ok) {
|
|
2106
|
-
if (!strictResult.retryable)
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
1911
|
+
if (!strictResult.retryable) {
|
|
1912
|
+
const completedHome = await cancelRegistrationHome(this.registrationAuthority, {
|
|
1913
|
+
ceremonyId: ceremony.registrationCeremonyId,
|
|
1914
|
+
walletId: ceremony.intent.walletId
|
|
1915
|
+
});
|
|
1916
|
+
if (!completedHome.ok) return completedHome;
|
|
1917
|
+
await store.cancelTerminalCeremony({
|
|
1918
|
+
registrationCeremonyId: ceremony.registrationCeremonyId,
|
|
1919
|
+
walletId: ceremony.intent.walletId
|
|
1920
|
+
});
|
|
1921
|
+
}
|
|
2110
1922
|
return {
|
|
2111
1923
|
ok: false,
|
|
2112
1924
|
code: strictResult.code,
|
|
@@ -2178,34 +1990,6 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
2178
1990
|
};
|
|
2179
1991
|
}
|
|
2180
1992
|
}
|
|
2181
|
-
/**
|
|
2182
|
-
* The Ed25519 commit core, extracted so deferred provisioning reaches it
|
|
2183
|
-
* without going through the standalone finalize wrapper. The operation row
|
|
2184
|
-
* owns idempotency here, so the commit keeps no replay cache of its own.
|
|
2185
|
-
*/
|
|
2186
|
-
async readRegistrationOwnerProofContext(registrationCeremonyId) {
|
|
2187
|
-
const ceremony = await this.getRegistrationCeremonyIntentStore().getCeremony(registrationCeremonyId);
|
|
2188
|
-
if (!ceremony) {
|
|
2189
|
-
const committed = await this.readCommittedRegistrationInstallation(registrationCeremonyId);
|
|
2190
|
-
if (!committed) return null;
|
|
2191
|
-
if (!isRegistrationEcdsaReadyReceipt(committed.receipt)) throw new Error("Committed registration installation has no ECDSA session receipt");
|
|
2192
|
-
const runtimePolicyScope = registrationPreparedContextRuntimePolicyScope(committed.projection.preparedContext);
|
|
2193
|
-
if (!runtimePolicyScope) throw new Error("Committed registration is missing its runtime policy scope");
|
|
2194
|
-
return {
|
|
2195
|
-
expectedOrigin: committed.receipt.expectedOrigin,
|
|
2196
|
-
runtimePolicyScope,
|
|
2197
|
-
expiresAtMs: committed.receipt.expiresAtMs
|
|
2198
|
-
};
|
|
2199
|
-
}
|
|
2200
|
-
const expectedOrigin = normalizeOptionalTrimmedString(ceremony.expectedOrigin);
|
|
2201
|
-
const runtimePolicyScope = registrationPreparedContextRuntimePolicyScope(ceremony.preparedContext);
|
|
2202
|
-
if (!expectedOrigin || !runtimePolicyScope) throw new Error("Registration is missing its session origin or runtime policy scope");
|
|
2203
|
-
return {
|
|
2204
|
-
expectedOrigin,
|
|
2205
|
-
runtimePolicyScope,
|
|
2206
|
-
expiresAtMs: ceremony.expiresAtMs
|
|
2207
|
-
};
|
|
2208
|
-
}
|
|
2209
1993
|
/** For callers that must read the context before finalize tombstones it. */
|
|
2210
1994
|
async registrationOwnerProofWithContext(context, input) {
|
|
2211
1995
|
return await buildRegistrationOwnerProof({
|
|
@@ -2228,7 +2012,7 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
2228
2012
|
nowMs
|
|
2229
2013
|
});
|
|
2230
2014
|
if (!issued) return null;
|
|
2231
|
-
const active = await this.walletAuthMethods.
|
|
2015
|
+
const active = await this.walletAuthMethods.readActiveRegistrationIdentity(installation.projection.registrationAuthority);
|
|
2232
2016
|
if (!active || issued.session.walletId !== installation.projection.walletId || issued.session.authorityId !== installation.receipt.foundingAuthority.authorityId || issued.session.walletAuthMethodId !== installation.receipt.walletAuthMethodId || active.walletAuthMethodId !== issued.session.walletAuthMethodId || active.authority.authorityId !== issued.session.authorityId || active.authority.authorityDigestB64u !== issued.session.authorityDigestB64u || active.authority.revocationEpoch !== issued.session.authorityRevocationEpoch || active.authority.revocationEpoch !== installation.receipt.foundingAuthority.revocationEpoch || issued.session.expiresAtMs <= nowMs) return null;
|
|
2233
2017
|
const originalSubjects = installation.receipt.committed.session.walletSession.capabilitySubjects;
|
|
2234
2018
|
for (const subject of originalSubjects) if (!issued.session.capabilitySubjects.some(sameRegistrationContinuationSubject.bind(void 0, subject))) return null;
|
|
@@ -2269,64 +2053,70 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
2269
2053
|
});
|
|
2270
2054
|
const nearPlan = projection.signerPlan.branches.find((branch) => branch.kind === "near_ed25519");
|
|
2271
2055
|
const ecdsaPlan = projection.signerPlan.branches.find((branch) => branch.kind === "evm_family_ecdsa");
|
|
2272
|
-
if (projection.registrationCeremonyId !== registrationCeremonyId || projection.walletId !== receipt.walletId || projection.registrationAuthority.walletId !== receipt.walletId || projection.orgId !== (projection.preparedContext.runtimePolicy.kind === "runtime_policy_scope" ? projection.preparedContext.runtimePolicy.scope.orgId : "") || !nearPlan || !ecdsaPlan || !thresholdEcdsaChainTargetsEqual(ecdsaPlan.chainTargets, projection.preparedContext.ecdsa.kind === "evm_family_ecdsa_requested" ? projection.preparedContext.ecdsa.chainTargets : []) || !thresholdEcdsaChainTargetsEqual(ecdsaPlan.chainTargets, receipt.committed.ecdsa.walletKeys.map((walletKey) => walletKey.chainTarget)) || receipt.committed.ecdsa.walletKeys.some((walletKey) => walletKey.walletId !== String(receipt.walletId) || walletKey.signingRootId !== projection.preparedContext.signingRootId || walletKey.signingRootVersion !== projection.preparedContext.signingRootVersion || walletKey.participantIds.length !== ecdsaPlan.participantIds.length || walletKey.participantIds.some((participantId, index) => participantId !== ecdsaPlan.participantIds[index])) || projection.nearEd25519.branchKey !== nearPlan.branchKey || projection.nearEd25519.admissionRequest.scope.lifecycle_id !== registrationCeremonyId || projection.nearEd25519.admissionRequest.scope.account_id !== String(receipt.walletId) || projection.nearEd25519.admissionRequest.scope.root_share_epoch !== projection.preparedContext.signingRootVersion || projection.nearEd25519.admissionRequest.scope.signer_set_id !== String(nearPlan.branchKey) || projection.nearEd25519.admissionRequest.application_binding.wallet_id !== String(receipt.walletId) || projection.nearEd25519.admissionRequest.application_binding.signing_root_id !== projection.preparedContext.signingRootId || projection.nearEd25519.admissionRequest.application_binding.key_creation_signer_slot !== nearPlan.signerSlot || projection.nearEd25519.admissionRequest.participant_ids.length !== nearPlan.participantIds.length || projection.nearEd25519.admissionRequest.participant_ids.some((participantId, index) => participantId !== nearPlan.participantIds[index]) || !walletAuthAuthoritiesMatch(derivedAuthority, receipt.authority) || record.prepared.walletAuthorityId !== receipt.foundingAuthority.authorityId || record.prepared.deviceId !== foundingDeviceId || record.prepared.walletAuthMethodId !== receipt.walletAuthMethodId) throw new Error("registration activation receipt installation identity is invalid");
|
|
2056
|
+
if (projection.registrationCeremonyId !== registrationCeremonyId || projection.walletId !== receipt.walletId || projection.registrationAuthority.walletId !== receipt.walletId || projection.orgId !== (projection.preparedContext.runtimePolicy.kind === "runtime_policy_scope" ? projection.preparedContext.runtimePolicy.scope.orgId : "") || !nearPlan || !ecdsaPlan || !thresholdEcdsaChainTargetsEqual(ecdsaPlan.chainTargets, projection.preparedContext.ecdsa.kind === "evm_family_ecdsa_requested" ? projection.preparedContext.ecdsa.chainTargets : []) || !thresholdEcdsaChainTargetsEqual(ecdsaPlan.chainTargets, receipt.committed.ecdsa.walletKeys.map((walletKey) => walletKey.chainTarget)) || receipt.committed.ecdsa.walletKeys.some((walletKey) => walletKey.walletId !== String(receipt.walletId) || walletKey.signingRootId !== projection.preparedContext.signingRootId || walletKey.signingRootVersion !== projection.preparedContext.signingRootVersion || walletKey.participantIds.length !== ecdsaPlan.participantIds.length || walletKey.participantIds.some((participantId, index) => participantId !== ecdsaPlan.participantIds[index])) || projection.nearEd25519.branchKey !== nearPlan.branchKey || projection.nearEd25519.admissionRequest.scope.lifecycle_id !== registrationCeremonyId || projection.nearEd25519.admissionRequest.scope.account_id !== String(receipt.walletId) || projection.nearEd25519.admissionRequest.scope.root_share_epoch !== projection.preparedContext.signingRootVersion || projection.nearEd25519.admissionRequest.scope.signer_set_id !== String(nearPlan.branchKey) || projection.nearEd25519.admissionRequest.application_binding.wallet_id !== String(receipt.walletId) || projection.nearEd25519.admissionRequest.application_binding.signing_root_id !== projection.preparedContext.signingRootId || projection.nearEd25519.admissionRequest.application_binding.key_creation_signer_slot !== nearPlan.signerSlot || projection.nearEd25519.admissionRequest.participant_ids.length !== nearPlan.participantIds.length || projection.nearEd25519.admissionRequest.participant_ids.some((participantId, index) => participantId !== nearPlan.participantIds[index]) || !walletAuthAuthoritiesMatch(derivedAuthority, receipt.authority) || record.prepared.walletId !== receipt.walletId || record.prepared.walletAuthorityId !== receipt.foundingAuthority.authorityId || record.prepared.deviceId !== foundingDeviceId || record.prepared.walletAuthMethodId !== receipt.walletAuthMethodId) throw new Error("registration activation receipt installation identity is invalid");
|
|
2273
2057
|
return {
|
|
2274
2058
|
receipt,
|
|
2275
2059
|
projection,
|
|
2276
2060
|
prepared: record.prepared
|
|
2277
2061
|
};
|
|
2278
2062
|
}
|
|
2279
|
-
|
|
2280
|
-
|
|
2063
|
+
/** Carries the preparation's ceremony into this request's execution. */
|
|
2064
|
+
async prepareNearProvisioningOperation(registrationCeremonyId, allocated, source) {
|
|
2065
|
+
const ceremony = source.kind === "ceremony" ? source.ceremony : null;
|
|
2281
2066
|
if (!ceremony) {
|
|
2282
|
-
const committed =
|
|
2067
|
+
const committed = source.kind === "installation" ? source.installation : await this.readCommittedRegistrationInstallation(registrationCeremonyId);
|
|
2283
2068
|
if (!committed) throw new Error("Registration ceremony is unavailable for identity preparation");
|
|
2284
|
-
if (allocated && (allocated.walletAuthorityId !== committed.prepared.walletAuthorityId || allocated.deviceId !== committed.prepared.deviceId || allocated.walletAuthMethodId !== committed.prepared.walletAuthMethodId)) throw new Error("registration operation identity does not match its committed installation");
|
|
2285
|
-
return
|
|
2069
|
+
if (allocated && (allocated.walletId !== committed.prepared.walletId || allocated.walletAuthorityId !== committed.prepared.walletAuthorityId || allocated.deviceId !== committed.prepared.deviceId || allocated.walletAuthMethodId !== committed.prepared.walletAuthMethodId)) throw new Error("registration operation identity does not match its committed installation");
|
|
2070
|
+
return {
|
|
2071
|
+
prepared: committed.prepared,
|
|
2072
|
+
ceremony: null
|
|
2073
|
+
};
|
|
2286
2074
|
}
|
|
2287
|
-
const prepared = allocated ?? walletRegistrationOperationPreparedFromCeremony(ceremony);
|
|
2288
|
-
const authority = verifiedRegistrationCeremonyAuthority(ceremony);
|
|
2289
|
-
if (!authority) return prepared;
|
|
2290
|
-
const persisted = await this.walletAuthMethods.readActiveRegistrationIdentity(authority);
|
|
2291
|
-
if (!persisted) return prepared;
|
|
2292
2075
|
return {
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
deviceId: prepared.deviceId,
|
|
2296
|
-
walletAuthMethodId: persisted.walletAuthMethodId
|
|
2076
|
+
prepared: walletRegistrationOperationPreparedFromCeremony(ceremony, allocated),
|
|
2077
|
+
ceremony
|
|
2297
2078
|
};
|
|
2298
2079
|
}
|
|
2299
2080
|
async commitDeferredEd25519Signer(args, prepared) {
|
|
2081
|
+
const sourceStartedAtMs = Date.now();
|
|
2300
2082
|
const committedInstallation = args.authoritySource.kind === "committed_mixed" ? args.authoritySource.installation : null;
|
|
2301
2083
|
if (committedInstallation && !isRegistrationEcdsaReadyReceipt(committedInstallation.receipt)) throw new Error("Committed mixed registration receipt is not ECDSA-ready");
|
|
2302
|
-
const
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
if (!ownerProofContext) throw new Error("Registration owner proof context is unavailable");
|
|
2308
|
-
if (!ownerProofContext.runtimePolicyScope) throw new Error("Committed registration is missing its runtime policy scope");
|
|
2309
|
-
const ceremony = committedInstallation ? null : await this.getRegistrationCeremonyIntentStore().getCeremony(args.input.registrationCeremonyId);
|
|
2310
|
-
let recovery = null;
|
|
2311
|
-
let registrationAuthority;
|
|
2084
|
+
const preparedCeremony = committedInstallation ? null : args.preparedCeremony();
|
|
2085
|
+
const ceremony = committedInstallation || preparedCeremony ? preparedCeremony : await this.getRegistrationCeremonyIntentStore().getCeremony(args.input.registrationCeremonyId);
|
|
2086
|
+
let source;
|
|
2087
|
+
let ownerProofContext;
|
|
2088
|
+
let effectivePrepared;
|
|
2312
2089
|
let sessionPredecessor;
|
|
2313
2090
|
if (ceremony) {
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2091
|
+
source = {
|
|
2092
|
+
kind: "stored_ceremony",
|
|
2093
|
+
ceremony
|
|
2094
|
+
};
|
|
2095
|
+
ownerProofContext = registrationOwnerProofContextFromCeremony(ceremony);
|
|
2096
|
+
if (!verifiedRegistrationCeremonyAuthority(ceremony)) throw new Error("Registration authority is unavailable before finalize");
|
|
2317
2097
|
sessionPredecessor = { kind: "ed25519_only" };
|
|
2098
|
+
effectivePrepared = walletRegistrationOperationPreparedFromCeremony(ceremony, prepared);
|
|
2318
2099
|
} else {
|
|
2319
2100
|
const committed = committedInstallation ?? await this.readCommittedRegistrationInstallation(args.input.registrationCeremonyId);
|
|
2320
2101
|
if (!committed) throw new Error("Committed registration installation is unavailable");
|
|
2321
|
-
|
|
2102
|
+
source = registrationFinalizeRecoveryFromCommittedInstallation({
|
|
2322
2103
|
setupClaims: args.setupClaims,
|
|
2323
2104
|
projection: committed.projection
|
|
2324
2105
|
});
|
|
2325
|
-
|
|
2326
|
-
if (!authority) throw new Error("Committed registration installation has no verified authority");
|
|
2327
|
-
registrationAuthority = authority;
|
|
2106
|
+
if (!verifiedRegistrationCeremonyAuthority(source.ceremony)) throw new Error("Committed registration installation has no verified authority");
|
|
2328
2107
|
const activationReceipt = committed.receipt;
|
|
2329
2108
|
if (!isRegistrationEcdsaReadyReceipt(activationReceipt)) throw new Error("Committed mixed registration receipt is not ECDSA-ready");
|
|
2109
|
+
const runtimePolicyScope = registrationPreparedContextRuntimePolicyScope(committed.projection.preparedContext);
|
|
2110
|
+
if (!runtimePolicyScope) throw new Error("Committed registration is missing its runtime policy scope");
|
|
2111
|
+
ownerProofContext = {
|
|
2112
|
+
expectedOrigin: activationReceipt.expectedOrigin,
|
|
2113
|
+
runtimePolicyScope,
|
|
2114
|
+
expiresAtMs: activationReceipt.expiresAtMs
|
|
2115
|
+
};
|
|
2116
|
+
effectivePrepared = (await this.prepareNearProvisioningOperation(args.input.registrationCeremonyId, prepared, {
|
|
2117
|
+
kind: "installation",
|
|
2118
|
+
installation: committed
|
|
2119
|
+
})).prepared;
|
|
2330
2120
|
if (activationReceipt.committed.session.tokens.kind !== "evm_family_ecdsa") throw new Error("Committed mixed registration is missing its ECDSA session projection");
|
|
2331
2121
|
if (args.input.authorization.kind === "wallet_session") {
|
|
2332
2122
|
const authorization = args.authoritySource.kind === "committed_mixed" ? args.authoritySource.authorization : null;
|
|
@@ -2341,57 +2131,100 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
2341
2131
|
ecdsa: activationReceipt.committed.session.tokens.ecdsa
|
|
2342
2132
|
};
|
|
2343
2133
|
}
|
|
2344
|
-
|
|
2345
|
-
const
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
walletCustodyCommit: args.input.walletCustodyCommit
|
|
2352
|
-
}, effectivePrepared, recovery);
|
|
2353
|
-
const finalized = committed.ok ? committed : throwIfRouterAbEd25519YaoRetryableSideEffectFailureV1(committed);
|
|
2354
|
-
if (!finalized.ok || finalized.kind !== "near_ed25519") return unissuedRegistrationCommit(finalized);
|
|
2134
|
+
recordRegistrationServerTiming(args.serverTiming, "near_finalize_source", sourceStartedAtMs);
|
|
2135
|
+
const ceremonyAuthority = verifiedRegistrationCeremonyAuthority(source.ceremony);
|
|
2136
|
+
if (!ceremonyAuthority) throw new Error("Registration authority is unavailable before finalize");
|
|
2137
|
+
const sessionAuthority = registrationWalletAuthAuthority({
|
|
2138
|
+
authority: ceremonyAuthority,
|
|
2139
|
+
walletAuthMethodId: effectivePrepared.walletAuthMethodId
|
|
2140
|
+
});
|
|
2355
2141
|
const proof = await buildRegistrationOwnerProof({
|
|
2356
2142
|
registrationCeremonyId: args.input.registrationCeremonyId,
|
|
2357
|
-
authMethod:
|
|
2358
|
-
authority:
|
|
2143
|
+
authMethod: walletRegistrationFinalizeAuthMethodFromAuthority(ceremonyAuthority),
|
|
2144
|
+
authority: sessionAuthority,
|
|
2359
2145
|
tenantId: this.authorizationTenantId,
|
|
2360
2146
|
expectedOrigin: ownerProofContext.expectedOrigin,
|
|
2361
2147
|
expiresAtMs: args.input.authorization.kind === "wallet_session" ? args.setupClaims.expiresAtMs : ownerProofContext.expiresAtMs
|
|
2362
2148
|
});
|
|
2363
|
-
const
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2149
|
+
const initialSessionPlan = sessionPredecessor.kind === "ed25519_only" && !registrationSignerBranchesFromPlan(source.ceremony.signerPlan).evmFamilyEcdsa ? {
|
|
2150
|
+
kind: "initial_near",
|
|
2151
|
+
store: this.registrationSessionStore,
|
|
2152
|
+
request: {
|
|
2153
|
+
authorizationService: this.authorizationService,
|
|
2154
|
+
authorizationTenantId: this.authorizationTenantId,
|
|
2155
|
+
registrationCeremonyId: args.input.registrationCeremonyId,
|
|
2156
|
+
authority: sessionAuthority,
|
|
2157
|
+
walletAuthMethodId: effectivePrepared.walletAuthMethodId,
|
|
2158
|
+
expiresAtMs: Date.now() + DEFAULT_WALLET_SESSION_TTL_MS,
|
|
2159
|
+
remainingUses: 3,
|
|
2160
|
+
proof
|
|
2161
|
+
}
|
|
2162
|
+
} : { kind: "separate" };
|
|
2163
|
+
const execution = await this.executeWalletRegistrationFinalize({
|
|
2164
|
+
kind: "near_ed25519",
|
|
2367
2165
|
registrationCeremonyId: args.input.registrationCeremonyId,
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2166
|
+
idempotencyKey: args.input.idempotencyKey,
|
|
2167
|
+
ed25519: args.input.ed25519,
|
|
2168
|
+
emailOtpEnrollment: args.input.emailOtpEnrollment,
|
|
2169
|
+
walletCustodyCommit: args.input.walletCustodyCommit
|
|
2170
|
+
}, effectivePrepared, source, args.serverTiming, initialSessionPlan, args.lifecycleDecision);
|
|
2171
|
+
if (!execution.ok) return unissuedRegistrationCommit(throwIfRouterAbEd25519YaoRetryableSideEffectFailureV1(execution));
|
|
2172
|
+
const finalized = execution.finalized;
|
|
2173
|
+
if (finalized.kind !== "near_ed25519") {
|
|
2174
|
+
await execution.custody;
|
|
2175
|
+
return unissuedRegistrationCommit({
|
|
2176
|
+
ok: false,
|
|
2177
|
+
code: "internal",
|
|
2178
|
+
message: "NEAR provisioning committed a non-NEAR branch"
|
|
2179
|
+
});
|
|
2180
|
+
}
|
|
2181
|
+
if (!this.registrationAuthority) throw new Error("Registration home completion is unavailable");
|
|
2182
|
+
const [issuance, custody] = await Promise.allSettled([recordRegistrationPromiseTiming({
|
|
2183
|
+
sink: args.serverTiming,
|
|
2184
|
+
name: "near_finalize_session_issue",
|
|
2185
|
+
startedAtMs: Date.now(),
|
|
2186
|
+
promise: issueDirectRegistrationEstablishedEd25519Session({
|
|
2187
|
+
homeCompletion: this.registrationAuthority,
|
|
2188
|
+
authorizationService: this.authorizationService,
|
|
2189
|
+
authorizationTenantId: this.authorizationTenantId,
|
|
2190
|
+
foundingAuthority: finalized.foundingAuthority,
|
|
2191
|
+
registrationCeremonyId: args.input.registrationCeremonyId,
|
|
2192
|
+
authority: finalized.authority,
|
|
2193
|
+
walletAuthMethodId: effectivePrepared.walletAuthMethodId,
|
|
2194
|
+
expiresAtMs: Date.now() + DEFAULT_WALLET_SESSION_TTL_MS,
|
|
2195
|
+
remainingUses: 3,
|
|
2196
|
+
publicResult: finalized.ed25519,
|
|
2197
|
+
predecessor: sessionPredecessor,
|
|
2198
|
+
initialSession: execution.initialSession,
|
|
2199
|
+
keyManifestDigestB64u: finalized.custodyKeyManifestDigestB64u,
|
|
2200
|
+
proof,
|
|
2201
|
+
onSessionCommitted: finalized.authMethod.kind === "passkey" ? args.input.onSessionCommitted : void 0
|
|
2202
|
+
})
|
|
2203
|
+
}), execution.custody]);
|
|
2204
|
+
if (issuance.status === "rejected") throw issuance.reason;
|
|
2205
|
+
if (custody.status === "rejected") throw custody.reason;
|
|
2206
|
+
const issuedRegistrationSession = issuance.value;
|
|
2207
|
+
const custodyField = custody.value.status === "not_requested" ? {} : { walletCustody: custody.value };
|
|
2378
2208
|
switch (issuedRegistrationSession.kind) {
|
|
2379
2209
|
case "issued": return {
|
|
2380
2210
|
kind: "session_issued",
|
|
2381
2211
|
response: {
|
|
2382
2212
|
...finalized,
|
|
2213
|
+
...custodyField,
|
|
2383
2214
|
registrationEstablishedSession: {
|
|
2384
2215
|
kind: "issued",
|
|
2385
2216
|
session: issuedRegistrationSession.session
|
|
2386
2217
|
}
|
|
2387
2218
|
},
|
|
2388
2219
|
issuedAtMs: issuedRegistrationSession.issuedAtMs,
|
|
2389
|
-
expectedOrigin: ownerProofContext.expectedOrigin
|
|
2220
|
+
expectedOrigin: ownerProofContext.expectedOrigin,
|
|
2221
|
+
activation: issuedRegistrationSession.activation
|
|
2390
2222
|
};
|
|
2391
2223
|
case "already_committed": return {
|
|
2392
2224
|
kind: "session_issued",
|
|
2393
2225
|
response: {
|
|
2394
2226
|
...finalized,
|
|
2227
|
+
...custodyField,
|
|
2395
2228
|
registrationEstablishedSession: {
|
|
2396
2229
|
kind: "already_committed",
|
|
2397
2230
|
session: issuedRegistrationSession.session,
|
|
@@ -2399,7 +2232,8 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
2399
2232
|
}
|
|
2400
2233
|
},
|
|
2401
2234
|
issuedAtMs: issuedRegistrationSession.issuedAtMs,
|
|
2402
|
-
expectedOrigin: ownerProofContext.expectedOrigin
|
|
2235
|
+
expectedOrigin: ownerProofContext.expectedOrigin,
|
|
2236
|
+
activation: issuedRegistrationSession.activation
|
|
2403
2237
|
};
|
|
2404
2238
|
default: return assertNeverD1RegistrationSessionIssuance(issuedRegistrationSession);
|
|
2405
2239
|
}
|
|
@@ -2408,29 +2242,6 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
2408
2242
|
if (receipt.operation !== "registration_activate") throw new Error("Registration activation receipt operation is invalid");
|
|
2409
2243
|
switch (receipt.committed.kind) {
|
|
2410
2244
|
case "error": return replayedRegistrationCommit(receipt.committed.error);
|
|
2411
|
-
case "near_pending": {
|
|
2412
|
-
if (!isRegistrationNearPendingReceipt(receipt)) throw new Error("Registration pending receipt branch is invalid");
|
|
2413
|
-
const authMethod = registrationReplayAuthMethodFields(receipt);
|
|
2414
|
-
if (authMethod.kind === "passkey") return replayedRegistrationCommit({
|
|
2415
|
-
ok: true,
|
|
2416
|
-
kind: "near_ed25519",
|
|
2417
|
-
walletId: receipt.walletId,
|
|
2418
|
-
authority: receipt.authority,
|
|
2419
|
-
authMethod: authMethod.authMethod,
|
|
2420
|
-
rpId: authMethod.rpId,
|
|
2421
|
-
...receipt.registrationDiagnostics ? { registrationDiagnostics: receipt.registrationDiagnostics } : {},
|
|
2422
|
-
nearProvisioning: { status: "near_pending" }
|
|
2423
|
-
});
|
|
2424
|
-
return replayedRegistrationCommit({
|
|
2425
|
-
ok: true,
|
|
2426
|
-
kind: "near_ed25519",
|
|
2427
|
-
walletId: receipt.walletId,
|
|
2428
|
-
authority: receipt.authority,
|
|
2429
|
-
authMethod: authMethod.authMethod,
|
|
2430
|
-
...receipt.registrationDiagnostics ? { registrationDiagnostics: receipt.registrationDiagnostics } : {},
|
|
2431
|
-
nearProvisioning: { status: "near_pending" }
|
|
2432
|
-
});
|
|
2433
|
-
}
|
|
2434
2245
|
case "ecdsa_ready": {
|
|
2435
2246
|
if (!isRegistrationEcdsaReadyReceipt(receipt)) throw new Error("Registration activation receipt branch is invalid");
|
|
2436
2247
|
const registrationEstablishedSession = replayDirectRegistrationEstablishedEcdsaSession(receipt);
|
|
@@ -2499,15 +2310,7 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
2499
2310
|
authMethod: authMethod.authMethod
|
|
2500
2311
|
});
|
|
2501
2312
|
}
|
|
2502
|
-
/**
|
|
2503
|
-
* Deferred NEAR provisioning. Verifies the signed setup, then reuses the
|
|
2504
|
-
* existing deferred Ed25519 commit — the same path lazy-Yao 4+5 built — so
|
|
2505
|
-
* signer installation and the implicit-account projection keep one
|
|
2506
|
-
* implementation across both plans.
|
|
2507
|
-
*
|
|
2508
|
-
* A retryable failure leaves the pending wallet intact: the wallet must not
|
|
2509
|
-
* be destroyed because its signer ceremony needs another attempt.
|
|
2510
|
-
*/
|
|
2313
|
+
/** Verifies registration or continuation authority without destroying retryable state. */
|
|
2511
2314
|
async verifyNearProvisioningAuthority(input) {
|
|
2512
2315
|
if (input.authorization.kind === "registration_grant") {
|
|
2513
2316
|
const verified = await verifyWalletRegistrationSetupClaims(input.verifier, input.signedSetup, {
|
|
@@ -2553,7 +2356,7 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
2553
2356
|
}
|
|
2554
2357
|
};
|
|
2555
2358
|
}
|
|
2556
|
-
async completeWalletRegistrationNearProvisioning(input, timingSink) {
|
|
2359
|
+
async completeWalletRegistrationNearProvisioning(input, timingSink, waitUntil) {
|
|
2557
2360
|
const serverTiming = timingSink ?? [];
|
|
2558
2361
|
const totalStartedAtMs = Date.now();
|
|
2559
2362
|
try {
|
|
@@ -2565,6 +2368,14 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
2565
2368
|
code: verified.code,
|
|
2566
2369
|
message: verified.message
|
|
2567
2370
|
};
|
|
2371
|
+
const admissionStartedAtMs = Date.now();
|
|
2372
|
+
const operationKey = `near-provisioning:${input.registrationCeremonyId}:${input.idempotencyKey}`;
|
|
2373
|
+
const initial = await this.registrationRead.readFinalization({
|
|
2374
|
+
ceremonyId: verified.claims.registrationCeremonyId,
|
|
2375
|
+
walletId: walletIdFromString(verified.claims.walletId)
|
|
2376
|
+
}, operationKey);
|
|
2377
|
+
recordRegistrationServerTiming(serverTiming, "near_finalize_initial_read", admissionStartedAtMs);
|
|
2378
|
+
if (!initial.ok) return initial;
|
|
2568
2379
|
const fingerprintStartedAtMs = Date.now();
|
|
2569
2380
|
const requestFingerprint = base64UrlEncode(await sha256BytesUtf8(alphabetizeStringify({
|
|
2570
2381
|
version: "wallet_registration_near_provisioning_digest_v1",
|
|
@@ -2576,19 +2387,34 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
2576
2387
|
})));
|
|
2577
2388
|
recordRegistrationServerTiming(serverTiming, "near_finalize_fingerprint", fingerprintStartedAtMs);
|
|
2578
2389
|
const sideEffectStartedAtMs = Date.now();
|
|
2579
|
-
|
|
2390
|
+
let preparedCeremony = null;
|
|
2391
|
+
const run = await runRouterAbEd25519YaoRegistrationSideEffectV2(this.registrationRead.operations, {
|
|
2580
2392
|
kind: "prepared_resumable",
|
|
2581
2393
|
operation: "near_provisioning",
|
|
2582
|
-
key:
|
|
2394
|
+
key: operationKey,
|
|
2395
|
+
initialRecord: initial.operation,
|
|
2583
2396
|
requestFingerprint,
|
|
2584
2397
|
resumeAfterMs: D1_WALLET_REGISTRATION_OPERATION_RESUME_AFTER_MS,
|
|
2585
2398
|
nowMs: Date.now,
|
|
2586
|
-
prepare: async () =>
|
|
2399
|
+
prepare: async () => {
|
|
2400
|
+
const preparation = await this.prepareNearProvisioningOperation(input.registrationCeremonyId, null, verified.source.kind === "committed_mixed" ? {
|
|
2401
|
+
kind: "installation",
|
|
2402
|
+
installation: verified.source.installation
|
|
2403
|
+
} : {
|
|
2404
|
+
kind: "ceremony",
|
|
2405
|
+
ceremony: await initial.readCeremony()
|
|
2406
|
+
});
|
|
2407
|
+
preparedCeremony = preparation.ceremony;
|
|
2408
|
+
return preparation.prepared;
|
|
2409
|
+
},
|
|
2587
2410
|
derivePreparedArtifactFingerprint: async (prepared) => base64UrlEncode(await sha256BytesUtf8(alphabetizeStringify(prepared))),
|
|
2588
2411
|
execute: this.commitDeferredEd25519Signer.bind(this, {
|
|
2589
2412
|
input,
|
|
2413
|
+
serverTiming,
|
|
2590
2414
|
setupClaims: verified.claims,
|
|
2591
|
-
authoritySource: verified.source
|
|
2415
|
+
authoritySource: verified.source,
|
|
2416
|
+
preparedCeremony: () => preparedCeremony,
|
|
2417
|
+
lifecycleDecision: initial.decision
|
|
2592
2418
|
}),
|
|
2593
2419
|
projectReceipt: (execution) => projectWalletRegistrationSessionCommitReceiptV2({
|
|
2594
2420
|
operation: "near_provisioning",
|
|
@@ -2596,6 +2422,7 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
2596
2422
|
registrationCeremonyId: input.registrationCeremonyId,
|
|
2597
2423
|
execution
|
|
2598
2424
|
}),
|
|
2425
|
+
completionWrite: registrationCommitActivation,
|
|
2599
2426
|
replay: this.replayWalletRegistrationNearProvisioningCommit.bind(this)
|
|
2600
2427
|
});
|
|
2601
2428
|
recordRegistrationServerTiming(serverTiming, "near_finalize_side_effect", sideEffectStartedAtMs);
|
|
@@ -2651,6 +2478,7 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
2651
2478
|
registrationCeremonyId: input.registrationCeremonyId
|
|
2652
2479
|
})
|
|
2653
2480
|
});
|
|
2481
|
+
if (waitUntil) waitUntil(cleanup);
|
|
2654
2482
|
if (input.authorization.kind === "wallet_session") {
|
|
2655
2483
|
const projectionStartedAtMs = Date.now();
|
|
2656
2484
|
const [current] = await Promise.all([recordRegistrationPromiseTiming({
|
|
@@ -2662,7 +2490,7 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
2662
2490
|
token: input.authorization.credential,
|
|
2663
2491
|
nowMs: Date.now()
|
|
2664
2492
|
})
|
|
2665
|
-
}), cleanup]);
|
|
2493
|
+
}), waitUntil ? void 0 : cleanup]);
|
|
2666
2494
|
const tokens = committed.registrationEstablishedSession.session.tokens;
|
|
2667
2495
|
if (!current || tokens.kind !== "near_ed25519_and_evm_family_ecdsa") throw new Error("NEAR continuation Wallet Session is no longer active");
|
|
2668
2496
|
recordRegistrationServerTiming(serverTiming, "near_finalize_total", totalStartedAtMs);
|
|
@@ -2676,7 +2504,7 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
2676
2504
|
nearProvisioning: { status: "near_ready" }
|
|
2677
2505
|
};
|
|
2678
2506
|
}
|
|
2679
|
-
await cleanup;
|
|
2507
|
+
if (!waitUntil) await cleanup;
|
|
2680
2508
|
recordRegistrationServerTiming(serverTiming, "near_finalize_total", totalStartedAtMs);
|
|
2681
2509
|
return {
|
|
2682
2510
|
...committed,
|
|
@@ -2693,100 +2521,6 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
2693
2521
|
}
|
|
2694
2522
|
}
|
|
2695
2523
|
/**
|
|
2696
|
-
* Persists the Ed25519-only wallet in `near_pending`: wallet, profile, and
|
|
2697
|
-
* authentication state, and no signer record — the signer does not exist
|
|
2698
|
-
* until deferred Yao produces it.
|
|
2699
|
-
*
|
|
2700
|
-
* The terminal response carries no signer, resolved account, or key
|
|
2701
|
-
* identity, because none of those are known yet. Reporting them would be
|
|
2702
|
-
* fabricating readiness.
|
|
2703
|
-
*/
|
|
2704
|
-
async commitEd25519PendingWallet(input) {
|
|
2705
|
-
const now = Date.now();
|
|
2706
|
-
const ceremony = input.ceremony;
|
|
2707
|
-
const authority = input.authority;
|
|
2708
|
-
const wallet = buildD1WalletRecord({
|
|
2709
|
-
walletId: ceremony.intent.walletId,
|
|
2710
|
-
now
|
|
2711
|
-
});
|
|
2712
|
-
const walletAuthAuthority = registrationWalletAuthAuthority({
|
|
2713
|
-
authority,
|
|
2714
|
-
walletAuthMethodId: input.walletAuthMethodId
|
|
2715
|
-
});
|
|
2716
|
-
switch (authority.kind) {
|
|
2717
|
-
case "passkey":
|
|
2718
|
-
await this.walletRegistrationCommitStore.commit({
|
|
2719
|
-
kind: "passkey_wallet_registration_commit_v1",
|
|
2720
|
-
wallet,
|
|
2721
|
-
walletSigners: [],
|
|
2722
|
-
authority,
|
|
2723
|
-
now,
|
|
2724
|
-
decisionStatements: []
|
|
2725
|
-
});
|
|
2726
|
-
break;
|
|
2727
|
-
case "email_otp": {
|
|
2728
|
-
const enrollment = await this.emailOtpRegistrationEnrollmentFinalizer.prepareRegistrationFinalize({
|
|
2729
|
-
authority,
|
|
2730
|
-
request: input.enrollment,
|
|
2731
|
-
walletId: ceremony.intent.walletId,
|
|
2732
|
-
orgId: ceremony.orgId,
|
|
2733
|
-
nowMs: now
|
|
2734
|
-
});
|
|
2735
|
-
if (!enrollment.ok) return enrollment;
|
|
2736
|
-
if (!enrollment.persistence) return {
|
|
2737
|
-
ok: false,
|
|
2738
|
-
code: "invalid_state",
|
|
2739
|
-
message: "Email OTP registration is missing enrollment persistence state"
|
|
2740
|
-
};
|
|
2741
|
-
await this.walletRegistrationCommitStore.commit({
|
|
2742
|
-
kind: "email_otp_wallet_registration_commit_v1",
|
|
2743
|
-
wallet,
|
|
2744
|
-
walletSigners: [],
|
|
2745
|
-
authority,
|
|
2746
|
-
emailOtp: this.emailOtpRegistrationEnrollmentFinalizer.prepareRegistrationCommitPlan(enrollment.persistence),
|
|
2747
|
-
now,
|
|
2748
|
-
decisionStatements: []
|
|
2749
|
-
});
|
|
2750
|
-
const completedIdentity = await this.emailOtpRegistrationEnrollmentFinalizer.completeRegistrationIdentity({
|
|
2751
|
-
authority,
|
|
2752
|
-
walletId: ceremony.intent.walletId
|
|
2753
|
-
});
|
|
2754
|
-
if (!completedIdentity.ok) return completedIdentity;
|
|
2755
|
-
break;
|
|
2756
|
-
}
|
|
2757
|
-
}
|
|
2758
|
-
const authMethod = walletRegistrationFinalizeAuthMethodFromAuthority(authority);
|
|
2759
|
-
if (authMethod.kind === "passkey") {
|
|
2760
|
-
if (!isPasskeyWalletAuthAuthority(walletAuthAuthority)) return {
|
|
2761
|
-
ok: false,
|
|
2762
|
-
code: "internal",
|
|
2763
|
-
message: "Passkey registration returned a different authority"
|
|
2764
|
-
};
|
|
2765
|
-
return buildWalletRegistrationActivatePendingPasskeyResponse({
|
|
2766
|
-
walletId: ceremony.intent.walletId,
|
|
2767
|
-
authority: walletAuthAuthority,
|
|
2768
|
-
authMethod,
|
|
2769
|
-
rpId: finalizePasskeyRpId(authority)
|
|
2770
|
-
});
|
|
2771
|
-
}
|
|
2772
|
-
if (!isEmailOtpWalletAuthAuthority(walletAuthAuthority)) return {
|
|
2773
|
-
ok: false,
|
|
2774
|
-
code: "internal",
|
|
2775
|
-
message: "Email OTP registration returned a different authority"
|
|
2776
|
-
};
|
|
2777
|
-
return buildWalletRegistrationActivatePendingEmailOtpResponse({
|
|
2778
|
-
walletId: ceremony.intent.walletId,
|
|
2779
|
-
authority: walletAuthAuthority,
|
|
2780
|
-
authMethod
|
|
2781
|
-
});
|
|
2782
|
-
}
|
|
2783
|
-
/**
|
|
2784
|
-
* Ed25519-only respond. The wallet's sole signer is Yao, and that is
|
|
2785
|
-
* deliberately not a reason to block: the admission is returned as deferred
|
|
2786
|
-
* work exactly as on a mixed plan, and the wallet lives in `near_pending`
|
|
2787
|
-
* until the computation completes.
|
|
2788
|
-
*/
|
|
2789
|
-
/**
|
|
2790
2524
|
* Respond replay stays authority-bound.
|
|
2791
2525
|
*
|
|
2792
2526
|
* `signedSetup` is client-carried, so possession of it must never recover a
|
|
@@ -2828,6 +2562,7 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
2828
2562
|
async respondEd25519OnlyRegistration(input) {
|
|
2829
2563
|
const ceremony = input.ceremony;
|
|
2830
2564
|
const stored = storedRespondEd25519DeferredWork(ceremony.signerState);
|
|
2565
|
+
let authority;
|
|
2831
2566
|
if (stored) {
|
|
2832
2567
|
const replayAuthority = await this.verifyRespondReplayAuthority({
|
|
2833
2568
|
ceremony,
|
|
@@ -2835,74 +2570,95 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
2835
2570
|
expectedOrigin: input.expectedOrigin,
|
|
2836
2571
|
...input.userAgent ? { userAgent: input.userAgent } : {}
|
|
2837
2572
|
});
|
|
2838
|
-
if (!replayAuthority.ok) return
|
|
2573
|
+
if (!replayAuthority.ok) return replayAuthority;
|
|
2574
|
+
const retainedAuthority = verifiedRegistrationCeremonyAuthority(ceremony);
|
|
2575
|
+
if (!retainedAuthority) return {
|
|
2839
2576
|
ok: false,
|
|
2840
|
-
code:
|
|
2841
|
-
message:
|
|
2577
|
+
code: "invalid_state",
|
|
2578
|
+
message: "Registration authority is unavailable"
|
|
2842
2579
|
};
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2580
|
+
authority = retainedAuthority;
|
|
2581
|
+
} else {
|
|
2582
|
+
const verified = await this.walletAuthMethods.verifyRegistrationAuthorityForIntent({
|
|
2583
|
+
orgId: ceremony.orgId,
|
|
2584
|
+
authority: input.authorityInput,
|
|
2585
|
+
expectedDigestB64u: ceremony.digestB64u,
|
|
2586
|
+
expectedOrigin: input.expectedOrigin,
|
|
2587
|
+
intent: ceremony.intent,
|
|
2588
|
+
verificationOperationId: ceremony.registrationCeremonyId,
|
|
2589
|
+
verificationReceiptExpiresAtMs: ceremony.expiresAtMs,
|
|
2590
|
+
...input.userAgent ? { userAgent: input.userAgent } : {}
|
|
2591
|
+
});
|
|
2592
|
+
if (!verified.ok) return {
|
|
2593
|
+
ok: false,
|
|
2594
|
+
code: verified.code,
|
|
2595
|
+
message: verified.message
|
|
2848
2596
|
};
|
|
2597
|
+
authority = verified.authority;
|
|
2849
2598
|
}
|
|
2850
|
-
const verifiedAuthority = await this.walletAuthMethods.verifyRegistrationAuthorityForIntent({
|
|
2851
|
-
orgId: ceremony.orgId,
|
|
2852
|
-
authority: input.authorityInput,
|
|
2853
|
-
expectedDigestB64u: ceremony.digestB64u,
|
|
2854
|
-
expectedOrigin: input.expectedOrigin,
|
|
2855
|
-
intent: ceremony.intent,
|
|
2856
|
-
verificationOperationId: ceremony.registrationCeremonyId,
|
|
2857
|
-
verificationReceiptExpiresAtMs: ceremony.expiresAtMs,
|
|
2858
|
-
...input.userAgent ? { userAgent: input.userAgent } : {}
|
|
2859
|
-
});
|
|
2860
|
-
if (!verifiedAuthority.ok) return {
|
|
2861
|
-
ok: false,
|
|
2862
|
-
code: verifiedAuthority.code,
|
|
2863
|
-
message: verifiedAuthority.message
|
|
2864
|
-
};
|
|
2865
|
-
const authority = verifiedAuthority.authority;
|
|
2866
2599
|
if (authority.walletId !== ceremony.intent.walletId) return {
|
|
2867
2600
|
ok: false,
|
|
2868
2601
|
code: "scope_mismatch",
|
|
2869
2602
|
message: "registration authority walletId does not match the ceremony"
|
|
2870
2603
|
};
|
|
2871
|
-
const
|
|
2604
|
+
const runtime = this.getEd25519YaoProductRegistration();
|
|
2605
|
+
if (!runtime) return {
|
|
2606
|
+
ok: false,
|
|
2607
|
+
code: "not_configured",
|
|
2608
|
+
message: "Ed25519 Yao registration is unavailable"
|
|
2609
|
+
};
|
|
2610
|
+
const admissionRequest = stored ? stored.admissionRequest : await buildRespondEd25519AdmissionRequest({
|
|
2872
2611
|
ceremony,
|
|
2873
2612
|
branch: input.branch,
|
|
2874
2613
|
authority,
|
|
2875
|
-
|
|
2614
|
+
signingWorkerId: runtime.signingWorkerId
|
|
2876
2615
|
});
|
|
2616
|
+
const verifiedAuthority = authority;
|
|
2617
|
+
const branchKey = input.branch.branchKey;
|
|
2618
|
+
const ceremonyStore = this.getRegistrationCeremonyIntentStore();
|
|
2619
|
+
const authorizedCeremony = (bound) => ({
|
|
2620
|
+
...ceremony,
|
|
2621
|
+
authorityState: {
|
|
2622
|
+
kind: "verified",
|
|
2623
|
+
authority: verifiedAuthority
|
|
2624
|
+
},
|
|
2625
|
+
signerState: {
|
|
2626
|
+
kind: "signer_set_registration",
|
|
2627
|
+
branches: [buildStoredWalletRegistrationNearEd25519YaoAuthorizedBranch({
|
|
2628
|
+
branchKey,
|
|
2629
|
+
admissionRequest: bound
|
|
2630
|
+
})]
|
|
2631
|
+
}
|
|
2632
|
+
});
|
|
2633
|
+
const admitted = await runtime.bindAndAdmitVerifiedRegistration({
|
|
2634
|
+
kind: "verified_registration_intent",
|
|
2635
|
+
ownershipGeneration: input.ownershipGeneration,
|
|
2636
|
+
registrationIntentGrant: registrationIntentGrantFromString(input.registrationBearerToken),
|
|
2637
|
+
intent: ceremony.intent,
|
|
2638
|
+
admissionRequest,
|
|
2639
|
+
expiresAtMs: ceremony.expiresAtMs
|
|
2640
|
+
}, stored ? null : (bound) => ceremonyStore.prepareEcdsaClaimCommit({
|
|
2641
|
+
expected: input.snapshot,
|
|
2642
|
+
next: authorizedCeremony(bound)
|
|
2643
|
+
}), input.startedDispatchRoot);
|
|
2877
2644
|
if (!admitted.ok) return {
|
|
2878
2645
|
ok: false,
|
|
2879
2646
|
code: admitted.code,
|
|
2880
2647
|
message: admitted.message
|
|
2881
2648
|
};
|
|
2882
|
-
if (!admitted.
|
|
2883
|
-
ok: false,
|
|
2884
|
-
code: "internal",
|
|
2885
|
-
message: "Ed25519 admission produced no branch"
|
|
2886
|
-
};
|
|
2887
|
-
await this.getRegistrationCeremonyIntentStore().commitEcdsaClaim({
|
|
2649
|
+
if (!stored && admitted.companionWrite === "not_committed") await ceremonyStore.commitEcdsaClaim({
|
|
2888
2650
|
expected: input.snapshot,
|
|
2889
|
-
next:
|
|
2890
|
-
...ceremony,
|
|
2891
|
-
authorityState: {
|
|
2892
|
-
kind: "verified",
|
|
2893
|
-
authority
|
|
2894
|
-
},
|
|
2895
|
-
signerState: {
|
|
2896
|
-
kind: "signer_set_registration",
|
|
2897
|
-
branches: [admitted.branch]
|
|
2898
|
-
}
|
|
2899
|
-
}
|
|
2651
|
+
next: authorizedCeremony(admitted.admissionRequest)
|
|
2900
2652
|
});
|
|
2901
2653
|
return {
|
|
2902
2654
|
ok: true,
|
|
2903
2655
|
registrationCeremonyId: ceremony.registrationCeremonyId,
|
|
2904
2656
|
kind: "near_ed25519",
|
|
2905
|
-
ed25519:
|
|
2657
|
+
ed25519: {
|
|
2658
|
+
status: "admitted",
|
|
2659
|
+
admissionRequest: admitted.admissionRequest,
|
|
2660
|
+
admissionReceipt: admitted.value
|
|
2661
|
+
}
|
|
2906
2662
|
};
|
|
2907
2663
|
}
|
|
2908
2664
|
/**
|
|
@@ -2923,21 +2679,15 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
2923
2679
|
code: "not_configured",
|
|
2924
2680
|
message: "Ed25519 Yao product registration is not configured"
|
|
2925
2681
|
};
|
|
2926
|
-
const admissionRequest = await
|
|
2927
|
-
|
|
2928
|
-
walletId: input.ceremony.intent.walletId,
|
|
2929
|
-
signingRootId: normalizeOptionalTrimmedString(input.ceremony.signingRootId) || "",
|
|
2930
|
-
signingRootVersion: normalizeOptionalTrimmedString(input.ceremony.signingRootVersion) || "",
|
|
2931
|
-
authorityScope: registrationEd25519AuthorityScopeFromAuthority(input.authority),
|
|
2682
|
+
const admissionRequest = await buildRespondEd25519AdmissionRequest({
|
|
2683
|
+
ceremony: input.ceremony,
|
|
2932
2684
|
branch: input.branch,
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
walletId: input.ceremony.intent.walletId,
|
|
2936
|
-
signingWorkerId: yaoRuntime.signingWorkerId
|
|
2937
|
-
})
|
|
2685
|
+
authority: input.authority,
|
|
2686
|
+
signingWorkerId: yaoRuntime.signingWorkerId
|
|
2938
2687
|
});
|
|
2939
2688
|
const admitted = await yaoRuntime.bindVerifiedIntent({
|
|
2940
2689
|
kind: "verified_registration_intent",
|
|
2690
|
+
ownershipGeneration: input.ownershipGeneration,
|
|
2941
2691
|
registrationIntentGrant: registrationIntentGrantFromString(input.registrationBearerToken),
|
|
2942
2692
|
intent: input.ceremony.intent,
|
|
2943
2693
|
admissionRequest,
|
|
@@ -2990,6 +2740,11 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
2990
2740
|
code: verifiedSetup.code,
|
|
2991
2741
|
message: verifiedSetup.message
|
|
2992
2742
|
};
|
|
2743
|
+
const homeAdmission = await admitRegistrationReservationHome(this.registrationAuthority, {
|
|
2744
|
+
ceremonyId: verifiedSetup.claims.registrationCeremonyId,
|
|
2745
|
+
walletId: walletIdFromString(verifiedSetup.claims.walletId)
|
|
2746
|
+
});
|
|
2747
|
+
if (!homeAdmission.ok) return homeAdmission;
|
|
2993
2748
|
const claims = verifiedSetup.claims;
|
|
2994
2749
|
const idempotencyKey = normalizeOptionalTrimmedString(input.idempotencyKey);
|
|
2995
2750
|
if (!idempotencyKey) return {
|
|
@@ -3009,10 +2764,14 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
3009
2764
|
kind: "prepared_resumable",
|
|
3010
2765
|
operation: "registration_activate",
|
|
3011
2766
|
key: `registration-activate:${claims.registrationCeremonyId}:${idempotencyKey}`,
|
|
2767
|
+
initialRecord: await this.activateSideEffects.read(`registration-activate:${claims.registrationCeremonyId}:${idempotencyKey}`),
|
|
3012
2768
|
requestFingerprint: activateDigestB64u,
|
|
3013
2769
|
resumeAfterMs: D1_WALLET_REGISTRATION_OPERATION_RESUME_AFTER_MS,
|
|
3014
2770
|
nowMs: Date.now,
|
|
3015
|
-
prepare: async () => await this.prepareNearProvisioningOperation(claims.registrationCeremonyId
|
|
2771
|
+
prepare: async () => (await this.prepareNearProvisioningOperation(claims.registrationCeremonyId, null, {
|
|
2772
|
+
kind: "ceremony",
|
|
2773
|
+
ceremony: await this.getRegistrationCeremonyIntentStore().getCeremony(claims.registrationCeremonyId)
|
|
2774
|
+
})).prepared,
|
|
3016
2775
|
derivePreparedArtifactFingerprint: async (prepared) => base64UrlEncode(await sha256BytesUtf8(alphabetizeStringify(prepared))),
|
|
3017
2776
|
execute: this.executeWalletRegistrationActivation.bind(this, {
|
|
3018
2777
|
registrationCeremonyId: claims.registrationCeremonyId,
|
|
@@ -3027,6 +2786,7 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
3027
2786
|
registrationCeremonyId: claims.registrationCeremonyId,
|
|
3028
2787
|
execution
|
|
3029
2788
|
}),
|
|
2789
|
+
completionWrite: registrationCommitActivation,
|
|
3030
2790
|
replay: this.replayWalletRegistrationActivateCommit.bind(this)
|
|
3031
2791
|
});
|
|
3032
2792
|
switch (run.kind) {
|
|
@@ -3078,36 +2838,15 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
3078
2838
|
code: "not_found",
|
|
3079
2839
|
message: "registration ceremony not found"
|
|
3080
2840
|
});
|
|
3081
|
-
|
|
3082
|
-
if (!ceremonyAuthority) return unissuedRegistrationCommit({
|
|
2841
|
+
if (!verifiedRegistrationCeremonyAuthority(ceremony)) return unissuedRegistrationCommit({
|
|
3083
2842
|
ok: false,
|
|
3084
2843
|
code: "invalid_state",
|
|
3085
2844
|
message: "registration ceremony has not verified its authority proof"
|
|
3086
2845
|
});
|
|
3087
|
-
if (!registrationSignerBranchesFromPlan(ceremony.signerPlan).evmFamilyEcdsa) {
|
|
3088
|
-
const expectedOrigin = normalizeOptionalTrimmedString(ceremony.expectedOrigin);
|
|
3089
|
-
if (!expectedOrigin) return unissuedRegistrationCommit({
|
|
3090
|
-
ok: false,
|
|
3091
|
-
code: "invalid_state",
|
|
3092
|
-
message: "registration ceremony has no expected origin"
|
|
3093
|
-
});
|
|
3094
|
-
const pending = await this.commitEd25519PendingWallet({
|
|
3095
|
-
ceremony,
|
|
3096
|
-
authority: ceremonyAuthority,
|
|
3097
|
-
walletAuthMethodId: prepared.walletAuthMethodId,
|
|
3098
|
-
enrollment: { ...context.input.emailOtpEnrollment ? { emailOtpEnrollment: context.input.emailOtpEnrollment } : {} }
|
|
3099
|
-
});
|
|
3100
|
-
if (!pending.ok) return unissuedRegistrationCommit(pending);
|
|
3101
|
-
return {
|
|
3102
|
-
kind: "near_pending",
|
|
3103
|
-
response: pending,
|
|
3104
|
-
expectedOrigin
|
|
3105
|
-
};
|
|
3106
|
-
}
|
|
3107
|
-
if (!context.input.ecdsa) return unissuedRegistrationCommit({
|
|
2846
|
+
if (!registrationSignerBranchesFromPlan(ceremony.signerPlan).evmFamilyEcdsa) return unissuedRegistrationCommit({
|
|
3108
2847
|
ok: false,
|
|
3109
|
-
code: "
|
|
3110
|
-
message: "
|
|
2848
|
+
code: "scope_mismatch",
|
|
2849
|
+
message: "NEAR-only registration commits through NEAR finalization"
|
|
3111
2850
|
});
|
|
3112
2851
|
const ecdsa = context.input.ecdsa;
|
|
3113
2852
|
const activated = await this.activateWalletRegistrationEcdsa({
|
|
@@ -3127,22 +2866,30 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
3127
2866
|
code: "internal",
|
|
3128
2867
|
message: "ECDSA activation completed without a key handle to commit"
|
|
3129
2868
|
});
|
|
3130
|
-
const
|
|
3131
|
-
if (!
|
|
3132
|
-
const
|
|
2869
|
+
const activatedCeremony = await this.getRegistrationCeremonyIntentStore().getCeremony(context.registrationCeremonyId);
|
|
2870
|
+
if (!activatedCeremony) throw new Error("Registration owner proof context is unavailable");
|
|
2871
|
+
const ownerProofContext = registrationOwnerProofContextFromCeremony(activatedCeremony);
|
|
2872
|
+
const execution = await this.executeWalletRegistrationFinalize({
|
|
3133
2873
|
kind: "evm_family_ecdsa",
|
|
3134
2874
|
registrationCeremonyId: context.registrationCeremonyId,
|
|
3135
2875
|
idempotencyKey: context.idempotencyKey,
|
|
3136
2876
|
ecdsa: { expectedKeyHandles: [keyHandle] },
|
|
3137
2877
|
...context.input.emailOtpEnrollment ? { emailOtpEnrollment: context.input.emailOtpEnrollment } : {},
|
|
3138
2878
|
...context.input.walletCustodyCommit !== void 0 ? { walletCustodyCommit: context.input.walletCustodyCommit } : {}
|
|
3139
|
-
}, prepared,
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
2879
|
+
}, prepared, {
|
|
2880
|
+
kind: "stored_ceremony",
|
|
2881
|
+
ceremony: activatedCeremony
|
|
2882
|
+
}, [], { kind: "separate" }, null);
|
|
2883
|
+
if (!execution.ok) return unissuedRegistrationCommit(throwIfRouterAbEd25519YaoRetryableSideEffectFailureV1(execution));
|
|
2884
|
+
const commit = execution.finalized;
|
|
2885
|
+
if (commit.kind !== "evm_family_ecdsa") {
|
|
2886
|
+
await execution.custody;
|
|
2887
|
+
return unissuedRegistrationCommit({
|
|
2888
|
+
ok: false,
|
|
2889
|
+
code: "internal",
|
|
2890
|
+
message: "registration activation committed a non-ECDSA branch"
|
|
2891
|
+
});
|
|
2892
|
+
}
|
|
3146
2893
|
let installationProjection = null;
|
|
3147
2894
|
if (registrationSignerBranchesFromPlan(ceremony.signerPlan).nearEd25519) {
|
|
3148
2895
|
const committedCeremony = await this.getRegistrationCeremonyIntentStore().getCeremony(context.registrationCeremonyId);
|
|
@@ -3151,25 +2898,30 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
3151
2898
|
}
|
|
3152
2899
|
const runtimePolicyScope = registrationPreparedContextRuntimePolicyScope(ceremony.preparedContext);
|
|
3153
2900
|
if (!runtimePolicyScope) throw new Error("ECDSA registration is missing runtime policy scope");
|
|
3154
|
-
|
|
2901
|
+
if (!this.registrationAuthority) throw new Error("Registration home completion is unavailable");
|
|
2902
|
+
const proof = await this.registrationOwnerProofWithContext(ownerProofContext, {
|
|
2903
|
+
registrationCeremonyId: context.registrationCeremonyId,
|
|
2904
|
+
authMethod: commit.authMethod,
|
|
2905
|
+
authority: commit.authority
|
|
2906
|
+
});
|
|
2907
|
+
const [issuance, custody] = await Promise.allSettled([issueDirectRegistrationEstablishedEcdsaSession({
|
|
2908
|
+
homeCompletion: this.registrationAuthority,
|
|
3155
2909
|
authorizationService: this.authorizationService,
|
|
3156
2910
|
authorizationTenantId: this.authorizationTenantId,
|
|
3157
|
-
|
|
2911
|
+
foundingAuthority: commit.foundingAuthority,
|
|
3158
2912
|
registrationCeremonyId: context.registrationCeremonyId,
|
|
3159
2913
|
authority: commit.authority,
|
|
3160
|
-
registrationAuthority: ceremonyAuthority,
|
|
3161
2914
|
walletAuthMethodId: prepared.walletAuthMethodId,
|
|
3162
2915
|
expiresAtMs: activated.ecdsa.bootstrap.expiresAtMs,
|
|
3163
2916
|
remainingUses: activated.ecdsa.bootstrap.remainingUses,
|
|
3164
2917
|
bootstrap: activated.ecdsa.bootstrap,
|
|
3165
2918
|
runtimePolicyScope,
|
|
3166
2919
|
keyManifestDigestB64u: commit.custodyKeyManifestDigestB64u,
|
|
3167
|
-
proof
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
});
|
|
2920
|
+
proof
|
|
2921
|
+
}), execution.custody]);
|
|
2922
|
+
if (issuance.status === "rejected") throw issuance.reason;
|
|
2923
|
+
if (custody.status === "rejected") throw custody.reason;
|
|
2924
|
+
const registrationEstablishedSession = issuance.value;
|
|
3173
2925
|
const registrationEstablishedSessionResult = registrationEstablishedSessionResultFromIssuance(registrationEstablishedSession);
|
|
3174
2926
|
const responseBase = {
|
|
3175
2927
|
ok: true,
|
|
@@ -3179,7 +2931,7 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
3179
2931
|
foundingAuthority: commit.foundingAuthority,
|
|
3180
2932
|
foundingAuthMethod: commit.foundingAuthMethod,
|
|
3181
2933
|
...commit.registrationDiagnostics ? { registrationDiagnostics: commit.registrationDiagnostics } : {},
|
|
3182
|
-
...
|
|
2934
|
+
...custody.value.status === "not_requested" ? {} : { walletCustody: custody.value },
|
|
3183
2935
|
custodyKeyManifestDigestB64u: commit.custodyKeyManifestDigestB64u,
|
|
3184
2936
|
ecdsa: {
|
|
3185
2937
|
...commit.ecdsa,
|
|
@@ -3191,7 +2943,8 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
3191
2943
|
};
|
|
3192
2944
|
const issuedContext = {
|
|
3193
2945
|
issuedAtMs: registrationEstablishedSession.issuedAtMs,
|
|
3194
|
-
expectedOrigin: ownerProofContext.expectedOrigin
|
|
2946
|
+
expectedOrigin: ownerProofContext.expectedOrigin,
|
|
2947
|
+
activation: registrationEstablishedSession.activation
|
|
3195
2948
|
};
|
|
3196
2949
|
if (commit.authMethod.kind === "passkey") {
|
|
3197
2950
|
if (!commit.rpId) throw new Error("Passkey registration activation is missing its RP ID");
|
|
@@ -3389,7 +3142,6 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
3389
3142
|
publicIdentity: bootstrap.publicIdentity,
|
|
3390
3143
|
clientShareRetryCounter: bootstrap.clientShareRetryCounter,
|
|
3391
3144
|
relayerShareRetryCounter: bootstrap.relayerShareRetryCounter,
|
|
3392
|
-
publicTranscriptDigest32B64u: bootstrap.publicTranscriptDigest32B64u,
|
|
3393
3145
|
keyHandle: bootstrap.keyHandle,
|
|
3394
3146
|
signingRootId: bootstrap.signingRootId,
|
|
3395
3147
|
signingRootVersion: bootstrap.signingRootVersion,
|
|
@@ -3463,9 +3215,10 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
3463
3215
|
};
|
|
3464
3216
|
}
|
|
3465
3217
|
}
|
|
3466
|
-
async executeWalletRegistrationFinalize(request, prepared,
|
|
3218
|
+
async executeWalletRegistrationFinalize(request, prepared, source, serverTiming, initialSessionPlan, lifecycleDecision) {
|
|
3467
3219
|
const finalizeTiming = createD1RegistrationRouteTimingRecorder("wallets_register_finalize");
|
|
3468
3220
|
const totalTiming = startD1RegistrationRouteTiming("registerFinalizeTotalMs");
|
|
3221
|
+
let startedCustody = null;
|
|
3469
3222
|
try {
|
|
3470
3223
|
const store = this.getRegistrationCeremonyIntentStore();
|
|
3471
3224
|
if (!normalizeOptionalTrimmedString(request.idempotencyKey)) return {
|
|
@@ -3474,29 +3227,20 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
3474
3227
|
message: "registration finalize idempotencyKey is required"
|
|
3475
3228
|
};
|
|
3476
3229
|
const requestFingerprint = await walletRegistrationFinalizeRequestFingerprint(request);
|
|
3477
|
-
const
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
}
|
|
3484
|
-
|
|
3485
|
-
if (storedCeremony) {
|
|
3486
|
-
if (storedCeremony.signerState.kind !== "signer_set_registration") return {
|
|
3487
|
-
ok: false,
|
|
3488
|
-
code: "invalid_state",
|
|
3489
|
-
message: "signer-set registration state is required"
|
|
3490
|
-
};
|
|
3491
|
-
ceremony = registrationFinalizeCeremonyFromStored(storedCeremony);
|
|
3492
|
-
} else if (recovery) {
|
|
3230
|
+
const storedCeremony = source.kind === "stored_ceremony" ? source.ceremony : null;
|
|
3231
|
+
const ceremony = source.kind === "stored_ceremony" ? registrationFinalizeCeremonyFromStored(source.ceremony) : source.ceremony;
|
|
3232
|
+
if (ceremony.registrationCeremonyId !== request.registrationCeremonyId) return {
|
|
3233
|
+
ok: false,
|
|
3234
|
+
code: "scope_mismatch",
|
|
3235
|
+
message: "registration ceremony mismatch"
|
|
3236
|
+
};
|
|
3237
|
+
if (source.kind === "committed_mixed_installation") {
|
|
3493
3238
|
if (request.kind !== "near_ed25519") return {
|
|
3494
3239
|
ok: false,
|
|
3495
3240
|
code: "invalid_state",
|
|
3496
3241
|
message: "committed mixed registration can only finalize NEAR Ed25519"
|
|
3497
3242
|
};
|
|
3498
|
-
|
|
3499
|
-
} else return {
|
|
3243
|
+
} else if (ceremony.expiresAtMs <= Date.now()) return {
|
|
3500
3244
|
ok: false,
|
|
3501
3245
|
code: "not_found",
|
|
3502
3246
|
message: "registration ceremony not found"
|
|
@@ -3521,7 +3265,7 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
3521
3265
|
message: "registration signer set requires a signer branch"
|
|
3522
3266
|
};
|
|
3523
3267
|
const storedEcdsaBranch = findStoredWalletRegistrationEvmFamilyEcdsaBranch(ceremony.signerState);
|
|
3524
|
-
const ecdsaAlreadyFinalized =
|
|
3268
|
+
const ecdsaAlreadyFinalized = source.kind === "committed_mixed_installation" || storedEcdsaBranch?.kind === "evm_family_ecdsa_finalized";
|
|
3525
3269
|
const sequenceFailure = finalizeSignerWorkSequenceFailure({
|
|
3526
3270
|
request,
|
|
3527
3271
|
hasNearEd25519: requestedNearEd25519 !== null,
|
|
@@ -3648,8 +3392,26 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
3648
3392
|
let ed25519SignerRecord = null;
|
|
3649
3393
|
let ed25519MaterialActivation = null;
|
|
3650
3394
|
let ed25519RegisteredPublicKeyB64u = null;
|
|
3651
|
-
let ed25519CapabilityInstallation = null;
|
|
3652
3395
|
let yaoDecision = null;
|
|
3396
|
+
let yaoDecisionFound = null;
|
|
3397
|
+
let commitWallet;
|
|
3398
|
+
const reserveCustody = () => recordRegistrationPromiseTiming({
|
|
3399
|
+
sink: serverTiming,
|
|
3400
|
+
name: "near_finalize_custody_reserve",
|
|
3401
|
+
startedAtMs: Date.now(),
|
|
3402
|
+
promise: reserveRegistrationCustody({
|
|
3403
|
+
payload: walletCustodyCommitPayload,
|
|
3404
|
+
verifiedWalletId: ceremony.intent.walletId,
|
|
3405
|
+
verifiedAuthority: walletAuthAuthority,
|
|
3406
|
+
...emailOtpEnrollment.persistence ? { verifiedEmailOtpEnrollment: {
|
|
3407
|
+
enrollmentId: emailOtpEnrollment.persistence.enrollment.enrollmentId,
|
|
3408
|
+
enrollmentSealKeyVersion: emailOtpEnrollment.persistence.enrollment.enrollmentSealKeyVersion
|
|
3409
|
+
} } : {},
|
|
3410
|
+
nowMs: now,
|
|
3411
|
+
store: this.walletCustodyCommitStore
|
|
3412
|
+
})
|
|
3413
|
+
});
|
|
3414
|
+
let custodyReservation;
|
|
3653
3415
|
if (finalizeNearEd25519) {
|
|
3654
3416
|
const yaoRuntime = this.getEd25519YaoProductRegistration();
|
|
3655
3417
|
if (!yaoRuntime) return {
|
|
@@ -3675,13 +3437,24 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
3675
3437
|
code: "scope_mismatch",
|
|
3676
3438
|
message: "Ed25519 activation reference does not belong to this registration ceremony"
|
|
3677
3439
|
};
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3440
|
+
custodyReservation = reserveCustody();
|
|
3441
|
+
startedCustody = custodyReservation;
|
|
3442
|
+
const [activationConsumption, authorityReservation] = await Promise.allSettled([recordRegistrationPromiseTiming({
|
|
3443
|
+
sink: serverTiming,
|
|
3444
|
+
name: "near_finalize_router_consume",
|
|
3445
|
+
startedAtMs: Date.now(),
|
|
3446
|
+
promise: yaoRuntime.consumeActivated({
|
|
3447
|
+
reference: {
|
|
3448
|
+
lifecycleId: activationReference.lifecycle_id,
|
|
3449
|
+
sessionId: activationReference.session_id
|
|
3450
|
+
},
|
|
3451
|
+
consumerBinding: requestFingerprint
|
|
3452
|
+
})
|
|
3453
|
+
}), this.walletRegistrationCommitStore.reserveAuthority(ceremonyAuthority)]);
|
|
3454
|
+
if (activationConsumption.status === "rejected") throw activationConsumption.reason;
|
|
3455
|
+
if (authorityReservation.status === "rejected") throw authorityReservation.reason;
|
|
3456
|
+
const consumed = activationConsumption.value;
|
|
3457
|
+
commitWallet = authorityReservation.value;
|
|
3685
3458
|
if (!consumed.ok) return {
|
|
3686
3459
|
ok: false,
|
|
3687
3460
|
code: consumed.code,
|
|
@@ -3713,6 +3486,7 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
3713
3486
|
const sponsoredAccountId = sponsoredNamedRegistrationAccountId(finalizeNearEd25519.accountProvisioning);
|
|
3714
3487
|
if (sponsoredAccountId) {
|
|
3715
3488
|
const created = await this.createSponsoredNamedNearAccount({
|
|
3489
|
+
walletId: ceremony.intent.walletId,
|
|
3716
3490
|
accountId: sponsoredAccountId,
|
|
3717
3491
|
publicKey,
|
|
3718
3492
|
idempotencyKey: bytesToUnprefixedHex(Uint8Array.from(consumed.activation.result.binding.session_id))
|
|
@@ -3744,7 +3518,7 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
3744
3518
|
});
|
|
3745
3519
|
if (!resolved.ok) return resolved;
|
|
3746
3520
|
resolvedNearAccount = resolved.value;
|
|
3747
|
-
|
|
3521
|
+
const activeYaoCapability = buildRouterAbEd25519YaoRegistrationCapabilityRecordV1({
|
|
3748
3522
|
kind: "router_ab_ed25519_yao_registration_finalize_capability_v1",
|
|
3749
3523
|
activeCapabilityBinding: consumed.activation.result.binding.session_id,
|
|
3750
3524
|
nearAccountId,
|
|
@@ -3752,8 +3526,7 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
3752
3526
|
registrationAdmissionReceipt: consumed.activation.admissionReceipt,
|
|
3753
3527
|
registrationResult: consumed.activation.result,
|
|
3754
3528
|
runtimePolicyScope
|
|
3755
|
-
};
|
|
3756
|
-
const activeYaoCapability = buildRouterAbEd25519YaoRegistrationCapabilityRecordV1(ed25519CapabilityInstallation);
|
|
3529
|
+
});
|
|
3757
3530
|
if (!activeYaoCapability.ok) return {
|
|
3758
3531
|
ok: false,
|
|
3759
3532
|
code: activeYaoCapability.code,
|
|
@@ -3766,6 +3539,7 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
3766
3539
|
consumerBinding: requestFingerprint,
|
|
3767
3540
|
capability: activeYaoCapability.record
|
|
3768
3541
|
});
|
|
3542
|
+
yaoDecisionFound = routerAbEd25519YaoLifecycleDecisionLookupV1(yaoDecision, lifecycleDecision);
|
|
3769
3543
|
const activatedEd25519PublicResult = {
|
|
3770
3544
|
signerSlot: finalizeNearEd25519.signerSlot,
|
|
3771
3545
|
nearAccountId,
|
|
@@ -3801,14 +3575,18 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
3801
3575
|
custodyKeyManifestDigestB64u,
|
|
3802
3576
|
now
|
|
3803
3577
|
});
|
|
3578
|
+
} else {
|
|
3579
|
+
custodyReservation = reserveCustody();
|
|
3580
|
+
startedCustody = custodyReservation;
|
|
3581
|
+
commitWallet = await this.walletRegistrationCommitStore.reserveAuthority(ceremonyAuthority);
|
|
3804
3582
|
}
|
|
3805
|
-
const yaoDecisionFound = yaoDecision ? routerAbEd25519YaoLifecycleDecisionLookupV1(yaoDecision, await this.yaoLifecycleDecisions.read(yaoDecision.lifecycleId)) : null;
|
|
3806
3583
|
if (yaoDecisionFound?.kind === "decided_otherwise") return {
|
|
3807
3584
|
ok: false,
|
|
3808
3585
|
code: "invalid_state",
|
|
3809
3586
|
message: "Ed25519 Yao registration lifecycle was finalized by another request"
|
|
3810
3587
|
};
|
|
3811
3588
|
let foundingAuthorityRecords = null;
|
|
3589
|
+
let initialSession = { kind: "uncommitted" };
|
|
3812
3590
|
if (yaoDecisionFound?.kind !== "decided") {
|
|
3813
3591
|
const wallet = buildD1WalletRecord({
|
|
3814
3592
|
walletId: ceremony.intent.walletId,
|
|
@@ -3934,6 +3712,7 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
3934
3712
|
}
|
|
3935
3713
|
const decisionStatements = yaoDecision ? this.yaoLifecycleDecisions.prepareDecideStatements(yaoDecision, now) : [];
|
|
3936
3714
|
const persistenceTiming = startD1RegistrationRouteTiming("relayPersistenceMs");
|
|
3715
|
+
const walletCommitStartedAtMs = Date.now();
|
|
3937
3716
|
try {
|
|
3938
3717
|
switch (ceremonyAuthority.kind) {
|
|
3939
3718
|
case "passkey":
|
|
@@ -3942,24 +3721,22 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
3942
3721
|
code: "invalid_state",
|
|
3943
3722
|
message: "Passkey registration cannot persist Email OTP enrollment state"
|
|
3944
3723
|
};
|
|
3945
|
-
if (foundingAuthorityRecords) await
|
|
3724
|
+
if (foundingAuthorityRecords) initialSession = await commitWalletRegistration(commitWallet, {
|
|
3946
3725
|
kind: "passkey_wallet_registration_commit_v1",
|
|
3947
3726
|
wallet,
|
|
3948
3727
|
walletSigners,
|
|
3949
|
-
authority: ceremonyAuthority,
|
|
3950
3728
|
foundingAuthority: foundingAuthorityRecords.authority,
|
|
3951
3729
|
foundingAuthMethod: foundingAuthorityRecords.authMethod,
|
|
3952
3730
|
now,
|
|
3953
3731
|
decisionStatements
|
|
3954
|
-
});
|
|
3955
|
-
else await
|
|
3732
|
+
}, initialSessionPlan);
|
|
3733
|
+
else initialSession = await commitWalletRegistration(commitWallet, {
|
|
3956
3734
|
kind: "passkey_wallet_registration_commit_v1",
|
|
3957
3735
|
wallet,
|
|
3958
3736
|
walletSigners,
|
|
3959
|
-
authority: ceremonyAuthority,
|
|
3960
3737
|
now,
|
|
3961
3738
|
decisionStatements
|
|
3962
|
-
});
|
|
3739
|
+
}, initialSessionPlan);
|
|
3963
3740
|
break;
|
|
3964
3741
|
case "email_otp": {
|
|
3965
3742
|
if (!emailOtpEnrollment.persistence) return {
|
|
@@ -3968,31 +3745,30 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
3968
3745
|
message: "Email OTP registration is missing enrollment persistence state"
|
|
3969
3746
|
};
|
|
3970
3747
|
const emailOtp = this.emailOtpRegistrationEnrollmentFinalizer.prepareRegistrationCommitPlan(emailOtpEnrollment.persistence);
|
|
3971
|
-
if (foundingAuthorityRecords) await
|
|
3748
|
+
if (foundingAuthorityRecords) initialSession = await commitWalletRegistration(commitWallet, {
|
|
3972
3749
|
kind: "email_otp_wallet_registration_commit_v1",
|
|
3973
3750
|
wallet,
|
|
3974
3751
|
walletSigners,
|
|
3975
|
-
authority: ceremonyAuthority,
|
|
3976
3752
|
emailOtp,
|
|
3977
3753
|
foundingAuthority: foundingAuthorityRecords.authority,
|
|
3978
3754
|
foundingAuthMethod: foundingAuthorityRecords.authMethod,
|
|
3979
3755
|
now,
|
|
3980
3756
|
decisionStatements
|
|
3981
|
-
});
|
|
3982
|
-
else await
|
|
3757
|
+
}, initialSessionPlan);
|
|
3758
|
+
else initialSession = await commitWalletRegistration(commitWallet, {
|
|
3983
3759
|
kind: "email_otp_wallet_registration_commit_v1",
|
|
3984
3760
|
wallet,
|
|
3985
3761
|
walletSigners,
|
|
3986
|
-
authority: ceremonyAuthority,
|
|
3987
3762
|
emailOtp,
|
|
3988
3763
|
now,
|
|
3989
3764
|
decisionStatements
|
|
3990
|
-
});
|
|
3765
|
+
}, initialSessionPlan);
|
|
3991
3766
|
break;
|
|
3992
3767
|
}
|
|
3993
3768
|
}
|
|
3994
3769
|
} finally {
|
|
3995
3770
|
finishD1RegistrationRouteTiming(finalizeTiming, persistenceTiming);
|
|
3771
|
+
recordRegistrationServerTiming(serverTiming, "near_finalize_wallet_commit", walletCommitStartedAtMs);
|
|
3996
3772
|
}
|
|
3997
3773
|
}
|
|
3998
3774
|
const completedRegistrationIdentity = await this.emailOtpRegistrationEnrollmentFinalizer.completeRegistrationIdentity({
|
|
@@ -4008,36 +3784,20 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
4008
3784
|
};
|
|
4009
3785
|
const foundingAuthority = persistedFoundingRecords.authority;
|
|
4010
3786
|
const foundingAuthMethod = persistedFoundingRecords.authMethod;
|
|
4011
|
-
|
|
4012
|
-
const
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
};
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
};
|
|
4024
|
-
}
|
|
4025
|
-
const walletCustody = await commitRegistrationCustody({
|
|
4026
|
-
payload: walletCustodyCommitPayload,
|
|
4027
|
-
verifiedWalletId: ceremony.intent.walletId,
|
|
4028
|
-
verifiedAuthority: walletAuthAuthority,
|
|
4029
|
-
...emailOtpEnrollment.persistence ? { verifiedEmailOtpEnrollment: {
|
|
4030
|
-
enrollmentId: emailOtpEnrollment.persistence.enrollment.enrollmentId,
|
|
4031
|
-
enrollmentSealKeyVersion: emailOtpEnrollment.persistence.enrollment.enrollmentSealKeyVersion
|
|
4032
|
-
} } : {},
|
|
4033
|
-
nowMs: now,
|
|
4034
|
-
store: this.walletCustodyCommitStore
|
|
4035
|
-
});
|
|
4036
|
-
if (walletCustody.status === "rejected") console.warn("[wallet-registration] custody commit rejected", {
|
|
4037
|
-
registrationCeremonyId: ceremony.registrationCeremonyId,
|
|
4038
|
-
reason: walletCustody.reason
|
|
3787
|
+
const custody = custodyReservation.then(async (commitCustody) => {
|
|
3788
|
+
const walletCustody = await recordRegistrationPromiseTiming({
|
|
3789
|
+
sink: serverTiming,
|
|
3790
|
+
name: "near_finalize_custody_commit",
|
|
3791
|
+
startedAtMs: Date.now(),
|
|
3792
|
+
promise: commitCustody()
|
|
3793
|
+
});
|
|
3794
|
+
if (walletCustody.status === "rejected") console.warn("[wallet-registration] custody commit rejected", {
|
|
3795
|
+
registrationCeremonyId: ceremony.registrationCeremonyId,
|
|
3796
|
+
reason: walletCustody.reason
|
|
3797
|
+
});
|
|
3798
|
+
return walletCustody;
|
|
4039
3799
|
});
|
|
4040
|
-
|
|
3800
|
+
startedCustody = custody;
|
|
4041
3801
|
const authMethod = walletRegistrationFinalizeAuthMethodFromAuthority(ceremonyAuthority);
|
|
4042
3802
|
let response;
|
|
4043
3803
|
if (ed25519PublicResult && finalizeNearEd25519 && resolvedNearAccount) {
|
|
@@ -4051,7 +3811,6 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
4051
3811
|
foundingAuthMethod,
|
|
4052
3812
|
rpId: finalizePasskeyRpId(ceremonyAuthority),
|
|
4053
3813
|
authMethod,
|
|
4054
|
-
...custodyField,
|
|
4055
3814
|
custodyKeyManifestDigestB64u,
|
|
4056
3815
|
authorityScope,
|
|
4057
3816
|
accountProvisioning: finalizeNearEd25519.accountProvisioning,
|
|
@@ -4065,7 +3824,6 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
4065
3824
|
foundingAuthority,
|
|
4066
3825
|
foundingAuthMethod,
|
|
4067
3826
|
authMethod,
|
|
4068
|
-
...custodyField,
|
|
4069
3827
|
custodyKeyManifestDigestB64u,
|
|
4070
3828
|
authorityScope,
|
|
4071
3829
|
accountProvisioning: finalizeNearEd25519.accountProvisioning,
|
|
@@ -4081,7 +3839,6 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
4081
3839
|
foundingAuthMethod,
|
|
4082
3840
|
rpId: finalizePasskeyRpId(ceremonyAuthority),
|
|
4083
3841
|
authMethod,
|
|
4084
|
-
...custodyField,
|
|
4085
3842
|
custodyKeyManifestDigestB64u,
|
|
4086
3843
|
ecdsa: { walletKeys: ecdsaWalletKeys }
|
|
4087
3844
|
} : {
|
|
@@ -4092,7 +3849,6 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
4092
3849
|
foundingAuthority,
|
|
4093
3850
|
foundingAuthMethod,
|
|
4094
3851
|
authMethod,
|
|
4095
|
-
...custodyField,
|
|
4096
3852
|
custodyKeyManifestDigestB64u,
|
|
4097
3853
|
ecdsa: { walletKeys: ecdsaWalletKeys }
|
|
4098
3854
|
};
|
|
@@ -4126,16 +3882,30 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
4126
3882
|
}
|
|
4127
3883
|
});
|
|
4128
3884
|
finishD1RegistrationRouteTiming(finalizeTiming, totalTiming);
|
|
4129
|
-
|
|
3885
|
+
startedCustody = null;
|
|
3886
|
+
return {
|
|
3887
|
+
ok: true,
|
|
3888
|
+
finalized: withD1RegistrationRouteDiagnostics(response, finalizeTiming),
|
|
3889
|
+
custody,
|
|
3890
|
+
initialSession
|
|
3891
|
+
};
|
|
4130
3892
|
}
|
|
4131
3893
|
finishD1RegistrationRouteTiming(finalizeTiming, totalTiming);
|
|
4132
|
-
|
|
3894
|
+
startedCustody = null;
|
|
3895
|
+
return {
|
|
3896
|
+
ok: true,
|
|
3897
|
+
finalized: withD1RegistrationRouteDiagnostics(response, finalizeTiming),
|
|
3898
|
+
custody,
|
|
3899
|
+
initialSession
|
|
3900
|
+
};
|
|
4133
3901
|
} catch (error) {
|
|
4134
3902
|
return {
|
|
4135
3903
|
ok: false,
|
|
4136
3904
|
code: "internal",
|
|
4137
3905
|
message: errorMessage(error) || "Failed to finalize wallet registration ceremony"
|
|
4138
3906
|
};
|
|
3907
|
+
} finally {
|
|
3908
|
+
await startedCustody;
|
|
4139
3909
|
}
|
|
4140
3910
|
}
|
|
4141
3911
|
};
|