@seams/wallet-server 0.7.1 → 0.7.3
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 +1 -105
- package/artifact-manifest.json +21 -21
- package/cloudflare-router-ab/build/deriver-a/build-stamp.json +1 -1
- 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_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_bg.wasm +0 -0
- package/cloudflare-router-ab/build/signing-worker/build-stamp.json +1 -1
- 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_bg.wasm +0 -0
- package/dist/esm/authorization/service.js +8 -0
- package/dist/esm/authorization/vaultProxyUse.js +2 -6
- package/dist/esm/cloud-host.js +4 -4
- package/dist/esm/core/IdentityStore.js +23 -110
- package/dist/esm/core/SessionService.js +7 -30
- package/dist/esm/core/ThresholdService/routerAbNormalSigningPolicy.js +3 -10
- package/dist/esm/core/ThresholdService/stores/WalletSessionStore.js +21 -97
- package/dist/esm/core/ThresholdService/stores/exportReplayGuard.js +7 -0
- package/dist/esm/core/WalletStore.js +4 -6
- package/dist/esm/core/authService/bytes.js +1 -4
- package/dist/esm/core/authService/emailOtpChallengeOperations.js +2 -5
- package/dist/esm/core/authService/emailOtpChallengeProof.js +9 -40
- package/dist/esm/core/authService/emailOtpChallengeVerification.js +19 -90
- package/dist/esm/core/authService/emailOtpChallenges.js +10 -45
- package/dist/esm/core/authService/emailOtpDelivery.js +10 -45
- package/dist/esm/core/authService/emailOtpEnrollment.js +9 -40
- package/dist/esm/core/authService/emailOtpGrant.js +9 -40
- package/dist/esm/core/authService/emailOtpRegistrationEnrollment.js +9 -40
- package/dist/esm/core/authService/emailOtpSeal.js +5 -20
- package/dist/esm/core/authService/emailOtpUnlock.js +20 -110
- package/dist/esm/core/authService/googleEmailOtpRegistration.js +28 -115
- package/dist/esm/core/authService/identity.js +5 -20
- package/dist/esm/core/authService/nearPublicKeyMetadata.js +6 -25
- package/dist/esm/core/authService/oidcVerification.js +22 -34
- package/dist/esm/core/authService/rateLimits.js +2 -5
- package/dist/esm/core/authService/thresholdEcdsaKeyInventory.js +2 -1
- package/dist/esm/core/authService/webauthn.js +37 -191
- package/dist/esm/core/authService/webauthnVerificationOutcomes.js +5 -24
- package/dist/esm/core/d1EcdsaSignerRead.js +76 -0
- package/dist/esm/core/d1IdentityStore.js +16 -75
- package/dist/esm/core/d1TenantStore.js +1 -1
- package/dist/esm/core/d1WalletStore.js +15 -25
- package/dist/esm/core/deviceLinking/linkedDeviceEmailOtpGrant.js +1 -5
- package/dist/esm/core/deviceLinking/linkedDeviceSessionApproval.js +1 -3
- package/dist/esm/core/deviceLinking/linkedDeviceSessionRecord.js +2 -8
- package/dist/esm/core/deviceLinking/requestProof.js +13 -4
- package/dist/esm/core/ecdsaMaterialReadSnapshot.js +85 -0
- package/dist/esm/core/nearRelayerAccountProvisioning.js +2 -5
- package/dist/esm/core/signingLanes/WalletExecutionLaneProjection.js +3 -6
- package/dist/esm/core/signingMaterial/ordinaryInactiveSignerMaterialReservation.js +2 -5
- package/dist/esm/core/storeBackends.js +1 -1
- package/dist/esm/core/thresholdEcdsaChainTarget.js +1 -3
- package/dist/esm/hosted-wallet-gateway.js +2 -2
- package/dist/esm/localHostedWalletGatewayHandler.js +13 -0
- package/dist/esm/localIntendedMaterialAdmissionFault.js +176 -0
- package/dist/esm/localIntendedPresignCancellation.js +44 -0
- package/dist/esm/router/auth/commonRouterUtils.js +24 -10
- package/dist/esm/router/auth/walletSessionFailure.js +2 -5
- package/dist/esm/router/auth/webAuthnCredentialCodecs.js +4 -15
- package/dist/esm/router/cloudflare/d1/auth/d1AuthorizedOperationRouteService.js +1 -0
- package/dist/esm/router/cloudflare/d1/auth/d1RouterApiAuthBoundary.js +2 -6
- package/dist/esm/router/cloudflare/d1/auth/d1RouterApiAuthService.js +5 -27
- package/dist/esm/router/cloudflare/d1/auth/walletSessionCredentialReaders.js +76 -0
- package/dist/esm/router/cloudflare/d1/authorization/authorizedOperationStatements.js +28 -21
- package/dist/esm/router/cloudflare/d1/authorization/d1AuthorizationStore.js +209 -44
- package/dist/esm/router/cloudflare/d1/authorization/d1VaultProxyStore.js +8 -12
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceAuthorityInstallService.js +50 -8
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceTargetCredentialProvider.js +1 -1
- package/dist/esm/router/cloudflare/d1/deviceLinking/index.js +3 -3
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeIssuer.js +12 -55
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeService.js +17 -80
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpDeliveryRuntime.js +6 -25
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpRecords.js +12 -47
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpRecoveryService.js +24 -85
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpRegistrationEnrollmentFinalizer.js +7 -30
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpServerSealRuntime.js +5 -20
- package/dist/esm/router/cloudflare/d1/emailOtp/d1GoogleEmailOtpSessionResolver.js +23 -110
- package/dist/esm/router/cloudflare/d1/identity/d1IdentityService.js +9 -40
- package/dist/esm/router/cloudflare/d1/near/d1NearPublicKeyStore.js +3 -10
- package/dist/esm/router/cloudflare/d1/oidc/d1OidcBoundary.js +18 -91
- package/dist/esm/router/cloudflare/d1/oidc/d1OidcVerificationService.js +6 -30
- package/dist/esm/router/cloudflare/d1/passkeyCustody/d1PasskeyCustodyRouteService.js +4 -15
- package/dist/esm/router/cloudflare/d1/passkeyCustody/d1WalletCustodyCommitStore.js +2 -7
- package/dist/esm/router/cloudflare/d1/passkeyCustody/d1WalletRecoveryGoogleEmailOtpRecords.js +9 -13
- package/dist/esm/router/cloudflare/d1/passkeyCustody/d1WalletRecoveryGoogleEmailOtpService.js +11 -50
- package/dist/esm/router/cloudflare/d1/registration/d1EvmFamilyEcdsaRegistrationBranch.js +5 -20
- package/dist/esm/router/cloudflare/d1/registration/d1RegistrationCeremonyRecordStore.js +4 -7
- package/dist/esm/router/cloudflare/d1/registration/d1RegistrationCeremonyRecords.js +2 -1
- package/dist/esm/router/cloudflare/d1/registration/d1RegistrationIntentService.js +7 -30
- package/dist/esm/router/cloudflare/d1/registration/d1WalletRegistrationService.js +32 -22
- package/dist/esm/router/cloudflare/d1/registration/walletRegistrationSessionCommitReceipt.js +1 -4
- package/dist/esm/router/cloudflare/d1/signingAdmission/d1RouterAbNormalSigningAdmissionStore.js +119 -25
- package/dist/esm/router/cloudflare/d1/webauthn/d1WebAuthnAuthService.js +31 -168
- package/dist/esm/router/cloudflare/d1/webauthn/d1WebAuthnRecords.js +6 -9
- package/dist/esm/router/cloudflare/durableObjects/thresholdStore.js +59 -66
- package/dist/esm/router/cloudflare/runtime/routerAbPrewarm.js +2 -2
- package/dist/esm/router/cloudflare/runtime/staticWalletConsoleBinding.js +5 -20
- package/dist/esm/router/cloudflare/runtime/tenantRootCreationGrant.js +2 -9
- package/dist/esm/router/cloudflare/runtime/walletControlOps.js +2 -1
- package/dist/esm/router/cloudflare/signingLanes/cloudflareLaneCurveExecution.js +2 -1
- package/dist/esm/router/cloudflare/signingLanes/cloudflareLaneProtocolCommitter.js +2 -2
- package/dist/esm/router/cloudflare.js +2146 -1802
- package/dist/esm/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistrationPersistence.js +5 -8
- package/dist/esm/router/domains/ed25519Yao/recovery/routerAbEd25519YaoRecoveryWalletSessionAuthorization.js +3 -6
- package/dist/esm/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistrationIntentAuthorization.js +6 -25
- package/dist/esm/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistrationSideEffectBoundary.js +39 -55
- package/dist/esm/router/domains/emailOtp/emailOtpRouteHandlers.js +15 -62
- package/dist/esm/router/domains/signingOperations/routerAbEcdsaDerivationNormalSigningRoute.js +83 -74
- package/dist/esm/router/domains/signingOperations/routerAbNormalSigningAdmission.js +1 -0
- package/dist/esm/router/domains/signingOperations/routerAbOperationStepUp.js +1 -0
- package/dist/esm/router/domains/signingOperations/walletExecutionAdmission.js +1 -4
- package/dist/esm/router/domains/tenantRoot/tenantRootIdentityResolution.js +7 -13
- package/dist/esm/router/domains/walletUnlock/walletUnlockRouteHandlers.js +41 -200
- package/dist/esm/router/express.js +317 -699
- package/dist/esm/router/framework/http.js +5 -1
- package/dist/esm/router/framework/runtimeSnapshotConsumer.js +8 -35
- package/dist/esm/router/transport/fetch/createFetchRouter.js +3 -6
- package/dist/esm/router/transport/fetch/routes/auth.js +9 -41
- package/dist/esm/router/transport/fetch/routes/deviceLinkingOwnerAuthorization.js +5 -22
- package/dist/esm/router/transport/fetch/routes/nearPublicKeys.js +4 -16
- package/dist/esm/router/transport/fetch/routes/sessions.js +1 -0
- package/dist/esm/router/transport/fetch/routes/syncAccount.js +8 -36
- package/dist/esm/router/transport/fetch/routes/thresholdEcdsa.js +27 -79
- package/dist/esm/router/transport/fetch/routes/walletExecutionLanePreflight.js +4 -1
- package/dist/esm/router/transport/fetch/routes/webauthnAuthenticators.js +4 -16
- package/dist/esm/shared-ts/src/authorization/walletSignerActivationEquality.js +12 -0
- package/dist/esm/shared-ts/src/device-linking/committedSignerPackages.js +2 -5
- package/dist/esm/shared-ts/src/device-linking/delegatedActivationPlan.js +1 -5
- package/dist/esm/shared-ts/src/device-linking/ed25519ExportRoot.js +12 -16
- package/dist/esm/shared-ts/src/device-linking/sourceContribution.js +5 -8
- package/dist/esm/shared-ts/src/passkey-custody/primitives.js +5 -1
- package/dist/esm/shared-ts/src/signing-lanes/ownerContinuity.js +4 -8
- package/dist/esm/shared-ts/src/tenant-root/tenantRootIdentifier.js +12 -0
- package/dist/esm/shared-ts/src/tenant-root/tenantRootIdentity.js +2 -9
- package/dist/esm/shared-ts/src/tenant-root/tenantRootOperationRecord.js +1 -4
- package/dist/esm/shared-ts/src/utils/ecdsaKeyFactsInventory.js +2 -4
- package/dist/esm/shared-ts/src/utils/ecdsaServerTiming.js +0 -1
- package/dist/esm/shared-ts/src/utils/emailOtpDomain.js +3 -1
- package/dist/esm/shared-ts/src/utils/exactKeys.js +17 -0
- package/dist/esm/shared-ts/src/utils/failure.js +20 -0
- package/dist/esm/shared-ts/src/utils/registrationIntent.js +3 -12
- package/dist/esm/shared-ts/src/utils/registrationSignerPlan.js +2 -5
- package/dist/esm/shared-ts/src/utils/routerAbEcdsaDerivation.js +1 -1
- package/dist/esm/shared-ts/src/utils/routerAbEd25519Yao.js +1 -1
- package/dist/esm/shared-ts/src/utils/thresholdEcdsaChainTarget.js +9 -0
- package/dist/esm/shared-ts/src/wallet-recovery/walletRecoveryCommittedProjection.js +1 -4
- package/dist/esm/threshold/session/signingSessionSeal/crypto/cipher.js +10 -32
- package/dist/esm/threshold/session/signingSessionSeal/idempotencyBackends.js +3 -3
- package/dist/esm/threshold/session/signingSessionSeal/idempotencyRecords.js +3 -9
- package/dist/esm/threshold/session/signingSessionSeal/service.js +8 -35
- package/dist/esm/threshold/session/signingSessionSeal/transport/express.js +18 -94
- package/dist/esm/threshold/session/signingSessionSeal/transport/fetch.js +6 -30
- package/dist/esm/threshold/session/signingSessionSeal/transport/shared.js +5 -20
- package/dist/esm/wasm/evm_crypto/pkg/evm_crypto_bg.wasm +0 -0
- package/dist/esm/wasm/near_signer/pkg/wasm_signer_worker_bg.wasm +0 -0
- package/dist/types/shared-ts/src/authorization/delegatedAuthority.d.ts +2 -1
- package/dist/types/shared-ts/src/authorization/walletSessionIssuance.d.ts +9 -2
- package/dist/types/shared-ts/src/authorization/walletSignerActivationEquality.d.ts +4 -0
- package/dist/types/shared-ts/src/device-linking/committedSignerPackages.d.ts +3 -4
- package/dist/types/shared-ts/src/device-linking/contracts.d.ts +5 -63
- package/dist/types/shared-ts/src/device-linking/sourceContribution.d.ts +2 -0
- package/dist/types/shared-ts/src/passkey-custody/custodyEnvelope.d.ts +5 -12
- package/dist/types/shared-ts/src/passkey-custody/primitives.d.ts +9 -0
- package/dist/types/shared-ts/src/signing-lanes/execution.d.ts +11 -1
- package/dist/types/shared-ts/src/signing-lanes/ids.d.ts +1 -10
- package/dist/types/shared-ts/src/signing-lanes/rotation.d.ts +3 -5
- package/dist/types/shared-ts/src/tenant-root/tenantRootIdentifier.d.ts +3 -0
- package/dist/types/shared-ts/src/tenant-root/tenantRootOperationRecord.d.ts +2 -1
- package/dist/types/shared-ts/src/threshold/ecdsaDerivationRoleLocalBootstrap.d.ts +6 -0
- package/dist/types/shared-ts/src/threshold/signingRootScope.d.ts +1 -0
- package/dist/types/shared-ts/src/utils/ecdsaKeyFactsInventory.d.ts +2 -11
- package/dist/types/shared-ts/src/utils/eip1559TxWasmJson.d.ts +16 -0
- package/dist/types/shared-ts/src/utils/emailOtpDomain.d.ts +2 -0
- package/dist/types/shared-ts/src/utils/exactKeys.d.ts +11 -0
- package/dist/types/shared-ts/src/utils/failure.d.ts +12 -0
- package/dist/types/shared-ts/src/utils/jsonRpc.d.ts +3 -4
- package/dist/types/shared-ts/src/utils/nearRpcResults.d.ts +1 -0
- package/dist/types/shared-ts/src/utils/registrationAuthMethodInput.d.ts +3 -8
- package/dist/types/shared-ts/src/utils/registrationSignerPlan.d.ts +7 -19
- package/dist/types/shared-ts/src/utils/routerAbEcdsaDerivation.d.ts +3 -1
- package/dist/types/shared-ts/src/utils/routerAbEd25519Yao.d.ts +1 -0
- package/dist/types/shared-ts/src/utils/routerAbEd25519YaoDigests.d.ts +3 -4
- package/dist/types/shared-ts/src/utils/routerAbNormalSigningIdentity.d.ts +30 -8
- package/dist/types/shared-ts/src/utils/routerApiKeyAuth.d.ts +2 -0
- package/dist/types/shared-ts/src/utils/signingSessionSeal.d.ts +10 -11
- package/dist/types/shared-ts/src/utils/thresholdEcdsaChainTarget.d.ts +25 -0
- package/dist/types/shared-ts/src/utils/variant.d.ts +18 -0
- package/dist/types/shared-ts/src/utils/walletAuthMethodRecord.d.ts +3 -6
- package/dist/types/shared-ts/src/utils/webauthnDeviceInfo.d.ts +4 -2
- package/dist/types/shared-ts/src/wallet-recovery/recoveryEnvelopes.d.ts +3 -16
- package/dist/types/shared-ts/src/wallet-recovery/walletRecoveryPreparation.d.ts +15 -0
- package/dist/types/shared-ts/src/wallet-recovery/walletRecoveryTarget.d.ts +3 -4
- package/dist/types/wallet-server/src/authorization/domain.d.ts +13 -2
- package/dist/types/wallet-server/src/authorization/ecdsaWalletSessionAdmission.d.ts +27 -3
- package/dist/types/wallet-server/src/authorization/service.d.ts +19 -0
- package/dist/types/wallet-server/src/core/ThresholdService/stores/SessionStore.d.ts +2 -2
- package/dist/types/wallet-server/src/core/ThresholdService/stores/WalletSessionStore.d.ts +1 -1
- package/dist/types/wallet-server/src/core/ThresholdService/stores/exportReplayGuard.d.ts +3 -0
- package/dist/types/wallet-server/src/core/ThresholdService/validation.d.ts +8 -101
- package/dist/types/wallet-server/src/core/WebAuthnAuthenticatorStore.d.ts +8 -0
- package/dist/types/wallet-server/src/core/authService/bytes.d.ts +0 -1
- package/dist/types/wallet-server/src/core/authService/emailOtpChallenges.d.ts +2 -10
- package/dist/types/wallet-server/src/core/authService/emailOtpSeal.d.ts +1 -1
- package/dist/types/wallet-server/src/core/authService/emailOtpUnlock.d.ts +3 -10
- package/dist/types/wallet-server/src/core/d1EcdsaSignerRead.d.ts +39 -0
- package/dist/types/wallet-server/src/core/d1WalletStore.d.ts +10 -0
- package/dist/types/wallet-server/src/core/deviceLinking/linkedDeviceSessionRecord.d.ts +3 -4
- package/dist/types/wallet-server/src/core/ecdsaMaterialReadSnapshot.d.ts +19 -0
- package/dist/types/wallet-server/src/core/routerAbSigning/RouterAbNormalSigningRuntime.d.ts +3 -5
- package/dist/types/wallet-server/src/core/rpcClients/near/NearClient.d.ts +1 -2
- package/dist/types/wallet-server/src/core/signingLanes/WalletExecutionLaneProjection.d.ts +2 -11
- package/dist/types/wallet-server/src/core/signingLanes/signingWorkerLaneMaterialIdentity.d.ts +2 -19
- package/dist/types/wallet-server/src/core/thresholdEcdsaChainTarget.d.ts +3 -11
- package/dist/types/wallet-server/src/core/types.d.ts +2 -6
- package/dist/types/wallet-server/src/localIntendedMaterialAdmissionFault.d.ts +38 -0
- package/dist/types/wallet-server/src/localIntendedPresignCancellation.d.ts +4 -0
- package/dist/types/wallet-server/src/router/auth/authRequestValidation.d.ts +4 -9
- package/dist/types/wallet-server/src/router/auth/commonRouterUtils.d.ts +15 -1
- package/dist/types/wallet-server/src/router/cloudflare/d1/auth/d1RouterApiAuthBoundary.d.ts +0 -1
- package/dist/types/wallet-server/src/router/cloudflare/d1/auth/d1RouterApiAuthService.d.ts +1 -1
- package/dist/types/wallet-server/src/router/cloudflare/d1/auth/walletSessionCredentialReaders.d.ts +9 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/authorization/authorizedOperationStatements.d.ts +4 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/authorization/d1AuthorizationStore.d.ts +10 -1
- package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceAuthorityInstallService.d.ts +19 -2
- package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceSessionStore.d.ts +2 -6
- package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceTargetCredentialProvider.d.ts +5 -8
- package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpEnrollmentStore.d.ts +2 -8
- package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpRateLimitStore.d.ts +2 -9
- package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpRecords.d.ts +5 -5
- package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpServerSealRuntime.d.ts +4 -14
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1RegistrationCeremonyRecordStore.d.ts +2 -6
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1WalletRegistrationService.d.ts +8 -6
- package/dist/types/wallet-server/src/router/cloudflare/d1/signingAdmission/d1RouterAbNormalSigningAdmissionStore.d.ts +14 -1
- package/dist/types/wallet-server/src/router/cloudflare/d1/webauthn/d1WebAuthnRecords.d.ts +10 -39
- package/dist/types/wallet-server/src/router/cloudflare/runtime/walletConsoleOps.d.ts +8 -34
- package/dist/types/wallet-server/src/router/domains/ecdsa/thresholdEcdsaRequestValidation.d.ts +3 -15
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/session/routerAbEd25519YaoWalletSession.d.ts +9 -50
- package/dist/types/wallet-server/src/router/domains/passkeyCustody/walletRecoveryKeyManifest.d.ts +1 -13
- package/dist/types/wallet-server/src/router/domains/signingOperations/routerAbEcdsaDerivationNormalSigningRoute.d.ts +8 -9
- package/dist/types/wallet-server/src/router/domains/signingOperations/routerAbNormalSigningAdmission.d.ts +13 -0
- package/dist/types/wallet-server/src/router/domains/signingOperations/routerAbOperationStepUp.d.ts +3 -4
- package/dist/types/wallet-server/src/router/domains/signingOperations/routerAbPrivateSigningWorker.d.ts +7 -16
- package/dist/types/wallet-server/src/router/domains/syncAccount/syncAccountRequestValidation.d.ts +2 -7
- package/dist/types/wallet-server/src/router/framework/apiCredentialPorts.d.ts +3 -1
- package/dist/types/wallet-server/src/router/framework/authServicePort.d.ts +25 -4
- package/dist/types/wallet-server/src/router/framework/http.d.ts +1 -0
- package/dist/types/wallet-server/src/router/framework/ror/normalize.d.ts +1 -9
- package/dist/types/wallet-server/src/router/transport/fetch/routes/deviceLinkingOwnerAuthorization.d.ts +3 -6
- package/dist/types/wallet-server/src/router/transport/fetch/routes/syncAccountBootstrap.d.ts +3 -5
- package/dist/types/wallet-server/src/router/transport/fetch/routes/thresholdEcdsa.d.ts +0 -1
- package/dist/types/wallet-server/src/threshold/session/signingSessionSeal/idempotencyRecords.d.ts +1 -2
- package/dist/types/wallet-server/src/threshold/session/signingSessionSeal/signingSessionSeal.types.d.ts +6 -8
- package/package.json +1 -1
- package/dist/esm/wasm/router_ab_ecdsa_signing_worker/pkg/router_ab_ecdsa_signing_worker_bg.wasm +0 -0
|
@@ -5,6 +5,7 @@ import "../../../../shared-ts/src/utils/encoders.js";
|
|
|
5
5
|
import { isActiveRecoveredWalletAuthorityV1, walletAuthorityDigestsMatchV1 } from "../../../../shared-ts/src/authorization/walletAuthority.js";
|
|
6
6
|
import { secureRandomBase64Url } from "../../../../shared-ts/src/utils/secureRandomId.js";
|
|
7
7
|
import { PASSKEY_PRF_FIRST_SALT_V1, PASSKEY_PRF_SECOND_SALT_V1 } from "../../../../shared-ts/src/utils/signingSessionSeal.js";
|
|
8
|
+
import { failure } from "../../../../shared-ts/src/utils/failure.js";
|
|
8
9
|
import { isHostWithinRpId, originHostnameOrEmpty } from "../../../../core/authService/webauthnOidcHelpers.js";
|
|
9
10
|
import { buildWalletRecoveryBackupAcknowledgementV1, walletRecoveryBackupIsOutstanding } from "../../../../shared-ts/src/wallet-recovery/backupAcknowledgement.js";
|
|
10
11
|
import "../../../../shared-ts/src/wallet-recovery/recoveryCodes.js";
|
|
@@ -251,20 +252,12 @@ function createD1PasskeyCustodyRouteService(assembly) {
|
|
|
251
252
|
const expectedOrigin = String(request.expectedOrigin || "").trim();
|
|
252
253
|
if (!challengeId || !expectedOrigin) return {
|
|
253
254
|
status: 400,
|
|
254
|
-
body:
|
|
255
|
-
ok: false,
|
|
256
|
-
code: "challenge_required",
|
|
257
|
-
message: "custody retrieval needs a server-issued challenge and an origin"
|
|
258
|
-
}
|
|
255
|
+
body: failure("challenge_required", "custody retrieval needs a server-issued challenge and an origin")
|
|
259
256
|
};
|
|
260
257
|
const challenge = await assembly.webAuthnStore.consumeLoginChallenge(challengeId);
|
|
261
258
|
if (!challenge) return {
|
|
262
259
|
status: 401,
|
|
263
|
-
body:
|
|
264
|
-
ok: false,
|
|
265
|
-
code: "challenge_unknown",
|
|
266
|
-
message: "the challenge is unknown, expired, or already used"
|
|
267
|
-
}
|
|
260
|
+
body: failure("challenge_unknown", "the challenge is unknown, expired, or already used")
|
|
268
261
|
};
|
|
269
262
|
const projections = await assembly.passkeyCustodyEnvelopes.listWalletCredentialActivity(request.locator.walletId);
|
|
270
263
|
const requestedFactor = request.locator.factor;
|
|
@@ -275,11 +268,7 @@ function createD1PasskeyCustodyRouteService(assembly) {
|
|
|
275
268
|
const projection = matchingProjections.find((entry) => entry.index.lifecycle.state === "active") ?? matchingProjections[0];
|
|
276
269
|
if (!projection || projection.index.factor.kind !== "passkey") return {
|
|
277
270
|
status: 404,
|
|
278
|
-
body:
|
|
279
|
-
ok: false,
|
|
280
|
-
code: "envelope_missing",
|
|
281
|
-
message: "no custody envelope for this wallet and credential"
|
|
282
|
-
}
|
|
271
|
+
body: failure("envelope_missing", "no custody envelope for this wallet and credential")
|
|
283
272
|
};
|
|
284
273
|
const locator = {
|
|
285
274
|
walletId: request.locator.walletId,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { parseWalletId } from "../../../../shared-ts/src/utils/domainIds.js";
|
|
2
2
|
import { sha256HexUtf8 } from "../../../../shared-ts/src/utils/digests.js";
|
|
3
3
|
import { buildDelegatedWalletAuthorityV1, buildFullOwnerDelegatedWalletAuthorityV1, sameDelegatedWalletAuthorityV1 } from "../../../../shared-ts/src/authorization/delegatedAuthority.js";
|
|
4
4
|
import { sameWalletAuthMethodRecordV2 } from "../../../../shared-ts/src/utils/walletAuthMethodRecord.js";
|
|
@@ -20,6 +20,7 @@ import { CloudflareD1VersionedJsonRecordStore } from "../versionedJson/d1Version
|
|
|
20
20
|
import { parseEmailOtpWalletEnrollmentRow } from "../emailOtp/d1EmailOtpRecords.js";
|
|
21
21
|
import "../../../../shared-ts/src/wallet-recovery/index.js";
|
|
22
22
|
import "../../../../shared-ts/src/authorization/index.js";
|
|
23
|
+
import { sameWalletEcdsaSignerActivationV1, sameWalletEd25519SignerActivationV1 } from "../../../../shared-ts/src/authorization/walletSignerActivationEquality.js";
|
|
23
24
|
import { PASSKEY_ENVELOPE_KEY_PREFIX, passkeyCustodyEnvelopeLocatorOf, passkeyCustodyEnvelopeRecordKey } from "./d1PasskeyCustodyEnvelopeStore.js";
|
|
24
25
|
import { parseWalletRecoveryGoogleEmailOtpAttemptRecord, sameWalletRecoveryGoogleEmailOtpFinalizationInputV1, walletRecoveryGoogleEmailOtpAttemptKey, walletRecoveryGoogleEmailOtpFinalizationInput } from "./d1WalletRecoveryGoogleEmailOtpRecords.js";
|
|
25
26
|
import { sameWalletCustodyRecoveryReplacementEnvelopeV1 } from "../../../domains/passkeyCustody/walletRecoveryFinalization.js";
|
|
@@ -36,12 +37,6 @@ function sameWalletSignerActivationSetV1(left, right) {
|
|
|
36
37
|
if (leftEd25519 === void 0 !== (rightEd25519 === void 0)) return false;
|
|
37
38
|
return leftEd25519 === void 0 || rightEd25519 === void 0 || sameWalletEd25519SignerActivationV1(leftEd25519, rightEd25519);
|
|
38
39
|
}
|
|
39
|
-
function sameWalletEcdsaSignerActivationV1(left, right) {
|
|
40
|
-
return left.kind === right.kind && left.signer.kind === right.signer.kind && left.signer.keyFamily === right.signer.keyFamily && left.signer.walletId === right.signer.walletId && left.signer.walletKeyId === right.signer.walletKeyId && left.signer.thresholdPublicKey33B64u === right.signer.thresholdPublicKey33B64u && left.signer.evmAddress === right.signer.evmAddress && mpcMaterialActivationRefsEqual(left.materialActivation, right.materialActivation);
|
|
41
|
-
}
|
|
42
|
-
function sameWalletEd25519SignerActivationV1(left, right) {
|
|
43
|
-
return left.kind === right.kind && left.signer.kind === right.signer.kind && left.signer.keyFamily === right.signer.keyFamily && left.signer.walletId === right.signer.walletId && left.signer.walletKeyId === right.signer.walletKeyId && left.signer.registeredPublicKeyB64u === right.signer.registeredPublicKeyB64u && mpcMaterialActivationRefsEqual(left.materialActivation, right.materialActivation);
|
|
44
|
-
}
|
|
45
40
|
function hasFullOwnerPermissionsV1(permissions) {
|
|
46
41
|
return sameDelegatedWalletAuthorityV1(buildDelegatedWalletAuthorityV1({ permissions }), buildFullOwnerDelegatedWalletAuthorityV1());
|
|
47
42
|
}
|
package/dist/esm/router/cloudflare/d1/passkeyCustody/d1WalletRecoveryGoogleEmailOtpRecords.js
CHANGED
|
@@ -4,6 +4,7 @@ import { parseDigestB64u } from "../../../../shared-ts/src/utils/canonicalPrimit
|
|
|
4
4
|
import { parseEnvelopeRevision } from "../../../../shared-ts/src/passkey-custody/primitives.js";
|
|
5
5
|
import { parseWalletAuthMethodRecordV2 } from "../../../../shared-ts/src/utils/walletAuthMethodRecord.js";
|
|
6
6
|
import { parseWalletAuthorityV1 } from "../../../../shared-ts/src/authorization/walletAuthority.js";
|
|
7
|
+
import { hasExactKeys } from "../../../../shared-ts/src/utils/exactKeys.js";
|
|
7
8
|
import "../../../../shared-ts/src/passkey-custody/index.js";
|
|
8
9
|
import { parseRecoveryCodeReservationId } from "../../../../shared-ts/src/wallet-recovery/recoveryCodeReservation.js";
|
|
9
10
|
//#region src/router/cloudflare/d1/passkeyCustody/d1WalletRecoveryGoogleEmailOtpRecords.ts
|
|
@@ -125,14 +126,14 @@ function parseWalletRecoveryGoogleEmailOtpAttemptRecord(raw) {
|
|
|
125
126
|
expiresAtMs
|
|
126
127
|
};
|
|
127
128
|
if (record.state === "prepared") {
|
|
128
|
-
if (!
|
|
129
|
+
if (!hasExactKeys(record, [...expectedCommonFields])) return null;
|
|
129
130
|
return {
|
|
130
131
|
...common,
|
|
131
132
|
state: "prepared"
|
|
132
133
|
};
|
|
133
134
|
}
|
|
134
135
|
if (record.state !== "otp_issued" && record.state !== "otp_verified" && record.state !== "finalized") return null;
|
|
135
|
-
if (!
|
|
136
|
+
if (!hasExactKeys(record, [
|
|
136
137
|
...expectedCommonFields,
|
|
137
138
|
"providerSubject",
|
|
138
139
|
"verifiedEmail",
|
|
@@ -164,7 +165,7 @@ function parseWalletRecoveryGoogleEmailOtpAttemptRecord(raw) {
|
|
|
164
165
|
function parseContinuityAnchor(raw) {
|
|
165
166
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return null;
|
|
166
167
|
const record = raw;
|
|
167
|
-
if (!
|
|
168
|
+
if (!hasExactKeys(record, [
|
|
168
169
|
"kind",
|
|
169
170
|
"authority",
|
|
170
171
|
"method",
|
|
@@ -207,7 +208,7 @@ function parseContinuityEnvelope(raw) {
|
|
|
207
208
|
const updatedAtMs = parsePositiveMs(record.updatedAtMs);
|
|
208
209
|
if (!envelopeId.ok || !walletId.ok || updatedAtMs === null || record.bindingKind !== "wallet_custody_seed_v1") return null;
|
|
209
210
|
if (record.kind === "passkey") {
|
|
210
|
-
if (!
|
|
211
|
+
if (!hasExactKeys(record, [
|
|
211
212
|
...commonFields,
|
|
212
213
|
"rpId",
|
|
213
214
|
"credentialIdB64u"
|
|
@@ -227,7 +228,7 @@ function parseContinuityEnvelope(raw) {
|
|
|
227
228
|
};
|
|
228
229
|
}
|
|
229
230
|
if (record.kind === "email_otp") {
|
|
230
|
-
if (!
|
|
231
|
+
if (!hasExactKeys(record, [
|
|
231
232
|
...commonFields,
|
|
232
233
|
"enrollmentId",
|
|
233
234
|
"enrollmentSealKeyVersion"
|
|
@@ -251,7 +252,7 @@ function parseContinuityEnvelope(raw) {
|
|
|
251
252
|
function parseTarget(raw) {
|
|
252
253
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return null;
|
|
253
254
|
const record = raw;
|
|
254
|
-
return
|
|
255
|
+
return hasExactKeys(record, ["kind", "googleProvider"]) && record.kind === "google_email_otp" && record.googleProvider === "google" ? {
|
|
255
256
|
kind: "google_email_otp",
|
|
256
257
|
googleProvider: "google"
|
|
257
258
|
} : null;
|
|
@@ -261,7 +262,7 @@ function parseTargetEnrollment(raw) {
|
|
|
261
262
|
const record = raw;
|
|
262
263
|
if (typeof record.kind !== "string") return null;
|
|
263
264
|
if (record.kind === "existing") {
|
|
264
|
-
if (!
|
|
265
|
+
if (!hasExactKeys(record, [
|
|
265
266
|
"kind",
|
|
266
267
|
"enrollmentId",
|
|
267
268
|
"enrollmentSealKeyVersion"
|
|
@@ -275,7 +276,7 @@ function parseTargetEnrollment(raw) {
|
|
|
275
276
|
} : null;
|
|
276
277
|
}
|
|
277
278
|
if (record.kind === "create") {
|
|
278
|
-
if (!
|
|
279
|
+
if (!hasExactKeys(record, [
|
|
279
280
|
"kind",
|
|
280
281
|
"providerSubject",
|
|
281
282
|
"verifiedEmail"
|
|
@@ -303,11 +304,6 @@ function parsePositiveMs(raw) {
|
|
|
303
304
|
function nonEmpty(raw) {
|
|
304
305
|
return typeof raw === "string" && raw.trim() ? raw.trim() : null;
|
|
305
306
|
}
|
|
306
|
-
function hasExactFields(record, fields) {
|
|
307
|
-
const actual = Object.keys(record).sort();
|
|
308
|
-
const expected = [...fields].sort();
|
|
309
|
-
return actual.length === expected.length && actual.every((field, index) => field === expected[index]);
|
|
310
|
-
}
|
|
311
307
|
function hasFields(record, fields) {
|
|
312
308
|
return fields.every((field) => Object.hasOwn(record, field));
|
|
313
309
|
}
|
package/dist/esm/router/cloudflare/d1/passkeyCustody/d1WalletRecoveryGoogleEmailOtpService.js
CHANGED
|
@@ -4,6 +4,7 @@ import { alphabetizeStringify, sha256BytesUtf8, sha256HexUtf8 } from "../../../.
|
|
|
4
4
|
import { parseDigestB64u } from "../../../../shared-ts/src/utils/canonicalPrimitives.js";
|
|
5
5
|
import "../../../../shared-ts/src/utils/encoders.js";
|
|
6
6
|
import { buildWalletAuthMethodRecordV2 } from "../../../../shared-ts/src/utils/walletAuthMethodRecord.js";
|
|
7
|
+
import { failure } from "../../../../shared-ts/src/utils/failure.js";
|
|
7
8
|
import { consumeReservedRecoveryCode } from "../../../../shared-ts/src/wallet-recovery/recoveryCodeReservation.js";
|
|
8
9
|
import { hashEmailOtpOperationBinding } from "../../../domains/emailOtp/emailOtpSessionRouteHelpers.js";
|
|
9
10
|
import { EMAIL_OTP_CHANNEL, WALLET_EMAIL_OTP_ACTIONS, WALLET_EMAIL_OTP_UNLOCK_OPERATION } from "../../../../shared-ts/src/utils/emailOtpDomain.js";
|
|
@@ -129,24 +130,12 @@ var CloudflareD1WalletRecoveryGoogleEmailOtpService = class {
|
|
|
129
130
|
enrollment: attempt.targetEnrollment
|
|
130
131
|
};
|
|
131
132
|
const workerEphemeralPublicKey65B64u = nonEmpty(input.workerEphemeralPublicKey65B64u);
|
|
132
|
-
if (!workerEphemeralPublicKey65B64u) return
|
|
133
|
-
ok: false,
|
|
134
|
-
code: "invalid_body",
|
|
135
|
-
message: "Email OTP recovery factor release key is required"
|
|
136
|
-
};
|
|
133
|
+
if (!workerEphemeralPublicKey65B64u) return failure("invalid_body", "Email OTP recovery factor release key is required");
|
|
137
134
|
const enrollment = await this.enrollments.readEnrollment(String(attempt.walletId));
|
|
138
|
-
if (!enrollment || enrollment.orgId !== attempt.orgId || enrollment.providerUserId !== attempt.providerSubject || enrollment.verifiedEmail !== attempt.verifiedEmail || enrollment.enrollmentId !== attempt.targetEnrollment.enrollmentId || enrollment.enrollmentSealKeyVersion !== attempt.targetEnrollment.enrollmentSealKeyVersion) return
|
|
139
|
-
ok: false,
|
|
140
|
-
code: "recovery_conflict",
|
|
141
|
-
message: "Email OTP recovery enrollment changed after verification"
|
|
142
|
-
};
|
|
135
|
+
if (!enrollment || enrollment.orgId !== attempt.orgId || enrollment.providerUserId !== attempt.providerSubject || enrollment.verifiedEmail !== attempt.verifiedEmail || enrollment.enrollmentId !== attempt.targetEnrollment.enrollmentId || enrollment.enrollmentSealKeyVersion !== attempt.targetEnrollment.enrollmentSealKeyVersion) return failure("recovery_conflict", "Email OTP recovery enrollment changed after verification");
|
|
143
136
|
const unsealed = await this.serverSeal.removeEmailOtpServerSeal({ wrappedCiphertext: enrollment.serverSealedFactorCiphertextB64u });
|
|
144
137
|
if (!unsealed.ok) return unsealed;
|
|
145
|
-
if (unsealed.enrollmentSealKeyVersion !== enrollment.enrollmentSealKeyVersion) return
|
|
146
|
-
ok: false,
|
|
147
|
-
code: "recovery_conflict",
|
|
148
|
-
message: "Email OTP recovery enrollment seal changed after verification"
|
|
149
|
-
};
|
|
138
|
+
if (unsealed.enrollmentSealKeyVersion !== enrollment.enrollmentSealKeyVersion) return failure("recovery_conflict", "Email OTP recovery enrollment seal changed after verification");
|
|
150
139
|
const sealed = await sealEmailOtpFactorSecretForWorker({
|
|
151
140
|
factorSecret32B64u: unsealed.ciphertext,
|
|
152
141
|
workerEphemeralPublicKey65B64u,
|
|
@@ -464,18 +453,10 @@ async function replayGoogleEmailOtpRecovery(input) {
|
|
|
464
453
|
};
|
|
465
454
|
}
|
|
466
455
|
function parseGoogleIdentity(result) {
|
|
467
|
-
if (!result.ok || result.verified !== true) return
|
|
468
|
-
ok: false,
|
|
469
|
-
code: result.code || "not_verified",
|
|
470
|
-
message: result.message || "Google verification failed"
|
|
471
|
-
};
|
|
456
|
+
if (!result.ok || result.verified !== true) return failure(result.code || "not_verified", result.message || "Google verification failed");
|
|
472
457
|
const providerSubject = parseProviderSubject(result.providerSubject);
|
|
473
458
|
const email = parseVerifiedGoogleEmail(result.email);
|
|
474
|
-
if (!providerSubject.ok || !email.ok || result.emailVerified !== true) return
|
|
475
|
-
ok: false,
|
|
476
|
-
code: "provider_identity_mismatch",
|
|
477
|
-
message: "Google verification did not provide a verified identity email"
|
|
478
|
-
};
|
|
459
|
+
if (!providerSubject.ok || !email.ok || result.emailVerified !== true) return failure("provider_identity_mismatch", "Google verification did not provide a verified identity email");
|
|
479
460
|
return {
|
|
480
461
|
ok: true,
|
|
481
462
|
providerSubject: providerSubject.value,
|
|
@@ -484,27 +465,15 @@ function parseGoogleIdentity(result) {
|
|
|
484
465
|
}
|
|
485
466
|
function resolveTargetEnrollment(input) {
|
|
486
467
|
if (input.enrollment) {
|
|
487
|
-
if (input.enrollment.orgId !== input.orgId || input.enrollment.providerUserId !== input.identity.providerSubject || input.enrollment.verifiedEmail !== input.identity.verifiedEmail) return
|
|
488
|
-
|
|
489
|
-
code: "provider_identity_mismatch",
|
|
490
|
-
message: "Google identity does not match the wallet Email enrollment"
|
|
491
|
-
};
|
|
492
|
-
if (input.anchor.envelope.kind === "email_otp" && (input.anchor.envelope.enrollmentId !== input.enrollment.enrollmentId || input.anchor.envelope.enrollmentSealKeyVersion !== input.enrollment.enrollmentSealKeyVersion)) return {
|
|
493
|
-
ok: false,
|
|
494
|
-
code: "recovery_conflict",
|
|
495
|
-
message: "Wallet Email custody enrollment changed after preparation"
|
|
496
|
-
};
|
|
468
|
+
if (input.enrollment.orgId !== input.orgId || input.enrollment.providerUserId !== input.identity.providerSubject || input.enrollment.verifiedEmail !== input.identity.verifiedEmail) return failure("provider_identity_mismatch", "Google identity does not match the wallet Email enrollment");
|
|
469
|
+
if (input.anchor.envelope.kind === "email_otp" && (input.anchor.envelope.enrollmentId !== input.enrollment.enrollmentId || input.anchor.envelope.enrollmentSealKeyVersion !== input.enrollment.enrollmentSealKeyVersion)) return failure("recovery_conflict", "Wallet Email custody enrollment changed after preparation");
|
|
497
470
|
return {
|
|
498
471
|
kind: "existing",
|
|
499
472
|
enrollmentId: input.enrollment.enrollmentId,
|
|
500
473
|
enrollmentSealKeyVersion: input.enrollment.enrollmentSealKeyVersion
|
|
501
474
|
};
|
|
502
475
|
}
|
|
503
|
-
if (input.anchor.envelope.kind === "email_otp") return
|
|
504
|
-
ok: false,
|
|
505
|
-
code: "recovery_conflict",
|
|
506
|
-
message: "Wallet Email custody enrollment is missing after preparation"
|
|
507
|
-
};
|
|
476
|
+
if (input.anchor.envelope.kind === "email_otp") return failure("recovery_conflict", "Wallet Email custody enrollment is missing after preparation");
|
|
508
477
|
return {
|
|
509
478
|
kind: "create",
|
|
510
479
|
providerSubject: input.identity.providerSubject,
|
|
@@ -565,18 +534,10 @@ function nonEmpty(value) {
|
|
|
565
534
|
return typeof value === "string" && value.trim() ? value.trim() : null;
|
|
566
535
|
}
|
|
567
536
|
function recoveryAttemptUnavailable() {
|
|
568
|
-
return
|
|
569
|
-
ok: false,
|
|
570
|
-
code: "recovery_attempt_unavailable",
|
|
571
|
-
message: "Wallet recovery operation is unavailable"
|
|
572
|
-
};
|
|
537
|
+
return failure("recovery_attempt_unavailable", "Wallet recovery operation is unavailable");
|
|
573
538
|
}
|
|
574
539
|
function recoveryAttemptConflict() {
|
|
575
|
-
return
|
|
576
|
-
ok: false,
|
|
577
|
-
code: "recovery_conflict",
|
|
578
|
-
message: "Wallet recovery operation changed; retry recovery"
|
|
579
|
-
};
|
|
540
|
+
return failure("recovery_conflict", "Wallet recovery operation changed; retry recovery");
|
|
580
541
|
}
|
|
581
542
|
function recoveryFinalizationRefused(reason) {
|
|
582
543
|
return {
|
|
@@ -3,6 +3,7 @@ import { deriveEvmFamilySigningKeySlotId } from "../../../../shared-ts/src/signi
|
|
|
3
3
|
import { computeEcdsaDerivationRoleLocalRelayerKeyId, computeEcdsaDerivationRoleLocalThresholdKeyId, computeSdkEcdsaDerivationApplicationBindingDigestB64u, parseSdkEcdsaDerivationSigningRootId, parseSdkEcdsaDerivationSigningRootVersion, parseSdkEcdsaDerivationThresholdKeyId } from "../../../../shared-ts/src/threshold/ecdsaDerivationRoleLocalBootstrap.js";
|
|
4
4
|
import { buildRouterAbEcdsaDerivationActiveStateIdV1 } from "../../../../shared-ts/src/utils/routerAbEcdsaDerivation.js";
|
|
5
5
|
import { secureRandomBase64Url } from "../../../../shared-ts/src/utils/secureRandomId.js";
|
|
6
|
+
import { failure } from "../../../../shared-ts/src/utils/failure.js";
|
|
6
7
|
import "./d1RegistrationCeremonyRecords.js";
|
|
7
8
|
//#region src/router/cloudflare/d1/registration/d1EvmFamilyEcdsaRegistrationBranch.ts
|
|
8
9
|
const REGISTRATION_WALLET_SIGNING_SESSION_REMAINING_USES = 3;
|
|
@@ -13,28 +14,12 @@ function requireRegistrationRootShareEpoch(value) {
|
|
|
13
14
|
return parsed.value;
|
|
14
15
|
}
|
|
15
16
|
async function buildD1EvmFamilyEcdsaRegistrationPrepare(input) {
|
|
16
|
-
if (!input.chainTargets) return
|
|
17
|
-
|
|
18
|
-
code: "invalid_body",
|
|
19
|
-
message: "ECDSA registration contains an invalid chain target"
|
|
20
|
-
};
|
|
21
|
-
if (input.chainTargets.length === 0) return {
|
|
22
|
-
ok: false,
|
|
23
|
-
code: "invalid_body",
|
|
24
|
-
message: "ECDSA registration requires at least one chain target"
|
|
25
|
-
};
|
|
17
|
+
if (!input.chainTargets) return failure("invalid_body", "ECDSA registration contains an invalid chain target");
|
|
18
|
+
if (input.chainTargets.length === 0) return failure("invalid_body", "ECDSA registration requires at least one chain target");
|
|
26
19
|
const firstChainTarget = input.chainTargets[0];
|
|
27
|
-
if (!firstChainTarget) return
|
|
28
|
-
ok: false,
|
|
29
|
-
code: "invalid_body",
|
|
30
|
-
message: "ECDSA registration requires at least one chain target"
|
|
31
|
-
};
|
|
20
|
+
if (!firstChainTarget) return failure("invalid_body", "ECDSA registration requires at least one chain target");
|
|
32
21
|
const chainTargets = [firstChainTarget, ...input.chainTargets.slice(1)];
|
|
33
|
-
if (input.participantIds.length !== 2 || input.participantIds[0] !== 1 || input.participantIds[1] !== 2) return
|
|
34
|
-
ok: false,
|
|
35
|
-
code: "invalid_body",
|
|
36
|
-
message: "ECDSA registration requires participant pair [1, 2]"
|
|
37
|
-
};
|
|
22
|
+
if (input.participantIds.length !== 2 || input.participantIds[0] !== 1 || input.participantIds[1] !== 2) return failure("invalid_body", "ECDSA registration requires participant pair [1, 2]");
|
|
38
23
|
const evmFamilySigningKeySlotId = deriveEvmFamilySigningKeySlotId({
|
|
39
24
|
walletId: input.walletId,
|
|
40
25
|
signingRootId: input.signingRootId,
|
|
@@ -64,14 +64,14 @@ var D1RegistrationCeremonyRecordStore = class {
|
|
|
64
64
|
async updateExpected(input) {
|
|
65
65
|
const key = this.normalizeKey(input.scope, input.id);
|
|
66
66
|
const current = await this.get(input.scope, input.id);
|
|
67
|
-
if (!current ||
|
|
67
|
+
if (!current || alphabetizeStringify(current.value) !== alphabetizeStringify(input.expected)) throw conflict("Registration ceremony record changed before update");
|
|
68
68
|
const next = prepareValue(input.next, input.expiresAtMs);
|
|
69
69
|
if (changes(await this.database.prepare(UPDATE_EXPECTED_VERSION_SQL).bind(...this.bindKey(key), next.recordJson, next.expiresAtMs, Date.now(), current.version).run()) !== 1) throw conflict("Registration ceremony record changed during update");
|
|
70
70
|
}
|
|
71
71
|
async claimEcdsaRegistrationBranch(input) {
|
|
72
72
|
const key = this.normalizeKey(input.scope, input.id);
|
|
73
73
|
const strictRegistrationBindingJson = input.binding.kind === "strict_registration" ? normalizeKeyPart(input.binding.strictRegistrationBindingJson, "strictRegistrationBindingJson", 16384) : "";
|
|
74
|
-
const patchJson =
|
|
74
|
+
const patchJson = alphabetizeStringify(input.patch);
|
|
75
75
|
const nowMs = Date.now();
|
|
76
76
|
const row = await this.database.prepare(`WITH target(branch_index) AS (
|
|
77
77
|
SELECT CAST(branch.key AS INTEGER)
|
|
@@ -236,7 +236,7 @@ function prepareValue(value, expiresAtMs) {
|
|
|
236
236
|
if (!Number.isSafeInteger(normalizedExpiresAtMs) || normalizedExpiresAtMs <= Date.now()) throw new Error("Registration ceremony record expiry must be in the future");
|
|
237
237
|
return {
|
|
238
238
|
value,
|
|
239
|
-
recordJson:
|
|
239
|
+
recordJson: alphabetizeStringify(value),
|
|
240
240
|
expiresAtMs: normalizedExpiresAtMs
|
|
241
241
|
};
|
|
242
242
|
}
|
|
@@ -259,10 +259,7 @@ function parseStoredRow(row) {
|
|
|
259
259
|
};
|
|
260
260
|
}
|
|
261
261
|
function recordsMatch(current, next) {
|
|
262
|
-
return current.expiresAtMs === next.expiresAtMs &&
|
|
263
|
-
}
|
|
264
|
-
function stableJson(value) {
|
|
265
|
-
return alphabetizeStringify(value);
|
|
262
|
+
return current.expiresAtMs === next.expiresAtMs && alphabetizeStringify(current.value) === next.recordJson;
|
|
266
263
|
}
|
|
267
264
|
function changes(result) {
|
|
268
265
|
if (!result.success) throw new Error("Registration ceremony D1 mutation failed");
|
|
@@ -16,8 +16,9 @@ import { parseWalletAuthorityV1 } from "../../../../shared-ts/src/authorization/
|
|
|
16
16
|
import { parseWebAuthnAuthenticatorDeviceInfo, unknownWebAuthnAuthenticatorDeviceInfo } from "../../../../shared-ts/src/utils/webauthnDeviceInfo.js";
|
|
17
17
|
import { secureRandomBase64Url } from "../../../../shared-ts/src/utils/secureRandomId.js";
|
|
18
18
|
import { parseRouterAbEd25519NormalSigningState } from "../../../../shared-ts/src/utils/signingSessionSeal.js";
|
|
19
|
-
import { thresholdEcdsaChainTargetFromValue, thresholdEcdsaChainTargetKey } from "../../../../core/thresholdEcdsaChainTarget.js";
|
|
20
19
|
import { parseEcdsaDerivationPublicIdentity, parseThresholdEd25519AuthorityScope, thresholdEd25519AuthorityScopeFromWalletAuthAuthority, thresholdEd25519AuthorityScopesMatch } from "../../../../core/ThresholdService/validation.js";
|
|
20
|
+
import { thresholdEcdsaChainTargetKey } from "../../../../shared-ts/src/utils/thresholdEcdsaChainTarget.js";
|
|
21
|
+
import { thresholdEcdsaChainTargetFromValue } from "../../../../core/thresholdEcdsaChainTarget.js";
|
|
21
22
|
import { buildWalletEcdsaSignerRecord, parseWalletEd25519SignerRecord } from "../../../../core/d1WalletStore.js";
|
|
22
23
|
import { createServerAllocatedWalletId, nearEd25519SigningKeyIdFromString, walletIdFromString } from "../../../../shared-ts/src/utils/registrationIds.js";
|
|
23
24
|
import { registrationPreparationIdFromString } from "../../../../core/types.js";
|
|
@@ -3,6 +3,7 @@ import { normalizeOptionalTrimmedString } from "../../../../shared-ts/src/utils/
|
|
|
3
3
|
import "../../../../shared-ts/src/utils/validation.js";
|
|
4
4
|
import { normalizeAddAuthMethodInput } from "../../../../shared-ts/src/utils/registrationAuthMethodInput.js";
|
|
5
5
|
import { secureRandomBase64Url } from "../../../../shared-ts/src/utils/secureRandomId.js";
|
|
6
|
+
import { failure } from "../../../../shared-ts/src/utils/failure.js";
|
|
6
7
|
import { thresholdEcdsaChainTargetFromValue } from "../../../../core/thresholdEcdsaChainTarget.js";
|
|
7
8
|
import { normalizeAddSignerSelection } from "../../../../shared-ts/src/utils/registrationSignerPlan.js";
|
|
8
9
|
import { addAuthMethodIntentGrantFromString, addSignerIntentGrantFromString, computeAddAuthMethodIntentDigestB64u, computeAddSignerIntentDigestB64u } from "../../../../shared-ts/src/utils/registrationIntent.js";
|
|
@@ -19,11 +20,7 @@ var CloudflareD1RegistrationIntentService = class {
|
|
|
19
20
|
try {
|
|
20
21
|
const store = this.getRegistrationCeremonyIntentStore();
|
|
21
22
|
const walletId = parseWalletIdForIntent(input.command.subject.walletId);
|
|
22
|
-
if (!walletId) return
|
|
23
|
-
ok: false,
|
|
24
|
-
code: "invalid_body",
|
|
25
|
-
message: "walletId is required"
|
|
26
|
-
};
|
|
23
|
+
if (!walletId) return failure("invalid_body", "walletId is required");
|
|
27
24
|
const signerSelection = normalizeAddSignerSelection(input.command.signerSelection, { normalizeEcdsaChainTarget: thresholdEcdsaChainTargetFromValue });
|
|
28
25
|
if (!signerSelection.ok) return signerSelection;
|
|
29
26
|
const runtimePolicyScope = input.runtimePolicyScope || inferRuntimePolicyScopeFromSigningRoot(input);
|
|
@@ -52,35 +49,19 @@ var CloudflareD1RegistrationIntentService = class {
|
|
|
52
49
|
expiresAtMs
|
|
53
50
|
};
|
|
54
51
|
} catch (error) {
|
|
55
|
-
return
|
|
56
|
-
ok: false,
|
|
57
|
-
code: "internal",
|
|
58
|
-
message: errorMessage(error) || "Failed to create add-signer intent"
|
|
59
|
-
};
|
|
52
|
+
return failure("internal", errorMessage(error) || "Failed to create add-signer intent");
|
|
60
53
|
}
|
|
61
54
|
}
|
|
62
55
|
async createAddAuthMethodIntent(input) {
|
|
63
56
|
try {
|
|
64
57
|
const store = this.getRegistrationCeremonyIntentStore();
|
|
65
58
|
const walletId = parseWalletIdForIntent(input.command.subject.walletId);
|
|
66
|
-
if (!walletId) return
|
|
67
|
-
ok: false,
|
|
68
|
-
code: "invalid_body",
|
|
69
|
-
message: "walletId is required"
|
|
70
|
-
};
|
|
59
|
+
if (!walletId) return failure("invalid_body", "walletId is required");
|
|
71
60
|
const authMethod = normalizeAddAuthMethodInput(input.command.authMethod);
|
|
72
|
-
if (!authMethod) return
|
|
73
|
-
ok: false,
|
|
74
|
-
code: "invalid_body",
|
|
75
|
-
message: "authMethod is required"
|
|
76
|
-
};
|
|
61
|
+
if (!authMethod) return failure("invalid_body", "authMethod is required");
|
|
77
62
|
const runtimePolicyScope = input.runtimePolicyScope || inferRuntimePolicyScopeFromSigningRoot(input);
|
|
78
63
|
const targetWalletAuthMethodId = parseWalletAuthMethodId(`wallet-auth-method:${secureRandomBase64Url(32)}`);
|
|
79
|
-
if (!targetWalletAuthMethodId.ok) return
|
|
80
|
-
ok: false,
|
|
81
|
-
code: "internal",
|
|
82
|
-
message: "Failed to allocate a target auth-method id"
|
|
83
|
-
};
|
|
64
|
+
if (!targetWalletAuthMethodId.ok) return failure("internal", "Failed to allocate a target auth-method id");
|
|
84
65
|
const intent = buildAddAuthMethodIntent({
|
|
85
66
|
walletId,
|
|
86
67
|
authMethod,
|
|
@@ -108,11 +89,7 @@ var CloudflareD1RegistrationIntentService = class {
|
|
|
108
89
|
expiresAtMs
|
|
109
90
|
};
|
|
110
91
|
} catch (error) {
|
|
111
|
-
return
|
|
112
|
-
ok: false,
|
|
113
|
-
code: "internal",
|
|
114
|
-
message: errorMessage(error) || "Failed to create add-auth-method intent"
|
|
115
|
-
};
|
|
92
|
+
return failure("internal", errorMessage(error) || "Failed to create add-auth-method intent");
|
|
116
93
|
}
|
|
117
94
|
}
|
|
118
95
|
};
|
|
@@ -1078,38 +1078,43 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
1078
1078
|
async resolveEcdsaMaterialActivation(input) {
|
|
1079
1079
|
try {
|
|
1080
1080
|
const walletId = walletIdFromString(input.walletId);
|
|
1081
|
-
const
|
|
1082
|
-
|
|
1081
|
+
const canonical = await this.getWalletStore().readEcdsaSignerMaterialSnapshot({
|
|
1082
|
+
source: input.source,
|
|
1083
1083
|
walletId,
|
|
1084
1084
|
materialActivation: input.materialActivation
|
|
1085
1085
|
});
|
|
1086
|
-
if (
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1086
|
+
if (canonical) {
|
|
1087
|
+
const { signer, readSnapshot } = canonical;
|
|
1088
|
+
return {
|
|
1089
|
+
readSnapshot,
|
|
1090
|
+
ok: true,
|
|
1091
|
+
materialActivation: signer.walletKey.publicCapability.material_activation,
|
|
1092
|
+
keyHandle: signer.walletKey.keyHandle,
|
|
1093
|
+
relayerKeyId: signer.walletKey.relayerKeyId,
|
|
1094
|
+
participantIds: signer.walletKey.participantIds,
|
|
1095
|
+
runtimePolicyScope: signer.runtimePolicyScope,
|
|
1096
|
+
routerAbEcdsaDerivationNormalSigning: buildPostRegistrationEcdsaNormalSigningState({
|
|
1097
|
+
walletKey: signer.walletKey,
|
|
1098
|
+
publicCapability: signer.walletKey.publicCapability
|
|
1099
|
+
})
|
|
1100
|
+
};
|
|
1101
|
+
}
|
|
1098
1102
|
const linkedDeviceReader = this.getLinkedDeviceEd25519AuthorityReader();
|
|
1099
|
-
const
|
|
1103
|
+
const custodySnapshot = linkedDeviceReader ? await linkedDeviceReader.readInstalledEcdsaCustodySnapshotV1({
|
|
1104
|
+
source: input.source,
|
|
1100
1105
|
walletId,
|
|
1101
1106
|
materialActivation: routerAbMpcMaterialActivationRefFromWire(input.materialActivation)
|
|
1102
|
-
}) :
|
|
1103
|
-
const projection =
|
|
1104
|
-
if (!projection) return {
|
|
1107
|
+
}) : null;
|
|
1108
|
+
const projection = custodySnapshot?.chain[0];
|
|
1109
|
+
if (!custodySnapshot || !projection) return {
|
|
1105
1110
|
ok: false,
|
|
1106
1111
|
code: "not_found",
|
|
1107
1112
|
message: "ECDSA material activation is not active for this wallet"
|
|
1108
1113
|
};
|
|
1109
|
-
const
|
|
1114
|
+
const { chain, signers } = custodySnapshot;
|
|
1110
1115
|
let matchingSourceSigners = [];
|
|
1111
|
-
for (const custodySource of
|
|
1112
|
-
matchingSourceSigners =
|
|
1116
|
+
for (const custodySource of chain) {
|
|
1117
|
+
matchingSourceSigners = signers.filter(linkedEcdsaProjectionMatchesSigner.bind(null, custodySource));
|
|
1113
1118
|
if (matchingSourceSigners.length > 0) break;
|
|
1114
1119
|
}
|
|
1115
1120
|
const canonicalSigner = matchingSourceSigners[0];
|
|
@@ -1125,6 +1130,7 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
1125
1130
|
};
|
|
1126
1131
|
return {
|
|
1127
1132
|
ok: true,
|
|
1133
|
+
readSnapshot: custodySnapshot.readSnapshot,
|
|
1128
1134
|
materialActivation: routerAbMpcMaterialActivationRefToWire(projection.materialActivation),
|
|
1129
1135
|
keyHandle: canonicalSigner.walletKey.keyHandle,
|
|
1130
1136
|
relayerKeyId: canonicalSigner.walletKey.relayerKeyId,
|
|
@@ -1174,7 +1180,11 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
1174
1180
|
}
|
|
1175
1181
|
}
|
|
1176
1182
|
async resolveActiveEcdsaTenantRoot(input) {
|
|
1177
|
-
const activeMaterial = await this.resolveEcdsaMaterialActivation(
|
|
1183
|
+
const activeMaterial = await this.resolveEcdsaMaterialActivation({
|
|
1184
|
+
walletId: input.walletId,
|
|
1185
|
+
materialActivation: input.materialActivation,
|
|
1186
|
+
source: { kind: "database" }
|
|
1187
|
+
});
|
|
1178
1188
|
if (!activeMaterial.ok) return activeMaterial;
|
|
1179
1189
|
const identity = resolveTenantRootIdentityV1({
|
|
1180
1190
|
kind: "ecdsa_b5_active_material",
|
package/dist/esm/router/cloudflare/d1/registration/walletRegistrationSessionCommitReceipt.js
CHANGED
|
@@ -5,6 +5,7 @@ import { parseWalletAuthAuthority } from "../../../../shared-ts/src/utils/wallet
|
|
|
5
5
|
import { parseWalletAuthMethodRecordV2 } from "../../../../shared-ts/src/utils/walletAuthMethodRecord.js";
|
|
6
6
|
import { parseWalletAuthorityV1 } from "../../../../shared-ts/src/authorization/walletAuthority.js";
|
|
7
7
|
import { parseSessionOrigin } from "../../../../authorization/domain.js";
|
|
8
|
+
import { hasExactKeys } from "../../../../shared-ts/src/utils/exactKeys.js";
|
|
8
9
|
import { parseWalletCustodyRegistrationOutcome } from "../../../../shared-ts/src/passkey-custody/ceremonyCommitPayload.js";
|
|
9
10
|
import "../../../../shared-ts/src/passkey-custody/index.js";
|
|
10
11
|
//#region src/router/cloudflare/d1/registration/walletRegistrationSessionCommitReceipt.ts
|
|
@@ -466,10 +467,6 @@ function parsePositiveSafeInteger(value) {
|
|
|
466
467
|
function parseNonNegativeSafeInteger(value) {
|
|
467
468
|
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : null;
|
|
468
469
|
}
|
|
469
|
-
function hasExactKeys(record, expected) {
|
|
470
|
-
const actual = Object.keys(record);
|
|
471
|
-
return actual.length === expected.length && expected.every((key) => actual.includes(key));
|
|
472
|
-
}
|
|
473
470
|
function containsPersistedRegistrationCredential(value) {
|
|
474
471
|
if (Array.isArray(value)) return value.some(containsPersistedRegistrationCredential);
|
|
475
472
|
if (value === null || typeof value !== "object") return false;
|