@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
|
@@ -5,12 +5,15 @@ import { buildCapabilityOperationEnvelope, computeCapabilityOperationFingerprint
|
|
|
5
5
|
import { routerAbMpcMaterialActivationRefFromWire, routerAbMpcMaterialActivationRefToWire, sameRouterAbMpcMaterialActivationRef } from "../../../../shared-ts/src/utils/routerAbNormalSigningIdentity.js";
|
|
6
6
|
import { buildActiveWalletSessionQuota, buildAuthorizedOperation, buildExactWalletSessionQuotaProjectionV1, computeAuthorizedOperationResultDigest, exactWalletSessionCapabilitySubjectsResolveAuthority, parseAuthorizedOperationReplayResponse, parseHostedWalletSessionCredentialId, parseSessionOrigin, parseWalletSessionAuthorizationV2, walletSessionAuthorizationV2RecordsEqual } from "../../../../authorization/domain.js";
|
|
7
7
|
import { ECDSA_INSTALLATION_SNAPSHOT_COLUMNS } from "../../../../core/ecdsaMaterialReadSnapshot.js";
|
|
8
|
-
import { d1ChangedRows, parseD1JsonColumn } from "../../../../storage/d1Sql.js";
|
|
8
|
+
import { D1_BATCH_CAS_GUARD_SQL, d1ChangedRows, parseD1JsonColumn } from "../../../../storage/d1Sql.js";
|
|
9
9
|
import { EcdsaMaterialRead } from "../../../../core/d1EcdsaSignerRead.js";
|
|
10
|
-
import { D1WalletStore } from "../../../../core/d1WalletStore.js";
|
|
10
|
+
import { D1WalletStore, ED25519_SIGNER_ACTIVATION_ID_PATH } from "../../../../core/d1WalletStore.js";
|
|
11
11
|
import { normalizeWalletAuthMethodV2 } from "../../../../core/d1WalletAuthMethodStore.js";
|
|
12
|
-
import { D1EcdsaAdmissionPolicyRead, ECDSA_CREDENTIAL_POLICY_PROJECTION } from "../signingAdmission/d1RouterAbNormalSigningAdmissionStore.js";
|
|
12
|
+
import { D1EcdsaAdmissionPolicyRead, D1Ed25519AdmissionPolicyRead, ECDSA_CREDENTIAL_POLICY_PROJECTION, ED25519_CREDENTIAL_POLICY_PROJECTION } from "../signingAdmission/d1RouterAbNormalSigningAdmissionStore.js";
|
|
13
13
|
import { parseInstalledEcdsaCustodySnapshotV1 } from "../deviceLinking/d1LinkedDeviceAuthorityInstallService.js";
|
|
14
|
+
import { D1RegistrationSessionTransaction } from "../registration/d1RegistrationSessionTransaction.js";
|
|
15
|
+
import { ROUTER_AB_ED25519_YAO_SHARED_STATE_RECORD_KEY_V1 } from "../../../domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistrationPartitionedStateStore.js";
|
|
16
|
+
import { Ed25519SignerRead } from "../../../../core/d1Ed25519SignerRead.js";
|
|
14
17
|
import { prepareAuthorizedOperationAdmissionRead, prepareAuthorizedOperationCommittedRead, prepareAuthorizedOperationInsert, prepareAuthorizedOperationRead } from "./authorizedOperationStatements.js";
|
|
15
18
|
import { prepareD1WalletSessionAuthorityProjectionStatements } from "./walletSessionAuthorityProjection.js";
|
|
16
19
|
import { parseD1WalletAuthorityRow } from "../wallet/d1WalletAuthorityStore.js";
|
|
@@ -604,6 +607,7 @@ var CloudflareD1AuthorizationStore = class {
|
|
|
604
607
|
}
|
|
605
608
|
async putVerifiedEvidenceSet(evidenceSet) {
|
|
606
609
|
if (d1ChangedRows(await this.database.prepare(`INSERT OR IGNORE INTO verified_wallet_operation_evidence_sets (
|
|
610
|
+
org_id, project_id, env_id,
|
|
607
611
|
namespace,
|
|
608
612
|
tenant_id,
|
|
609
613
|
evidence_set_id,
|
|
@@ -622,7 +626,7 @@ var CloudflareD1AuthorizationStore = class {
|
|
|
622
626
|
assurance,
|
|
623
627
|
verified_at_ms,
|
|
624
628
|
expires_at_ms
|
|
625
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).bind(this.namespace, evidenceSet.tenantId, evidenceSet.evidenceSetId, evidenceSet.principalId, evidenceSet.walletId, evidenceSet.authorityRef.authorityDigest, evidenceSet.requestOrigin, evidenceSet.audience, evidenceSet.evidenceSetDigest, JSON.stringify(evidenceSet.evidence), evidenceSet.operation.capabilityKind, evidenceSet.operation.operationKind, evidenceSet.laneDigest, evidenceSet.intentDigest, evidenceSet.displayDigest, evidenceSet.assurance, requirePositiveInteger(evidenceSet.verifiedAtMs, "evidenceSet.verifiedAtMs"), requirePositiveInteger(evidenceSet.expiresAtMs, "evidenceSet.expiresAtMs")).run()) > 1) throw new Error("verified wallet operation evidence set changed more than one row");
|
|
629
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).bind(this.walletSignerScope.orgId, this.walletSignerScope.projectId, this.walletSignerScope.envId, this.namespace, evidenceSet.tenantId, evidenceSet.evidenceSetId, evidenceSet.principalId, evidenceSet.walletId, evidenceSet.authorityRef.authorityDigest, evidenceSet.requestOrigin, evidenceSet.audience, evidenceSet.evidenceSetDigest, JSON.stringify(evidenceSet.evidence), evidenceSet.operation.capabilityKind, evidenceSet.operation.operationKind, evidenceSet.laneDigest, evidenceSet.intentDigest, evidenceSet.displayDigest, evidenceSet.assurance, requirePositiveInteger(evidenceSet.verifiedAtMs, "evidenceSet.verifiedAtMs"), requirePositiveInteger(evidenceSet.expiresAtMs, "evidenceSet.expiresAtMs")).run()) > 1) throw new Error("verified wallet operation evidence set changed more than one row");
|
|
626
630
|
}
|
|
627
631
|
async consumeVerifiedOwnerProof(proof, consumedAtMs, consumptionScopeId) {
|
|
628
632
|
const consumedAt = requirePositiveInteger(consumedAtMs, "owner proof consumedAtMs");
|
|
@@ -660,28 +664,40 @@ var CloudflareD1AuthorizationStore = class {
|
|
|
660
664
|
async commitDirectWalletSessionAuthorizationV2(input) {
|
|
661
665
|
return await this.commitDirectWalletSessionAuthorizationV2WithMode({
|
|
662
666
|
persisted: input.persisted,
|
|
663
|
-
mode: { kind: "strict" }
|
|
667
|
+
mode: { kind: "strict" },
|
|
668
|
+
purpose: { kind: "ordinary" }
|
|
664
669
|
});
|
|
665
670
|
}
|
|
671
|
+
async readWalletSessionIssuanceGeneration(walletId) {
|
|
672
|
+
const row = await this.prepareWalletSessionIssuanceGenerationRead(walletId).first();
|
|
673
|
+
if (!row) throw new Error("Wallet session issuance requires an open execution generation");
|
|
674
|
+
return requirePositiveInteger(row.generation, "Wallet Session ownership generation");
|
|
675
|
+
}
|
|
676
|
+
prepareWalletSessionIssuanceGenerationRead(walletId) {
|
|
677
|
+
return this.database.prepare(`SELECT generation, state FROM wallet_execution_generations
|
|
678
|
+
WHERE namespace = ? AND org_id = ? AND project_id = ? AND env_id = ?
|
|
679
|
+
AND wallet_id = ? AND state IN ('registering', 'active')`).bind(this.namespace, this.walletSignerScope.orgId, this.walletSignerScope.projectId, this.walletSignerScope.envId, walletId);
|
|
680
|
+
}
|
|
666
681
|
/** The service validates the committed winner against its caller-specific replay contract. */
|
|
667
682
|
async commitDirectReplayableWalletSessionAuthorizationV2(input) {
|
|
668
683
|
return await this.commitDirectWalletSessionAuthorizationV2WithMode({
|
|
669
684
|
persisted: input.persisted,
|
|
670
|
-
mode: { kind: "replayable" }
|
|
685
|
+
mode: { kind: "replayable" },
|
|
686
|
+
purpose: input.purpose
|
|
671
687
|
});
|
|
672
688
|
}
|
|
673
|
-
async
|
|
689
|
+
async commitRegistrationWalletSessionAuthorizationV2(commitWallet, input) {
|
|
690
|
+
if (input.purpose.kind !== "registration") throw new Error("A wallet registration transaction requires a registration session");
|
|
691
|
+
const transaction = new D1RegistrationSessionTransaction(this.database, commitWallet);
|
|
692
|
+
return this.commitDirectWalletSessionAuthorizationV2WithMode({
|
|
693
|
+
persisted: input.persisted,
|
|
694
|
+
purpose: input.purpose,
|
|
695
|
+
mode: { kind: "replayable" }
|
|
696
|
+
}, transaction.execute.bind(transaction));
|
|
697
|
+
}
|
|
698
|
+
async commitDirectWalletSessionAuthorizationV2WithMode(input, executeBatch) {
|
|
674
699
|
const { persisted, mode } = input;
|
|
675
700
|
requireExactPersistedActiveWalletSessionAuthorizationV2(persisted);
|
|
676
|
-
const statements = this.prepareDirectWalletSessionAuthorizationV2Statements(persisted);
|
|
677
|
-
const results = await this.database.batch(statements);
|
|
678
|
-
if (results.length !== 6) throw new Error("Direct V2 Wallet Session transaction returned incomplete results");
|
|
679
|
-
const quotaResult = results[4];
|
|
680
|
-
const sessionResult = results[5];
|
|
681
|
-
if (!quotaResult || !sessionResult) throw new Error("Direct V2 Wallet Session transaction returned incomplete results");
|
|
682
|
-
const quotaChanges = d1ChangedRows(quotaResult);
|
|
683
|
-
const sessionChanges = d1ChangedRows(sessionResult);
|
|
684
|
-
if (quotaChanges !== sessionChanges) throw new Error("Direct V2 Wallet Session transaction persisted an incomplete identity");
|
|
685
701
|
const lookup = {
|
|
686
702
|
tenantId: persisted.session.tenantId,
|
|
687
703
|
principalId: persisted.session.principalId,
|
|
@@ -690,13 +706,44 @@ var CloudflareD1AuthorizationStore = class {
|
|
|
690
706
|
walletAuthMethodId: persisted.session.walletAuthMethodId,
|
|
691
707
|
mintId: persisted.session.mintId
|
|
692
708
|
};
|
|
693
|
-
const
|
|
694
|
-
|
|
709
|
+
const completionStatements = this.prepareRegistrationSessionCompletion(input.purpose, lookup);
|
|
710
|
+
const statements = [
|
|
711
|
+
...this.prepareDirectWalletSessionAuthorizationV2Statements(persisted),
|
|
712
|
+
this.prepareWalletSessionAuthorizationV2ByMintRead(lookup),
|
|
713
|
+
this.prepareWalletSessionIssuanceGenerationRead(persisted.session.walletId),
|
|
714
|
+
...completionStatements
|
|
715
|
+
];
|
|
716
|
+
const results = executeBatch ? await executeBatch(statements) : await this.database.batch(statements);
|
|
717
|
+
if (results.length !== 8 + completionStatements.length) throw new Error("Direct V2 Wallet Session transaction returned incomplete results");
|
|
718
|
+
const quotaResult = results[4];
|
|
719
|
+
const sessionResult = results[5];
|
|
720
|
+
const committedResult = results[6];
|
|
721
|
+
if (!quotaResult || !sessionResult || !committedResult?.success) throw new Error("Direct V2 Wallet Session transaction returned incomplete results");
|
|
722
|
+
const quotaChanges = d1ChangedRows(quotaResult);
|
|
723
|
+
const sessionChanges = d1ChangedRows(sessionResult);
|
|
724
|
+
if (quotaChanges !== sessionChanges) throw new Error("Direct V2 Wallet Session transaction persisted an incomplete identity");
|
|
725
|
+
const committed = parseWalletSessionAuthorizationV2MintRow(committedResult.results?.[0] ?? null, lookup);
|
|
726
|
+
const generationResult = results[7];
|
|
727
|
+
const generation = generationResult?.results?.[0];
|
|
728
|
+
let registration = null;
|
|
729
|
+
if (input.purpose.kind === "registration") {
|
|
730
|
+
if (!generationResult?.success || generation?.state !== "registering" && generation?.state !== "active") throw new Error("Registration session commit requires an open execution generation");
|
|
731
|
+
registration = {
|
|
732
|
+
ceremonyId: input.purpose.ceremonyId,
|
|
733
|
+
walletId: lookup.walletId,
|
|
734
|
+
state: generation.state
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
if (!committed) {
|
|
738
|
+
if (!generationResult?.success || !generation) throw new Error("Wallet session issuance requires an open execution generation");
|
|
739
|
+
throw new Error("Direct V2 Wallet Session authorization commit was not readable");
|
|
740
|
+
}
|
|
695
741
|
if (sessionChanges === 0) switch (mode.kind) {
|
|
696
742
|
case "strict": break;
|
|
697
743
|
case "replayable": return {
|
|
698
744
|
kind: "already_committed",
|
|
699
|
-
committed
|
|
745
|
+
committed,
|
|
746
|
+
registration
|
|
700
747
|
};
|
|
701
748
|
default: return assertNeverDirectV2CommitMode(mode);
|
|
702
749
|
}
|
|
@@ -704,10 +751,33 @@ var CloudflareD1AuthorizationStore = class {
|
|
|
704
751
|
if (committed.primaryOperationCredentialDigestB64u !== persisted.primaryOperationCredentialDigestB64u) throw new Error("Direct V2 Wallet Session commit returned a different credential digest");
|
|
705
752
|
if (sessionChanges === 0) return {
|
|
706
753
|
kind: "already_committed",
|
|
707
|
-
committed
|
|
754
|
+
committed,
|
|
755
|
+
registration
|
|
708
756
|
};
|
|
709
757
|
if (sessionChanges !== 1) throw new Error("Direct V2 Wallet Session transaction changed more than one session");
|
|
710
|
-
|
|
758
|
+
if (!generationResult?.success || !generation) throw new Error("Wallet session issuance requires an open execution generation");
|
|
759
|
+
return {
|
|
760
|
+
kind: "inserted",
|
|
761
|
+
registration,
|
|
762
|
+
ownershipGeneration: requirePositiveInteger(generation.generation, "Wallet Session ownership generation")
|
|
763
|
+
};
|
|
764
|
+
}
|
|
765
|
+
prepareRegistrationSessionCompletion(purpose, session) {
|
|
766
|
+
switch (purpose.kind) {
|
|
767
|
+
case "ordinary": return [];
|
|
768
|
+
case "registration": return [this.database.prepare(`UPDATE wallet_execution_generations SET registration_completion = 'established'
|
|
769
|
+
WHERE namespace = ?1 AND org_id = ?2 AND project_id = ?3 AND env_id = ?4
|
|
770
|
+
AND wallet_id = ?5 AND origin = 'registration' AND origin_id = ?6
|
|
771
|
+
AND state IN ('registering', 'active')
|
|
772
|
+
AND registration_completion IN ('pending', 'established')
|
|
773
|
+
AND EXISTS (
|
|
774
|
+
SELECT 1 FROM wallet_session_authorizations_v2
|
|
775
|
+
WHERE namespace = ?1 AND org_id = ?2 AND project_id = ?3 AND env_id = ?4
|
|
776
|
+
AND wallet_id = ?5 AND tenant_id = ?7 AND principal_id = ?8
|
|
777
|
+
AND authority_id = ?9 AND wallet_auth_method_id = ?10 AND mint_id = ?11
|
|
778
|
+
)`).bind(this.namespace, this.walletSignerScope.orgId, this.walletSignerScope.projectId, this.walletSignerScope.envId, session.walletId, purpose.ceremonyId, session.tenantId, String(session.principalId), session.authorityId, session.walletAuthMethodId, session.mintId), this.database.prepare(D1_BATCH_CAS_GUARD_SQL)];
|
|
779
|
+
default: return assertNeverDirectWalletSessionCommitPurpose(purpose);
|
|
780
|
+
}
|
|
711
781
|
}
|
|
712
782
|
/**
|
|
713
783
|
* Builds the one batch used by direct issuance. Every predecessor mutation
|
|
@@ -768,8 +838,7 @@ var CloudflareD1AuthorizationStore = class {
|
|
|
768
838
|
expires_at_ms
|
|
769
839
|
)
|
|
770
840
|
SELECT ?, ?, ?, ?, ?, ?, 'active', ?
|
|
771
|
-
WHERE ${availabilitySql}
|
|
772
|
-
AND ${ACTIVE_V2_AUTHORITY_METHOD_EXISTS_SQL}`).bind(this.namespace, quota.tenantId, String(quota.quotaId), String(quota.walletSessionId), String(quota.principalId), requirePositiveInteger(quota.remainingUses, "Direct V2 quota.remainingUses"), requirePositiveInteger(quota.expiresAtMs, "Direct V2 quota.expiresAtMs"), ...availabilityBindings, ...activeV2AuthorityMethodBindings(this.walletSignerScope, session));
|
|
841
|
+
WHERE ${availabilitySql}`).bind(this.namespace, quota.tenantId, String(quota.quotaId), String(quota.walletSessionId), String(quota.principalId), requirePositiveInteger(quota.remainingUses, "Direct V2 quota.remainingUses"), requirePositiveInteger(quota.expiresAtMs, "Direct V2 quota.expiresAtMs"), ...availabilityBindings);
|
|
773
842
|
const sessionStatement = this.database.prepare(`INSERT OR IGNORE INTO wallet_session_authorizations_v2 (
|
|
774
843
|
namespace,
|
|
775
844
|
org_id,
|
|
@@ -795,7 +864,6 @@ var CloudflareD1AuthorizationStore = class {
|
|
|
795
864
|
)
|
|
796
865
|
SELECT ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, ?, ?
|
|
797
866
|
WHERE ${sessionIdentityAvailabilitySql}
|
|
798
|
-
AND ${ACTIVE_V2_AUTHORITY_METHOD_EXISTS_SQL}
|
|
799
867
|
AND EXISTS (
|
|
800
868
|
SELECT 1
|
|
801
869
|
FROM authorization_wallet_session_quotas AS quota
|
|
@@ -807,7 +875,7 @@ var CloudflareD1AuthorizationStore = class {
|
|
|
807
875
|
AND quota.remaining_uses = ?
|
|
808
876
|
AND quota.lifecycle_kind = 'active'
|
|
809
877
|
AND quota.expires_at_ms = ?
|
|
810
|
-
)`).bind(this.namespace, this.walletSignerScope.orgId, this.walletSignerScope.projectId, this.walletSignerScope.envId, session.tenantId, String(session.authorizationId), String(session.mintId), String(session.walletSessionId), String(session.quotaId), String(session.principalId), String(session.walletId), String(session.authorityId), String(session.walletAuthMethodId), String(session.authorityDigestB64u), session.authorityRevocationEpoch, capabilitySubjectsJson, requirePositiveInteger(session.createdAtMs, "Direct V2 session.createdAtMs"), requirePositiveInteger(session.expiresAtMs, "Direct V2 session.expiresAtMs"), recordJson, String(primaryOperationCredentialDigestB64u), ...sessionIdentityAvailabilityBindings,
|
|
878
|
+
)`).bind(this.namespace, this.walletSignerScope.orgId, this.walletSignerScope.projectId, this.walletSignerScope.envId, session.tenantId, String(session.authorizationId), String(session.mintId), String(session.walletSessionId), String(session.quotaId), String(session.principalId), String(session.walletId), String(session.authorityId), String(session.walletAuthMethodId), String(session.authorityDigestB64u), session.authorityRevocationEpoch, capabilitySubjectsJson, requirePositiveInteger(session.createdAtMs, "Direct V2 session.createdAtMs"), requirePositiveInteger(session.expiresAtMs, "Direct V2 session.expiresAtMs"), recordJson, String(primaryOperationCredentialDigestB64u), ...sessionIdentityAvailabilityBindings, this.namespace, quota.tenantId, String(quota.quotaId), String(quota.walletSessionId), String(quota.principalId), requirePositiveInteger(quota.remainingUses, "Direct V2 quota.remainingUses"), requirePositiveInteger(quota.expiresAtMs, "Direct V2 quota.expiresAtMs"));
|
|
811
879
|
const [deleteHostedExchanges, retireHostedCredentials] = this.prepareRetireHostedChildrenForParentSelection({
|
|
812
880
|
tenantId: session.tenantId,
|
|
813
881
|
nowMs: session.createdAtMs,
|
|
@@ -816,12 +884,14 @@ var CloudflareD1AuthorizationStore = class {
|
|
|
816
884
|
AND predecessor.authority_id = ?
|
|
817
885
|
AND predecessor.wallet_auth_method_id = ?
|
|
818
886
|
AND predecessor.mint_id != ?
|
|
819
|
-
AND predecessor.retired_at_ms IS NULL
|
|
887
|
+
AND predecessor.retired_at_ms IS NULL
|
|
888
|
+
AND ${availabilitySql}`,
|
|
820
889
|
parentSelectionBindings: [
|
|
821
890
|
session.walletId,
|
|
822
891
|
session.authorityId,
|
|
823
892
|
session.walletAuthMethodId,
|
|
824
|
-
session.mintId
|
|
893
|
+
session.mintId,
|
|
894
|
+
...availabilityBindings
|
|
825
895
|
]
|
|
826
896
|
});
|
|
827
897
|
return [
|
|
@@ -864,7 +934,10 @@ var CloudflareD1AuthorizationStore = class {
|
|
|
864
934
|
});
|
|
865
935
|
}
|
|
866
936
|
async readWalletSessionAuthorizationV2ByMint(input) {
|
|
867
|
-
|
|
937
|
+
return parseWalletSessionAuthorizationV2MintRow(await this.prepareWalletSessionAuthorizationV2ByMintRead(input).first(), input);
|
|
938
|
+
}
|
|
939
|
+
prepareWalletSessionAuthorizationV2ByMintRead(input) {
|
|
940
|
+
return this.database.prepare(`SELECT
|
|
868
941
|
record_json,
|
|
869
942
|
capability_subjects_json,
|
|
870
943
|
tenant_id,
|
|
@@ -893,46 +966,7 @@ var CloudflareD1AuthorizationStore = class {
|
|
|
893
966
|
AND authority_id = ?
|
|
894
967
|
AND wallet_auth_method_id = ?
|
|
895
968
|
AND mint_id = ?
|
|
896
|
-
LIMIT 1`).bind(this.namespace, this.walletSignerScope.orgId, this.walletSignerScope.projectId, this.walletSignerScope.envId, input.tenantId, String(input.principalId), String(input.walletId), String(input.authorityId), String(input.walletAuthMethodId), String(input.mintId))
|
|
897
|
-
if (!row) return null;
|
|
898
|
-
const session = parsePersistedWalletSessionAuthorizationV2(parseD1JsonColumn(row.record_json));
|
|
899
|
-
if (!walletSessionAuthorizationV2RowMatches({
|
|
900
|
-
session_tenant_id: row.tenant_id,
|
|
901
|
-
session_authorization_id: row.authorization_id,
|
|
902
|
-
session_mint_id: row.mint_id,
|
|
903
|
-
session_wallet_session_id: row.wallet_session_id,
|
|
904
|
-
session_quota_id: row.quota_id,
|
|
905
|
-
session_principal_id: row.principal_id,
|
|
906
|
-
session_wallet_id: row.wallet_id,
|
|
907
|
-
session_authority_id: row.authority_id,
|
|
908
|
-
session_wallet_auth_method_id: row.wallet_auth_method_id,
|
|
909
|
-
session_authority_digest_b64u: row.authority_digest_b64u,
|
|
910
|
-
session_authority_revocation_epoch: row.authority_revocation_epoch,
|
|
911
|
-
session_issued_at_ms: row.issued_at_ms,
|
|
912
|
-
session_expires_at_ms: row.expires_at_ms
|
|
913
|
-
}, session)) throw new Error("Stored V2 Wallet Session mint columns disagree with record");
|
|
914
|
-
if (!walletSessionAuthorizationV2RecordsEqual(parseWalletSessionAuthorizationV2WithSubjects({
|
|
915
|
-
session_tenant_id: row.tenant_id,
|
|
916
|
-
session_authorization_id: row.authorization_id,
|
|
917
|
-
session_mint_id: row.mint_id,
|
|
918
|
-
session_wallet_session_id: row.wallet_session_id,
|
|
919
|
-
session_quota_id: row.quota_id,
|
|
920
|
-
session_principal_id: row.principal_id,
|
|
921
|
-
session_wallet_id: row.wallet_id,
|
|
922
|
-
session_authority_id: row.authority_id,
|
|
923
|
-
session_wallet_auth_method_id: row.wallet_auth_method_id,
|
|
924
|
-
session_authority_digest_b64u: row.authority_digest_b64u,
|
|
925
|
-
session_authority_revocation_epoch: row.authority_revocation_epoch,
|
|
926
|
-
session_issued_at_ms: row.issued_at_ms,
|
|
927
|
-
session_expires_at_ms: row.expires_at_ms
|
|
928
|
-
}, parseD1JsonColumn(row.capability_subjects_json)), session)) throw new Error("Stored V2 Wallet Session mint subjects disagree with record");
|
|
929
|
-
if (session.tenantId !== input.tenantId || session.principalId !== input.principalId || session.walletId !== input.walletId || session.authorityId !== input.authorityId || session.walletAuthMethodId !== input.walletAuthMethodId || session.mintId !== input.mintId) throw new Error("Stored V2 Wallet Session mint identity does not match the request");
|
|
930
|
-
return {
|
|
931
|
-
kind: "committed",
|
|
932
|
-
session,
|
|
933
|
-
primaryOperationCredentialDigestB64u: parseDigestB64u(row.operation_credential_hash),
|
|
934
|
-
retiredAtMs: row.retired_at_ms === null || row.retired_at_ms === void 0 ? null : requirePositiveInteger(row.retired_at_ms, "V2 session.retiredAtMs")
|
|
935
|
-
};
|
|
969
|
+
LIMIT 1`).bind(this.namespace, this.walletSignerScope.orgId, this.walletSignerScope.projectId, this.walletSignerScope.envId, input.tenantId, String(input.principalId), String(input.walletId), String(input.authorityId), String(input.walletAuthMethodId), String(input.mintId));
|
|
936
970
|
}
|
|
937
971
|
async readLiveWalletSessionAuthorizationProjectionV2(input) {
|
|
938
972
|
const row = await this.readJoinedWalletSessionAuthorizationV2Row({
|
|
@@ -1000,7 +1034,7 @@ var CloudflareD1AuthorizationStore = class {
|
|
|
1000
1034
|
tenantId: input.tenantId,
|
|
1001
1035
|
lookupValue: input.tokenHash
|
|
1002
1036
|
});
|
|
1003
|
-
if (!row) return null;
|
|
1037
|
+
if (!row || row.session_retired_at_ms !== null) return null;
|
|
1004
1038
|
return parseWalletSessionAdmissionRow(row, input);
|
|
1005
1039
|
}
|
|
1006
1040
|
async readEcdsaWalletSessionAdmissionSnapshotByOperationCredential(input) {
|
|
@@ -1013,7 +1047,7 @@ var CloudflareD1AuthorizationStore = class {
|
|
|
1013
1047
|
tenantId: input.tenantId,
|
|
1014
1048
|
lookupValue: input.tokenHash
|
|
1015
1049
|
});
|
|
1016
|
-
if (!row) return null;
|
|
1050
|
+
if (!row || row.session_retired_at_ms !== null) return null;
|
|
1017
1051
|
const snapshot = await parseWalletSessionAdmissionRow(row, input);
|
|
1018
1052
|
const session = snapshot.kind === "active" ? snapshot.authorization.session : snapshot.session;
|
|
1019
1053
|
return {
|
|
@@ -1028,6 +1062,30 @@ var CloudflareD1AuthorizationStore = class {
|
|
|
1028
1062
|
policyRead: D1EcdsaAdmissionPolicyRead.fromRows(this.database, this.namespace, session.walletId, input.materialActivation.activation_id, parseD1JsonColumn(row.ecdsa_policy_records_json))
|
|
1029
1063
|
};
|
|
1030
1064
|
}
|
|
1065
|
+
/**
|
|
1066
|
+
* The session with the Ed25519 signer and the policy rows its admission
|
|
1067
|
+
* needs, in one statement. The signer and the policy are those of the
|
|
1068
|
+
* session's own wallet, whatever wallet the request names.
|
|
1069
|
+
*/
|
|
1070
|
+
async readEd25519WalletSessionAdmissionSnapshotByOperationCredential(input) {
|
|
1071
|
+
const row = await this.readJoinedWalletSessionAuthorizationV2Row({
|
|
1072
|
+
projection: {
|
|
1073
|
+
kind: "ed25519_material",
|
|
1074
|
+
materialActivation: input.materialActivation
|
|
1075
|
+
},
|
|
1076
|
+
lookupColumn: "operation_credential_hash",
|
|
1077
|
+
tenantId: input.tenantId,
|
|
1078
|
+
lookupValue: input.tokenHash
|
|
1079
|
+
});
|
|
1080
|
+
if (!row || row.session_retired_at_ms !== null) return null;
|
|
1081
|
+
const snapshot = await parseWalletSessionAdmissionRow(row, input);
|
|
1082
|
+
const session = snapshot.kind === "active" ? snapshot.authorization.session : snapshot.session;
|
|
1083
|
+
return {
|
|
1084
|
+
snapshot,
|
|
1085
|
+
signerRead: Ed25519SignerRead.fromRows(session.walletId, input.materialActivation, parseD1JsonColumn(row.ed25519_material_records_json), parseD1JsonColumn(row.ed25519_capability_partition_json)),
|
|
1086
|
+
policyRead: D1Ed25519AdmissionPolicyRead.fromRows(this.database, this.namespace, session.walletId, session.authorityId, parseD1JsonColumn(row.ed25519_policy_records_json))
|
|
1087
|
+
};
|
|
1088
|
+
}
|
|
1031
1089
|
async readWalletSessionExactOperationContextByCredential(input) {
|
|
1032
1090
|
const row = await this.readJoinedWalletSessionAuthorizationV2Row({
|
|
1033
1091
|
projection: { kind: "session" },
|
|
@@ -1052,6 +1110,7 @@ var CloudflareD1AuthorizationStore = class {
|
|
|
1052
1110
|
authMethod,
|
|
1053
1111
|
retiredAtMs: null,
|
|
1054
1112
|
ownerWalletScope: {
|
|
1113
|
+
ownershipGeneration: requirePositiveInteger(row.execution_generation, "session.ownershipGeneration"),
|
|
1055
1114
|
orgId: requireString(row.session_org_id, "session.ownerWalletScope.orgId"),
|
|
1056
1115
|
projectId: requireString(row.session_project_id, "session.ownerWalletScope.projectId"),
|
|
1057
1116
|
projectEnvironmentId: requireString(row.session_env_id, "session.ownerWalletScope.projectEnvironmentId"),
|
|
@@ -1241,6 +1300,37 @@ var CloudflareD1AuthorizationStore = class {
|
|
|
1241
1300
|
END AS ecdsa_source_signers_json,
|
|
1242
1301
|
${ECDSA_CREDENTIAL_POLICY_PROJECTION}`;
|
|
1243
1302
|
materialBindings = [input.projection.materialActivation.activation_id, input.projection.materialActivation.activation_id];
|
|
1303
|
+
} else if (input.projection.kind === "ed25519_material") {
|
|
1304
|
+
const signerScope = [
|
|
1305
|
+
this.walletSignerScope.namespace,
|
|
1306
|
+
this.walletSignerScope.orgId,
|
|
1307
|
+
this.walletSignerScope.projectId,
|
|
1308
|
+
this.walletSignerScope.envId
|
|
1309
|
+
];
|
|
1310
|
+
materialProjection = `
|
|
1311
|
+
(SELECT json_group_array(json_object('record_json', signer.record_json))
|
|
1312
|
+
FROM wallet_signers AS signer
|
|
1313
|
+
WHERE signer.namespace = ? AND signer.org_id = ?
|
|
1314
|
+
AND signer.project_id = ? AND signer.env_id = ?
|
|
1315
|
+
AND signer.wallet_id = session.wallet_id
|
|
1316
|
+
AND signer.signer_family = 'ed25519'
|
|
1317
|
+
AND CASE WHEN json_valid(signer.record_json) THEN
|
|
1318
|
+
json_extract(signer.record_json, '${ED25519_SIGNER_ACTIVATION_ID_PATH}') = ?
|
|
1319
|
+
ELSE 0 END
|
|
1320
|
+
) AS ed25519_material_records_json,
|
|
1321
|
+
(SELECT record_json FROM router_ab_yao_versioned_json_records
|
|
1322
|
+
WHERE namespace = ? AND org_id = ? AND project_id = ? AND env_id = ?
|
|
1323
|
+
AND record_key = ?
|
|
1324
|
+
) AS ed25519_capability_partition_json,
|
|
1325
|
+
${ED25519_CREDENTIAL_POLICY_PROJECTION}`;
|
|
1326
|
+
materialBindings = [
|
|
1327
|
+
...signerScope,
|
|
1328
|
+
input.projection.materialActivation.activation_id,
|
|
1329
|
+
...signerScope,
|
|
1330
|
+
`router-ab-yao:${ROUTER_AB_ED25519_YAO_SHARED_STATE_RECORD_KEY_V1}`,
|
|
1331
|
+
...signerScope,
|
|
1332
|
+
input.projection.materialActivation.activation_id
|
|
1333
|
+
];
|
|
1244
1334
|
} else if (input.projection.kind === "session_status") {
|
|
1245
1335
|
materialProjection = `
|
|
1246
1336
|
(SELECT json_group_array(json_object('record_json', signer.record_json))
|
|
@@ -1259,6 +1349,13 @@ var CloudflareD1AuthorizationStore = class {
|
|
|
1259
1349
|
}
|
|
1260
1350
|
return await this.database.prepare(`SELECT ${materialProjection}
|
|
1261
1351
|
authority.*,
|
|
1352
|
+
(SELECT execution.generation FROM wallet_execution_generations AS execution
|
|
1353
|
+
WHERE execution.namespace = session.namespace
|
|
1354
|
+
AND execution.org_id = session.org_id
|
|
1355
|
+
AND execution.project_id = session.project_id
|
|
1356
|
+
AND execution.env_id = session.env_id
|
|
1357
|
+
AND execution.wallet_id = session.wallet_id
|
|
1358
|
+
AND execution.state = 'active') AS execution_generation,
|
|
1262
1359
|
session.namespace AS session_namespace,
|
|
1263
1360
|
session.record_json AS session_record_json,
|
|
1264
1361
|
session.capability_subjects_json AS session_capability_subjects_json,
|
|
@@ -1356,8 +1453,9 @@ var CloudflareD1AuthorizationStore = class {
|
|
|
1356
1453
|
const row = await prepareAuthorizedOperationCommittedRead(this.database, this.namespace, operation).first();
|
|
1357
1454
|
if (!row || row.authorized_operation_id !== operation.authorizedOperationId || row.authorization_source_kind !== operation.authorization.kind) throw new Error("Pinned owner operation is not claimed");
|
|
1358
1455
|
if (operation.authorization.kind === "verified_step_up") {
|
|
1359
|
-
if (row.evidence_set_digest !== operation.authorization.evidenceSetDigest || row.pinned_owner_wallet_id !== walletId) throw new Error("Verified step-up operation is not claimed");
|
|
1456
|
+
if (row.evidence_set_digest !== operation.authorization.evidenceSetDigest || row.pinned_owner_wallet_id !== walletId || row.step_up_org_id !== this.walletSignerScope.orgId || row.step_up_project_id !== this.walletSignerScope.projectId || row.step_up_env_id !== this.walletSignerScope.envId) throw new Error("Verified step-up operation is not claimed");
|
|
1360
1457
|
return {
|
|
1458
|
+
ownershipGeneration: requirePositiveInteger(row.ownership_generation, "operation.ownershipGeneration"),
|
|
1361
1459
|
orgId: this.walletSignerScope.orgId,
|
|
1362
1460
|
projectId: this.walletSignerScope.projectId,
|
|
1363
1461
|
projectEnvironmentId: this.walletSignerScope.envId
|
|
@@ -1369,6 +1467,7 @@ var CloudflareD1AuthorizationStore = class {
|
|
|
1369
1467
|
pinnedWalletSessionOwnerScope(row, walletId) {
|
|
1370
1468
|
if (row.pinned_owner_wallet_id !== walletId) throw new Error("Pinned owner Wallet Session scope is unavailable");
|
|
1371
1469
|
return {
|
|
1470
|
+
ownershipGeneration: requirePositiveInteger(row.ownership_generation, "operation.ownershipGeneration"),
|
|
1372
1471
|
orgId: requireString(row.owner_scope_org_id, "operation.ownerScope.orgId"),
|
|
1373
1472
|
projectId: requireString(row.owner_scope_project_id, "operation.ownerScope.projectId"),
|
|
1374
1473
|
projectEnvironmentId: requireString(row.owner_scope_env_id, "operation.ownerScope.projectEnvironmentId")
|
|
@@ -1471,39 +1570,32 @@ var CloudflareD1AuthorizationStore = class {
|
|
|
1471
1570
|
materialSnapshot: input.material.readSnapshot
|
|
1472
1571
|
});
|
|
1473
1572
|
if (!existing) return { kind: "authorized_operation_missing" };
|
|
1474
|
-
|
|
1475
|
-
if (result.kind === "operation_in_progress") return {
|
|
1476
|
-
kind: result.kind,
|
|
1477
|
-
operation: result.operation,
|
|
1478
|
-
ownerScope: this.pinnedWalletSessionOwnerScope(result.row, input.material.walletId)
|
|
1479
|
-
};
|
|
1480
|
-
if (result.kind === "replayed") return {
|
|
1481
|
-
kind: result.kind,
|
|
1482
|
-
operation: result.operation
|
|
1483
|
-
};
|
|
1484
|
-
switch (result.kind) {
|
|
1485
|
-
case "authorization_grant_rejected":
|
|
1486
|
-
case "verified_step_up_rejected":
|
|
1487
|
-
case "wallet_session_quota_exhausted":
|
|
1488
|
-
case "material_mismatch": return result;
|
|
1489
|
-
default: throw new Error("Unexpected ECDSA operation resolution");
|
|
1490
|
-
}
|
|
1573
|
+
return this.pinExistingWalletSessionOperation(this.answerExistingAuthorizedOperation(existing, operation, input.material), input.material.walletId);
|
|
1491
1574
|
}
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1575
|
+
/**
|
|
1576
|
+
* The stored operation answers for itself: its own grant must still be
|
|
1577
|
+
* active, as when a finalize request admitted it again.
|
|
1578
|
+
*/
|
|
1579
|
+
async resolveEd25519WalletSessionOperation(input) {
|
|
1580
|
+
const existing = await this.readAuthorizedOperationForAdmission({
|
|
1581
|
+
tenantId: input.tenantId,
|
|
1582
|
+
operationFingerprintDigest: input.operationFingerprintDigest,
|
|
1583
|
+
nowMs: input.nowMs,
|
|
1584
|
+
materialSnapshot: null
|
|
1497
1585
|
});
|
|
1586
|
+
if (!existing) return { kind: "authorized_operation_missing" };
|
|
1587
|
+
if (existing.operation.authorization.kind !== "authorization_grant") return { kind: "authorization_grant_rejected" };
|
|
1588
|
+
return this.pinExistingWalletSessionOperation(this.answerExistingAuthorizedOperation(existing, existing.operation, void 0), input.walletId);
|
|
1589
|
+
}
|
|
1590
|
+
pinExistingWalletSessionOperation(result, walletId) {
|
|
1498
1591
|
switch (result.kind) {
|
|
1499
|
-
case "claimed":
|
|
1500
1592
|
case "operation_in_progress": return {
|
|
1501
1593
|
kind: result.kind,
|
|
1502
1594
|
operation: result.operation,
|
|
1503
|
-
ownerScope: this.pinnedWalletSessionOwnerScope(result.row,
|
|
1595
|
+
ownerScope: this.pinnedWalletSessionOwnerScope(result.row, walletId)
|
|
1504
1596
|
};
|
|
1505
1597
|
case "replayed": return {
|
|
1506
|
-
kind:
|
|
1598
|
+
kind: result.kind,
|
|
1507
1599
|
operation: result.operation
|
|
1508
1600
|
};
|
|
1509
1601
|
case "authorization_grant_rejected":
|
|
@@ -1512,10 +1604,33 @@ var CloudflareD1AuthorizationStore = class {
|
|
|
1512
1604
|
case "material_mismatch": return result;
|
|
1513
1605
|
default: {
|
|
1514
1606
|
const unexpected = result;
|
|
1515
|
-
throw new Error(`Unexpected
|
|
1607
|
+
throw new Error(`Unexpected Wallet Session resolution: ${unexpected}`);
|
|
1516
1608
|
}
|
|
1517
1609
|
}
|
|
1518
1610
|
}
|
|
1611
|
+
async admitEcdsaWalletSessionOperation(input) {
|
|
1612
|
+
return this.pinWalletSessionAdmission(await this.admitAuthorizedOperationRecord({
|
|
1613
|
+
operation: input.operation,
|
|
1614
|
+
material: input.material,
|
|
1615
|
+
materialSnapshot: input.material.readSnapshot
|
|
1616
|
+
}), input.material.walletId);
|
|
1617
|
+
}
|
|
1618
|
+
async admitEd25519WalletSessionOperation(input) {
|
|
1619
|
+
return this.pinWalletSessionAdmission(await this.admitAuthorizedOperationRecord({
|
|
1620
|
+
operation: input.operation,
|
|
1621
|
+
material: void 0,
|
|
1622
|
+
materialSnapshot: null
|
|
1623
|
+
}), input.walletId);
|
|
1624
|
+
}
|
|
1625
|
+
/** A live operation's owner scope comes from the row its own admission read back. */
|
|
1626
|
+
pinWalletSessionAdmission(result, walletId) {
|
|
1627
|
+
if (result.kind !== "claimed") return this.pinExistingWalletSessionOperation(result, walletId);
|
|
1628
|
+
return {
|
|
1629
|
+
kind: "claimed",
|
|
1630
|
+
operation: result.operation,
|
|
1631
|
+
ownerScope: this.pinnedWalletSessionOwnerScope(result.row, walletId)
|
|
1632
|
+
};
|
|
1633
|
+
}
|
|
1519
1634
|
async admitAuthorizedOperationRecord(input) {
|
|
1520
1635
|
const operation = await buildAuthorizedOperation(input.operation);
|
|
1521
1636
|
if (!authorizedOperationMaterialScopeMatches(operation, input.material, input.materialSnapshot)) return { kind: "material_mismatch" };
|
|
@@ -1557,6 +1672,7 @@ var CloudflareD1AuthorizationStore = class {
|
|
|
1557
1672
|
}
|
|
1558
1673
|
if (!committedRow) {
|
|
1559
1674
|
if (!claimed && input.material) return { kind: "material_mismatch" };
|
|
1675
|
+
if (!claimed && operation.authorization.kind === "verified_step_up") return { kind: "verified_step_up_rejected" };
|
|
1560
1676
|
throw new Error("authorized operation admission could not be read back");
|
|
1561
1677
|
}
|
|
1562
1678
|
const admitted = await parseAuthorizedOperationAdmissionRecord(committedRow);
|
|
@@ -1652,7 +1768,7 @@ function authorizedOperationReplayMismatch(input) {
|
|
|
1652
1768
|
const expectedGrantKind = input.incoming.authorization.authorizationGrantRef.kind;
|
|
1653
1769
|
if (input.existing.authorization_grant_kind !== expectedGrantKind) return { kind: "authorization_grant_rejected" };
|
|
1654
1770
|
if (input.existing.authorization_id !== input.incoming.authorization.authorizationGrantRef.authorizationId) return { kind: "authorization_grant_rejected" };
|
|
1655
|
-
} else if (input.existing.evidence_set_digest !== input.incoming.authorization.evidenceSetDigest) return { kind: "verified_step_up_rejected" };
|
|
1771
|
+
} else if (input.existing.evidence_set_digest !== input.incoming.authorization.evidenceSetDigest || input.existing.step_up_org_id !== input.scope.orgId || input.existing.step_up_project_id !== input.scope.projectId || input.existing.step_up_env_id !== input.scope.envId) return { kind: "verified_step_up_rejected" };
|
|
1656
1772
|
const existingQuotaKind = requireString(input.existing.quota_kind, "operation.quota.kind");
|
|
1657
1773
|
if (existingQuotaKind !== input.incoming.quota.kind) return authorizationSourceRejected(input.incoming.authorization);
|
|
1658
1774
|
if (existingQuotaKind === "consume_reusable_wallet_session" && input.existing.quota_id !== input.incoming.quota.quotaId) return { kind: "authorization_grant_rejected" };
|
|
@@ -1829,7 +1945,13 @@ function directV2IdentityAvailabilityBindings(namespace, scope, session) {
|
|
|
1829
1945
|
}
|
|
1830
1946
|
function directV2SessionIdentityAvailabilitySql() {
|
|
1831
1947
|
return `
|
|
1832
|
-
|
|
1948
|
+
${ACTIVE_V2_AUTHORITY_METHOD_EXISTS_SQL}
|
|
1949
|
+
AND EXISTS (
|
|
1950
|
+
SELECT 1 FROM wallet_execution_generations
|
|
1951
|
+
WHERE namespace = ? AND org_id = ? AND project_id = ? AND env_id = ?
|
|
1952
|
+
AND wallet_id = ? AND state IN ('registering', 'active')
|
|
1953
|
+
)
|
|
1954
|
+
AND NOT EXISTS (
|
|
1833
1955
|
SELECT 1
|
|
1834
1956
|
FROM wallet_session_authorizations_v2 AS existing
|
|
1835
1957
|
WHERE existing.namespace = ?
|
|
@@ -1847,6 +1969,12 @@ function directV2SessionIdentityAvailabilitySql() {
|
|
|
1847
1969
|
}
|
|
1848
1970
|
function directV2SessionIdentityAvailabilityBindings(namespace, scope, session) {
|
|
1849
1971
|
return [
|
|
1972
|
+
...activeV2AuthorityMethodBindings(scope, session),
|
|
1973
|
+
namespace,
|
|
1974
|
+
scope.orgId,
|
|
1975
|
+
scope.projectId,
|
|
1976
|
+
scope.envId,
|
|
1977
|
+
String(session.walletId),
|
|
1850
1978
|
namespace,
|
|
1851
1979
|
scope.orgId,
|
|
1852
1980
|
scope.projectId,
|
|
@@ -1858,6 +1986,34 @@ function directV2SessionIdentityAvailabilityBindings(namespace, scope, session)
|
|
|
1858
1986
|
String(session.quotaId)
|
|
1859
1987
|
];
|
|
1860
1988
|
}
|
|
1989
|
+
function parseWalletSessionAuthorizationV2MintRow(row, input) {
|
|
1990
|
+
if (!row) return null;
|
|
1991
|
+
const session = parsePersistedWalletSessionAuthorizationV2(parseD1JsonColumn(row.record_json));
|
|
1992
|
+
const sessionColumns = {
|
|
1993
|
+
session_tenant_id: row.tenant_id,
|
|
1994
|
+
session_authorization_id: row.authorization_id,
|
|
1995
|
+
session_mint_id: row.mint_id,
|
|
1996
|
+
session_wallet_session_id: row.wallet_session_id,
|
|
1997
|
+
session_quota_id: row.quota_id,
|
|
1998
|
+
session_principal_id: row.principal_id,
|
|
1999
|
+
session_wallet_id: row.wallet_id,
|
|
2000
|
+
session_authority_id: row.authority_id,
|
|
2001
|
+
session_wallet_auth_method_id: row.wallet_auth_method_id,
|
|
2002
|
+
session_authority_digest_b64u: row.authority_digest_b64u,
|
|
2003
|
+
session_authority_revocation_epoch: row.authority_revocation_epoch,
|
|
2004
|
+
session_issued_at_ms: row.issued_at_ms,
|
|
2005
|
+
session_expires_at_ms: row.expires_at_ms
|
|
2006
|
+
};
|
|
2007
|
+
if (!walletSessionAuthorizationV2RowMatches(sessionColumns, session)) throw new Error("Stored V2 Wallet Session mint columns disagree with record");
|
|
2008
|
+
if (!walletSessionAuthorizationV2RecordsEqual(parseWalletSessionAuthorizationV2WithSubjects(sessionColumns, parseD1JsonColumn(row.capability_subjects_json)), session)) throw new Error("Stored V2 Wallet Session mint subjects disagree with record");
|
|
2009
|
+
if (session.tenantId !== input.tenantId || session.principalId !== input.principalId || session.walletId !== input.walletId || session.authorityId !== input.authorityId || session.walletAuthMethodId !== input.walletAuthMethodId || session.mintId !== input.mintId) throw new Error("Stored V2 Wallet Session mint identity does not match the request");
|
|
2010
|
+
return {
|
|
2011
|
+
kind: "committed",
|
|
2012
|
+
session,
|
|
2013
|
+
primaryOperationCredentialDigestB64u: parseDigestB64u(row.operation_credential_hash),
|
|
2014
|
+
retiredAtMs: row.retired_at_ms === null || row.retired_at_ms === void 0 ? null : requirePositiveInteger(row.retired_at_ms, "V2 session.retiredAtMs")
|
|
2015
|
+
};
|
|
2016
|
+
}
|
|
1861
2017
|
function walletSessionAuthorizationV2RowMatches(row, session) {
|
|
1862
2018
|
return row.session_tenant_id === String(session.tenantId) && row.session_authorization_id === String(session.authorizationId) && row.session_mint_id === String(session.mintId) && row.session_wallet_session_id === String(session.walletSessionId) && row.session_quota_id === String(session.quotaId) && row.session_principal_id === String(session.principalId) && row.session_wallet_id === String(session.walletId) && row.session_authority_id === String(session.authorityId) && row.session_wallet_auth_method_id === String(session.walletAuthMethodId) && row.session_authority_digest_b64u === String(session.authorityDigestB64u) && integerColumn(row.session_authority_revocation_epoch, "session.authorityRevocationEpoch") === session.authorityRevocationEpoch && integerColumn(row.session_issued_at_ms, "session.createdAtMs") === session.createdAtMs && integerColumn(row.session_expires_at_ms, "session.expiresAtMs") === session.expiresAtMs;
|
|
1863
2019
|
}
|
|
@@ -1945,6 +2101,9 @@ function parseExactWalletSessionQuotaProjectionRow(row, session) {
|
|
|
1945
2101
|
function assertNeverDirectV2CommitMode(value) {
|
|
1946
2102
|
throw new Error(`Unsupported direct V2 Wallet Session commit mode: ${String(value)}`);
|
|
1947
2103
|
}
|
|
2104
|
+
function assertNeverDirectWalletSessionCommitPurpose(value) {
|
|
2105
|
+
throw new Error(`Unsupported Wallet Session commit purpose: ${String(value)}`);
|
|
2106
|
+
}
|
|
1948
2107
|
async function parseWalletSessionAdmissionRow(row, input) {
|
|
1949
2108
|
const session = parseLiveWalletSessionAuthorizationV2Row(row, {
|
|
1950
2109
|
operationCredentialHash: input.tokenHash,
|