@seams/wallet-server 0.8.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
|
@@ -12,6 +12,7 @@ const CORS_ALLOW_HEADERS = [
|
|
|
12
12
|
"Content-Type",
|
|
13
13
|
WALLET_MANAGEMENT_PROTOCOL_HEADER,
|
|
14
14
|
"Authorization",
|
|
15
|
+
"X-Seams-Wallet-Region",
|
|
15
16
|
"X-Seams-Benchmark-Diagnostics",
|
|
16
17
|
LINKED_DEVICE_REQUEST_PROOF_HEADER_V1,
|
|
17
18
|
ROUTER_AB_ED25519_YAO_RECOVERY_CHALLENGE_ID_HEADER_V1,
|
|
@@ -64,7 +65,7 @@ function withCors(headers, opts, request) {
|
|
|
64
65
|
headers.set("Access-Control-Allow-Methods", CORS_ALLOW_METHODS);
|
|
65
66
|
headers.set("Access-Control-Allow-Headers", CORS_ALLOW_HEADERS);
|
|
66
67
|
if (allowedOrigin && request?.method === "OPTIONS") headers.set("Access-Control-Max-Age", String(CORS_PREFLIGHT_MAX_AGE_SECONDS));
|
|
67
|
-
|
|
68
|
+
headers.set("Access-Control-Expose-Headers", "Server-Timing, X-Seams-Wallet-Region");
|
|
68
69
|
if (allowedOrigin && allowedOrigin !== "*") headers.set("Access-Control-Allow-Credentials", "true");
|
|
69
70
|
}
|
|
70
71
|
function toResponse(out) {
|
|
@@ -3,12 +3,12 @@ import { base64UrlEncode } from "../../../shared-ts/src/utils/base64.js";
|
|
|
3
3
|
import { routerAbMpcMaterialActivationRefToWire, sameRouterAbMpcMaterialActivationRef } from "../../../shared-ts/src/utils/routerAbNormalSigningIdentity.js";
|
|
4
4
|
import { routerAbEcdsaDerivationActiveStateId } from "../../../shared-ts/src/utils/routerAbEcdsaDerivation.js";
|
|
5
5
|
import { findRouteDefinitionForRequest } from "../../framework/routeDefinitions.js";
|
|
6
|
+
import { extractBearerCredential } from "../../auth/routerApiKeyAuth.js";
|
|
7
|
+
import { resolveWalletSessionOperationCredentialAdmissionFromContext } from "../../auth/commonRouterUtils.js";
|
|
6
8
|
import { getRouterApiRouteExtensionRoutes, getRouterApiRouteExtensionsForTransport } from "../../framework/routeExtensions.js";
|
|
7
9
|
import { coerceRouterLogger } from "../../framework/logger.js";
|
|
8
10
|
import { json, jsonFailure, withCors } from "../../framework/http.js";
|
|
9
11
|
import { handleHealth, handleReady } from "./routes/health.js";
|
|
10
|
-
import { extractBearerCredential } from "../../auth/routerApiKeyAuth.js";
|
|
11
|
-
import { resolveWalletSessionOperationCredentialAdmissionFromContext } from "../../auth/commonRouterUtils.js";
|
|
12
12
|
import { handleWalletRegistration } from "./routes/walletRegistration.js";
|
|
13
13
|
import { handlePasskeyCustody, handleWalletCustodyCredentialLabel, handleWalletCustodyCredentialsList, handleWalletCustodyEmailOtpChallenge, handleWalletCustodyEnvelopeOwnershipUpgrade, handleWalletRecoveryBackupAcknowledge, handleWalletRecoveryEmailOtpRelease, handleWalletRecoveryEmailOtpVerify, handleWalletRecoveryFinalize, handleWalletRecoveryGoogleEmailOtpFinalize, handleWalletRecoveryGoogleVerify, handleWalletRecoveryPrepare, handleWalletRecoveryRead, handleWalletRecoveryRotate, handleWalletRecoveryStatus } from "./routes/passkeyCustody.js";
|
|
14
14
|
import { handleThresholdEcdsa } from "./routes/thresholdEcdsa.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { json, jsonFailure, readJson } from "../../../framework/http.js";
|
|
2
1
|
import { extractBearerCredential } from "../../../auth/routerApiKeyAuth.js";
|
|
3
2
|
import { resolveThresholdRuntimePolicyScope } from "../../../auth/commonRouterUtils.js";
|
|
3
|
+
import { json, jsonFailure, readJson } from "../../../framework/http.js";
|
|
4
4
|
import { parseAuthIdentityMutationRequest, parseAuthProviderActionPath, parseGoogleLoginVerifyRequest, parsePasskeyLoginOptionsRequest, parsePasskeyLoginVerifyRequest } from "../../../auth/authRequestValidation.js";
|
|
5
5
|
//#region src/router/transport/fetch/routes/auth.ts
|
|
6
6
|
function assertNeverAuthProviderAction(route) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { parseLinkDeviceSessionId } from "../../../../shared-ts/src/utils/domainIds.js";
|
|
2
|
+
import { requireRecord } from "../../../../shared-ts/src/utils/validation.js";
|
|
2
3
|
import { base64UrlDecode, base64UrlEncode } from "../../../../shared-ts/src/utils/base64.js";
|
|
3
4
|
import { sha256Bytes } from "../../../../shared-ts/src/utils/digests.js";
|
|
4
5
|
import { parseDigestB64u } from "../../../../shared-ts/src/utils/canonicalPrimitives.js";
|
|
5
|
-
import { isLinkSessionTerminalFailureV1 } from "../../../../shared-ts/src/device-linking/contracts.js";
|
|
6
|
-
import { requireRecord } from "../../../../shared-ts/src/utils/validation.js";
|
|
7
6
|
import { parseActiveWalletSessionV1 } from "../../../../shared-ts/src/device-linking/activeWalletSession.js";
|
|
7
|
+
import { isLinkSessionTerminalFailureV1 } from "../../../../shared-ts/src/device-linking/contracts.js";
|
|
8
8
|
import { parseLinkedDeviceEd25519ExportRootRecipientV1, parseLinkedDeviceEd25519ExportRootSubmissionV1 } from "../../../../shared-ts/src/device-linking/ed25519ExportRoot.js";
|
|
9
9
|
import { parseRouterAbEd25519YaoRegistrationActivationExecuteRequestV1, sameRouterAbEd25519YaoActivationBindingV1 } from "../../../../shared-ts/src/utils/routerAbEd25519Yao.js";
|
|
10
10
|
import { parseLinkedDeviceEd25519SourcePreservingReservationV1, parseLinkedDeviceOrdinaryMaterialSourceContributionPreparationTupleV1 } from "../../../../shared-ts/src/device-linking/sourceContribution.js";
|
|
@@ -13,9 +13,9 @@ import { parseLocalAuthorityActivationFinalAckV1, parseLocalAuthorityInstallatio
|
|
|
13
13
|
import { LINKED_DEVICE_REQUEST_PROOF_HEADER_V1, computeLinkedDevicePublicKeyDigestV1 } from "../../../../shared-ts/src/device-linking/requestProof.js";
|
|
14
14
|
import { findRouteDefinitionById } from "../../../framework/routeDefinitions.js";
|
|
15
15
|
import { normalizeCorsOrigin } from "../../../../core/SessionService.js";
|
|
16
|
-
import { json, readJson } from "../../../framework/http.js";
|
|
17
16
|
import { extractBearerCredential, extractRouterApiEnvironmentId } from "../../../auth/routerApiKeyAuth.js";
|
|
18
17
|
import { resolvePublishableKeyApiCredentialAuth } from "../../../auth/routerApiCredentialAuth.js";
|
|
18
|
+
import { json, readJson } from "../../../framework/http.js";
|
|
19
19
|
import { authDeniedResponse, exportRootWriteResponse, invalidInputResponse, invalidStateResponse, methodNotAllowedResponse, notFoundResponse, notSupportedResponse, projectSession, sessionProjectionResponse, targetCredentialResultResponse } from "./deviceLinkingResponses.js";
|
|
20
20
|
import { linkedDeviceBootstrapFailure } from "../../../../core/deviceLinking/linkedDeviceBootstrap.js";
|
|
21
21
|
import { parseLinkedDeviceRequestProofV1 } from "../../../../core/deviceLinking/requestProof.js";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { parseProviderSubject } from "../../../../shared-ts/src/utils/domainIds.js";
|
|
2
|
-
import { sha256DigestB64u } from "../../../../shared-ts/src/utils/canonicalPrimitives.js";
|
|
3
2
|
import { buildDelegatedWalletAuthorityV1 } from "../../../../shared-ts/src/authorization/delegatedAuthority.js";
|
|
3
|
+
import { sha256DigestB64u } from "../../../../shared-ts/src/utils/canonicalPrimitives.js";
|
|
4
4
|
import { buildEmailOtpWalletAuthAuthority, buildPasskeyWalletAuthAuthority, walletAuthAuthorityRef } from "../../../../shared-ts/src/utils/walletAuthAuthority.js";
|
|
5
5
|
import { parseLinkedDeviceOwnerAuthorizationRequestV1 } from "../../../../shared-ts/src/device-linking/parsers.js";
|
|
6
6
|
import { buildWalletSessionCapabilitySubjectsV1, walletSessionCapabilitySubjectsV1Equal } from "../../../../authorization/domain.js";
|
|
7
|
-
import { json, jsonFailure, readJson } from "../../../framework/http.js";
|
|
8
7
|
import { extractBearerCredential } from "../../../auth/routerApiKeyAuth.js";
|
|
8
|
+
import { json, jsonFailure, readJson } from "../../../framework/http.js";
|
|
9
9
|
import { thresholdEd25519AuthorityScopeFromWalletAuthAuthority } from "../../../../core/ThresholdService/validation.js";
|
|
10
10
|
//#region src/router/transport/fetch/routes/deviceLinkingOwnerAuthorization.ts
|
|
11
11
|
const LINKED_DEVICE_OWNER_AUTHORIZATION_PATH_V1 = "/wallet/device-linking/v1/owner-authorization";
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { json } from "../../../framework/http.js";
|
|
2
|
+
//#region src/router/transport/fetch/routes/ed25519AuthorizedOperationRevalidation.ts
|
|
3
|
+
function rejected(code, message, status) {
|
|
4
|
+
return {
|
|
5
|
+
ok: false,
|
|
6
|
+
response: json({
|
|
7
|
+
ok: false,
|
|
8
|
+
code,
|
|
9
|
+
message
|
|
10
|
+
}, { status })
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function rejectedAdmission(kind) {
|
|
14
|
+
return kind === "authorization_grant_rejected" || kind === "verified_step_up_rejected" ? rejected(kind, "Ed25519 operation authorization is no longer active", 403) : rejected(kind, "Ed25519 operation admission failed", 409);
|
|
15
|
+
}
|
|
16
|
+
async function revalidateEd25519StepUpOperation(input) {
|
|
17
|
+
const stored = input.operation;
|
|
18
|
+
if (stored.authorization.kind !== "verified_step_up" || stored.quota.kind !== "quota_neutral") return rejected("verified_step_up_rejected", "Ed25519 operation step-up authorization has an invalid quota", 403);
|
|
19
|
+
const result = await input.ctx.service.authorizedOperations.admitAuthorizedOperation({ operation: {
|
|
20
|
+
tenantId: stored.tenantId,
|
|
21
|
+
authorizedOperationId: stored.authorizedOperationId,
|
|
22
|
+
auditEventId: stored.auditEventId,
|
|
23
|
+
operation: stored.operation,
|
|
24
|
+
authorization: stored.authorization,
|
|
25
|
+
quota: stored.quota,
|
|
26
|
+
claimedAtMs: Date.now()
|
|
27
|
+
} });
|
|
28
|
+
if (!("operation" in result)) return rejectedAdmission(result.kind);
|
|
29
|
+
if (result.operation.authorizedOperationId !== stored.authorizedOperationId) throw new Error("Ed25519 authorized operation changed during revalidation");
|
|
30
|
+
return {
|
|
31
|
+
ok: true,
|
|
32
|
+
operation: result.operation
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Finds the operation a reusable Wallet Session prepared and checks that its
|
|
37
|
+
* grant is still active. A live operation returns the owner scope its
|
|
38
|
+
* admission row pinned. A completed operation returns none: it replays its
|
|
39
|
+
* stored response. The operation is read by its fingerprint, so a receipt
|
|
40
|
+
* that names another operation ID has no stored operation.
|
|
41
|
+
*/
|
|
42
|
+
async function resolveEd25519WalletSessionOperation(input) {
|
|
43
|
+
const result = await input.ctx.service.authorizedOperations.resolveEd25519WalletSessionOperation({
|
|
44
|
+
tenantId: input.tenantId,
|
|
45
|
+
operationFingerprintDigest: input.operationFingerprintDigest,
|
|
46
|
+
walletId: input.walletId,
|
|
47
|
+
nowMs: Date.now()
|
|
48
|
+
});
|
|
49
|
+
if (result.kind === "authorized_operation_missing") return rejected("authorized_operation_missing", "Authorized operation is unavailable", 409);
|
|
50
|
+
if (!result.operation) return rejectedAdmission(result.kind);
|
|
51
|
+
const stored = result.operation;
|
|
52
|
+
if (stored.authorizedOperationId !== input.authorizedOperationId) return rejected("authorized_operation_missing", "Authorized operation is unavailable", 409);
|
|
53
|
+
if (stored.quota.kind !== "consume_reusable_wallet_session") return rejected("authorization_grant_rejected", "Ed25519 reusable operation authorization has an invalid quota", 403);
|
|
54
|
+
const operation = stored.operation.operation;
|
|
55
|
+
if (operation.capabilityKind !== "near_ed25519_mpc_signing" || operation.operationKind === "near.export_key") return rejected("authorization_grant_rejected", "Ed25519 reusable operation kind is invalid", 403);
|
|
56
|
+
return {
|
|
57
|
+
ok: true,
|
|
58
|
+
operation: stored,
|
|
59
|
+
ownerScope: result.ownerScope ?? null
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
export { resolveEd25519WalletSessionOperation, revalidateEd25519StepUpOperation };
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=ed25519AuthorizedOperationRevalidation.js.map
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { isPlainObject } from "../../../../shared-ts/src/utils/validation.js";
|
|
1
2
|
import { routerAbMpcMaterialActivationRefFromWire } from "../../../../shared-ts/src/utils/routerAbNormalSigningIdentity.js";
|
|
3
|
+
import { walletObjectIdentity, walletObjectIdentityHeaders } from "../../../cloudflare/runtime/walletObjectAddresses.js";
|
|
2
4
|
import { ROUTER_AB_INTERNAL_SERVICE_AUTH_HEADER_V1, normalizeRouterAbInternalServiceAuthSecret } from "../../../../core/ThresholdService/routerAb/internalServiceHttp.js";
|
|
3
|
-
import { json } from "../../../framework/http.js";
|
|
4
5
|
import { prepareOwnerWalletExecution } from "../../../domains/signingOperations/walletExecutionAdmission.js";
|
|
6
|
+
import { json } from "../../../framework/http.js";
|
|
5
7
|
//#region src/router/transport/fetch/routes/normalSigningRouterProxy.ts
|
|
6
8
|
async function proxyNormalSigningRequestToMpcRouter(input) {
|
|
7
9
|
const proxy = input.proxy;
|
|
@@ -12,6 +14,14 @@ async function proxyNormalSigningRequestToMpcRouter(input) {
|
|
|
12
14
|
}, { status: 501 });
|
|
13
15
|
try {
|
|
14
16
|
const headers = new Headers(input.request.headers);
|
|
17
|
+
const envelope = input.body?.authorized_operation;
|
|
18
|
+
if (!isPlainObject(envelope) || !isPlainObject(envelope.binding)) throw new Error("Signing requires an admitted wallet binding");
|
|
19
|
+
const identity = walletObjectIdentity(envelope.binding.account_id, envelope.binding.ownership_generation, {
|
|
20
|
+
orgId: envelope.binding.org_id,
|
|
21
|
+
projectId: envelope.binding.project_id,
|
|
22
|
+
envId: envelope.binding.project_environment_id
|
|
23
|
+
});
|
|
24
|
+
for (const [name, value] of Object.entries(walletObjectIdentityHeaders(identity))) headers.set(name, value);
|
|
15
25
|
if (input.body && parseNormalSigningSessionAdmission(input.body)) headers.delete("authorization");
|
|
16
26
|
headers.set(ROUTER_AB_INTERNAL_SERVICE_AUTH_HEADER_V1, normalizeRouterAbInternalServiceAuthSecret(proxy.internalServiceAuthSecret));
|
|
17
27
|
const request = input.targetPath ? new Request(new URL(input.targetPath, input.request.url), input.request) : input.request;
|
|
@@ -53,7 +63,7 @@ function isNormalSigningReusableBindingRecord(value) {
|
|
|
53
63
|
}
|
|
54
64
|
function isNormalSigningGatewayOwnerBindingRecord(value) {
|
|
55
65
|
if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
|
|
56
|
-
return Object.keys(value).sort().join("|") === "account_id|authorization_id|environment|expires_at_ms|kind|org_id|project_environment_id|project_id|quota_id|signing_worker_id|subject_id|threshold_session_id|wallet_session_id";
|
|
66
|
+
return Object.keys(value).sort().join("|") === "account_id|authorization_id|environment|expires_at_ms|kind|org_id|ownership_generation|project_environment_id|project_id|quota_id|signing_worker_id|subject_id|threshold_session_id|wallet_session_id";
|
|
57
67
|
}
|
|
58
68
|
function isNormalSigningReusableReceiptRecord(value) {
|
|
59
69
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -62,7 +72,7 @@ function isNormalSigningReusableBindingValues(record) {
|
|
|
62
72
|
return typeof record.authorization_id === "string" && record.authorization_id.trim().length > 0 && typeof record.wallet_session_id === "string" && record.wallet_session_id.trim().length > 0 && typeof record.quota_id === "string" && record.quota_id.trim().length > 0;
|
|
63
73
|
}
|
|
64
74
|
function isNormalSigningGatewayOwnerBindingValues(record) {
|
|
65
|
-
return typeof record.subject_id === "string" && record.subject_id.trim().length > 0 && typeof record.account_id === "string" && record.account_id.trim().length > 0 && typeof record.authorization_id === "string" && record.authorization_id.trim().length > 0 && typeof record.wallet_session_id === "string" && record.wallet_session_id.trim().length > 0 && typeof record.quota_id === "string" && record.quota_id.trim().length > 0 && typeof record.threshold_session_id === "string" && record.threshold_session_id.trim().length > 0 && typeof record.org_id === "string" && record.org_id.trim().length > 0 && typeof record.project_id === "string" && record.project_id.trim().length > 0 && typeof record.environment === "string" && record.environment.trim().length > 0 && typeof record.project_environment_id === "string" && record.project_environment_id.trim().length > 0 && typeof record.signing_worker_id === "string" && record.signing_worker_id.trim().length > 0 && typeof record.expires_at_ms === "number" && Number.isSafeInteger(record.expires_at_ms) && record.expires_at_ms > 0;
|
|
75
|
+
return record.kind === "gateway_owner_wallet_session" && typeof record.ownership_generation === "number" && Number.isSafeInteger(record.ownership_generation) && record.ownership_generation > 0 && typeof record.subject_id === "string" && record.subject_id.trim().length > 0 && typeof record.account_id === "string" && record.account_id.trim().length > 0 && typeof record.authorization_id === "string" && record.authorization_id.trim().length > 0 && typeof record.wallet_session_id === "string" && record.wallet_session_id.trim().length > 0 && typeof record.quota_id === "string" && record.quota_id.trim().length > 0 && typeof record.threshold_session_id === "string" && record.threshold_session_id.trim().length > 0 && typeof record.org_id === "string" && record.org_id.trim().length > 0 && typeof record.project_id === "string" && record.project_id.trim().length > 0 && typeof record.environment === "string" && record.environment.trim().length > 0 && typeof record.project_environment_id === "string" && record.project_environment_id.trim().length > 0 && typeof record.signing_worker_id === "string" && record.signing_worker_id.trim().length > 0 && typeof record.expires_at_ms === "number" && Number.isSafeInteger(record.expires_at_ms) && record.expires_at_ms > 0;
|
|
66
76
|
}
|
|
67
77
|
async function proxyOwnerLaneAdmittedNormalSigningRequest(input) {
|
|
68
78
|
const expectedMaterialActivation = routerAbMpcMaterialActivationRefFromWire(input.expectedMaterialActivation);
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { parseEmailOtpChallengeId, parseOrgId, parseProviderSubject, parseWalletAuthMethodId, parseWalletAuthorityId, parseWalletId, parseWalletRecoveryOperationId, parseWebAuthnCredentialIdB64u, parseWebAuthnRpId } from "../../../../shared-ts/src/utils/domainIds.js";
|
|
2
2
|
import { buildVaultOperationRef, parseAuthFactorId, parseAuthorizationAuditEventId, parseAuthorizationEvidenceId, parseAuthorizationEvidenceSetId, parseAuthorizedOperationId, parseCapabilityId, parseCapabilityOperationId, parseDeviceId, parsePrincipalId, parseTenantId } from "../../../../shared-ts/src/authorization/capabilityKinds.js";
|
|
3
|
+
import { normalizeOptionalTrimmedString } from "../../../../shared-ts/src/utils/normalize.js";
|
|
4
|
+
import { isPlainObject, requireTrimmedString } from "../../../../shared-ts/src/utils/validation.js";
|
|
3
5
|
import { base64UrlDecode } from "../../../../shared-ts/src/utils/base64.js";
|
|
4
6
|
import { alphabetizeStringify } from "../../../../shared-ts/src/utils/digests.js";
|
|
5
7
|
import { sha256Utf8DigestB64u } from "../../../../shared-ts/src/utils/canonicalPrimitives.js";
|
|
6
8
|
import { buildCapabilityOperationEnvelope, computeCapabilityOperationFingerprintDigest } from "../../../../shared-ts/src/authorization/operationFingerprint.js";
|
|
7
|
-
import { normalizeOptionalTrimmedString } from "../../../../shared-ts/src/utils/normalize.js";
|
|
8
|
-
import { isPlainObject, requireTrimmedString } from "../../../../shared-ts/src/utils/validation.js";
|
|
9
9
|
import { buildPasskeyWalletAuthAuthority, walletAuthAuthorityRef } from "../../../../shared-ts/src/utils/walletAuthAuthority.js";
|
|
10
10
|
import { parseSessionOrigin, parseVerifiedOwnerProofId } from "../../../../authorization/domain.js";
|
|
11
11
|
import { buildVerifiedWalletOperationEmailOtpFactorResult, buildVerifiedWalletOperationPasskeyFactorResult } from "../../../../authorization/factorEvidence.js";
|
|
12
12
|
import { findRouteDefinitionById, matchesRouteDefinitionRequest } from "../../../framework/routeDefinitions.js";
|
|
13
|
-
import { readJson } from "../../../framework/http.js";
|
|
14
13
|
import { extractBearerCredential, resolveSourceIpFromFetchHeaders } from "../../../auth/routerApiKeyAuth.js";
|
|
15
14
|
import { toFetchRouteResponse } from "../../../framework/routeResponses.js";
|
|
16
15
|
import { parsePasskeyCustodyEnvelopeRecord } from "../../../../shared-ts/src/passkey-custody/custodyEnvelope.js";
|
|
17
16
|
import "../../../../shared-ts/src/passkey-custody/index.js";
|
|
17
|
+
import { readJson } from "../../../framework/http.js";
|
|
18
18
|
import { isHostWithinRpId, originHostnameOrEmpty } from "../../../../core/authService/webauthnOidcHelpers.js";
|
|
19
19
|
import { parseRecoveryCodeReservationId } from "../../../../shared-ts/src/wallet-recovery/recoveryCodeReservation.js";
|
|
20
20
|
import { computeWalletCustodyAdminChallengeDigest } from "../../../../shared-ts/src/authorization/walletCustodyOperation.js";
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { parseOrgId, parseProviderSubject, parseWalletAuthMethodId, parseWalletId, parseWebAuthnCredentialIdB64u, parseWebAuthnRpId } from "../../../../shared-ts/src/utils/domainIds.js";
|
|
2
2
|
import { parseMpcWalletSigningQuotaId, parseWalletSessionId } from "../../../../shared-ts/src/authorization/capabilityKinds.js";
|
|
3
|
+
import { isPlainObject } from "../../../../shared-ts/src/utils/validation.js";
|
|
3
4
|
import { sha256HexUtf8 } from "../../../../shared-ts/src/utils/digests.js";
|
|
4
5
|
import { parseDigestB64u } from "../../../../shared-ts/src/utils/canonicalPrimitives.js";
|
|
5
6
|
import { base58Encode } from "../../../../shared-ts/src/utils/base58.js";
|
|
6
|
-
import { isPlainObject } from "../../../../shared-ts/src/utils/validation.js";
|
|
7
7
|
import { routerAbMpcMaterialActivationRefToWire, sameRouterAbMpcMaterialActivationRef } from "../../../../shared-ts/src/utils/routerAbNormalSigningIdentity.js";
|
|
8
8
|
import { normalizeRuntimePolicyScope } from "../../../../shared-ts/src/threshold/signingRootScope.js";
|
|
9
9
|
import { walletAuthAuthorityRef } from "../../../../shared-ts/src/utils/walletAuthAuthority.js";
|
|
10
10
|
import { parseRouterAbEcdsaCredentialFreeSessionActivationResponseV1, parseRouterAbEcdsaPostRegistrationSessionActivationPolicyV1, parseRouterAbEcdsaPostRegistrationSessionActivationResponseV1, sameRouterAbEcdsaDerivationPublicCapabilityV1, sameRouterAbEcdsaRegistrationActivationReceiptV1 } from "../../../../shared-ts/src/utils/routerAbEcdsaDerivation.js";
|
|
11
11
|
import { parseHostedWalletSeamsSessionExchangeCode, parseHostedWalletSeamsSessionExchangeNonce, parsePrimaryWalletSessionOperationCredentialToken, parseSessionOrigin, projectExactWalletSessionAuthorizationV1 } from "../../../../authorization/domain.js";
|
|
12
12
|
import { walletIdFromString } from "../../../../shared-ts/src/utils/registrationIds.js";
|
|
13
|
-
import { json, readJson } from "../../../framework/http.js";
|
|
14
13
|
import { extractBearerCredential, resolveSourceIpFromFetchHeaders } from "../../../auth/routerApiKeyAuth.js";
|
|
14
|
+
import { json, readJson } from "../../../framework/http.js";
|
|
15
15
|
import { routerApiEmailOtpRouteService } from "../../../framework/authServicePort.js";
|
|
16
16
|
import { emailOtpStatusCode, hashEmailOtpOperationBinding } from "../../../domains/emailOtp/emailOtpSessionRouteHelpers.js";
|
|
17
17
|
import { EMAIL_OTP_CHANNEL, WALLET_EMAIL_OTP_EXPORT_OPERATION } from "../../../../shared-ts/src/utils/emailOtpDomain.js";
|
|
@@ -266,6 +266,7 @@ async function handleHostedWalletSessionExchangeIssue(ctx) {
|
|
|
266
266
|
ok: true,
|
|
267
267
|
delivery: {
|
|
268
268
|
exchangeCode: delivery.exchangeCode,
|
|
269
|
+
home: delivery.home,
|
|
269
270
|
nonce: delivery.nonce,
|
|
270
271
|
appOrigin: delivery.appOrigin,
|
|
271
272
|
walletOrigin: delivery.walletOrigin,
|
|
@@ -7,17 +7,21 @@ import "../../../../shared-ts/src/utils/encoders.js";
|
|
|
7
7
|
import { routerAbMpcMaterialActivationRefToWire, sameRouterAbMpcMaterialActivationRef } from "../../../../shared-ts/src/utils/routerAbNormalSigningIdentity.js";
|
|
8
8
|
import { walletAuthAuthorityRef } from "../../../../shared-ts/src/utils/walletAuthAuthority.js";
|
|
9
9
|
import { ROUTER_AB_ECDSA_DERIVATION_EXPORT_PATH, ROUTER_AB_ECDSA_DERIVATION_NORMAL_SIGNING_STATE_KIND_V1, ROUTER_AB_ECDSA_DERIVATION_REFRESH_PATH, computeRouterAbEcdsaOperationStepUpChallengeB64u, parseRouterAbEcdsaDerivationActivationRefreshCommitRequestV1, parseRouterAbEcdsaDerivationEvmDigestSigningFinalizeRequestV1, parseRouterAbEcdsaDerivationEvmDigestSigningRequestV1, parseRouterAbEcdsaDerivationExplicitExportRequestV1, parseRouterAbEcdsaOperationStepUpAuthorizationRequestV1, parseRouterAbEcdsaPostRegistrationSessionActivationRequestV1, parseRouterAbEcdsaPrepareSourceV1, sameRouterAbEcdsaDerivationNormalSigningScopeV1, sameRouterAbEcdsaDerivationPublicCapabilityV1 } from "../../../../shared-ts/src/utils/routerAbEcdsaDerivation.js";
|
|
10
|
-
import { buildWalletSessionCapabilitySubjectsV1, projectActiveWalletSession } from "../../../../authorization/domain.js";
|
|
10
|
+
import { buildWalletSessionCapabilitySubjectsV1, projectActiveWalletSession, walletSessionAuthorizationV2RecordsEqual } from "../../../../authorization/domain.js";
|
|
11
11
|
import { walletIdFromString } from "../../../../shared-ts/src/utils/registrationIds.js";
|
|
12
12
|
import { WALLET_SESSION_FAILURE_CODES } from "../../../../shared-ts/src/utils/walletSessionFailure.js";
|
|
13
|
-
import { json, readJson } from "../../../framework/http.js";
|
|
14
13
|
import { extractBearerCredential } from "../../../auth/routerApiKeyAuth.js";
|
|
15
14
|
import { walletSessionFailure, walletSessionFailureStatus } from "../../../auth/walletSessionFailure.js";
|
|
15
|
+
import { resolveWalletSessionAuthorizationV2Admission } from "../../../domains/signingOperations/walletExecutionAdmission.js";
|
|
16
16
|
import { resolveWalletSessionOperationCredentialAdmission, validateEcdsaPreprocessingSession } from "../../../auth/commonRouterUtils.js";
|
|
17
|
+
import { json, readJson } from "../../../framework/http.js";
|
|
17
18
|
import { thresholdEcdsaStatusCode } from "../../../../threshold/statusCodes.js";
|
|
18
|
-
import {
|
|
19
|
+
import { signingPrepareSessionResponse } from "../../../domains/signingOperations/signingPrepareSession.js";
|
|
19
20
|
import { authenticateRouterAbWalletOperationStepUpIdentity } from "../../../domains/signingOperations/routerAbOperationStepUp.js";
|
|
20
|
-
import { admitRouterAbEcdsaReusableWalletSessionOperation, authenticateRouterAbEcdsaOperationStepUp, authorizeRouterAbEcdsaDerivationNormalSigningRoute, buildRouterAbEcdsaOwnerOperationStepUpPreparation, claimRouterAbEcdsaOperationStepUp,
|
|
21
|
+
import { admitRouterAbEcdsaReusableWalletSessionOperation, authenticateRouterAbEcdsaOperationStepUp, authorizeRouterAbEcdsaDerivationNormalSigningRoute, buildRouterAbEcdsaOwnerOperationStepUpPreparation, claimRouterAbEcdsaOperationStepUp, decideRouterAbEcdsaOwnerOperationAuthorization, resolveFreshRouterAbEcdsaMaterialActivation, routerAbEcdsaAtomicAuthorizationConfigured, routerAbEcdsaOperationInProgressResult, routerAbEcdsaOwnerOperationFailureResult, routerAbEcdsaReplayHttpResponse, routerAbEcdsaReplayUnavailableResult } from "../../../domains/signingOperations/routerAbEcdsaDerivationNormalSigningRoute.js";
|
|
22
|
+
import { finishRouterAbEcdsaSigningResponse } from "../../../domains/signingOperations/ecdsaSigningResponse.js";
|
|
23
|
+
import { buildAuthorizedOperationWire } from "../../../domains/signingOperations/authorizedOperationWire.js";
|
|
24
|
+
import { parseEcdsaServerTiming } from "../../../../shared-ts/src/utils/ecdsaServerTiming.js";
|
|
21
25
|
import { parseRouterAbEcdsaDerivationPoolFillInitRouteRequest, parseRouterAbEcdsaDerivationPoolFillStepRouteRequest } from "../../../domains/ecdsa/thresholdEcdsaRequestValidation.js";
|
|
22
26
|
import { verifyEcdsaOperationStepUpFactor } from "./ecdsaOperationStepUpFactor.js";
|
|
23
27
|
import { resolveWalletAuthMethodIdForAuthority } from "../../../../core/signingLanes/WalletExecutionLaneProjection.js";
|
|
@@ -49,6 +53,7 @@ async function ecdsaOperationStepUpBinding(ctx, session, operation) {
|
|
|
49
53
|
const pinned = await readPinnedEcdsaStepUpWalletScope(ctx, session, operation);
|
|
50
54
|
return {
|
|
51
55
|
kind: "operation_step_up",
|
|
56
|
+
ownershipGeneration: pinned.ownershipGeneration,
|
|
52
57
|
authorizationSessionId: session.sessionId,
|
|
53
58
|
orgId: scope.orgId,
|
|
54
59
|
projectId: scope.projectId,
|
|
@@ -68,7 +73,10 @@ async function readPinnedEcdsaStepUpWalletScope(ctx, session, operation) {
|
|
|
68
73
|
const scope = session.runtimePolicyScope;
|
|
69
74
|
if (pinned.orgId !== scope.orgId || pinned.projectId !== scope.projectId) throw new Error("Step-up wallet scope differs from the Wallet Session scope");
|
|
70
75
|
return {
|
|
71
|
-
|
|
76
|
+
orgId: pinned.orgId,
|
|
77
|
+
projectId: pinned.projectId,
|
|
78
|
+
projectEnvironmentId: pinned.projectEnvironmentId,
|
|
79
|
+
ownershipGeneration: pinned.ownershipGeneration,
|
|
72
80
|
walletId: session.walletId
|
|
73
81
|
};
|
|
74
82
|
}
|
|
@@ -76,7 +84,7 @@ function buildRouterAbEcdsaAuthorizedOperationWire(input) {
|
|
|
76
84
|
const operation = input.operation;
|
|
77
85
|
const operationRef = operation.operation.operation;
|
|
78
86
|
if (operationRef.capabilityKind !== "evm_ecdsa_mpc_signing" || operationRef.operationKind !== "evm.sign_transaction") throw new Error("ECDSA authorized operation capability or operation kind is invalid");
|
|
79
|
-
|
|
87
|
+
return buildAuthorizedOperationWire(input, {
|
|
80
88
|
authorized_operation_id: operation.authorizedOperationId,
|
|
81
89
|
operation_id: operation.operation.operationId,
|
|
82
90
|
capability_kind: "evm_ecdsa_mpc_signing",
|
|
@@ -85,66 +93,7 @@ function buildRouterAbEcdsaAuthorizedOperationWire(input) {
|
|
|
85
93
|
intent_digest_b64u: operation.operation.digests.intentDigest,
|
|
86
94
|
display_digest_b64u: operation.operation.digests.displayDigest,
|
|
87
95
|
operation_fingerprint_digest: operation.operationFingerprintDigest
|
|
88
|
-
};
|
|
89
|
-
switch (input.binding.kind) {
|
|
90
|
-
case "reusable_wallet_session":
|
|
91
|
-
if (operation.authorization.kind !== "authorization_grant" || operation.quota.kind !== "consume_reusable_wallet_session") throw new Error("Reusable Wallet Session authorized operation is invalid");
|
|
92
|
-
return {
|
|
93
|
-
binding: {
|
|
94
|
-
kind: "reusable_wallet_session",
|
|
95
|
-
authorization_id: operation.authorization.authorizationGrantRef.authorizationId,
|
|
96
|
-
wallet_session_id: input.binding.walletSessionId,
|
|
97
|
-
quota_id: input.binding.quotaId
|
|
98
|
-
},
|
|
99
|
-
authorized_operation: {
|
|
100
|
-
kind: "reusable_wallet_session_authorized_operation_v1",
|
|
101
|
-
...commonAuthorizedOperation
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
case "gateway_owner_wallet_session":
|
|
105
|
-
if (operation.authorization.kind !== "authorization_grant" || operation.quota.kind !== "consume_reusable_wallet_session") throw new Error("Gateway owner Wallet Session authorized operation is invalid");
|
|
106
|
-
return {
|
|
107
|
-
binding: {
|
|
108
|
-
kind: "gateway_owner_wallet_session",
|
|
109
|
-
subject_id: input.binding.subjectId,
|
|
110
|
-
account_id: input.binding.accountId,
|
|
111
|
-
authorization_id: input.binding.authorizationId,
|
|
112
|
-
wallet_session_id: input.binding.walletSessionId,
|
|
113
|
-
quota_id: input.binding.quotaId,
|
|
114
|
-
threshold_session_id: input.binding.thresholdSessionId,
|
|
115
|
-
org_id: input.binding.orgId,
|
|
116
|
-
project_id: input.binding.projectId,
|
|
117
|
-
environment: input.binding.environment,
|
|
118
|
-
project_environment_id: input.binding.projectEnvironmentId,
|
|
119
|
-
signing_worker_id: input.binding.signingWorkerId,
|
|
120
|
-
expires_at_ms: input.binding.expiresAtMs
|
|
121
|
-
},
|
|
122
|
-
authorized_operation: {
|
|
123
|
-
kind: "reusable_wallet_session_authorized_operation_v1",
|
|
124
|
-
...commonAuthorizedOperation
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
case "operation_step_up":
|
|
128
|
-
if (operation.authorization.kind !== "verified_step_up" || operation.quota.kind !== "quota_neutral") throw new Error("Verified step-up authorized operation is invalid");
|
|
129
|
-
return {
|
|
130
|
-
binding: {
|
|
131
|
-
kind: "operation_step_up",
|
|
132
|
-
authorization_session_id: input.binding.authorizationSessionId,
|
|
133
|
-
org_id: input.binding.orgId,
|
|
134
|
-
project_id: input.binding.projectId,
|
|
135
|
-
environment: input.binding.environment,
|
|
136
|
-
project_environment_id: input.binding.projectEnvironmentId,
|
|
137
|
-
subject_id: input.binding.subjectId,
|
|
138
|
-
account_id: input.binding.accountId
|
|
139
|
-
},
|
|
140
|
-
authorized_operation: {
|
|
141
|
-
kind: "verified_step_up_authorized_operation_v1",
|
|
142
|
-
authorization_session_id: input.binding.authorizationSessionId,
|
|
143
|
-
evidence_set_digest: operation.authorization.evidenceSetDigest,
|
|
144
|
-
...commonAuthorizedOperation
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
}
|
|
96
|
+
});
|
|
148
97
|
}
|
|
149
98
|
function decideRouterAbEcdsaOperationStepUpExecution(input) {
|
|
150
99
|
if (input.admissionKind === "replayed") return {
|
|
@@ -299,6 +248,7 @@ async function executeRouterAbEcdsaDerivationNormalSigningRoute(input, timing) {
|
|
|
299
248
|
operation: authorizedOperation,
|
|
300
249
|
binding: {
|
|
301
250
|
kind: "gateway_owner_wallet_session",
|
|
251
|
+
ownershipGeneration: pinnedOwnerScope.ownershipGeneration,
|
|
302
252
|
subjectId: String(session.principalId),
|
|
303
253
|
accountId: String(session.walletId),
|
|
304
254
|
authorizationId: String(session.authorizationId),
|
|
@@ -345,8 +295,18 @@ async function executeRouterAbEcdsaDerivationNormalSigningRoute(input, timing) {
|
|
|
345
295
|
walletRegistration: input.ctx.service.walletRegistration,
|
|
346
296
|
body: admittedBody
|
|
347
297
|
});
|
|
298
|
+
if (input.phase === "prepare" && upstream.ok) {
|
|
299
|
+
const body = signingPrepareSessionResponse(await upstream.json(), authorization);
|
|
300
|
+
timing.proxy = performance.now() - proxyStartedAt;
|
|
301
|
+
const headers = new Headers(upstream.headers);
|
|
302
|
+
headers.delete("content-length");
|
|
303
|
+
headers.delete("content-encoding");
|
|
304
|
+
return new Response(JSON.stringify(body), {
|
|
305
|
+
status: upstream.status,
|
|
306
|
+
headers
|
|
307
|
+
});
|
|
308
|
+
}
|
|
348
309
|
return finishRouterAbEcdsaSigningResponse({
|
|
349
|
-
phase: input.phase,
|
|
350
310
|
upstream,
|
|
351
311
|
operation: authorizedOperation,
|
|
352
312
|
authorizedOperations: input.ctx.service.authorizedOperations,
|
|
@@ -354,35 +314,6 @@ async function executeRouterAbEcdsaDerivationNormalSigningRoute(input, timing) {
|
|
|
354
314
|
proxyStartedAt
|
|
355
315
|
});
|
|
356
316
|
}
|
|
357
|
-
async function finishRouterAbEcdsaSigningResponse(input) {
|
|
358
|
-
const upstream = input.upstream;
|
|
359
|
-
if (input.phase === "prepare" && upstream.ok) {
|
|
360
|
-
input.timing.proxy = performance.now() - input.proxyStartedAt;
|
|
361
|
-
return upstream;
|
|
362
|
-
}
|
|
363
|
-
const upstreamBodyText = await upstream.clone().text().catch(() => "");
|
|
364
|
-
input.timing.proxy = performance.now() - input.proxyStartedAt;
|
|
365
|
-
if (isRouterAbEcdsaOperationInProgressResponse({
|
|
366
|
-
status: upstream.status,
|
|
367
|
-
bodyText: upstreamBodyText
|
|
368
|
-
})) return upstream;
|
|
369
|
-
const completionStartedAt = performance.now();
|
|
370
|
-
await completeRouterAbEcdsaOperation({
|
|
371
|
-
authorizedOperations: input.authorizedOperations,
|
|
372
|
-
operation: input.operation,
|
|
373
|
-
result: upstream.ok ? "succeeded" : upstream.status < 500 ? "failed_before_side_effect" : "failed_after_side_effect",
|
|
374
|
-
response: {
|
|
375
|
-
status: upstream.status,
|
|
376
|
-
contentType: upstream.headers.get("content-type") || "application/json",
|
|
377
|
-
bodyText: upstreamBodyText
|
|
378
|
-
}
|
|
379
|
-
});
|
|
380
|
-
input.timing.complete = performance.now() - completionStartedAt;
|
|
381
|
-
return upstream;
|
|
382
|
-
}
|
|
383
|
-
function isRouterAbEcdsaOperationInProgressResponse(input) {
|
|
384
|
-
return input.status === 409 && input.bodyText.includes("ReplayedLocalRequest:") && input.bodyText.includes("SigningWorker ECDSA effect is already in progress");
|
|
385
|
-
}
|
|
386
317
|
function routerAbEcdsaReplayResponse(operation) {
|
|
387
318
|
const response = routerAbEcdsaReplayHttpResponse(operation);
|
|
388
319
|
if (response) return response;
|
|
@@ -392,31 +323,40 @@ function routerAbEcdsaReplayResponse(operation) {
|
|
|
392
323
|
async function resolveV2EcdsaOperationStepUpAdmission(input) {
|
|
393
324
|
const token = extractBearerCredential(input.ctx.request.headers);
|
|
394
325
|
if (!token) return { kind: "not_found" };
|
|
395
|
-
let
|
|
326
|
+
let context;
|
|
396
327
|
try {
|
|
397
|
-
|
|
398
|
-
|
|
328
|
+
context = await input.ctx.service.authorizationSessions.readWalletSessionExactOperationContextByCredential({
|
|
329
|
+
tenantId: input.ctx.service.authorizationSessions.tenantId,
|
|
399
330
|
token,
|
|
400
|
-
nowMs: Date.now()
|
|
401
|
-
operation: {
|
|
402
|
-
keyFamily: "ecdsa_secp256k1",
|
|
403
|
-
operationKind: input.operation.operation_kind
|
|
404
|
-
}
|
|
331
|
+
nowMs: Date.now()
|
|
405
332
|
});
|
|
406
333
|
} catch {
|
|
407
334
|
return { kind: "unavailable" };
|
|
408
335
|
}
|
|
409
|
-
if (
|
|
410
|
-
if (resolution.kind === "rejected") return {
|
|
336
|
+
if (!context) return {
|
|
411
337
|
kind: "rejected",
|
|
412
|
-
message: "ECDSA operation step-up Wallet Session
|
|
338
|
+
message: "ECDSA operation step-up Wallet Session is unavailable"
|
|
413
339
|
};
|
|
414
|
-
|
|
340
|
+
const session = context.session;
|
|
341
|
+
const admission = resolveWalletSessionAuthorizationV2Admission({
|
|
342
|
+
authorization: session,
|
|
343
|
+
authority: context.authority,
|
|
344
|
+
authMethod: context.authMethod,
|
|
345
|
+
retiredAtMs: context.retiredAtMs,
|
|
346
|
+
nowMs: Date.now(),
|
|
347
|
+
operation: {
|
|
348
|
+
tenantId: session.tenantId,
|
|
349
|
+
principalId: session.principalId,
|
|
350
|
+
walletId: session.walletId,
|
|
351
|
+
keyFamily: "ecdsa_secp256k1",
|
|
352
|
+
operationKind: input.operation.operation_kind
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
if (!admission.ok || admission.keyFamily !== "ecdsa_secp256k1") return {
|
|
415
356
|
kind: "rejected",
|
|
416
|
-
message: "ECDSA operation step-up Wallet Session
|
|
357
|
+
message: "ECDSA operation step-up Wallet Session authorization is invalid"
|
|
417
358
|
};
|
|
418
|
-
const
|
|
419
|
-
const admittedSigner = resolution.admission.admission.signer;
|
|
359
|
+
const admittedSigner = admission.signer;
|
|
420
360
|
if (input.operation.wallet_id !== String(session.walletId) || input.operation.material_activation.material_owner !== String(session.walletId) || input.operation.expires_at_ms > session.expiresAtMs || input.operation.expires_at_ms <= Date.now()) return {
|
|
421
361
|
kind: "rejected",
|
|
422
362
|
message: "ECDSA operation step-up Wallet Session scope is invalid"
|
|
@@ -432,13 +372,13 @@ async function resolveV2EcdsaOperationStepUpAdmission(input) {
|
|
|
432
372
|
kind: "rejected",
|
|
433
373
|
message: "ECDSA operation step-up material is not uniquely active"
|
|
434
374
|
};
|
|
435
|
-
if (input.operation.signing_worker_id !== input.operation.normal_signing_scope.signing_worker.server_id || !sameRouterAbMpcMaterialActivationRef(input.operation.material_activation, input.operation.normal_signing_scope.material_activation) || !sameRouterAbMpcMaterialActivationRef(input.operation.material_activation, routerAbMpcMaterialActivationRefToWire(
|
|
375
|
+
if (input.operation.signing_worker_id !== input.operation.normal_signing_scope.signing_worker.server_id || !sameRouterAbMpcMaterialActivationRef(input.operation.material_activation, input.operation.normal_signing_scope.material_activation) || !sameRouterAbMpcMaterialActivationRef(input.operation.material_activation, routerAbMpcMaterialActivationRefToWire(admission.materialActivation))) return {
|
|
436
376
|
kind: "rejected",
|
|
437
377
|
message: "ECDSA operation step-up material activation is invalid"
|
|
438
378
|
};
|
|
439
379
|
const activeMaterial = {
|
|
440
380
|
ok: true,
|
|
441
|
-
materialActivation: routerAbMpcMaterialActivationRefToWire(
|
|
381
|
+
materialActivation: routerAbMpcMaterialActivationRefToWire(admission.materialActivation),
|
|
442
382
|
keyHandle: signer.walletKey.keyHandle,
|
|
443
383
|
relayerKeyId: signer.walletKey.relayerKeyId,
|
|
444
384
|
participantIds: signer.walletKey.participantIds,
|
|
@@ -447,13 +387,13 @@ async function resolveV2EcdsaOperationStepUpAdmission(input) {
|
|
|
447
387
|
if (input.operation.operation_kind === "evm.sign_transaction") return {
|
|
448
388
|
kind: "admitted",
|
|
449
389
|
operationKind: "evm.sign_transaction",
|
|
450
|
-
|
|
390
|
+
context,
|
|
451
391
|
activeMaterial
|
|
452
392
|
};
|
|
453
393
|
return {
|
|
454
394
|
kind: "admitted",
|
|
455
395
|
operationKind: "evm.export_key",
|
|
456
|
-
|
|
396
|
+
context,
|
|
457
397
|
activeMaterial,
|
|
458
398
|
exportTopology: {
|
|
459
399
|
signer_set: signer.walletKey.publicCapability.signer_set,
|
|
@@ -513,8 +453,8 @@ async function issueEcdsaOperationStepUpAuthorization(input) {
|
|
|
513
453
|
let v2AuthorityRef;
|
|
514
454
|
if (v2Resolution.kind === "admitted") {
|
|
515
455
|
v2AuthorityRef = await walletAuthAuthorityRef({ authority });
|
|
516
|
-
const session = v2Resolution.
|
|
517
|
-
const context = v2Resolution.
|
|
456
|
+
const session = v2Resolution.context.session;
|
|
457
|
+
const context = v2Resolution.context;
|
|
518
458
|
if (authority.walletId !== String(session.walletId) || authority.bindingId !== context.authMethod.walletAuthMethodId || context.authMethod.walletAuthorityId !== context.authority.authorityId) return json({
|
|
519
459
|
ok: false,
|
|
520
460
|
code: "scope_mismatch",
|
|
@@ -542,10 +482,10 @@ async function issueEcdsaOperationStepUpAuthorization(input) {
|
|
|
542
482
|
ok: true,
|
|
543
483
|
authorizedOperations: proofAuthenticated.authorizedOperations,
|
|
544
484
|
session: {
|
|
545
|
-
tenantId: v2Resolution.
|
|
546
|
-
principalId: v2Resolution.
|
|
547
|
-
sessionId: String(v2Resolution.
|
|
548
|
-
walletId: String(v2Resolution.
|
|
485
|
+
tenantId: v2Resolution.context.session.tenantId,
|
|
486
|
+
principalId: v2Resolution.context.session.principalId,
|
|
487
|
+
sessionId: String(v2Resolution.context.session.authorizationId),
|
|
488
|
+
walletId: String(v2Resolution.context.session.walletId),
|
|
549
489
|
runtimePolicyScope: activeMaterial.runtimePolicyScope,
|
|
550
490
|
laneAuthorization: {
|
|
551
491
|
kind: "authority_ref",
|
|
@@ -591,7 +531,7 @@ async function issueEcdsaOperationStepUpAuthorization(input) {
|
|
|
591
531
|
code: "wallet_session_unavailable",
|
|
592
532
|
message: "Wallet Session authorization is unavailable"
|
|
593
533
|
}, { status: 503 });
|
|
594
|
-
if (refreshedV2Resolution.kind !== "admitted" || !
|
|
534
|
+
if (refreshedV2Resolution.kind !== "admitted" || !walletSessionAuthorizationV2RecordsEqual(v2Resolution.context.session, refreshedV2Resolution.context.session)) return json({
|
|
595
535
|
ok: false,
|
|
596
536
|
code: "scope_mismatch",
|
|
597
537
|
message: "ECDSA operation step-up Wallet Session authorization changed"
|
|
@@ -867,6 +807,7 @@ async function authorizeEcdsaPoolFillOperationStepUp(input) {
|
|
|
867
807
|
materialExpiresAtMs: input.operation.expires_at_ms
|
|
868
808
|
},
|
|
869
809
|
ownerWalletScope,
|
|
810
|
+
ownershipGeneration: ownerWalletScope.ownershipGeneration,
|
|
870
811
|
routerAbEcdsaDerivationNormalSigning: {
|
|
871
812
|
kind: ROUTER_AB_ECDSA_DERIVATION_NORMAL_SIGNING_STATE_KIND_V1,
|
|
872
813
|
scope: input.operation.normal_signing_scope
|
|
@@ -946,6 +887,7 @@ async function authorizeEcdsaPoolFill(input) {
|
|
|
946
887
|
thresholdExpiresAtMs: session.expiresAtMs,
|
|
947
888
|
authorization: { kind: "wallet_session" },
|
|
948
889
|
ownerWalletScope: validated.ownerWalletScope,
|
|
890
|
+
ownershipGeneration: validated.ownerWalletScope.ownershipGeneration,
|
|
949
891
|
routerAbEcdsaDerivationNormalSigning: normalSigning
|
|
950
892
|
}
|
|
951
893
|
};
|
|
@@ -1314,11 +1256,6 @@ async function admitStrictEcdsaExportOperationStepUp(input) {
|
|
|
1314
1256
|
case "wallet_session_quota_exhausted": return strictEcdsaExportFailure(409, result.kind, "Operation step-up authorization is invalid");
|
|
1315
1257
|
}
|
|
1316
1258
|
}
|
|
1317
|
-
function sameWalletSessionOperationCredentialAdmission(left, right) {
|
|
1318
|
-
const leftSession = left.context.authorization.session;
|
|
1319
|
-
const rightSession = right.context.authorization.session;
|
|
1320
|
-
return leftSession.tenantId === rightSession.tenantId && leftSession.principalId === rightSession.principalId && leftSession.walletId === rightSession.walletId && leftSession.authorityId === rightSession.authorityId && leftSession.walletAuthMethodId === rightSession.walletAuthMethodId && leftSession.authorityDigestB64u === rightSession.authorityDigestB64u && leftSession.authorityRevocationEpoch === rightSession.authorityRevocationEpoch && leftSession.authorizationId === rightSession.authorizationId && leftSession.walletSessionId === rightSession.walletSessionId && leftSession.quotaId === rightSession.quotaId && leftSession.expiresAtMs === rightSession.expiresAtMs && left.context.authority.authorityId === right.context.authority.authorityId && left.context.authority.authorityDigestB64u === right.context.authority.authorityDigestB64u && left.context.authMethod.walletAuthMethodId === right.context.authMethod.walletAuthMethodId && left.context.authMethod.walletAuthorityId === right.context.authMethod.walletAuthorityId && left.context.retiredAtMs === right.context.retiredAtMs && sameRouterAbMpcMaterialActivationRef(routerAbMpcMaterialActivationRefToWire(left.admission.materialActivation), routerAbMpcMaterialActivationRefToWire(right.admission.materialActivation));
|
|
1321
|
-
}
|
|
1322
1259
|
async function authorizeStrictEcdsaV2ExportOperationStepUp(input) {
|
|
1323
1260
|
const operation = input.request.operation;
|
|
1324
1261
|
if (!operation) return strictEcdsaExportFailure(400, "invalid_body", "Operation step-up export requires operation preparation");
|
|
@@ -1328,8 +1265,8 @@ async function authorizeStrictEcdsaV2ExportOperationStepUp(input) {
|
|
|
1328
1265
|
});
|
|
1329
1266
|
if (resolution.kind === "unavailable") return strictEcdsaExportFailure(503, "wallet_session_unavailable", "Wallet Session authorization is unavailable");
|
|
1330
1267
|
if (resolution.kind !== "admitted") return strictEcdsaExportFailure(403, "scope_mismatch", "ECDSA export operation step-up Wallet Session authorization is invalid");
|
|
1331
|
-
if (!
|
|
1332
|
-
const session = resolution.
|
|
1268
|
+
if (!walletSessionAuthorizationV2RecordsEqual(input.authorization.v2Admission.context.authorization.session, resolution.context.session)) return strictEcdsaExportFailure(403, "scope_mismatch", "ECDSA export operation step-up Wallet Session changed");
|
|
1269
|
+
const session = resolution.context.session;
|
|
1333
1270
|
const activeMaterial = resolution.activeMaterial;
|
|
1334
1271
|
if (input.request.authorization.kind !== "operation_step_up" || operation.operation_kind !== "evm.export_key" || operation.wallet_id !== String(session.walletId) || operation.wallet_id !== input.request.lifecycle.account_id || operation.material_activation.material_owner !== String(session.walletId) || operation.material_activation.signing_worker !== input.request.lifecycle.selected_server_id || operation.signing_worker_id !== input.request.lifecycle.selected_server_id || !sameRouterAbMpcMaterialActivationRef(operation.material_activation, input.request.material_activation) || operation.expires_at_ms < input.request.expires_at_ms || !strictEcdsaExportScopeMatchesRequest({
|
|
1335
1272
|
request: input.request,
|
|
@@ -1680,6 +1617,6 @@ async function handleThresholdEcdsa(ctx) {
|
|
|
1680
1617
|
return null;
|
|
1681
1618
|
}
|
|
1682
1619
|
//#endregion
|
|
1683
|
-
export { authorizeEcdsaPoolFill,
|
|
1620
|
+
export { authorizeEcdsaPoolFill, handleStrictEcdsaSessionActivation, handleThresholdEcdsa };
|
|
1684
1621
|
|
|
1685
1622
|
//# sourceMappingURL=thresholdEcdsa.js.map
|