@seams/wallet-server 0.8.0 → 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 -1
- package/artifact-manifest.json +196 -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 -117
- 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/ed25519WalletSessionAdmission.js +0 -0
- package/dist/esm/authorization/service.js +64 -36
- package/dist/esm/cloud-host.js +24 -19
- package/dist/esm/core/EmailOtpRecords.js +29 -6
- package/dist/esm/core/ThresholdService/routerAb/ecdsaDerivationPoolFillHandlers.js +2 -0
- 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/validation.js +2 -2
- package/dist/esm/core/authService/nearPrivateKeySigning.js +1 -1
- package/dist/esm/core/authService/webauthn.js +1 -1
- package/dist/esm/core/d1Ed25519SignerRead.js +55 -0
- package/dist/esm/core/d1WalletStore.js +14 -11
- package/dist/esm/core/deviceLinking/linkedDeviceEmailOtpGrant.js +2 -2
- package/dist/esm/core/deviceLinking/linkedDeviceManagement.js +1 -1
- package/dist/esm/core/deviceLinking/linkedDeviceSessionRecord.js +2 -2
- package/dist/esm/core/emailOtpD1Statements.js +1 -0
- package/dist/esm/core/nearRelayerAccountProvisioning.js +1 -1
- package/dist/esm/core/routerAbSigning/RouterAbEcdsaPresignRuntime.js +4 -0
- package/dist/esm/core/signingLanes/WalletExecutionLaneProjection.js +1 -1
- package/dist/esm/core/signingMaterial/ordinaryInactiveSignerMaterialReservation.js +1 -0
- package/dist/esm/hosted-wallet-gateway.js +93 -10
- package/dist/esm/localHostedWalletGatewayHandler.js +12 -9
- package/dist/esm/localIntendedYaoSigningFault.js +2 -30
- package/dist/esm/localRegistrationSetupAuthority.js +8 -1
- 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 -1
- package/dist/esm/router/cloudflare/d1/auth/d1AuthorizationAssembly.js +4 -3
- 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 +14 -6
- package/dist/esm/router/cloudflare/d1/auth/d1RouterApiAuthService.js +44 -40
- package/dist/esm/router/cloudflare/d1/auth/walletSessionCredentialReaders.js +17 -1
- package/dist/esm/router/cloudflare/d1/authorization/authorizedOperationStatements.js +35 -5
- package/dist/esm/router/cloudflare/d1/authorization/d1AuthorizationStore.js +258 -99
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceAuthorityInstallService.js +31 -4
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceOwnerAuthorizationProvider.js +1 -1
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceRequestProofNonceStore.js +1 -1
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceSessionRecords.js +1 -1
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceTargetCredentialProvider.js +1 -1
- 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/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 -8
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeStore.js +14 -8
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeVerifier.js +3 -1
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpRateLimitStore.js +58 -38
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpRecords.js +27 -20
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpRecoveryService.js +1 -0
- package/dist/esm/router/cloudflare/d1/emailOtp/d1GoogleEmailOtpSessionResolver.js +1 -0
- package/dist/esm/router/cloudflare/d1/oidc/d1OidcBoundary.js +1 -1
- package/dist/esm/router/cloudflare/d1/passkeyCustody/d1WalletCustodyCommitStore.js +18 -7
- package/dist/esm/router/cloudflare/d1/registration/d1RegistrationCeremonyRecordStore.js +75 -14
- package/dist/esm/router/cloudflare/d1/registration/d1RegistrationCeremonyRecords.js +1 -1
- package/dist/esm/router/cloudflare/d1/registration/d1RegistrationCeremonyStore.js +49 -29
- package/dist/esm/router/cloudflare/d1/registration/d1RegistrationSessionTransaction.js +28 -0
- package/dist/esm/router/cloudflare/d1/registration/d1RegistrationSetupSupport.js +11 -1
- 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 +83 -42
- 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 +439 -500
- package/dist/esm/router/cloudflare/d1/registration/d1WalletRegistrationSetup.js +1 -1
- package/dist/esm/router/cloudflare/d1/registration/d1WalletRegistrationSetupExecution.js +104 -90
- package/dist/esm/router/cloudflare/d1/registration/walletRegistrationEstablishedSessionIssuer.js +78 -44
- package/dist/esm/router/cloudflare/d1/registration/walletRegistrationSessionCommitReceipt.js +11 -35
- package/dist/esm/router/cloudflare/d1/signingAdmission/d1RouterAbNormalSigningAdmissionStore.js +98 -39
- 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 +1 -1
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletAddSignerService.js +15 -6
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletAuthMethodService.js +3 -40
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletAuthorityStore.js +54 -1
- 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 +1 -1
- package/dist/esm/router/cloudflare/runtime/routerAbServiceBindings.js +32 -1
- package/dist/esm/router/cloudflare/runtime/staticWalletConsoleBinding.js +20 -8
- package/dist/esm/router/cloudflare/runtime/walletAuthorizationRelocationRoutes.js +488 -0
- package/dist/esm/router/cloudflare/runtime/walletConsoleOps.js +1 -1
- package/dist/esm/router/cloudflare/runtime/walletConsoleOpsClient.js +26 -6
- 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/signingLanes/cloudflareOrdinaryInactiveSignerMaterialReservation.js +30 -8
- package/dist/esm/router/cloudflare-adaptor.js +8 -8
- package/dist/esm/router/cloudflare.js +34115 -32240
- 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 +32 -6
- package/dist/esm/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistrationPartitionedStateStore.js +61 -1
- 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 +52 -22
- package/dist/esm/router/domains/ed25519Yao/export/routerAbEd25519YaoExportRequestScopedCloudflare.js +10 -7
- package/dist/esm/router/domains/ed25519Yao/recovery/routerAbEd25519YaoRecovery.js +108 -78
- package/dist/esm/router/domains/ed25519Yao/recovery/routerAbEd25519YaoRecoveryRequestScopedCloudflare.js +19 -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/emailOtpRouteHandlers.js +2 -2
- package/dist/esm/router/domains/passkeyCustody/passkeyCustodyEnvelopeRetrieval.js +1 -1
- 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 +16 -6
- 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 +1 -1
- package/dist/esm/router/domains/signingOperations/signingPrepareSession.js +33 -0
- package/dist/esm/router/domains/walletRegistration/registrationSessionSeal.js +121 -0
- package/dist/esm/router/domains/walletRegistration/walletRegistrationReservation.js +4 -4
- package/dist/esm/router/domains/walletRegistration/walletRegistrationRoutes.js +46 -157
- package/dist/esm/router/domains/walletRegistration/walletRegistrationSetupPayload.js +1 -1
- package/dist/esm/router/express.js +764 -894
- package/dist/esm/router/framework/http.js +2 -1
- package/dist/esm/router/transport/fetch/createFetchRouter.js +2 -2
- package/dist/esm/router/transport/fetch/routes/auth.js +1 -1
- package/dist/esm/router/transport/fetch/routes/deviceLinking.js +3 -3
- package/dist/esm/router/transport/fetch/routes/deviceLinkingOwnerAuthorization.js +2 -2
- 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 +3 -3
- package/dist/esm/router/transport/fetch/routes/sessions.js +3 -2
- package/dist/esm/router/transport/fetch/routes/thresholdEcdsa.js +67 -130
- 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 -5
- 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/device-linking/activeWalletSession.js +12 -2
- package/dist/esm/shared-ts/src/device-linking/digests.js +1 -1
- 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/nearClient.js +1 -1
- package/dist/esm/shared-ts/src/signing-lanes/ownerContinuity.js +2 -2
- 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/routerAbEcdsaDerivation.js +1 -1
- package/dist/esm/shared-ts/src/utils/routerAbPublicKeyset.js +0 -27
- package/dist/esm/shared-ts/src/wallet-recovery/walletRecoveryEcdsaPossession.js +1 -1
- package/dist/esm/threshold/session/signingSessionSeal/options.js +1 -1
- package/dist/esm/wasm/near_signer/pkg/wasm_signer_worker_bg.wasm +0 -0
- package/dist/types/shared-ts/src/device-linking/activeWalletSession.d.ts +2 -1
- package/dist/types/shared-ts/src/device-linking/contracts.d.ts +10 -0
- package/dist/types/shared-ts/src/threshold/ed25519OperationFingerprint.d.ts +2 -1
- package/dist/types/shared-ts/src/utils/emailOtpDomain.d.ts +3 -1
- package/dist/types/shared-ts/src/utils/routerAbPublicKeyset.d.ts +0 -9
- package/dist/types/shared-ts/src/utils/walletManagementProtocol.d.ts +1 -1
- 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/service.d.ts +43 -5
- package/dist/types/wallet-server/src/authorization/sessionRouting.d.ts +2 -0
- package/dist/types/wallet-server/src/cloud-host.d.ts +7 -3
- package/dist/types/wallet-server/src/core/EmailOtpRecords.d.ts +2 -1
- package/dist/types/wallet-server/src/core/EmailOtpStores.d.ts +19 -5
- package/dist/types/wallet-server/src/core/ThresholdService/routerAb/ecdsaDerivationPoolFillHandlers.d.ts +1 -0
- 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/d1Ed25519SignerRead.d.ts +17 -0
- package/dist/types/wallet-server/src/core/d1WalletStore.d.ts +6 -0
- package/dist/types/wallet-server/src/core/emailOtpD1Statements.d.ts +1 -0
- package/dist/types/wallet-server/src/core/routerAbSigning/RouterAbEcdsaPresignRuntime.d.ts +5 -1
- package/dist/types/wallet-server/src/core/signingMaterial/ordinaryInactiveSignerMaterialReservation.d.ts +1 -0
- package/dist/types/wallet-server/src/core/threeRouteRegistrationContracts.d.ts +14 -48
- package/dist/types/wallet-server/src/hosted-wallet-gateway.d.ts +4 -3
- package/dist/types/wallet-server/src/localIntendedYaoSigningFault.d.ts +1 -16
- package/dist/types/wallet-server/src/localRegistrationSetupAuthority.d.ts +1 -1
- 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 +1 -1
- 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 +7 -4
- 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 +32 -1
- package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceAuthorityInstallService.d.ts +2 -0
- 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/d1EmailOtpChallengeStore.d.ts +1 -0
- 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/d1EmailOtpRateLimitStore.d.ts +6 -29
- package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpRecords.d.ts +21 -7
- package/dist/types/wallet-server/src/router/cloudflare/d1/passkeyCustody/d1WalletCustodyCommitStore.d.ts +17 -1
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1RegistrationCeremonyRecordStore.d.ts +32 -7
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1RegistrationCeremonyStore.d.ts +16 -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 +7 -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 +6 -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 +24 -45
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1WalletRegistrationSetupExecution.d.ts +9 -4
- 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/d1WalletAddSignerService.d.ts +3 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/wallet/d1WalletAuthMethodService.d.ts +3 -7
- package/dist/types/wallet-server/src/router/cloudflare/d1/wallet/d1WalletAuthorityStore.d.ts +8 -0
- 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/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 -1
- package/dist/types/wallet-server/src/router/cloudflare/runtime/walletConsoleOpsClient.d.ts +3 -3
- 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/signingLanes/cloudflareOrdinaryInactiveSignerMaterialReservation.d.ts +5 -0
- 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 +41 -7
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistrationPartitionedStateStore.d.ts +33 -2
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/export/routerAbEd25519YaoExport.d.ts +12 -6
- 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/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/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 -5
- 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/signingPrepareSession.d.ts +23 -0
- 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 +7 -7
- package/dist/types/wallet-server/src/router/domains/walletRegistration/walletRegistrationReservation.d.ts +80 -6
- package/dist/types/wallet-server/src/router/domains/walletRegistration/walletRegistrationRoutes.d.ts +15 -5
- package/dist/types/wallet-server/src/router/framework/apiCredentialPorts.d.ts +24 -0
- package/dist/types/wallet-server/src/router/framework/authServicePort.d.ts +21 -7
- package/dist/types/wallet-server/src/router/framework/routerApi.d.ts +3 -12
- 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/tenantRoute.d.ts +1 -1
- 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 +1 -1
- package/src/README.md +23 -1
- package/cloudflare-router-ab/scripts/local-key-material.mjs +0 -29
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { normalizeOptionalTrimmedString } from "../../../../shared-ts/src/utils/normalize.js";
|
|
2
2
|
import { normalizeRegistrationAuthMethodInput } from "../../../../shared-ts/src/utils/registrationAuthMethodInput.js";
|
|
3
3
|
import { thresholdEcdsaChainTargetFromValue } from "../../../../core/thresholdEcdsaChainTarget.js";
|
|
4
|
-
import { computeWalletRegistrationSetupDigestB64u, mintSignedWalletRegistrationSetup } from "../../../domains/walletRegistration/walletRegistrationSetupPayload.js";
|
|
5
4
|
import { normalizeRegistrationSignerPlan, registrationSignerSetSelectionFromPlan } from "../../../../shared-ts/src/utils/registrationSignerPlan.js";
|
|
6
5
|
import { computeRegistrationIntentDigestB64u } from "../../../../shared-ts/src/utils/registrationIntent.js";
|
|
6
|
+
import { computeWalletRegistrationSetupDigestB64u, mintSignedWalletRegistrationSetup } from "../../../domains/walletRegistration/walletRegistrationSetupPayload.js";
|
|
7
7
|
//#region src/router/cloudflare/d1/registration/d1WalletRegistrationSetup.ts
|
|
8
8
|
/**
|
|
9
9
|
* `/wallets/register/setup` — one request replacing the bootstrap grant, the
|
|
@@ -20,101 +20,114 @@ async function executeD1WalletRegistrationSetup(input, dependencies) {
|
|
|
20
20
|
if (input.request.wallet?.kind === "provided" && input.request.wallet.walletId !== wallet.walletId) return walletRegistrationSetupError("reservation_conflict", "Registration reservation changed the requested wallet");
|
|
21
21
|
const expiresAtMs = walletRegistrationSetupExpiresAtMs(reservation.reservedAtMs);
|
|
22
22
|
if (Date.now() >= expiresAtMs) return walletRegistrationSetupError("registration_expired", "Registration setup has expired");
|
|
23
|
-
const
|
|
24
|
-
const registrationPreparationId = reservation.preparationId;
|
|
25
|
-
const runtimePolicyScope = input.runtimePolicyScope || inferRuntimePolicyScopeFromSigningRoot({
|
|
26
|
-
orgId: input.orgId,
|
|
27
|
-
signingRootId: input.signingRootId,
|
|
28
|
-
signingRootVersion: input.signingRootVersion
|
|
29
|
-
});
|
|
30
|
-
const signingRootId = normalizeOptionalTrimmedString(input.signingRootId) || (runtimePolicyScope ? deriveSigningRootId(runtimePolicyScope) : "");
|
|
31
|
-
const signingRootVersion = normalizeOptionalTrimmedString(input.signingRootVersion) || runtimePolicyScope?.signingRootVersion || "default";
|
|
32
|
-
if (!signingRootId) return walletRegistrationSetupError("invalid_body", "registration requires a signing root");
|
|
33
|
-
const registrationOperation = reservation;
|
|
34
|
-
const intent = buildRegistrationIntent({
|
|
35
|
-
nonceB64u: registrationCeremonyId.slice(4),
|
|
23
|
+
const [startup, setup] = await Promise.allSettled([dependencies.startRegistrationWallets?.({
|
|
36
24
|
walletId: wallet.walletId,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const existing = await dependencies.store.getSetupCeremony(registrationCeremonyId);
|
|
44
|
-
if (existing) {
|
|
45
|
-
if (existing.digestB64u !== digestB64u || existing.expectedOrigin !== input.expectedOrigin || existing.foundingWalletAuthorityId !== reservation.walletAuthorityId || existing.foundingDeviceId !== reservation.deviceId || existing.foundingWalletAuthMethodId !== reservation.walletAuthMethodId || existing.expiresAtMs !== expiresAtMs) return walletRegistrationSetupError("reservation_conflict", "Registration setup conflicts with its reservation");
|
|
46
|
-
if (admitted.lifecycle === "reserved") await dependencies.store.ensureSetupCeremony(existing);
|
|
47
|
-
return await setupResponseFromCeremony(input, existing);
|
|
48
|
-
}
|
|
49
|
-
if (admitted.lifecycle === "established") return walletRegistrationSetupError("registration_closed", "Completed registration setup snapshot is unavailable");
|
|
50
|
-
const branches = registrationIntentSignerBranches(intent);
|
|
51
|
-
if (!branches.ok) return walletRegistrationSetupError(branches.code, branches.message);
|
|
52
|
-
const ecdsaBranch = branches.value.evmFamilyEcdsa;
|
|
53
|
-
const nearEd25519Branch = branches.value.nearEd25519;
|
|
54
|
-
if (!ecdsaBranch && !nearEd25519Branch) return walletRegistrationSetupError("invalid_body", "registration signer branch is required");
|
|
55
|
-
const preparedContext = resolveRegistrationPreparedContextFromPlan({
|
|
56
|
-
signerPlan: branches.value.plan,
|
|
57
|
-
runtimePolicyScope,
|
|
58
|
-
signingRootId,
|
|
59
|
-
signingRootVersion
|
|
60
|
-
});
|
|
61
|
-
if (!preparedContext.ok) return walletRegistrationSetupError(preparedContext.code, preparedContext.message);
|
|
62
|
-
if (ecdsaBranch && !runtimePolicyScope) return walletRegistrationSetupError("invalid_body", "ECDSA registration requires an exact runtime policy scope");
|
|
63
|
-
const chainTargets = ecdsaBranch ? registrationPreparedContextEcdsaChainTargets(preparedContext.preparedContext) : null;
|
|
64
|
-
if (ecdsaBranch && !chainTargets) return walletRegistrationSetupError("invalid_body", "ECDSA chain targets are required");
|
|
65
|
-
const ecdsaPrepared = ecdsaBranch && chainTargets && runtimePolicyScope ? await buildD1EvmFamilyEcdsaRegistrationPrepare({
|
|
66
|
-
registrationPurpose: "wallet_registration",
|
|
67
|
-
registrationCeremonyId,
|
|
68
|
-
registrationPreparationId: registrationPreparationIdFromString(registrationPreparationId),
|
|
69
|
-
walletId: wallet.walletId,
|
|
70
|
-
signingRootId,
|
|
71
|
-
signingRootVersion,
|
|
72
|
-
chainTargets,
|
|
73
|
-
participantIds: [...ecdsaBranch.participantIds],
|
|
74
|
-
strictRegistration: dependencies.ecdsaStrictRegistration,
|
|
75
|
-
runtimePolicyScope
|
|
76
|
-
}) : null;
|
|
77
|
-
if (ecdsaPrepared && !ecdsaPrepared.ok) return walletRegistrationSetupError(ecdsaPrepared.code, ecdsaPrepared.message);
|
|
78
|
-
const storedBranches = [];
|
|
79
|
-
if (ecdsaPrepared?.ok && ecdsaBranch) storedBranches.push(buildStoredWalletRegistrationEvmFamilyEcdsaPreparedBranch({
|
|
80
|
-
branchKey: ecdsaBranch.branchKey,
|
|
81
|
-
ecdsa: {
|
|
82
|
-
kind: ecdsaPrepared.ecdsa.kind,
|
|
83
|
-
chainTargets: ecdsaPrepared.ecdsa.chainTargets,
|
|
84
|
-
prepare: ecdsaPrepared.ecdsa.prepare,
|
|
85
|
-
strictRegistration: ecdsaPrepared.ecdsa.strictRegistration,
|
|
86
|
-
strictRegistrationBindingJson: routerAbEcdsaStrictRegistrationFactsBindingJson(ecdsaPrepared.ecdsa.strictRegistration)
|
|
87
|
-
}
|
|
88
|
-
}));
|
|
89
|
-
const ceremony = {
|
|
90
|
-
registrationCeremonyId,
|
|
91
|
-
foundingWalletAuthorityId: registrationOperation.walletAuthorityId,
|
|
92
|
-
foundingDeviceId: registrationOperation.deviceId,
|
|
93
|
-
foundingWalletAuthMethodId: registrationOperation.walletAuthMethodId,
|
|
94
|
-
intent,
|
|
95
|
-
digestB64u,
|
|
96
|
-
signerPlan: branches.value.plan,
|
|
97
|
-
preparedContext: preparedContext.preparedContext,
|
|
98
|
-
orgId: normalizeOptionalTrimmedString(input.orgId) || "",
|
|
99
|
-
signingRootId,
|
|
100
|
-
signingRootVersion,
|
|
101
|
-
...input.expectedOrigin ? { expectedOrigin: input.expectedOrigin } : {},
|
|
102
|
-
expiresAtMs,
|
|
103
|
-
authorityState: {
|
|
104
|
-
kind: "awaiting_proof",
|
|
105
|
-
authMethod: normalized.authMethod
|
|
106
|
-
},
|
|
107
|
-
signerState: {
|
|
108
|
-
kind: "signer_set_registration",
|
|
109
|
-
branches: storedBranches
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
return await setupResponseFromCeremony(input, await dependencies.store.reserveSetupCeremony(ceremony));
|
|
25
|
+
ownershipGeneration: admitted.ownershipGeneration
|
|
26
|
+
}), completeReservedRegistrationSetup(input, dependencies, admitted, normalized, expiresAtMs)]);
|
|
27
|
+
if (setup.status === "rejected") throw setup.reason;
|
|
28
|
+
if (!setup.value.ok) return setup.value;
|
|
29
|
+
if (startup.status === "rejected") throw startup.reason;
|
|
30
|
+
return setup.value;
|
|
113
31
|
} catch (error) {
|
|
114
32
|
return walletRegistrationSetupError("internal", errorMessage(error) || "Failed to set up wallet registration");
|
|
115
33
|
}
|
|
116
34
|
}
|
|
117
|
-
async function
|
|
35
|
+
async function completeReservedRegistrationSetup(input, dependencies, admitted, normalized, expiresAtMs) {
|
|
36
|
+
const reservation = admitted.reservation;
|
|
37
|
+
const wallet = { walletId: reservation.walletId };
|
|
38
|
+
const registrationCeremonyId = reservation.ceremonyId;
|
|
39
|
+
const registrationPreparationId = reservation.preparationId;
|
|
40
|
+
const runtimePolicyScope = input.runtimePolicyScope || inferRuntimePolicyScopeFromSigningRoot({
|
|
41
|
+
orgId: input.orgId,
|
|
42
|
+
signingRootId: input.signingRootId,
|
|
43
|
+
signingRootVersion: input.signingRootVersion
|
|
44
|
+
});
|
|
45
|
+
const signingRootId = normalizeOptionalTrimmedString(input.signingRootId) || (runtimePolicyScope ? deriveSigningRootId(runtimePolicyScope) : "");
|
|
46
|
+
const signingRootVersion = normalizeOptionalTrimmedString(input.signingRootVersion) || runtimePolicyScope?.signingRootVersion || "default";
|
|
47
|
+
if (!signingRootId) return walletRegistrationSetupError("invalid_body", "registration requires a signing root");
|
|
48
|
+
const registrationOperation = reservation;
|
|
49
|
+
const intent = buildRegistrationIntent({
|
|
50
|
+
nonceB64u: registrationCeremonyId.slice(4),
|
|
51
|
+
walletId: wallet.walletId,
|
|
52
|
+
authMethod: normalized.authMethod,
|
|
53
|
+
signerSelection: normalized.signerSelection,
|
|
54
|
+
foundingWalletAuthMethodId: registrationOperation.walletAuthMethodId,
|
|
55
|
+
...runtimePolicyScope ? { runtimePolicyScope } : {}
|
|
56
|
+
});
|
|
57
|
+
const digestB64u = await walletRegistrationSetupIntentDigest(intent);
|
|
58
|
+
const branches = registrationIntentSignerBranches(intent);
|
|
59
|
+
if (!branches.ok) return walletRegistrationSetupError(branches.code, branches.message);
|
|
60
|
+
const existing = admitted.lifecycle === "established" || branches.value.evmFamilyEcdsa ? await dependencies.store.getSetupCeremony(registrationCeremonyId) : null;
|
|
61
|
+
if (existing) {
|
|
62
|
+
if (existing.digestB64u !== digestB64u || existing.expectedOrigin !== input.expectedOrigin || existing.foundingWalletAuthorityId !== reservation.walletAuthorityId || existing.foundingDeviceId !== reservation.deviceId || existing.foundingWalletAuthMethodId !== reservation.walletAuthMethodId || existing.expiresAtMs !== expiresAtMs) return walletRegistrationSetupError("reservation_conflict", "Registration setup conflicts with its reservation");
|
|
63
|
+
if (admitted.lifecycle === "reserved") await dependencies.store.reserveSetupCeremony(existing, admitted.ownershipGeneration);
|
|
64
|
+
return await setupResponseFromCeremony(input, dependencies.home, existing);
|
|
65
|
+
}
|
|
66
|
+
if (admitted.lifecycle === "established") return walletRegistrationSetupError("registration_closed", "Completed registration setup snapshot is unavailable");
|
|
67
|
+
const ecdsaBranch = branches.value.evmFamilyEcdsa;
|
|
68
|
+
const nearEd25519Branch = branches.value.nearEd25519;
|
|
69
|
+
if (!ecdsaBranch && !nearEd25519Branch) return walletRegistrationSetupError("invalid_body", "registration signer branch is required");
|
|
70
|
+
const preparedContext = resolveRegistrationPreparedContextFromPlan({
|
|
71
|
+
signerPlan: branches.value.plan,
|
|
72
|
+
runtimePolicyScope,
|
|
73
|
+
signingRootId,
|
|
74
|
+
signingRootVersion
|
|
75
|
+
});
|
|
76
|
+
if (!preparedContext.ok) return walletRegistrationSetupError(preparedContext.code, preparedContext.message);
|
|
77
|
+
if (ecdsaBranch && !runtimePolicyScope) return walletRegistrationSetupError("invalid_body", "ECDSA registration requires an exact runtime policy scope");
|
|
78
|
+
const chainTargets = ecdsaBranch ? registrationPreparedContextEcdsaChainTargets(preparedContext.preparedContext) : null;
|
|
79
|
+
if (ecdsaBranch && !chainTargets) return walletRegistrationSetupError("invalid_body", "ECDSA chain targets are required");
|
|
80
|
+
const ecdsaPrepared = ecdsaBranch && chainTargets && runtimePolicyScope ? await buildD1EvmFamilyEcdsaRegistrationPrepare({
|
|
81
|
+
registrationPurpose: "wallet_registration",
|
|
82
|
+
registrationCeremonyId,
|
|
83
|
+
registrationPreparationId: registrationPreparationIdFromString(registrationPreparationId),
|
|
84
|
+
walletId: wallet.walletId,
|
|
85
|
+
signingRootId,
|
|
86
|
+
signingRootVersion,
|
|
87
|
+
chainTargets,
|
|
88
|
+
participantIds: [...ecdsaBranch.participantIds],
|
|
89
|
+
strictRegistration: dependencies.ecdsaStrictRegistration,
|
|
90
|
+
runtimePolicyScope
|
|
91
|
+
}) : null;
|
|
92
|
+
if (ecdsaPrepared && !ecdsaPrepared.ok) return walletRegistrationSetupError(ecdsaPrepared.code, ecdsaPrepared.message);
|
|
93
|
+
const storedBranches = [];
|
|
94
|
+
if (ecdsaPrepared?.ok && ecdsaBranch) storedBranches.push(buildStoredWalletRegistrationEvmFamilyEcdsaPreparedBranch({
|
|
95
|
+
branchKey: ecdsaBranch.branchKey,
|
|
96
|
+
ecdsa: {
|
|
97
|
+
kind: ecdsaPrepared.ecdsa.kind,
|
|
98
|
+
chainTargets: ecdsaPrepared.ecdsa.chainTargets,
|
|
99
|
+
prepare: ecdsaPrepared.ecdsa.prepare,
|
|
100
|
+
strictRegistration: ecdsaPrepared.ecdsa.strictRegistration,
|
|
101
|
+
strictRegistrationBindingJson: routerAbEcdsaStrictRegistrationFactsBindingJson(ecdsaPrepared.ecdsa.strictRegistration)
|
|
102
|
+
}
|
|
103
|
+
}));
|
|
104
|
+
const ceremony = {
|
|
105
|
+
registrationCeremonyId,
|
|
106
|
+
foundingWalletAuthorityId: registrationOperation.walletAuthorityId,
|
|
107
|
+
foundingDeviceId: registrationOperation.deviceId,
|
|
108
|
+
foundingWalletAuthMethodId: registrationOperation.walletAuthMethodId,
|
|
109
|
+
intent,
|
|
110
|
+
digestB64u,
|
|
111
|
+
signerPlan: branches.value.plan,
|
|
112
|
+
preparedContext: preparedContext.preparedContext,
|
|
113
|
+
orgId: normalizeOptionalTrimmedString(input.orgId) || "",
|
|
114
|
+
signingRootId,
|
|
115
|
+
signingRootVersion,
|
|
116
|
+
...input.expectedOrigin ? { expectedOrigin: input.expectedOrigin } : {},
|
|
117
|
+
expiresAtMs,
|
|
118
|
+
authorityState: {
|
|
119
|
+
kind: "awaiting_proof",
|
|
120
|
+
authMethod: normalized.authMethod
|
|
121
|
+
},
|
|
122
|
+
signerState: {
|
|
123
|
+
kind: "signer_set_registration",
|
|
124
|
+
branches: storedBranches
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
const stored = await dependencies.store.reserveSetupCeremony(ceremony, admitted.ownershipGeneration);
|
|
128
|
+
return await setupResponseFromCeremony(input, dependencies.home, stored);
|
|
129
|
+
}
|
|
130
|
+
async function setupResponseFromCeremony(input, home, ceremony) {
|
|
118
131
|
const { signedSetup } = await buildWalletRegistrationSetupSignature({
|
|
119
132
|
signer: input.signer,
|
|
120
133
|
ceremony,
|
|
@@ -123,6 +136,7 @@ async function setupResponseFromCeremony(input, ceremony) {
|
|
|
123
136
|
const branches = registrationIntentSignerBranches(ceremony.intent);
|
|
124
137
|
if (!branches.ok) return branches;
|
|
125
138
|
const success = {
|
|
139
|
+
home,
|
|
126
140
|
ok: true,
|
|
127
141
|
registrationCeremonyId: ceremony.registrationCeremonyId,
|
|
128
142
|
walletId: String(ceremony.intent.walletId),
|
package/dist/esm/router/cloudflare/d1/registration/walletRegistrationEstablishedSessionIssuer.js
CHANGED
|
@@ -14,11 +14,48 @@ import { DEFAULT_WALLET_SESSION_TTL_MS } from "../../../../shared-ts/src/thresho
|
|
|
14
14
|
import { deriveThresholdEcdsaKeyHandle } from "../../../../shared-ts/src/utils/thresholdEcdsaKeyHandle.js";
|
|
15
15
|
import { registrationEstablishedMintId } from "./walletRegistrationSessionCommitReceipt.js";
|
|
16
16
|
//#region src/router/cloudflare/d1/registration/walletRegistrationEstablishedSessionIssuer.ts
|
|
17
|
+
async function commitInitialEd25519RegistrationSession(input, commitSession) {
|
|
18
|
+
const issuedAtMs = Date.now();
|
|
19
|
+
await assertDirectWalletSessionOwnerProof({
|
|
20
|
+
proof: input.proof,
|
|
21
|
+
tenantId: input.authorizationTenantId,
|
|
22
|
+
authority: input.authority,
|
|
23
|
+
activeAuthority: input.foundingAuthority,
|
|
24
|
+
walletAuthMethodId: input.walletAuthMethodId,
|
|
25
|
+
nowMs: issuedAtMs
|
|
26
|
+
});
|
|
27
|
+
const policy = registrationSessionPolicy({
|
|
28
|
+
issuedAtMs,
|
|
29
|
+
expiresAtMs: input.expiresAtMs,
|
|
30
|
+
remainingUses: input.remainingUses
|
|
31
|
+
});
|
|
32
|
+
return input.authorizationService.commitDirectWalletSessionAuthorizationV2({
|
|
33
|
+
tenantId: input.authorizationTenantId,
|
|
34
|
+
principalId: walletSessionPrincipalId(input.authority),
|
|
35
|
+
walletId: walletIdFromString(String(input.authority.walletId)),
|
|
36
|
+
authority: input.foundingAuthority,
|
|
37
|
+
walletAuthMethodId: input.walletAuthMethodId,
|
|
38
|
+
mintId: registrationEstablishedMintId(input.registrationCeremonyId),
|
|
39
|
+
remainingUses: policy.remainingUses,
|
|
40
|
+
issuedAtMs,
|
|
41
|
+
expiresAtMs: policy.expiresAtMs
|
|
42
|
+
}, { kind: "validated_registration_authority_projection" }, {
|
|
43
|
+
kind: "registration",
|
|
44
|
+
ceremonyId: input.registrationCeremonyId
|
|
45
|
+
}, commitSession);
|
|
46
|
+
}
|
|
17
47
|
function requireWalletSessionPrincipalId(value) {
|
|
18
48
|
const parsed = parsePrincipalId(value);
|
|
19
49
|
if (!parsed.ok) throw new Error(`Wallet Session principal is invalid: ${parsed.error.message}`);
|
|
20
50
|
return parsed.value;
|
|
21
51
|
}
|
|
52
|
+
function publishCommittedRegistration(home, committed) {
|
|
53
|
+
if (!committed.registration) throw new Error("Registration publication requires a committed registration session");
|
|
54
|
+
return home.publishEstablished({
|
|
55
|
+
registration: committed.registration,
|
|
56
|
+
session: committed.publication
|
|
57
|
+
});
|
|
58
|
+
}
|
|
22
59
|
function walletSessionPrincipalId(authority) {
|
|
23
60
|
return requireWalletSessionPrincipalId(isEmailOtpWalletAuthAuthority(authority) ? String(authority.factor.providerUserId) : String(authority.walletId));
|
|
24
61
|
}
|
|
@@ -229,13 +266,15 @@ function directRegistrationResultFromIssue(input) {
|
|
|
229
266
|
case "issued": return {
|
|
230
267
|
kind: "issued",
|
|
231
268
|
session: directRegistrationSession(input.authorization, input.tokens, input.directIssue.operationCredential),
|
|
232
|
-
issuedAtMs: input.authorization.session.createdAtMs
|
|
269
|
+
issuedAtMs: input.authorization.session.createdAtMs,
|
|
270
|
+
activation: input.activation
|
|
233
271
|
};
|
|
234
272
|
case "already_committed": return {
|
|
235
273
|
kind: "already_committed",
|
|
236
274
|
session: projectDirectRegistrationSession(input.authorization, input.tokens),
|
|
237
275
|
next: input.directIssue.next,
|
|
238
|
-
issuedAtMs: input.authorization.session.createdAtMs
|
|
276
|
+
issuedAtMs: input.authorization.session.createdAtMs,
|
|
277
|
+
activation: input.activation
|
|
239
278
|
};
|
|
240
279
|
default: return assertNeverDirectRegistrationIssue(input.directIssue);
|
|
241
280
|
}
|
|
@@ -248,15 +287,13 @@ async function assertDirectWalletSessionOwnerProof(input) {
|
|
|
248
287
|
if (input.proof.tenantId !== input.tenantId || input.proof.walletId !== input.authority.walletId || input.proof.principalId !== walletSessionPrincipalId(input.authority) || input.proof.authority.walletId !== authorityRef.walletId || input.proof.authority.authorityDigest !== authorityRef.authorityDigest || input.proof.authority.walletAuthMethodId !== authorityRef.walletAuthMethodId || input.activeAuthority.walletId !== input.authority.walletId || input.activeAuthority.state !== "active" || input.walletAuthMethodId !== authorityRef.walletAuthMethodId || input.proof.verifiedAtMs > input.nowMs || input.proof.expiresAtMs <= input.nowMs) throw new Error("Owner proof does not authorize direct Wallet Session issuance");
|
|
249
288
|
}
|
|
250
289
|
async function issueDirectRegistrationEstablishedEcdsaSession(input) {
|
|
251
|
-
const activeRegistration = await input.walletAuthMethods.readActiveRegistrationAuthority(input.registrationAuthority);
|
|
252
|
-
if (!activeRegistration || activeRegistration.authority.walletId !== input.authority.walletId || activeRegistration.walletAuthMethodId !== input.walletAuthMethodId) throw new Error("Registration founding authority is unavailable after commit");
|
|
253
290
|
const issuedAtMs = Date.now();
|
|
254
291
|
await assertDirectWalletSessionOwnerProof({
|
|
255
292
|
proof: input.proof,
|
|
256
293
|
tenantId: input.authorizationTenantId,
|
|
257
294
|
authority: input.authority,
|
|
258
|
-
activeAuthority:
|
|
259
|
-
walletAuthMethodId:
|
|
295
|
+
activeAuthority: input.foundingAuthority,
|
|
296
|
+
walletAuthMethodId: input.walletAuthMethodId,
|
|
260
297
|
nowMs: issuedAtMs
|
|
261
298
|
});
|
|
262
299
|
const policy = registrationSessionPolicy({
|
|
@@ -264,17 +301,21 @@ async function issueDirectRegistrationEstablishedEcdsaSession(input) {
|
|
|
264
301
|
expiresAtMs: input.expiresAtMs,
|
|
265
302
|
remainingUses: input.remainingUses
|
|
266
303
|
});
|
|
267
|
-
const
|
|
304
|
+
const committed = await input.authorizationService.commitDirectWalletSessionAuthorizationV2({
|
|
268
305
|
tenantId: input.authorizationTenantId,
|
|
269
306
|
principalId: walletSessionPrincipalId(input.authority),
|
|
270
307
|
walletId: walletIdFromString(String(input.authority.walletId)),
|
|
271
|
-
authority:
|
|
272
|
-
walletAuthMethodId:
|
|
308
|
+
authority: input.foundingAuthority,
|
|
309
|
+
walletAuthMethodId: input.walletAuthMethodId,
|
|
273
310
|
mintId: registrationEstablishedMintId(input.registrationCeremonyId),
|
|
274
311
|
remainingUses: policy.remainingUses,
|
|
275
312
|
issuedAtMs,
|
|
276
313
|
expiresAtMs: policy.expiresAtMs
|
|
314
|
+
}, { kind: "strict" }, {
|
|
315
|
+
kind: "registration",
|
|
316
|
+
ceremonyId: input.registrationCeremonyId
|
|
277
317
|
});
|
|
318
|
+
const directIssue = committed.result;
|
|
278
319
|
let authorization;
|
|
279
320
|
switch (directIssue.kind) {
|
|
280
321
|
case "issued":
|
|
@@ -305,29 +346,29 @@ async function issueDirectRegistrationEstablishedEcdsaSession(input) {
|
|
|
305
346
|
runtimePolicyScope: input.runtimePolicyScope,
|
|
306
347
|
keyHandle
|
|
307
348
|
});
|
|
349
|
+
const published = await publishCommittedRegistration(input.homeCompletion, committed);
|
|
350
|
+
if (!published.ok) throw new Error(published.message);
|
|
308
351
|
return directRegistrationResultFromIssue({
|
|
309
352
|
directIssue,
|
|
310
353
|
authorization,
|
|
311
|
-
tokens
|
|
354
|
+
tokens,
|
|
355
|
+
activation: published.activation
|
|
312
356
|
});
|
|
313
357
|
}
|
|
314
358
|
async function issueDirectRegistrationEstablishedEd25519Session(input) {
|
|
315
|
-
const activeRegistration = await input.walletAuthMethods.readActiveRegistrationAuthority(input.registrationAuthority);
|
|
316
|
-
if (!activeRegistration || activeRegistration.authority.walletId !== input.authority.walletId || activeRegistration.walletAuthMethodId !== input.walletAuthMethodId) throw new Error("Registration founding authority is unavailable after commit");
|
|
317
|
-
const issuedAtMs = Date.now();
|
|
318
|
-
await assertDirectWalletSessionOwnerProof({
|
|
319
|
-
proof: input.proof,
|
|
320
|
-
tenantId: input.authorizationTenantId,
|
|
321
|
-
authority: input.authority,
|
|
322
|
-
activeAuthority: activeRegistration.authority,
|
|
323
|
-
walletAuthMethodId: activeRegistration.walletAuthMethodId,
|
|
324
|
-
nowMs: issuedAtMs
|
|
325
|
-
});
|
|
326
359
|
if (input.predecessor.kind === "resumed_mixed") {
|
|
360
|
+
await assertDirectWalletSessionOwnerProof({
|
|
361
|
+
proof: input.proof,
|
|
362
|
+
tenantId: input.authorizationTenantId,
|
|
363
|
+
authority: input.authority,
|
|
364
|
+
activeAuthority: input.foundingAuthority,
|
|
365
|
+
walletAuthMethodId: input.walletAuthMethodId,
|
|
366
|
+
nowMs: Date.now()
|
|
367
|
+
});
|
|
327
368
|
const authorization = await input.authorizationService.refreshWalletSessionAuthorizationV2AuthorityProjection({
|
|
328
369
|
existing: input.predecessor.authorization,
|
|
329
|
-
authority:
|
|
330
|
-
walletAuthMethodId:
|
|
370
|
+
authority: input.foundingAuthority,
|
|
371
|
+
walletAuthMethodId: input.walletAuthMethodId
|
|
331
372
|
});
|
|
332
373
|
return {
|
|
333
374
|
kind: "already_committed",
|
|
@@ -339,25 +380,12 @@ async function issueDirectRegistrationEstablishedEd25519Session(input) {
|
|
|
339
380
|
predecessor: input.predecessor
|
|
340
381
|
})),
|
|
341
382
|
next: "unlock_exact_method",
|
|
342
|
-
issuedAtMs: authorization.session.createdAtMs
|
|
383
|
+
issuedAtMs: authorization.session.createdAtMs,
|
|
384
|
+
activation: null
|
|
343
385
|
};
|
|
344
386
|
}
|
|
345
|
-
const
|
|
346
|
-
|
|
347
|
-
expiresAtMs: input.expiresAtMs,
|
|
348
|
-
remainingUses: input.remainingUses
|
|
349
|
-
});
|
|
350
|
-
const directIssue = await input.authorizationService.issueDirectRegistrationPromotedWalletSessionAuthorizationV2({
|
|
351
|
-
tenantId: input.authorizationTenantId,
|
|
352
|
-
principalId: walletSessionPrincipalId(input.authority),
|
|
353
|
-
walletId: walletIdFromString(String(input.authority.walletId)),
|
|
354
|
-
authority: activeRegistration.authority,
|
|
355
|
-
walletAuthMethodId: activeRegistration.walletAuthMethodId,
|
|
356
|
-
mintId: registrationEstablishedMintId(input.registrationCeremonyId),
|
|
357
|
-
remainingUses: policy.remainingUses,
|
|
358
|
-
issuedAtMs,
|
|
359
|
-
expiresAtMs: policy.expiresAtMs
|
|
360
|
-
});
|
|
387
|
+
const committed = input.initialSession.kind === "committed" ? input.initialSession.value : await commitInitialEd25519RegistrationSession(input);
|
|
388
|
+
const directIssue = committed.result;
|
|
361
389
|
let authorization;
|
|
362
390
|
switch (directIssue.kind) {
|
|
363
391
|
case "issued":
|
|
@@ -375,8 +403,8 @@ async function issueDirectRegistrationEstablishedEd25519Session(input) {
|
|
|
375
403
|
});
|
|
376
404
|
authorization = await input.authorizationService.refreshWalletSessionAuthorizationV2AuthorityProjection({
|
|
377
405
|
existing,
|
|
378
|
-
authority:
|
|
379
|
-
walletAuthMethodId:
|
|
406
|
+
authority: input.foundingAuthority,
|
|
407
|
+
walletAuthMethodId: input.walletAuthMethodId
|
|
380
408
|
});
|
|
381
409
|
break;
|
|
382
410
|
}
|
|
@@ -389,10 +417,16 @@ async function issueDirectRegistrationEstablishedEd25519Session(input) {
|
|
|
389
417
|
}).ed25519,
|
|
390
418
|
predecessor: input.predecessor
|
|
391
419
|
});
|
|
420
|
+
const [publication, preparation] = await Promise.allSettled([publishCommittedRegistration(input.homeCompletion, committed), input.onSessionCommitted?.(projectDirectRegistrationSession(authorization, tokens))]);
|
|
421
|
+
if (publication.status === "rejected") throw publication.reason;
|
|
422
|
+
if (preparation.status === "rejected") throw preparation.reason;
|
|
423
|
+
const published = publication.value;
|
|
424
|
+
if (!published.ok) throw new Error(published.message);
|
|
392
425
|
return directRegistrationResultFromIssue({
|
|
393
426
|
directIssue,
|
|
394
427
|
authorization,
|
|
395
|
-
tokens
|
|
428
|
+
tokens,
|
|
429
|
+
activation: published.activation
|
|
396
430
|
});
|
|
397
431
|
}
|
|
398
432
|
function projectCurrentNearRegistrationSession(authorization, tokens) {
|
|
@@ -416,6 +450,6 @@ function replayDirectRegistrationEstablishedEd25519Session(receipt) {
|
|
|
416
450
|
};
|
|
417
451
|
}
|
|
418
452
|
//#endregion
|
|
419
|
-
export { assertDirectWalletSessionOwnerProof, buildRegistrationOwnerProof, issueDirectRegistrationEstablishedEcdsaSession, issueDirectRegistrationEstablishedEd25519Session, projectCurrentNearRegistrationSession, replayDirectRegistrationEstablishedEcdsaSession, replayDirectRegistrationEstablishedEd25519Session, walletSessionPrincipalId };
|
|
453
|
+
export { assertDirectWalletSessionOwnerProof, buildRegistrationOwnerProof, commitInitialEd25519RegistrationSession, issueDirectRegistrationEstablishedEcdsaSession, issueDirectRegistrationEstablishedEd25519Session, projectCurrentNearRegistrationSession, replayDirectRegistrationEstablishedEcdsaSession, replayDirectRegistrationEstablishedEd25519Session, walletSessionPrincipalId };
|
|
420
454
|
|
|
421
455
|
//# sourceMappingURL=walletRegistrationEstablishedSessionIssuer.js.map
|
package/dist/esm/router/cloudflare/d1/registration/walletRegistrationSessionCommitReceipt.js
CHANGED
|
@@ -9,6 +9,15 @@ import { hasExactKeys } from "../../../../shared-ts/src/utils/exactKeys.js";
|
|
|
9
9
|
import { parseWalletCustodyRegistrationOutcome } from "../../../../shared-ts/src/passkey-custody/ceremonyCommitPayload.js";
|
|
10
10
|
import "../../../../shared-ts/src/passkey-custody/index.js";
|
|
11
11
|
//#region src/router/cloudflare/d1/registration/walletRegistrationSessionCommitReceipt.ts
|
|
12
|
+
/** The home activation that a commit left for the record that completes its operation. */
|
|
13
|
+
function registrationCommitActivation(execution) {
|
|
14
|
+
switch (execution.kind) {
|
|
15
|
+
case "session_issued":
|
|
16
|
+
case "session_issued_with_installation_projection": return execution.activation;
|
|
17
|
+
case "unissued":
|
|
18
|
+
case "replayed": return null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
12
21
|
function unissuedRegistrationCommit(response) {
|
|
13
22
|
return {
|
|
14
23
|
kind: "unissued",
|
|
@@ -59,7 +68,7 @@ function projectWalletRegistrationSessionCommitReceiptV2(input) {
|
|
|
59
68
|
}
|
|
60
69
|
};
|
|
61
70
|
}
|
|
62
|
-
if (input.execution.kind === "unissued" || input.execution.kind === "replayed") throw new Error("Registration commit receipt requires an issued
|
|
71
|
+
if (input.execution.kind === "unissued" || input.execution.kind === "replayed") throw new Error("Registration commit receipt requires an issued response");
|
|
63
72
|
const expectedOrigin = input.execution.expectedOrigin;
|
|
64
73
|
const metadata = {
|
|
65
74
|
kind: "wallet_registration_session_commit_receipt_v2",
|
|
@@ -72,17 +81,6 @@ function projectWalletRegistrationSessionCommitReceiptV2(input) {
|
|
|
72
81
|
expectedOrigin,
|
|
73
82
|
..."registrationDiagnostics" in response && response.registrationDiagnostics ? { registrationDiagnostics: response.registrationDiagnostics } : {}
|
|
74
83
|
};
|
|
75
|
-
if (response.kind === "near_ed25519" && !("registrationEstablishedSession" in response)) {
|
|
76
|
-
if (input.execution.kind !== "near_pending") throw new Error("Pending registration commit receipt has an issued-session marker");
|
|
77
|
-
return {
|
|
78
|
-
...metadata,
|
|
79
|
-
walletAuthMethodId: response.authority.bindingId,
|
|
80
|
-
committed: {
|
|
81
|
-
kind: "near_pending",
|
|
82
|
-
nearProvisioning: { status: "near_pending" }
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
84
|
if (response.kind === "evm_family_ecdsa") {
|
|
87
85
|
if (!("registrationEstablishedSession" in response)) throw new Error("ECDSA registration commit receipt is missing its session");
|
|
88
86
|
if (input.execution.kind !== "session_issued" && input.execution.kind !== "session_issued_with_installation_projection") throw new Error("ECDSA registration commit receipt is missing its issue identity");
|
|
@@ -235,28 +233,6 @@ function parseWalletRegistrationSessionCommitReceiptV2(raw, parseCommitted) {
|
|
|
235
233
|
expectedOrigin,
|
|
236
234
|
...registrationDiagnostics ? { registrationDiagnostics } : {}
|
|
237
235
|
};
|
|
238
|
-
if (committedRecord.kind === "near_pending") {
|
|
239
|
-
if (operation !== "registration_activate" || !hasExactKeys(record, [
|
|
240
|
-
"kind",
|
|
241
|
-
"operation",
|
|
242
|
-
"operationFingerprint",
|
|
243
|
-
"registrationCeremonyId",
|
|
244
|
-
"walletId",
|
|
245
|
-
"walletAuthMethodId",
|
|
246
|
-
"authority",
|
|
247
|
-
"authMethod",
|
|
248
|
-
"expectedOrigin",
|
|
249
|
-
...registrationDiagnostics ? ["registrationDiagnostics"] : [],
|
|
250
|
-
"committed"
|
|
251
|
-
]) || !hasExactKeys(committedRecord, ["kind", "nearProvisioning"]) || committedRecord.nearProvisioning === null || typeof committedRecord.nearProvisioning !== "object" || Array.isArray(committedRecord.nearProvisioning) || !hasExactKeys(committedRecord.nearProvisioning, ["status"]) || committedRecord.nearProvisioning.status !== "near_pending") return null;
|
|
252
|
-
return {
|
|
253
|
-
...common,
|
|
254
|
-
committed: {
|
|
255
|
-
kind: "near_pending",
|
|
256
|
-
nearProvisioning: { status: "near_pending" }
|
|
257
|
-
}
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
236
|
if (committedRecord.kind !== "ecdsa_ready" && committedRecord.kind !== "near_ready") return null;
|
|
261
237
|
if (committedRecord.kind === "ecdsa_ready" && operation !== "registration_activate" || committedRecord.kind === "near_ready" && operation !== "near_provisioning") return null;
|
|
262
238
|
const foundingAuthority = parseWalletAuthorityV1(record.foundingAuthority);
|
|
@@ -478,6 +454,6 @@ function containsPersistedRegistrationCredential(value) {
|
|
|
478
454
|
return false;
|
|
479
455
|
}
|
|
480
456
|
//#endregion
|
|
481
|
-
export { parseWalletRegistrationSessionCommitReceiptV2, projectWalletRegistrationSessionCommitReceiptV2, registrationEstablishedMintId, registrationReplayAuthMethodFields, replayedRegistrationCommit, unissuedRegistrationCommit };
|
|
457
|
+
export { parseWalletRegistrationSessionCommitReceiptV2, projectWalletRegistrationSessionCommitReceiptV2, registrationCommitActivation, registrationEstablishedMintId, registrationReplayAuthMethodFields, replayedRegistrationCommit, unissuedRegistrationCommit };
|
|
482
458
|
|
|
483
459
|
//# sourceMappingURL=walletRegistrationSessionCommitReceipt.js.map
|