@seams/wallet-server 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +8 -0
- package/artifact-manifest.json +464 -0
- package/cloudflare-router-ab/build/deriver-a/index.js +2 -0
- package/cloudflare-router-ab/build/deriver-a/index_bg.wasm +0 -0
- package/cloudflare-router-ab/build/deriver-a/package.json +16 -0
- package/cloudflare-router-ab/build/deriver-a/worker/shim.mjs +4 -0
- package/cloudflare-router-ab/build/deriver-b/index.js +2 -0
- package/cloudflare-router-ab/build/deriver-b/index_bg.wasm +0 -0
- package/cloudflare-router-ab/build/deriver-b/package.json +16 -0
- package/cloudflare-router-ab/build/deriver-b/worker/shim.mjs +4 -0
- package/cloudflare-router-ab/build/local-tools/darwin-arm64/router_ab_local_init +0 -0
- package/cloudflare-router-ab/build/router/index.js +2 -0
- package/cloudflare-router-ab/build/router/index_bg.wasm +0 -0
- package/cloudflare-router-ab/build/router/package.json +16 -0
- package/cloudflare-router-ab/build/router/worker/shim.mjs +4 -0
- package/cloudflare-router-ab/build/signing-worker/index.js +2 -0
- package/cloudflare-router-ab/build/signing-worker/index_bg.wasm +0 -0
- package/cloudflare-router-ab/build/signing-worker/package.json +16 -0
- package/cloudflare-router-ab/build/signing-worker/worker/shim.mjs +4 -0
- package/cloudflare-router-ab/build/tenant-root-control-plane/index.js +2 -0
- package/cloudflare-router-ab/build/tenant-root-control-plane/index_bg.wasm +0 -0
- package/cloudflare-router-ab/build/tenant-root-control-plane/package.json +16 -0
- package/cloudflare-router-ab/build/tenant-root-control-plane/worker/shim.mjs +4 -0
- package/cloudflare-router-ab/env/tenant-root-control-plane.local.example +6 -0
- package/cloudflare-router-ab/migrations/deriver-a/0001_role_private_storage.sql +14 -0
- package/cloudflare-router-ab/migrations/deriver-a/0002_tenant_root_role_shares.sql +32 -0
- package/cloudflare-router-ab/migrations/deriver-a/0003_tenant_root_command_replays.sql +76 -0
- package/cloudflare-router-ab/migrations/deriver-a/0004_tenant_root_creation_admission.sql +7 -0
- package/cloudflare-router-ab/migrations/deriver-a/0005_tenant_root_refresh_state.sql +15 -0
- package/cloudflare-router-ab/migrations/deriver-a/0006_tenant_root_restore_import_keys.sql +119 -0
- package/cloudflare-router-ab/migrations/deriver-a/0007_tenant_root_restore_refresh_attempts.sql +103 -0
- package/cloudflare-router-ab/migrations/deriver-a/0008_tenant_root_restore_promotion.sql +40 -0
- package/cloudflare-router-ab/migrations/deriver-a/0009_tenant_root_restore_preactivation_cleanup.sql +8 -0
- package/cloudflare-router-ab/migrations/deriver-a/0010_tenant_root_recovery_attempts.sql +26 -0
- package/cloudflare-router-ab/migrations/deriver-a/0011_tenant_root_source_retirement.sql +100 -0
- package/cloudflare-router-ab/migrations/deriver-b/0001_role_private_storage.sql +14 -0
- package/cloudflare-router-ab/migrations/deriver-b/0002_tenant_root_role_shares.sql +32 -0
- package/cloudflare-router-ab/migrations/deriver-b/0003_tenant_root_command_replays.sql +76 -0
- package/cloudflare-router-ab/migrations/deriver-b/0004_tenant_root_creation_admission.sql +7 -0
- package/cloudflare-router-ab/migrations/deriver-b/0005_tenant_root_refresh_state.sql +15 -0
- package/cloudflare-router-ab/migrations/deriver-b/0006_tenant_root_restore_import_keys.sql +119 -0
- package/cloudflare-router-ab/migrations/deriver-b/0007_tenant_root_restore_refresh_attempts.sql +103 -0
- package/cloudflare-router-ab/migrations/deriver-b/0008_tenant_root_restore_promotion.sql +40 -0
- package/cloudflare-router-ab/migrations/deriver-b/0009_tenant_root_restore_preactivation_cleanup.sql +8 -0
- package/cloudflare-router-ab/migrations/deriver-b/0010_tenant_root_recovery_attempts.sql +26 -0
- package/cloudflare-router-ab/migrations/deriver-b/0011_tenant_root_source_retirement.sql +100 -0
- package/cloudflare-router-ab/migrations/signing-worker/0001_private_storage.sql +67 -0
- package/cloudflare-router-ab/migrations/signing-worker/0002_activation_revocation_fences.sql +3 -0
- package/cloudflare-router-ab/scripts/bootstrap-local-tenant-root.mjs +182 -0
- package/cloudflare-router-ab/scripts/initialize-local-wallet.mjs +17 -0
- package/cloudflare-router-ab/scripts/local-key-material.mjs +29 -0
- package/cloudflare-router-ab/scripts/prepare-local-runtime-config.mjs +1110 -0
- package/cloudflare-router-ab/scripts/start-local-role-workers.mjs +333 -0
- package/cloudflare-router-ab/scripts/start-local-wallet-system.mjs +427 -0
- package/cloudflare-router-ab/wrangler.deriver-a.toml +123 -0
- package/cloudflare-router-ab/wrangler.deriver-b.toml +123 -0
- package/cloudflare-router-ab/wrangler.router.toml +126 -0
- package/cloudflare-router-ab/wrangler.signing-worker.toml +86 -0
- package/cloudflare-router-ab/wrangler.tenant-root-control-plane.toml +56 -0
- package/dist/esm/authorization/capabilityPolicy.js +96 -0
- package/dist/esm/authorization/domain.js +434 -0
- package/dist/esm/authorization/factorEvidence.js +405 -0
- package/dist/esm/authorization/service.js +319 -0
- package/dist/esm/authorization/vaultProxyUse.js +295 -0
- package/dist/esm/cloud-host.js +126 -0
- package/dist/esm/core/AuthService.js +2 -0
- package/dist/esm/core/EmailOtpRecords.js +361 -0
- package/dist/esm/core/EmailOtpStores.js +1460 -0
- package/dist/esm/core/IdentityStore.js +617 -0
- package/dist/esm/core/NearPublicKeyStore.js +242 -0
- package/dist/esm/core/RegistrationCeremonyStore.js +2101 -0
- package/dist/esm/core/SessionService.js +255 -0
- package/dist/esm/core/ThresholdService/config.js +111 -0
- package/dist/esm/core/ThresholdService/ecdsaClientRootProof.js +27 -0
- package/dist/esm/core/ThresholdService/evmCryptoWasm.js +167 -0
- package/dist/esm/core/ThresholdService/index.js +4 -0
- package/dist/esm/core/ThresholdService/kv.js +368 -0
- package/dist/esm/core/ThresholdService/routerAb/ecdsaDerivationPoolFillHandlers.js +360 -0
- package/dist/esm/core/ThresholdService/routerAb/ecdsaDerivationPoolFillLiveSession.js +282 -0
- package/dist/esm/core/ThresholdService/routerAb/ecdsaDerivationPresignBridge.js +272 -0
- package/dist/esm/core/ThresholdService/routerAb/internalServiceHttp.js +57 -0
- package/dist/esm/core/ThresholdService/routerAbEcdsaSigningWorkerWasm.js +115 -0
- package/dist/esm/core/ThresholdService/routerAbNormalSigningPolicy.js +31 -0
- package/dist/esm/core/ThresholdService/secureRandomId.js +9 -0
- package/dist/esm/core/ThresholdService/stores/CloudflareDurableObjectStore.js +603 -0
- package/dist/esm/core/ThresholdService/stores/EcdsaSigningStore.js +422 -0
- package/dist/esm/core/ThresholdService/stores/KeyStore.js +140 -0
- package/dist/esm/core/ThresholdService/stores/SessionStore.js +437 -0
- package/dist/esm/core/ThresholdService/stores/StoreConfig.js +13 -0
- package/dist/esm/core/ThresholdService/stores/WalletSessionStore.js +722 -0
- package/dist/esm/core/ThresholdService/validation.js +718 -0
- package/dist/esm/core/WalletAuthMethodStore.js +180 -0
- package/dist/esm/core/WalletStore.js +495 -0
- package/dist/esm/core/WebAuthnAuthenticatorStore.js +485 -0
- package/dist/esm/core/WebAuthnCredentialBindingStore.js +594 -0
- package/dist/esm/core/WebAuthnLoginChallengeStore.js +432 -0
- package/dist/esm/core/WebAuthnSyncChallengeStore.js +434 -0
- package/dist/esm/core/authService/AuthService.js +611 -0
- package/dist/esm/core/authService/bytes.js +22 -0
- package/dist/esm/core/authService/configValues.js +15 -0
- package/dist/esm/core/authService/emailOtpChallengeOperations.js +126 -0
- package/dist/esm/core/authService/emailOtpChallengeProof.js +214 -0
- package/dist/esm/core/authService/emailOtpChallengeVerification.js +335 -0
- package/dist/esm/core/authService/emailOtpChallenges.js +260 -0
- package/dist/esm/core/authService/emailOtpConfig.js +231 -0
- package/dist/esm/core/authService/emailOtpDelivery.js +169 -0
- package/dist/esm/core/authService/emailOtpEnrollment.js +141 -0
- package/dist/esm/core/authService/emailOtpGrant.js +74 -0
- package/dist/esm/core/authService/emailOtpRegistrationEnrollment.js +322 -0
- package/dist/esm/core/authService/emailOtpSeal.js +78 -0
- package/dist/esm/core/authService/emailOtpUnlock.js +264 -0
- package/dist/esm/core/authService/githubOAuth.js +140 -0
- package/dist/esm/core/authService/googleEmailOtpErrors.js +6 -0
- package/dist/esm/core/authService/googleEmailOtpOperations.js +141 -0
- package/dist/esm/core/authService/googleEmailOtpRegistration.js +674 -0
- package/dist/esm/core/authService/identity.js +57 -0
- package/dist/esm/core/authService/identityOperations.js +32 -0
- package/dist/esm/core/authService/nearAccountOperations.js +229 -0
- package/dist/esm/core/authService/nearPrivateKeySigning.js +110 -0
- package/dist/esm/core/authService/nearPublicKeyMetadata.js +127 -0
- package/dist/esm/core/authService/nearTransactions.js +139 -0
- package/dist/esm/core/authService/oidcVerification.js +262 -0
- package/dist/esm/core/authService/portableCrypto.js +19 -0
- package/dist/esm/core/authService/rateLimits.js +117 -0
- package/dist/esm/core/authService/record.js +8 -0
- package/dist/esm/core/authService/registrationThresholdHelpers.js +131 -0
- package/dist/esm/core/authService/runtime.js +45 -0
- package/dist/esm/core/authService/signerWasmUrls.js +20 -0
- package/dist/esm/core/authService/storeRegistry.js +113 -0
- package/dist/esm/core/authService/thresholdEcdsaKeyInventory.js +146 -0
- package/dist/esm/core/authService/thresholdRuntimePolicy.js +19 -0
- package/dist/esm/core/authService/thresholdStoreSummary.js +32 -0
- package/dist/esm/core/authService/walletRegistrationPlanning.js +49 -0
- package/dist/esm/core/authService/wasm.js +78 -0
- package/dist/esm/core/authService/webauthn.js +746 -0
- package/dist/esm/core/authService/webauthnAuthority.js +17 -0
- package/dist/esm/core/authService/webauthnOidcHelpers.js +91 -0
- package/dist/esm/core/authService/webauthnWalletBinding.js +157 -0
- package/dist/esm/core/config.js +110 -0
- package/dist/esm/core/d1IdentityStore.js +340 -0
- package/dist/esm/core/d1WalletAuthMethodStore.js +768 -0
- package/dist/esm/core/d1WalletStore.js +724 -0
- package/dist/esm/core/defaultConfigsServer.js +9 -0
- package/dist/esm/core/deviceLinking/index.js +5 -0
- package/dist/esm/core/deviceLinking/linkedDeviceEd25519ExportRoot.js +0 -0
- package/dist/esm/core/deviceLinking/linkedDeviceEmailOtpGrant.js +211 -0
- package/dist/esm/core/deviceLinking/linkedDeviceManagement.js +279 -0
- package/dist/esm/core/deviceLinking/linkedDeviceSession.js +1419 -0
- package/dist/esm/core/deviceLinking/requestProof.js +172 -0
- package/dist/esm/core/errors.js +54 -0
- package/dist/esm/core/hostedAccountIds.js +225 -0
- package/dist/esm/core/keyMaterialBrands.js +58 -0
- package/dist/esm/core/logger.js +39 -0
- package/dist/esm/core/nearKeys.js +20 -0
- package/dist/esm/core/nearRelayerAccountProvisioning.js +713 -0
- package/dist/esm/core/nearSignerWasmRuntime.js +87 -0
- package/dist/esm/core/registrationContracts.js +2 -0
- package/dist/esm/core/routerAbSigning/RouterAbEcdsaPresignRuntime.js +88 -0
- package/dist/esm/core/routerAbSigning/RouterAbNormalSigningRuntime.js +101 -0
- package/dist/esm/core/routerAbSigning/createCloudflareDurableObjectRouterAbSigningRuntimes.js +39 -0
- package/dist/esm/core/routerAbSigning/createRouterAbSigningRuntimes.js +91 -0
- package/dist/esm/core/rpcClients/near/NearClient.js +389 -0
- package/dist/esm/core/sessionValidation.js +0 -0
- package/dist/esm/core/signingLanes/LaneAggregateRevocationApplicationService.js +86 -0
- package/dist/esm/core/signingLanes/LaneEffectJournalStore.js +0 -0
- package/dist/esm/core/signingLanes/LaneEnrollmentActivation.js +324 -0
- package/dist/esm/core/signingLanes/LaneEnrollmentRevocation.js +173 -0
- package/dist/esm/core/signingLanes/LaneLifecycleApplicationService.js +200 -0
- package/dist/esm/core/signingLanes/LaneLifecycleStore.js +24 -0
- package/dist/esm/core/signingLanes/SigningLaneStore.js +0 -0
- package/dist/esm/core/signingLanes/WalletExecutionLaneProjection.js +296 -0
- package/dist/esm/core/signingLanes/WalletKeyStore.js +0 -0
- package/dist/esm/core/signingLanes/ecdsaServerRetirement.js +78 -0
- package/dist/esm/core/signingLanes/ed25519ServerRetirement.js +71 -0
- package/dist/esm/core/signingLanes/index.js +8 -0
- package/dist/esm/core/signingLanes/signingWorkerLaneMaterialIdentity.js +0 -0
- package/dist/esm/core/signingMaterial/ordinaryInactiveSignerMaterialReservation.js +305 -0
- package/dist/esm/core/threeRouteRegistrationContracts.js +5 -0
- package/dist/esm/core/thresholdEcdsaChainTarget.js +49 -0
- package/dist/esm/core/types.js +8 -0
- package/dist/esm/core/utils.js +14 -0
- package/dist/esm/delegateAction/index.js +136 -0
- package/dist/esm/hosted-wallet-gateway-worker.js +18 -0
- package/dist/esm/hosted-wallet-gateway.js +701 -0
- package/dist/esm/index.js +53 -0
- package/dist/esm/local-hosted-wallet-gateway-worker.js +23 -0
- package/dist/esm/node_modules/@near-js/types/lib/esm/provider/response.js +17 -0
- package/dist/esm/router/auth/authRequestValidation.js +264 -0
- package/dist/esm/router/auth/commonRouterUtils.js +305 -0
- package/dist/esm/router/auth/routerApiCredentialAuth.js +91 -0
- package/dist/esm/router/auth/routerApiKeyAuth.js +63 -0
- package/dist/esm/router/auth/walletSessionFailure.js +49 -0
- package/dist/esm/router/auth/webAuthnCredentialCodecs.js +107 -0
- package/dist/esm/router/cloudflare/d1/auth/d1RouterApiAuthBoundary.js +84 -0
- package/dist/esm/router/cloudflare/d1/auth/d1RouterApiAuthConfig.js +321 -0
- package/dist/esm/router/cloudflare/d1/auth/d1RouterApiAuthService.js +1581 -0
- package/dist/esm/router/cloudflare/d1/authorization/d1AuthorizationStore.js +1820 -0
- package/dist/esm/router/cloudflare/d1/authorization/d1VaultProxyStore.js +122 -0
- package/dist/esm/router/cloudflare/d1/authorization/walletSessionAuthorityProjection.js +119 -0
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceAuthorityInstallService.js +1831 -0
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceEd25519ExportRootStore.js +118 -0
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceEmailOtpGrantStore.js +81 -0
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceEmailOtpTargetFactor.js +539 -0
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceManagementService.js +92 -0
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceOwnerAuthorizationProvider.js +560 -0
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceRequestProofNonceStore.js +136 -0
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceRouteService.js +95 -0
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceSessionRecords.js +91 -0
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceSessionService.js +15 -0
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceSessionStore.js +732 -0
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceSourceContributionPreparationPlanner.js +195 -0
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceTargetAuthenticatorStore.js +100 -0
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceTargetCredentialProvider.js +867 -0
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceTargetPlanner.js +169 -0
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceVerifiedLinkBuilder.js +255 -0
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceVerifiedLinkSourceReader.js +128 -0
- package/dist/esm/router/cloudflare/d1/deviceLinking/index.js +15 -0
- package/dist/esm/router/cloudflare/d1/ed25519Yao/d1Ed25519YaoCapabilityPersistence.js +311 -0
- package/dist/esm/router/cloudflare/d1/ed25519Yao/d1Ed25519YaoProductRegistrationPartitionedStateStore.js +21 -0
- package/dist/esm/router/cloudflare/d1/ed25519Yao/d1Ed25519YaoWalletSigner.js +65 -0
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeIssuer.js +216 -0
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeService.js +326 -0
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeStore.js +346 -0
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeVerifier.js +495 -0
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpDeliveryRuntime.js +157 -0
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpEnrollmentStore.js +248 -0
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpGrantStore.js +66 -0
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpRateLimitStore.js +76 -0
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpRecords.js +539 -0
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpRecoveryService.js +404 -0
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpRegistrationEnrollmentFinalizer.js +200 -0
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpServerSealRuntime.js +84 -0
- package/dist/esm/router/cloudflare/d1/emailOtp/d1GoogleEmailOtpRegistrationAttemptStore.js +217 -0
- package/dist/esm/router/cloudflare/d1/emailOtp/d1GoogleEmailOtpRegistrationRecords.js +485 -0
- package/dist/esm/router/cloudflare/d1/emailOtp/d1GoogleEmailOtpSessionResolver.js +509 -0
- package/dist/esm/router/cloudflare/d1/identity/d1IdentityRecords.js +51 -0
- package/dist/esm/router/cloudflare/d1/identity/d1IdentityService.js +135 -0
- package/dist/esm/router/cloudflare/d1/near/d1NearPublicKeyStore.js +62 -0
- package/dist/esm/router/cloudflare/d1/oidc/d1OidcBoundary.js +272 -0
- package/dist/esm/router/cloudflare/d1/oidc/d1OidcVerificationService.js +132 -0
- package/dist/esm/router/cloudflare/d1/passkeyCustody/d1PasskeyCustodyEnvelopeStore.js +628 -0
- package/dist/esm/router/cloudflare/d1/passkeyCustody/d1PasskeyCustodyRouteService.js +871 -0
- package/dist/esm/router/cloudflare/d1/passkeyCustody/d1WalletCustodyCommitStore.js +823 -0
- package/dist/esm/router/cloudflare/d1/passkeyCustody/d1WalletRecoveryGoogleEmailOtpAttemptStore.js +38 -0
- package/dist/esm/router/cloudflare/d1/passkeyCustody/d1WalletRecoveryGoogleEmailOtpRecords.js +304 -0
- package/dist/esm/router/cloudflare/d1/passkeyCustody/d1WalletRecoveryGoogleEmailOtpService.js +793 -0
- package/dist/esm/router/cloudflare/d1/registration/d1EvmFamilyEcdsaRegistrationBranch.js +120 -0
- package/dist/esm/router/cloudflare/d1/registration/d1RegistrationCeremonyRecordStore.js +317 -0
- package/dist/esm/router/cloudflare/d1/registration/d1RegistrationCeremonyRecords.js +2084 -0
- package/dist/esm/router/cloudflare/d1/registration/d1RegistrationCeremonyStore.js +309 -0
- package/dist/esm/router/cloudflare/d1/registration/d1RegistrationIntentService.js +120 -0
- package/dist/esm/router/cloudflare/d1/registration/d1WalletRegistrationCommitStore.js +263 -0
- package/dist/esm/router/cloudflare/d1/registration/d1WalletRegistrationService.js +3887 -0
- package/dist/esm/router/cloudflare/d1/registration/d1WalletRegistrationSetup.js +182 -0
- package/dist/esm/router/cloudflare/d1/registration/walletRegistrationEstablishedSessionIssuer.js +399 -0
- package/dist/esm/router/cloudflare/d1/registration/walletRegistrationSessionCommitReceipt.js +486 -0
- package/dist/esm/router/cloudflare/d1/signingAdmission/d1RouterAbNormalSigningAdmissionStore.js +146 -0
- package/dist/esm/router/cloudflare/d1/signingLanes/d1EcdsaLanePrivateBindingResolver.js +10 -0
- package/dist/esm/router/cloudflare/d1/signingLanes/d1LaneAggregateRevocationApplicationService.js +22 -0
- package/dist/esm/router/cloudflare/d1/signingLanes/d1LaneEffectJournalStore.js +167 -0
- package/dist/esm/router/cloudflare/d1/signingLanes/d1LaneEnrollmentGateway.js +38 -0
- package/dist/esm/router/cloudflare/d1/signingLanes/d1LaneLifecycleApplicationService.js +20 -0
- package/dist/esm/router/cloudflare/d1/signingLanes/d1LaneLifecycleStore.js +1459 -0
- package/dist/esm/router/cloudflare/d1/signingLanes/d1LaneLockStore.js +114 -0
- package/dist/esm/router/cloudflare/d1/signingLanes/d1LaneProtocolCommitter.js +16 -0
- package/dist/esm/router/cloudflare/d1/signingLanes/d1LaneRecords.js +170 -0
- package/dist/esm/router/cloudflare/d1/signingLanes/index.js +10 -0
- package/dist/esm/router/cloudflare/d1/versionedJson/d1VersionedJsonRecordStore.js +412 -0
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletAddSignerService.js +1396 -0
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletAuthMethodBoundary.js +285 -0
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletAuthMethodService.js +2018 -0
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletAuthorityStore.js +792 -0
- package/dist/esm/router/cloudflare/d1/webauthn/d1WebAuthnAuthService.js +635 -0
- package/dist/esm/router/cloudflare/d1/webauthn/d1WebAuthnRecords.js +538 -0
- package/dist/esm/router/cloudflare/d1/webauthn/d1WebAuthnStore.js +264 -0
- package/dist/esm/router/cloudflare/durableObjects/thresholdStore.js +514 -0
- package/dist/esm/router/cloudflare/durableObjects/versionedJsonRecordStore.js +192 -0
- package/dist/esm/router/cloudflare/runtime/cloudflare.types.js +0 -0
- package/dist/esm/router/cloudflare/runtime/cloudflareSignerWasm.js +8 -0
- package/dist/esm/router/cloudflare/runtime/createCloudflareRouter.js +19 -0
- package/dist/esm/router/cloudflare/runtime/createSelfHostedCloudflareSigningWorker.js +94 -0
- package/dist/esm/router/cloudflare/runtime/ed25519SessionAdapter.js +106 -0
- package/dist/esm/router/cloudflare/runtime/environment.js +25 -0
- package/dist/esm/router/cloudflare/runtime/routerAbPrewarm.js +34 -0
- package/dist/esm/router/cloudflare/runtime/routerAbServiceBindings.js +33 -0
- package/dist/esm/router/cloudflare/runtime/sessionAdapterRuntime.js +104 -0
- package/dist/esm/router/cloudflare/runtime/staticWalletConsoleBinding.js +168 -0
- package/dist/esm/router/cloudflare/runtime/tenantRootCreationGrant.js +147 -0
- package/dist/esm/router/cloudflare/runtime/walletConsoleOps.js +143 -0
- package/dist/esm/router/cloudflare/runtime/walletConsoleOpsClient.js +227 -0
- package/dist/esm/router/cloudflare/runtime/walletConsoleTenantRootLineage.js +30 -0
- package/dist/esm/router/cloudflare/runtime/walletControlOps.js +107 -0
- package/dist/esm/router/cloudflare/runtime/walletGateway.js +149 -0
- package/dist/esm/router/cloudflare/runtime/walletRuntimeOps.js +322 -0
- package/dist/esm/router/cloudflare/runtime/walletRuntimeOpsHandler.js +48 -0
- package/dist/esm/router/cloudflare/signingLanes/cloudflareLaneCurveExecution.js +597 -0
- package/dist/esm/router/cloudflare/signingLanes/cloudflareLaneProtocolCommitter.js +272 -0
- package/dist/esm/router/cloudflare/signingLanes/cloudflareOrdinaryInactiveSignerMaterialReservation.js +477 -0
- package/dist/esm/router/cloudflare/signingLanes/index.js +4 -0
- package/dist/esm/router/cloudflare/signingLanes/linkedDeviceEd25519CeremonyBinding.js +32 -0
- package/dist/esm/router/cloudflare-adaptor.js +45 -0
- package/dist/esm/router/cloudflare.js +42794 -0
- package/dist/esm/router/domains/ecdsa/routerAbEcdsaStrictRegistration.js +738 -0
- package/dist/esm/router/domains/ecdsa/thresholdEcdsaRequestValidation.js +134 -0
- package/dist/esm/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistration.js +368 -0
- package/dist/esm/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistrationPartitionedStateStore.js +624 -0
- package/dist/esm/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistrationPartitioning.js +143 -0
- package/dist/esm/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistrationPersistence.js +270 -0
- package/dist/esm/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistrationRequestScopedRunner.js +31 -0
- package/dist/esm/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistrationRequestScopedRuntime.js +162 -0
- package/dist/esm/router/domains/ed25519Yao/export/routerAbEd25519YaoExport.js +1366 -0
- package/dist/esm/router/domains/ed25519Yao/export/routerAbEd25519YaoExportRequestScopedCloudflare.js +465 -0
- package/dist/esm/router/domains/ed25519Yao/recovery/routerAbEd25519YaoRecovery.js +1609 -0
- package/dist/esm/router/domains/ed25519Yao/recovery/routerAbEd25519YaoRecoveryRequestScopedCloudflare.js +540 -0
- package/dist/esm/router/domains/ed25519Yao/recovery/routerAbEd25519YaoRecoveryWalletSessionAuthorization.js +394 -0
- package/dist/esm/router/domains/ed25519Yao/registration/routerAbEd25519YaoHttpRegistrationBackend.js +572 -0
- package/dist/esm/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistration.js +555 -0
- package/dist/esm/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistrationExecutionRecord.js +268 -0
- package/dist/esm/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistrationIntentAuthorization.js +329 -0
- package/dist/esm/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistrationRequestScopedCloudflare.js +423 -0
- package/dist/esm/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistrationSideEffectBoundary.js +432 -0
- package/dist/esm/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistrationTwoPhaseRunner.js +58 -0
- package/dist/esm/router/domains/ed25519Yao/routerAbEd25519YaoGatewayEnvelope.js +0 -0
- package/dist/esm/router/domains/ed25519Yao/session/routerAbEd25519YaoWalletSession.js +0 -0
- package/dist/esm/router/domains/ed25519Yao/session/thresholdEd25519RequestValidation.js +275 -0
- package/dist/esm/router/domains/emailOtp/emailOtpExportPolicy.js +70 -0
- package/dist/esm/router/domains/emailOtp/emailOtpRequestValidation.js +34 -0
- package/dist/esm/router/domains/emailOtp/emailOtpRouteHandlers.js +218 -0
- package/dist/esm/router/domains/emailOtp/emailOtpSessionRouteHelpers.js +210 -0
- package/dist/esm/router/domains/passkeyCustody/envelopeRevocationAdmission.js +26 -0
- package/dist/esm/router/domains/passkeyCustody/passkeyCustodyEnvelopeRetrieval.js +107 -0
- package/dist/esm/router/domains/passkeyCustody/passkeyCustodyEnvelopeRetrievalRoute.js +45 -0
- package/dist/esm/router/domains/passkeyCustody/registrationCustodyOutcome.js +47 -0
- package/dist/esm/router/domains/passkeyCustody/verifiedCustodyFactor.js +46 -0
- package/dist/esm/router/domains/passkeyCustody/walletCustodyRegistrationAdmission.js +32 -0
- package/dist/esm/router/domains/passkeyCustody/walletCustodyRegistrationCommit.js +170 -0
- package/dist/esm/router/domains/passkeyCustody/walletRecoveryAttempt.js +64 -0
- package/dist/esm/router/domains/passkeyCustody/walletRecoveryFinalization.js +652 -0
- package/dist/esm/router/domains/passkeyCustody/walletRecoveryKeyManifest.js +396 -0
- package/dist/esm/router/domains/passkeyCustody/walletRecoveryRotation.js +87 -0
- package/dist/esm/router/domains/signingOperations/ed25519AuthorizedOperationReceipt.js +89 -0
- package/dist/esm/router/domains/signingOperations/routerAbNormalSigningAdmissionCore.js +106 -0
- package/dist/esm/router/domains/signingOperations/routerAbPrivateSigningWorker.js +2669 -0
- package/dist/esm/router/domains/signingOperations/walletExecutionAdmission.js +228 -0
- package/dist/esm/router/domains/syncAccount/syncAccountRequestValidation.js +78 -0
- package/dist/esm/router/domains/tenantRoot/tenantRootCustodyLineage.js +0 -0
- package/dist/esm/router/domains/tenantRoot/tenantRootEcdsaWalletSessionComposition.js +55 -0
- package/dist/esm/router/domains/tenantRoot/tenantRootEd25519WalletSessionComposition.js +56 -0
- package/dist/esm/router/domains/tenantRoot/tenantRootIdentityResolution.js +111 -0
- package/dist/esm/router/domains/walletRegistration/walletRegistrationInputs.js +0 -0
- package/dist/esm/router/domains/walletRegistration/walletRegistrationRoutes.js +2199 -0
- package/dist/esm/router/domains/walletRegistration/walletRegistrationSetupPayload.js +155 -0
- package/dist/esm/router/domains/walletUnlock/walletUnlockRequestedCapabilitiesValidation.js +84 -0
- package/dist/esm/router/domains/walletUnlock/walletUnlockRouteHandlers.js +1142 -0
- package/dist/esm/router/express-adaptor.js +84 -0
- package/dist/esm/router/express.js +26616 -0
- package/dist/esm/router/framework/apiCredentialPorts.js +11 -0
- package/dist/esm/router/framework/applyRouteMetering.js +26 -0
- package/dist/esm/router/framework/authServicePort.js +30 -0
- package/dist/esm/router/framework/enforceRoutePolicy.js +92 -0
- package/dist/esm/router/framework/http.js +87 -0
- package/dist/esm/router/framework/logger.js +7 -0
- package/dist/esm/router/framework/modules.js +34 -0
- package/dist/esm/router/framework/ror/index.js +5 -0
- package/dist/esm/router/framework/ror/normalize.js +57 -0
- package/dist/esm/router/framework/ror/options.js +33 -0
- package/dist/esm/router/framework/ror/provider.js +33 -0
- package/dist/esm/router/framework/ror/staticProvider.js +24 -0
- package/dist/esm/router/framework/routeAuthPolicy.js +16 -0
- package/dist/esm/router/framework/routeDefinitions.js +446 -0
- package/dist/esm/router/framework/routeExecutionContext.js +24 -0
- package/dist/esm/router/framework/routeExtensions.js +50 -0
- package/dist/esm/router/framework/routeMeteringPolicy.js +0 -0
- package/dist/esm/router/framework/routeRequestValidation.js +32 -0
- package/dist/esm/router/framework/routeResponses.js +33 -0
- package/dist/esm/router/framework/routerApi.js +42 -0
- package/dist/esm/router/framework/routerApiRouteSurface.js +54 -0
- package/dist/esm/router/framework/routerApiWebhooks.js +60 -0
- package/dist/esm/router/framework/runtimeSnapshotConsumer.js +145 -0
- package/dist/esm/router/framework/versionedJsonRecordStore.js +0 -0
- package/dist/esm/router/ror-adaptor.js +5 -0
- package/dist/esm/router/ror.js +178 -0
- package/dist/esm/router/transport/fetch/createFetchRouter.js +309 -0
- package/dist/esm/router/transport/fetch/fetchRouter.types.js +0 -0
- package/dist/esm/router/transport/fetch/routes/auth.js +219 -0
- package/dist/esm/router/transport/fetch/routes/deviceLinking.js +1196 -0
- package/dist/esm/router/transport/fetch/routes/deviceLinkingOwnerAuthorization.js +264 -0
- package/dist/esm/router/transport/fetch/routes/deviceManagement.js +289 -0
- package/dist/esm/router/transport/fetch/routes/health.js +42 -0
- package/dist/esm/router/transport/fetch/routes/nearPublicKeys.js +39 -0
- package/dist/esm/router/transport/fetch/routes/normalSigningRouterProxy.js +118 -0
- package/dist/esm/router/transport/fetch/routes/passkeyCustody.js +1618 -0
- package/dist/esm/router/transport/fetch/routes/sessions.js +1033 -0
- package/dist/esm/router/transport/fetch/routes/syncAccount.js +187 -0
- package/dist/esm/router/transport/fetch/routes/syncAccountBootstrap.js +214 -0
- package/dist/esm/router/transport/fetch/routes/thresholdEcdsa.js +1729 -0
- package/dist/esm/router/transport/fetch/routes/thresholdEd25519.js +1321 -0
- package/dist/esm/router/transport/fetch/routes/walletExecutionLanePreflight.js +228 -0
- package/dist/esm/router/transport/fetch/routes/walletRegistration.js +73 -0
- package/dist/esm/router/transport/fetch/routes/webauthnAuthenticators.js +43 -0
- package/dist/esm/router/transport/fetch/routes/wellKnown.js +48 -0
- package/dist/esm/shared-ts/src/authorization/capabilityKinds.js +224 -0
- package/dist/esm/shared-ts/src/authorization/delegatedAuthority.js +134 -0
- package/dist/esm/shared-ts/src/authorization/index.js +6 -0
- package/dist/esm/shared-ts/src/authorization/operationFingerprint.js +58 -0
- package/dist/esm/shared-ts/src/authorization/walletAuthority.js +802 -0
- package/dist/esm/shared-ts/src/authorization/walletCustodyOperation.js +18 -0
- package/dist/esm/shared-ts/src/authorization/walletSessionIssuance.js +5 -0
- package/dist/esm/shared-ts/src/device-linking/committedSignerPackages.js +332 -0
- package/dist/esm/shared-ts/src/device-linking/contracts.js +8 -0
- package/dist/esm/shared-ts/src/device-linking/delegatedActivationPlan.js +132 -0
- package/dist/esm/shared-ts/src/device-linking/digests.js +273 -0
- package/dist/esm/shared-ts/src/device-linking/ed25519ExportRoot.js +158 -0
- package/dist/esm/shared-ts/src/device-linking/index.js +9 -0
- package/dist/esm/shared-ts/src/device-linking/parsers.js +1412 -0
- package/dist/esm/shared-ts/src/device-linking/requestProof.js +114 -0
- package/dist/esm/shared-ts/src/device-linking/sourceContribution.js +563 -0
- package/dist/esm/shared-ts/src/device-linking/walletSessionCredentialDelivery.js +207 -0
- package/dist/esm/shared-ts/src/near/actions.js +75 -0
- package/dist/esm/shared-ts/src/passkey-custody/ceremonyCommitPayload.js +69 -0
- package/dist/esm/shared-ts/src/passkey-custody/credentialActivity.js +81 -0
- package/dist/esm/shared-ts/src/passkey-custody/custodyEnvelope.js +272 -0
- package/dist/esm/shared-ts/src/passkey-custody/custodySecretBinding.js +175 -0
- package/dist/esm/shared-ts/src/passkey-custody/index.js +5 -0
- package/dist/esm/shared-ts/src/passkey-custody/primitives.js +92 -0
- package/dist/esm/shared-ts/src/signing-lanes/evmFamilySigningKeySlotId.js +53 -0
- package/dist/esm/shared-ts/src/signing-lanes/execution.js +14 -0
- package/dist/esm/shared-ts/src/signing-lanes/index.js +11 -0
- package/dist/esm/shared-ts/src/signing-lanes/linkedEcdsaScope.js +1 -0
- package/dist/esm/shared-ts/src/signing-lanes/ownerContinuity.js +91 -0
- package/dist/esm/shared-ts/src/signing-lanes/participantDigest.js +124 -0
- package/dist/esm/shared-ts/src/signing-lanes/participants.js +262 -0
- package/dist/esm/shared-ts/src/signing-lanes/recordParsers.js +143 -0
- package/dist/esm/shared-ts/src/signing-lanes/rotation.js +8 -0
- package/dist/esm/shared-ts/src/signing-lanes/rotationDigests.js +397 -0
- package/dist/esm/shared-ts/src/signing-lanes/rotationLifecycle.js +313 -0
- package/dist/esm/shared-ts/src/signing-lanes/rotationParsers.js +1620 -0
- package/dist/esm/shared-ts/src/tenant-root/index.js +2 -0
- package/dist/esm/shared-ts/src/tenant-root/tenantRootIdentity.js +198 -0
- package/dist/esm/shared-ts/src/tenant-root/tenantRootOperationRecord.js +440 -0
- package/dist/esm/shared-ts/src/threshold/ecdsaDerivationRoleLocalBootstrap.js +85 -0
- package/dist/esm/shared-ts/src/threshold/participants.js +26 -0
- package/dist/esm/shared-ts/src/threshold/sessionPolicy.js +9 -0
- package/dist/esm/shared-ts/src/threshold/signingRootScope.js +40 -0
- package/dist/esm/shared-ts/src/utils/addAuthMethodRegistration.js +104 -0
- package/dist/esm/shared-ts/src/utils/addWalletAuthMethod.js +36 -0
- package/dist/esm/shared-ts/src/utils/base58.js +28 -0
- package/dist/esm/shared-ts/src/utils/base64.js +70 -0
- package/dist/esm/shared-ts/src/utils/canonicalPrimitives.js +27 -0
- package/dist/esm/shared-ts/src/utils/digests.js +33 -0
- package/dist/esm/shared-ts/src/utils/domainIds.js +309 -0
- package/dist/esm/shared-ts/src/utils/ecdsaCapabilityActivation.js +34 -0
- package/dist/esm/shared-ts/src/utils/ecdsaKeyFactsInventory.js +46 -0
- package/dist/esm/shared-ts/src/utils/emailOtpDomain.js +38 -0
- package/dist/esm/shared-ts/src/utils/emailOtpRecoveryKey.js +10 -0
- package/dist/esm/shared-ts/src/utils/encoders.js +2 -0
- package/dist/esm/shared-ts/src/utils/errors.js +88 -0
- package/dist/esm/shared-ts/src/utils/evmRpcResults.js +97 -0
- package/dist/esm/shared-ts/src/utils/jsonRpc.js +64 -0
- package/dist/esm/shared-ts/src/utils/keccak.js +150 -0
- package/dist/esm/shared-ts/src/utils/near.js +99 -0
- package/dist/esm/shared-ts/src/utils/nearRpcResults.js +205 -0
- package/dist/esm/shared-ts/src/utils/normalize.js +87 -0
- package/dist/esm/shared-ts/src/utils/registrationEstablishedSession.js +201 -0
- package/dist/esm/shared-ts/src/utils/registrationIntent.js +1268 -0
- package/dist/esm/shared-ts/src/utils/routerAbEcdsaDerivation.js +1655 -0
- package/dist/esm/shared-ts/src/utils/routerAbEd25519Yao.js +984 -0
- package/dist/esm/shared-ts/src/utils/routerAbNormalSigningIdentity.js +118 -0
- package/dist/esm/shared-ts/src/utils/routerAbPublicKeyset.js +138 -0
- package/dist/esm/shared-ts/src/utils/routerAbTraceContext.js +36 -0
- package/dist/esm/shared-ts/src/utils/secureRandomId.js +35 -0
- package/dist/esm/shared-ts/src/utils/signingSessionSeal.js +118 -0
- package/dist/esm/shared-ts/src/utils/thresholdEcdsaKeyHandle.js +28 -0
- package/dist/esm/shared-ts/src/utils/validation.js +23 -0
- package/dist/esm/shared-ts/src/utils/walletAddSignerActivation.js +32 -0
- package/dist/esm/shared-ts/src/utils/walletAuthAuthority.js +207 -0
- package/dist/esm/shared-ts/src/utils/walletSessionFailure.js +15 -0
- package/dist/esm/shared-ts/src/utils/webauthnDeviceInfo.js +207 -0
- package/dist/esm/shared-ts/src/wallet-recovery/backupAcknowledgement.js +66 -0
- package/dist/esm/shared-ts/src/wallet-recovery/index.js +10 -0
- package/dist/esm/shared-ts/src/wallet-recovery/recoveryCodeIssuance.js +1 -0
- package/dist/esm/shared-ts/src/wallet-recovery/recoveryCodeLocator.js +34 -0
- package/dist/esm/shared-ts/src/wallet-recovery/recoveryCodeReservation.js +80 -0
- package/dist/esm/shared-ts/src/wallet-recovery/recoveryCodes.js +4 -0
- package/dist/esm/shared-ts/src/wallet-recovery/recoveryKeyId.js +53 -0
- package/dist/esm/shared-ts/src/wallet-recovery/walletRecoveryCommittedProjection.js +108 -0
- package/dist/esm/shared-ts/src/wallet-recovery/walletRecoveryEcdsaPossession.js +157 -0
- package/dist/esm/shared-ts/src/wallet-recovery/walletRecoveryEnvelopeSet.js +233 -0
- package/dist/esm/shared-ts/src/wallet-recovery/walletRecoveryRotation.js +3 -0
- package/dist/esm/shared-ts/src/wallet-recovery/walletRecoveryTarget.js +29 -0
- package/dist/esm/storage/d1Sql.js +85 -0
- package/dist/esm/storage/tenantRoute.js +89 -0
- package/dist/esm/tenant-root.js +5 -0
- package/dist/esm/threshold/session/signingSessionSeal/crypto/cipher.js +204 -0
- package/dist/esm/threshold/session/signingSessionSeal/crypto/shamir3PassWasm.js +87 -0
- package/dist/esm/threshold/session/signingSessionSeal/guards/backends.js +192 -0
- package/dist/esm/threshold/session/signingSessionSeal/guards/index.js +121 -0
- package/dist/esm/threshold/session/signingSessionSeal/idempotency.js +38 -0
- package/dist/esm/threshold/session/signingSessionSeal/idempotencyBackends.js +131 -0
- package/dist/esm/threshold/session/signingSessionSeal/idempotencyRecords.js +55 -0
- package/dist/esm/threshold/session/signingSessionSeal/index.js +13 -0
- package/dist/esm/threshold/session/signingSessionSeal/observability/audit.js +38 -0
- package/dist/esm/threshold/session/signingSessionSeal/options.js +54 -0
- package/dist/esm/threshold/session/signingSessionSeal/routesOptions.js +45 -0
- package/dist/esm/threshold/session/signingSessionSeal/service.js +316 -0
- package/dist/esm/threshold/session/signingSessionSeal/signingSessionSeal.types.js +0 -0
- package/dist/esm/threshold/session/signingSessionSeal/transport/express.js +151 -0
- package/dist/esm/threshold/session/signingSessionSeal/transport/fetch.js +106 -0
- package/dist/esm/threshold/session/signingSessionSeal/transport/shared.js +159 -0
- package/dist/esm/threshold/statusCodes.js +39 -0
- package/dist/esm/wasm/evm_crypto/pkg/evm_crypto.js +601 -0
- package/dist/esm/wasm/evm_crypto/pkg/evm_crypto_bg.wasm +0 -0
- package/dist/esm/wasm/near_signer/pkg/wasm_signer_worker.js +1078 -0
- package/dist/esm/wasm/near_signer/pkg/wasm_signer_worker_bg.wasm +0 -0
- package/dist/esm/wasm/router_ab_ecdsa_signing_worker/pkg/router_ab_ecdsa_signing_worker.js +503 -0
- package/dist/esm/wasm/router_ab_ecdsa_signing_worker/pkg/router_ab_ecdsa_signing_worker_bg.wasm +0 -0
- package/dist/esm/wasm/shamir3pass_runtime/pkg/shamir3pass_runtime.js +393 -0
- package/dist/esm/wasm/shamir3pass_runtime/pkg/shamir3pass_runtime_bg.wasm +0 -0
- package/dist/esm/wasm/signer.js +2 -0
- package/dist/types/shared-ts/src/authorization/capabilityKinds.d.ts +147 -0
- package/dist/types/shared-ts/src/authorization/capabilityKinds.typecheck.d.ts +2 -0
- package/dist/types/shared-ts/src/authorization/delegatedAuthority.d.ts +44 -0
- package/dist/types/shared-ts/src/authorization/index.d.ts +7 -0
- package/dist/types/shared-ts/src/authorization/operationFingerprint.d.ts +39 -0
- package/dist/types/shared-ts/src/authorization/operationFingerprint.typecheck.d.ts +2 -0
- package/dist/types/shared-ts/src/authorization/walletAuthority.d.ts +168 -0
- package/dist/types/shared-ts/src/authorization/walletAuthority.typecheck.d.ts +2 -0
- package/dist/types/shared-ts/src/authorization/walletCustodyOperation.d.ts +10 -0
- package/dist/types/shared-ts/src/authorization/walletSessionIssuance.d.ts +28 -0
- package/dist/types/shared-ts/src/device-linking/activeWalletSession.d.ts +3 -0
- package/dist/types/shared-ts/src/device-linking/activeWalletSession.typecheck.d.ts +2 -0
- package/dist/types/shared-ts/src/device-linking/committedSignerPackages.d.ts +71 -0
- package/dist/types/shared-ts/src/device-linking/contracts.d.ts +843 -0
- package/dist/types/shared-ts/src/device-linking/contracts.typecheck.d.ts +2 -0
- package/dist/types/shared-ts/src/device-linking/delegatedActivationPlan.d.ts +37 -0
- package/dist/types/shared-ts/src/device-linking/digests.d.ts +23 -0
- package/dist/types/shared-ts/src/device-linking/ed25519ExportRoot.d.ts +93 -0
- package/dist/types/shared-ts/src/device-linking/index.d.ts +11 -0
- package/dist/types/shared-ts/src/device-linking/parsers.d.ts +124 -0
- package/dist/types/shared-ts/src/device-linking/requestProof.d.ts +26 -0
- package/dist/types/shared-ts/src/device-linking/sourceContribution.d.ts +182 -0
- package/dist/types/shared-ts/src/device-linking/walletSessionCredentialDelivery.d.ts +84 -0
- package/dist/types/shared-ts/src/index.d.ts +10 -0
- package/dist/types/shared-ts/src/near/actions.d.ts +141 -0
- package/dist/types/shared-ts/src/near/delegate.d.ts +55 -0
- package/dist/types/shared-ts/src/near/index.d.ts +3 -0
- package/dist/types/shared-ts/src/passkey-custody/ceremonyCommitPayload.d.ts +211 -0
- package/dist/types/shared-ts/src/passkey-custody/credentialActivity.d.ts +49 -0
- package/dist/types/shared-ts/src/passkey-custody/credentialObservations.d.ts +74 -0
- package/dist/types/shared-ts/src/passkey-custody/custodyEnvelope.d.ts +191 -0
- package/dist/types/shared-ts/src/passkey-custody/custodySecretBinding.d.ts +140 -0
- package/dist/types/shared-ts/src/passkey-custody/envelopeIndex.d.ts +29 -0
- package/dist/types/shared-ts/src/passkey-custody/index.d.ts +9 -0
- package/dist/types/shared-ts/src/passkey-custody/kekContext.d.ts +34 -0
- package/dist/types/shared-ts/src/passkey-custody/passkeyCustody.typecheck.d.ts +2 -0
- package/dist/types/shared-ts/src/passkey-custody/primitives.d.ts +34 -0
- package/dist/types/shared-ts/src/signing-lanes/evmFamilySigningKeySlotId.d.ts +27 -0
- package/dist/types/shared-ts/src/signing-lanes/execution.d.ts +91 -0
- package/dist/types/shared-ts/src/signing-lanes/execution.typecheck.d.ts +2 -0
- package/dist/types/shared-ts/src/signing-lanes/ids.d.ts +18 -0
- package/dist/types/shared-ts/src/signing-lanes/index.d.ts +14 -0
- package/dist/types/shared-ts/src/signing-lanes/linkedEcdsaScope.d.ts +62 -0
- package/dist/types/shared-ts/src/signing-lanes/linkedEcdsaScope.typecheck.d.ts +2 -0
- package/dist/types/shared-ts/src/signing-lanes/ownerContinuity.d.ts +30 -0
- package/dist/types/shared-ts/src/signing-lanes/ownerContinuity.typecheck.d.ts +2 -0
- package/dist/types/shared-ts/src/signing-lanes/participantDigest.d.ts +48 -0
- package/dist/types/shared-ts/src/signing-lanes/participantDigest.typecheck.d.ts +2 -0
- package/dist/types/shared-ts/src/signing-lanes/participants.d.ts +89 -0
- package/dist/types/shared-ts/src/signing-lanes/recordParsers.d.ts +128 -0
- package/dist/types/shared-ts/src/signing-lanes/records.d.ts +160 -0
- package/dist/types/shared-ts/src/signing-lanes/records.typecheck.d.ts +2 -0
- package/dist/types/shared-ts/src/signing-lanes/rotation.d.ts +894 -0
- package/dist/types/shared-ts/src/signing-lanes/rotation.typecheck.d.ts +2 -0
- package/dist/types/shared-ts/src/signing-lanes/rotationDigests.d.ts +32 -0
- package/dist/types/shared-ts/src/signing-lanes/rotationLifecycle.d.ts +99 -0
- package/dist/types/shared-ts/src/signing-lanes/rotationParsers.d.ts +67 -0
- package/dist/types/shared-ts/src/signing-lanes/validation.d.ts +11 -0
- package/dist/types/shared-ts/src/tenant-root/index.d.ts +3 -0
- package/dist/types/shared-ts/src/tenant-root/tenantRootIdentity.d.ts +72 -0
- package/dist/types/shared-ts/src/tenant-root/tenantRootOperationRecord.d.ts +192 -0
- package/dist/types/shared-ts/src/threshold/ecdsaDerivationRoleLocalBootstrap.d.ts +77 -0
- package/dist/types/shared-ts/src/threshold/ed25519OperationFingerprint.d.ts +130 -0
- package/dist/types/shared-ts/src/threshold/index.d.ts +7 -0
- package/dist/types/shared-ts/src/threshold/participants.d.ts +38 -0
- package/dist/types/shared-ts/src/threshold/secp256k1.d.ts +39 -0
- package/dist/types/shared-ts/src/threshold/sessionPolicy.d.ts +5 -0
- package/dist/types/shared-ts/src/threshold/signingRootScope.d.ts +24 -0
- package/dist/types/shared-ts/src/utils/addAuthMethodRegistration.d.ts +63 -0
- package/dist/types/shared-ts/src/utils/addWalletAuthMethod.d.ts +295 -0
- package/dist/types/shared-ts/src/utils/addWalletAuthMethod.typecheck.d.ts +11 -0
- package/dist/types/shared-ts/src/utils/authenticatorOptions.d.ts +25 -0
- package/dist/types/shared-ts/src/utils/base58.d.ts +17 -0
- package/dist/types/shared-ts/src/utils/base64.d.ts +53 -0
- package/dist/types/shared-ts/src/utils/bigint.d.ts +3 -0
- package/dist/types/shared-ts/src/utils/canonicalPrimitives.d.ts +12 -0
- package/dist/types/shared-ts/src/utils/digests.d.ts +6 -0
- package/dist/types/shared-ts/src/utils/domainIds.d.ts +140 -0
- package/dist/types/shared-ts/src/utils/domainIds.typecheck.d.ts +2 -0
- package/dist/types/shared-ts/src/utils/ecdsaCapabilityActivation.d.ts +29 -0
- package/dist/types/shared-ts/src/utils/ecdsaKeyFactsInventory.d.ts +24 -0
- package/dist/types/shared-ts/src/utils/emailOtpDomain.d.ts +30 -0
- package/dist/types/shared-ts/src/utils/emailOtpRecoveryKey.d.ts +31 -0
- package/dist/types/shared-ts/src/utils/encoders.d.ts +3 -0
- package/dist/types/shared-ts/src/utils/errors.d.ts +44 -0
- package/dist/types/shared-ts/src/utils/evmRpcResults.d.ts +31 -0
- package/dist/types/shared-ts/src/utils/generated/routerAbEd25519YaoCore.d.ts +128 -0
- package/dist/types/shared-ts/src/utils/index.d.ts +34 -0
- package/dist/types/shared-ts/src/utils/jsonRpc.d.ts +30 -0
- package/dist/types/shared-ts/src/utils/keccak.d.ts +2 -0
- package/dist/types/shared-ts/src/utils/near.d.ts +81 -0
- package/dist/types/shared-ts/src/utils/nearRpcResults.d.ts +101 -0
- package/dist/types/shared-ts/src/utils/normalize.d.ts +57 -0
- package/dist/types/shared-ts/src/utils/paillier.d.ts +37 -0
- package/dist/types/shared-ts/src/utils/recoveryDomain.d.ts +12 -0
- package/dist/types/shared-ts/src/utils/registrationEstablishedSession.d.ts +85 -0
- package/dist/types/shared-ts/src/utils/registrationIntent.d.ts +621 -0
- package/dist/types/shared-ts/src/utils/registrationIntent.typecheck.d.ts +2 -0
- package/dist/types/shared-ts/src/utils/routerAbEcdsaDerivation.d.ts +715 -0
- package/dist/types/shared-ts/src/utils/routerAbEcdsaDerivation.typecheck.d.ts +2 -0
- package/dist/types/shared-ts/src/utils/routerAbEcdsaDerivationRefresh.typecheck.d.ts +2 -0
- package/dist/types/shared-ts/src/utils/routerAbEd25519Yao.d.ts +339 -0
- package/dist/types/shared-ts/src/utils/routerAbEd25519Yao.typecheck.d.ts +2 -0
- package/dist/types/shared-ts/src/utils/routerAbNormalSigningIdentity.d.ts +71 -0
- package/dist/types/shared-ts/src/utils/routerAbPublicKeyset.d.ts +51 -0
- package/dist/types/shared-ts/src/utils/routerAbTraceContext.d.ts +16 -0
- package/dist/types/shared-ts/src/utils/secureRandomId.d.ts +6 -0
- package/dist/types/shared-ts/src/utils/signerDomain.d.ts +75 -0
- package/dist/types/shared-ts/src/utils/signerDomain.typecheck.d.ts +2 -0
- package/dist/types/shared-ts/src/utils/signerSlot.d.ts +11 -0
- package/dist/types/shared-ts/src/utils/signingSessionSeal.d.ts +153 -0
- package/dist/types/shared-ts/src/utils/signingSessionSeal.typecheck.d.ts +2 -0
- package/dist/types/shared-ts/src/utils/theme.d.ts +2 -0
- package/dist/types/shared-ts/src/utils/thresholdEcdsaKeyHandle.d.ts +11 -0
- package/dist/types/shared-ts/src/utils/validation.d.ts +35 -0
- package/dist/types/shared-ts/src/utils/walletAddSignerActivation.d.ts +23 -0
- package/dist/types/shared-ts/src/utils/walletAuthAuthority.d.ts +150 -0
- package/dist/types/shared-ts/src/utils/walletAuthAuthority.typecheck.d.ts +2 -0
- package/dist/types/shared-ts/src/utils/walletCapabilityBindings.d.ts +106 -0
- package/dist/types/shared-ts/src/utils/walletCapabilityBindings.typecheck.d.ts +2 -0
- package/dist/types/shared-ts/src/utils/walletSessionFailure.d.ts +13 -0
- package/dist/types/shared-ts/src/utils/webauthnDeviceInfo.d.ts +48 -0
- package/dist/types/shared-ts/src/wallet-recovery/backupAcknowledgement.d.ts +56 -0
- package/dist/types/shared-ts/src/wallet-recovery/index.d.ts +10 -0
- package/dist/types/shared-ts/src/wallet-recovery/recoveryCodeAttempt.d.ts +59 -0
- package/dist/types/shared-ts/src/wallet-recovery/recoveryCodeIssuance.d.ts +37 -0
- package/dist/types/shared-ts/src/wallet-recovery/recoveryCodeLocator.d.ts +22 -0
- package/dist/types/shared-ts/src/wallet-recovery/recoveryCodeReservation.d.ts +79 -0
- package/dist/types/shared-ts/src/wallet-recovery/recoveryCodes.d.ts +11 -0
- package/dist/types/shared-ts/src/wallet-recovery/recoveryEnvelopes.d.ts +42 -0
- package/dist/types/shared-ts/src/wallet-recovery/recoveryKekContext.d.ts +37 -0
- package/dist/types/shared-ts/src/wallet-recovery/recoveryKeyId.d.ts +58 -0
- package/dist/types/shared-ts/src/wallet-recovery/walletRecovery.typecheck.d.ts +2 -0
- package/dist/types/shared-ts/src/wallet-recovery/walletRecoveryCommittedProjection.d.ts +110 -0
- package/dist/types/shared-ts/src/wallet-recovery/walletRecoveryEcdsaPossession.d.ts +29 -0
- package/dist/types/shared-ts/src/wallet-recovery/walletRecoveryEnvelopeSet.d.ts +115 -0
- package/dist/types/shared-ts/src/wallet-recovery/walletRecoveryRotation.d.ts +18 -0
- package/dist/types/shared-ts/src/wallet-recovery/walletRecoveryTarget.d.ts +12 -0
- package/dist/types/shared-ts/src/wallet-recovery/walletRecoveryTarget.typecheck.d.ts +2 -0
- package/dist/types/wallet-server/src/authorization/capabilityPolicy.d.ts +45 -0
- package/dist/types/wallet-server/src/authorization/capabilityPolicy.typecheck.d.ts +2 -0
- package/dist/types/wallet-server/src/authorization/domain.d.ts +454 -0
- package/dist/types/wallet-server/src/authorization/domain.typecheck.d.ts +2 -0
- package/dist/types/wallet-server/src/authorization/factorEvidence.d.ts +165 -0
- package/dist/types/wallet-server/src/authorization/factorEvidence.typecheck.d.ts +2 -0
- package/dist/types/wallet-server/src/authorization/service.d.ts +227 -0
- package/dist/types/wallet-server/src/authorization/vaultProxyUse.d.ts +75 -0
- package/dist/types/wallet-server/src/cloud-host.d.ts +94 -0
- package/dist/types/wallet-server/src/core/AuthService.d.ts +3 -0
- package/dist/types/wallet-server/src/core/EmailOtpRecords.d.ts +33 -0
- package/dist/types/wallet-server/src/core/EmailOtpStores.d.ts +336 -0
- package/dist/types/wallet-server/src/core/IdentityStore.d.ts +57 -0
- package/dist/types/wallet-server/src/core/NearPublicKeyStore.d.ts +58 -0
- package/dist/types/wallet-server/src/core/RegistrationCeremonyStore.d.ts +551 -0
- package/dist/types/wallet-server/src/core/SessionService.d.ts +70 -0
- package/dist/types/wallet-server/src/core/ThresholdService/config.d.ts +23 -0
- package/dist/types/wallet-server/src/core/ThresholdService/ecdsaClientRootProof.d.ts +12 -0
- package/dist/types/wallet-server/src/core/ThresholdService/evmCryptoWasm.d.ts +32 -0
- package/dist/types/wallet-server/src/core/ThresholdService/index.d.ts +4 -0
- package/dist/types/wallet-server/src/core/ThresholdService/kv.d.ts +52 -0
- package/dist/types/wallet-server/src/core/ThresholdService/routerAb/ecdsaDerivationPoolFillHandlers.d.ts +45 -0
- package/dist/types/wallet-server/src/core/ThresholdService/routerAb/ecdsaDerivationPoolFillLiveSession.d.ts +93 -0
- package/dist/types/wallet-server/src/core/ThresholdService/routerAb/ecdsaDerivationPresignBridge.d.ts +138 -0
- package/dist/types/wallet-server/src/core/ThresholdService/routerAb/internalServiceHttp.d.ts +30 -0
- package/dist/types/wallet-server/src/core/ThresholdService/routerAbEcdsaSigningWorkerWasm.d.ts +17 -0
- package/dist/types/wallet-server/src/core/ThresholdService/routerAbNormalSigningPolicy.d.ts +21 -0
- package/dist/types/wallet-server/src/core/ThresholdService/secureRandomId.d.ts +2 -0
- package/dist/types/wallet-server/src/core/ThresholdService/stores/CloudflareDurableObjectStore.d.ts +128 -0
- package/dist/types/wallet-server/src/core/ThresholdService/stores/EcdsaSigningStore.d.ts +76 -0
- package/dist/types/wallet-server/src/core/ThresholdService/stores/KeyStore.d.ts +39 -0
- package/dist/types/wallet-server/src/core/ThresholdService/stores/SessionStore.d.ts +102 -0
- package/dist/types/wallet-server/src/core/ThresholdService/stores/StoreConfig.d.ts +3 -0
- package/dist/types/wallet-server/src/core/ThresholdService/stores/ThresholdStoreConfig.typecheck.d.ts +2 -0
- package/dist/types/wallet-server/src/core/ThresholdService/stores/WalletSessionStore.d.ts +98 -0
- package/dist/types/wallet-server/src/core/ThresholdService/thresholdEd25519AuthorityScope.typecheck.d.ts +2 -0
- package/dist/types/wallet-server/src/core/ThresholdService/validation.d.ts +193 -0
- package/dist/types/wallet-server/src/core/WalletAuthMethodStore.d.ts +12 -0
- package/dist/types/wallet-server/src/core/WalletStore.d.ts +143 -0
- package/dist/types/wallet-server/src/core/WalletStore.typecheck.d.ts +2 -0
- package/dist/types/wallet-server/src/core/WebAuthnAuthenticatorStore.d.ts +62 -0
- package/dist/types/wallet-server/src/core/WebAuthnCredentialBindingStore.d.ts +116 -0
- package/dist/types/wallet-server/src/core/WebAuthnCredentialBindingStore.typecheck.d.ts +13 -0
- package/dist/types/wallet-server/src/core/WebAuthnLoginChallengeStore.d.ts +50 -0
- package/dist/types/wallet-server/src/core/WebAuthnSyncChallengeStore.d.ts +50 -0
- package/dist/types/wallet-server/src/core/authService/AuthService.d.ts +493 -0
- package/dist/types/wallet-server/src/core/authService/bytes.d.ts +4 -0
- package/dist/types/wallet-server/src/core/authService/configValues.d.ts +7 -0
- package/dist/types/wallet-server/src/core/authService/emailOtpChallengeOperations.d.ts +108 -0
- package/dist/types/wallet-server/src/core/authService/emailOtpChallengeProof.d.ts +177 -0
- package/dist/types/wallet-server/src/core/authService/emailOtpChallengeVerification.d.ts +46 -0
- package/dist/types/wallet-server/src/core/authService/emailOtpChallenges.d.ts +110 -0
- package/dist/types/wallet-server/src/core/authService/emailOtpConfig.d.ts +34 -0
- package/dist/types/wallet-server/src/core/authService/emailOtpDelivery.d.ts +65 -0
- package/dist/types/wallet-server/src/core/authService/emailOtpEnrollment.d.ts +79 -0
- package/dist/types/wallet-server/src/core/authService/emailOtpGrant.d.ts +42 -0
- package/dist/types/wallet-server/src/core/authService/emailOtpRegistrationEnrollment.d.ts +116 -0
- package/dist/types/wallet-server/src/core/authService/emailOtpSeal.d.ts +35 -0
- package/dist/types/wallet-server/src/core/authService/emailOtpUnlock.d.ts +70 -0
- package/dist/types/wallet-server/src/core/authService/githubOAuth.d.ts +35 -0
- package/dist/types/wallet-server/src/core/authService/googleEmailOtpErrors.d.ts +2 -0
- package/dist/types/wallet-server/src/core/authService/googleEmailOtpOperations.d.ts +126 -0
- package/dist/types/wallet-server/src/core/authService/googleEmailOtpRegistration.d.ts +172 -0
- package/dist/types/wallet-server/src/core/authService/identity.d.ts +25 -0
- package/dist/types/wallet-server/src/core/authService/identityOperations.d.ts +19 -0
- package/dist/types/wallet-server/src/core/authService/nearAccountOperations.d.ts +55 -0
- package/dist/types/wallet-server/src/core/authService/nearPrivateKeySigning.d.ts +16 -0
- package/dist/types/wallet-server/src/core/authService/nearPublicKeyMetadata.d.ts +43 -0
- package/dist/types/wallet-server/src/core/authService/nearTransactions.d.ts +49 -0
- package/dist/types/wallet-server/src/core/authService/oidcVerification.d.ts +65 -0
- package/dist/types/wallet-server/src/core/authService/portableCrypto.d.ts +3 -0
- package/dist/types/wallet-server/src/core/authService/rateLimits.d.ts +30 -0
- package/dist/types/wallet-server/src/core/authService/record.d.ts +2 -0
- package/dist/types/wallet-server/src/core/authService/registrationThresholdHelpers.d.ts +37 -0
- package/dist/types/wallet-server/src/core/authService/runtime.d.ts +20 -0
- package/dist/types/wallet-server/src/core/authService/signerWasmUrls.d.ts +3 -0
- package/dist/types/wallet-server/src/core/authService/storeRegistry.d.ts +58 -0
- package/dist/types/wallet-server/src/core/authService/thresholdEcdsaKeyInventory.d.ts +72 -0
- package/dist/types/wallet-server/src/core/authService/thresholdRuntimePolicy.d.ts +4 -0
- package/dist/types/wallet-server/src/core/authService/thresholdStoreSummary.d.ts +3 -0
- package/dist/types/wallet-server/src/core/authService/walletRegistrationPlanning.d.ts +19 -0
- package/dist/types/wallet-server/src/core/authService/wasm.d.ts +12 -0
- package/dist/types/wallet-server/src/core/authService/webauthn.d.ts +207 -0
- package/dist/types/wallet-server/src/core/authService/webauthnAuthority.d.ts +5 -0
- package/dist/types/wallet-server/src/core/authService/webauthnOidcHelpers.d.ts +52 -0
- package/dist/types/wallet-server/src/core/authService/webauthnWalletBinding.d.ts +48 -0
- package/dist/types/wallet-server/src/core/config.d.ts +13 -0
- package/dist/types/wallet-server/src/core/d1IdentityStore.d.ts +44 -0
- package/dist/types/wallet-server/src/core/d1WalletAuthMethodStore.d.ts +214 -0
- package/dist/types/wallet-server/src/core/d1WalletStore.d.ts +108 -0
- package/dist/types/wallet-server/src/core/defaultConfigsServer.d.ts +5 -0
- package/dist/types/wallet-server/src/core/deviceLinking/index.d.ts +5 -0
- package/dist/types/wallet-server/src/core/deviceLinking/linkedDeviceEd25519ExportRoot.d.ts +36 -0
- package/dist/types/wallet-server/src/core/deviceLinking/linkedDeviceEmailOtpGrant.d.ts +87 -0
- package/dist/types/wallet-server/src/core/deviceLinking/linkedDeviceManagement.d.ts +137 -0
- package/dist/types/wallet-server/src/core/deviceLinking/linkedDeviceSession.d.ts +462 -0
- package/dist/types/wallet-server/src/core/deviceLinking/requestProof.d.ts +55 -0
- package/dist/types/wallet-server/src/core/errors.d.ts +10 -0
- package/dist/types/wallet-server/src/core/hostedAccountIds.d.ts +31 -0
- package/dist/types/wallet-server/src/core/keyMaterialBrands.d.ts +28 -0
- package/dist/types/wallet-server/src/core/keyMaterialBrands.typecheck.d.ts +2 -0
- package/dist/types/wallet-server/src/core/logger.d.ts +21 -0
- package/dist/types/wallet-server/src/core/nearKeys.d.ts +3 -0
- package/dist/types/wallet-server/src/core/nearRelayerAccountProvisioning.d.ts +78 -0
- package/dist/types/wallet-server/src/core/nearSignerWasmRuntime.d.ts +3 -0
- package/dist/types/wallet-server/src/core/registrationContracts.d.ts +747 -0
- package/dist/types/wallet-server/src/core/registrationRequests.typecheck.d.ts +2 -0
- package/dist/types/wallet-server/src/core/routerAbSigning/RouterAbEcdsaPresignRuntime.d.ts +53 -0
- package/dist/types/wallet-server/src/core/routerAbSigning/RouterAbNormalSigningRuntime.d.ts +71 -0
- package/dist/types/wallet-server/src/core/routerAbSigning/createCloudflareDurableObjectRouterAbSigningRuntimes.d.ts +28 -0
- package/dist/types/wallet-server/src/core/routerAbSigning/createRouterAbSigningRuntimes.d.ts +16 -0
- package/dist/types/wallet-server/src/core/rpcClients/near/NearClient.d.ts +134 -0
- package/dist/types/wallet-server/src/core/sessionValidation.d.ts +9 -0
- package/dist/types/wallet-server/src/core/signingLanes/LaneAggregateRevocationApplicationService.d.ts +35 -0
- package/dist/types/wallet-server/src/core/signingLanes/LaneEffectJournalStore.d.ts +63 -0
- package/dist/types/wallet-server/src/core/signingLanes/LaneEnrollmentActivation.d.ts +13 -0
- package/dist/types/wallet-server/src/core/signingLanes/LaneEnrollmentRevocation.d.ts +24 -0
- package/dist/types/wallet-server/src/core/signingLanes/LaneLifecycleApplicationService.d.ts +141 -0
- package/dist/types/wallet-server/src/core/signingLanes/LaneLifecycleStore.d.ts +229 -0
- package/dist/types/wallet-server/src/core/signingLanes/SigningLaneStore.d.ts +15 -0
- package/dist/types/wallet-server/src/core/signingLanes/WalletExecutionLaneProjection.d.ts +59 -0
- package/dist/types/wallet-server/src/core/signingLanes/WalletKeyStore.d.ts +13 -0
- package/dist/types/wallet-server/src/core/signingLanes/ecdsaServerRetirement.d.ts +58 -0
- package/dist/types/wallet-server/src/core/signingLanes/ed25519ServerRetirement.d.ts +30 -0
- package/dist/types/wallet-server/src/core/signingLanes/index.d.ts +11 -0
- package/dist/types/wallet-server/src/core/signingLanes/signingWorkerLaneMaterialIdentity.d.ts +21 -0
- package/dist/types/wallet-server/src/core/signingMaterial/ordinaryInactiveSignerMaterialReservation.d.ts +155 -0
- package/dist/types/wallet-server/src/core/threeRouteRegistrationContracts.d.ts +442 -0
- package/dist/types/wallet-server/src/core/threeRouteRegistrationContracts.typecheck.d.ts +58 -0
- package/dist/types/wallet-server/src/core/thresholdEcdsaChainTarget.d.ts +15 -0
- package/dist/types/wallet-server/src/core/types.d.ts +757 -0
- package/dist/types/wallet-server/src/core/utils.d.ts +3 -0
- package/dist/types/wallet-server/src/delegateAction/index.d.ts +88 -0
- package/dist/types/wallet-server/src/hosted-wallet-gateway-worker.d.ts +10 -0
- package/dist/types/wallet-server/src/hosted-wallet-gateway.d.ts +126 -0
- package/dist/types/wallet-server/src/index.d.ts +34 -0
- package/dist/types/wallet-server/src/local-hosted-wallet-gateway-worker.d.ts +13 -0
- package/dist/types/wallet-server/src/router/auth/authRequestValidation.d.ts +97 -0
- package/dist/types/wallet-server/src/router/auth/commonRouterUtils.d.ts +142 -0
- package/dist/types/wallet-server/src/router/auth/routerApiCredentialAuth.d.ts +26 -0
- package/dist/types/wallet-server/src/router/auth/routerApiKeyAuth.d.ts +16 -0
- package/dist/types/wallet-server/src/router/auth/walletSessionFailure.d.ts +14 -0
- package/dist/types/wallet-server/src/router/auth/webAuthnCredentialCodecs.d.ts +20 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/auth/d1RouterApiAuthBoundary.d.ts +28 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/auth/d1RouterApiAuthConfig.d.ts +192 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/auth/d1RouterApiAuthService.d.ts +13 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/authorization/d1AuthorizationStore.d.ts +174 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/authorization/d1VaultProxyStore.d.ts +13 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/authorization/walletSessionAuthorityProjection.d.ts +24 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceAuthorityInstallService.d.ts +241 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceEd25519ExportRootStore.d.ts +23 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceEmailOtpGrantStore.d.ts +32 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceEmailOtpTargetFactor.d.ts +118 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceManagementService.d.ts +22 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceOwnerAuthorizationProvider.d.ts +80 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceRequestProofNonceStore.d.ts +29 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceRouteService.d.ts +17 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceSessionRecords.d.ts +37 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceSessionService.d.ts +12 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceSessionStore.d.ts +149 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceSourceContributionPreparationPlanner.d.ts +38 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceTargetAuthenticatorStore.d.ts +19 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceTargetCredentialProvider.d.ts +220 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceTargetPlanner.d.ts +88 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceVerifiedLinkBuilder.d.ts +54 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceVerifiedLinkSourceReader.d.ts +23 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/index.d.ts +15 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/ed25519Yao/d1Ed25519YaoCapabilityPersistence.d.ts +33 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/ed25519Yao/d1Ed25519YaoProductRegistrationPartitionedStateStore.d.ts +6 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/ed25519Yao/d1Ed25519YaoWalletSigner.d.ts +27 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeIssuer.d.ts +80 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeService.d.ts +48 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeStore.d.ts +64 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeVerifier.d.ts +126 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpDeliveryRuntime.d.ts +22 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpEnrollmentStore.d.ts +68 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpGrantStore.d.ts +15 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpRateLimitStore.d.ts +37 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpRecords.d.ts +186 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpRecoveryService.d.ts +45 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpRegistrationEnrollmentFinalizer.d.ts +124 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpServerSealRuntime.d.ts +24 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1GoogleEmailOtpRegistrationAttemptStore.d.ts +51 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1GoogleEmailOtpRegistrationRecords.d.ts +69 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1GoogleEmailOtpSessionResolver.d.ts +57 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/identity/d1IdentityRecords.d.ts +38 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/identity/d1IdentityService.d.ts +31 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/near/d1NearPublicKeyStore.d.ts +30 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/oidc/d1OidcBoundary.d.ts +60 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/oidc/d1OidcVerificationService.d.ts +39 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/passkeyCustody/d1PasskeyCustodyEnvelopeStore.d.ts +335 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/passkeyCustody/d1PasskeyCustodyRouteService.d.ts +448 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/passkeyCustody/d1WalletCustodyCommitStore.d.ts +256 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/passkeyCustody/d1WalletRecoveryGoogleEmailOtpAttemptStore.d.ts +32 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/passkeyCustody/d1WalletRecoveryGoogleEmailOtpRecords.d.ts +116 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/passkeyCustody/d1WalletRecoveryGoogleEmailOtpService.d.ts +180 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1EvmFamilyEcdsaRegistrationBranch.d.ts +24 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1RegistrationCeremonyRecordStore.d.ts +86 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1RegistrationCeremonyRecords.d.ts +121 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1RegistrationCeremonyStore.d.ts +84 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1RegistrationIntentService.d.ts +31 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1WalletRegistrationCommitStore.d.ts +49 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1WalletRegistrationService.d.ts +369 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1WalletRegistrationSetup.d.ts +106 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/walletRegistrationEstablishedSessionIssuer.d.ts +104 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/walletRegistrationSessionCommitReceipt.d.ts +70 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/signingAdmission/d1RouterAbNormalSigningAdmissionStore.d.ts +26 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/signingLanes/d1EcdsaLanePrivateBindingResolver.d.ts +4 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/signingLanes/d1LaneAggregateRevocationApplicationService.d.ts +4 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/signingLanes/d1LaneEffectJournalStore.d.ts +25 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/signingLanes/d1LaneEnrollmentGateway.d.ts +20 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/signingLanes/d1LaneLifecycleApplicationService.d.ts +13 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/signingLanes/d1LaneLifecycleStore.d.ts +51 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/signingLanes/d1LaneLockStore.d.ts +28 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/signingLanes/d1LaneProtocolCommitter.d.ts +5 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/signingLanes/d1LaneRecords.d.ts +107 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/signingLanes/index.d.ts +10 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/versionedJson/d1VersionedJsonRecordStore.d.ts +118 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/wallet/d1WalletAddSignerService.d.ts +114 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/wallet/d1WalletAddSignerService.typecheck.d.ts +2 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/wallet/d1WalletAuthMethodBoundary.d.ts +90 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/wallet/d1WalletAuthMethodService.d.ts +359 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/wallet/d1WalletAuthorityStore.d.ts +143 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/webauthn/d1WebAuthnAuthService.d.ts +42 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/webauthn/d1WebAuthnRecords.d.ts +135 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/webauthn/d1WebAuthnStore.d.ts +89 -0
- package/dist/types/wallet-server/src/router/cloudflare/durableObjects/thresholdStore.d.ts +19 -0
- package/dist/types/wallet-server/src/router/cloudflare/durableObjects/versionedJsonRecordStore.d.ts +32 -0
- package/dist/types/wallet-server/src/router/cloudflare/runtime/cloudflare.types.d.ts +30 -0
- package/dist/types/wallet-server/src/router/cloudflare/runtime/cloudflareSignerWasm.d.ts +2 -0
- package/dist/types/wallet-server/src/router/cloudflare/runtime/createCloudflareRouter.d.ts +5 -0
- package/dist/types/wallet-server/src/router/cloudflare/runtime/createSelfHostedCloudflareSigningWorker.d.ts +23 -0
- package/dist/types/wallet-server/src/router/cloudflare/runtime/ed25519SessionAdapter.d.ts +16 -0
- package/dist/types/wallet-server/src/router/cloudflare/runtime/environment.d.ts +5 -0
- package/dist/types/wallet-server/src/router/cloudflare/runtime/routerAbPrewarm.d.ts +9 -0
- package/dist/types/wallet-server/src/router/cloudflare/runtime/routerAbServiceBindings.d.ts +11 -0
- package/dist/types/wallet-server/src/router/cloudflare/runtime/sessionAdapterRuntime.d.ts +28 -0
- package/dist/types/wallet-server/src/router/cloudflare/runtime/staticWalletConsoleBinding.d.ts +27 -0
- package/dist/types/wallet-server/src/router/cloudflare/runtime/tenantRootCreationGrant.d.ts +24 -0
- package/dist/types/wallet-server/src/router/cloudflare/runtime/walletConsoleOps.d.ts +143 -0
- package/dist/types/wallet-server/src/router/cloudflare/runtime/walletConsoleOpsClient.d.ts +20 -0
- package/dist/types/wallet-server/src/router/cloudflare/runtime/walletConsoleTenantRootLineage.d.ts +7 -0
- package/dist/types/wallet-server/src/router/cloudflare/runtime/walletControlOps.d.ts +21 -0
- package/dist/types/wallet-server/src/router/cloudflare/runtime/walletGateway.d.ts +30 -0
- package/dist/types/wallet-server/src/router/cloudflare/runtime/walletRuntimeOps.d.ts +64 -0
- package/dist/types/wallet-server/src/router/cloudflare/runtime/walletRuntimeOpsHandler.d.ts +3 -0
- package/dist/types/wallet-server/src/router/cloudflare/signingLanes/cloudflareLaneCurveExecution.d.ts +217 -0
- package/dist/types/wallet-server/src/router/cloudflare/signingLanes/cloudflareLaneProtocolCommitter.d.ts +73 -0
- package/dist/types/wallet-server/src/router/cloudflare/signingLanes/cloudflareOrdinaryInactiveSignerMaterialReservation.d.ts +100 -0
- package/dist/types/wallet-server/src/router/cloudflare/signingLanes/index.d.ts +4 -0
- package/dist/types/wallet-server/src/router/cloudflare/signingLanes/linkedDeviceEd25519CeremonyBinding.d.ts +6 -0
- package/dist/types/wallet-server/src/router/cloudflare-adaptor.d.ts +75 -0
- package/dist/types/wallet-server/src/router/domains/ecdsa/routerAbEcdsaStrictRegistration.d.ts +199 -0
- package/dist/types/wallet-server/src/router/domains/ecdsa/thresholdEcdsaRequestValidation.d.ts +32 -0
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistration.d.ts +172 -0
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistration.typecheck.d.ts +2 -0
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistrationPartitionedStateStore.d.ts +156 -0
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistrationPartitioning.d.ts +59 -0
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistrationPersistence.d.ts +47 -0
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistrationRequestScopedRunner.d.ts +29 -0
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistrationRequestScopedRuntime.d.ts +20 -0
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/export/routerAbEd25519YaoExport.d.ts +271 -0
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/export/routerAbEd25519YaoExportRequestScopedCloudflare.d.ts +12 -0
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/recovery/routerAbEd25519YaoRecovery.d.ts +509 -0
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/recovery/routerAbEd25519YaoRecoveryActivation.typecheck.d.ts +2 -0
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/recovery/routerAbEd25519YaoRecoveryRequestScopedCloudflare.d.ts +14 -0
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/recovery/routerAbEd25519YaoRecoveryWalletSessionAuthorization.d.ts +20 -0
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/registration/routerAbEd25519YaoHttpRegistrationBackend.d.ts +56 -0
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistration.d.ts +200 -0
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistrationExecutionRecord.d.ts +70 -0
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistrationIntentAuthorization.d.ts +73 -0
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistrationRequestScopedCloudflare.d.ts +9 -0
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistrationSideEffectBoundary.d.ts +131 -0
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistrationSideEffectBoundary.typecheck.d.ts +2 -0
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistrationTwoPhaseRunner.d.ts +62 -0
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/routerAbEd25519YaoGatewayEnvelope.d.ts +17 -0
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/session/routerAbEd25519YaoWalletSession.d.ts +178 -0
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/session/routerAbEd25519YaoWalletSession.typecheck.d.ts +2 -0
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/session/thresholdEd25519RequestValidation.d.ts +19 -0
- package/dist/types/wallet-server/src/router/domains/emailOtp/emailOtpExportPolicy.d.ts +32 -0
- package/dist/types/wallet-server/src/router/domains/emailOtp/emailOtpRequestValidation.d.ts +13 -0
- package/dist/types/wallet-server/src/router/domains/emailOtp/emailOtpRouteHandlers.d.ts +35 -0
- package/dist/types/wallet-server/src/router/domains/emailOtp/emailOtpSessionRouteHelpers.d.ts +134 -0
- package/dist/types/wallet-server/src/router/domains/passkeyCustody/envelopeRevocationAdmission.d.ts +31 -0
- package/dist/types/wallet-server/src/router/domains/passkeyCustody/passkeyCustodyEnvelopeRetrieval.d.ts +85 -0
- package/dist/types/wallet-server/src/router/domains/passkeyCustody/passkeyCustodyEnvelopeRetrievalRoute.d.ts +42 -0
- package/dist/types/wallet-server/src/router/domains/passkeyCustody/registrationCustodyOutcome.d.ts +38 -0
- package/dist/types/wallet-server/src/router/domains/passkeyCustody/verifiedCustodyFactor.d.ts +35 -0
- package/dist/types/wallet-server/src/router/domains/passkeyCustody/walletCustodyRegistrationAdmission.d.ts +56 -0
- package/dist/types/wallet-server/src/router/domains/passkeyCustody/walletCustodyRegistrationCommit.d.ts +65 -0
- package/dist/types/wallet-server/src/router/domains/passkeyCustody/walletRecoveryAttempt.d.ts +59 -0
- package/dist/types/wallet-server/src/router/domains/passkeyCustody/walletRecoveryFinalization.d.ts +81 -0
- package/dist/types/wallet-server/src/router/domains/passkeyCustody/walletRecoveryKeyManifest.d.ts +184 -0
- package/dist/types/wallet-server/src/router/domains/passkeyCustody/walletRecoveryRotation.d.ts +31 -0
- package/dist/types/wallet-server/src/router/domains/signingOperations/ed25519AuthorizedOperationReceipt.d.ts +32 -0
- package/dist/types/wallet-server/src/router/domains/signingOperations/routerAbNormalSigningAdmissionCore.d.ts +48 -0
- package/dist/types/wallet-server/src/router/domains/signingOperations/routerAbPrivateSigningWorker.d.ts +909 -0
- package/dist/types/wallet-server/src/router/domains/signingOperations/walletExecutionAdmission.d.ts +104 -0
- package/dist/types/wallet-server/src/router/domains/syncAccount/syncAccountRequestValidation.d.ts +30 -0
- package/dist/types/wallet-server/src/router/domains/tenantRoot/tenantRootCustodyLineage.d.ts +14 -0
- package/dist/types/wallet-server/src/router/domains/tenantRoot/tenantRootEcdsaWalletSessionComposition.d.ts +35 -0
- package/dist/types/wallet-server/src/router/domains/tenantRoot/tenantRootEd25519WalletSessionComposition.d.ts +35 -0
- package/dist/types/wallet-server/src/router/domains/tenantRoot/tenantRootIdentityResolution.d.ts +56 -0
- package/dist/types/wallet-server/src/router/domains/walletRegistration/walletRegistrationInputs.d.ts +78 -0
- package/dist/types/wallet-server/src/router/domains/walletRegistration/walletRegistrationRoutes.d.ts +91 -0
- package/dist/types/wallet-server/src/router/domains/walletRegistration/walletRegistrationSetupPayload.d.ts +105 -0
- package/dist/types/wallet-server/src/router/domains/walletUnlock/walletUnlockRequestedCapabilitiesValidation.d.ts +39 -0
- package/dist/types/wallet-server/src/router/domains/walletUnlock/walletUnlockRouteHandlers.d.ts +172 -0
- package/dist/types/wallet-server/src/router/express-adaptor.d.ts +22 -0
- package/dist/types/wallet-server/src/router/framework/apiCredentialPorts.d.ts +82 -0
- package/dist/types/wallet-server/src/router/framework/applyRouteMetering.d.ts +23 -0
- package/dist/types/wallet-server/src/router/framework/authServicePort.d.ts +1392 -0
- package/dist/types/wallet-server/src/router/framework/enforceRoutePolicy.d.ts +48 -0
- package/dist/types/wallet-server/src/router/framework/http.d.ts +12 -0
- package/dist/types/wallet-server/src/router/framework/logger.d.ts +5 -0
- package/dist/types/wallet-server/src/router/framework/modules.d.ts +17 -0
- package/dist/types/wallet-server/src/router/framework/ror/index.d.ts +7 -0
- package/dist/types/wallet-server/src/router/framework/ror/normalize.d.ts +14 -0
- package/dist/types/wallet-server/src/router/framework/ror/options.d.ts +9 -0
- package/dist/types/wallet-server/src/router/framework/ror/provider.d.ts +17 -0
- package/dist/types/wallet-server/src/router/framework/ror/staticProvider.d.ts +11 -0
- package/dist/types/wallet-server/src/router/framework/routeAuthPolicy.d.ts +34 -0
- package/dist/types/wallet-server/src/router/framework/routeDefinitions.d.ts +27 -0
- package/dist/types/wallet-server/src/router/framework/routeDefinitions.typecheck.d.ts +2 -0
- package/dist/types/wallet-server/src/router/framework/routeExecutionContext.d.ts +29 -0
- package/dist/types/wallet-server/src/router/framework/routeExtensions.d.ts +27 -0
- package/dist/types/wallet-server/src/router/framework/routeMeteringPolicy.d.ts +17 -0
- package/dist/types/wallet-server/src/router/framework/routeRequestValidation.d.ts +5 -0
- package/dist/types/wallet-server/src/router/framework/routeResponses.d.ts +17 -0
- package/dist/types/wallet-server/src/router/framework/routerApi.d.ts +221 -0
- package/dist/types/wallet-server/src/router/framework/routerApiRouteSurface.d.ts +14 -0
- package/dist/types/wallet-server/src/router/framework/routerApiWebhooks.d.ts +12 -0
- package/dist/types/wallet-server/src/router/framework/runtimeSnapshotConsumer.d.ts +28 -0
- package/dist/types/wallet-server/src/router/framework/versionedJsonRecordStore.d.ts +20 -0
- package/dist/types/wallet-server/src/router/ror-adaptor.d.ts +3 -0
- package/dist/types/wallet-server/src/router/transport/fetch/createFetchRouter.d.ts +8 -0
- package/dist/types/wallet-server/src/router/transport/fetch/fetchRouter.types.d.ts +23 -0
- package/dist/types/wallet-server/src/router/transport/fetch/routes/auth.d.ts +3 -0
- package/dist/types/wallet-server/src/router/transport/fetch/routes/deviceLinking.d.ts +202 -0
- package/dist/types/wallet-server/src/router/transport/fetch/routes/deviceLinkingOwnerAuthorization.d.ts +92 -0
- package/dist/types/wallet-server/src/router/transport/fetch/routes/deviceManagement.d.ts +29 -0
- package/dist/types/wallet-server/src/router/transport/fetch/routes/health.d.ts +4 -0
- package/dist/types/wallet-server/src/router/transport/fetch/routes/nearPublicKeys.d.ts +3 -0
- package/dist/types/wallet-server/src/router/transport/fetch/routes/normalSigningRouterProxy.d.ts +33 -0
- package/dist/types/wallet-server/src/router/transport/fetch/routes/passkeyCustody.d.ts +66 -0
- package/dist/types/wallet-server/src/router/transport/fetch/routes/sessions.d.ts +31 -0
- package/dist/types/wallet-server/src/router/transport/fetch/routes/syncAccount.d.ts +3 -0
- package/dist/types/wallet-server/src/router/transport/fetch/routes/syncAccountBootstrap.d.ts +128 -0
- package/dist/types/wallet-server/src/router/transport/fetch/routes/thresholdEcdsa.d.ts +87 -0
- package/dist/types/wallet-server/src/router/transport/fetch/routes/thresholdEd25519.d.ts +47 -0
- package/dist/types/wallet-server/src/router/transport/fetch/routes/walletExecutionLanePreflight.d.ts +4 -0
- package/dist/types/wallet-server/src/router/transport/fetch/routes/walletRegistration.d.ts +3 -0
- package/dist/types/wallet-server/src/router/transport/fetch/routes/webauthnAuthenticators.d.ts +3 -0
- package/dist/types/wallet-server/src/router/transport/fetch/routes/wellKnown.d.ts +3 -0
- package/dist/types/wallet-server/src/storage/d1Sql.d.ts +14 -0
- package/dist/types/wallet-server/src/storage/tenantRoute.d.ts +136 -0
- package/dist/types/wallet-server/src/storage/tenantRoute.typecheck.d.ts +2 -0
- package/dist/types/wallet-server/src/tenant-root.d.ts +5 -0
- package/dist/types/wallet-server/src/threshold/session/signingSessionSeal/crypto/cipher.d.ts +45 -0
- package/dist/types/wallet-server/src/threshold/session/signingSessionSeal/crypto/shamir3PassWasm.d.ts +16 -0
- package/dist/types/wallet-server/src/threshold/session/signingSessionSeal/guards/backends.d.ts +23 -0
- package/dist/types/wallet-server/src/threshold/session/signingSessionSeal/guards/index.d.ts +46 -0
- package/dist/types/wallet-server/src/threshold/session/signingSessionSeal/idempotency.d.ts +3 -0
- package/dist/types/wallet-server/src/threshold/session/signingSessionSeal/idempotencyBackends.d.ts +24 -0
- package/dist/types/wallet-server/src/threshold/session/signingSessionSeal/idempotencyRecords.d.ts +22 -0
- package/dist/types/wallet-server/src/threshold/session/signingSessionSeal/index.d.ts +23 -0
- package/dist/types/wallet-server/src/threshold/session/signingSessionSeal/observability/audit.d.ts +9 -0
- package/dist/types/wallet-server/src/threshold/session/signingSessionSeal/options.d.ts +9 -0
- package/dist/types/wallet-server/src/threshold/session/signingSessionSeal/routesOptions.d.ts +20 -0
- package/dist/types/wallet-server/src/threshold/session/signingSessionSeal/service.d.ts +3 -0
- package/dist/types/wallet-server/src/threshold/session/signingSessionSeal/signingSessionSeal.typecheck.d.ts +2 -0
- package/dist/types/wallet-server/src/threshold/session/signingSessionSeal/signingSessionSeal.types.d.ts +148 -0
- package/dist/types/wallet-server/src/threshold/session/signingSessionSeal/transport/express.d.ts +12 -0
- package/dist/types/wallet-server/src/threshold/session/signingSessionSeal/transport/fetch.d.ts +13 -0
- package/dist/types/wallet-server/src/threshold/session/signingSessionSeal/transport/shared.d.ts +24 -0
- package/dist/types/wallet-server/src/threshold/statusCodes.d.ts +10 -0
- package/dist/types/wallet-server/src/wasm/signer.d.ts +8 -0
- package/migrations/d1-signer/0001_signer_d1_initial.sql +2486 -0
- package/migrations/d1-signer/0002_signer_post_103_canonical_upgrade.sql +1576 -0
- package/migrations/d1-signer/0003_r107_wallet_authorization.sql +299 -0
- package/migrations/d1-signer/0004_remove_legacy_email_recovery.sql +14 -0
- package/migrations/d1-signer/0005_r103p8_linked_owner_auth_bindings.sql +92 -0
- package/migrations/d1-signer/0006_r103p8_linked_device_custody_transfers.sql +77 -0
- package/migrations/d1-signer/0007_r103p8_wallet_session_auth_method_provenance.sql +18 -0
- package/migrations/d1-signer/0008_r103p8_linked_device_session_cas_guard.sql +35 -0
- package/migrations/d1-signer/0009_linked_device_email_otp.sql +405 -0
- package/migrations/d1-signer/0010_linked_device_session_target_factor.sql +78 -0
- package/migrations/d1-signer/0011_linked_device_ed25519_export_root.sql +9 -0
- package/migrations/d1-signer/0012_versioned_json_cas_guard.sql +3 -0
- package/migrations/d1-signer/0013_linked_device_export_authorization.sql +133 -0
- package/migrations/d1-signer/0014_wallet_recovery_code_locators.sql +19 -0
- package/migrations/d1-signer/0015_r103e_authority_baseline.sql +259 -0
- package/migrations/d1-signer/0016_r103e_wallet_session_authorizations_v2.sql +133 -0
- package/migrations/d1-signer/0017_r103e_link_session_state.sql +83 -0
- package/migrations/d1-signer/0018_r103e_linked_device_authority_installations.sql +34 -0
- package/migrations/d1-signer/0019_r103e_email_otp_device_methods.sql +3 -0
- package/migrations/d1-signer/0020_r103e_wallet_session_operation_credentials.sql +12 -0
- package/migrations/d1-signer/0021_linked_device_source_contribution_transcripts.sql +64 -0
- package/migrations/d1-signer/0022_r109c_multi_auth_email_cardinality.sql +118 -0
- package/migrations/d1-signer/0023_r109d_first_email_linked_device.sql +111 -0
- package/migrations/d1-signer/0024_r103f_v2_authorized_operation_claim.sql +99 -0
- package/migrations/d1-signer/0025_r109d_email_enrollment_wallet_cardinality.sql +57 -0
- package/migrations/d1-signer/0026_r115_wallet_recovery_authority_provenance.sql +253 -0
- package/migrations/d1-signer/0027_r115_email_otp_recovery_bootstrap.sql +90 -0
- package/migrations/d1-signer/0028_r103f_phase1_additive_schema_bridge.sql +1119 -0
- package/migrations/d1-signer/0029_r103f_phase0_registration_replay_tokens.sql +135 -0
- package/migrations/d1-signer/0030_r103f_wallet_session_client_capability.sql +17 -0
- package/migrations/d1-signer/0031_r103f_delete_registration_replay_tokens.sql +4 -0
- package/migrations/d1-signer/0032_r103f_exact_authorized_operation_enforcement.sql +149 -0
- package/migrations/d1-signer/0033_r103f_linked_delivery_recipient.sql +6 -0
- package/migrations/d1-signer/0034_r103f_exact_wallet_session_cutover.sql +743 -0
- package/migrations/d1-signer/0035_r103f_linked_delivery_acknowledgement_cleanup_window.sql +413 -0
- package/package.json +132 -0
- package/scripts/d1-local-migrate-signer.mjs +148 -0
- package/src/README.md +75 -0
- package/wrangler.local-hosted-wallet-gateway.toml +37 -0
|
@@ -0,0 +1,2101 @@
|
|
|
1
|
+
import { parseChallengeSubjectId, parseEmailOtpChallengeId, parseOrgId, parseProviderSubject, parseRootShareEpoch, parseWalletAuthMethodId, parseWalletAuthorityId, parseWalletId, parseWebAuthnCredentialIdB64u, parseWebAuthnRpId } from "../shared-ts/src/utils/domainIds.js";
|
|
2
|
+
import { parseDeviceId } from "../shared-ts/src/authorization/capabilityKinds.js";
|
|
3
|
+
import { parseDigestB64u } from "../shared-ts/src/utils/canonicalPrimitives.js";
|
|
4
|
+
import { parseWalletAddAuthMethodRegistrationOptions } from "../shared-ts/src/utils/addAuthMethodRegistration.js";
|
|
5
|
+
import { addAuthMethodIntentGrantFromString, addSignerIntentGrantFromString, normalizeAddAuthMethodInput, normalizeAddAuthMethodIntentCaller, normalizeAddSignerSelection, normalizeRegistrationAuthMethodInput, normalizeRegistrationSignerPlan, registrationSignerBranchKeyFromString, registrationSignerPlanFromSelection, registrationSignerSetSelectionFromPlan } from "../shared-ts/src/utils/registrationIntent.js";
|
|
6
|
+
import { parseWebAuthnAuthenticatorDeviceInfo } from "../shared-ts/src/utils/webauthnDeviceInfo.js";
|
|
7
|
+
import { parseRouterAbEd25519YaoRegistrationActivationAdmissionReceiptV1, parseRouterAbEd25519YaoRegistrationActivationResultV1, parseRouterAbEd25519YaoRegistrationAdmissionRequestV1 } from "../shared-ts/src/utils/routerAbEd25519Yao.js";
|
|
8
|
+
import { derivationClientSharePublicKey33B64uFromString, ecdsaClientRootPublicKey33B64uFromString } from "../shared-ts/src/threshold/ecdsaDerivationRoleLocalBootstrap.js";
|
|
9
|
+
import { parseWalletAuthAuthorityRef } from "../shared-ts/src/utils/walletAuthAuthority.js";
|
|
10
|
+
import { parseRouterAbEcdsaDerivationNormalSigningStateV1, parseRouterAbEcdsaDerivationPublicCapabilityV1, parseRouterAbEcdsaRegistrationActivationReceiptV1, parseRouterAbEcdsaRegistrationRequestFactsV1, parseRouterAbEcdsaRegistrationRequestV1, parseRouterAbEcdsaStrictForwardedRegistrationResponseV1, parseRouterAbEcdsaVerifiedClientActivationFactsV1 } from "../shared-ts/src/utils/routerAbEcdsaDerivation.js";
|
|
11
|
+
import { thresholdEcdsaChainTargetFromValue, thresholdEcdsaChainTargetKey } from "./thresholdEcdsaChainTarget.js";
|
|
12
|
+
import "./defaultConfigsServer.js";
|
|
13
|
+
import { parseWalletEd25519SignerRecord } from "./d1WalletStore.js";
|
|
14
|
+
import { registrationPreparationIdFromString } from "./types.js";
|
|
15
|
+
import { parsePasskeyCustodyEnvelopeRecord } from "../shared-ts/src/passkey-custody/custodyEnvelope.js";
|
|
16
|
+
import "../shared-ts/src/passkey-custody/index.js";
|
|
17
|
+
import { parseEcdsaDerivationPublicIdentity } from "./ThresholdService/validation.js";
|
|
18
|
+
import { parseStoredRouterAbEcdsaPendingActivationV1 } from "../router/domains/ecdsa/routerAbEcdsaStrictRegistration.js";
|
|
19
|
+
//#region src/core/RegistrationCeremonyStore.ts
|
|
20
|
+
function buildStoredWalletRegistrationPreparedContext(input) {
|
|
21
|
+
const signingRootId = String(input.signingRootId || "").trim();
|
|
22
|
+
const signingRootVersion = String(input.signingRootVersion || "").trim();
|
|
23
|
+
if (!signingRootId || !signingRootVersion) throw new Error("registration prepared context requires signing-root scope");
|
|
24
|
+
return {
|
|
25
|
+
kind: "wallet_registration_prepared_context_v1",
|
|
26
|
+
signingRootId,
|
|
27
|
+
signingRootVersion,
|
|
28
|
+
runtimePolicy: input.runtimePolicyScope ? {
|
|
29
|
+
kind: "runtime_policy_scope",
|
|
30
|
+
scope: {
|
|
31
|
+
orgId: input.runtimePolicyScope.orgId,
|
|
32
|
+
projectId: input.runtimePolicyScope.projectId,
|
|
33
|
+
envId: input.runtimePolicyScope.envId,
|
|
34
|
+
signingRootVersion: input.runtimePolicyScope.signingRootVersion
|
|
35
|
+
}
|
|
36
|
+
} : { kind: "signing_root_only" },
|
|
37
|
+
ecdsa: input.ecdsaChainTargets && input.ecdsaChainTargets.length > 0 ? {
|
|
38
|
+
kind: "evm_family_ecdsa_requested",
|
|
39
|
+
chainTargets: input.ecdsaChainTargets.map((target) => ({ ...target }))
|
|
40
|
+
} : { kind: "evm_family_ecdsa_absent" }
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function storedWalletRegistrationPreparedContextsMatch(left, right) {
|
|
44
|
+
if (left.kind !== right.kind || left.signingRootId !== right.signingRootId || left.signingRootVersion !== right.signingRootVersion || left.runtimePolicy.kind !== right.runtimePolicy.kind || left.ecdsa.kind !== right.ecdsa.kind) return false;
|
|
45
|
+
if (left.runtimePolicy.kind === "runtime_policy_scope" && right.runtimePolicy.kind === "runtime_policy_scope" && (left.runtimePolicy.scope.orgId !== right.runtimePolicy.scope.orgId || left.runtimePolicy.scope.projectId !== right.runtimePolicy.scope.projectId || left.runtimePolicy.scope.envId !== right.runtimePolicy.scope.envId || left.runtimePolicy.scope.signingRootVersion !== right.runtimePolicy.scope.signingRootVersion)) return false;
|
|
46
|
+
if (left.ecdsa.kind === "evm_family_ecdsa_requested" && right.ecdsa.kind === "evm_family_ecdsa_requested") {
|
|
47
|
+
const leftTargets = left.ecdsa.chainTargets;
|
|
48
|
+
const rightTargets = right.ecdsa.chainTargets;
|
|
49
|
+
if (leftTargets.length !== rightTargets.length) return false;
|
|
50
|
+
return leftTargets.every((target, index) => thresholdEcdsaChainTargetKey(target) === thresholdEcdsaChainTargetKey(rightTargets[index]));
|
|
51
|
+
}
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
function storedRegistrationAuthoritiesMatch(left, right) {
|
|
55
|
+
if (left.kind !== right.kind) return false;
|
|
56
|
+
switch (left.kind) {
|
|
57
|
+
case "passkey": return right.kind === "passkey" && left.walletId === right.walletId && left.rpId === right.rpId && left.credentialIdB64u === right.credentialIdB64u && left.credentialPublicKeyB64u === right.credentialPublicKeyB64u && left.registrationIntentDigestB64u === right.registrationIntentDigestB64u;
|
|
58
|
+
case "email_otp": return right.kind === "email_otp" && left.proofKind === right.proofKind && left.walletId === right.walletId && left.providerSubject === right.providerSubject && left.emailHashHex === right.emailHashHex && left.registrationAuthorityId === right.registrationAuthorityId && left.finalWalletId === right.finalWalletId && left.orgId === right.orgId && left.registrationIntentDigestB64u === right.registrationIntentDigestB64u;
|
|
59
|
+
default: return left;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function buildStoredWalletRegistrationEvmFamilyEcdsaFinalizedBranch(input) {
|
|
63
|
+
const { activationOwner: _activationOwner, ...activated } = input.activated;
|
|
64
|
+
return {
|
|
65
|
+
...activated,
|
|
66
|
+
kind: "evm_family_ecdsa_finalized",
|
|
67
|
+
finalizedAtMs: input.finalizedAtMs
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function buildStoredWalletRegistrationEvmFamilyEcdsaPreparedBranch(input) {
|
|
71
|
+
return {
|
|
72
|
+
kind: "evm_family_ecdsa_prepared",
|
|
73
|
+
branchKey: input.branchKey,
|
|
74
|
+
derivationKind: input.ecdsa.kind,
|
|
75
|
+
chainTargets: input.ecdsa.chainTargets,
|
|
76
|
+
prepare: input.ecdsa.prepare,
|
|
77
|
+
strictRegistration: input.ecdsa.strictRegistration,
|
|
78
|
+
strictRegistrationBindingJson: input.ecdsa.strictRegistrationBindingJson
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function buildStoredWalletRegistrationNearEd25519YaoAuthorizedBranch(input) {
|
|
82
|
+
return {
|
|
83
|
+
kind: "near_ed25519_yao_authorized",
|
|
84
|
+
branchKey: input.branchKey,
|
|
85
|
+
admissionRequest: input.admissionRequest,
|
|
86
|
+
admissionReceipt: input.admissionReceipt
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function findStoredWalletRegistrationNearEd25519YaoBranch(state) {
|
|
90
|
+
for (const branch of state.branches) if (branch.kind === "near_ed25519_yao_authorized") return branch;
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
function findStoredWalletRegistrationEvmFamilyEcdsaBranch(state) {
|
|
94
|
+
for (const branch of state.branches) if (branch.kind === "evm_family_ecdsa_prepared" || branch.kind === "evm_family_ecdsa_response_claimed" || branch.kind === "evm_family_ecdsa_pending_activation" || branch.kind === "evm_family_ecdsa_activation_claimed" || branch.kind === "evm_family_ecdsa_activated" || branch.kind === "evm_family_ecdsa_finalized") return branch;
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
function replaceStoredWalletRegistrationSignerBranch(input) {
|
|
98
|
+
return {
|
|
99
|
+
kind: "signer_set_registration",
|
|
100
|
+
branches: input.state.branches.map((branch) => branch.branchKey === input.replacement.branchKey ? input.replacement : branch)
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The verified authority, or `null` while the ceremony is still awaiting its
|
|
105
|
+
* proof. Legs downstream of respond (activation, finalization, persistence)
|
|
106
|
+
* require a verified authority and treat `null` as an invalid state rather
|
|
107
|
+
* than a missing field.
|
|
108
|
+
*/
|
|
109
|
+
function verifiedRegistrationCeremonyAuthority(ceremony) {
|
|
110
|
+
return ceremony.authorityState.kind === "verified" ? ceremony.authorityState.authority : null;
|
|
111
|
+
}
|
|
112
|
+
function registrationCeremonyAuthorityRpId(authorityState) {
|
|
113
|
+
switch (authorityState.kind) {
|
|
114
|
+
case "awaiting_proof": return authorityState.authMethod.kind === "passkey" ? String(authorityState.authMethod.rpId) : null;
|
|
115
|
+
case "verified": return authorityState.authority.kind === "passkey" ? String(authorityState.authority.rpId) : null;
|
|
116
|
+
default: return authorityState;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
function parseTerminalRegistrationCeremonyCancellationResult(value) {
|
|
120
|
+
const parsed = parseJsonValue(value);
|
|
121
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) return null;
|
|
122
|
+
const record = parsed;
|
|
123
|
+
switch (record.kind) {
|
|
124
|
+
case "cancelled": return record.ceremonyDeleted === true ? {
|
|
125
|
+
kind: "cancelled",
|
|
126
|
+
ceremonyDeleted: true
|
|
127
|
+
} : null;
|
|
128
|
+
case "not_found": return record.ceremonyDeleted === false ? {
|
|
129
|
+
kind: "not_found",
|
|
130
|
+
ceremonyDeleted: false
|
|
131
|
+
} : null;
|
|
132
|
+
default: return null;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
var MemoryRegistrationCeremonyStore = class {
|
|
136
|
+
constructor() {
|
|
137
|
+
this.addAuthMethodIntents = /* @__PURE__ */ new Map();
|
|
138
|
+
this.addSignerIntents = /* @__PURE__ */ new Map();
|
|
139
|
+
this.ceremonies = /* @__PURE__ */ new Map();
|
|
140
|
+
this.addSignerFinalizeReplays = /* @__PURE__ */ new Map();
|
|
141
|
+
this.addSignerFinalizeReplayClaims = /* @__PURE__ */ new Map();
|
|
142
|
+
this.addAuthMethodCeremonies = /* @__PURE__ */ new Map();
|
|
143
|
+
this.addSignerCeremonies = /* @__PURE__ */ new Map();
|
|
144
|
+
}
|
|
145
|
+
async putAddAuthMethodIntent(intent) {
|
|
146
|
+
this.pruneExpired();
|
|
147
|
+
this.addAuthMethodIntents.set(intent.grant, intent);
|
|
148
|
+
}
|
|
149
|
+
async getAddAuthMethodIntent(grant) {
|
|
150
|
+
this.pruneExpired();
|
|
151
|
+
const intent = this.addAuthMethodIntents.get(String(grant || "").trim()) || null;
|
|
152
|
+
if (!intent || intent.expiresAtMs <= Date.now()) return null;
|
|
153
|
+
return intent;
|
|
154
|
+
}
|
|
155
|
+
async takeAddAuthMethodIntent(grant) {
|
|
156
|
+
this.pruneExpired();
|
|
157
|
+
const key = String(grant || "").trim();
|
|
158
|
+
const intent = this.addAuthMethodIntents.get(key) || null;
|
|
159
|
+
if (!intent) return null;
|
|
160
|
+
this.addAuthMethodIntents.delete(key);
|
|
161
|
+
if (intent.expiresAtMs <= Date.now()) return null;
|
|
162
|
+
return {
|
|
163
|
+
...intent,
|
|
164
|
+
kind: "add_auth_method_intent_consumed",
|
|
165
|
+
consumedAtMs: Date.now()
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
async putAddSignerIntent(intent) {
|
|
169
|
+
this.pruneExpired();
|
|
170
|
+
this.addSignerIntents.set(intent.grant, intent);
|
|
171
|
+
}
|
|
172
|
+
async getAddSignerIntent(grant) {
|
|
173
|
+
this.pruneExpired();
|
|
174
|
+
const intent = this.addSignerIntents.get(String(grant || "").trim()) || null;
|
|
175
|
+
if (!intent || intent.expiresAtMs <= Date.now()) return null;
|
|
176
|
+
return intent;
|
|
177
|
+
}
|
|
178
|
+
async takeAddSignerIntent(grant) {
|
|
179
|
+
this.pruneExpired();
|
|
180
|
+
const key = String(grant || "").trim();
|
|
181
|
+
const intent = this.addSignerIntents.get(key) || null;
|
|
182
|
+
if (!intent) return null;
|
|
183
|
+
this.addSignerIntents.delete(key);
|
|
184
|
+
if (intent.expiresAtMs <= Date.now()) return null;
|
|
185
|
+
return {
|
|
186
|
+
...intent,
|
|
187
|
+
kind: "add_signer_intent_consumed",
|
|
188
|
+
consumedAtMs: Date.now()
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
async putCeremony(ceremony) {
|
|
192
|
+
this.pruneExpired();
|
|
193
|
+
this.ceremonies.set(ceremony.registrationCeremonyId, ceremony);
|
|
194
|
+
}
|
|
195
|
+
async getCeremony(registrationCeremonyId) {
|
|
196
|
+
this.pruneExpired();
|
|
197
|
+
const ceremony = this.ceremonies.get(String(registrationCeremonyId || "").trim()) || null;
|
|
198
|
+
if (!ceremony || ceremony.expiresAtMs <= Date.now()) return null;
|
|
199
|
+
return ceremony;
|
|
200
|
+
}
|
|
201
|
+
async updateCeremony(ceremony) {
|
|
202
|
+
this.pruneExpired();
|
|
203
|
+
if (ceremony.expiresAtMs <= Date.now()) return;
|
|
204
|
+
this.ceremonies.set(ceremony.registrationCeremonyId, ceremony);
|
|
205
|
+
}
|
|
206
|
+
async takeCeremony(registrationCeremonyId) {
|
|
207
|
+
this.pruneExpired();
|
|
208
|
+
const key = String(registrationCeremonyId || "").trim();
|
|
209
|
+
const ceremony = this.ceremonies.get(key) || null;
|
|
210
|
+
this.ceremonies.delete(key);
|
|
211
|
+
if (!ceremony || ceremony.expiresAtMs <= Date.now()) return null;
|
|
212
|
+
return ceremony;
|
|
213
|
+
}
|
|
214
|
+
async cancelTerminalCeremony(input) {
|
|
215
|
+
this.pruneExpired();
|
|
216
|
+
const registrationCeremonyId = trimString(input.registrationCeremonyId);
|
|
217
|
+
const ceremony = this.ceremonies.get(registrationCeremonyId);
|
|
218
|
+
if (!ceremony) return {
|
|
219
|
+
kind: "not_found",
|
|
220
|
+
ceremonyDeleted: false
|
|
221
|
+
};
|
|
222
|
+
if (ceremony.intent.walletId !== input.walletId) throw new Error("Terminal registration cancellation walletId mismatch");
|
|
223
|
+
this.ceremonies.delete(registrationCeremonyId);
|
|
224
|
+
return {
|
|
225
|
+
kind: "cancelled",
|
|
226
|
+
ceremonyDeleted: true
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
async putAddSignerFinalizeReplay(replay) {
|
|
230
|
+
this.pruneExpired();
|
|
231
|
+
this.addSignerFinalizeReplays.set(addSignerFinalizeReplayKey(replay), replay);
|
|
232
|
+
this.addSignerFinalizeReplayClaims.set(replay.addSignerCeremonyId, replay);
|
|
233
|
+
}
|
|
234
|
+
async getAddSignerFinalizeReplay(input) {
|
|
235
|
+
this.pruneExpired();
|
|
236
|
+
const replay = this.addSignerFinalizeReplays.get(addSignerFinalizeReplayKey(input)) || null;
|
|
237
|
+
if (!replay || replay.expiresAtMs <= Date.now()) return null;
|
|
238
|
+
return replay;
|
|
239
|
+
}
|
|
240
|
+
async getAddSignerFinalizeReplayForCeremony(addSignerCeremonyId) {
|
|
241
|
+
this.pruneExpired();
|
|
242
|
+
const replay = this.addSignerFinalizeReplayClaims.get(trimString(addSignerCeremonyId)) || null;
|
|
243
|
+
if (!replay || replay.expiresAtMs <= Date.now()) return null;
|
|
244
|
+
return replay;
|
|
245
|
+
}
|
|
246
|
+
async putAddAuthMethodCeremony(ceremony) {
|
|
247
|
+
this.pruneExpired();
|
|
248
|
+
this.addAuthMethodCeremonies.set(ceremony.addAuthMethodCeremonyId, ceremony);
|
|
249
|
+
}
|
|
250
|
+
async getAddAuthMethodCeremony(addAuthMethodCeremonyId) {
|
|
251
|
+
this.pruneExpired();
|
|
252
|
+
const ceremony = this.addAuthMethodCeremonies.get(String(addAuthMethodCeremonyId || "").trim()) || null;
|
|
253
|
+
if (!ceremony || ceremony.expiresAtMs <= Date.now()) return null;
|
|
254
|
+
return ceremony;
|
|
255
|
+
}
|
|
256
|
+
async updateAddAuthMethodCeremony(ceremony) {
|
|
257
|
+
this.pruneExpired();
|
|
258
|
+
if (ceremony.expiresAtMs <= Date.now()) return;
|
|
259
|
+
this.addAuthMethodCeremonies.set(ceremony.addAuthMethodCeremonyId, ceremony);
|
|
260
|
+
}
|
|
261
|
+
async takeAddAuthMethodCeremony(addAuthMethodCeremonyId) {
|
|
262
|
+
this.pruneExpired();
|
|
263
|
+
const key = String(addAuthMethodCeremonyId || "").trim();
|
|
264
|
+
const ceremony = this.addAuthMethodCeremonies.get(key) || null;
|
|
265
|
+
this.addAuthMethodCeremonies.delete(key);
|
|
266
|
+
if (!ceremony || ceremony.expiresAtMs <= Date.now()) return null;
|
|
267
|
+
return ceremony;
|
|
268
|
+
}
|
|
269
|
+
async putAddSignerCeremony(ceremony) {
|
|
270
|
+
this.pruneExpired();
|
|
271
|
+
this.addSignerCeremonies.set(ceremony.addSignerCeremonyId, ceremony);
|
|
272
|
+
}
|
|
273
|
+
async getAddSignerCeremony(addSignerCeremonyId) {
|
|
274
|
+
this.pruneExpired();
|
|
275
|
+
const ceremony = this.addSignerCeremonies.get(String(addSignerCeremonyId || "").trim()) || null;
|
|
276
|
+
if (!ceremony || ceremony.expiresAtMs <= Date.now()) return null;
|
|
277
|
+
return ceremony;
|
|
278
|
+
}
|
|
279
|
+
async updateAddSignerCeremony(ceremony) {
|
|
280
|
+
this.pruneExpired();
|
|
281
|
+
if (ceremony.expiresAtMs <= Date.now()) return;
|
|
282
|
+
this.addSignerCeremonies.set(ceremony.addSignerCeremonyId, ceremony);
|
|
283
|
+
}
|
|
284
|
+
async takeAddSignerCeremony(addSignerCeremonyId) {
|
|
285
|
+
this.pruneExpired();
|
|
286
|
+
const key = String(addSignerCeremonyId || "").trim();
|
|
287
|
+
const ceremony = this.addSignerCeremonies.get(key) || null;
|
|
288
|
+
this.addSignerCeremonies.delete(key);
|
|
289
|
+
if (!ceremony || ceremony.expiresAtMs <= Date.now()) return null;
|
|
290
|
+
return ceremony;
|
|
291
|
+
}
|
|
292
|
+
pruneExpired() {
|
|
293
|
+
const now = Date.now();
|
|
294
|
+
for (const [key, intent] of this.addAuthMethodIntents) if (intent.expiresAtMs <= now) this.addAuthMethodIntents.delete(key);
|
|
295
|
+
for (const [key, intent] of this.addSignerIntents) if (intent.expiresAtMs <= now) this.addSignerIntents.delete(key);
|
|
296
|
+
for (const [key, ceremony] of this.ceremonies) if (ceremony.expiresAtMs <= now) this.ceremonies.delete(key);
|
|
297
|
+
for (const [key, replay] of this.addSignerFinalizeReplays) if (replay.expiresAtMs <= now) this.addSignerFinalizeReplays.delete(key);
|
|
298
|
+
for (const [key, replay] of this.addSignerFinalizeReplayClaims) if (replay.expiresAtMs <= now) this.addSignerFinalizeReplayClaims.delete(key);
|
|
299
|
+
for (const [key, ceremony] of this.addAuthMethodCeremonies) if (ceremony.expiresAtMs <= now) this.addAuthMethodCeremonies.delete(key);
|
|
300
|
+
for (const [key, ceremony] of this.addSignerCeremonies) if (ceremony.expiresAtMs <= now) this.addSignerCeremonies.delete(key);
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
function assertNever(value) {
|
|
304
|
+
throw new Error(`Unexpected registration ceremony store branch: ${String(value)}`);
|
|
305
|
+
}
|
|
306
|
+
function trimString(value) {
|
|
307
|
+
return typeof value === "string" ? value.trim() : "";
|
|
308
|
+
}
|
|
309
|
+
function addSignerFinalizeReplayKey(input) {
|
|
310
|
+
return `${trimString(input.addSignerCeremonyId)}:${trimString(input.idempotencyKey)}`;
|
|
311
|
+
}
|
|
312
|
+
function parseJsonValue(value) {
|
|
313
|
+
if (typeof value !== "string") return value;
|
|
314
|
+
try {
|
|
315
|
+
return JSON.parse(value);
|
|
316
|
+
} catch {
|
|
317
|
+
return null;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
function parseStoredWalletAddSignerFinalizeParticipantIds(value) {
|
|
321
|
+
if (!Array.isArray(value) || value.length !== 2) return null;
|
|
322
|
+
const first = value[0];
|
|
323
|
+
const second = value[1];
|
|
324
|
+
if (typeof first !== "number" || !Number.isSafeInteger(first) || first <= 0 || typeof second !== "number" || !Number.isSafeInteger(second) || second <= 0) return null;
|
|
325
|
+
return [first, second];
|
|
326
|
+
}
|
|
327
|
+
function parseStoredWalletAddSignerFinalizeEd25519Result(value) {
|
|
328
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
|
|
329
|
+
const record = value;
|
|
330
|
+
const signerSlot = Number(record.signerSlot);
|
|
331
|
+
const nearAccountId = trimString(record.nearAccountId);
|
|
332
|
+
const nearEd25519SigningKeyId = trimString(record.nearEd25519SigningKeyId);
|
|
333
|
+
const publicKey = trimString(record.publicKey);
|
|
334
|
+
const relayerKeyId = trimString(record.relayerKeyId);
|
|
335
|
+
const keyVersion = trimString(record.keyVersion);
|
|
336
|
+
const participantIds = parseStoredWalletAddSignerFinalizeParticipantIds(record.participantIds);
|
|
337
|
+
if (record.recoveryExportCapable !== true || !Number.isSafeInteger(signerSlot) || signerSlot <= 0 || !nearAccountId || !nearEd25519SigningKeyId || !publicKey.startsWith("ed25519:") || !relayerKeyId || !keyVersion || !participantIds) return null;
|
|
338
|
+
return {
|
|
339
|
+
signerSlot,
|
|
340
|
+
nearAccountId,
|
|
341
|
+
nearEd25519SigningKeyId,
|
|
342
|
+
publicKey,
|
|
343
|
+
relayerKeyId,
|
|
344
|
+
keyVersion,
|
|
345
|
+
recoveryExportCapable: true,
|
|
346
|
+
participantIds
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
function parseStoredWalletAddSignerFinalizeEcdsaWalletKey(value) {
|
|
350
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
|
|
351
|
+
const record = value;
|
|
352
|
+
if (record.keyScope !== "evm-family") return null;
|
|
353
|
+
const chainTarget = thresholdEcdsaChainTargetFromValue(record.chainTarget);
|
|
354
|
+
const walletId = trimString(record.walletId);
|
|
355
|
+
const evmFamilySigningKeySlotId = trimString(record.evmFamilySigningKeySlotId);
|
|
356
|
+
const keyHandle = trimString(record.keyHandle);
|
|
357
|
+
const ecdsaThresholdKeyId = trimString(record.ecdsaThresholdKeyId);
|
|
358
|
+
const signingRootId = trimString(record.signingRootId);
|
|
359
|
+
const signingRootVersion = trimString(record.signingRootVersion);
|
|
360
|
+
const thresholdEcdsaPublicKeyB64u = trimString(record.thresholdEcdsaPublicKeyB64u);
|
|
361
|
+
const thresholdOwnerAddress = trimString(record.thresholdOwnerAddress);
|
|
362
|
+
const relayerKeyId = trimString(record.relayerKeyId);
|
|
363
|
+
const relayerVerifyingShareB64u = trimString(record.relayerVerifyingShareB64u);
|
|
364
|
+
const contextBinding32B64u = trimString(record.contextBinding32B64u);
|
|
365
|
+
const derivationClientSharePublicKey33B64u = trimString(record.derivationClientSharePublicKey33B64u);
|
|
366
|
+
const clientShareRetryCounter = Number(record.clientShareRetryCounter);
|
|
367
|
+
const relayerShareRetryCounter = Number(record.relayerShareRetryCounter);
|
|
368
|
+
const participantIds = parseStoredWalletAddSignerFinalizeParticipantIds(record.participantIds);
|
|
369
|
+
let publicCapability;
|
|
370
|
+
let parsedDerivationClientSharePublicKey33B64u;
|
|
371
|
+
try {
|
|
372
|
+
publicCapability = parseRouterAbEcdsaDerivationPublicCapabilityV1(record.publicCapability);
|
|
373
|
+
parsedDerivationClientSharePublicKey33B64u = derivationClientSharePublicKey33B64uFromString(derivationClientSharePublicKey33B64u);
|
|
374
|
+
} catch {
|
|
375
|
+
return null;
|
|
376
|
+
}
|
|
377
|
+
if (!chainTarget || !walletId || !evmFamilySigningKeySlotId || !keyHandle || !ecdsaThresholdKeyId || !signingRootId || !signingRootVersion || !thresholdEcdsaPublicKeyB64u || !thresholdOwnerAddress || !relayerKeyId || !relayerVerifyingShareB64u || !contextBinding32B64u || !derivationClientSharePublicKey33B64u || !Number.isSafeInteger(clientShareRetryCounter) || clientShareRetryCounter < 0 || !Number.isSafeInteger(relayerShareRetryCounter) || relayerShareRetryCounter < 0 || !participantIds || participantIds[0] !== 1 || participantIds[1] !== 2) return null;
|
|
378
|
+
return {
|
|
379
|
+
keyScope: "evm-family",
|
|
380
|
+
chainTarget,
|
|
381
|
+
walletId,
|
|
382
|
+
evmFamilySigningKeySlotId,
|
|
383
|
+
keyHandle,
|
|
384
|
+
ecdsaThresholdKeyId,
|
|
385
|
+
signingRootId,
|
|
386
|
+
signingRootVersion,
|
|
387
|
+
thresholdEcdsaPublicKeyB64u,
|
|
388
|
+
thresholdOwnerAddress,
|
|
389
|
+
relayerKeyId,
|
|
390
|
+
relayerVerifyingShareB64u,
|
|
391
|
+
contextBinding32B64u,
|
|
392
|
+
derivationClientSharePublicKey33B64u: parsedDerivationClientSharePublicKey33B64u,
|
|
393
|
+
clientShareRetryCounter,
|
|
394
|
+
relayerShareRetryCounter,
|
|
395
|
+
participantIds: [1, 2],
|
|
396
|
+
publicCapability
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
function parseStoredWalletAddSignerFinalizeEcdsaResult(value) {
|
|
400
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
|
|
401
|
+
const record = value;
|
|
402
|
+
if (!Array.isArray(record.walletKeys) || record.walletKeys.length === 0) return null;
|
|
403
|
+
const walletKeys = [];
|
|
404
|
+
for (const rawWalletKey of record.walletKeys) {
|
|
405
|
+
const walletKey = parseStoredWalletAddSignerFinalizeEcdsaWalletKey(rawWalletKey);
|
|
406
|
+
if (!walletKey) return null;
|
|
407
|
+
walletKeys.push(walletKey);
|
|
408
|
+
}
|
|
409
|
+
return { walletKeys };
|
|
410
|
+
}
|
|
411
|
+
function parseStoredWalletAddSignerFinalizeSuccess(value) {
|
|
412
|
+
const parsed = parseJsonValue(value);
|
|
413
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) return null;
|
|
414
|
+
const record = parsed;
|
|
415
|
+
if (record.ok !== true) return null;
|
|
416
|
+
const walletId = parseWalletId(record.walletId);
|
|
417
|
+
if (!walletId.ok) return null;
|
|
418
|
+
if (record.kind === "near_ed25519") {
|
|
419
|
+
if (!trimString(record.rpId) || !trimString(record.credentialIdB64u)) return null;
|
|
420
|
+
const ed25519 = parseStoredWalletAddSignerFinalizeEd25519Result(record.ed25519);
|
|
421
|
+
return ed25519 ? {
|
|
422
|
+
ok: true,
|
|
423
|
+
kind: "near_ed25519",
|
|
424
|
+
walletId: walletId.value,
|
|
425
|
+
rpId: trimString(record.rpId),
|
|
426
|
+
credentialIdB64u: trimString(record.credentialIdB64u),
|
|
427
|
+
ed25519
|
|
428
|
+
} : null;
|
|
429
|
+
}
|
|
430
|
+
if (record.kind !== "evm_family_ecdsa") return null;
|
|
431
|
+
const ecdsa = parseStoredWalletAddSignerFinalizeEcdsaResult(record.ecdsa);
|
|
432
|
+
if (!ecdsa) return null;
|
|
433
|
+
const rpId = trimString(record.rpId);
|
|
434
|
+
return rpId ? {
|
|
435
|
+
ok: true,
|
|
436
|
+
kind: "evm_family_ecdsa",
|
|
437
|
+
walletId: walletId.value,
|
|
438
|
+
rpId,
|
|
439
|
+
ecdsa
|
|
440
|
+
} : {
|
|
441
|
+
ok: true,
|
|
442
|
+
kind: "evm_family_ecdsa",
|
|
443
|
+
walletId: walletId.value,
|
|
444
|
+
ecdsa
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
function parseStoredWalletAddSignerFinalizeReplay(value) {
|
|
448
|
+
const parsed = parseJsonValue(value);
|
|
449
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) return null;
|
|
450
|
+
const record = parsed;
|
|
451
|
+
if (record.kind !== "wallet_add_signer_finalize_replay_v1") return null;
|
|
452
|
+
const addSignerCeremonyId = trimString(record.addSignerCeremonyId);
|
|
453
|
+
const idempotencyKey = trimString(record.idempotencyKey);
|
|
454
|
+
const createdAtMs = Number(record.createdAtMs);
|
|
455
|
+
const expiresAtMs = Number(record.expiresAtMs);
|
|
456
|
+
const request = parseStoredWalletAddSignerFinalizeRequest(record.request);
|
|
457
|
+
const response = parseStoredWalletAddSignerFinalizeSuccess(record.response);
|
|
458
|
+
if (!addSignerCeremonyId || !idempotencyKey || !request || request.addSignerCeremonyId !== addSignerCeremonyId || request.idempotencyKey !== idempotencyKey || !response || request.kind !== response.kind || !Number.isSafeInteger(createdAtMs) || createdAtMs <= 0 || !Number.isSafeInteger(expiresAtMs) || expiresAtMs <= 0) return null;
|
|
459
|
+
return {
|
|
460
|
+
kind: "wallet_add_signer_finalize_replay_v1",
|
|
461
|
+
addSignerCeremonyId,
|
|
462
|
+
idempotencyKey,
|
|
463
|
+
request,
|
|
464
|
+
response,
|
|
465
|
+
createdAtMs,
|
|
466
|
+
expiresAtMs
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
function parseStoredWalletAddSignerFinalizeRequest(value) {
|
|
470
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
|
|
471
|
+
const record = value;
|
|
472
|
+
const addSignerCeremonyId = trimString(record.addSignerCeremonyId);
|
|
473
|
+
const idempotencyKey = trimString(record.idempotencyKey);
|
|
474
|
+
if (!addSignerCeremonyId || !idempotencyKey) return null;
|
|
475
|
+
if (record.kind === "near_ed25519") {
|
|
476
|
+
if (record.custodyKeySet === null || typeof record.custodyKeySet !== "object" || Array.isArray(record.custodyKeySet) || record.activationReference === null || typeof record.activationReference !== "object" || Array.isArray(record.activationReference)) return null;
|
|
477
|
+
const custodyKeySet = record.custodyKeySet;
|
|
478
|
+
const activationReference = record.activationReference;
|
|
479
|
+
const lifecycleId = trimString(activationReference.lifecycleId);
|
|
480
|
+
const sessionId = parseStoredBytes32(activationReference.sessionId);
|
|
481
|
+
if (custodyKeySet.kind !== "near_ed25519_v1" || !lifecycleId || !sessionId) return null;
|
|
482
|
+
let keyManifestDigestB64u;
|
|
483
|
+
try {
|
|
484
|
+
keyManifestDigestB64u = parseDigestB64u(custodyKeySet.keyManifestDigestB64u);
|
|
485
|
+
} catch {
|
|
486
|
+
return null;
|
|
487
|
+
}
|
|
488
|
+
const registeredPublicKeyB64u = trimString(custodyKeySet.registeredPublicKeyB64u);
|
|
489
|
+
if (!registeredPublicKeyB64u) return null;
|
|
490
|
+
return {
|
|
491
|
+
kind: "near_ed25519",
|
|
492
|
+
addSignerCeremonyId,
|
|
493
|
+
idempotencyKey,
|
|
494
|
+
custodyKeySet: {
|
|
495
|
+
kind: "near_ed25519_v1",
|
|
496
|
+
keyManifestDigestB64u,
|
|
497
|
+
registeredPublicKeyB64u
|
|
498
|
+
},
|
|
499
|
+
activationReference: {
|
|
500
|
+
lifecycleId,
|
|
501
|
+
sessionId
|
|
502
|
+
}
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
if (record.kind !== "evm_family_ecdsa" || !Array.isArray(record.expectedKeyHandles) || record.expectedKeyHandles.length !== 1) return null;
|
|
506
|
+
const expectedKeyHandle = trimString(record.expectedKeyHandles[0]);
|
|
507
|
+
if (record.custodyKeySet === null || typeof record.custodyKeySet !== "object" || Array.isArray(record.custodyKeySet)) return null;
|
|
508
|
+
const custodyKeySet = record.custodyKeySet;
|
|
509
|
+
if (!expectedKeyHandle || custodyKeySet.kind !== "evm_family_ecdsa_v1") return null;
|
|
510
|
+
let keyManifestDigestB64u;
|
|
511
|
+
let clientRootPublicKey33B64u;
|
|
512
|
+
try {
|
|
513
|
+
keyManifestDigestB64u = parseDigestB64u(custodyKeySet.keyManifestDigestB64u);
|
|
514
|
+
clientRootPublicKey33B64u = ecdsaClientRootPublicKey33B64uFromString(trimString(custodyKeySet.clientRootPublicKey33B64u));
|
|
515
|
+
} catch {
|
|
516
|
+
return null;
|
|
517
|
+
}
|
|
518
|
+
return {
|
|
519
|
+
kind: "evm_family_ecdsa",
|
|
520
|
+
addSignerCeremonyId,
|
|
521
|
+
idempotencyKey,
|
|
522
|
+
custodyKeySet: {
|
|
523
|
+
kind: "evm_family_ecdsa_v1",
|
|
524
|
+
keyManifestDigestB64u,
|
|
525
|
+
clientRootPublicKey33B64u
|
|
526
|
+
},
|
|
527
|
+
expectedKeyHandles: [expectedKeyHandle]
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
function parseStoredBytes32(value) {
|
|
531
|
+
if (!Array.isArray(value) || value.length !== 32) return null;
|
|
532
|
+
const bytes = [];
|
|
533
|
+
for (const byte of value) {
|
|
534
|
+
if (typeof byte !== "number" || !Number.isInteger(byte) || byte < 0 || byte > 255) return null;
|
|
535
|
+
bytes.push(byte);
|
|
536
|
+
}
|
|
537
|
+
return bytes;
|
|
538
|
+
}
|
|
539
|
+
function parseStoredRegistrationSignerPlan(value) {
|
|
540
|
+
const parsed = normalizeRegistrationSignerPlan(value);
|
|
541
|
+
if (parsed.ok) return parsed.value;
|
|
542
|
+
const decoded = parseJsonValue(value);
|
|
543
|
+
if (decoded === null || typeof decoded !== "object" || Array.isArray(decoded)) return null;
|
|
544
|
+
const record = decoded;
|
|
545
|
+
if (record.kind !== "signer_set" || !Array.isArray(record.branches)) return null;
|
|
546
|
+
const branches = [];
|
|
547
|
+
const signers = [];
|
|
548
|
+
for (const rawBranch of record.branches) {
|
|
549
|
+
const branch = parseStoredRegistrationSignerPlanBranch(rawBranch);
|
|
550
|
+
if (!branch) return null;
|
|
551
|
+
branches.push(branch.branch);
|
|
552
|
+
signers.push(branch.signer);
|
|
553
|
+
}
|
|
554
|
+
const recomputed = registrationSignerPlanFromSelection({
|
|
555
|
+
kind: "signer_set",
|
|
556
|
+
signers
|
|
557
|
+
});
|
|
558
|
+
if (!recomputed.ok) return null;
|
|
559
|
+
if (!storedRegistrationSignerPlansMatch({
|
|
560
|
+
kind: "signer_set",
|
|
561
|
+
branches
|
|
562
|
+
}, recomputed.value)) return null;
|
|
563
|
+
return recomputed.value;
|
|
564
|
+
}
|
|
565
|
+
function parseStoredWalletRegistrationPreparedContext(value) {
|
|
566
|
+
const decoded = parseJsonValue(value);
|
|
567
|
+
if (decoded === null || typeof decoded !== "object" || Array.isArray(decoded)) return null;
|
|
568
|
+
const record = decoded;
|
|
569
|
+
if (record.kind !== "wallet_registration_prepared_context_v1" || record.runtimePolicy === null || typeof record.runtimePolicy !== "object" || Array.isArray(record.runtimePolicy) || record.ecdsa === null || typeof record.ecdsa !== "object" || Array.isArray(record.ecdsa)) return null;
|
|
570
|
+
const signingRootId = trimString(record.signingRootId);
|
|
571
|
+
const signingRootVersion = trimString(record.signingRootVersion);
|
|
572
|
+
if (!signingRootId || !signingRootVersion) return null;
|
|
573
|
+
const runtimePolicy = parseStoredWalletRegistrationRuntimePolicyContext(record.runtimePolicy);
|
|
574
|
+
const ecdsa = parseStoredWalletRegistrationEcdsaPreparedContext(record.ecdsa);
|
|
575
|
+
if (!runtimePolicy || !ecdsa) return null;
|
|
576
|
+
return {
|
|
577
|
+
kind: "wallet_registration_prepared_context_v1",
|
|
578
|
+
signingRootId,
|
|
579
|
+
signingRootVersion,
|
|
580
|
+
runtimePolicy,
|
|
581
|
+
ecdsa
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
function parseStoredWalletRegistrationRuntimePolicyContext(value) {
|
|
585
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
|
|
586
|
+
const record = value;
|
|
587
|
+
switch (record.kind) {
|
|
588
|
+
case "runtime_policy_scope": {
|
|
589
|
+
const scope = parseStoredRuntimePolicyScope(record.scope);
|
|
590
|
+
return scope ? {
|
|
591
|
+
kind: "runtime_policy_scope",
|
|
592
|
+
scope
|
|
593
|
+
} : null;
|
|
594
|
+
}
|
|
595
|
+
case "signing_root_only": return record.scope !== void 0 ? null : { kind: "signing_root_only" };
|
|
596
|
+
default: return null;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
function parseStoredRuntimePolicyScope(value) {
|
|
600
|
+
const scope = parseStoredAddAuthMethodRuntimePolicyScope(value);
|
|
601
|
+
if (!scope?.signingRootVersion) return null;
|
|
602
|
+
return {
|
|
603
|
+
orgId: scope.orgId,
|
|
604
|
+
projectId: scope.projectId,
|
|
605
|
+
envId: scope.envId,
|
|
606
|
+
signingRootVersion: scope.signingRootVersion
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
function parseStoredWalletRegistrationEcdsaPreparedContext(value) {
|
|
610
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
|
|
611
|
+
const record = value;
|
|
612
|
+
switch (record.kind) {
|
|
613
|
+
case "evm_family_ecdsa_requested": {
|
|
614
|
+
if (!Array.isArray(record.chainTargets) || record.chainTargets.length === 0) return null;
|
|
615
|
+
const chainTargets = [];
|
|
616
|
+
for (const rawTarget of record.chainTargets) {
|
|
617
|
+
const chainTarget = thresholdEcdsaChainTargetFromValue(rawTarget);
|
|
618
|
+
if (!chainTarget) return null;
|
|
619
|
+
chainTargets.push(chainTarget);
|
|
620
|
+
}
|
|
621
|
+
return {
|
|
622
|
+
kind: "evm_family_ecdsa_requested",
|
|
623
|
+
chainTargets
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
case "evm_family_ecdsa_absent": return record.chainTargets !== void 0 ? null : { kind: "evm_family_ecdsa_absent" };
|
|
627
|
+
default: return null;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
function parseStoredRegistrationSignerPlanBranch(value) {
|
|
631
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
|
|
632
|
+
const record = value;
|
|
633
|
+
let signerCandidate;
|
|
634
|
+
switch (record.kind) {
|
|
635
|
+
case "near_ed25519":
|
|
636
|
+
signerCandidate = {
|
|
637
|
+
kind: "near_ed25519",
|
|
638
|
+
accountProvisioning: record.accountProvisioning,
|
|
639
|
+
signerSlot: Number(record.signerSlot),
|
|
640
|
+
participantIds: Array.isArray(record.participantIds) ? [...record.participantIds] : [],
|
|
641
|
+
derivationVersion: Number(record.derivationVersion)
|
|
642
|
+
};
|
|
643
|
+
break;
|
|
644
|
+
case "evm_family_ecdsa":
|
|
645
|
+
signerCandidate = {
|
|
646
|
+
kind: "evm_family_ecdsa",
|
|
647
|
+
participantIds: Array.isArray(record.participantIds) ? [...record.participantIds] : [],
|
|
648
|
+
chainTargets: Array.isArray(record.chainTargets) ? [...record.chainTargets] : []
|
|
649
|
+
};
|
|
650
|
+
break;
|
|
651
|
+
default: return null;
|
|
652
|
+
}
|
|
653
|
+
let singleBranchPlan;
|
|
654
|
+
try {
|
|
655
|
+
singleBranchPlan = normalizeRegistrationSignerPlan({
|
|
656
|
+
kind: "signer_set",
|
|
657
|
+
signers: [signerCandidate]
|
|
658
|
+
});
|
|
659
|
+
} catch {
|
|
660
|
+
return null;
|
|
661
|
+
}
|
|
662
|
+
if (!singleBranchPlan.ok || singleBranchPlan.value.branches.length !== 1) return null;
|
|
663
|
+
const branch = singleBranchPlan.value.branches[0];
|
|
664
|
+
if (!branch || trimString(record.branchKey) !== branch.branchKey) return null;
|
|
665
|
+
switch (branch.kind) {
|
|
666
|
+
case "near_ed25519":
|
|
667
|
+
if (trimString(record.keyPurpose) !== branch.keyPurpose || trimString(record.keyVersion) !== branch.keyVersion || record.chainTargets !== void 0) return null;
|
|
668
|
+
return {
|
|
669
|
+
branch,
|
|
670
|
+
signer: {
|
|
671
|
+
kind: "near_ed25519",
|
|
672
|
+
accountProvisioning: branch.accountProvisioning,
|
|
673
|
+
signerSlot: branch.signerSlot,
|
|
674
|
+
participantIds: [...branch.participantIds],
|
|
675
|
+
derivationVersion: branch.derivationVersion
|
|
676
|
+
}
|
|
677
|
+
};
|
|
678
|
+
case "evm_family_ecdsa":
|
|
679
|
+
if (record.accountProvisioning !== void 0 || record.signerSlot !== void 0 || record.keyPurpose !== void 0 || record.keyVersion !== void 0 || record.derivationVersion !== void 0) return null;
|
|
680
|
+
return {
|
|
681
|
+
branch,
|
|
682
|
+
signer: {
|
|
683
|
+
kind: "evm_family_ecdsa",
|
|
684
|
+
participantIds: [...branch.participantIds],
|
|
685
|
+
chainTargets: [...branch.chainTargets]
|
|
686
|
+
}
|
|
687
|
+
};
|
|
688
|
+
default: return assertNever(branch);
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
function storedRegistrationSignerPlansMatch(left, right) {
|
|
692
|
+
if (left.kind !== right.kind || left.branches.length !== right.branches.length) return false;
|
|
693
|
+
for (let index = 0; index < left.branches.length; index += 1) {
|
|
694
|
+
const rightBranch = right.branches[index];
|
|
695
|
+
if (!rightBranch || !storedRegistrationSignerPlanBranchesMatch(left.branches[index], rightBranch)) return false;
|
|
696
|
+
}
|
|
697
|
+
return true;
|
|
698
|
+
}
|
|
699
|
+
function storedRegistrationSignerPlanBranchesMatch(left, right) {
|
|
700
|
+
if (left.kind !== right.kind || left.branchKey !== right.branchKey || !storedRegistrationNumberArraysMatch(left.participantIds, right.participantIds)) return false;
|
|
701
|
+
switch (left.kind) {
|
|
702
|
+
case "near_ed25519": return right.kind === "near_ed25519" && sameStoredRegistrationNearAccountProvisioning(left.accountProvisioning, right.accountProvisioning) && left.signerSlot === right.signerSlot && left.keyPurpose === right.keyPurpose && left.keyVersion === right.keyVersion && left.derivationVersion === right.derivationVersion;
|
|
703
|
+
case "evm_family_ecdsa": return right.kind === "evm_family_ecdsa" && left.chainTargets.length === right.chainTargets.length;
|
|
704
|
+
default: return assertNeverStoredRegistrationSignerPlanBranch(left);
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
function storedRegistrationNumberArraysMatch(left, right) {
|
|
708
|
+
if (left.length !== right.length) return false;
|
|
709
|
+
for (let index = 0; index < left.length; index += 1) if (left[index] !== right[index]) return false;
|
|
710
|
+
return true;
|
|
711
|
+
}
|
|
712
|
+
function sameStoredRegistrationNearAccountProvisioning(left, right) {
|
|
713
|
+
if (left.kind !== right.kind) return false;
|
|
714
|
+
switch (left.kind) {
|
|
715
|
+
case "implicit_account": return right.kind === "implicit_account" && left.accountIdSource === right.accountIdSource;
|
|
716
|
+
case "sponsored_named_account": return right.kind === "sponsored_named_account" && left.requestedAccountId === right.requestedAccountId && left.sponsor === right.sponsor;
|
|
717
|
+
default: return assertNeverStoredRegistrationNearAccountProvisioning(left);
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
function assertNeverStoredRegistrationSignerPlanBranch(branch) {
|
|
721
|
+
throw new Error(`Unexpected stored registration signer plan branch: ${String(branch)}`);
|
|
722
|
+
}
|
|
723
|
+
function assertNeverStoredRegistrationNearAccountProvisioning(provisioning) {
|
|
724
|
+
throw new Error(`Unexpected stored registration account provisioning: ${String(provisioning)}`);
|
|
725
|
+
}
|
|
726
|
+
function parseStoredAddSignerIntent(value) {
|
|
727
|
+
const decoded = parseJsonValue(value);
|
|
728
|
+
if (decoded === null || typeof decoded !== "object" || Array.isArray(decoded)) return null;
|
|
729
|
+
const record = decoded;
|
|
730
|
+
if (record.kind !== "add_signer_intent_allocated") return null;
|
|
731
|
+
const grant = trimString(record.grant);
|
|
732
|
+
const digestB64u = trimString(record.digestB64u);
|
|
733
|
+
const orgId = trimString(record.orgId);
|
|
734
|
+
const expiresAtMs = Number(record.expiresAtMs);
|
|
735
|
+
if (!grant || !digestB64u || !orgId || !Number.isSafeInteger(expiresAtMs)) return null;
|
|
736
|
+
if (record.intent === null || typeof record.intent !== "object" || Array.isArray(record.intent)) return null;
|
|
737
|
+
const intent = record.intent;
|
|
738
|
+
if (intent.version !== "add_signer_intent_v1") return null;
|
|
739
|
+
const walletId = parseWalletId(intent.walletId);
|
|
740
|
+
const signerSelection = normalizeAddSignerSelection(intent.signerSelection, { normalizeEcdsaChainTarget: thresholdEcdsaChainTargetFromValue });
|
|
741
|
+
const nonceB64u = trimString(intent.nonceB64u);
|
|
742
|
+
if (!walletId.ok || !signerSelection.ok || !nonceB64u) return null;
|
|
743
|
+
const runtimePolicyScope = Object.prototype.hasOwnProperty.call(intent, "runtimePolicyScope") ? parseStoredAddAuthMethodRuntimePolicyScope(intent.runtimePolicyScope) : void 0;
|
|
744
|
+
if (Object.prototype.hasOwnProperty.call(intent, "runtimePolicyScope") && !runtimePolicyScope) return null;
|
|
745
|
+
const parsedIntent = runtimePolicyScope ? {
|
|
746
|
+
version: "add_signer_intent_v1",
|
|
747
|
+
walletId: walletId.value,
|
|
748
|
+
signerSelection: signerSelection.value,
|
|
749
|
+
runtimePolicyScope,
|
|
750
|
+
nonceB64u
|
|
751
|
+
} : {
|
|
752
|
+
version: "add_signer_intent_v1",
|
|
753
|
+
walletId: walletId.value,
|
|
754
|
+
signerSelection: signerSelection.value,
|
|
755
|
+
nonceB64u
|
|
756
|
+
};
|
|
757
|
+
return {
|
|
758
|
+
kind: "add_signer_intent_allocated",
|
|
759
|
+
grant: addSignerIntentGrantFromString(grant),
|
|
760
|
+
intent: parsedIntent,
|
|
761
|
+
digestB64u,
|
|
762
|
+
orgId,
|
|
763
|
+
expiresAtMs,
|
|
764
|
+
...trimString(record.signingRootId) ? { signingRootId: trimString(record.signingRootId) } : {},
|
|
765
|
+
...trimString(record.signingRootVersion) ? { signingRootVersion: trimString(record.signingRootVersion) } : {},
|
|
766
|
+
...trimString(record.expectedOrigin) ? { expectedOrigin: trimString(record.expectedOrigin) } : {}
|
|
767
|
+
};
|
|
768
|
+
}
|
|
769
|
+
function parseStoredAddAuthMethodIntent(value) {
|
|
770
|
+
const decoded = parseJsonValue(value);
|
|
771
|
+
if (decoded === null || typeof decoded !== "object" || Array.isArray(decoded)) return null;
|
|
772
|
+
const record = decoded;
|
|
773
|
+
if (record.kind !== "add_auth_method_intent_allocated") return null;
|
|
774
|
+
const grant = trimString(record.grant);
|
|
775
|
+
const digestB64u = trimString(record.digestB64u);
|
|
776
|
+
const orgId = trimString(record.orgId);
|
|
777
|
+
const expiresAtMs = Number(record.expiresAtMs);
|
|
778
|
+
if (!grant || !digestB64u || !orgId || !Number.isSafeInteger(expiresAtMs)) return null;
|
|
779
|
+
if (record.intent === null || typeof record.intent !== "object" || Array.isArray(record.intent)) return null;
|
|
780
|
+
const intent = record.intent;
|
|
781
|
+
const walletId = parseWalletId(intent.walletId);
|
|
782
|
+
const authMethod = normalizeAddAuthMethodInput(intent.authMethod);
|
|
783
|
+
const targetWalletAuthMethodId = parseWalletAuthMethodId(intent.targetWalletAuthMethodId);
|
|
784
|
+
const caller = normalizeAddAuthMethodIntentCaller(intent);
|
|
785
|
+
const nonceB64u = trimString(intent.nonceB64u);
|
|
786
|
+
if (intent.version !== "add_auth_method_intent_v1" || !walletId.ok || !authMethod || !targetWalletAuthMethodId.ok || !caller || !nonceB64u) return null;
|
|
787
|
+
const runtimePolicyScope = Object.prototype.hasOwnProperty.call(intent, "runtimePolicyScope") ? parseStoredAddAuthMethodRuntimePolicyScope(intent.runtimePolicyScope) : void 0;
|
|
788
|
+
if (Object.prototype.hasOwnProperty.call(intent, "runtimePolicyScope") && !runtimePolicyScope) return null;
|
|
789
|
+
const parsedIntent = caller.caller === "same_device_addition" ? {
|
|
790
|
+
version: "add_auth_method_intent_v1",
|
|
791
|
+
walletId: walletId.value,
|
|
792
|
+
authMethod,
|
|
793
|
+
targetWalletAuthMethodId: targetWalletAuthMethodId.value,
|
|
794
|
+
...runtimePolicyScope ? { runtimePolicyScope } : {},
|
|
795
|
+
nonceB64u,
|
|
796
|
+
caller: "same_device_addition",
|
|
797
|
+
source: caller.source
|
|
798
|
+
} : {
|
|
799
|
+
version: "add_auth_method_intent_v1",
|
|
800
|
+
walletId: walletId.value,
|
|
801
|
+
authMethod,
|
|
802
|
+
targetWalletAuthMethodId: targetWalletAuthMethodId.value,
|
|
803
|
+
...runtimePolicyScope ? { runtimePolicyScope } : {},
|
|
804
|
+
nonceB64u,
|
|
805
|
+
caller: "linked_device_ceremony"
|
|
806
|
+
};
|
|
807
|
+
return {
|
|
808
|
+
kind: "add_auth_method_intent_allocated",
|
|
809
|
+
grant: addAuthMethodIntentGrantFromString(grant),
|
|
810
|
+
intent: parsedIntent,
|
|
811
|
+
digestB64u,
|
|
812
|
+
orgId,
|
|
813
|
+
expiresAtMs,
|
|
814
|
+
...trimString(record.signingRootId) ? { signingRootId: trimString(record.signingRootId) } : {},
|
|
815
|
+
...trimString(record.signingRootVersion) ? { signingRootVersion: trimString(record.signingRootVersion) } : {},
|
|
816
|
+
...trimString(record.expectedOrigin) ? { expectedOrigin: trimString(record.expectedOrigin) } : {}
|
|
817
|
+
};
|
|
818
|
+
}
|
|
819
|
+
function parseStoredAddAuthMethodRuntimePolicyScope(value) {
|
|
820
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
|
|
821
|
+
const record = value;
|
|
822
|
+
const orgId = trimString(record.orgId);
|
|
823
|
+
const projectId = trimString(record.projectId);
|
|
824
|
+
const envId = trimString(record.envId);
|
|
825
|
+
const signingRootVersion = trimString(record.signingRootVersion);
|
|
826
|
+
if (!orgId || !projectId || !envId) return null;
|
|
827
|
+
if (record.signingRootVersion !== void 0 && !signingRootVersion) return null;
|
|
828
|
+
return signingRootVersion ? {
|
|
829
|
+
orgId,
|
|
830
|
+
projectId,
|
|
831
|
+
envId,
|
|
832
|
+
signingRootVersion
|
|
833
|
+
} : {
|
|
834
|
+
orgId,
|
|
835
|
+
projectId,
|
|
836
|
+
envId
|
|
837
|
+
};
|
|
838
|
+
}
|
|
839
|
+
function parseStoredRegistrationAuthority(value) {
|
|
840
|
+
const decoded = parseJsonValue(value);
|
|
841
|
+
if (decoded === null || typeof decoded !== "object" || Array.isArray(decoded)) return null;
|
|
842
|
+
const record = decoded;
|
|
843
|
+
const walletId = parseWalletId(record.walletId);
|
|
844
|
+
const registrationIntentDigestB64u = trimString(record.registrationIntentDigestB64u);
|
|
845
|
+
if (!walletId.ok || !registrationIntentDigestB64u) return null;
|
|
846
|
+
switch (record.kind) {
|
|
847
|
+
case "passkey": {
|
|
848
|
+
if (record.emailHashHex !== void 0 || record.challengeId !== void 0) return null;
|
|
849
|
+
const rpId = parseWebAuthnRpId(record.rpId);
|
|
850
|
+
const credentialIdB64u = parseWebAuthnCredentialIdB64u(record.credentialIdB64u);
|
|
851
|
+
const credentialPublicKeyB64u = trimString(record.credentialPublicKeyB64u);
|
|
852
|
+
const counter = Number(record.counter);
|
|
853
|
+
const device = parseWebAuthnAuthenticatorDeviceInfo(record.device);
|
|
854
|
+
if (!rpId.ok || !credentialIdB64u.ok || !credentialPublicKeyB64u || !Number.isSafeInteger(counter) || counter < 0 || !device) return null;
|
|
855
|
+
return {
|
|
856
|
+
kind: "passkey",
|
|
857
|
+
walletId: walletId.value,
|
|
858
|
+
rpId: rpId.value,
|
|
859
|
+
credentialIdB64u: credentialIdB64u.value,
|
|
860
|
+
credentialPublicKeyB64u,
|
|
861
|
+
counter,
|
|
862
|
+
device,
|
|
863
|
+
registrationIntentDigestB64u
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
case "email_otp": {
|
|
867
|
+
if (record.rpId !== void 0 || record.credentialIdB64u !== void 0 || record.credentialPublicKeyB64u !== void 0 || record.counter !== void 0) return null;
|
|
868
|
+
const emailHashHex = trimString(record.emailHashHex);
|
|
869
|
+
const proofKind = trimString(record.proofKind);
|
|
870
|
+
const providerSubject = parseProviderSubject(record.providerSubject);
|
|
871
|
+
const email = trimString(record.email).toLowerCase();
|
|
872
|
+
const finalWalletId = parseWalletId(record.finalWalletId);
|
|
873
|
+
const orgId = parseOrgId(record.orgId);
|
|
874
|
+
const ownerProofBindingDigest = trimString(record.ownerProofBindingDigest);
|
|
875
|
+
if (!providerSubject.ok || !email || !emailHashHex || !finalWalletId.ok || !orgId.ok || !ownerProofBindingDigest) return null;
|
|
876
|
+
if (proofKind === "otp_challenge") {
|
|
877
|
+
const parsedChallengeId = parseEmailOtpChallengeId(record.challengeId);
|
|
878
|
+
const registrationAuthorityId = parseEmailOtpChallengeId(record.registrationAuthorityId);
|
|
879
|
+
const challengeSubjectId = parseChallengeSubjectId(record.challengeSubjectId);
|
|
880
|
+
const originalWalletId = parseWalletId(record.originalWalletId);
|
|
881
|
+
const challengePurpose = record.challengePurpose === "registration" || record.challengePurpose === "registration_reroll" ? record.challengePurpose : null;
|
|
882
|
+
if (!challengeSubjectId.ok || !parsedChallengeId.ok || !registrationAuthorityId.ok || parsedChallengeId.value !== registrationAuthorityId.value || !originalWalletId.ok || !challengePurpose) return null;
|
|
883
|
+
return {
|
|
884
|
+
kind: "email_otp",
|
|
885
|
+
proofKind: "otp_challenge",
|
|
886
|
+
walletId: walletId.value,
|
|
887
|
+
providerSubject: providerSubject.value,
|
|
888
|
+
challengeSubjectId: challengeSubjectId.value,
|
|
889
|
+
email,
|
|
890
|
+
emailHashHex,
|
|
891
|
+
challengeId: parsedChallengeId.value,
|
|
892
|
+
registrationAuthorityId: registrationAuthorityId.value,
|
|
893
|
+
originalWalletId: originalWalletId.value,
|
|
894
|
+
finalWalletId: finalWalletId.value,
|
|
895
|
+
orgId: orgId.value,
|
|
896
|
+
ownerProofBindingDigest,
|
|
897
|
+
challengePurpose,
|
|
898
|
+
registrationIntentDigestB64u
|
|
899
|
+
};
|
|
900
|
+
}
|
|
901
|
+
if (proofKind === "google_sso_registration") {
|
|
902
|
+
const registrationAttemptId = trimString(record.googleEmailOtpRegistrationAttemptId);
|
|
903
|
+
const registrationOfferId = trimString(record.googleEmailOtpRegistrationOfferId);
|
|
904
|
+
const registrationCandidateId = trimString(record.googleEmailOtpRegistrationCandidateId);
|
|
905
|
+
const registrationAuthorityId = trimString(record.registrationAuthorityId);
|
|
906
|
+
if (!registrationAttemptId || !registrationOfferId || !registrationCandidateId || !registrationAuthorityId || registrationAuthorityId !== registrationAttemptId || record.challengeId !== void 0 || record.challengeSubjectId !== void 0 || record.originalWalletId !== void 0 || record.challengePurpose !== void 0) return null;
|
|
907
|
+
return {
|
|
908
|
+
kind: "email_otp",
|
|
909
|
+
proofKind: "google_sso_registration",
|
|
910
|
+
walletId: walletId.value,
|
|
911
|
+
providerSubject: providerSubject.value,
|
|
912
|
+
email,
|
|
913
|
+
emailHashHex,
|
|
914
|
+
googleEmailOtpRegistrationAttemptId: registrationAttemptId,
|
|
915
|
+
googleEmailOtpRegistrationOfferId: registrationOfferId,
|
|
916
|
+
googleEmailOtpRegistrationCandidateId: registrationCandidateId,
|
|
917
|
+
registrationAuthorityId,
|
|
918
|
+
finalWalletId: finalWalletId.value,
|
|
919
|
+
orgId: orgId.value,
|
|
920
|
+
ownerProofBindingDigest,
|
|
921
|
+
registrationIntentDigestB64u
|
|
922
|
+
};
|
|
923
|
+
}
|
|
924
|
+
return null;
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
return null;
|
|
928
|
+
}
|
|
929
|
+
function parseStoredRegistrationIntent(value) {
|
|
930
|
+
const decoded = parseJsonValue(value);
|
|
931
|
+
if (decoded === null || typeof decoded !== "object" || Array.isArray(decoded)) return null;
|
|
932
|
+
const record = decoded;
|
|
933
|
+
if (record.version !== "registration_intent_v1") return null;
|
|
934
|
+
const walletId = parseWalletId(record.walletId);
|
|
935
|
+
const authMethod = normalizeRegistrationAuthMethodInput(record.authMethod);
|
|
936
|
+
const signerPlan = parseStoredRegistrationSignerPlan(record.signerSelection);
|
|
937
|
+
const foundingWalletAuthMethodId = parseWalletAuthMethodId(record.foundingWalletAuthMethodId);
|
|
938
|
+
const nonceB64u = trimString(record.nonceB64u);
|
|
939
|
+
if (!walletId.ok || !authMethod || !signerPlan || !foundingWalletAuthMethodId.ok || !nonceB64u) return null;
|
|
940
|
+
const signerSelection = registrationSignerSetSelectionFromPlan(signerPlan, { normalizeEcdsaChainTarget: thresholdEcdsaChainTargetFromValue });
|
|
941
|
+
if (!signerSelection.ok) return null;
|
|
942
|
+
const runtimePolicyScope = Object.prototype.hasOwnProperty.call(record, "runtimePolicyScope") ? parseStoredAddAuthMethodRuntimePolicyScope(record.runtimePolicyScope) : void 0;
|
|
943
|
+
if (Object.prototype.hasOwnProperty.call(record, "runtimePolicyScope") && !runtimePolicyScope) return null;
|
|
944
|
+
return runtimePolicyScope ? {
|
|
945
|
+
version: "registration_intent_v1",
|
|
946
|
+
walletId: walletId.value,
|
|
947
|
+
authMethod,
|
|
948
|
+
signerSelection: signerSelection.value,
|
|
949
|
+
foundingWalletAuthMethodId: foundingWalletAuthMethodId.value,
|
|
950
|
+
runtimePolicyScope,
|
|
951
|
+
nonceB64u
|
|
952
|
+
} : {
|
|
953
|
+
version: "registration_intent_v1",
|
|
954
|
+
walletId: walletId.value,
|
|
955
|
+
authMethod,
|
|
956
|
+
signerSelection: signerSelection.value,
|
|
957
|
+
foundingWalletAuthMethodId: foundingWalletAuthMethodId.value,
|
|
958
|
+
nonceB64u
|
|
959
|
+
};
|
|
960
|
+
}
|
|
961
|
+
function parseStoredRegistrationSignerBranchKey(value) {
|
|
962
|
+
const branchKey = trimString(value);
|
|
963
|
+
if (!branchKey) return null;
|
|
964
|
+
try {
|
|
965
|
+
return registrationSignerBranchKeyFromString(branchKey);
|
|
966
|
+
} catch {
|
|
967
|
+
return null;
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
function parseStoredRegistrationEcdsaChainTargets(value) {
|
|
971
|
+
if (!Array.isArray(value) || value.length === 0) return null;
|
|
972
|
+
const chainTargets = [];
|
|
973
|
+
const seen = /* @__PURE__ */ new Set();
|
|
974
|
+
for (const rawTarget of value) {
|
|
975
|
+
const chainTarget = thresholdEcdsaChainTargetFromValue(rawTarget);
|
|
976
|
+
if (!chainTarget) return null;
|
|
977
|
+
const key = thresholdEcdsaChainTargetKey(chainTarget);
|
|
978
|
+
if (seen.has(key)) return null;
|
|
979
|
+
seen.add(key);
|
|
980
|
+
chainTargets.push(chainTarget);
|
|
981
|
+
}
|
|
982
|
+
const first = chainTargets[0];
|
|
983
|
+
return first ? [first, ...chainTargets.slice(1)] : null;
|
|
984
|
+
}
|
|
985
|
+
function parseStoredRegistrationEcdsaParticipantPair(value) {
|
|
986
|
+
if (!Array.isArray(value) || value.length !== 2 || value[0] !== 1 || value[1] !== 2) return null;
|
|
987
|
+
return [1, 2];
|
|
988
|
+
}
|
|
989
|
+
function parseStoredWalletRegistrationEcdsaPrepare(value) {
|
|
990
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
|
|
991
|
+
const record = value;
|
|
992
|
+
if (record.formatVersion !== "ecdsa-derivation-role-local") return null;
|
|
993
|
+
const walletId = trimString(record.walletId);
|
|
994
|
+
const evmFamilySigningKeySlotId = trimString(record.evmFamilySigningKeySlotId);
|
|
995
|
+
const ecdsaThresholdKeyId = trimString(record.ecdsaThresholdKeyId);
|
|
996
|
+
const signingRootId = trimString(record.signingRootId);
|
|
997
|
+
const signingRootVersion = trimString(record.signingRootVersion);
|
|
998
|
+
const relayerKeyId = trimString(record.relayerKeyId);
|
|
999
|
+
const registrationPreparationId = trimString(record.registrationPreparationId);
|
|
1000
|
+
const requestId = trimString(record.requestId);
|
|
1001
|
+
const thresholdSessionId = trimString(record.thresholdSessionId);
|
|
1002
|
+
const ttlMs = Number(record.ttlMs);
|
|
1003
|
+
const remainingUses = Number(record.remainingUses);
|
|
1004
|
+
const participantIds = parseStoredRegistrationEcdsaParticipantPair(record.participantIds);
|
|
1005
|
+
const runtimePolicyScope = parseStoredRuntimePolicyScope(record.runtimePolicyScope);
|
|
1006
|
+
if (!walletId || !evmFamilySigningKeySlotId || !ecdsaThresholdKeyId || !signingRootId || !signingRootVersion || record.keyScope !== "evm-family" || !relayerKeyId || !registrationPreparationId || !requestId || !thresholdSessionId || !Number.isSafeInteger(ttlMs) || !Number.isSafeInteger(remainingUses) || !participantIds || !runtimePolicyScope) return null;
|
|
1007
|
+
try {
|
|
1008
|
+
return {
|
|
1009
|
+
formatVersion: "ecdsa-derivation-role-local",
|
|
1010
|
+
walletId,
|
|
1011
|
+
evmFamilySigningKeySlotId,
|
|
1012
|
+
ecdsaThresholdKeyId,
|
|
1013
|
+
signingRootId,
|
|
1014
|
+
signingRootVersion,
|
|
1015
|
+
keyScope: "evm-family",
|
|
1016
|
+
relayerKeyId,
|
|
1017
|
+
registrationPreparationId: registrationPreparationIdFromString(registrationPreparationId),
|
|
1018
|
+
requestId,
|
|
1019
|
+
thresholdSessionId,
|
|
1020
|
+
ttlMs,
|
|
1021
|
+
remainingUses,
|
|
1022
|
+
participantIds,
|
|
1023
|
+
runtimePolicyScope
|
|
1024
|
+
};
|
|
1025
|
+
} catch {
|
|
1026
|
+
return null;
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
function parseStoredEcdsaDerivationPublicIdentity(value) {
|
|
1030
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
|
|
1031
|
+
const record = value;
|
|
1032
|
+
const derivationClientSharePublicKey33B64u = trimString(record.derivationClientSharePublicKey33B64u);
|
|
1033
|
+
const relayerPublicKey33B64u = trimString(record.relayerPublicKey33B64u);
|
|
1034
|
+
const groupPublicKey33B64u = trimString(record.groupPublicKey33B64u);
|
|
1035
|
+
const ethereumAddress = trimString(record.ethereumAddress);
|
|
1036
|
+
if (!derivationClientSharePublicKey33B64u || !relayerPublicKey33B64u || !groupPublicKey33B64u || !ethereumAddress) return null;
|
|
1037
|
+
return parseEcdsaDerivationPublicIdentity({
|
|
1038
|
+
derivationClientSharePublicKey33B64u,
|
|
1039
|
+
relayerPublicKey33B64u,
|
|
1040
|
+
groupPublicKey33B64u,
|
|
1041
|
+
ethereumAddress
|
|
1042
|
+
});
|
|
1043
|
+
}
|
|
1044
|
+
function parseStoredEcdsaDerivationServerBootstrapResponse(value) {
|
|
1045
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
|
|
1046
|
+
const record = value;
|
|
1047
|
+
if (record.formatVersion !== "ecdsa-derivation-role-local") return null;
|
|
1048
|
+
const publicIdentity = parseStoredEcdsaDerivationPublicIdentity(record.publicIdentity);
|
|
1049
|
+
const walletId = trimString(record.walletId);
|
|
1050
|
+
const evmFamilySigningKeySlotId = trimString(record.evmFamilySigningKeySlotId);
|
|
1051
|
+
const ecdsaThresholdKeyId = trimString(record.ecdsaThresholdKeyId);
|
|
1052
|
+
const relayerKeyId = trimString(record.relayerKeyId);
|
|
1053
|
+
const applicationBindingDigestB64u = trimString(record.applicationBindingDigestB64u);
|
|
1054
|
+
const contextBinding32B64u = trimString(record.contextBinding32B64u);
|
|
1055
|
+
const clientShareRetryCounter = Number(record.clientShareRetryCounter);
|
|
1056
|
+
const relayerShareRetryCounter = Number(record.relayerShareRetryCounter);
|
|
1057
|
+
const publicTranscriptDigest32B64u = trimString(record.publicTranscriptDigest32B64u);
|
|
1058
|
+
const keyHandle = trimString(record.keyHandle);
|
|
1059
|
+
const signingRootId = trimString(record.signingRootId);
|
|
1060
|
+
const signingRootVersion = trimString(record.signingRootVersion);
|
|
1061
|
+
const thresholdEcdsaPublicKeyB64u = trimString(record.thresholdEcdsaPublicKeyB64u);
|
|
1062
|
+
const ethereumAddress = trimString(record.ethereumAddress);
|
|
1063
|
+
const relayerVerifyingShareB64u = trimString(record.relayerVerifyingShareB64u);
|
|
1064
|
+
const participantIds = parseStoredRegistrationEcdsaParticipantPair(record.participantIds);
|
|
1065
|
+
const thresholdSessionId = trimString(record.thresholdSessionId);
|
|
1066
|
+
const activationEpoch = parseRootShareEpoch(record.activationEpoch);
|
|
1067
|
+
const expiresAtMs = Number(record.expiresAtMs);
|
|
1068
|
+
const expiresAt = trimString(record.expiresAt);
|
|
1069
|
+
const remainingUses = Number(record.remainingUses);
|
|
1070
|
+
let routerAbEcdsaDerivationNormalSigning;
|
|
1071
|
+
try {
|
|
1072
|
+
routerAbEcdsaDerivationNormalSigning = parseRouterAbEcdsaDerivationNormalSigningStateV1(record.routerAbEcdsaDerivationNormalSigning);
|
|
1073
|
+
} catch {
|
|
1074
|
+
return null;
|
|
1075
|
+
}
|
|
1076
|
+
if (!walletId || !evmFamilySigningKeySlotId || !ecdsaThresholdKeyId || !relayerKeyId || !applicationBindingDigestB64u || !contextBinding32B64u || !publicIdentity || !Number.isSafeInteger(clientShareRetryCounter) || clientShareRetryCounter < 0 || !Number.isSafeInteger(relayerShareRetryCounter) || relayerShareRetryCounter < 0 || !publicTranscriptDigest32B64u || !keyHandle || !signingRootId || !signingRootVersion || !thresholdEcdsaPublicKeyB64u || !ethereumAddress || !relayerVerifyingShareB64u || !participantIds || !thresholdSessionId || !activationEpoch.ok || !Number.isSafeInteger(expiresAtMs) || !expiresAt || !Number.isSafeInteger(remainingUses) || remainingUses < 0 || !routerAbEcdsaDerivationNormalSigning) return null;
|
|
1077
|
+
return {
|
|
1078
|
+
formatVersion: "ecdsa-derivation-role-local",
|
|
1079
|
+
walletId,
|
|
1080
|
+
evmFamilySigningKeySlotId,
|
|
1081
|
+
ecdsaThresholdKeyId,
|
|
1082
|
+
relayerKeyId,
|
|
1083
|
+
applicationBindingDigestB64u,
|
|
1084
|
+
contextBinding32B64u,
|
|
1085
|
+
publicIdentity,
|
|
1086
|
+
clientShareRetryCounter,
|
|
1087
|
+
relayerShareRetryCounter,
|
|
1088
|
+
publicTranscriptDigest32B64u,
|
|
1089
|
+
keyHandle,
|
|
1090
|
+
signingRootId,
|
|
1091
|
+
signingRootVersion,
|
|
1092
|
+
thresholdEcdsaPublicKeyB64u,
|
|
1093
|
+
ethereumAddress,
|
|
1094
|
+
relayerVerifyingShareB64u,
|
|
1095
|
+
participantIds: [1, 2],
|
|
1096
|
+
thresholdSessionId,
|
|
1097
|
+
activationEpoch: activationEpoch.value,
|
|
1098
|
+
expiresAtMs,
|
|
1099
|
+
expiresAt,
|
|
1100
|
+
remainingUses,
|
|
1101
|
+
routerAbEcdsaDerivationNormalSigning
|
|
1102
|
+
};
|
|
1103
|
+
}
|
|
1104
|
+
function parseStoredWalletRegistrationEcdsaBranchBase(value) {
|
|
1105
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
|
|
1106
|
+
const record = value;
|
|
1107
|
+
const branchKey = parseStoredRegistrationSignerBranchKey(record.branchKey);
|
|
1108
|
+
const chainTargets = parseStoredRegistrationEcdsaChainTargets(record.chainTargets);
|
|
1109
|
+
const prepare = parseStoredWalletRegistrationEcdsaPrepare(record.prepare);
|
|
1110
|
+
const strictRegistrationBindingJson = trimString(record.strictRegistrationBindingJson);
|
|
1111
|
+
if (!branchKey || record.derivationKind !== "evm_family_ecdsa_keygen" || !chainTargets || !prepare || !strictRegistrationBindingJson) return null;
|
|
1112
|
+
let strictRegistration;
|
|
1113
|
+
try {
|
|
1114
|
+
strictRegistration = parseRouterAbEcdsaRegistrationRequestFactsV1(record.strictRegistration);
|
|
1115
|
+
} catch {
|
|
1116
|
+
return null;
|
|
1117
|
+
}
|
|
1118
|
+
return strictRegistration.registration_purpose === "wallet_registration" ? {
|
|
1119
|
+
branchKey,
|
|
1120
|
+
derivationKind: "evm_family_ecdsa_keygen",
|
|
1121
|
+
chainTargets,
|
|
1122
|
+
prepare,
|
|
1123
|
+
strictRegistration,
|
|
1124
|
+
strictRegistrationBindingJson
|
|
1125
|
+
} : null;
|
|
1126
|
+
}
|
|
1127
|
+
function parseStoredWalletRegistrationSignerBranch(value) {
|
|
1128
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
|
|
1129
|
+
const record = value;
|
|
1130
|
+
switch (record.kind) {
|
|
1131
|
+
case "near_ed25519_yao_authorized": {
|
|
1132
|
+
const branchKey = parseStoredRegistrationSignerBranchKey(record.branchKey);
|
|
1133
|
+
const admissionRequest = parseRouterAbEd25519YaoRegistrationAdmissionRequestV1(record.admissionRequest);
|
|
1134
|
+
const admissionReceipt = parseRouterAbEd25519YaoRegistrationActivationAdmissionReceiptV1(record.admissionReceipt);
|
|
1135
|
+
return branchKey && admissionRequest.ok && admissionReceipt.ok ? {
|
|
1136
|
+
kind: "near_ed25519_yao_authorized",
|
|
1137
|
+
branchKey,
|
|
1138
|
+
admissionRequest: admissionRequest.value,
|
|
1139
|
+
admissionReceipt: admissionReceipt.value
|
|
1140
|
+
} : null;
|
|
1141
|
+
}
|
|
1142
|
+
case "evm_family_ecdsa_prepared": {
|
|
1143
|
+
const base = parseStoredWalletRegistrationEcdsaBranchBase(record);
|
|
1144
|
+
return base ? {
|
|
1145
|
+
kind: "evm_family_ecdsa_prepared",
|
|
1146
|
+
branchKey: base.branchKey,
|
|
1147
|
+
derivationKind: base.derivationKind,
|
|
1148
|
+
chainTargets: base.chainTargets,
|
|
1149
|
+
prepare: base.prepare,
|
|
1150
|
+
strictRegistration: base.strictRegistration,
|
|
1151
|
+
strictRegistrationBindingJson: base.strictRegistrationBindingJson
|
|
1152
|
+
} : null;
|
|
1153
|
+
}
|
|
1154
|
+
case "evm_family_ecdsa_response_claimed": {
|
|
1155
|
+
const base = parseStoredWalletRegistrationEcdsaBranchBase(record);
|
|
1156
|
+
if (!base) return null;
|
|
1157
|
+
try {
|
|
1158
|
+
const registrationRequest = parseRouterAbEcdsaRegistrationRequestV1(record.registrationRequest);
|
|
1159
|
+
return registrationRequest.registration_purpose === "wallet_registration" ? {
|
|
1160
|
+
kind: "evm_family_ecdsa_response_claimed",
|
|
1161
|
+
branchKey: base.branchKey,
|
|
1162
|
+
derivationKind: base.derivationKind,
|
|
1163
|
+
chainTargets: base.chainTargets,
|
|
1164
|
+
prepare: base.prepare,
|
|
1165
|
+
strictRegistration: base.strictRegistration,
|
|
1166
|
+
strictRegistrationBindingJson: base.strictRegistrationBindingJson,
|
|
1167
|
+
registrationRequest
|
|
1168
|
+
} : null;
|
|
1169
|
+
} catch {
|
|
1170
|
+
return null;
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
case "evm_family_ecdsa_pending_activation": {
|
|
1174
|
+
const base = parseStoredWalletRegistrationEcdsaBranchBase(record);
|
|
1175
|
+
if (!base) return null;
|
|
1176
|
+
try {
|
|
1177
|
+
const registrationRequest = parseRouterAbEcdsaRegistrationRequestV1(record.registrationRequest);
|
|
1178
|
+
const pendingActivation = parseStoredRouterAbEcdsaPendingActivationV1(record.pendingActivation);
|
|
1179
|
+
const publicResponse = parseRouterAbEcdsaStrictForwardedRegistrationResponseV1(record.publicResponse);
|
|
1180
|
+
return registrationRequest.registration_purpose === "wallet_registration" ? {
|
|
1181
|
+
kind: "evm_family_ecdsa_pending_activation",
|
|
1182
|
+
branchKey: base.branchKey,
|
|
1183
|
+
derivationKind: base.derivationKind,
|
|
1184
|
+
chainTargets: base.chainTargets,
|
|
1185
|
+
prepare: base.prepare,
|
|
1186
|
+
strictRegistration: base.strictRegistration,
|
|
1187
|
+
strictRegistrationBindingJson: base.strictRegistrationBindingJson,
|
|
1188
|
+
registrationRequest,
|
|
1189
|
+
pendingActivation,
|
|
1190
|
+
publicResponse
|
|
1191
|
+
} : null;
|
|
1192
|
+
} catch {
|
|
1193
|
+
return null;
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
case "evm_family_ecdsa_activation_claimed": {
|
|
1197
|
+
const base = parseStoredWalletRegistrationEcdsaBranchBase(record);
|
|
1198
|
+
const activationRequestDigestB64u = parseStoredRegistrationDigest(record.activationRequestDigestB64u);
|
|
1199
|
+
const activationOwner = trimString(record.activationOwner);
|
|
1200
|
+
if (!base || !activationRequestDigestB64u || !activationOwner) return null;
|
|
1201
|
+
try {
|
|
1202
|
+
const registrationRequest = parseRouterAbEcdsaRegistrationRequestV1(record.registrationRequest);
|
|
1203
|
+
const pendingActivation = parseStoredRouterAbEcdsaPendingActivationV1(record.pendingActivation);
|
|
1204
|
+
const publicResponse = parseRouterAbEcdsaStrictForwardedRegistrationResponseV1(record.publicResponse);
|
|
1205
|
+
const publicFacts = parseRouterAbEcdsaVerifiedClientActivationFactsV1(record.publicFacts);
|
|
1206
|
+
return registrationRequest.registration_purpose === "wallet_registration" ? {
|
|
1207
|
+
kind: "evm_family_ecdsa_activation_claimed",
|
|
1208
|
+
branchKey: base.branchKey,
|
|
1209
|
+
derivationKind: base.derivationKind,
|
|
1210
|
+
chainTargets: base.chainTargets,
|
|
1211
|
+
prepare: base.prepare,
|
|
1212
|
+
strictRegistration: base.strictRegistration,
|
|
1213
|
+
strictRegistrationBindingJson: base.strictRegistrationBindingJson,
|
|
1214
|
+
registrationRequest,
|
|
1215
|
+
pendingActivation,
|
|
1216
|
+
publicResponse,
|
|
1217
|
+
publicFacts,
|
|
1218
|
+
activationRequestDigestB64u,
|
|
1219
|
+
activationOwner
|
|
1220
|
+
} : null;
|
|
1221
|
+
} catch {
|
|
1222
|
+
return null;
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
case "evm_family_ecdsa_activated":
|
|
1226
|
+
case "evm_family_ecdsa_finalized": {
|
|
1227
|
+
const base = parseStoredWalletRegistrationEcdsaBranchBase(record);
|
|
1228
|
+
const bootstrap = parseStoredEcdsaDerivationServerBootstrapResponse(record.bootstrap);
|
|
1229
|
+
if (!base || !bootstrap) return null;
|
|
1230
|
+
try {
|
|
1231
|
+
const registrationRequest = parseRouterAbEcdsaRegistrationRequestV1(record.registrationRequest);
|
|
1232
|
+
const publicFacts = parseRouterAbEcdsaVerifiedClientActivationFactsV1(record.publicFacts);
|
|
1233
|
+
const activation = parseRouterAbEcdsaRegistrationActivationReceiptV1(record.activation);
|
|
1234
|
+
const publicCapability = parseRouterAbEcdsaDerivationPublicCapabilityV1(record.publicCapability);
|
|
1235
|
+
if (registrationRequest.registration_purpose !== "wallet_registration") return null;
|
|
1236
|
+
if (record.kind === "evm_family_ecdsa_activated") {
|
|
1237
|
+
const activationOwner = trimString(record.activationOwner);
|
|
1238
|
+
return activationOwner ? {
|
|
1239
|
+
kind: "evm_family_ecdsa_activated",
|
|
1240
|
+
branchKey: base.branchKey,
|
|
1241
|
+
derivationKind: base.derivationKind,
|
|
1242
|
+
chainTargets: base.chainTargets,
|
|
1243
|
+
prepare: base.prepare,
|
|
1244
|
+
strictRegistration: base.strictRegistration,
|
|
1245
|
+
strictRegistrationBindingJson: base.strictRegistrationBindingJson,
|
|
1246
|
+
registrationRequest,
|
|
1247
|
+
publicFacts,
|
|
1248
|
+
activation,
|
|
1249
|
+
publicCapability,
|
|
1250
|
+
bootstrap,
|
|
1251
|
+
activationOwner
|
|
1252
|
+
} : null;
|
|
1253
|
+
}
|
|
1254
|
+
const finalizedAtMs = Number(record.finalizedAtMs);
|
|
1255
|
+
return Number.isSafeInteger(finalizedAtMs) && finalizedAtMs > 0 ? {
|
|
1256
|
+
kind: "evm_family_ecdsa_finalized",
|
|
1257
|
+
branchKey: base.branchKey,
|
|
1258
|
+
derivationKind: base.derivationKind,
|
|
1259
|
+
chainTargets: base.chainTargets,
|
|
1260
|
+
prepare: base.prepare,
|
|
1261
|
+
strictRegistration: base.strictRegistration,
|
|
1262
|
+
strictRegistrationBindingJson: base.strictRegistrationBindingJson,
|
|
1263
|
+
registrationRequest,
|
|
1264
|
+
publicFacts,
|
|
1265
|
+
activation,
|
|
1266
|
+
publicCapability,
|
|
1267
|
+
bootstrap,
|
|
1268
|
+
finalizedAtMs
|
|
1269
|
+
} : null;
|
|
1270
|
+
} catch {
|
|
1271
|
+
return null;
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
default: return null;
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
function parseStoredWalletRegistrationSignerState(value) {
|
|
1278
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
|
|
1279
|
+
const record = value;
|
|
1280
|
+
if (record.kind === "signer_set_registration") {
|
|
1281
|
+
if (!Array.isArray(record.branches)) return null;
|
|
1282
|
+
const branches = [];
|
|
1283
|
+
for (const rawBranch of record.branches) {
|
|
1284
|
+
const branch = parseStoredWalletRegistrationSignerBranch(rawBranch);
|
|
1285
|
+
if (!branch) return null;
|
|
1286
|
+
branches.push(branch);
|
|
1287
|
+
}
|
|
1288
|
+
return {
|
|
1289
|
+
kind: "signer_set_registration",
|
|
1290
|
+
branches
|
|
1291
|
+
};
|
|
1292
|
+
}
|
|
1293
|
+
if (record.kind !== "registration_failed") return null;
|
|
1294
|
+
const failedAtMs = Number(record.failedAtMs);
|
|
1295
|
+
if (!Number.isSafeInteger(failedAtMs) || failedAtMs <= 0 || record.failure === null || typeof record.failure !== "object" || Array.isArray(record.failure)) return null;
|
|
1296
|
+
const failure = record.failure;
|
|
1297
|
+
const code = trimString(failure.code);
|
|
1298
|
+
const message = trimString(failure.message);
|
|
1299
|
+
return code && message ? {
|
|
1300
|
+
kind: "registration_failed",
|
|
1301
|
+
failedAtMs,
|
|
1302
|
+
failure: {
|
|
1303
|
+
code,
|
|
1304
|
+
message
|
|
1305
|
+
}
|
|
1306
|
+
} : null;
|
|
1307
|
+
}
|
|
1308
|
+
function parseStoredRegistrationDigest(value) {
|
|
1309
|
+
try {
|
|
1310
|
+
return parseDigestB64u(value);
|
|
1311
|
+
} catch {
|
|
1312
|
+
return null;
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
function parseStoredWalletRegistrationCeremony(value) {
|
|
1316
|
+
const decoded = parseJsonValue(value);
|
|
1317
|
+
if (decoded === null || typeof decoded !== "object" || Array.isArray(decoded)) return null;
|
|
1318
|
+
const record = decoded;
|
|
1319
|
+
const registrationCeremonyId = trimString(record.registrationCeremonyId);
|
|
1320
|
+
const foundingWalletAuthorityId = parseWalletAuthorityId(record.foundingWalletAuthorityId);
|
|
1321
|
+
const foundingDeviceId = parseDeviceId(record.foundingDeviceId);
|
|
1322
|
+
const foundingWalletAuthMethodId = parseWalletAuthMethodId(record.foundingWalletAuthMethodId);
|
|
1323
|
+
const intent = parseStoredRegistrationIntent(record.intent);
|
|
1324
|
+
const digestB64u = trimString(record.digestB64u);
|
|
1325
|
+
const signerPlan = parseStoredRegistrationSignerPlan(record.signerPlan);
|
|
1326
|
+
const preparedContext = parseStoredWalletRegistrationPreparedContext(record.preparedContext);
|
|
1327
|
+
const orgId = trimString(record.orgId);
|
|
1328
|
+
const signingRootId = trimString(record.signingRootId);
|
|
1329
|
+
const signingRootVersion = trimString(record.signingRootVersion);
|
|
1330
|
+
const expectedOrigin = trimString(record.expectedOrigin);
|
|
1331
|
+
const expiresAtMs = Number(record.expiresAtMs);
|
|
1332
|
+
const authorityState = parseStoredWalletRegistrationCeremonyAuthorityState(record.authorityState);
|
|
1333
|
+
const signerState = parseStoredWalletRegistrationSignerState(record.signerState);
|
|
1334
|
+
const intentSignerPlan = intent ? parseStoredRegistrationSignerPlan(intent.signerSelection) : null;
|
|
1335
|
+
if (!registrationCeremonyId || !authorityState || !foundingWalletAuthorityId.ok || !foundingDeviceId.ok || !foundingWalletAuthMethodId.ok || !intent || !digestB64u || !orgId || !Number.isSafeInteger(expiresAtMs) || !signerPlan || !preparedContext || !intentSignerPlan || !storedRegistrationSignerPlansMatch(signerPlan, intentSignerPlan) || signingRootId && preparedContext.signingRootId !== signingRootId || signingRootVersion && preparedContext.signingRootVersion !== signingRootVersion || !signerState) return null;
|
|
1336
|
+
return {
|
|
1337
|
+
registrationCeremonyId,
|
|
1338
|
+
foundingWalletAuthorityId: foundingWalletAuthorityId.value,
|
|
1339
|
+
foundingDeviceId: foundingDeviceId.value,
|
|
1340
|
+
foundingWalletAuthMethodId: foundingWalletAuthMethodId.value,
|
|
1341
|
+
intent,
|
|
1342
|
+
digestB64u,
|
|
1343
|
+
signerPlan,
|
|
1344
|
+
preparedContext,
|
|
1345
|
+
orgId,
|
|
1346
|
+
...signingRootId ? { signingRootId } : {},
|
|
1347
|
+
...signingRootVersion ? { signingRootVersion } : {},
|
|
1348
|
+
...expectedOrigin ? { expectedOrigin } : {},
|
|
1349
|
+
expiresAtMs,
|
|
1350
|
+
authorityState,
|
|
1351
|
+
signerState
|
|
1352
|
+
};
|
|
1353
|
+
}
|
|
1354
|
+
function parseStoredWalletRegistrationCeremonyAuthorityState(value) {
|
|
1355
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
|
|
1356
|
+
const record = value;
|
|
1357
|
+
switch (record.kind) {
|
|
1358
|
+
case "awaiting_proof": {
|
|
1359
|
+
const authMethod = parseStoredRegistrationCeremonyAuthMethod(record.authMethod);
|
|
1360
|
+
return authMethod ? {
|
|
1361
|
+
kind: "awaiting_proof",
|
|
1362
|
+
authMethod
|
|
1363
|
+
} : null;
|
|
1364
|
+
}
|
|
1365
|
+
case "verified": {
|
|
1366
|
+
const authority = parseStoredRegistrationAuthority(record.authority);
|
|
1367
|
+
return authority ? {
|
|
1368
|
+
kind: "verified",
|
|
1369
|
+
authority
|
|
1370
|
+
} : null;
|
|
1371
|
+
}
|
|
1372
|
+
default: return null;
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
function parseStoredRegistrationCeremonyAuthMethod(value) {
|
|
1376
|
+
return normalizeRegistrationAuthMethodInput(parseJsonValue(value));
|
|
1377
|
+
}
|
|
1378
|
+
function parseStoredWalletAddSignerAuth(value) {
|
|
1379
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
|
|
1380
|
+
const record = value;
|
|
1381
|
+
if (record.kind !== "webauthn_assertion") return null;
|
|
1382
|
+
const rpId = parseWebAuthnRpId(record.rpId);
|
|
1383
|
+
const credentialIdB64u = parseWebAuthnCredentialIdB64u(record.credentialIdB64u);
|
|
1384
|
+
return rpId.ok && credentialIdB64u.ok ? {
|
|
1385
|
+
kind: "webauthn_assertion",
|
|
1386
|
+
rpId: rpId.value,
|
|
1387
|
+
credentialIdB64u: credentialIdB64u.value
|
|
1388
|
+
} : null;
|
|
1389
|
+
}
|
|
1390
|
+
function parseStoredWalletAddSignerEcdsaStateBase(value) {
|
|
1391
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
|
|
1392
|
+
const record = value;
|
|
1393
|
+
const chainTargets = parseStoredRegistrationEcdsaChainTargets(record.chainTargets);
|
|
1394
|
+
const prepare = parseStoredWalletRegistrationEcdsaPrepare(record.prepare);
|
|
1395
|
+
if (record.derivationKind !== "evm_family_ecdsa_keygen" || !chainTargets || !prepare) return null;
|
|
1396
|
+
let strictRegistration;
|
|
1397
|
+
try {
|
|
1398
|
+
strictRegistration = parseRouterAbEcdsaRegistrationRequestFactsV1(record.strictRegistration);
|
|
1399
|
+
} catch {
|
|
1400
|
+
return null;
|
|
1401
|
+
}
|
|
1402
|
+
return strictRegistration.registration_purpose === "wallet_add_signer" ? {
|
|
1403
|
+
derivationKind: "evm_family_ecdsa_keygen",
|
|
1404
|
+
chainTargets,
|
|
1405
|
+
prepare,
|
|
1406
|
+
strictRegistration
|
|
1407
|
+
} : null;
|
|
1408
|
+
}
|
|
1409
|
+
function parseStoredWalletAddSignerNearActivation(value) {
|
|
1410
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
|
|
1411
|
+
const record = value;
|
|
1412
|
+
if (record.finalizeRequest === null || typeof record.finalizeRequest !== "object" || Array.isArray(record.finalizeRequest) || record.activation === null || typeof record.activation !== "object" || Array.isArray(record.activation)) return null;
|
|
1413
|
+
const finalizeRequest = parseStoredWalletAddSignerFinalizeRequest(record.finalizeRequest);
|
|
1414
|
+
const activation = record.activation;
|
|
1415
|
+
const admissionRequest = parseRouterAbEd25519YaoRegistrationAdmissionRequestV1(activation.admissionRequest);
|
|
1416
|
+
const admissionReceipt = parseRouterAbEd25519YaoRegistrationActivationAdmissionReceiptV1(activation.admissionReceipt);
|
|
1417
|
+
const result = parseRouterAbEd25519YaoRegistrationActivationResultV1(activation.result);
|
|
1418
|
+
if (!finalizeRequest || finalizeRequest.kind !== "near_ed25519" || !admissionRequest.ok || !admissionReceipt.ok || !result.ok) return null;
|
|
1419
|
+
const { lifecycleId, sessionId } = finalizeRequest.activationReference;
|
|
1420
|
+
if (lifecycleId !== admissionRequest.value.scope.lifecycle_id || !storedWalletAddSignerByteArraysEqual(sessionId, admissionReceipt.value.binding.session_id) || !storedWalletAddSignerByteArraysEqual(sessionId, result.value.binding.session_id)) return null;
|
|
1421
|
+
return {
|
|
1422
|
+
finalizeRequest,
|
|
1423
|
+
activation: {
|
|
1424
|
+
admissionRequest: admissionRequest.value,
|
|
1425
|
+
admissionReceipt: admissionReceipt.value,
|
|
1426
|
+
result: result.value
|
|
1427
|
+
}
|
|
1428
|
+
};
|
|
1429
|
+
}
|
|
1430
|
+
function parseStoredWalletAddSignerSignerState(value) {
|
|
1431
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
|
|
1432
|
+
const record = value;
|
|
1433
|
+
switch (record.kind) {
|
|
1434
|
+
case "near_ed25519_yao_add_signer_authorized": {
|
|
1435
|
+
const admissionRequest = parseRouterAbEd25519YaoRegistrationAdmissionRequestV1(record.admissionRequest);
|
|
1436
|
+
return admissionRequest.ok ? {
|
|
1437
|
+
kind: "near_ed25519_yao_add_signer_authorized",
|
|
1438
|
+
admissionRequest: admissionRequest.value
|
|
1439
|
+
} : null;
|
|
1440
|
+
}
|
|
1441
|
+
case "near_ed25519_yao_add_signer_activated": {
|
|
1442
|
+
const activation = parseStoredWalletAddSignerNearActivation(record);
|
|
1443
|
+
return activation ? {
|
|
1444
|
+
kind: "near_ed25519_yao_add_signer_activated",
|
|
1445
|
+
finalizeRequest: activation.finalizeRequest,
|
|
1446
|
+
activation: activation.activation
|
|
1447
|
+
} : null;
|
|
1448
|
+
}
|
|
1449
|
+
case "near_ed25519_yao_add_signer_finalizing": {
|
|
1450
|
+
const activation = parseStoredWalletAddSignerNearActivation(record);
|
|
1451
|
+
const response = parseStoredWalletAddSignerFinalizeSuccess(record.response);
|
|
1452
|
+
if (!activation || !response || response.kind !== "near_ed25519") return null;
|
|
1453
|
+
const signer = parseWalletEd25519SignerRecord(record.signer);
|
|
1454
|
+
const finalizingAtMs = Number(record.finalizingAtMs);
|
|
1455
|
+
return signer && Number.isSafeInteger(finalizingAtMs) && finalizingAtMs > 0 ? {
|
|
1456
|
+
kind: "near_ed25519_yao_add_signer_finalizing",
|
|
1457
|
+
finalizeRequest: activation.finalizeRequest,
|
|
1458
|
+
activation: activation.activation,
|
|
1459
|
+
response,
|
|
1460
|
+
signer,
|
|
1461
|
+
finalizingAtMs
|
|
1462
|
+
} : null;
|
|
1463
|
+
}
|
|
1464
|
+
case "ecdsa_add_signer_prepared": {
|
|
1465
|
+
const base = parseStoredWalletAddSignerEcdsaStateBase(record);
|
|
1466
|
+
return base ? {
|
|
1467
|
+
kind: "ecdsa_add_signer_prepared",
|
|
1468
|
+
derivationKind: base.derivationKind,
|
|
1469
|
+
chainTargets: base.chainTargets,
|
|
1470
|
+
prepare: base.prepare,
|
|
1471
|
+
strictRegistration: base.strictRegistration
|
|
1472
|
+
} : null;
|
|
1473
|
+
}
|
|
1474
|
+
case "ecdsa_add_signer_pending_activation": {
|
|
1475
|
+
const base = parseStoredWalletAddSignerEcdsaStateBase(record);
|
|
1476
|
+
if (!base) return null;
|
|
1477
|
+
try {
|
|
1478
|
+
const registrationRequest = parseRouterAbEcdsaRegistrationRequestV1(record.registrationRequest);
|
|
1479
|
+
const pendingActivation = parseStoredRouterAbEcdsaPendingActivationV1(record.pendingActivation);
|
|
1480
|
+
const publicResponse = parseRouterAbEcdsaStrictForwardedRegistrationResponseV1(record.publicResponse);
|
|
1481
|
+
return registrationRequest.registration_purpose === "wallet_add_signer" ? {
|
|
1482
|
+
kind: "ecdsa_add_signer_pending_activation",
|
|
1483
|
+
derivationKind: base.derivationKind,
|
|
1484
|
+
chainTargets: base.chainTargets,
|
|
1485
|
+
prepare: base.prepare,
|
|
1486
|
+
strictRegistration: base.strictRegistration,
|
|
1487
|
+
registrationRequest,
|
|
1488
|
+
pendingActivation,
|
|
1489
|
+
publicResponse
|
|
1490
|
+
} : null;
|
|
1491
|
+
} catch {
|
|
1492
|
+
return null;
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
case "ecdsa_add_signer_activation_claimed": {
|
|
1496
|
+
const base = parseStoredWalletAddSignerEcdsaStateBase(record);
|
|
1497
|
+
const activationRequestDigestB64u = parseStoredRegistrationDigest(record.activationRequestDigestB64u);
|
|
1498
|
+
if (!base || !activationRequestDigestB64u) return null;
|
|
1499
|
+
try {
|
|
1500
|
+
const registrationRequest = parseRouterAbEcdsaRegistrationRequestV1(record.registrationRequest);
|
|
1501
|
+
const pendingActivation = parseStoredRouterAbEcdsaPendingActivationV1(record.pendingActivation);
|
|
1502
|
+
const publicResponse = parseRouterAbEcdsaStrictForwardedRegistrationResponseV1(record.publicResponse);
|
|
1503
|
+
const publicFacts = parseRouterAbEcdsaVerifiedClientActivationFactsV1(record.publicFacts);
|
|
1504
|
+
return registrationRequest.registration_purpose === "wallet_add_signer" ? {
|
|
1505
|
+
kind: "ecdsa_add_signer_activation_claimed",
|
|
1506
|
+
derivationKind: base.derivationKind,
|
|
1507
|
+
chainTargets: base.chainTargets,
|
|
1508
|
+
prepare: base.prepare,
|
|
1509
|
+
strictRegistration: base.strictRegistration,
|
|
1510
|
+
registrationRequest,
|
|
1511
|
+
pendingActivation,
|
|
1512
|
+
publicResponse,
|
|
1513
|
+
publicFacts,
|
|
1514
|
+
activationRequestDigestB64u
|
|
1515
|
+
} : null;
|
|
1516
|
+
} catch {
|
|
1517
|
+
return null;
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
case "ecdsa_add_signer_activated": {
|
|
1521
|
+
const base = parseStoredWalletAddSignerEcdsaStateBase(record);
|
|
1522
|
+
const activationRequestDigestB64u = parseStoredRegistrationDigest(record.activationRequestDigestB64u);
|
|
1523
|
+
const bootstrap = parseStoredEcdsaDerivationServerBootstrapResponse(record.bootstrap);
|
|
1524
|
+
if (!base || !activationRequestDigestB64u || !bootstrap) return null;
|
|
1525
|
+
try {
|
|
1526
|
+
const registrationRequest = parseRouterAbEcdsaRegistrationRequestV1(record.registrationRequest);
|
|
1527
|
+
const publicFacts = parseRouterAbEcdsaVerifiedClientActivationFactsV1(record.publicFacts);
|
|
1528
|
+
const activation = parseRouterAbEcdsaRegistrationActivationReceiptV1(record.activation);
|
|
1529
|
+
const publicCapability = parseRouterAbEcdsaDerivationPublicCapabilityV1(record.publicCapability);
|
|
1530
|
+
return registrationRequest.registration_purpose === "wallet_add_signer" ? {
|
|
1531
|
+
kind: "ecdsa_add_signer_activated",
|
|
1532
|
+
derivationKind: base.derivationKind,
|
|
1533
|
+
chainTargets: base.chainTargets,
|
|
1534
|
+
prepare: base.prepare,
|
|
1535
|
+
strictRegistration: base.strictRegistration,
|
|
1536
|
+
registrationRequest,
|
|
1537
|
+
publicFacts,
|
|
1538
|
+
activationRequestDigestB64u,
|
|
1539
|
+
activation,
|
|
1540
|
+
publicCapability,
|
|
1541
|
+
bootstrap
|
|
1542
|
+
} : null;
|
|
1543
|
+
} catch {
|
|
1544
|
+
return null;
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
default: return null;
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
function storedWalletAddSignerByteArraysEqual(left, right) {
|
|
1551
|
+
return left.length === right.length && left.every((byte, index) => byte === right[index]);
|
|
1552
|
+
}
|
|
1553
|
+
function parseStoredWalletAddSignerCeremony(value) {
|
|
1554
|
+
const decoded = parseJsonValue(value);
|
|
1555
|
+
if (decoded === null || typeof decoded !== "object" || Array.isArray(decoded)) return null;
|
|
1556
|
+
const record = decoded;
|
|
1557
|
+
const addSignerCeremonyId = trimString(record.addSignerCeremonyId);
|
|
1558
|
+
const digestB64u = trimString(record.digestB64u);
|
|
1559
|
+
const orgId = trimString(record.orgId);
|
|
1560
|
+
const signingRootId = trimString(record.signingRootId);
|
|
1561
|
+
const signingRootVersion = trimString(record.signingRootVersion);
|
|
1562
|
+
const expiresAtMs = Number(record.expiresAtMs);
|
|
1563
|
+
const intentRecord = parseStoredAddSignerIntent({
|
|
1564
|
+
kind: "add_signer_intent_allocated",
|
|
1565
|
+
grant: "ignored",
|
|
1566
|
+
intent: record.intent,
|
|
1567
|
+
digestB64u,
|
|
1568
|
+
orgId,
|
|
1569
|
+
expiresAtMs
|
|
1570
|
+
});
|
|
1571
|
+
const auth = parseStoredWalletAddSignerAuth(record.auth);
|
|
1572
|
+
const signerState = parseStoredWalletAddSignerSignerState(record.signerState);
|
|
1573
|
+
if (!addSignerCeremonyId || !digestB64u || !orgId || !signingRootId || !signingRootVersion || !Number.isSafeInteger(expiresAtMs) || !intentRecord || !auth || !signerState) return null;
|
|
1574
|
+
if ((signerState.kind === "near_ed25519_yao_add_signer_activated" || signerState.kind === "near_ed25519_yao_add_signer_finalizing") && signerState.finalizeRequest.addSignerCeremonyId !== addSignerCeremonyId) return null;
|
|
1575
|
+
return {
|
|
1576
|
+
addSignerCeremonyId,
|
|
1577
|
+
intent: intentRecord.intent,
|
|
1578
|
+
digestB64u,
|
|
1579
|
+
orgId,
|
|
1580
|
+
signingRootId,
|
|
1581
|
+
signingRootVersion,
|
|
1582
|
+
expiresAtMs,
|
|
1583
|
+
auth,
|
|
1584
|
+
signerState
|
|
1585
|
+
};
|
|
1586
|
+
}
|
|
1587
|
+
function parseStoredWalletAddAuthMethodCeremonyAuth(value) {
|
|
1588
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
|
|
1589
|
+
const record = value;
|
|
1590
|
+
if (record.kind === "email_otp") {
|
|
1591
|
+
const providerUserId = trimString(record.providerUserId);
|
|
1592
|
+
const enrollmentId = trimString(record.enrollmentId);
|
|
1593
|
+
const enrollmentSealKeyVersion = trimString(record.enrollmentSealKeyVersion);
|
|
1594
|
+
const authorityRef = parseWalletAuthAuthorityRef(record.authorityRef);
|
|
1595
|
+
if (!providerUserId || !enrollmentId || !enrollmentSealKeyVersion || !authorityRef) return null;
|
|
1596
|
+
return {
|
|
1597
|
+
kind: "email_otp",
|
|
1598
|
+
providerUserId,
|
|
1599
|
+
enrollmentId,
|
|
1600
|
+
enrollmentSealKeyVersion,
|
|
1601
|
+
authorityRef
|
|
1602
|
+
};
|
|
1603
|
+
}
|
|
1604
|
+
if (record.kind === "wallet_session") {
|
|
1605
|
+
const walletSessionId = trimString(record.walletSessionId);
|
|
1606
|
+
const authorizationId = trimString(record.authorizationId);
|
|
1607
|
+
const rpId = trimString(record.rpId);
|
|
1608
|
+
const credentialIdB64u = trimString(record.credentialIdB64u);
|
|
1609
|
+
if (!walletSessionId || !authorizationId || !rpId || !credentialIdB64u) return null;
|
|
1610
|
+
return {
|
|
1611
|
+
kind: "wallet_session",
|
|
1612
|
+
walletSessionId,
|
|
1613
|
+
authorizationId,
|
|
1614
|
+
rpId,
|
|
1615
|
+
credentialIdB64u
|
|
1616
|
+
};
|
|
1617
|
+
}
|
|
1618
|
+
if (record.kind !== "webauthn_assertion") return null;
|
|
1619
|
+
const rpId = trimString(record.rpId);
|
|
1620
|
+
const credentialIdB64u = trimString(record.credentialIdB64u);
|
|
1621
|
+
if (!rpId || !credentialIdB64u) return null;
|
|
1622
|
+
return {
|
|
1623
|
+
kind: "webauthn_assertion",
|
|
1624
|
+
rpId,
|
|
1625
|
+
credentialIdB64u
|
|
1626
|
+
};
|
|
1627
|
+
}
|
|
1628
|
+
function addAuthMethodCustodyFactorMatches(auth, custodyEnvelope) {
|
|
1629
|
+
switch (auth.kind) {
|
|
1630
|
+
case "webauthn_assertion":
|
|
1631
|
+
case "wallet_session": return custodyEnvelope.factor.kind === "passkey" && custodyEnvelope.factor.rpId === auth.rpId && custodyEnvelope.factor.credentialIdB64u === auth.credentialIdB64u;
|
|
1632
|
+
case "email_otp": return custodyEnvelope.factor.kind === "email_otp" && custodyEnvelope.factor.enrollmentId === auth.enrollmentId && custodyEnvelope.factor.enrollmentSealKeyVersion === auth.enrollmentSealKeyVersion;
|
|
1633
|
+
default: return assertNever(auth);
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
/**
|
|
1637
|
+
* Nullable wrapper over the canonical parser. Reading these options a second,
|
|
1638
|
+
* looser way here is what would let a stored ceremony and a live one disagree.
|
|
1639
|
+
*/
|
|
1640
|
+
function parseStoredWalletAddAuthMethodRegistrationOptions(value) {
|
|
1641
|
+
try {
|
|
1642
|
+
return parseWalletAddAuthMethodRegistrationOptions(value);
|
|
1643
|
+
} catch {
|
|
1644
|
+
return null;
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
function parseStoredWalletAddAuthMethodCeremony(value) {
|
|
1648
|
+
const decoded = parseJsonValue(value);
|
|
1649
|
+
if (decoded === null || typeof decoded !== "object" || Array.isArray(decoded)) return null;
|
|
1650
|
+
const record = decoded;
|
|
1651
|
+
const addAuthMethodCeremonyId = trimString(record.addAuthMethodCeremonyId);
|
|
1652
|
+
const digestB64u = trimString(record.digestB64u);
|
|
1653
|
+
const orgId = trimString(record.orgId);
|
|
1654
|
+
const expiresAtMs = Number(record.expiresAtMs);
|
|
1655
|
+
const sourceWalletAuthMethodId = parseWalletAuthMethodId(record.sourceWalletAuthMethodId);
|
|
1656
|
+
const sourceWalletAuthorityId = parseWalletAuthorityId(record.sourceWalletAuthorityId);
|
|
1657
|
+
const targetWalletAuthMethodId = parseWalletAuthMethodId(record.targetWalletAuthMethodId);
|
|
1658
|
+
let sourceAuthorityDigestB64u;
|
|
1659
|
+
try {
|
|
1660
|
+
sourceAuthorityDigestB64u = parseDigestB64u(record.sourceAuthorityDigestB64u);
|
|
1661
|
+
} catch {
|
|
1662
|
+
return null;
|
|
1663
|
+
}
|
|
1664
|
+
const sourceAuthorityRevocationEpoch = Number(record.sourceAuthorityRevocationEpoch);
|
|
1665
|
+
if (!addAuthMethodCeremonyId || !digestB64u || !orgId || !Number.isSafeInteger(expiresAtMs) || !sourceWalletAuthMethodId.ok || !sourceWalletAuthorityId.ok || !Number.isSafeInteger(sourceAuthorityRevocationEpoch) || sourceAuthorityRevocationEpoch < 0 || !targetWalletAuthMethodId.ok) return null;
|
|
1666
|
+
const auth = parseStoredWalletAddAuthMethodCeremonyAuth(record.auth);
|
|
1667
|
+
const intentRecord = parseStoredAddAuthMethodIntent({
|
|
1668
|
+
kind: "add_auth_method_intent_allocated",
|
|
1669
|
+
grant: "ignored",
|
|
1670
|
+
intent: record.intent,
|
|
1671
|
+
digestB64u,
|
|
1672
|
+
orgId,
|
|
1673
|
+
expiresAtMs
|
|
1674
|
+
});
|
|
1675
|
+
if (!auth || !intentRecord) return null;
|
|
1676
|
+
let custodyEnvelope;
|
|
1677
|
+
try {
|
|
1678
|
+
custodyEnvelope = parsePasskeyCustodyEnvelopeRecord(record.custodyEnvelope);
|
|
1679
|
+
} catch {
|
|
1680
|
+
return null;
|
|
1681
|
+
}
|
|
1682
|
+
if (custodyEnvelope.walletId !== intentRecord.intent.walletId || !addAuthMethodCustodyFactorMatches(auth, custodyEnvelope) || custodyEnvelope.lifecycle.state !== "active") return null;
|
|
1683
|
+
const kind = record.kind;
|
|
1684
|
+
if (kind === "email_otp") {
|
|
1685
|
+
const authority = parseStoredRegistrationAuthority(record.authority);
|
|
1686
|
+
if (!authority || authority.kind !== "email_otp") return null;
|
|
1687
|
+
return {
|
|
1688
|
+
kind: "email_otp",
|
|
1689
|
+
custodyEnvelope,
|
|
1690
|
+
addAuthMethodCeremonyId,
|
|
1691
|
+
intent: intentRecord.intent,
|
|
1692
|
+
digestB64u,
|
|
1693
|
+
orgId,
|
|
1694
|
+
sourceWalletAuthMethodId: sourceWalletAuthMethodId.value,
|
|
1695
|
+
sourceWalletAuthorityId: sourceWalletAuthorityId.value,
|
|
1696
|
+
sourceAuthorityDigestB64u,
|
|
1697
|
+
sourceAuthorityRevocationEpoch,
|
|
1698
|
+
targetWalletAuthMethodId: targetWalletAuthMethodId.value,
|
|
1699
|
+
expiresAtMs: Math.floor(expiresAtMs),
|
|
1700
|
+
auth,
|
|
1701
|
+
authority,
|
|
1702
|
+
...trimString(record.expectedOrigin) ? { expectedOrigin: trimString(record.expectedOrigin) } : {}
|
|
1703
|
+
};
|
|
1704
|
+
}
|
|
1705
|
+
if (kind !== "passkey" || record.passkeyRegistration === null || typeof record.passkeyRegistration !== "object" || Array.isArray(record.passkeyRegistration)) return null;
|
|
1706
|
+
const passkeyRegistration = record.passkeyRegistration;
|
|
1707
|
+
const rpId = parseWebAuthnRpId(passkeyRegistration.rpId);
|
|
1708
|
+
const challengeB64u = trimString(passkeyRegistration.challengeB64u);
|
|
1709
|
+
const options = parseStoredWalletAddAuthMethodRegistrationOptions(passkeyRegistration.options);
|
|
1710
|
+
if (!rpId.ok || !challengeB64u || !options || options.rpId !== rpId.value || options.challengeB64u !== challengeB64u || intentRecord.intent.authMethod.kind !== "passkey" || intentRecord.intent.authMethod.rpId !== rpId.value) return null;
|
|
1711
|
+
return {
|
|
1712
|
+
kind: "passkey",
|
|
1713
|
+
addAuthMethodCeremonyId,
|
|
1714
|
+
intent: intentRecord.intent,
|
|
1715
|
+
digestB64u,
|
|
1716
|
+
orgId,
|
|
1717
|
+
sourceWalletAuthMethodId: sourceWalletAuthMethodId.value,
|
|
1718
|
+
sourceWalletAuthorityId: sourceWalletAuthorityId.value,
|
|
1719
|
+
sourceAuthorityDigestB64u,
|
|
1720
|
+
sourceAuthorityRevocationEpoch,
|
|
1721
|
+
targetWalletAuthMethodId: targetWalletAuthMethodId.value,
|
|
1722
|
+
expiresAtMs: Math.floor(expiresAtMs),
|
|
1723
|
+
auth,
|
|
1724
|
+
passkeyRegistration: {
|
|
1725
|
+
rpId: rpId.value,
|
|
1726
|
+
challengeB64u,
|
|
1727
|
+
options
|
|
1728
|
+
},
|
|
1729
|
+
custodyEnvelope,
|
|
1730
|
+
...trimString(record.expectedOrigin) ? { expectedOrigin: trimString(record.expectedOrigin) } : {}
|
|
1731
|
+
};
|
|
1732
|
+
}
|
|
1733
|
+
function isDurableObjectNamespaceLike(value) {
|
|
1734
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
|
|
1735
|
+
return "idFromName" in value && typeof value.idFromName === "function" && "get" in value && typeof value.get === "function";
|
|
1736
|
+
}
|
|
1737
|
+
function resolveDoNamespaceFromConfig(config) {
|
|
1738
|
+
const direct = config.namespace;
|
|
1739
|
+
if (isDurableObjectNamespaceLike(direct)) return direct;
|
|
1740
|
+
const durableObjectNamespace = config.durableObjectNamespace;
|
|
1741
|
+
if (isDurableObjectNamespaceLike(durableObjectNamespace)) return durableObjectNamespace;
|
|
1742
|
+
const envStyle = config.THRESHOLD_DO_NAMESPACE;
|
|
1743
|
+
if (isDurableObjectNamespaceLike(envStyle)) return envStyle;
|
|
1744
|
+
return null;
|
|
1745
|
+
}
|
|
1746
|
+
function resolveDoStub(input) {
|
|
1747
|
+
const id = input.namespace.idFromName(input.objectName);
|
|
1748
|
+
return input.namespace.get(id);
|
|
1749
|
+
}
|
|
1750
|
+
async function callDo(stub, request) {
|
|
1751
|
+
const response = await stub.fetch("https://threshold-store.invalid/", {
|
|
1752
|
+
method: "POST",
|
|
1753
|
+
headers: { "content-type": "application/json" },
|
|
1754
|
+
body: JSON.stringify(request)
|
|
1755
|
+
});
|
|
1756
|
+
const text = await response.text();
|
|
1757
|
+
if (!response.ok) throw new Error(`Registration ceremony DO store HTTP ${response.status}: ${text}`);
|
|
1758
|
+
let json;
|
|
1759
|
+
try {
|
|
1760
|
+
json = text ? JSON.parse(text) : null;
|
|
1761
|
+
} catch {
|
|
1762
|
+
throw new Error(`Registration ceremony DO store returned non-JSON response: ${text.slice(0, 200)}`);
|
|
1763
|
+
}
|
|
1764
|
+
if (json === null || typeof json !== "object" || Array.isArray(json)) throw new Error("Registration ceremony DO store returned invalid JSON shape");
|
|
1765
|
+
const responseKeys = Reflect.ownKeys(json);
|
|
1766
|
+
if (Reflect.get(json, "ok") === true && responseKeys.length === 2 && responseKeys.includes("ok") && responseKeys.includes("value")) return {
|
|
1767
|
+
ok: true,
|
|
1768
|
+
value: Reflect.get(json, "value")
|
|
1769
|
+
};
|
|
1770
|
+
if (Reflect.get(json, "ok") !== false || responseKeys.length !== 3 || !responseKeys.includes("ok") || !responseKeys.includes("code") || !responseKeys.includes("message")) throw new Error("Registration ceremony DO store returned invalid JSON shape");
|
|
1771
|
+
const code = trimString(Reflect.get(json, "code"));
|
|
1772
|
+
const message = trimString(Reflect.get(json, "message"));
|
|
1773
|
+
return {
|
|
1774
|
+
ok: false,
|
|
1775
|
+
code: code || "internal",
|
|
1776
|
+
message: message || "Registration ceremony DO store error"
|
|
1777
|
+
};
|
|
1778
|
+
}
|
|
1779
|
+
var CloudflareDurableObjectRegistrationCeremonyStore = class {
|
|
1780
|
+
constructor(input) {
|
|
1781
|
+
this.stub = resolveDoStub({
|
|
1782
|
+
namespace: input.namespace,
|
|
1783
|
+
objectName: input.objectName
|
|
1784
|
+
});
|
|
1785
|
+
this.prefix = input.prefix;
|
|
1786
|
+
}
|
|
1787
|
+
key(scope, id) {
|
|
1788
|
+
return `${this.prefix}${scope}:${id}`;
|
|
1789
|
+
}
|
|
1790
|
+
async putAddSignerIntent(intent) {
|
|
1791
|
+
const parsed = parseStoredAddSignerIntent(intent);
|
|
1792
|
+
if (!parsed) throw new Error("Invalid add-signer intent record");
|
|
1793
|
+
const ttlMs = Math.max(1, parsed.expiresAtMs - Date.now());
|
|
1794
|
+
const response = await callDo(this.stub, {
|
|
1795
|
+
op: "set",
|
|
1796
|
+
key: this.key("add-signer-intent", parsed.grant),
|
|
1797
|
+
value: parsed,
|
|
1798
|
+
ttlMs
|
|
1799
|
+
});
|
|
1800
|
+
if (!response.ok) throw new Error(response.message);
|
|
1801
|
+
}
|
|
1802
|
+
async getAddSignerIntent(grant) {
|
|
1803
|
+
const key = trimString(grant);
|
|
1804
|
+
if (!key) return null;
|
|
1805
|
+
const response = await callDo(this.stub, {
|
|
1806
|
+
op: "get",
|
|
1807
|
+
key: this.key("add-signer-intent", key)
|
|
1808
|
+
});
|
|
1809
|
+
if (!response.ok) return null;
|
|
1810
|
+
const intent = parseStoredAddSignerIntent(response.value);
|
|
1811
|
+
if (!intent || intent.expiresAtMs <= Date.now()) return null;
|
|
1812
|
+
return intent;
|
|
1813
|
+
}
|
|
1814
|
+
async takeAddSignerIntent(grant) {
|
|
1815
|
+
const key = trimString(grant);
|
|
1816
|
+
if (!key) return null;
|
|
1817
|
+
const response = await callDo(this.stub, {
|
|
1818
|
+
op: "getdel",
|
|
1819
|
+
key: this.key("add-signer-intent", key)
|
|
1820
|
+
});
|
|
1821
|
+
if (!response.ok) return null;
|
|
1822
|
+
const intent = parseStoredAddSignerIntent(response.value);
|
|
1823
|
+
if (!intent || intent.expiresAtMs <= Date.now()) return null;
|
|
1824
|
+
return {
|
|
1825
|
+
...intent,
|
|
1826
|
+
kind: "add_signer_intent_consumed",
|
|
1827
|
+
consumedAtMs: Date.now()
|
|
1828
|
+
};
|
|
1829
|
+
}
|
|
1830
|
+
async putAddAuthMethodIntent(intent) {
|
|
1831
|
+
const parsed = parseStoredAddAuthMethodIntent(intent);
|
|
1832
|
+
if (!parsed) throw new Error("Invalid add-auth-method intent record");
|
|
1833
|
+
const ttlMs = Math.max(1, parsed.expiresAtMs - Date.now());
|
|
1834
|
+
const response = await callDo(this.stub, {
|
|
1835
|
+
op: "set",
|
|
1836
|
+
key: this.key("add-auth-method-intent", parsed.grant),
|
|
1837
|
+
value: parsed,
|
|
1838
|
+
ttlMs
|
|
1839
|
+
});
|
|
1840
|
+
if (!response.ok) throw new Error(response.message);
|
|
1841
|
+
}
|
|
1842
|
+
async getAddAuthMethodIntent(grant) {
|
|
1843
|
+
const key = trimString(grant);
|
|
1844
|
+
if (!key) return null;
|
|
1845
|
+
const response = await callDo(this.stub, {
|
|
1846
|
+
op: "get",
|
|
1847
|
+
key: this.key("add-auth-method-intent", key)
|
|
1848
|
+
});
|
|
1849
|
+
if (!response.ok) return null;
|
|
1850
|
+
const intent = parseStoredAddAuthMethodIntent(response.value);
|
|
1851
|
+
if (!intent || intent.expiresAtMs <= Date.now()) return null;
|
|
1852
|
+
return intent;
|
|
1853
|
+
}
|
|
1854
|
+
async takeAddAuthMethodIntent(grant) {
|
|
1855
|
+
const key = trimString(grant);
|
|
1856
|
+
if (!key) return null;
|
|
1857
|
+
const response = await callDo(this.stub, {
|
|
1858
|
+
op: "getdel",
|
|
1859
|
+
key: this.key("add-auth-method-intent", key)
|
|
1860
|
+
});
|
|
1861
|
+
if (!response.ok) return null;
|
|
1862
|
+
const intent = parseStoredAddAuthMethodIntent(response.value);
|
|
1863
|
+
if (!intent || intent.expiresAtMs <= Date.now()) return null;
|
|
1864
|
+
return {
|
|
1865
|
+
...intent,
|
|
1866
|
+
kind: "add_auth_method_intent_consumed",
|
|
1867
|
+
consumedAtMs: Date.now()
|
|
1868
|
+
};
|
|
1869
|
+
}
|
|
1870
|
+
async putCeremony(ceremony) {
|
|
1871
|
+
const parsed = parseStoredWalletRegistrationCeremony(ceremony);
|
|
1872
|
+
if (!parsed) throw new Error("Invalid registration ceremony record");
|
|
1873
|
+
const ttlMs = Math.max(1, parsed.expiresAtMs - Date.now());
|
|
1874
|
+
const response = await callDo(this.stub, {
|
|
1875
|
+
op: "set",
|
|
1876
|
+
key: this.key("ceremony", parsed.registrationCeremonyId),
|
|
1877
|
+
value: parsed,
|
|
1878
|
+
ttlMs
|
|
1879
|
+
});
|
|
1880
|
+
if (!response.ok) throw new Error(response.message);
|
|
1881
|
+
}
|
|
1882
|
+
async getCeremony(registrationCeremonyId) {
|
|
1883
|
+
const key = trimString(registrationCeremonyId);
|
|
1884
|
+
if (!key) return null;
|
|
1885
|
+
const response = await callDo(this.stub, {
|
|
1886
|
+
op: "get",
|
|
1887
|
+
key: this.key("ceremony", key)
|
|
1888
|
+
});
|
|
1889
|
+
if (!response.ok) return null;
|
|
1890
|
+
const ceremony = parseStoredWalletRegistrationCeremony(response.value);
|
|
1891
|
+
if (!ceremony || ceremony.expiresAtMs <= Date.now()) return null;
|
|
1892
|
+
return ceremony;
|
|
1893
|
+
}
|
|
1894
|
+
async updateCeremony(ceremony) {
|
|
1895
|
+
const parsed = parseStoredWalletRegistrationCeremony(ceremony);
|
|
1896
|
+
if (!parsed) throw new Error("Invalid registration ceremony record");
|
|
1897
|
+
if (parsed.expiresAtMs <= Date.now()) return;
|
|
1898
|
+
const ttlMs = Math.max(1, parsed.expiresAtMs - Date.now());
|
|
1899
|
+
const response = await callDo(this.stub, {
|
|
1900
|
+
op: "set",
|
|
1901
|
+
key: this.key("ceremony", parsed.registrationCeremonyId),
|
|
1902
|
+
value: parsed,
|
|
1903
|
+
ttlMs
|
|
1904
|
+
});
|
|
1905
|
+
if (!response.ok) throw new Error(response.message);
|
|
1906
|
+
}
|
|
1907
|
+
async takeCeremony(registrationCeremonyId) {
|
|
1908
|
+
const key = trimString(registrationCeremonyId);
|
|
1909
|
+
if (!key) return null;
|
|
1910
|
+
const response = await callDo(this.stub, {
|
|
1911
|
+
op: "getdel",
|
|
1912
|
+
key: this.key("ceremony", key)
|
|
1913
|
+
});
|
|
1914
|
+
if (!response.ok) return null;
|
|
1915
|
+
const ceremony = parseStoredWalletRegistrationCeremony(response.value);
|
|
1916
|
+
if (!ceremony || ceremony.expiresAtMs <= Date.now()) return null;
|
|
1917
|
+
return ceremony;
|
|
1918
|
+
}
|
|
1919
|
+
async cancelTerminalCeremony(input) {
|
|
1920
|
+
const registrationCeremonyId = trimString(input.registrationCeremonyId);
|
|
1921
|
+
const walletId = trimString(input.walletId);
|
|
1922
|
+
if (!registrationCeremonyId || !walletId) throw new Error("Terminal registration cancellation requires ceremony and wallet IDs");
|
|
1923
|
+
const response = await callDo(this.stub, {
|
|
1924
|
+
op: "registrationCancelTerminal",
|
|
1925
|
+
ceremonyKey: this.key("ceremony", registrationCeremonyId),
|
|
1926
|
+
registrationCeremonyId,
|
|
1927
|
+
walletId
|
|
1928
|
+
});
|
|
1929
|
+
if (!response.ok) throw new Error(response.message);
|
|
1930
|
+
const result = parseTerminalRegistrationCeremonyCancellationResult(response.value);
|
|
1931
|
+
if (!result) throw new Error("Terminal registration cancellation returned an invalid result");
|
|
1932
|
+
return result;
|
|
1933
|
+
}
|
|
1934
|
+
async putAddSignerFinalizeReplay(replay) {
|
|
1935
|
+
const parsed = parseStoredWalletAddSignerFinalizeReplay(replay);
|
|
1936
|
+
if (!parsed) throw new Error("Invalid wallet add-signer finalize replay record");
|
|
1937
|
+
const ttlMs = Math.max(1, parsed.expiresAtMs - Date.now());
|
|
1938
|
+
const response = await callDo(this.stub, {
|
|
1939
|
+
op: "set",
|
|
1940
|
+
key: this.key("add-signer-finalize-replay", addSignerFinalizeReplayKey(parsed)),
|
|
1941
|
+
value: parsed,
|
|
1942
|
+
ttlMs
|
|
1943
|
+
});
|
|
1944
|
+
if (!response.ok) throw new Error(response.message);
|
|
1945
|
+
const claimResponse = await callDo(this.stub, {
|
|
1946
|
+
op: "set",
|
|
1947
|
+
key: this.key("add-signer-finalize-claim", parsed.addSignerCeremonyId),
|
|
1948
|
+
value: parsed,
|
|
1949
|
+
ttlMs
|
|
1950
|
+
});
|
|
1951
|
+
if (!claimResponse.ok) throw new Error(claimResponse.message);
|
|
1952
|
+
}
|
|
1953
|
+
async getAddSignerFinalizeReplay(input) {
|
|
1954
|
+
if (!trimString(input.addSignerCeremonyId) || !trimString(input.idempotencyKey)) return null;
|
|
1955
|
+
const response = await callDo(this.stub, {
|
|
1956
|
+
op: "get",
|
|
1957
|
+
key: this.key("add-signer-finalize-replay", addSignerFinalizeReplayKey(input))
|
|
1958
|
+
});
|
|
1959
|
+
if (!response.ok) return null;
|
|
1960
|
+
const replay = parseStoredWalletAddSignerFinalizeReplay(response.value);
|
|
1961
|
+
if (!replay || replay.expiresAtMs <= Date.now()) return null;
|
|
1962
|
+
return replay;
|
|
1963
|
+
}
|
|
1964
|
+
async getAddSignerFinalizeReplayForCeremony(addSignerCeremonyId) {
|
|
1965
|
+
const ceremonyId = trimString(addSignerCeremonyId);
|
|
1966
|
+
if (!ceremonyId) return null;
|
|
1967
|
+
const response = await callDo(this.stub, {
|
|
1968
|
+
op: "get",
|
|
1969
|
+
key: this.key("add-signer-finalize-claim", ceremonyId)
|
|
1970
|
+
});
|
|
1971
|
+
if (!response.ok) return null;
|
|
1972
|
+
const replay = parseStoredWalletAddSignerFinalizeReplay(response.value);
|
|
1973
|
+
if (!replay || replay.expiresAtMs <= Date.now()) return null;
|
|
1974
|
+
return replay;
|
|
1975
|
+
}
|
|
1976
|
+
async putAddAuthMethodCeremony(ceremony) {
|
|
1977
|
+
const parsed = parseStoredWalletAddAuthMethodCeremony(ceremony);
|
|
1978
|
+
if (!parsed) throw new Error("Invalid add-auth-method ceremony record");
|
|
1979
|
+
const ttlMs = Math.max(1, parsed.expiresAtMs - Date.now());
|
|
1980
|
+
const response = await callDo(this.stub, {
|
|
1981
|
+
op: "set",
|
|
1982
|
+
key: this.key("add-auth-method", parsed.addAuthMethodCeremonyId),
|
|
1983
|
+
value: parsed,
|
|
1984
|
+
ttlMs
|
|
1985
|
+
});
|
|
1986
|
+
if (!response.ok) throw new Error(response.message);
|
|
1987
|
+
}
|
|
1988
|
+
async getAddAuthMethodCeremony(addAuthMethodCeremonyId) {
|
|
1989
|
+
const key = trimString(addAuthMethodCeremonyId);
|
|
1990
|
+
if (!key) return null;
|
|
1991
|
+
const response = await callDo(this.stub, {
|
|
1992
|
+
op: "get",
|
|
1993
|
+
key: this.key("add-auth-method", key)
|
|
1994
|
+
});
|
|
1995
|
+
if (!response.ok) return null;
|
|
1996
|
+
const ceremony = parseStoredWalletAddAuthMethodCeremony(response.value);
|
|
1997
|
+
if (!ceremony || ceremony.expiresAtMs <= Date.now()) return null;
|
|
1998
|
+
return ceremony;
|
|
1999
|
+
}
|
|
2000
|
+
async updateAddAuthMethodCeremony(ceremony) {
|
|
2001
|
+
const parsed = parseStoredWalletAddAuthMethodCeremony(ceremony);
|
|
2002
|
+
if (!parsed) throw new Error("Invalid add-auth-method ceremony record");
|
|
2003
|
+
if (parsed.expiresAtMs <= Date.now()) return;
|
|
2004
|
+
const ttlMs = Math.max(1, parsed.expiresAtMs - Date.now());
|
|
2005
|
+
const response = await callDo(this.stub, {
|
|
2006
|
+
op: "set",
|
|
2007
|
+
key: this.key("add-auth-method", parsed.addAuthMethodCeremonyId),
|
|
2008
|
+
value: parsed,
|
|
2009
|
+
ttlMs
|
|
2010
|
+
});
|
|
2011
|
+
if (!response.ok) throw new Error(response.message);
|
|
2012
|
+
}
|
|
2013
|
+
async takeAddAuthMethodCeremony(addAuthMethodCeremonyId) {
|
|
2014
|
+
const key = trimString(addAuthMethodCeremonyId);
|
|
2015
|
+
if (!key) return null;
|
|
2016
|
+
const response = await callDo(this.stub, {
|
|
2017
|
+
op: "getdel",
|
|
2018
|
+
key: this.key("add-auth-method", key)
|
|
2019
|
+
});
|
|
2020
|
+
if (!response.ok) return null;
|
|
2021
|
+
const ceremony = parseStoredWalletAddAuthMethodCeremony(response.value);
|
|
2022
|
+
if (!ceremony || ceremony.expiresAtMs <= Date.now()) return null;
|
|
2023
|
+
return ceremony;
|
|
2024
|
+
}
|
|
2025
|
+
async putAddSignerCeremony(ceremony) {
|
|
2026
|
+
const parsed = parseStoredWalletAddSignerCeremony(ceremony);
|
|
2027
|
+
if (!parsed) throw new Error("Invalid add-signer ceremony record");
|
|
2028
|
+
const ttlMs = Math.max(1, parsed.expiresAtMs - Date.now());
|
|
2029
|
+
const response = await callDo(this.stub, {
|
|
2030
|
+
op: "set",
|
|
2031
|
+
key: this.key("add-signer", parsed.addSignerCeremonyId),
|
|
2032
|
+
value: parsed,
|
|
2033
|
+
ttlMs
|
|
2034
|
+
});
|
|
2035
|
+
if (!response.ok) throw new Error(response.message);
|
|
2036
|
+
}
|
|
2037
|
+
async getAddSignerCeremony(addSignerCeremonyId) {
|
|
2038
|
+
const key = trimString(addSignerCeremonyId);
|
|
2039
|
+
if (!key) return null;
|
|
2040
|
+
const response = await callDo(this.stub, {
|
|
2041
|
+
op: "get",
|
|
2042
|
+
key: this.key("add-signer", key)
|
|
2043
|
+
});
|
|
2044
|
+
if (!response.ok) return null;
|
|
2045
|
+
const ceremony = parseStoredWalletAddSignerCeremony(response.value);
|
|
2046
|
+
if (!ceremony || ceremony.expiresAtMs <= Date.now()) return null;
|
|
2047
|
+
return ceremony;
|
|
2048
|
+
}
|
|
2049
|
+
async updateAddSignerCeremony(ceremony) {
|
|
2050
|
+
const parsed = parseStoredWalletAddSignerCeremony(ceremony);
|
|
2051
|
+
if (!parsed) throw new Error("Invalid add-signer ceremony record");
|
|
2052
|
+
if (parsed.expiresAtMs <= Date.now()) return;
|
|
2053
|
+
const ttlMs = Math.max(1, parsed.expiresAtMs - Date.now());
|
|
2054
|
+
const response = await callDo(this.stub, {
|
|
2055
|
+
op: "set",
|
|
2056
|
+
key: this.key("add-signer", parsed.addSignerCeremonyId),
|
|
2057
|
+
value: parsed,
|
|
2058
|
+
ttlMs
|
|
2059
|
+
});
|
|
2060
|
+
if (!response.ok) throw new Error(response.message);
|
|
2061
|
+
}
|
|
2062
|
+
async takeAddSignerCeremony(addSignerCeremonyId) {
|
|
2063
|
+
const key = trimString(addSignerCeremonyId);
|
|
2064
|
+
if (!key) return null;
|
|
2065
|
+
const response = await callDo(this.stub, {
|
|
2066
|
+
op: "getdel",
|
|
2067
|
+
key: this.key("add-signer", key)
|
|
2068
|
+
});
|
|
2069
|
+
if (!response.ok) return null;
|
|
2070
|
+
const ceremony = parseStoredWalletAddSignerCeremony(response.value);
|
|
2071
|
+
if (!ceremony || ceremony.expiresAtMs <= Date.now()) return null;
|
|
2072
|
+
return ceremony;
|
|
2073
|
+
}
|
|
2074
|
+
};
|
|
2075
|
+
function resolveRegistrationDoPrefix(config) {
|
|
2076
|
+
const base = trimString(config.WALLET_REGISTRATION_PREFIX) || trimString(config.walletRegistrationPrefix) || trimString(config.keyPrefix) || trimString(config.THRESHOLD_PREFIX);
|
|
2077
|
+
if (!base) return "wallet-registration:";
|
|
2078
|
+
return base.endsWith(":") ? `${base}wallet-registration:` : `${base}:wallet-registration:`;
|
|
2079
|
+
}
|
|
2080
|
+
function createRegistrationCeremonyStore(input = {}) {
|
|
2081
|
+
const config = input.config || {};
|
|
2082
|
+
const kind = typeof config.kind === "string" ? config.kind.trim() : "";
|
|
2083
|
+
if (kind === "cloudflare-do") {
|
|
2084
|
+
const namespace = resolveDoNamespaceFromConfig(config);
|
|
2085
|
+
if (!namespace) throw new Error("cloudflare-do registration ceremony store selected but no Durable Object namespace was provided (expected config.namespace)");
|
|
2086
|
+
const objectName = trimString(config.objectName) || trimString(config.name) || "threshold-store";
|
|
2087
|
+
input.logger?.info("[wallet-registration] Using Cloudflare Durable Object store for registration ceremonies");
|
|
2088
|
+
return new CloudflareDurableObjectRegistrationCeremonyStore({
|
|
2089
|
+
namespace,
|
|
2090
|
+
objectName,
|
|
2091
|
+
prefix: resolveRegistrationDoPrefix(config)
|
|
2092
|
+
});
|
|
2093
|
+
}
|
|
2094
|
+
if (kind && kind !== "memory" && kind !== "in-memory") throw new Error(`[wallet-registration] Unknown registration ceremony store kind: ${kind}`);
|
|
2095
|
+
input.logger?.warn?.("[wallet-registration] Using in-memory registration ceremony store; configure Cloudflare Durable Object storage for durable registration ceremonies");
|
|
2096
|
+
return new MemoryRegistrationCeremonyStore();
|
|
2097
|
+
}
|
|
2098
|
+
//#endregion
|
|
2099
|
+
export { MemoryRegistrationCeremonyStore, buildStoredWalletRegistrationEvmFamilyEcdsaFinalizedBranch, buildStoredWalletRegistrationEvmFamilyEcdsaPreparedBranch, buildStoredWalletRegistrationNearEd25519YaoAuthorizedBranch, buildStoredWalletRegistrationPreparedContext, createRegistrationCeremonyStore, findStoredWalletRegistrationEvmFamilyEcdsaBranch, findStoredWalletRegistrationNearEd25519YaoBranch, parseStoredRegistrationSignerPlan, parseStoredWalletRegistrationPreparedContext, parseTerminalRegistrationCeremonyCancellationResult, registrationCeremonyAuthorityRpId, replaceStoredWalletRegistrationSignerBranch, storedRegistrationAuthoritiesMatch, storedRegistrationSignerPlansMatch, storedWalletRegistrationPreparedContextsMatch, verifiedRegistrationCeremonyAuthority };
|
|
2100
|
+
|
|
2101
|
+
//# sourceMappingURL=RegistrationCeremonyStore.js.map
|