@seams/wallet-server 0.7.1 → 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRD_PARTY_NOTICES.md +1 -105
- package/artifact-manifest.json +21 -21
- package/cloudflare-router-ab/build/deriver-a/build-stamp.json +1 -1
- package/cloudflare-router-ab/build/deriver-a/index_bg.wasm +0 -0
- package/cloudflare-router-ab/build/deriver-b/build-stamp.json +1 -1
- package/cloudflare-router-ab/build/deriver-b/index_bg.wasm +0 -0
- package/cloudflare-router-ab/build/local-tools/darwin-arm64/router_ab_local_init +0 -0
- package/cloudflare-router-ab/build/local-tools/darwin-x64/router_ab_local_init +0 -0
- package/cloudflare-router-ab/build/local-tools/linux-x64/router_ab_local_init +0 -0
- package/cloudflare-router-ab/build/router/build-stamp.json +1 -1
- package/cloudflare-router-ab/build/router/index_bg.wasm +0 -0
- package/cloudflare-router-ab/build/signing-worker/build-stamp.json +1 -1
- package/cloudflare-router-ab/build/signing-worker/index_bg.wasm +0 -0
- package/cloudflare-router-ab/build/tenant-root-control-plane/build-stamp.json +1 -1
- package/cloudflare-router-ab/build/tenant-root-control-plane/index_bg.wasm +0 -0
- package/dist/esm/authorization/service.js +8 -0
- package/dist/esm/authorization/vaultProxyUse.js +2 -6
- package/dist/esm/cloud-host.js +4 -4
- package/dist/esm/core/IdentityStore.js +23 -110
- package/dist/esm/core/SessionService.js +7 -30
- package/dist/esm/core/ThresholdService/routerAbNormalSigningPolicy.js +3 -10
- package/dist/esm/core/ThresholdService/stores/WalletSessionStore.js +21 -97
- package/dist/esm/core/ThresholdService/stores/exportReplayGuard.js +7 -0
- package/dist/esm/core/WalletStore.js +4 -6
- package/dist/esm/core/authService/bytes.js +1 -4
- package/dist/esm/core/authService/emailOtpChallengeOperations.js +2 -5
- package/dist/esm/core/authService/emailOtpChallengeProof.js +9 -40
- package/dist/esm/core/authService/emailOtpChallengeVerification.js +19 -90
- package/dist/esm/core/authService/emailOtpChallenges.js +10 -45
- package/dist/esm/core/authService/emailOtpDelivery.js +10 -45
- package/dist/esm/core/authService/emailOtpEnrollment.js +9 -40
- package/dist/esm/core/authService/emailOtpGrant.js +9 -40
- package/dist/esm/core/authService/emailOtpRegistrationEnrollment.js +9 -40
- package/dist/esm/core/authService/emailOtpSeal.js +5 -20
- package/dist/esm/core/authService/emailOtpUnlock.js +20 -110
- package/dist/esm/core/authService/googleEmailOtpRegistration.js +28 -115
- package/dist/esm/core/authService/identity.js +5 -20
- package/dist/esm/core/authService/nearPublicKeyMetadata.js +6 -25
- package/dist/esm/core/authService/oidcVerification.js +22 -34
- package/dist/esm/core/authService/rateLimits.js +2 -5
- package/dist/esm/core/authService/thresholdEcdsaKeyInventory.js +2 -1
- package/dist/esm/core/authService/webauthn.js +37 -191
- package/dist/esm/core/authService/webauthnVerificationOutcomes.js +5 -24
- package/dist/esm/core/d1EcdsaSignerRead.js +76 -0
- package/dist/esm/core/d1IdentityStore.js +16 -75
- package/dist/esm/core/d1TenantStore.js +1 -1
- package/dist/esm/core/d1WalletStore.js +15 -25
- package/dist/esm/core/deviceLinking/linkedDeviceEmailOtpGrant.js +1 -5
- package/dist/esm/core/deviceLinking/linkedDeviceSessionApproval.js +1 -3
- package/dist/esm/core/deviceLinking/linkedDeviceSessionRecord.js +2 -8
- package/dist/esm/core/deviceLinking/requestProof.js +13 -4
- package/dist/esm/core/ecdsaMaterialReadSnapshot.js +85 -0
- package/dist/esm/core/nearRelayerAccountProvisioning.js +2 -5
- package/dist/esm/core/signingLanes/WalletExecutionLaneProjection.js +3 -6
- package/dist/esm/core/signingMaterial/ordinaryInactiveSignerMaterialReservation.js +2 -5
- package/dist/esm/core/storeBackends.js +1 -1
- package/dist/esm/core/thresholdEcdsaChainTarget.js +1 -3
- package/dist/esm/hosted-wallet-gateway.js +2 -2
- package/dist/esm/localHostedWalletGatewayHandler.js +13 -0
- package/dist/esm/localIntendedMaterialAdmissionFault.js +176 -0
- package/dist/esm/localIntendedPresignCancellation.js +44 -0
- package/dist/esm/router/auth/commonRouterUtils.js +24 -10
- package/dist/esm/router/auth/walletSessionFailure.js +2 -5
- package/dist/esm/router/auth/webAuthnCredentialCodecs.js +4 -15
- package/dist/esm/router/cloudflare/d1/auth/d1AuthorizedOperationRouteService.js +1 -0
- package/dist/esm/router/cloudflare/d1/auth/d1RouterApiAuthBoundary.js +2 -6
- package/dist/esm/router/cloudflare/d1/auth/d1RouterApiAuthService.js +5 -27
- package/dist/esm/router/cloudflare/d1/auth/walletSessionCredentialReaders.js +76 -0
- package/dist/esm/router/cloudflare/d1/authorization/authorizedOperationStatements.js +28 -21
- package/dist/esm/router/cloudflare/d1/authorization/d1AuthorizationStore.js +209 -44
- package/dist/esm/router/cloudflare/d1/authorization/d1VaultProxyStore.js +8 -12
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceAuthorityInstallService.js +50 -8
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceTargetCredentialProvider.js +1 -1
- package/dist/esm/router/cloudflare/d1/deviceLinking/index.js +3 -3
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeIssuer.js +12 -55
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeService.js +17 -80
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpDeliveryRuntime.js +6 -25
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpRecords.js +12 -47
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpRecoveryService.js +24 -85
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpRegistrationEnrollmentFinalizer.js +7 -30
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpServerSealRuntime.js +5 -20
- package/dist/esm/router/cloudflare/d1/emailOtp/d1GoogleEmailOtpSessionResolver.js +23 -110
- package/dist/esm/router/cloudflare/d1/identity/d1IdentityService.js +9 -40
- package/dist/esm/router/cloudflare/d1/near/d1NearPublicKeyStore.js +3 -10
- package/dist/esm/router/cloudflare/d1/oidc/d1OidcBoundary.js +18 -91
- package/dist/esm/router/cloudflare/d1/oidc/d1OidcVerificationService.js +6 -30
- package/dist/esm/router/cloudflare/d1/passkeyCustody/d1PasskeyCustodyRouteService.js +4 -15
- package/dist/esm/router/cloudflare/d1/passkeyCustody/d1WalletCustodyCommitStore.js +2 -7
- package/dist/esm/router/cloudflare/d1/passkeyCustody/d1WalletRecoveryGoogleEmailOtpRecords.js +9 -13
- package/dist/esm/router/cloudflare/d1/passkeyCustody/d1WalletRecoveryGoogleEmailOtpService.js +11 -50
- package/dist/esm/router/cloudflare/d1/registration/d1EvmFamilyEcdsaRegistrationBranch.js +5 -20
- package/dist/esm/router/cloudflare/d1/registration/d1RegistrationCeremonyRecordStore.js +4 -7
- package/dist/esm/router/cloudflare/d1/registration/d1RegistrationCeremonyRecords.js +2 -1
- package/dist/esm/router/cloudflare/d1/registration/d1RegistrationIntentService.js +7 -30
- package/dist/esm/router/cloudflare/d1/registration/d1WalletRegistrationService.js +32 -22
- package/dist/esm/router/cloudflare/d1/registration/walletRegistrationSessionCommitReceipt.js +1 -4
- package/dist/esm/router/cloudflare/d1/signingAdmission/d1RouterAbNormalSigningAdmissionStore.js +119 -25
- package/dist/esm/router/cloudflare/d1/webauthn/d1WebAuthnAuthService.js +31 -168
- package/dist/esm/router/cloudflare/d1/webauthn/d1WebAuthnRecords.js +6 -9
- package/dist/esm/router/cloudflare/durableObjects/thresholdStore.js +59 -66
- package/dist/esm/router/cloudflare/runtime/routerAbPrewarm.js +2 -2
- package/dist/esm/router/cloudflare/runtime/staticWalletConsoleBinding.js +5 -20
- package/dist/esm/router/cloudflare/runtime/tenantRootCreationGrant.js +2 -9
- package/dist/esm/router/cloudflare/runtime/walletControlOps.js +2 -1
- package/dist/esm/router/cloudflare/signingLanes/cloudflareLaneCurveExecution.js +2 -1
- package/dist/esm/router/cloudflare/signingLanes/cloudflareLaneProtocolCommitter.js +2 -2
- package/dist/esm/router/cloudflare.js +2146 -1802
- package/dist/esm/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistrationPersistence.js +5 -8
- package/dist/esm/router/domains/ed25519Yao/recovery/routerAbEd25519YaoRecoveryWalletSessionAuthorization.js +3 -6
- package/dist/esm/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistrationIntentAuthorization.js +6 -25
- package/dist/esm/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistrationSideEffectBoundary.js +39 -55
- package/dist/esm/router/domains/emailOtp/emailOtpRouteHandlers.js +15 -62
- package/dist/esm/router/domains/signingOperations/routerAbEcdsaDerivationNormalSigningRoute.js +83 -74
- package/dist/esm/router/domains/signingOperations/routerAbNormalSigningAdmission.js +1 -0
- package/dist/esm/router/domains/signingOperations/routerAbOperationStepUp.js +1 -0
- package/dist/esm/router/domains/signingOperations/walletExecutionAdmission.js +1 -4
- package/dist/esm/router/domains/tenantRoot/tenantRootIdentityResolution.js +7 -13
- package/dist/esm/router/domains/walletUnlock/walletUnlockRouteHandlers.js +41 -200
- package/dist/esm/router/express.js +317 -699
- package/dist/esm/router/framework/http.js +5 -1
- package/dist/esm/router/framework/runtimeSnapshotConsumer.js +8 -35
- package/dist/esm/router/transport/fetch/createFetchRouter.js +3 -6
- package/dist/esm/router/transport/fetch/routes/auth.js +9 -41
- package/dist/esm/router/transport/fetch/routes/deviceLinkingOwnerAuthorization.js +5 -22
- package/dist/esm/router/transport/fetch/routes/nearPublicKeys.js +4 -16
- package/dist/esm/router/transport/fetch/routes/sessions.js +1 -0
- package/dist/esm/router/transport/fetch/routes/syncAccount.js +8 -36
- package/dist/esm/router/transport/fetch/routes/thresholdEcdsa.js +27 -79
- package/dist/esm/router/transport/fetch/routes/walletExecutionLanePreflight.js +4 -1
- package/dist/esm/router/transport/fetch/routes/webauthnAuthenticators.js +4 -16
- package/dist/esm/shared-ts/src/authorization/walletSignerActivationEquality.js +12 -0
- package/dist/esm/shared-ts/src/device-linking/committedSignerPackages.js +2 -5
- package/dist/esm/shared-ts/src/device-linking/delegatedActivationPlan.js +1 -5
- package/dist/esm/shared-ts/src/device-linking/ed25519ExportRoot.js +12 -16
- package/dist/esm/shared-ts/src/device-linking/sourceContribution.js +5 -8
- package/dist/esm/shared-ts/src/passkey-custody/primitives.js +5 -1
- package/dist/esm/shared-ts/src/signing-lanes/ownerContinuity.js +4 -8
- package/dist/esm/shared-ts/src/tenant-root/tenantRootIdentifier.js +12 -0
- package/dist/esm/shared-ts/src/tenant-root/tenantRootIdentity.js +2 -9
- package/dist/esm/shared-ts/src/tenant-root/tenantRootOperationRecord.js +1 -4
- package/dist/esm/shared-ts/src/utils/ecdsaKeyFactsInventory.js +2 -4
- package/dist/esm/shared-ts/src/utils/ecdsaServerTiming.js +0 -1
- package/dist/esm/shared-ts/src/utils/emailOtpDomain.js +3 -1
- package/dist/esm/shared-ts/src/utils/exactKeys.js +17 -0
- package/dist/esm/shared-ts/src/utils/failure.js +20 -0
- package/dist/esm/shared-ts/src/utils/registrationIntent.js +3 -12
- package/dist/esm/shared-ts/src/utils/registrationSignerPlan.js +2 -5
- package/dist/esm/shared-ts/src/utils/routerAbEcdsaDerivation.js +1 -1
- package/dist/esm/shared-ts/src/utils/routerAbEd25519Yao.js +1 -1
- package/dist/esm/shared-ts/src/utils/thresholdEcdsaChainTarget.js +9 -0
- package/dist/esm/shared-ts/src/wallet-recovery/walletRecoveryCommittedProjection.js +1 -4
- package/dist/esm/threshold/session/signingSessionSeal/crypto/cipher.js +10 -32
- package/dist/esm/threshold/session/signingSessionSeal/idempotencyBackends.js +3 -3
- package/dist/esm/threshold/session/signingSessionSeal/idempotencyRecords.js +3 -9
- package/dist/esm/threshold/session/signingSessionSeal/service.js +8 -35
- package/dist/esm/threshold/session/signingSessionSeal/transport/express.js +18 -94
- package/dist/esm/threshold/session/signingSessionSeal/transport/fetch.js +6 -30
- package/dist/esm/threshold/session/signingSessionSeal/transport/shared.js +5 -20
- package/dist/esm/wasm/evm_crypto/pkg/evm_crypto_bg.wasm +0 -0
- package/dist/esm/wasm/near_signer/pkg/wasm_signer_worker_bg.wasm +0 -0
- package/dist/types/shared-ts/src/authorization/delegatedAuthority.d.ts +2 -1
- package/dist/types/shared-ts/src/authorization/walletSessionIssuance.d.ts +9 -2
- package/dist/types/shared-ts/src/authorization/walletSignerActivationEquality.d.ts +4 -0
- package/dist/types/shared-ts/src/device-linking/committedSignerPackages.d.ts +3 -4
- package/dist/types/shared-ts/src/device-linking/contracts.d.ts +5 -63
- package/dist/types/shared-ts/src/device-linking/sourceContribution.d.ts +2 -0
- package/dist/types/shared-ts/src/passkey-custody/custodyEnvelope.d.ts +5 -12
- package/dist/types/shared-ts/src/passkey-custody/primitives.d.ts +9 -0
- package/dist/types/shared-ts/src/signing-lanes/execution.d.ts +11 -1
- package/dist/types/shared-ts/src/signing-lanes/ids.d.ts +1 -10
- package/dist/types/shared-ts/src/signing-lanes/rotation.d.ts +3 -5
- package/dist/types/shared-ts/src/tenant-root/tenantRootIdentifier.d.ts +3 -0
- package/dist/types/shared-ts/src/tenant-root/tenantRootOperationRecord.d.ts +2 -1
- package/dist/types/shared-ts/src/threshold/ecdsaDerivationRoleLocalBootstrap.d.ts +6 -0
- package/dist/types/shared-ts/src/threshold/signingRootScope.d.ts +1 -0
- package/dist/types/shared-ts/src/utils/ecdsaKeyFactsInventory.d.ts +2 -11
- package/dist/types/shared-ts/src/utils/eip1559TxWasmJson.d.ts +16 -0
- package/dist/types/shared-ts/src/utils/emailOtpDomain.d.ts +2 -0
- package/dist/types/shared-ts/src/utils/exactKeys.d.ts +11 -0
- package/dist/types/shared-ts/src/utils/failure.d.ts +12 -0
- package/dist/types/shared-ts/src/utils/jsonRpc.d.ts +3 -4
- package/dist/types/shared-ts/src/utils/nearRpcResults.d.ts +1 -0
- package/dist/types/shared-ts/src/utils/registrationAuthMethodInput.d.ts +3 -8
- package/dist/types/shared-ts/src/utils/registrationSignerPlan.d.ts +7 -19
- package/dist/types/shared-ts/src/utils/routerAbEcdsaDerivation.d.ts +3 -1
- package/dist/types/shared-ts/src/utils/routerAbEd25519Yao.d.ts +1 -0
- package/dist/types/shared-ts/src/utils/routerAbEd25519YaoDigests.d.ts +3 -4
- package/dist/types/shared-ts/src/utils/routerAbNormalSigningIdentity.d.ts +30 -8
- package/dist/types/shared-ts/src/utils/routerApiKeyAuth.d.ts +2 -0
- package/dist/types/shared-ts/src/utils/signingSessionSeal.d.ts +10 -11
- package/dist/types/shared-ts/src/utils/thresholdEcdsaChainTarget.d.ts +25 -0
- package/dist/types/shared-ts/src/utils/variant.d.ts +18 -0
- package/dist/types/shared-ts/src/utils/walletAuthMethodRecord.d.ts +3 -6
- package/dist/types/shared-ts/src/utils/webauthnDeviceInfo.d.ts +4 -2
- package/dist/types/shared-ts/src/wallet-recovery/recoveryEnvelopes.d.ts +3 -16
- package/dist/types/shared-ts/src/wallet-recovery/walletRecoveryPreparation.d.ts +15 -0
- package/dist/types/shared-ts/src/wallet-recovery/walletRecoveryTarget.d.ts +3 -4
- package/dist/types/wallet-server/src/authorization/domain.d.ts +13 -2
- package/dist/types/wallet-server/src/authorization/ecdsaWalletSessionAdmission.d.ts +27 -3
- package/dist/types/wallet-server/src/authorization/service.d.ts +19 -0
- package/dist/types/wallet-server/src/core/ThresholdService/stores/SessionStore.d.ts +2 -2
- package/dist/types/wallet-server/src/core/ThresholdService/stores/WalletSessionStore.d.ts +1 -1
- package/dist/types/wallet-server/src/core/ThresholdService/stores/exportReplayGuard.d.ts +3 -0
- package/dist/types/wallet-server/src/core/ThresholdService/validation.d.ts +8 -101
- package/dist/types/wallet-server/src/core/WebAuthnAuthenticatorStore.d.ts +8 -0
- package/dist/types/wallet-server/src/core/authService/bytes.d.ts +0 -1
- package/dist/types/wallet-server/src/core/authService/emailOtpChallenges.d.ts +2 -10
- package/dist/types/wallet-server/src/core/authService/emailOtpSeal.d.ts +1 -1
- package/dist/types/wallet-server/src/core/authService/emailOtpUnlock.d.ts +3 -10
- package/dist/types/wallet-server/src/core/d1EcdsaSignerRead.d.ts +39 -0
- package/dist/types/wallet-server/src/core/d1WalletStore.d.ts +10 -0
- package/dist/types/wallet-server/src/core/deviceLinking/linkedDeviceSessionRecord.d.ts +3 -4
- package/dist/types/wallet-server/src/core/ecdsaMaterialReadSnapshot.d.ts +19 -0
- package/dist/types/wallet-server/src/core/routerAbSigning/RouterAbNormalSigningRuntime.d.ts +3 -5
- package/dist/types/wallet-server/src/core/rpcClients/near/NearClient.d.ts +1 -2
- package/dist/types/wallet-server/src/core/signingLanes/WalletExecutionLaneProjection.d.ts +2 -11
- package/dist/types/wallet-server/src/core/signingLanes/signingWorkerLaneMaterialIdentity.d.ts +2 -19
- package/dist/types/wallet-server/src/core/thresholdEcdsaChainTarget.d.ts +3 -11
- package/dist/types/wallet-server/src/core/types.d.ts +2 -6
- package/dist/types/wallet-server/src/localIntendedMaterialAdmissionFault.d.ts +38 -0
- package/dist/types/wallet-server/src/localIntendedPresignCancellation.d.ts +4 -0
- package/dist/types/wallet-server/src/router/auth/authRequestValidation.d.ts +4 -9
- package/dist/types/wallet-server/src/router/auth/commonRouterUtils.d.ts +15 -1
- package/dist/types/wallet-server/src/router/cloudflare/d1/auth/d1RouterApiAuthBoundary.d.ts +0 -1
- package/dist/types/wallet-server/src/router/cloudflare/d1/auth/d1RouterApiAuthService.d.ts +1 -1
- package/dist/types/wallet-server/src/router/cloudflare/d1/auth/walletSessionCredentialReaders.d.ts +9 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/authorization/authorizedOperationStatements.d.ts +4 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/authorization/d1AuthorizationStore.d.ts +10 -1
- package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceAuthorityInstallService.d.ts +19 -2
- package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceSessionStore.d.ts +2 -6
- package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceTargetCredentialProvider.d.ts +5 -8
- package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpEnrollmentStore.d.ts +2 -8
- package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpRateLimitStore.d.ts +2 -9
- package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpRecords.d.ts +5 -5
- package/dist/types/wallet-server/src/router/cloudflare/d1/emailOtp/d1EmailOtpServerSealRuntime.d.ts +4 -14
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1RegistrationCeremonyRecordStore.d.ts +2 -6
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1WalletRegistrationService.d.ts +8 -6
- package/dist/types/wallet-server/src/router/cloudflare/d1/signingAdmission/d1RouterAbNormalSigningAdmissionStore.d.ts +14 -1
- package/dist/types/wallet-server/src/router/cloudflare/d1/webauthn/d1WebAuthnRecords.d.ts +10 -39
- package/dist/types/wallet-server/src/router/cloudflare/runtime/walletConsoleOps.d.ts +8 -34
- package/dist/types/wallet-server/src/router/domains/ecdsa/thresholdEcdsaRequestValidation.d.ts +3 -15
- package/dist/types/wallet-server/src/router/domains/ed25519Yao/session/routerAbEd25519YaoWalletSession.d.ts +9 -50
- package/dist/types/wallet-server/src/router/domains/passkeyCustody/walletRecoveryKeyManifest.d.ts +1 -13
- package/dist/types/wallet-server/src/router/domains/signingOperations/routerAbEcdsaDerivationNormalSigningRoute.d.ts +8 -9
- package/dist/types/wallet-server/src/router/domains/signingOperations/routerAbNormalSigningAdmission.d.ts +13 -0
- package/dist/types/wallet-server/src/router/domains/signingOperations/routerAbOperationStepUp.d.ts +3 -4
- package/dist/types/wallet-server/src/router/domains/signingOperations/routerAbPrivateSigningWorker.d.ts +7 -16
- package/dist/types/wallet-server/src/router/domains/syncAccount/syncAccountRequestValidation.d.ts +2 -7
- package/dist/types/wallet-server/src/router/framework/apiCredentialPorts.d.ts +3 -1
- package/dist/types/wallet-server/src/router/framework/authServicePort.d.ts +25 -4
- package/dist/types/wallet-server/src/router/framework/http.d.ts +1 -0
- package/dist/types/wallet-server/src/router/framework/ror/normalize.d.ts +1 -9
- package/dist/types/wallet-server/src/router/transport/fetch/routes/deviceLinkingOwnerAuthorization.d.ts +3 -6
- package/dist/types/wallet-server/src/router/transport/fetch/routes/syncAccountBootstrap.d.ts +3 -5
- package/dist/types/wallet-server/src/router/transport/fetch/routes/thresholdEcdsa.d.ts +0 -1
- package/dist/types/wallet-server/src/threshold/session/signingSessionSeal/idempotencyRecords.d.ts +1 -2
- package/dist/types/wallet-server/src/threshold/session/signingSessionSeal/signingSessionSeal.types.d.ts +6 -8
- package/package.json +1 -1
- package/dist/esm/wasm/router_ab_ecdsa_signing_worker/pkg/router_ab_ecdsa_signing_worker_bg.wasm +0 -0
|
@@ -2,7 +2,7 @@ import { normalizeOptionalTrimmedString } from "../../../shared-ts/src/utils/nor
|
|
|
2
2
|
import "../../../shared-ts/src/utils/validation.js";
|
|
3
3
|
import { RedisTcpClient, UpstashRedisRestClient, redisDel, redisGetJson, redisSetJson } from "../../../core/ThresholdService/kv.js";
|
|
4
4
|
import { createInMemorySigningSessionSealIdempotencyStore } from "./idempotency.js";
|
|
5
|
-
import {
|
|
5
|
+
import { parseCurrentSigningSessionSealIdempotencyResultRecord, parseCurrentSigningSessionSealIdempotencyStoredEntry } from "./idempotencyRecords.js";
|
|
6
6
|
//#region src/threshold/session/signingSessionSeal/idempotencyBackends.ts
|
|
7
7
|
const DEFAULT_KEY_PREFIX = "threshold:signing-session-seal:idempotency:";
|
|
8
8
|
function toPositiveInt(value) {
|
|
@@ -46,7 +46,7 @@ var UpstashSigningSessionSealIdempotencyStore = class {
|
|
|
46
46
|
if (!key) return;
|
|
47
47
|
const expiresAtMs = toPositiveInt(input.expiresAtMs);
|
|
48
48
|
if (expiresAtMs === void 0) return;
|
|
49
|
-
const normalizedResult =
|
|
49
|
+
const normalizedResult = parseCurrentSigningSessionSealIdempotencyResultRecord(input.result);
|
|
50
50
|
if (!normalizedResult) return;
|
|
51
51
|
const ttlMs = ttlMsUntilExpiry(expiresAtMs, this.nowMs());
|
|
52
52
|
if (ttlMs <= 0) return;
|
|
@@ -80,7 +80,7 @@ var RedisTcpSigningSessionSealIdempotencyStore = class {
|
|
|
80
80
|
if (!key) return;
|
|
81
81
|
const expiresAtMs = toPositiveInt(input.expiresAtMs);
|
|
82
82
|
if (expiresAtMs === void 0) return;
|
|
83
|
-
const normalizedResult =
|
|
83
|
+
const normalizedResult = parseCurrentSigningSessionSealIdempotencyResultRecord(input.result);
|
|
84
84
|
if (!normalizedResult) return;
|
|
85
85
|
const ttlMs = ttlMsUntilExpiry(expiresAtMs, this.nowMs());
|
|
86
86
|
if (ttlMs <= 0) return;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { normalizeOptionalTrimmedString } from "../../../shared-ts/src/utils/normalize.js";
|
|
2
2
|
import "../../../shared-ts/src/utils/validation.js";
|
|
3
|
+
import { failure } from "../../../shared-ts/src/utils/failure.js";
|
|
3
4
|
//#region src/threshold/session/signingSessionSeal/idempotencyRecords.ts
|
|
4
5
|
function toPositiveInt(value) {
|
|
5
6
|
const parsed = Number(value);
|
|
@@ -26,11 +27,7 @@ function parseCurrentSigningSessionSealIdempotencyResultRecord(raw) {
|
|
|
26
27
|
const code = normalizeOptionalTrimmedString(obj.code);
|
|
27
28
|
const message = normalizeOptionalTrimmedString(obj.message);
|
|
28
29
|
if (!code || !message) return null;
|
|
29
|
-
return
|
|
30
|
-
ok: false,
|
|
31
|
-
code,
|
|
32
|
-
message
|
|
33
|
-
};
|
|
30
|
+
return failure(code, message);
|
|
34
31
|
}
|
|
35
32
|
return null;
|
|
36
33
|
}
|
|
@@ -45,10 +42,7 @@ function parseCurrentSigningSessionSealIdempotencyStoredEntry(raw) {
|
|
|
45
42
|
expiresAtMs
|
|
46
43
|
};
|
|
47
44
|
}
|
|
48
|
-
function parseCurrentSigningSessionSealIdempotencyRouteResult(raw) {
|
|
49
|
-
return parseCurrentSigningSessionSealIdempotencyResultRecord(raw);
|
|
50
|
-
}
|
|
51
45
|
//#endregion
|
|
52
|
-
export {
|
|
46
|
+
export { parseCurrentSigningSessionSealIdempotencyResultRecord, parseCurrentSigningSessionSealIdempotencyStoredEntry };
|
|
53
47
|
|
|
54
48
|
//# sourceMappingURL=idempotencyRecords.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { base64UrlEncode } from "../../../shared-ts/src/utils/base64.js";
|
|
2
2
|
import { sha256BytesUtf8 } from "../../../shared-ts/src/utils/digests.js";
|
|
3
3
|
import "../../../shared-ts/src/utils/encoders.js";
|
|
4
|
+
import { failure } from "../../../shared-ts/src/utils/failure.js";
|
|
4
5
|
//#region src/threshold/session/signingSessionSeal/service.ts
|
|
5
6
|
const SIGNING_SESSION_SEAL_LOG_LABEL = "[threshold-signing-session-seal]";
|
|
6
7
|
const SIGNING_SESSION_SEAL_IDEMPOTENCY_TTL_MS_DEFAULT = 9e4;
|
|
@@ -120,11 +121,7 @@ function shouldPersistIdempotentResult(result) {
|
|
|
120
121
|
async function runSealOperation(input) {
|
|
121
122
|
const nowMs = input.options.nowMs || Date.now;
|
|
122
123
|
const startedAtMs = nowMs();
|
|
123
|
-
let result =
|
|
124
|
-
ok: false,
|
|
125
|
-
code: "internal",
|
|
126
|
-
message: "Internal error"
|
|
127
|
-
};
|
|
124
|
+
let result = failure("internal", "Internal error");
|
|
128
125
|
try {
|
|
129
126
|
emitOperationRequestLog({
|
|
130
127
|
options: input.options,
|
|
@@ -136,27 +133,15 @@ async function runSealOperation(input) {
|
|
|
136
133
|
});
|
|
137
134
|
const session = input.auth.session;
|
|
138
135
|
if (signingSessionSealAuthorizationId(session) !== input.request.thresholdSessionId) {
|
|
139
|
-
result =
|
|
140
|
-
ok: false,
|
|
141
|
-
code: "forbidden",
|
|
142
|
-
message: "Wallet Session does not match requested thresholdSessionId"
|
|
143
|
-
};
|
|
136
|
+
result = failure("forbidden", "Wallet Session does not match requested thresholdSessionId");
|
|
144
137
|
return result;
|
|
145
138
|
}
|
|
146
139
|
if (session.userId !== input.auth.userId) {
|
|
147
|
-
result =
|
|
148
|
-
ok: false,
|
|
149
|
-
code: "forbidden",
|
|
150
|
-
message: "thresholdSessionId does not belong to authenticated user"
|
|
151
|
-
};
|
|
140
|
+
result = failure("forbidden", "thresholdSessionId does not belong to authenticated user");
|
|
152
141
|
return result;
|
|
153
142
|
}
|
|
154
143
|
if (isExpired(session, nowMs())) {
|
|
155
|
-
result =
|
|
156
|
-
ok: false,
|
|
157
|
-
code: "expired",
|
|
158
|
-
message: "threshold session expired"
|
|
159
|
-
};
|
|
144
|
+
result = failure("expired", "threshold session expired");
|
|
160
145
|
return result;
|
|
161
146
|
}
|
|
162
147
|
if (input.options.guard) {
|
|
@@ -166,11 +151,7 @@ async function runSealOperation(input) {
|
|
|
166
151
|
auth: input.auth
|
|
167
152
|
});
|
|
168
153
|
if (!guard.ok) {
|
|
169
|
-
result =
|
|
170
|
-
ok: false,
|
|
171
|
-
code: toCode(guard.code, "forbidden"),
|
|
172
|
-
message: toMessage(guard.message, "Request rejected")
|
|
173
|
-
};
|
|
154
|
+
result = failure(toCode(guard.code, "forbidden"), toMessage(guard.message, "Request rejected"));
|
|
174
155
|
return result;
|
|
175
156
|
}
|
|
176
157
|
}
|
|
@@ -183,11 +164,7 @@ async function runSealOperation(input) {
|
|
|
183
164
|
auth: { userId: input.auth.userId }
|
|
184
165
|
});
|
|
185
166
|
if (!sealed.ok) {
|
|
186
|
-
result =
|
|
187
|
-
ok: false,
|
|
188
|
-
code: toCode(sealed.code, "internal"),
|
|
189
|
-
message: toMessage(sealed.message, "Signing-session seal operation failed")
|
|
190
|
-
};
|
|
167
|
+
result = failure(toCode(sealed.code, "internal"), toMessage(sealed.message, "Signing-session seal operation failed"));
|
|
191
168
|
return result;
|
|
192
169
|
}
|
|
193
170
|
result = {
|
|
@@ -198,11 +175,7 @@ async function runSealOperation(input) {
|
|
|
198
175
|
};
|
|
199
176
|
return result;
|
|
200
177
|
} catch (error) {
|
|
201
|
-
result =
|
|
202
|
-
ok: false,
|
|
203
|
-
code: "internal",
|
|
204
|
-
message: toMessage(error instanceof Error ? error.message : error, "Internal error")
|
|
205
|
-
};
|
|
178
|
+
result = failure("internal", toMessage(error instanceof Error ? error.message : error, "Internal error"));
|
|
206
179
|
return result;
|
|
207
180
|
} finally {
|
|
208
181
|
const durationMs = Math.max(0, nowMs() - startedAtMs);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { failure } from "../../../../shared-ts/src/utils/failure.js";
|
|
1
2
|
import { authorizeSigningSessionSealRequest, buildSigningSessionSealApplyPath, buildSigningSessionSealRemovePath, parseSigningSessionSealApplyBody, parseSigningSessionSealRemoveBody, resolveSigningSessionSealBasePath, signingSessionSealAuthorizeStatusCode, signingSessionSealStatusCode } from "./shared.js";
|
|
2
3
|
//#region src/threshold/session/signingSessionSeal/transport/express.ts
|
|
3
4
|
function errMessage(error) {
|
|
@@ -10,94 +11,23 @@ function registerSigningSessionSealRoutes(router, ctx) {
|
|
|
10
11
|
const basePath = resolveSigningSessionSealBasePath(options.basePath);
|
|
11
12
|
const applyPath = buildSigningSessionSealApplyPath(basePath);
|
|
12
13
|
const removePath = buildSigningSessionSealRemovePath(basePath);
|
|
13
|
-
|
|
14
|
+
const handleSealRoute = (route, operation) => async (req, res) => {
|
|
14
15
|
const startedAtMs = Date.now();
|
|
15
16
|
try {
|
|
16
17
|
ctx.logger.info("[threshold-signing-session-seal] request", {
|
|
17
|
-
route
|
|
18
|
-
operation
|
|
18
|
+
route,
|
|
19
|
+
operation
|
|
19
20
|
});
|
|
20
|
-
const parsed = parseSigningSessionSealApplyBody(req.body || {});
|
|
21
|
+
const parsed = operation === "apply-server-seal" ? parseSigningSessionSealApplyBody(req.body || {}) : parseSigningSessionSealRemoveBody(req.body || {});
|
|
21
22
|
if (!parsed.ok) {
|
|
22
23
|
ctx.logger.warn("[threshold-signing-session-seal] invalid_body", {
|
|
23
|
-
route
|
|
24
|
-
operation
|
|
24
|
+
route,
|
|
25
|
+
operation,
|
|
25
26
|
code: parsed.code,
|
|
26
27
|
message: parsed.message,
|
|
27
28
|
durationMs: Math.max(0, Date.now() - startedAtMs)
|
|
28
29
|
});
|
|
29
|
-
res.status(400).json(
|
|
30
|
-
ok: false,
|
|
31
|
-
code: parsed.code,
|
|
32
|
-
message: parsed.message
|
|
33
|
-
});
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
const authorized = await authorizeSigningSessionSealRequest({
|
|
37
|
-
options,
|
|
38
|
-
headers: req.headers || {},
|
|
39
|
-
thresholdSessionId: parsed.value.thresholdSessionId
|
|
40
|
-
});
|
|
41
|
-
if (!authorized.ok) {
|
|
42
|
-
ctx.logger.warn("[threshold-signing-session-seal] unauthorized", {
|
|
43
|
-
route: applyPath,
|
|
44
|
-
operation: "apply-server-seal",
|
|
45
|
-
code: authorized.code || "unauthorized",
|
|
46
|
-
message: authorized.message || "Unauthorized",
|
|
47
|
-
durationMs: Math.max(0, Date.now() - startedAtMs)
|
|
48
|
-
});
|
|
49
|
-
res.status(signingSessionSealAuthorizeStatusCode(authorized)).json({
|
|
50
|
-
ok: false,
|
|
51
|
-
code: authorized.code || "unauthorized",
|
|
52
|
-
message: authorized.message || "Unauthorized"
|
|
53
|
-
});
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
const result = await options.service.applyServerSeal(parsed.value, authorized.auth);
|
|
57
|
-
const status = signingSessionSealStatusCode(result);
|
|
58
|
-
res.status(status).json(result);
|
|
59
|
-
ctx.logger.info("[threshold-signing-session-seal] response", {
|
|
60
|
-
route: applyPath,
|
|
61
|
-
status,
|
|
62
|
-
ok: result.ok,
|
|
63
|
-
durationMs: Math.max(0, Date.now() - startedAtMs),
|
|
64
|
-
userId: authorized.auth.userId
|
|
65
|
-
});
|
|
66
|
-
} catch (error) {
|
|
67
|
-
const message = errMessage(error);
|
|
68
|
-
ctx.logger.error("[threshold-signing-session-seal] error", {
|
|
69
|
-
route: applyPath,
|
|
70
|
-
message,
|
|
71
|
-
durationMs: Math.max(0, Date.now() - startedAtMs)
|
|
72
|
-
});
|
|
73
|
-
res.status(500).json({
|
|
74
|
-
ok: false,
|
|
75
|
-
code: "internal",
|
|
76
|
-
message
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
router.post(removePath, async (req, res) => {
|
|
81
|
-
const startedAtMs = Date.now();
|
|
82
|
-
try {
|
|
83
|
-
ctx.logger.info("[threshold-signing-session-seal] request", {
|
|
84
|
-
route: removePath,
|
|
85
|
-
operation: "remove-server-seal"
|
|
86
|
-
});
|
|
87
|
-
const parsed = parseSigningSessionSealRemoveBody(req.body || {});
|
|
88
|
-
if (!parsed.ok) {
|
|
89
|
-
ctx.logger.warn("[threshold-signing-session-seal] invalid_body", {
|
|
90
|
-
route: removePath,
|
|
91
|
-
operation: "remove-server-seal",
|
|
92
|
-
code: parsed.code,
|
|
93
|
-
message: parsed.message,
|
|
94
|
-
durationMs: Math.max(0, Date.now() - startedAtMs)
|
|
95
|
-
});
|
|
96
|
-
res.status(400).json({
|
|
97
|
-
ok: false,
|
|
98
|
-
code: parsed.code,
|
|
99
|
-
message: parsed.message
|
|
100
|
-
});
|
|
30
|
+
res.status(400).json(failure(parsed.code, parsed.message));
|
|
101
31
|
return;
|
|
102
32
|
}
|
|
103
33
|
const authorized = await authorizeSigningSessionSealRequest({
|
|
@@ -107,24 +37,20 @@ function registerSigningSessionSealRoutes(router, ctx) {
|
|
|
107
37
|
});
|
|
108
38
|
if (!authorized.ok) {
|
|
109
39
|
ctx.logger.warn("[threshold-signing-session-seal] unauthorized", {
|
|
110
|
-
route
|
|
111
|
-
operation
|
|
40
|
+
route,
|
|
41
|
+
operation,
|
|
112
42
|
code: authorized.code || "unauthorized",
|
|
113
43
|
message: authorized.message || "Unauthorized",
|
|
114
44
|
durationMs: Math.max(0, Date.now() - startedAtMs)
|
|
115
45
|
});
|
|
116
|
-
res.status(signingSessionSealAuthorizeStatusCode(authorized)).json(
|
|
117
|
-
ok: false,
|
|
118
|
-
code: authorized.code || "unauthorized",
|
|
119
|
-
message: authorized.message || "Unauthorized"
|
|
120
|
-
});
|
|
46
|
+
res.status(signingSessionSealAuthorizeStatusCode(authorized)).json(failure(authorized.code || "unauthorized", authorized.message || "Unauthorized"));
|
|
121
47
|
return;
|
|
122
48
|
}
|
|
123
|
-
const result = await options.service.removeServerSeal(parsed.value, authorized.auth);
|
|
49
|
+
const result = operation === "apply-server-seal" ? await options.service.applyServerSeal(parsed.value, authorized.auth) : await options.service.removeServerSeal(parsed.value, authorized.auth);
|
|
124
50
|
const status = signingSessionSealStatusCode(result);
|
|
125
51
|
res.status(status).json(result);
|
|
126
52
|
ctx.logger.info("[threshold-signing-session-seal] response", {
|
|
127
|
-
route
|
|
53
|
+
route,
|
|
128
54
|
status,
|
|
129
55
|
ok: result.ok,
|
|
130
56
|
durationMs: Math.max(0, Date.now() - startedAtMs),
|
|
@@ -133,17 +59,15 @@ function registerSigningSessionSealRoutes(router, ctx) {
|
|
|
133
59
|
} catch (error) {
|
|
134
60
|
const message = errMessage(error);
|
|
135
61
|
ctx.logger.error("[threshold-signing-session-seal] error", {
|
|
136
|
-
route
|
|
62
|
+
route,
|
|
137
63
|
message,
|
|
138
64
|
durationMs: Math.max(0, Date.now() - startedAtMs)
|
|
139
65
|
});
|
|
140
|
-
res.status(500).json(
|
|
141
|
-
ok: false,
|
|
142
|
-
code: "internal",
|
|
143
|
-
message
|
|
144
|
-
});
|
|
66
|
+
res.status(500).json(failure("internal", message));
|
|
145
67
|
}
|
|
146
|
-
}
|
|
68
|
+
};
|
|
69
|
+
router.post(applyPath, handleSealRoute(applyPath, "apply-server-seal"));
|
|
70
|
+
router.post(removePath, handleSealRoute(removePath, "remove-server-seal"));
|
|
147
71
|
}
|
|
148
72
|
//#endregion
|
|
149
73
|
export { registerSigningSessionSealRoutes };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { failure } from "../../../../shared-ts/src/utils/failure.js";
|
|
1
2
|
import { authorizeSigningSessionSealRequest, buildSigningSessionSealApplyPath, buildSigningSessionSealRemovePath, parseSigningSessionSealApplyBody, parseSigningSessionSealRemoveBody, resolveSigningSessionSealBasePath, signingSessionSealAuthorizeStatusCode, signingSessionSealStatusCode } from "./shared.js";
|
|
3
|
+
import { headersToRecord, readJson } from "../../../../router/framework/http.js";
|
|
2
4
|
//#region src/threshold/session/signingSessionSeal/transport/fetch.ts
|
|
3
5
|
function json(body, status = 200) {
|
|
4
6
|
return new Response(JSON.stringify(body), {
|
|
@@ -6,20 +8,6 @@ function json(body, status = 200) {
|
|
|
6
8
|
headers: { "Content-Type": "application/json; charset=utf-8" }
|
|
7
9
|
});
|
|
8
10
|
}
|
|
9
|
-
async function readJsonSafe(request) {
|
|
10
|
-
try {
|
|
11
|
-
return await request.json();
|
|
12
|
-
} catch {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
function headersToRecord(headers) {
|
|
17
|
-
const out = {};
|
|
18
|
-
headers.forEach((value, key) => {
|
|
19
|
-
out[key] = value;
|
|
20
|
-
});
|
|
21
|
-
return out;
|
|
22
|
-
}
|
|
23
11
|
function errMessage(error) {
|
|
24
12
|
return error instanceof Error ? error.message : String(error || "Internal error");
|
|
25
13
|
}
|
|
@@ -39,7 +27,7 @@ async function handleSigningSessionSealRoutes(ctx) {
|
|
|
39
27
|
route: isApply ? applyPath : removePath,
|
|
40
28
|
operation
|
|
41
29
|
});
|
|
42
|
-
const body = await
|
|
30
|
+
const body = await readJson(ctx.request);
|
|
43
31
|
const parsed = isApply ? parseSigningSessionSealApplyBody(body) : parseSigningSessionSealRemoveBody(body);
|
|
44
32
|
if (!parsed.ok) {
|
|
45
33
|
ctx.logger.warn("[threshold-signing-session-seal] invalid_body", {
|
|
@@ -49,11 +37,7 @@ async function handleSigningSessionSealRoutes(ctx) {
|
|
|
49
37
|
message: parsed.message,
|
|
50
38
|
durationMs: Math.max(0, Date.now() - startedAtMs)
|
|
51
39
|
});
|
|
52
|
-
return json(
|
|
53
|
-
ok: false,
|
|
54
|
-
code: parsed.code,
|
|
55
|
-
message: parsed.message
|
|
56
|
-
}, 400);
|
|
40
|
+
return json(failure(parsed.code, parsed.message), 400);
|
|
57
41
|
}
|
|
58
42
|
const authorized = await authorizeSigningSessionSealRequest({
|
|
59
43
|
options,
|
|
@@ -69,11 +53,7 @@ async function handleSigningSessionSealRoutes(ctx) {
|
|
|
69
53
|
message: authorized.message || "Unauthorized",
|
|
70
54
|
durationMs: Math.max(0, Date.now() - startedAtMs)
|
|
71
55
|
});
|
|
72
|
-
return json(
|
|
73
|
-
ok: false,
|
|
74
|
-
code: authorized.code || "unauthorized",
|
|
75
|
-
message: authorized.message || "Unauthorized"
|
|
76
|
-
}, signingSessionSealAuthorizeStatusCode(authorized));
|
|
56
|
+
return json(failure(authorized.code || "unauthorized", authorized.message || "Unauthorized"), signingSessionSealAuthorizeStatusCode(authorized));
|
|
77
57
|
}
|
|
78
58
|
const result = isApply ? await options.service.applyServerSeal(parsed.value, authorized.auth) : await options.service.removeServerSeal(parsed.value, authorized.auth);
|
|
79
59
|
const status = signingSessionSealStatusCode(result);
|
|
@@ -93,11 +73,7 @@ async function handleSigningSessionSealRoutes(ctx) {
|
|
|
93
73
|
message,
|
|
94
74
|
durationMs: Math.max(0, Date.now() - startedAtMs)
|
|
95
75
|
});
|
|
96
|
-
return json(
|
|
97
|
-
ok: false,
|
|
98
|
-
code: "internal",
|
|
99
|
-
message
|
|
100
|
-
}, 500);
|
|
76
|
+
return json(failure("internal", message), 500);
|
|
101
77
|
}
|
|
102
78
|
}
|
|
103
79
|
//#endregion
|
|
@@ -2,6 +2,7 @@ import { parseThresholdSessionId } from "../../../../shared-ts/src/utils/domainI
|
|
|
2
2
|
import { ensureLeadingSlash } from "../../../../shared-ts/src/utils/normalize.js";
|
|
3
3
|
import { asRecord } from "../../../../shared-ts/src/utils/validation.js";
|
|
4
4
|
import { WALLET_SESSION_SEAL_BASE_PATH } from "../../../../shared-ts/src/utils/signingSessionSeal.js";
|
|
5
|
+
import { failure } from "../../../../shared-ts/src/utils/failure.js";
|
|
5
6
|
//#region src/threshold/session/signingSessionSeal/transport/shared.ts
|
|
6
7
|
const DEFAULT_BASE_PATH = WALLET_SESSION_SEAL_BASE_PATH;
|
|
7
8
|
function readRequiredString(obj, key) {
|
|
@@ -24,24 +25,12 @@ function buildSigningSessionSealRemovePath(basePath) {
|
|
|
24
25
|
}
|
|
25
26
|
function parseSigningSessionSealApplyBody(body) {
|
|
26
27
|
const obj = asRecord(body);
|
|
27
|
-
if (!obj) return
|
|
28
|
-
ok: false,
|
|
29
|
-
code: "invalid_body",
|
|
30
|
-
message: "Request body must be a JSON object"
|
|
31
|
-
};
|
|
28
|
+
if (!obj) return failure("invalid_body", "Request body must be a JSON object");
|
|
32
29
|
const thresholdSessionId = readRequiredString(obj, "thresholdSessionId");
|
|
33
30
|
const ciphertext = readRequiredString(obj, "ciphertext");
|
|
34
|
-
if (!thresholdSessionId || !ciphertext) return
|
|
35
|
-
ok: false,
|
|
36
|
-
code: "invalid_body",
|
|
37
|
-
message: "thresholdSessionId and ciphertext are required"
|
|
38
|
-
};
|
|
31
|
+
if (!thresholdSessionId || !ciphertext) return failure("invalid_body", "thresholdSessionId and ciphertext are required");
|
|
39
32
|
const parsedThresholdSessionId = parseThresholdSessionId(thresholdSessionId);
|
|
40
|
-
if (!parsedThresholdSessionId.ok) return
|
|
41
|
-
ok: false,
|
|
42
|
-
code: "invalid_body",
|
|
43
|
-
message: "thresholdSessionId is invalid"
|
|
44
|
-
};
|
|
33
|
+
if (!parsedThresholdSessionId.ok) return failure("invalid_body", "thresholdSessionId is invalid");
|
|
45
34
|
return {
|
|
46
35
|
ok: true,
|
|
47
36
|
value: {
|
|
@@ -64,11 +53,7 @@ async function authorizeSigningSessionSealRequest(args) {
|
|
|
64
53
|
thresholdSessionId: args.thresholdSessionId
|
|
65
54
|
});
|
|
66
55
|
} catch (error) {
|
|
67
|
-
return
|
|
68
|
-
ok: false,
|
|
69
|
-
code: "internal",
|
|
70
|
-
message: error instanceof Error ? error.message : String(error || "Authorization failed")
|
|
71
|
-
};
|
|
56
|
+
return failure("internal", error instanceof Error ? error.message : String(error || "Authorization failed"));
|
|
72
57
|
}
|
|
73
58
|
return {
|
|
74
59
|
ok: false,
|
|
Binary file
|
|
Binary file
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AuthorizationParseResult } from './capabilityKinds';
|
|
2
|
-
export type DelegatedWalletPermissionV1 =
|
|
2
|
+
export type DelegatedWalletPermissionV1 = (typeof DELEGATED_WALLET_PERMISSION_VALUES)[number];
|
|
3
|
+
declare const DELEGATED_WALLET_PERMISSION_VALUES: readonly ["export_keys", "link_devices", "revoke_devices", "sign"];
|
|
3
4
|
type CanonicalPermissionTuple = readonly [
|
|
4
5
|
DelegatedWalletPermissionV1,
|
|
5
6
|
...DelegatedWalletPermissionV1[]
|
|
@@ -16,14 +16,21 @@ export type WalletSessionCommittedIdentityV1 = {
|
|
|
16
16
|
readonly quotaId: MpcWalletSigningQuotaId;
|
|
17
17
|
};
|
|
18
18
|
/** The credential-free retry signal shared by issuer response boundaries. */
|
|
19
|
-
type WalletSessionAlreadyCommittedResponseV1 = {
|
|
19
|
+
export type WalletSessionAlreadyCommittedResponseV1 = {
|
|
20
20
|
readonly ok: false;
|
|
21
21
|
readonly code: 'already_committed';
|
|
22
22
|
readonly message: string;
|
|
23
23
|
readonly next: 'unlock_exact_method';
|
|
24
24
|
readonly committed: WalletSessionCommittedIdentityV1;
|
|
25
25
|
};
|
|
26
|
+
/** An issuer rejection that carries no committed identity to retry against. */
|
|
27
|
+
export type WalletSessionRejectionV1 = {
|
|
28
|
+
readonly ok: false;
|
|
29
|
+
readonly code: string;
|
|
30
|
+
readonly message: string;
|
|
31
|
+
readonly next?: never;
|
|
32
|
+
readonly committed?: never;
|
|
33
|
+
};
|
|
26
34
|
export declare function parseWalletSessionAlreadyCommittedResponseV1(value: unknown): WalletSessionAlreadyCommittedResponseV1 | null;
|
|
27
35
|
export declare function parseWalletUnlockAlreadyCommittedResponseV1(value: unknown): WalletSessionAlreadyCommittedResponseV1 | null;
|
|
28
|
-
export {};
|
|
29
36
|
//# sourceMappingURL=walletSessionIssuance.d.ts.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { WalletEcdsaSignerActivationV1, WalletEd25519SignerActivationV1 } from './walletAuthority';
|
|
2
|
+
export declare function sameWalletEd25519SignerActivationV1(left: WalletEd25519SignerActivationV1, right: WalletEd25519SignerActivationV1): boolean;
|
|
3
|
+
export declare function sameWalletEcdsaSignerActivationV1(left: WalletEcdsaSignerActivationV1, right: WalletEcdsaSignerActivationV1): boolean;
|
|
4
|
+
//# sourceMappingURL=walletSignerActivationEquality.d.ts.map
|
|
@@ -7,6 +7,7 @@ import { type PendingWalletAuthMethodRecordV2 } from '../utils/walletAuthMethodR
|
|
|
7
7
|
import { type LinkedDeviceEd25519ExportRootPackageV1 } from './ed25519ExportRoot';
|
|
8
8
|
import { type LinkedDeviceEcdsaEncryptedSourceContributionV1, type LinkedDeviceEcdsaSourcePreservingActivationReceiptV1 } from './sourceContribution';
|
|
9
9
|
import { type RouterAbEd25519YaoApplicationBindingFactsV1, type RouterAbEd25519YaoActivationPublicReceiptV1, type RouterAbEd25519YaoActivationClientPackageV1, type RouterAbEd25519YaoCeremonyBindingV1 } from '../utils/routerAbEd25519Yao';
|
|
10
|
+
import type { ReadonlyExclusiveUnion } from '../utils/variant';
|
|
10
11
|
export type CommittedEd25519SignerPackageV1 = {
|
|
11
12
|
readonly kind: 'committed_ed25519_signer_package_v1';
|
|
12
13
|
readonly materialActivation: MpcMaterialActivationRef;
|
|
@@ -23,22 +24,20 @@ export type CommittedEcdsaSignerPackageV1 = {
|
|
|
23
24
|
readonly encryptedTargetClientShare: LinkedDeviceEcdsaEncryptedSourceContributionV1;
|
|
24
25
|
readonly activationReceipt: LinkedDeviceEcdsaSourcePreservingActivationReceiptV1;
|
|
25
26
|
};
|
|
26
|
-
export type CommittedSignerPackageSetV1 = {
|
|
27
|
+
export type CommittedSignerPackageSetV1 = ReadonlyExclusiveUnion<{
|
|
27
28
|
readonly kind: 'committed_signer_package_set_v1';
|
|
28
29
|
readonly keyFamilies: readonly ['ed25519'];
|
|
29
30
|
readonly ed25519: CommittedEd25519SignerPackageV1;
|
|
30
|
-
readonly ecdsa?: never;
|
|
31
31
|
} | {
|
|
32
32
|
readonly kind: 'committed_signer_package_set_v1';
|
|
33
33
|
readonly keyFamilies: readonly ['ecdsa_secp256k1'];
|
|
34
|
-
readonly ed25519?: never;
|
|
35
34
|
readonly ecdsa: CommittedEcdsaSignerPackageV1;
|
|
36
35
|
} | {
|
|
37
36
|
readonly kind: 'committed_signer_package_set_v1';
|
|
38
37
|
readonly keyFamilies: readonly ['ed25519', 'ecdsa_secp256k1'];
|
|
39
38
|
readonly ed25519: CommittedEd25519SignerPackageV1;
|
|
40
39
|
readonly ecdsa: CommittedEcdsaSignerPackageV1;
|
|
41
|
-
}
|
|
40
|
+
}>;
|
|
42
41
|
export type CommittedAuthorityPackagesV1 = {
|
|
43
42
|
readonly kind: 'committed_authority_packages_v1';
|
|
44
43
|
readonly authority: PendingWalletAuthorityV1;
|
|
@@ -14,6 +14,7 @@ import type { WalletEmailOtpEnrollmentMaterialV1 } from '../utils/registrationAu
|
|
|
14
14
|
import type { VerifiedEmailAddress } from '../utils/domainIds';
|
|
15
15
|
import type { LinkedDeviceOrdinaryMaterialSourceContributionPreparationV1, LinkedDeviceOrdinaryMaterialSourceContributionTupleV1 } from './sourceContribution';
|
|
16
16
|
import type { LinkedDeviceWalletSessionCredentialDeliveryBindingV1, LinkedDeviceWalletSessionCredentialDeliveryV1 } from './walletSessionCredentialDelivery';
|
|
17
|
+
import type { ReadonlyExclusiveUnion } from '../utils/variant';
|
|
17
18
|
export type { LinkedDeviceEcdsaSourceContributionBindingV1, LinkedDeviceEcdsaSourceContributionPackageV1, LinkedDeviceEcdsaSourceContributionPreparationV1, LinkedDeviceEcdsaSourceDerivationV1, LinkedDeviceEcdsaSourcePreservingActivationReceiptV1, LinkedDeviceEcdsaSourceContributionV1, LinkedDeviceEcdsaSourceSignerIdentityV1, LinkedDeviceEcdsaTargetRecipientPreparationV1, LinkedDeviceEd25519SourceContributionPreparationV1, LinkedDeviceEd25519SourceContributionV1, LinkedDeviceOrdinaryMaterialSourceContributionPreparationV1, LinkedDeviceOrdinaryMaterialSourceContributionPreparationTupleV1, LinkedDeviceOrdinaryMaterialSourceContributionTupleV1, LinkedDeviceOrdinaryMaterialSourceContributionV1, } from './sourceContribution';
|
|
18
19
|
export type { CommittedAuthorityPackagesV1, CommittedEd25519SignerPackageV1, CommittedEcdsaSignerPackageV1, CommittedSignerPackageSetDigestInputV1, CommittedSignerPackageSetV1, } from './committedSignerPackages';
|
|
19
20
|
/** Public key bytes carried by the link session, encoded as canonical base64url. */
|
|
@@ -531,97 +532,40 @@ export type LinkPrecommitFailureV1 = {
|
|
|
531
532
|
readonly reason: string;
|
|
532
533
|
};
|
|
533
534
|
/** The only durable states retained by the linear link-session boundary. */
|
|
534
|
-
export type LinkSessionStateV1 = {
|
|
535
|
+
export type LinkSessionStateV1 = ReadonlyExclusiveUnion<{
|
|
535
536
|
readonly state: 'displaying_qr';
|
|
536
|
-
readonly deviceId?: never;
|
|
537
|
-
readonly authorityId?: never;
|
|
538
|
-
readonly packageSetDigestB64u?: never;
|
|
539
|
-
readonly activatedAtMs?: never;
|
|
540
|
-
readonly error?: never;
|
|
541
|
-
readonly cancelledAtMs?: never;
|
|
542
|
-
readonly expiredAtMs?: never;
|
|
543
537
|
} | {
|
|
544
538
|
readonly state: 'claimed';
|
|
545
539
|
readonly deviceId: DeviceId;
|
|
546
|
-
readonly authorityId?: never;
|
|
547
|
-
readonly packageSetDigestB64u?: never;
|
|
548
|
-
readonly activatedAtMs?: never;
|
|
549
|
-
readonly error?: never;
|
|
550
|
-
readonly cancelledAtMs?: never;
|
|
551
|
-
readonly expiredAtMs?: never;
|
|
552
540
|
} | {
|
|
553
541
|
readonly state: 'awaiting_target_factor';
|
|
554
542
|
readonly deviceId: DeviceId;
|
|
555
|
-
readonly authorityId?: never;
|
|
556
|
-
readonly packageSetDigestB64u?: never;
|
|
557
|
-
readonly activatedAtMs?: never;
|
|
558
|
-
readonly error?: never;
|
|
559
|
-
readonly cancelledAtMs?: never;
|
|
560
|
-
readonly expiredAtMs?: never;
|
|
561
543
|
} | {
|
|
562
544
|
readonly state: 'awaiting_source_contribution';
|
|
563
545
|
readonly deviceId: DeviceId;
|
|
564
|
-
readonly authorityId?: never;
|
|
565
|
-
readonly packageSetDigestB64u?: never;
|
|
566
|
-
readonly activatedAtMs?: never;
|
|
567
|
-
readonly error?: never;
|
|
568
|
-
readonly cancelledAtMs?: never;
|
|
569
|
-
readonly expiredAtMs?: never;
|
|
570
546
|
} | {
|
|
571
547
|
readonly state: 'provisioning';
|
|
572
548
|
readonly deviceId: DeviceId;
|
|
573
|
-
readonly authorityId?: never;
|
|
574
|
-
readonly packageSetDigestB64u?: never;
|
|
575
|
-
readonly activatedAtMs?: never;
|
|
576
|
-
readonly error?: never;
|
|
577
|
-
readonly cancelledAtMs?: never;
|
|
578
|
-
readonly expiredAtMs?: never;
|
|
579
549
|
} | {
|
|
580
550
|
readonly state: 'authority_pending_local_install';
|
|
581
551
|
readonly deviceId: DeviceId;
|
|
582
552
|
readonly authorityId: WalletAuthorityId;
|
|
583
553
|
readonly packageSetDigestB64u: DigestB64u;
|
|
584
|
-
readonly activatedAtMs?: never;
|
|
585
|
-
readonly error?: never;
|
|
586
|
-
readonly cancelledAtMs?: never;
|
|
587
|
-
readonly expiredAtMs?: never;
|
|
588
554
|
} | {
|
|
589
555
|
readonly state: 'active';
|
|
590
556
|
readonly deviceId: DeviceId;
|
|
591
557
|
readonly authorityId: WalletAuthorityId;
|
|
592
558
|
readonly activatedAtMs: number;
|
|
593
|
-
readonly packageSetDigestB64u?: never;
|
|
594
|
-
readonly error?: never;
|
|
595
|
-
readonly cancelledAtMs?: never;
|
|
596
|
-
readonly expiredAtMs?: never;
|
|
597
559
|
} | {
|
|
598
560
|
readonly state: 'failed_before_commit';
|
|
599
561
|
readonly error: LinkPrecommitFailureV1;
|
|
600
|
-
readonly deviceId?: never;
|
|
601
|
-
readonly authorityId?: never;
|
|
602
|
-
readonly packageSetDigestB64u?: never;
|
|
603
|
-
readonly activatedAtMs?: never;
|
|
604
|
-
readonly cancelledAtMs?: never;
|
|
605
|
-
readonly expiredAtMs?: never;
|
|
606
562
|
} | {
|
|
607
563
|
readonly state: 'cancelled';
|
|
608
564
|
readonly cancelledAtMs: number;
|
|
609
|
-
readonly deviceId?: never;
|
|
610
|
-
readonly authorityId?: never;
|
|
611
|
-
readonly packageSetDigestB64u?: never;
|
|
612
|
-
readonly activatedAtMs?: never;
|
|
613
|
-
readonly error?: never;
|
|
614
|
-
readonly expiredAtMs?: never;
|
|
615
565
|
} | {
|
|
616
566
|
readonly state: 'expired';
|
|
617
567
|
readonly expiredAtMs: number;
|
|
618
|
-
|
|
619
|
-
readonly authorityId?: never;
|
|
620
|
-
readonly packageSetDigestB64u?: never;
|
|
621
|
-
readonly activatedAtMs?: never;
|
|
622
|
-
readonly error?: never;
|
|
623
|
-
readonly cancelledAtMs?: never;
|
|
624
|
-
};
|
|
568
|
+
}>;
|
|
625
569
|
export type VerifiedSourceAuthorityV1 = {
|
|
626
570
|
readonly authority: ActiveWalletAuthorityV1;
|
|
627
571
|
readonly authMethodId: WalletAuthMethodId;
|
|
@@ -702,7 +646,7 @@ export type LinkedDeviceTargetCredentialRegistrationResultV1 = {
|
|
|
702
646
|
readonly keyManifestDigestB64u: DigestB64u;
|
|
703
647
|
};
|
|
704
648
|
/** The ordinary session issued by activation and persisted by the browser. */
|
|
705
|
-
export type WalletCapabilitySubjectV1 = {
|
|
649
|
+
export type WalletCapabilitySubjectV1 = ReadonlyExclusiveUnion<{
|
|
706
650
|
readonly kind: 'sign';
|
|
707
651
|
readonly keyFamily: 'ed25519' | 'ecdsa_secp256k1';
|
|
708
652
|
readonly materialActivation: MpcMaterialActivationRef;
|
|
@@ -712,9 +656,7 @@ export type WalletCapabilitySubjectV1 = {
|
|
|
712
656
|
readonly materialActivation: MpcMaterialActivationRef;
|
|
713
657
|
} | {
|
|
714
658
|
readonly kind: 'link_devices' | 'revoke_devices';
|
|
715
|
-
|
|
716
|
-
readonly materialActivation?: never;
|
|
717
|
-
};
|
|
659
|
+
}>;
|
|
718
660
|
export type ActiveWalletSessionV1 = {
|
|
719
661
|
readonly kind: 'active_wallet_session_v1';
|
|
720
662
|
readonly walletId: WalletId;
|
|
@@ -179,5 +179,7 @@ export declare function parseLinkedDeviceEcdsaSourcePreservingActivationReceiptV
|
|
|
179
179
|
export declare function parseLinkedDeviceEcdsaSourceContributionPackageV1(raw: unknown): LinkedDeviceEcdsaSourceContributionPackageV1;
|
|
180
180
|
export declare function parseLinkedDeviceEcdsaSourceContributionBindingV1(raw: unknown): LinkedDeviceEcdsaSourceContributionBindingV1;
|
|
181
181
|
export declare function parseLinkedDeviceEcdsaEncryptedSourceContributionV1(raw: unknown, label: string): LinkedDeviceEcdsaEncryptedSourceContributionV1;
|
|
182
|
+
export declare function sameEcdsaSourceSigner(left: LinkedDeviceEcdsaSourceSignerIdentityV1, right: LinkedDeviceEcdsaSourceSignerIdentityV1): boolean;
|
|
183
|
+
export declare function sameEcdsaTarget(left: LinkedDeviceEcdsaTargetRecipientPreparationV1, right: LinkedDeviceEcdsaTargetRecipientPreparationV1): boolean;
|
|
182
184
|
export {};
|
|
183
185
|
//# sourceMappingURL=sourceContribution.d.ts.map
|