@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
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { parseEmailOtpChallengeId, parseOrgId, parseProviderSubject, parseWalletId, parseWebAuthnCredentialIdB64u } from "../../../../shared-ts/src/utils/domainIds.js";
|
|
2
|
-
import { buildAuthorizationGrantRef,
|
|
2
|
+
import { buildAuthorizationGrantRef, parseAuthFactorId, parseAuthorizationAuditEventId, parseAuthorizationEvidenceId, parseAuthorizationEvidenceSetId, parseAuthorizedOperationId, parseCapabilityId, parseCapabilityOperationId, parsePrincipalId } from "../../../../shared-ts/src/authorization/capabilityKinds.js";
|
|
3
|
+
import { isPlainObject } from "../../../../shared-ts/src/utils/validation.js";
|
|
3
4
|
import { base64UrlEncode } from "../../../../shared-ts/src/utils/base64.js";
|
|
4
5
|
import { alphabetizeStringify, sha256BytesUtf8 } from "../../../../shared-ts/src/utils/digests.js";
|
|
5
6
|
import { parseDigestB64u } from "../../../../shared-ts/src/utils/canonicalPrimitives.js";
|
|
6
7
|
import { buildCapabilityOperationEnvelope, computeCapabilityOperationFingerprintDigest, parseCapabilityOperationFingerprintDigest, parseSigningOperationFingerprintDigest } from "../../../../shared-ts/src/authorization/operationFingerprint.js";
|
|
7
8
|
import "../../../../shared-ts/src/utils/encoders.js";
|
|
8
|
-
import { isPlainObject } from "../../../../shared-ts/src/utils/validation.js";
|
|
9
9
|
import { sameRouterAbMpcMaterialActivationRef } from "../../../../shared-ts/src/utils/routerAbNormalSigningIdentity.js";
|
|
10
10
|
import { isPasskeyWalletAuthAuthority, walletAuthAuthorityRef } from "../../../../shared-ts/src/utils/walletAuthAuthority.js";
|
|
11
11
|
import { authorizedOperationReplayBodyInit, parseSessionOrigin, parseVerifiedOwnerProofId } from "../../../../authorization/domain.js";
|
|
@@ -13,15 +13,18 @@ import { buildVerifiedWalletOperationEmailOtpFactorResult, buildVerifiedWalletOp
|
|
|
13
13
|
import { ROUTER_AB_ED25519_NORMAL_SIGNING_PATH, ROUTER_AB_ED25519_NORMAL_SIGNING_PREPARE_PATH, ROUTER_AB_ED25519_WALLET_SESSION_PATH } from "../../../../shared-ts/src/utils/signingSessionSeal.js";
|
|
14
14
|
import { normalizeCorsOrigin } from "../../../../core/SessionService.js";
|
|
15
15
|
import { walletIdFromString } from "../../../../shared-ts/src/utils/registrationIds.js";
|
|
16
|
-
import { json, readJson } from "../../../framework/http.js";
|
|
17
16
|
import { resolveThresholdRuntimePolicyScope } from "../../../auth/commonRouterUtils.js";
|
|
17
|
+
import { json, readJson } from "../../../framework/http.js";
|
|
18
18
|
import { emailOtpStatusCode, hashEmailOtpOperationBinding } from "../../../domains/emailOtp/emailOtpSessionRouteHelpers.js";
|
|
19
19
|
import { EMAIL_OTP_CHANNEL, WALLET_EMAIL_OTP_TRANSACTION_SIGN_OPERATION } from "../../../../shared-ts/src/utils/emailOtpDomain.js";
|
|
20
20
|
import { thresholdEd25519StatusCode } from "../../../../threshold/statusCodes.js";
|
|
21
|
+
import { signingPrepareSessionResponse } from "../../../domains/signingOperations/signingPrepareSession.js";
|
|
21
22
|
import { authenticateRouterAbWalletOperationStepUpIdentity } from "../../../domains/signingOperations/routerAbOperationStepUp.js";
|
|
22
23
|
import { buildRouterAbEd25519PrivateSigningWorkerBody } from "../../../domains/signingOperations/routerAbPrivateSigningWorker.js";
|
|
24
|
+
import { buildAuthorizedOperationWire } from "../../../domains/signingOperations/authorizedOperationWire.js";
|
|
23
25
|
import { proxyNormalSigningRequestToMpcRouter, proxyOwnerLaneAdmittedNormalSigningRequest } from "./normalSigningRouterProxy.js";
|
|
24
26
|
import { sealEmailOtpFactorSecretForWorker } from "../../../domains/emailOtp/emailOtpRouteHandlers.js";
|
|
27
|
+
import { resolveEd25519WalletSessionOperation, revalidateEd25519StepUpOperation } from "./ed25519AuthorizedOperationRevalidation.js";
|
|
25
28
|
import { parseEd25519ReusableAuthorizedOperationReceipt, parseEd25519VerifiedStepUpAuthorizedOperationReceipt, requireEd25519OperationKind } from "../../../domains/signingOperations/ed25519AuthorizedOperationReceipt.js";
|
|
26
29
|
import { authorizeRouterAbEd25519NormalSigningRoute, buildRouterAbEd25519OwnerOperationStepUpPreparation, decideRouterAbEd25519OwnerOperationAuthorization, parseRouterAbEd25519OperationStepUpScope, parseRouterAbOperationStepUpOperation, routerAbEd25519OwnerOperationFailureResult } from "../../../domains/signingOperations/routerAbEd25519NormalSigningRoute.js";
|
|
27
30
|
import { parseThresholdEd25519OperationStepUpGrantRequest, parseThresholdEd25519SessionRouteRequest } from "../../../domains/ed25519Yao/session/thresholdEd25519RequestValidation.js";
|
|
@@ -56,11 +59,12 @@ function ed25519ReusableWalletSessionIdentity(authorization) {
|
|
|
56
59
|
quotaId: session.quotaId
|
|
57
60
|
};
|
|
58
61
|
}
|
|
59
|
-
function buildEd25519GatewayOwnerWalletSessionBinding(authorization,
|
|
62
|
+
function buildEd25519GatewayOwnerWalletSessionBinding(authorization, pinned) {
|
|
60
63
|
const session = ed25519ReusableWalletSession(authorization);
|
|
61
64
|
const runtimePolicyScope = authorization.activeMaterial.runtimePolicyScope;
|
|
62
65
|
return {
|
|
63
66
|
kind: "gateway_owner_wallet_session",
|
|
67
|
+
ownershipGeneration: pinned.ownershipGeneration,
|
|
64
68
|
subjectId: String(session.principalId),
|
|
65
69
|
accountId: String(session.walletId),
|
|
66
70
|
authorizationId: String(session.authorizationId),
|
|
@@ -70,20 +74,16 @@ function buildEd25519GatewayOwnerWalletSessionBinding(authorization, projectEnvi
|
|
|
70
74
|
orgId: runtimePolicyScope.orgId,
|
|
71
75
|
projectId: runtimePolicyScope.projectId,
|
|
72
76
|
environment: runtimePolicyScope.envId,
|
|
73
|
-
projectEnvironmentId,
|
|
77
|
+
projectEnvironmentId: pinned.projectEnvironmentId,
|
|
74
78
|
signingWorkerId: authorization.activeMaterial.signingWorkerId,
|
|
75
79
|
expiresAtMs: session.expiresAtMs
|
|
76
80
|
};
|
|
77
81
|
}
|
|
78
|
-
|
|
79
|
-
|
|
82
|
+
/** The scope the operation's own admission pinned, checked against the active material. */
|
|
83
|
+
function pinnedEd25519WalletScope(authorization, pinned) {
|
|
80
84
|
const scope = authorization.activeMaterial.runtimePolicyScope;
|
|
81
|
-
const pinned = await ctx.service.authorizedOperations.readPinnedOwnerWalletScope({
|
|
82
|
-
operation,
|
|
83
|
-
walletId: session.walletId
|
|
84
|
-
});
|
|
85
85
|
if (pinned.orgId !== scope.orgId || pinned.projectId !== scope.projectId) throw new Error("Pinned owner Wallet Session scope differs from active material");
|
|
86
|
-
return pinned
|
|
86
|
+
return pinned;
|
|
87
87
|
}
|
|
88
88
|
/**
|
|
89
89
|
* The Router binding for a verified step-up: the wallet it signs for and the
|
|
@@ -99,6 +99,7 @@ async function ed25519OperationStepUpBinding(ctx, session, operation) {
|
|
|
99
99
|
if (pinned.orgId !== scope.orgId || pinned.projectId !== scope.projectId) throw new Error("Step-up wallet scope differs from the Wallet Session scope");
|
|
100
100
|
return {
|
|
101
101
|
kind: "operation_step_up",
|
|
102
|
+
ownershipGeneration: pinned.ownershipGeneration,
|
|
102
103
|
authorizationSessionId: session.sessionId,
|
|
103
104
|
orgId: scope.orgId,
|
|
104
105
|
projectId: scope.projectId,
|
|
@@ -113,7 +114,7 @@ function buildRouterAbEd25519AuthorizedOperationWire(input) {
|
|
|
113
114
|
const operationRef = operation.operation.operation;
|
|
114
115
|
if (operationRef.capabilityKind !== "near_ed25519_mpc_signing") throw new Error("Ed25519 authorized operation capability is invalid");
|
|
115
116
|
const operationKind = requireEd25519OperationKind(operationRef.operationKind);
|
|
116
|
-
|
|
117
|
+
return buildAuthorizedOperationWire(input, {
|
|
117
118
|
authorized_operation_id: operation.authorizedOperationId,
|
|
118
119
|
operation_id: operation.operation.operationId,
|
|
119
120
|
capability_kind: "near_ed25519_mpc_signing",
|
|
@@ -122,66 +123,7 @@ function buildRouterAbEd25519AuthorizedOperationWire(input) {
|
|
|
122
123
|
intent_digest_b64u: operation.operation.digests.intentDigest,
|
|
123
124
|
display_digest_b64u: operation.operation.digests.displayDigest,
|
|
124
125
|
operation_fingerprint_digest: operation.operationFingerprintDigest
|
|
125
|
-
};
|
|
126
|
-
switch (input.binding.kind) {
|
|
127
|
-
case "reusable_wallet_session":
|
|
128
|
-
if (operation.authorization.kind !== "authorization_grant" || operation.quota.kind !== "consume_reusable_wallet_session") throw new Error("Reusable Wallet Session authorized operation is invalid");
|
|
129
|
-
return {
|
|
130
|
-
binding: {
|
|
131
|
-
kind: "reusable_wallet_session",
|
|
132
|
-
authorization_id: operation.authorization.authorizationGrantRef.authorizationId,
|
|
133
|
-
wallet_session_id: input.binding.walletSessionId,
|
|
134
|
-
quota_id: input.binding.quotaId
|
|
135
|
-
},
|
|
136
|
-
authorized_operation: {
|
|
137
|
-
kind: "reusable_wallet_session_authorized_operation_v1",
|
|
138
|
-
...commonAuthorizedOperation
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
case "gateway_owner_wallet_session":
|
|
142
|
-
if (operation.authorization.kind !== "authorization_grant" || operation.quota.kind !== "consume_reusable_wallet_session") throw new Error("Gateway owner Wallet Session authorized operation is invalid");
|
|
143
|
-
return {
|
|
144
|
-
binding: {
|
|
145
|
-
kind: "gateway_owner_wallet_session",
|
|
146
|
-
subject_id: input.binding.subjectId,
|
|
147
|
-
account_id: input.binding.accountId,
|
|
148
|
-
authorization_id: input.binding.authorizationId,
|
|
149
|
-
wallet_session_id: input.binding.walletSessionId,
|
|
150
|
-
quota_id: input.binding.quotaId,
|
|
151
|
-
threshold_session_id: input.binding.thresholdSessionId,
|
|
152
|
-
org_id: input.binding.orgId,
|
|
153
|
-
project_id: input.binding.projectId,
|
|
154
|
-
environment: input.binding.environment,
|
|
155
|
-
project_environment_id: input.binding.projectEnvironmentId,
|
|
156
|
-
signing_worker_id: input.binding.signingWorkerId,
|
|
157
|
-
expires_at_ms: input.binding.expiresAtMs
|
|
158
|
-
},
|
|
159
|
-
authorized_operation: {
|
|
160
|
-
kind: "reusable_wallet_session_authorized_operation_v1",
|
|
161
|
-
...commonAuthorizedOperation
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
case "operation_step_up":
|
|
165
|
-
if (operation.authorization.kind !== "verified_step_up" || operation.quota.kind !== "quota_neutral") throw new Error("Verified step-up authorized operation is invalid");
|
|
166
|
-
return {
|
|
167
|
-
binding: {
|
|
168
|
-
kind: "operation_step_up",
|
|
169
|
-
authorization_session_id: input.binding.authorizationSessionId,
|
|
170
|
-
org_id: input.binding.orgId,
|
|
171
|
-
project_id: input.binding.projectId,
|
|
172
|
-
environment: input.binding.environment,
|
|
173
|
-
project_environment_id: input.binding.projectEnvironmentId,
|
|
174
|
-
subject_id: input.binding.subjectId,
|
|
175
|
-
account_id: input.binding.accountId
|
|
176
|
-
},
|
|
177
|
-
authorized_operation: {
|
|
178
|
-
kind: "verified_step_up_authorized_operation_v1",
|
|
179
|
-
authorization_session_id: input.binding.authorizationSessionId,
|
|
180
|
-
evidence_set_digest: operation.authorization.evidenceSetDigest,
|
|
181
|
-
...commonAuthorizedOperation
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
}
|
|
126
|
+
});
|
|
185
127
|
}
|
|
186
128
|
async function releaseEmailOtpFactorForWorker(input) {
|
|
187
129
|
const unsealed = await input.emailOtp.removeEmailOtpServerSeal({ wrappedCiphertext: input.request.enrollment.serverSealedFactorCiphertextB64u });
|
|
@@ -340,21 +282,24 @@ async function authorizeEd25519ReusableWalletSessionOperation(input) {
|
|
|
340
282
|
}
|
|
341
283
|
});
|
|
342
284
|
const authorizedOperationId = requireAuthorizationValue(parseAuthorizedOperationId(`ed25519-operation:${operation.operationId}:${scope.request_id}`));
|
|
343
|
-
const outcome = await input.ctx.service.authorizedOperations.
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
285
|
+
const outcome = await input.ctx.service.authorizedOperations.admitEd25519WalletSessionOperation({
|
|
286
|
+
operation: {
|
|
287
|
+
tenantId: identity.tenantId,
|
|
288
|
+
authorizedOperationId,
|
|
289
|
+
auditEventId: requireAuthorizationValue(parseAuthorizationAuditEventId(`ed25519-operation-audit:${operation.operationId}`)),
|
|
290
|
+
operation: envelope,
|
|
291
|
+
authorization: {
|
|
292
|
+
kind: "authorization_grant",
|
|
293
|
+
authorizationGrantRef: buildAuthorizationGrantRef(identity.authorizationId)
|
|
294
|
+
},
|
|
295
|
+
quota: {
|
|
296
|
+
kind: "consume_reusable_wallet_session",
|
|
297
|
+
quotaId: identity.quotaId
|
|
298
|
+
},
|
|
299
|
+
claimedAtMs: nowMs
|
|
355
300
|
},
|
|
356
|
-
|
|
357
|
-
}
|
|
301
|
+
walletId: session.walletId
|
|
302
|
+
});
|
|
358
303
|
if (outcome.kind !== "claimed" && outcome.kind !== "operation_in_progress" && outcome.kind !== "replayed") {
|
|
359
304
|
const stepUpMaterial = await input.ctx.service.walletRegistration.resolveEd25519MaterialActivation({
|
|
360
305
|
walletId: scope.account_id,
|
|
@@ -389,6 +334,7 @@ async function authorizeEd25519ReusableWalletSessionOperation(input) {
|
|
|
389
334
|
admission: {
|
|
390
335
|
kind: "claimed",
|
|
391
336
|
operation: outcome.operation,
|
|
337
|
+
ownerScope: outcome.ownerScope,
|
|
392
338
|
receipt: {
|
|
393
339
|
kind: "reusable_wallet_session_authorized_operation_v1",
|
|
394
340
|
authorized_operation_id: outcome.operation.authorizedOperationId,
|
|
@@ -413,101 +359,6 @@ async function authorizeEd25519ReusableWalletSessionOperation(input) {
|
|
|
413
359
|
};
|
|
414
360
|
}
|
|
415
361
|
}
|
|
416
|
-
async function revalidateEd25519AuthorizedOperation(input) {
|
|
417
|
-
let admission;
|
|
418
|
-
if (input.operation.authorization.kind === "verified_step_up") {
|
|
419
|
-
if (input.operation.quota.kind !== "quota_neutral") return {
|
|
420
|
-
ok: false,
|
|
421
|
-
response: json({
|
|
422
|
-
ok: false,
|
|
423
|
-
code: "verified_step_up_rejected",
|
|
424
|
-
message: "Ed25519 operation step-up authorization has an invalid quota"
|
|
425
|
-
}, { status: 403 })
|
|
426
|
-
};
|
|
427
|
-
admission = {
|
|
428
|
-
tenantId: input.operation.tenantId,
|
|
429
|
-
authorizedOperationId: input.operation.authorizedOperationId,
|
|
430
|
-
auditEventId: input.operation.auditEventId,
|
|
431
|
-
operation: input.operation.operation,
|
|
432
|
-
authorization: input.operation.authorization,
|
|
433
|
-
quota: input.operation.quota,
|
|
434
|
-
claimedAtMs: Date.now()
|
|
435
|
-
};
|
|
436
|
-
} else {
|
|
437
|
-
if (input.operation.quota.kind !== "consume_reusable_wallet_session") return {
|
|
438
|
-
ok: false,
|
|
439
|
-
response: json({
|
|
440
|
-
ok: false,
|
|
441
|
-
code: "authorization_grant_rejected",
|
|
442
|
-
message: "Ed25519 reusable operation authorization has an invalid quota"
|
|
443
|
-
}, { status: 403 })
|
|
444
|
-
};
|
|
445
|
-
const operation = buildEd25519ReusableOperationEnvelope(input.operation);
|
|
446
|
-
if (!operation) return {
|
|
447
|
-
ok: false,
|
|
448
|
-
response: json({
|
|
449
|
-
ok: false,
|
|
450
|
-
code: "authorization_grant_rejected",
|
|
451
|
-
message: "Ed25519 reusable operation kind is invalid"
|
|
452
|
-
}, { status: 403 })
|
|
453
|
-
};
|
|
454
|
-
admission = {
|
|
455
|
-
tenantId: input.operation.tenantId,
|
|
456
|
-
authorizedOperationId: input.operation.authorizedOperationId,
|
|
457
|
-
auditEventId: input.operation.auditEventId,
|
|
458
|
-
operation,
|
|
459
|
-
authorization: input.operation.authorization,
|
|
460
|
-
quota: input.operation.quota,
|
|
461
|
-
claimedAtMs: Date.now()
|
|
462
|
-
};
|
|
463
|
-
}
|
|
464
|
-
const result = await input.ctx.service.authorizedOperations.admitAuthorizedOperation({ operation: admission });
|
|
465
|
-
switch (result.kind) {
|
|
466
|
-
case "claimed":
|
|
467
|
-
case "operation_in_progress":
|
|
468
|
-
case "replayed":
|
|
469
|
-
if (result.operation.authorizedOperationId !== input.operation.authorizedOperationId) throw new Error("Ed25519 authorized operation changed during revalidation");
|
|
470
|
-
return {
|
|
471
|
-
ok: true,
|
|
472
|
-
operation: result.operation
|
|
473
|
-
};
|
|
474
|
-
case "authorization_grant_rejected":
|
|
475
|
-
case "verified_step_up_rejected": return {
|
|
476
|
-
ok: false,
|
|
477
|
-
response: json({
|
|
478
|
-
ok: false,
|
|
479
|
-
code: result.kind,
|
|
480
|
-
message: "Ed25519 operation authorization is no longer active"
|
|
481
|
-
}, { status: 403 })
|
|
482
|
-
};
|
|
483
|
-
case "wallet_session_quota_exhausted":
|
|
484
|
-
case "material_mismatch": return {
|
|
485
|
-
ok: false,
|
|
486
|
-
response: json({
|
|
487
|
-
ok: false,
|
|
488
|
-
code: result.kind,
|
|
489
|
-
message: "Ed25519 operation admission failed"
|
|
490
|
-
}, { status: 409 })
|
|
491
|
-
};
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
function buildEd25519ReusableOperationEnvelope(operation) {
|
|
495
|
-
const operationRef = operation.operation.operation;
|
|
496
|
-
if (operationRef.capabilityKind !== "near_ed25519_mpc_signing") return null;
|
|
497
|
-
switch (operationRef.operationKind) {
|
|
498
|
-
case "near.sign_transaction":
|
|
499
|
-
case "near.sign_delegate_action":
|
|
500
|
-
case "near.sign_nep413_message": return buildCapabilityOperationEnvelope({
|
|
501
|
-
tenantId: operation.operation.tenantId,
|
|
502
|
-
principalId: operation.operation.principalId,
|
|
503
|
-
capabilityId: operation.operation.capabilityId,
|
|
504
|
-
operationId: operation.operation.operationId,
|
|
505
|
-
operation: buildNearEd25519MpcOperationRef(operationRef.operationKind),
|
|
506
|
-
digests: operation.operation.digests
|
|
507
|
-
});
|
|
508
|
-
case "near.export_key": return null;
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
362
|
async function validateEd25519ReusableAuthorizedOperation(input) {
|
|
512
363
|
try {
|
|
513
364
|
const receipt = parseEd25519ReusableAuthorizedOperationReceipt(input.body.authorized_operation);
|
|
@@ -516,7 +367,7 @@ async function validateEd25519ReusableAuthorizedOperation(input) {
|
|
|
516
367
|
const identity = ed25519ReusableWalletSessionIdentity(input.authorization);
|
|
517
368
|
const capabilityId = requireAuthorizationValue(parseCapabilityId(scope.material_activation.capability));
|
|
518
369
|
const operationId = requireAuthorizationValue(parseCapabilityOperationId(receipt.operation_id));
|
|
519
|
-
const
|
|
370
|
+
const envelope = buildCapabilityOperationEnvelope({
|
|
520
371
|
tenantId: identity.tenantId,
|
|
521
372
|
principalId: identity.principalId,
|
|
522
373
|
capabilityId,
|
|
@@ -530,31 +381,39 @@ async function validateEd25519ReusableAuthorizedOperation(input) {
|
|
|
530
381
|
intentDigest: parseDigestB64u(receipt.intent_digest_b64u),
|
|
531
382
|
displayDigest: parseDigestB64u(receipt.display_digest_b64u)
|
|
532
383
|
}
|
|
533
|
-
})
|
|
384
|
+
});
|
|
385
|
+
const fingerprint = await computeCapabilityOperationFingerprintDigest(envelope);
|
|
534
386
|
if (fingerprint !== parseCapabilityOperationFingerprintDigest(receipt.operation_fingerprint_digest)) throw new Error("Ed25519 authorized operation fingerprint changed");
|
|
535
387
|
if (digestWireB64u((isPlainObject(input.body.prepare_binding) ? input.body.prepare_binding : null)?.intent_digest, "prepare_binding.intent_digest") !== receipt.intent_digest_b64u) throw new Error("Ed25519 authorized operation intent changed after prepare");
|
|
536
|
-
const
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
388
|
+
const authorizedOperationId = requireAuthorizationValue(parseAuthorizedOperationId(receipt.authorized_operation_id));
|
|
389
|
+
let resolved;
|
|
390
|
+
try {
|
|
391
|
+
resolved = await resolveEd25519WalletSessionOperation({
|
|
392
|
+
ctx: input.ctx,
|
|
393
|
+
tenantId: identity.tenantId,
|
|
394
|
+
authorizedOperationId,
|
|
395
|
+
operationFingerprintDigest: fingerprint,
|
|
396
|
+
walletId: ed25519ReusableWalletSession(input.authorization).walletId
|
|
397
|
+
});
|
|
398
|
+
} catch {
|
|
399
|
+
return {
|
|
543
400
|
ok: false,
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
401
|
+
response: json({
|
|
402
|
+
ok: false,
|
|
403
|
+
code: "internal",
|
|
404
|
+
message: "Authorized operation lookup failed"
|
|
405
|
+
}, { status: 500 })
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
if (!resolved.ok) return resolved;
|
|
409
|
+
const operationResult = resolved.operation;
|
|
410
|
+
if (operationResult.tenantId !== identity.tenantId || operationResult.tenantId !== input.ctx.service.authorizedOperations.tenantId || operationResult.operationFingerprintDigest !== fingerprint || operationResult.operation.operationId !== operationId || operationResult.operation.digests.laneDigest !== envelope.digests.laneDigest || operationResult.operation.digests.intentDigest !== envelope.digests.intentDigest || operationResult.operation.digests.displayDigest !== envelope.digests.displayDigest || operationResult.operation.operation.capabilityKind !== "near_ed25519_mpc_signing" || operationResult.operation.operation.operationKind !== receipt.operation_kind) throw new Error("Ed25519 authorized operation identity changed after prepare");
|
|
411
|
+
return {
|
|
554
412
|
ok: true,
|
|
555
413
|
receipt,
|
|
556
|
-
operation:
|
|
557
|
-
|
|
414
|
+
operation: operationResult,
|
|
415
|
+
ownerScope: resolved.ownerScope
|
|
416
|
+
};
|
|
558
417
|
} catch (error) {
|
|
559
418
|
return {
|
|
560
419
|
ok: false,
|
|
@@ -620,7 +479,7 @@ async function validateEd25519VerifiedStepUpAuthorizedOperation(input) {
|
|
|
620
479
|
};
|
|
621
480
|
if (operationResult.authorizedOperationId !== requireAuthorizationValue(parseAuthorizedOperationId(receipt.authorized_operation_id)) || operationResult.operationFingerprintDigest !== fingerprint) throw new Error("Operation step-up authorized operation identity changed after prepare");
|
|
622
481
|
if (operationResult.authorization.kind !== "verified_step_up" || operationResult.authorization.evidenceSetDigest !== parseDigestB64u(receipt.evidence_set_digest)) throw new Error("Operation step-up evidence changed after prepare");
|
|
623
|
-
const revalidated = await
|
|
482
|
+
const revalidated = await revalidateEd25519StepUpOperation({
|
|
624
483
|
ctx: input.ctx,
|
|
625
484
|
operation: operationResult
|
|
626
485
|
});
|
|
@@ -1083,13 +942,15 @@ async function handleRouterAbEd25519NormalSigningRoute(input) {
|
|
|
1083
942
|
bodyText: upstreamBodyText
|
|
1084
943
|
})
|
|
1085
944
|
}));
|
|
1086
|
-
|
|
945
|
+
const headers = new Headers(upstream.headers);
|
|
946
|
+
headers.delete("content-length");
|
|
947
|
+
return new Response(JSON.stringify(signingPrepareSessionResponse({
|
|
1087
948
|
...upstreamBody,
|
|
1088
949
|
authorized_operation: buildEd25519VerifiedStepUpAuthorizedOperationReceipt({ authorization })
|
|
1089
|
-
}), {
|
|
950
|
+
}, authorization)), {
|
|
1090
951
|
status: upstream.status,
|
|
1091
952
|
statusText: upstream.statusText,
|
|
1092
|
-
headers
|
|
953
|
+
headers
|
|
1093
954
|
});
|
|
1094
955
|
}
|
|
1095
956
|
if (authorization.phase !== "finalize") throw new Error("Operation step-up finalize authorization phase changed");
|
|
@@ -1163,7 +1024,7 @@ async function handleRouterAbEd25519NormalSigningRoute(input) {
|
|
|
1163
1024
|
...input.body,
|
|
1164
1025
|
authorized_operation: buildRouterAbEd25519AuthorizedOperationWire({
|
|
1165
1026
|
operation: execution.operation,
|
|
1166
|
-
binding:
|
|
1027
|
+
binding: buildEd25519GatewayOwnerWalletSessionBinding(authorization, pinnedEd25519WalletScope(authorization, authorized.admission.ownerScope))
|
|
1167
1028
|
})
|
|
1168
1029
|
}
|
|
1169
1030
|
});
|
|
@@ -1187,13 +1048,15 @@ async function handleRouterAbEd25519NormalSigningRoute(input) {
|
|
|
1187
1048
|
bodyText: upstreamBodyText
|
|
1188
1049
|
})
|
|
1189
1050
|
}));
|
|
1190
|
-
|
|
1051
|
+
const headers = new Headers(upstream.headers);
|
|
1052
|
+
headers.delete("content-length");
|
|
1053
|
+
return new Response(JSON.stringify(signingPrepareSessionResponse({
|
|
1191
1054
|
...upstreamBody,
|
|
1192
1055
|
authorized_operation: authorized.admission.receipt
|
|
1193
|
-
}), {
|
|
1056
|
+
}, authorization)), {
|
|
1194
1057
|
status: upstream.status,
|
|
1195
1058
|
statusText: upstream.statusText,
|
|
1196
|
-
headers
|
|
1059
|
+
headers
|
|
1197
1060
|
});
|
|
1198
1061
|
}
|
|
1199
1062
|
const validatedAuthorization = await validateEd25519ReusableAuthorizedOperation({
|
|
@@ -1204,6 +1067,7 @@ async function handleRouterAbEd25519NormalSigningRoute(input) {
|
|
|
1204
1067
|
if (!validatedAuthorization.ok) return validatedAuthorization.response;
|
|
1205
1068
|
const replay = replayCompletedEd25519Operation(validatedAuthorization.operation);
|
|
1206
1069
|
if (replay) return replay;
|
|
1070
|
+
if (!validatedAuthorization.ownerScope) throw new Error("Pinned owner Wallet Session scope is unavailable");
|
|
1207
1071
|
const upstream = await proxyEd25519OwnerLaneExecution({
|
|
1208
1072
|
ctx: input.ctx,
|
|
1209
1073
|
authorization,
|
|
@@ -1212,7 +1076,7 @@ async function handleRouterAbEd25519NormalSigningRoute(input) {
|
|
|
1212
1076
|
...input.body,
|
|
1213
1077
|
authorized_operation: buildRouterAbEd25519AuthorizedOperationWire({
|
|
1214
1078
|
operation: validatedAuthorization.operation,
|
|
1215
|
-
binding:
|
|
1079
|
+
binding: buildEd25519GatewayOwnerWalletSessionBinding(authorization, pinnedEd25519WalletScope(authorization, validatedAuthorization.ownerScope))
|
|
1216
1080
|
})
|
|
1217
1081
|
}
|
|
1218
1082
|
});
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import { parseMpcMaterialActivationRef
|
|
2
|
-
import { EVM_ECDSA_MPC_OPERATION_KINDS
|
|
1
|
+
import { parseMpcMaterialActivationRef } from "../../../../shared-ts/src/utils/domainIds.js";
|
|
2
|
+
import { EVM_ECDSA_MPC_OPERATION_KINDS } from "../../../../shared-ts/src/authorization/capabilityKinds.js";
|
|
3
3
|
import { isPlainObject } from "../../../../shared-ts/src/utils/validation.js";
|
|
4
4
|
import { routerAbMpcMaterialActivationRefToWire } from "../../../../shared-ts/src/utils/routerAbNormalSigningIdentity.js";
|
|
5
|
-
import { WALLET_SESSION_FAILURE_CODES } from "../../../../shared-ts/src/utils/walletSessionFailure.js";
|
|
6
|
-
import { json, readJson } from "../../../framework/http.js";
|
|
7
5
|
import { walletSessionFailure, walletSessionFailureStatus } from "../../../auth/walletSessionFailure.js";
|
|
8
|
-
import { validateRouterAbEcdsaDerivationWalletSessionInputs
|
|
6
|
+
import { validateRouterAbEcdsaDerivationWalletSessionInputs } from "../../../auth/commonRouterUtils.js";
|
|
7
|
+
import { json, readJson } from "../../../framework/http.js";
|
|
9
8
|
//#region src/router/transport/fetch/routes/walletExecutionLanePreflight.ts
|
|
10
9
|
const OWNER_WALLET_EXECUTION_LANE_PREFLIGHT_PATH = "/wallet/execution-lane/owner";
|
|
11
10
|
function parsePreflightRequest(raw) {
|
|
12
11
|
if (!isPlainObject(raw)) throw new Error("owner execution-lane preflight body is required");
|
|
13
12
|
const fields = Object.keys(raw).sort();
|
|
14
13
|
if (fields.length !== 2 || fields[0] !== "curve" || fields[1] !== "expectedMaterialActivation") throw new Error("owner execution-lane preflight body fields are invalid");
|
|
15
|
-
if (raw.curve !== "
|
|
14
|
+
if (raw.curve !== "ecdsa_secp256k1") throw new Error("owner execution-lane preflight curve is invalid");
|
|
16
15
|
const materialActivation = parseMpcMaterialActivationRef(raw.expectedMaterialActivation);
|
|
17
16
|
if (!materialActivation.ok) throw new Error(materialActivation.error.message);
|
|
18
17
|
return {
|
|
@@ -162,46 +161,24 @@ async function handleOwnerWalletExecutionLanePreflight(ctx) {
|
|
|
162
161
|
}, { status: 400 });
|
|
163
162
|
}
|
|
164
163
|
const headers = Object.fromEntries(ctx.request.headers.entries());
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
authorizationSessions: ctx.service.authorizationSessions,
|
|
171
|
-
operationKind: NEAR_ED25519_MPC_OPERATION_KINDS.signTransaction
|
|
172
|
-
});
|
|
173
|
-
if (!validated.ok) return validationFailure(validated);
|
|
174
|
-
walletIdRaw = String(validated.admission.context.authorization.session.walletId);
|
|
175
|
-
authorization = {
|
|
176
|
-
kind: "wallet_auth_method",
|
|
177
|
-
walletAuthMethodId: validated.admission.context.authorization.session.walletAuthMethodId
|
|
178
|
-
};
|
|
179
|
-
} else {
|
|
180
|
-
const validated = await validateRouterAbEcdsaDerivationWalletSessionInputs({
|
|
181
|
-
materialActivation: routerAbMpcMaterialActivationRefToWire(request.expectedMaterialActivation),
|
|
182
|
-
headers,
|
|
183
|
-
authorizationSessions: ctx.service.authorizationSessions,
|
|
184
|
-
operationKind: EVM_ECDSA_MPC_OPERATION_KINDS.signTransaction
|
|
185
|
-
});
|
|
186
|
-
if (!validated.ok) return validationFailure(validated);
|
|
187
|
-
if (validated.kind === "wallet_session_operation_credential_exhausted_candidate_v1") return validationFailure(walletSessionFailure("wallet_session_unavailable"));
|
|
188
|
-
walletIdRaw = String(validated.admission.context.authorization.session.walletId);
|
|
189
|
-
authorization = {
|
|
190
|
-
kind: "wallet_auth_method",
|
|
191
|
-
walletAuthMethodId: validated.admission.context.authorization.session.walletAuthMethodId
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
const walletId = parseWalletId(walletIdRaw);
|
|
195
|
-
if (!walletId.ok) return validationFailure({
|
|
196
|
-
code: WALLET_SESSION_FAILURE_CODES.invalid,
|
|
197
|
-
message: "Wallet Session wallet identity is invalid"
|
|
164
|
+
const validated = await validateRouterAbEcdsaDerivationWalletSessionInputs({
|
|
165
|
+
materialActivation: routerAbMpcMaterialActivationRefToWire(request.expectedMaterialActivation),
|
|
166
|
+
headers,
|
|
167
|
+
authorizationSessions: ctx.service.authorizationSessions,
|
|
168
|
+
operationKind: EVM_ECDSA_MPC_OPERATION_KINDS.signTransaction
|
|
198
169
|
});
|
|
170
|
+
if (!validated.ok) return validationFailure(validated);
|
|
171
|
+
if (validated.kind === "wallet_session_operation_credential_exhausted_candidate_v1") return validationFailure(walletSessionFailure("wallet_session_unavailable"));
|
|
172
|
+
const session = validated.admission.context.authorization.session;
|
|
199
173
|
let resolved;
|
|
200
174
|
try {
|
|
201
175
|
resolved = await ctx.service.walletRegistration.resolveActiveOwnerWalletExecutionLane({
|
|
202
|
-
walletId: walletId
|
|
176
|
+
walletId: session.walletId,
|
|
203
177
|
expectedMaterialActivation: request.expectedMaterialActivation,
|
|
204
|
-
authorization
|
|
178
|
+
authorization: {
|
|
179
|
+
kind: "wallet_auth_method",
|
|
180
|
+
walletAuthMethodId: session.walletAuthMethodId
|
|
181
|
+
}
|
|
205
182
|
});
|
|
206
183
|
} catch {
|
|
207
184
|
return json({
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { findRouteDefinitionById, matchesRouteDefinitionRequest } from "../../../framework/routeDefinitions.js";
|
|
2
|
-
import "../../../../shared-ts/src/utils/walletManagementProtocol.js";
|
|
3
|
-
import { jsonFailure, readJson } from "../../../framework/http.js";
|
|
4
2
|
import { resolveSourceIpFromFetchHeaders } from "../../../auth/routerApiKeyAuth.js";
|
|
5
3
|
import { toFetchRouteResponse } from "../../../framework/routeResponses.js";
|
|
6
4
|
import { handleRouterApiWalletAddAuthMethodEmailOtpChallenge, handleRouterApiWalletAddAuthMethodFinalize, handleRouterApiWalletAddAuthMethodIntent, handleRouterApiWalletAddAuthMethodStart, handleRouterApiWalletAddSignerEcdsaActivation, handleRouterApiWalletAddSignerEcdsaDerivationRespond, handleRouterApiWalletAddSignerFinalize, handleRouterApiWalletAddSignerIntent, handleRouterApiWalletAddSignerStart, handleRouterApiWalletEcdsaKeyFactsInventory, handleRouterApiWalletNearImplicitAccountFund, handleRouterApiWalletRegistrationActivate, handleRouterApiWalletRegistrationNearAdmission, handleRouterApiWalletRegistrationNearProvisioning, handleRouterApiWalletRegistrationRespond, handleRouterApiWalletRegistrationSetup, handleRouterApiWalletRevokeAuthMethod } from "../../../domains/walletRegistration/walletRegistrationRoutes.js";
|
|
5
|
+
import "../../../../shared-ts/src/utils/walletManagementProtocol.js";
|
|
6
|
+
import { jsonFailure, readJson } from "../../../framework/http.js";
|
|
7
7
|
import { routerApiWalletRegistrationRouteService } from "../../../framework/authServicePort.js";
|
|
8
8
|
//#region src/router/transport/fetch/routes/walletRegistration.ts
|
|
9
9
|
const ROUTE_IDS = [
|
|
@@ -44,7 +44,7 @@ function resolveWalletRegistrationRoute(ctx) {
|
|
|
44
44
|
async function handleWalletRegistration(ctx) {
|
|
45
45
|
const route = resolveWalletRegistrationRoute(ctx);
|
|
46
46
|
if (!route) return null;
|
|
47
|
-
if (ctx.request.headers.get("X-Seams-Wallet-Protocol") !== "
|
|
47
|
+
if (ctx.request.headers.get("X-Seams-Wallet-Protocol") !== "3") return jsonFailure(409, "wallet_protocol_mismatch", "Your wallet application needs an update. Reload this page and try again. If the problem continues, ask the application developer to upgrade the Wallet SDK.");
|
|
48
48
|
const common = {
|
|
49
49
|
body: await readJson(ctx.request),
|
|
50
50
|
headers: Object.fromEntries(ctx.request.headers.entries()),
|
|
@@ -64,10 +64,11 @@ async function handleWalletRegistration(ctx) {
|
|
|
64
64
|
routerAbPublicKeyset: ctx.opts.routerAbPublicKeyset,
|
|
65
65
|
session: ctx.opts.session,
|
|
66
66
|
publishableKeyAuth: ctx.opts.publishableKeyAuth,
|
|
67
|
-
|
|
67
|
+
registrationContext: ctx.opts.registrationContext
|
|
68
68
|
},
|
|
69
69
|
sourceIp: resolveSourceIpFromFetchHeaders(ctx.request.headers) || void 0,
|
|
70
|
-
signingSessionSeal: ctx.opts.signingSessionSeal
|
|
70
|
+
signingSessionSeal: ctx.opts.signingSessionSeal,
|
|
71
|
+
waitUntil: ctx.runtime.kind === "background" ? ctx.runtime.waitUntil : void 0
|
|
71
72
|
};
|
|
72
73
|
let response;
|
|
73
74
|
switch (route.id) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { json, jsonFailure } from "../../../framework/http.js";
|
|
2
1
|
import { extractBearerCredential } from "../../../auth/routerApiKeyAuth.js";
|
|
2
|
+
import { json, jsonFailure } from "../../../framework/http.js";
|
|
3
3
|
//#region src/router/transport/fetch/routes/webauthnAuthenticators.ts
|
|
4
4
|
async function handleWebAuthnAuthenticators(ctx) {
|
|
5
5
|
if (ctx.method !== "GET") return null;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { parseLinkDeviceSessionId, parseLinkedDeviceEnrollmentId, parseMpcMaterialActivationRef, parseWalletAuthorityId, parseWalletId, parseWalletRecoveryOperationId } from "../utils/domainIds.js";
|
|
2
2
|
import { parseDeviceId } from "./capabilityKinds.js";
|
|
3
|
+
import { requireRecord } from "../utils/validation.js";
|
|
4
|
+
import { parseDelegatedWalletPermissionSetV1 } from "./delegatedAuthority.js";
|
|
3
5
|
import { base64UrlEncode } from "../utils/base64.js";
|
|
4
6
|
import { sha256Bytes } from "../utils/digests.js";
|
|
5
7
|
import { parseDigestB64u } from "../utils/canonicalPrimitives.js";
|
|
6
|
-
import { requireRecord } from "../utils/validation.js";
|
|
7
|
-
import { parseDelegatedWalletPermissionSetV1 } from "./delegatedAuthority.js";
|
|
8
8
|
import { buildExactAdministeredSignerManifestV1, parseExactAdministeredSignerManifestV1 } from "../device-linking/delegatedActivationPlan.js";
|
|
9
9
|
import { concat, lp32, rawDigest, rawPublicKey, text, u32, u64 } from "../utils/digestEncoding.js";
|
|
10
10
|
//#region ../shared-ts/src/authorization/walletAuthority.ts
|
|
@@ -1,17 +1,27 @@
|
|
|
1
1
|
import { requireRecord } from "../utils/validation.js";
|
|
2
2
|
import { rejectUnknownFields } from "../utils/exactRecord.js";
|
|
3
|
-
import { wireLiteral, wireObject } from "../utils/wireSchema.js";
|
|
3
|
+
import { wireLiteral, wireObject, wireUnion } from "../utils/wireSchema.js";
|
|
4
4
|
import { digest, keyLabeled, materialActivation, parseNonNegativeSafeInteger, parseUnixTime, quotaId, walletAuthMethodId, walletAuthorityId, walletId, walletSessionAuthorizationId, walletSessionId } from "./wireFields.js";
|
|
5
5
|
//#region ../shared-ts/src/device-linking/activeWalletSession.ts
|
|
6
|
+
const walletSessionHome = wireUnion("kind", [wireObject({ kind: wireLiteral("direct") }), wireObject({
|
|
7
|
+
kind: wireLiteral("regional"),
|
|
8
|
+
region: wireLiteral("US", "WEUR", "APAC", "OC")
|
|
9
|
+
})]);
|
|
10
|
+
function parseWalletSessionHome(raw) {
|
|
11
|
+
return walletSessionHome(raw, "Wallet Session home");
|
|
12
|
+
}
|
|
6
13
|
function walletSessionOperationCredentialV1() {
|
|
7
14
|
return wireObject({
|
|
8
15
|
kind: wireLiteral("opaque_wallet_session_operation_credential_v1"),
|
|
16
|
+
ownershipGeneration: parseNonNegativeSafeInteger,
|
|
17
|
+
home: parseWalletSessionHome,
|
|
9
18
|
token: (raw, label) => {
|
|
10
19
|
if (typeof raw !== "string" || raw.length > 8192) throw new Error(`${label} is invalid`);
|
|
11
20
|
return raw;
|
|
12
21
|
},
|
|
13
22
|
walletSessionId: keyLabeled(walletSessionId)
|
|
14
23
|
}, (credential, label) => {
|
|
24
|
+
if (credential.ownershipGeneration === 0) throw new Error(`${label} ownership generation must be positive`);
|
|
15
25
|
if (!/^wst_[A-Za-z0-9_-]{43}$/.test(credential.token)) throw new Error(`${label} opaque token is invalid`);
|
|
16
26
|
});
|
|
17
27
|
}
|
|
@@ -69,6 +79,6 @@ function parseWalletCapabilitySubjectV1(raw, label) {
|
|
|
69
79
|
};
|
|
70
80
|
}
|
|
71
81
|
//#endregion
|
|
72
|
-
export { parseActiveWalletSessionV1, parseWalletSessionOperationCredentialV1 };
|
|
82
|
+
export { parseActiveWalletSessionV1, parseWalletSessionHome, parseWalletSessionOperationCredentialV1 };
|
|
73
83
|
|
|
74
84
|
//# sourceMappingURL=activeWalletSession.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { delegatedWalletPermissionNamesV1 } from "../authorization/delegatedAuthority.js";
|
|
1
2
|
import { alphabetizeStringify } from "../utils/digests.js";
|
|
2
3
|
import { sha256DigestB64u, sha256Utf8DigestB64u } from "../utils/canonicalPrimitives.js";
|
|
3
|
-
import { delegatedWalletPermissionNamesV1 } from "../authorization/delegatedAuthority.js";
|
|
4
4
|
import { concat, lp32, rawDigest, rawPublicKey, text, u32, u64 } from "../utils/digestEncoding.js";
|
|
5
5
|
import "./committedSignerPackages.js";
|
|
6
6
|
//#region ../shared-ts/src/device-linking/digests.ts
|