@seams/wallet-server 0.27.0 → 0.29.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/README.md +19 -4
- package/artifact-manifest.json +28 -13
- package/cloudflare-router-ab/build/deriver-a/build-stamp.json +1 -1
- package/cloudflare-router-ab/build/deriver-b/build-stamp.json +1 -1
- package/cloudflare-router-ab/build/router/build-stamp.json +1 -1
- package/cloudflare-router-ab/build/signing-worker/build-stamp.json +1 -1
- package/cloudflare-router-ab/build/tenant-root-control-plane/build-stamp.json +1 -1
- package/dist/esm/application-auth.js +2 -0
- package/dist/esm/auth/applicationAuth.js +85 -0
- package/dist/esm/auth/externalAuthService.js +149 -0
- package/dist/esm/auth/externalAuthStore.js +353 -0
- package/dist/esm/auth/externalOwnerOperations.js +82 -0
- package/dist/esm/authorization/domain.js +2 -2
- package/dist/esm/authorization/factorEvidence.js +1 -1
- package/dist/esm/authorization/service.js +2 -2
- package/dist/esm/authorization/vaultProxyUse.js +1 -1
- package/dist/esm/cloud-host.js +12 -11
- package/dist/esm/core/ThresholdService/validation.js +1 -1
- package/dist/esm/core/WebAuthnCredentialBindingStore.js +1 -1
- package/dist/esm/core/authService/webauthn.js +1 -1
- package/dist/esm/core/d1EcdsaSignerRead.js +1 -1
- package/dist/esm/core/d1WalletAuthMethodStore.js +2 -2
- package/dist/esm/core/d1WalletStore.js +1 -1
- package/dist/esm/core/deviceLinking/linkedDeviceEmailOtpGrant.js +1 -1
- package/dist/esm/core/deviceLinking/linkedDeviceManagement.js +1 -1
- package/dist/esm/core/deviceLinking/linkedDeviceSessionRecord.js +2 -2
- package/dist/esm/core/nearRelayerAccountProvisioning.js +2 -2
- package/dist/esm/hosted-wallet-gateway.js +3 -3
- package/dist/esm/index.js +1 -1
- package/dist/esm/router/auth/webAuthnCredentialCodecs.js +1 -1
- package/dist/esm/router/cloudflare/d1/auth/d1AuthorizedOperationRouteService.js +2 -0
- package/dist/esm/router/cloudflare/d1/auth/d1RecordedOwnerOperation.js +43 -0
- package/dist/esm/router/cloudflare/d1/auth/d1RouterApiAuthService.js +27 -3
- package/dist/esm/router/cloudflare/d1/authorization/d1AuthorizationStore.js +2 -2
- package/dist/esm/router/cloudflare/d1/authorization/d1VaultProxyStore.js +2 -2
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceAuthorityInstallService.js +3 -3
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceEd25519ExportRootStore.js +1 -1
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceOwnerAuthorizationProvider.js +2 -2
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceSessionStore.js +1 -1
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceSourceContributionPreparationPlanner.js +1 -1
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceTargetAuthenticatorStore.js +1 -1
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceTargetCredentialProvider.js +1 -1
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceTargetPlanner.js +1 -1
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceVerifiedLinkBuilder.js +2 -2
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceVerifiedLinkSourceReader.js +1 -1
- package/dist/esm/router/cloudflare/d1/ed25519Yao/d1Ed25519YaoCapabilityPersistence.js +1 -1
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeIssuer.js +1 -1
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeService.js +1 -1
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeStore.js +1 -1
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpRecords.js +2 -2
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpRecoveryService.js +3 -3
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpRegistrationEnrollmentFinalizer.js +1 -1
- package/dist/esm/router/cloudflare/d1/emailOtp/d1GoogleEmailOtpRegistrationAttemptStore.js +1 -1
- package/dist/esm/router/cloudflare/d1/emailOtp/d1GoogleEmailOtpSessionResolver.js +3 -3
- package/dist/esm/router/cloudflare/d1/oidc/d1OidcBoundary.js +7 -1
- package/dist/esm/router/cloudflare/d1/oidc/d1OidcVerificationService.js +1 -1
- package/dist/esm/router/cloudflare/d1/passkeyCustody/d1PasskeyCustodyRouteService.js +4 -4
- package/dist/esm/router/cloudflare/d1/passkeyCustody/d1WalletCustodyCommitStore.js +4 -4
- package/dist/esm/router/cloudflare/d1/passkeyCustody/d1WalletRecoveryGoogleEmailOtpRecords.js +1 -1
- package/dist/esm/router/cloudflare/d1/passkeyCustody/d1WalletRecoveryGoogleEmailOtpService.js +3 -3
- package/dist/esm/router/cloudflare/d1/registration/d1EvmFamilyEcdsaRegistrationBranch.js +1 -1
- package/dist/esm/router/cloudflare/d1/registration/d1RegistrationCeremonyRecords.js +11 -2
- package/dist/esm/router/cloudflare/d1/registration/d1RegistrationIntentService.js +1 -1
- package/dist/esm/router/cloudflare/d1/registration/d1WalletExecutionAuthority.js +9 -16
- package/dist/esm/router/cloudflare/d1/registration/d1WalletRegistrationCommitStore.js +1 -1
- package/dist/esm/router/cloudflare/d1/registration/d1WalletRegistrationService.js +46 -4
- package/dist/esm/router/cloudflare/d1/registration/d1WalletRegistrationSetup.js +12 -0
- package/dist/esm/router/cloudflare/d1/registration/d1WalletRegistrationSetupExecution.js +1 -0
- package/dist/esm/router/cloudflare/d1/registration/registrationCompletionWrite.js +1 -0
- package/dist/esm/router/cloudflare/d1/registration/walletRegistrationEstablishedSessionIssuer.js +1 -1
- package/dist/esm/router/cloudflare/d1/registration/walletRegistrationSessionCommitReceipt.js +36 -1
- package/dist/esm/router/cloudflare/d1/signingAdmission/d1RouterAbNormalSigningAdmissionStore.js +1 -1
- package/dist/esm/router/cloudflare/d1/wallet/authorizationSnapshotLayout.js +1 -0
- package/dist/esm/router/cloudflare/d1/wallet/d1VoiceIdWalletSessionChallenges.js +2 -2
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletAuthMethodBoundary.js +1 -1
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletAuthMethodRevocationReplayStore.js +1 -1
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletAuthMethodService.js +6 -5
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletAuthorityStore.js +2 -2
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletAuthorizationCleanup.js +2 -1
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletAuthorizationIntake.js +1 -1
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletAuthorizationSnapshot.js +1 -1
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletRelocationChallenges.js +1 -1
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletRelocationOwnerRequest.js +2 -2
- package/dist/esm/router/cloudflare/d1/webauthn/d1WebAuthnAuthService.js +2 -2
- package/dist/esm/router/cloudflare/d1/webauthn/d1WebAuthnRecords.js +2 -2
- package/dist/esm/router/cloudflare/runtime/staticWalletConsoleBinding.js +9 -0
- package/dist/esm/router/cloudflare/runtime/walletConsoleOpsClient.js +6 -0
- package/dist/esm/router/cloudflare-adaptor.js +1 -1
- package/dist/esm/router/cloudflare.js +6139 -5567
- package/dist/esm/router/domains/ecdsa/routerAbEcdsaStrictRegistration.js +1 -1
- package/dist/esm/router/domains/ed25519Yao/export/routerAbEd25519YaoExport.js +5 -5
- package/dist/esm/router/domains/ed25519Yao/recovery/routerAbEd25519YaoRecovery.js +2 -2
- package/dist/esm/router/domains/ed25519Yao/recovery/routerAbEd25519YaoRecoveryWalletSessionAuthorization.js +1 -1
- package/dist/esm/router/domains/ed25519Yao/registration/routerAbEd25519YaoHttpRegistrationBackend.js +1 -1
- package/dist/esm/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistration.js +1 -1
- package/dist/esm/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistrationIntentAuthorization.js +1 -1
- package/dist/esm/router/domains/emailOtp/emailOtpRouteHandlers.js +2 -2
- package/dist/esm/router/domains/passkeyCustody/walletCustodyRegistrationCommit.js +1 -1
- package/dist/esm/router/domains/signingOperations/routerAbEcdsaDerivationNormalSigningRoute.js +2 -2
- package/dist/esm/router/domains/signingOperations/routerAbEd25519NormalSigningRoute.js +37 -3
- package/dist/esm/router/domains/signingOperations/routerAbOperationStepUp.js +1 -1
- package/dist/esm/router/domains/tenantRoot/tenantRootIdentityResolution.js +1 -1
- package/dist/esm/router/domains/walletRegistration/walletRegistrationReservation.js +18 -3
- package/dist/esm/router/domains/walletRegistration/walletRegistrationRoutes.js +12 -4
- package/dist/esm/router/domains/walletUnlock/walletUnlockRouteHandlers.js +3 -3
- package/dist/esm/router/framework/http.js +1 -1
- package/dist/esm/router/framework/routeDefinitions.js +2 -1
- package/dist/esm/router/transport/fetch/createFetchRouter.js +5 -3
- package/dist/esm/router/transport/fetch/routes/auth.js +1 -1
- package/dist/esm/router/transport/fetch/routes/deviceLinking.js +3 -3
- package/dist/esm/router/transport/fetch/routes/deviceLinkingOwnerAuthorization.js +1 -1
- package/dist/esm/router/transport/fetch/routes/ecdsaOperationStepUpFactor.js +3 -3
- package/dist/esm/router/transport/fetch/routes/externalAuth.js +351 -0
- package/dist/esm/router/transport/fetch/routes/normalSigningRouterProxy.js +1 -1
- package/dist/esm/router/transport/fetch/routes/passkeyCustody.js +46 -306
- package/dist/esm/router/transport/fetch/routes/sessions.js +4 -4
- package/dist/esm/router/transport/fetch/routes/syncAccount.js +2 -2
- package/dist/esm/router/transport/fetch/routes/syncAccountBootstrap.js +1 -1
- package/dist/esm/router/transport/fetch/routes/thresholdEcdsa.js +4 -4
- package/dist/esm/router/transport/fetch/routes/thresholdEd25519.js +6 -6
- package/dist/esm/router/transport/fetch/routes/walletExecutionLanePreflight.js +2 -2
- package/dist/esm/router/transport/fetch/routes/walletRegistration.js +4 -4
- package/dist/esm/router/transport/fetch/walletOwnerOperationAuthorization.js +306 -0
- package/dist/esm/shared-ts/src/auth/externalAuth.js +118 -0
- package/dist/esm/shared-ts/src/authorization/index.js +1 -1
- package/dist/esm/shared-ts/src/authorization/voiceIdDeviceAssertion.js +1 -1
- package/dist/esm/shared-ts/src/authorization/walletAuthority.js +2 -2
- package/dist/esm/shared-ts/src/authorization/{walletCustodyOperation.js → walletOwnerOperation.js} +4 -4
- package/dist/esm/shared-ts/src/device-linking/delegatedActivationPlan.js +1 -1
- package/dist/esm/shared-ts/src/device-linking/digests.js +1 -1
- package/dist/esm/shared-ts/src/device-linking/ed25519ExportRoot.js +1 -1
- package/dist/esm/shared-ts/src/device-linking/parsers.js +2 -2
- package/dist/esm/shared-ts/src/device-linking/sourceContribution.js +1 -1
- package/dist/esm/shared-ts/src/device-linking/walletSessionCredentialDelivery.js +1 -1
- package/dist/esm/shared-ts/src/device-linking/wireFields.js +2 -2
- package/dist/esm/shared-ts/src/passkey-custody/custodyEnvelope.js +1 -1
- package/dist/esm/shared-ts/src/passkey-custody/custodySecretBinding.js +1 -1
- package/dist/esm/shared-ts/src/signing-lanes/ownerContinuity.js +1 -1
- package/dist/esm/shared-ts/src/utils/routerAbEcdsaDerivation.js +1 -1
- package/dist/esm/shared-ts/src/utils/walletAuthAuthority.js +1 -1
- package/dist/esm/shared-ts/src/wallet-recovery/index.js +3 -3
- package/dist/esm/shared-ts/src/wallet-recovery/walletRecoveryCommittedProjection.js +1 -1
- package/dist/esm/shared-ts/src/wallet-recovery/walletRecoveryEnvelopeSet.js +1 -1
- package/dist/esm/threshold/session/signingSessionSeal/crypto/cipher.js +1 -1
- package/dist/esm/threshold/session/signingSessionSeal/service.js +1 -1
- package/dist/esm/threshold/session/signingSessionSeal/transport/fetch.js +1 -1
- package/dist/esm/threshold/session/signingSessionSeal/transport/shared.js +1 -1
- package/dist/types/shared-ts/src/auth/externalAuth.d.ts +127 -0
- package/dist/types/shared-ts/src/authorization/index.d.ts +1 -1
- package/dist/types/shared-ts/src/authorization/walletOwnerOperation.d.ts +10 -0
- package/dist/types/shared-ts/src/utils/registrationEstablishedSession.d.ts +4 -0
- package/dist/types/shared-ts/src/utils/registrationIntent.d.ts +2 -0
- package/dist/types/shared-ts/src/utils/walletManagementProtocol.d.ts +1 -1
- package/dist/types/wallet-server/src/application-auth.d.ts +3 -0
- package/dist/types/wallet-server/src/auth/applicationAuth.d.ts +29 -0
- package/dist/types/wallet-server/src/auth/externalAuthService.d.ts +55 -0
- package/dist/types/wallet-server/src/auth/externalAuthStore.d.ts +115 -0
- package/dist/types/wallet-server/src/auth/externalOwnerOperations.d.ts +18 -0
- package/dist/types/wallet-server/src/cloud-host.d.ts +2 -1
- package/dist/types/wallet-server/src/core/threeRouteRegistrationContracts.d.ts +12 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/auth/d1AuthorizedOperationRouteService.d.ts +5 -1
- package/dist/types/wallet-server/src/router/cloudflare/d1/auth/d1RecordedOwnerOperation.d.ts +16 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/oidc/d1OidcBoundary.d.ts +5 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1RegistrationCeremonyRecords.d.ts +1 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1WalletRegistrationSetup.d.ts +2 -0
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/walletRegistrationSessionCommitReceipt.d.ts +7 -1
- package/dist/types/wallet-server/src/router/cloudflare/d1/wallet/authorizationSnapshotLayout.d.ts +1 -1
- package/dist/types/wallet-server/src/router/cloudflare/d1/wallet/d1WalletAuthMethodService.d.ts +1 -0
- package/dist/types/wallet-server/src/router/cloudflare/runtime/staticWalletConsoleBinding.d.ts +2 -0
- package/dist/types/wallet-server/src/router/domains/signingOperations/routerAbEd25519NormalSigningRoute.d.ts +2 -2
- package/dist/types/wallet-server/src/router/domains/signingOperations/routerAbOperationStepUp.d.ts +1 -1
- package/dist/types/wallet-server/src/router/domains/walletRegistration/walletRegistrationInputs.d.ts +1 -0
- package/dist/types/wallet-server/src/router/domains/walletRegistration/walletRegistrationReservation.d.ts +11 -6
- package/dist/types/wallet-server/src/router/framework/apiCredentialPorts.d.ts +1 -0
- package/dist/types/wallet-server/src/router/framework/authServicePort.d.ts +12 -0
- package/dist/types/wallet-server/src/router/transport/fetch/routes/externalAuth.d.ts +5 -0
- package/dist/types/wallet-server/src/router/transport/fetch/walletOwnerOperationAuthorization.d.ts +23 -0
- package/migrations/d1-signer/0085_external_wallet_auth.sql +158 -0
- package/migrations/d1-signer/0086_application_auth.sql +67 -0
- package/migrations/d1-signer/0087_registration_without_session.sql +43 -0
- package/package.json +7 -2
- package/dist/types/shared-ts/src/authorization/walletCustodyOperation.d.ts +0 -10
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { normalizeOptionalTrimmedString } from "../../../../shared-ts/src/utils/normalize.js";
|
|
2
2
|
import { base64UrlDecode } from "../../../../shared-ts/src/utils/base64.js";
|
|
3
|
-
import "../../../../shared-ts/src/utils/encoders.js";
|
|
4
3
|
import { failedVerification } from "../../../../shared-ts/src/utils/failure.js";
|
|
4
|
+
import "../../../../shared-ts/src/utils/encoders.js";
|
|
5
5
|
import { toArrayBufferCopy } from "../../../../core/authService/portableCrypto.js";
|
|
6
6
|
import { toRecordValue } from "../auth/d1RouterApiAuthBoundary.js";
|
|
7
7
|
//#region src/router/cloudflare/d1/oidc/d1OidcBoundary.ts
|
|
@@ -134,6 +134,7 @@ function validateGoogleIdTokenClaims(input) {
|
|
|
134
134
|
const aud = parseJwtAud(payload.aud);
|
|
135
135
|
if (aud.length === 0) return failedVerification("invalid_claims", "Missing Google id_token aud");
|
|
136
136
|
if (!aud.includes(input.clientId)) return failedVerification("invalid_audience", "Google id_token audience mismatch");
|
|
137
|
+
const authorizedParty = normalizeOptionalTrimmedString(payload.azp);
|
|
137
138
|
const sub = normalizeOptionalTrimmedString(payload.sub);
|
|
138
139
|
if (!sub) return failedVerification("invalid_claims", "Missing Google id_token sub");
|
|
139
140
|
const email = normalizeOptionalTrimmedString(payload.email);
|
|
@@ -146,6 +147,11 @@ function validateGoogleIdTokenClaims(input) {
|
|
|
146
147
|
return {
|
|
147
148
|
ok: true,
|
|
148
149
|
sub,
|
|
150
|
+
issuer: "https://accounts.google.com",
|
|
151
|
+
audience: input.clientId,
|
|
152
|
+
expiresAtMs: exp * 1e3,
|
|
153
|
+
authorizedParty: authorizedParty || null,
|
|
154
|
+
audienceCount: aud.length,
|
|
149
155
|
...email ? { email } : {},
|
|
150
156
|
...name ? { name } : {},
|
|
151
157
|
...givenName ? { givenName } : {},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { normalizeOptionalTrimmedString } from "../../../../shared-ts/src/utils/normalize.js";
|
|
2
2
|
import { failedVerification } from "../../../../shared-ts/src/utils/failure.js";
|
|
3
|
-
import { githubOAuthPublicConfig, verifyGithubOAuthCodeWithIdentityStore } from "../../../../core/authService/githubOAuth.js";
|
|
4
3
|
import { verifyGoogleOidcToken } from "./googleOidcToken.js";
|
|
4
|
+
import { githubOAuthPublicConfig, verifyGithubOAuthCodeWithIdentityStore } from "../../../../core/authService/githubOAuth.js";
|
|
5
5
|
//#region src/router/cloudflare/d1/oidc/d1OidcVerificationService.ts
|
|
6
6
|
function errorMessage(error) {
|
|
7
7
|
return error instanceof Error ? error.message : String(error || "");
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { parseEmailOtpProviderUserId, parsePasskeyEnvelopeId, parseWalletAuthMethodId, parseWalletAuthorityBindingDigest, parseWalletAuthorityId, parseWalletId, parseWalletRecoveryOperationId, parseWebAuthnRpId } from "../../../../shared-ts/src/utils/domainIds.js";
|
|
2
|
-
import { parseDeviceId } from "../../../../shared-ts/src/authorization/capabilityKinds.js";
|
|
3
2
|
import { base64UrlEncode } from "../../../../shared-ts/src/utils/base64.js";
|
|
3
|
+
import { failure } from "../../../../shared-ts/src/utils/failure.js";
|
|
4
4
|
import "../../../../shared-ts/src/utils/encoders.js";
|
|
5
|
+
import { parseDeviceId } from "../../../../shared-ts/src/authorization/capabilityKinds.js";
|
|
5
6
|
import { isActiveRecoveredWalletAuthorityV1, walletAuthorityDigestsMatchV1 } from "../../../../shared-ts/src/authorization/walletAuthority.js";
|
|
6
7
|
import { secureRandomBase64Url } from "../../../../shared-ts/src/utils/secureRandomId.js";
|
|
7
8
|
import { PASSKEY_PRF_FIRST_SALT_V1, PASSKEY_PRF_SECOND_SALT_V1 } from "../../../../shared-ts/src/utils/signingSessionSeal.js";
|
|
8
|
-
import {
|
|
9
|
-
import { isHostWithinRpId, originHostnameOrEmpty } from "../../../../core/authService/webauthnOidcHelpers.js";
|
|
9
|
+
import { deriveRecoveryCodeLocatorV1FromBytes } from "../../../../shared-ts/src/wallet-recovery/recoveryCodeLocator.js";
|
|
10
10
|
import { buildWalletRecoveryBackupAcknowledgementV1, walletRecoveryBackupIsOutstanding } from "../../../../shared-ts/src/wallet-recovery/backupAcknowledgement.js";
|
|
11
11
|
import "../../../../shared-ts/src/wallet-recovery/recoveryCodes.js";
|
|
12
|
-
import {
|
|
12
|
+
import { isHostWithinRpId, originHostnameOrEmpty } from "../../../../core/authService/webauthnOidcHelpers.js";
|
|
13
13
|
import { buildWebAuthnRecoveryContinuityAnchorRecord } from "../webauthn/d1WebAuthnRecords.js";
|
|
14
14
|
import { buildWalletRecoveryCommittedProjectionV1 } from "../../../../shared-ts/src/wallet-recovery/walletRecoveryCommittedProjection.js";
|
|
15
15
|
import { envelopeFactorRef } from "./d1PasskeyCustodyEnvelopeStore.js";
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { parseWalletId } from "../../../../shared-ts/src/utils/domainIds.js";
|
|
2
|
-
import { buildDelegatedWalletAuthorityV1, buildFullOwnerDelegatedWalletAuthorityV1, sameDelegatedWalletAuthorityV1 } from "../../../../shared-ts/src/authorization/delegatedAuthority.js";
|
|
3
2
|
import { sha256HexUtf8 } from "../../../../shared-ts/src/utils/digests.js";
|
|
3
|
+
import { D1_BATCH_CAS_GUARD_SQL } from "../../../../storage/d1Sql.js";
|
|
4
|
+
import { buildDelegatedWalletAuthorityV1, buildFullOwnerDelegatedWalletAuthorityV1, sameDelegatedWalletAuthorityV1 } from "../../../../shared-ts/src/authorization/delegatedAuthority.js";
|
|
4
5
|
import { sameWalletAuthMethodRecordV2 } from "../../../../shared-ts/src/utils/walletAuthMethodRecord.js";
|
|
5
6
|
import { sameVerifiedActiveWalletAuthorityV1, walletAuthorityDigestsMatchV1 } from "../../../../shared-ts/src/authorization/walletAuthority.js";
|
|
6
|
-
import {
|
|
7
|
+
import { WALLET_EMAIL_OTP_ACTIONS, emailOtpDeviceEnrollmentId } from "../../../../shared-ts/src/utils/emailOtpDomain.js";
|
|
7
8
|
import { D1WalletAuthMethodStore } from "../../../../core/d1WalletAuthMethodStore.js";
|
|
8
9
|
import { parsePasskeyCustodyEnvelopeRecord } from "../../../../shared-ts/src/passkey-custody/custodyEnvelope.js";
|
|
9
10
|
import "../../../../shared-ts/src/passkey-custody/index.js";
|
|
10
|
-
import {
|
|
11
|
+
import { parseRecoveryCodeLocatorV1 } from "../../../../shared-ts/src/wallet-recovery/recoveryCodeLocator.js";
|
|
11
12
|
import { parseDerivedWalletRecoveryKeyId } from "../../../../shared-ts/src/wallet-recovery/recoveryKeyId.js";
|
|
12
13
|
import { parseWalletRecoveryBackupAcknowledgementV1 } from "../../../../shared-ts/src/wallet-recovery/backupAcknowledgement.js";
|
|
13
14
|
import "../../../../shared-ts/src/wallet-recovery/recoveryCodes.js";
|
|
14
15
|
import { parseWalletRecoveryEnvelopeSetRecord } from "../../../../shared-ts/src/wallet-recovery/walletRecoveryEnvelopeSet.js";
|
|
15
|
-
import { parseRecoveryCodeLocatorV1 } from "../../../../shared-ts/src/wallet-recovery/recoveryCodeLocator.js";
|
|
16
16
|
import { reservePasskeyCredential } from "../../../../core/passkeyCredentialClaims.js";
|
|
17
17
|
import { prepareD1WebAuthnCredentialBindingInsertStatement } from "../../../../core/WebAuthnCredentialBindingStore.js";
|
|
18
18
|
import { prepareD1WebAuthnAuthenticatorInsertStatement } from "../webauthn/d1WebAuthnStore.js";
|
package/dist/esm/router/cloudflare/d1/passkeyCustody/d1WalletRecoveryGoogleEmailOtpRecords.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { parsePasskeyEnvelopeId, parseWalletAuthMethodId, parseWalletAuthorityId, parseWalletId, parseWalletRecoveryOperationId, parseWebAuthnCredentialIdB64u, parseWebAuthnRpId } from "../../../../shared-ts/src/utils/domainIds.js";
|
|
2
|
-
import { parseDeviceId } from "../../../../shared-ts/src/authorization/capabilityKinds.js";
|
|
3
2
|
import { parseDigestB64u } from "../../../../shared-ts/src/utils/canonicalPrimitives.js";
|
|
4
3
|
import { parseEnvelopeRevision } from "../../../../shared-ts/src/passkey-custody/primitives.js";
|
|
4
|
+
import { parseDeviceId } from "../../../../shared-ts/src/authorization/capabilityKinds.js";
|
|
5
5
|
import { parseWalletAuthMethodRecordV2 } from "../../../../shared-ts/src/utils/walletAuthMethodRecord.js";
|
|
6
6
|
import { parseWalletAuthorityV1 } from "../../../../shared-ts/src/authorization/walletAuthority.js";
|
|
7
7
|
import { hasExactKeys } from "../../../../shared-ts/src/utils/exactKeys.js";
|
package/dist/esm/router/cloudflare/d1/passkeyCustody/d1WalletRecoveryGoogleEmailOtpService.js
CHANGED
|
@@ -2,12 +2,12 @@ import { parseProviderSubject, parseVerifiedGoogleEmail } from "../../../../shar
|
|
|
2
2
|
import { base64UrlEncode } from "../../../../shared-ts/src/utils/base64.js";
|
|
3
3
|
import { alphabetizeStringify, sha256BytesUtf8, sha256HexUtf8 } from "../../../../shared-ts/src/utils/digests.js";
|
|
4
4
|
import { parseDigestB64u } from "../../../../shared-ts/src/utils/canonicalPrimitives.js";
|
|
5
|
+
import { failure } from "../../../../shared-ts/src/utils/failure.js";
|
|
5
6
|
import "../../../../shared-ts/src/utils/encoders.js";
|
|
6
7
|
import { buildWalletAuthMethodRecordV2 } from "../../../../shared-ts/src/utils/walletAuthMethodRecord.js";
|
|
7
|
-
import { failure } from "../../../../shared-ts/src/utils/failure.js";
|
|
8
|
-
import { consumeReservedRecoveryCode } from "../../../../shared-ts/src/wallet-recovery/recoveryCodeReservation.js";
|
|
9
|
-
import { hashEmailOtpOperationBinding } from "../../../domains/emailOtp/emailOtpSessionRouteHelpers.js";
|
|
10
8
|
import { EMAIL_OTP_CHANNEL, WALLET_EMAIL_OTP_ACTIONS, WALLET_EMAIL_OTP_UNLOCK_OPERATION } from "../../../../shared-ts/src/utils/emailOtpDomain.js";
|
|
9
|
+
import { hashEmailOtpOperationBinding } from "../../../domains/emailOtp/emailOtpSessionRouteHelpers.js";
|
|
10
|
+
import { consumeReservedRecoveryCode } from "../../../../shared-ts/src/wallet-recovery/recoveryCodeReservation.js";
|
|
11
11
|
import { sealEmailOtpFactorSecretForWorker } from "../../../domains/emailOtp/emailOtpRouteHandlers.js";
|
|
12
12
|
import { markWalletRecoveryGoogleEmailOtpAttemptIssued, markWalletRecoveryGoogleEmailOtpAttemptVerified, sameWalletRecoveryGoogleEmailOtpFinalizationInputV1, walletRecoveryGoogleEmailOtpFinalizationInput } from "./d1WalletRecoveryGoogleEmailOtpRecords.js";
|
|
13
13
|
import { buildWalletRecoveryEcdsaPossessionChallengesV1, resolveWalletRecoveryKeyManifestV1, verifyWalletRecoveryKeyActivationsV1 } from "../../../domains/passkeyCustody/walletRecoveryKeyManifest.js";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { parseRootShareEpoch } from "../../../../shared-ts/src/utils/domainIds.js";
|
|
2
|
+
import { failure } from "../../../../shared-ts/src/utils/failure.js";
|
|
2
3
|
import { deriveEvmFamilySigningKeySlotId } from "../../../../shared-ts/src/signing-lanes/evmFamilySigningKeySlotId.js";
|
|
3
4
|
import { computeEcdsaDerivationRoleLocalRelayerKeyId, computeEcdsaDerivationRoleLocalThresholdKeyId, computeSdkEcdsaDerivationApplicationBindingDigestB64u, parseSdkEcdsaDerivationSigningRootId, parseSdkEcdsaDerivationSigningRootVersion, parseSdkEcdsaDerivationThresholdKeyId } from "../../../../shared-ts/src/threshold/ecdsaDerivationRoleLocalBootstrap.js";
|
|
4
5
|
import { buildRouterAbEcdsaDerivationActiveStateIdV1 } from "../../../../shared-ts/src/utils/routerAbEcdsaDerivation.js";
|
|
5
6
|
import { secureRandomBase64Url } from "../../../../shared-ts/src/utils/secureRandomId.js";
|
|
6
|
-
import { failure } from "../../../../shared-ts/src/utils/failure.js";
|
|
7
7
|
import "./d1RegistrationCeremonyRecords.js";
|
|
8
8
|
//#region src/router/cloudflare/d1/registration/d1EvmFamilyEcdsaRegistrationBranch.ts
|
|
9
9
|
const REGISTRATION_WALLET_SIGNING_SESSION_REMAINING_USES = 3;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { parseChallengeSubjectId, parseEmailOtpChallengeId, parseOrgId, parseProviderSubject, parseRootShareEpoch, parseWalletAuthMethodId, parseWalletAuthorityId, parseWebAuthnRpId } from "../../../../shared-ts/src/utils/domainIds.js";
|
|
2
|
-
import { parseDeviceId } from "../../../../shared-ts/src/authorization/capabilityKinds.js";
|
|
3
2
|
import { normalizeOptionalTrimmedString } from "../../../../shared-ts/src/utils/normalize.js";
|
|
4
3
|
import { parseDigestB64u } from "../../../../shared-ts/src/utils/canonicalPrimitives.js";
|
|
4
|
+
import { toRecordValue } from "../auth/d1RouterApiAuthBoundary.js";
|
|
5
|
+
import { parseDeviceId } from "../../../../shared-ts/src/authorization/capabilityKinds.js";
|
|
5
6
|
import { parseWalletAddAuthMethodRegistrationOptions } from "../../../../shared-ts/src/utils/addAuthMethodRegistration.js";
|
|
6
7
|
import { parseRouterAbMpcMaterialActivationRef } from "../../../../shared-ts/src/utils/routerAbNormalSigningIdentity.js";
|
|
7
8
|
import { parseRouterAbEd25519YaoRegistrationActivationAdmissionReceiptV1, parseRouterAbEd25519YaoRegistrationActivationResultV1, parseRouterAbEd25519YaoRegistrationAdmissionRequestV1 } from "../../../../shared-ts/src/utils/routerAbEd25519Yao.js";
|
|
@@ -27,7 +28,6 @@ import { parseImplicitNearAccountId, parseNamedNearAccountId } from "../../../..
|
|
|
27
28
|
import { findRegistrationSignerPlanNearEd25519Branch, normalizeAddSignerSelection, normalizeRegistrationSignerPlan, registrationSignerBranchKeyFromString, registrationSignerSetSelectionFromPlan } from "../../../../shared-ts/src/utils/registrationSignerPlan.js";
|
|
28
29
|
import { addAuthMethodIntentGrantFromString, addSignerIntentGrantFromString, normalizeAddAuthMethodIntentCaller } from "../../../../shared-ts/src/utils/registrationIntent.js";
|
|
29
30
|
import { parseEcdsaDerivationPublicIdentity, parseThresholdEd25519AuthorityScope, thresholdEd25519AuthorityScopeFromWalletAuthAuthority, thresholdEd25519AuthorityScopesMatch } from "../../../../core/ThresholdService/validation.js";
|
|
30
|
-
import { toRecordValue } from "../auth/d1RouterApiAuthBoundary.js";
|
|
31
31
|
import { parseStoredRegistrationSignerPlan, parseStoredWalletRegistrationPreparedContext, storedRegistrationSignerPlansMatch } from "../../../../core/RegistrationCeremonyStore.js";
|
|
32
32
|
import { parseStoredRouterAbEcdsaPendingActivationV1 } from "../../../domains/ecdsa/routerAbEcdsaStrictRegistration.js";
|
|
33
33
|
//#region src/router/cloudflare/d1/registration/d1RegistrationCeremonyRecords.ts
|
|
@@ -49,6 +49,7 @@ function buildRegistrationIntent(input) {
|
|
|
49
49
|
const foundingWalletAuthMethodId = input.foundingWalletAuthMethodId;
|
|
50
50
|
if (input.runtimePolicyScope) return {
|
|
51
51
|
version: "registration_intent_v1",
|
|
52
|
+
completion: input.completion,
|
|
52
53
|
walletId: input.walletId,
|
|
53
54
|
authMethod: input.authMethod,
|
|
54
55
|
signerSelection: input.signerSelection,
|
|
@@ -58,6 +59,7 @@ function buildRegistrationIntent(input) {
|
|
|
58
59
|
};
|
|
59
60
|
return {
|
|
60
61
|
version: "registration_intent_v1",
|
|
62
|
+
completion: input.completion,
|
|
61
63
|
walletId: input.walletId,
|
|
62
64
|
authMethod: input.authMethod,
|
|
63
65
|
signerSelection: input.signerSelection,
|
|
@@ -139,6 +141,7 @@ function parseD1RegistrationIntent(raw) {
|
|
|
139
141
|
if (record.runtimePolicyScope !== void 0 && !runtimePolicyScope) return null;
|
|
140
142
|
if (runtimePolicyScope) return {
|
|
141
143
|
version: "registration_intent_v1",
|
|
144
|
+
completion: parsePersistedRegistrationCompletion(record.completion),
|
|
142
145
|
walletId,
|
|
143
146
|
authMethod,
|
|
144
147
|
signerSelection: signerSelection.value,
|
|
@@ -148,6 +151,7 @@ function parseD1RegistrationIntent(raw) {
|
|
|
148
151
|
};
|
|
149
152
|
return {
|
|
150
153
|
version: "registration_intent_v1",
|
|
154
|
+
completion: parsePersistedRegistrationCompletion(record.completion),
|
|
151
155
|
walletId,
|
|
152
156
|
authMethod,
|
|
153
157
|
signerSelection: signerSelection.value,
|
|
@@ -2046,6 +2050,11 @@ function safeInteger(raw) {
|
|
|
2046
2050
|
function unreachableAddAuthMethodInput(value) {
|
|
2047
2051
|
throw new Error(`Unhandled add-auth-method input kind: ${String(value)}`);
|
|
2048
2052
|
}
|
|
2053
|
+
function parsePersistedRegistrationCompletion(raw) {
|
|
2054
|
+
if (raw === void 0 || raw === "wallet_session") return "wallet_session";
|
|
2055
|
+
if (raw === "owner_operations") return "owner_operations";
|
|
2056
|
+
throw new Error("Stored registration completion is invalid");
|
|
2057
|
+
}
|
|
2049
2058
|
//#endregion
|
|
2050
2059
|
export { buildAddAuthMethodIntent, buildAddSignerIntent, buildD1EcdsaWalletKeysFromBootstrap, buildD1WalletEcdsaSignerRecords, buildD1WalletRecord, buildRegistrationIntent, deriveEvmFamilySigningKeySlotId, inferRuntimePolicyScopeFromSigningRoot, intentScopeMetadata, normalizeThresholdEcdsaChainTargets, parseD1AddSignerIntent, parseD1EcdsaDerivationServerBootstrapResponse, parseD1RuntimePolicyScope, parseD1StoredAddAuthMethodIntent, parseD1StoredAddSignerAuth, parseD1StoredAddSignerIntent, parseD1StoredWalletAddAuthMethodCeremony, parseD1StoredWalletAddAuthMethodFinalizeReplay, parseD1StoredWalletAddSignerCeremony, parseD1StoredWalletAddSignerFinalizeReplay, parseD1StoredWalletRegistrationCeremony, parseD1WalletAddSignerFinalizeTerminalResponse, parseD1WalletRegistrationCommittedInstallationProjection, parseD1WalletRegistrationFinalizeReplayResponse, parseWalletIdForIntent, positiveIntegerArraysEqual, runtimePolicyScopeMatches, thresholdEcdsaChainTargetsEqual };
|
|
2051
2060
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { parseWalletAuthMethodId } from "../../../../shared-ts/src/utils/domainIds.js";
|
|
2
2
|
import { normalizeOptionalTrimmedString } from "../../../../shared-ts/src/utils/normalize.js";
|
|
3
|
+
import { failure } from "../../../../shared-ts/src/utils/failure.js";
|
|
3
4
|
import { normalizeAddAuthMethodInput } from "../../../../shared-ts/src/utils/registrationAuthMethodInput.js";
|
|
4
5
|
import { secureRandomBase64Url } from "../../../../shared-ts/src/utils/secureRandomId.js";
|
|
5
|
-
import { failure } from "../../../../shared-ts/src/utils/failure.js";
|
|
6
6
|
import { thresholdEcdsaChainTargetFromValue } from "../../../../core/thresholdEcdsaChainTarget.js";
|
|
7
7
|
import { normalizeAddSignerSelection } from "../../../../shared-ts/src/utils/registrationSignerPlan.js";
|
|
8
8
|
import { addAuthMethodIntentGrantFromString, addSignerIntentGrantFromString, computeAddAuthMethodIntentDigestB64u, computeAddSignerIntentDigestB64u } from "../../../../shared-ts/src/utils/registrationIntent.js";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { D1_BATCH_CAS_GUARD_SQL } from "../../../../storage/d1Sql.js";
|
|
2
2
|
import { prepareD1TenantStatement } from "../../../../core/d1TenantStore.js";
|
|
3
|
+
import { parseRegistrationSessionPublication } from "../../../domains/walletRegistration/walletRegistrationReservation.js";
|
|
3
4
|
//#region src/router/cloudflare/d1/registration/d1WalletExecutionAuthority.ts
|
|
4
5
|
/** The finalize response normally delivers first; the scheduled resumption waits this long. */
|
|
5
6
|
const DIRECTORY_PUBLICATION_FIRST_RETRY_MS = 6e4;
|
|
@@ -91,20 +92,18 @@ var D1WalletExecutionAuthority = class {
|
|
|
91
92
|
const publication = {
|
|
92
93
|
walletId: input.registration.walletId,
|
|
93
94
|
ceremonyId: input.registration.ceremonyId,
|
|
94
|
-
|
|
95
|
-
expiresAtMs: input.session.expiresAtMs,
|
|
95
|
+
session: input.session,
|
|
96
96
|
attempts: 0
|
|
97
97
|
};
|
|
98
98
|
return {
|
|
99
99
|
statements: [...this.prepareState(input.registration, "active"), prepareD1TenantStatement(this.database, this.scope, `INSERT INTO wallet_registration_directory_publications
|
|
100
100
|
(namespace, org_id, project_id, env_id, wallet_id, ceremony_id,
|
|
101
|
-
|
|
102
|
-
VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8
|
|
101
|
+
session_json, next_attempt_at_ms)
|
|
102
|
+
VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8)
|
|
103
103
|
ON CONFLICT DO NOTHING`, [
|
|
104
104
|
publication.walletId,
|
|
105
105
|
publication.ceremonyId,
|
|
106
|
-
publication.
|
|
107
|
-
publication.expiresAtMs,
|
|
106
|
+
JSON.stringify(publication.session),
|
|
108
107
|
Date.now() + DIRECTORY_PUBLICATION_FIRST_RETRY_MS
|
|
109
108
|
])],
|
|
110
109
|
publish: async () => {
|
|
@@ -118,7 +117,7 @@ var D1WalletExecutionAuthority = class {
|
|
|
118
117
|
}
|
|
119
118
|
/** Sends the publications that are due, oldest first, one at a time. */
|
|
120
119
|
async resumeDirectoryPublications(input) {
|
|
121
|
-
const due = await prepareD1TenantStatement(this.database, this.scope, `SELECT wallet_id, ceremony_id,
|
|
120
|
+
const due = await prepareD1TenantStatement(this.database, this.scope, `SELECT wallet_id, ceremony_id, session_json, attempts
|
|
122
121
|
FROM wallet_registration_directory_publications
|
|
123
122
|
WHERE namespace = ?1 AND org_id = ?2 AND project_id = ?3 AND env_id = ?4
|
|
124
123
|
AND state = 'pending' AND next_attempt_at_ms <= ?5
|
|
@@ -133,8 +132,7 @@ var D1WalletExecutionAuthority = class {
|
|
|
133
132
|
const outcome = await this.deliver({
|
|
134
133
|
walletId: row.wallet_id,
|
|
135
134
|
ceremonyId: row.ceremony_id,
|
|
136
|
-
|
|
137
|
-
expiresAtMs: row.session_expires_at_ms,
|
|
135
|
+
session: parseRegistrationSessionPublication(JSON.parse(row.session_json), row.wallet_id),
|
|
138
136
|
attempts: row.attempts
|
|
139
137
|
});
|
|
140
138
|
delivered[outcome] += 1;
|
|
@@ -148,12 +146,7 @@ var D1WalletExecutionAuthority = class {
|
|
|
148
146
|
ceremonyId: publication.ceremonyId,
|
|
149
147
|
walletId: publication.walletId,
|
|
150
148
|
outcome: "established",
|
|
151
|
-
session:
|
|
152
|
-
kind: "credential",
|
|
153
|
-
walletId: publication.walletId,
|
|
154
|
-
digest: publication.digest,
|
|
155
|
-
expiresAtMs: publication.expiresAtMs
|
|
156
|
-
}
|
|
149
|
+
session: publication.session
|
|
157
150
|
});
|
|
158
151
|
} catch (error) {
|
|
159
152
|
console.warn("[wallet-registration] directory publication deferred", error);
|
|
@@ -194,7 +187,7 @@ var D1WalletExecutionAuthority = class {
|
|
|
194
187
|
}
|
|
195
188
|
/** The state update with its guard. The guard reads the row count of the update before it. */
|
|
196
189
|
prepareState(input, state) {
|
|
197
|
-
return [prepareD1TenantStatement(this.database, this.scope, `UPDATE wallet_execution_generations SET state = ?7
|
|
190
|
+
return [prepareD1TenantStatement(this.database, this.scope, `UPDATE wallet_execution_generations SET state = ?7, registration_completion = CASE WHEN ?7 = 'active' THEN 'established' ELSE registration_completion END
|
|
198
191
|
WHERE namespace = ?1 AND org_id = ?2 AND project_id = ?3 AND env_id = ?4
|
|
199
192
|
AND wallet_id = ?5 AND origin = 'registration' AND origin_id = ?6
|
|
200
193
|
AND state IN ('registering', ?7)`, [
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { mpcMaterialActivationRefsEqual, parseWalletAuthMethodId, parseWalletAuthorityId, parseWalletId } from "../../../../shared-ts/src/utils/domainIds.js";
|
|
2
2
|
import { normalizeOptionalTrimmedString } from "../../../../shared-ts/src/utils/normalize.js";
|
|
3
|
+
import { parseD1JsonColumn } from "../../../../storage/d1Sql.js";
|
|
3
4
|
import { parseWalletAuthMethodRecordV2, sameWalletAuthMethodRecordV2 } from "../../../../shared-ts/src/utils/walletAuthMethodRecord.js";
|
|
4
5
|
import { parseWalletAuthorityV1 } from "../../../../shared-ts/src/authorization/walletAuthority.js";
|
|
5
6
|
import { buildWalletSessionCapabilitySubjectsV1 } from "../../../../authorization/domain.js";
|
|
6
|
-
import { parseD1JsonColumn } from "../../../../storage/d1Sql.js";
|
|
7
7
|
import { prepareD1WalletPutSignerStatement, prepareD1WalletPutSubjectStatement } from "../../../../core/d1WalletStore.js";
|
|
8
8
|
import { prepareD1WalletAuthMethodV2PutStatement } from "../../../../core/d1WalletAuthMethodStore.js";
|
|
9
9
|
import { reservePasskeyCredential } from "../../../../core/passkeyCredentialClaims.js";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { mpcMaterialActivationRefsEqual, parseThresholdEd25519SessionId, parseWalletKeyId, parseWebAuthnCredentialIdB64u } from "../../../../shared-ts/src/utils/domainIds.js";
|
|
2
|
-
import { parseWalletSessionMintId } from "../../../../shared-ts/src/authorization/capabilityKinds.js";
|
|
3
2
|
import { normalizeOptionalTrimmedString } from "../../../../shared-ts/src/utils/normalize.js";
|
|
4
|
-
import { buildFullOwnerPermissionsV1 } from "../../../../shared-ts/src/authorization/delegatedAuthority.js";
|
|
5
3
|
import { base64UrlDecode, base64UrlEncode } from "../../../../shared-ts/src/utils/base64.js";
|
|
6
4
|
import { alphabetizeStringify, bytesToUnprefixedHex, sha256BytesUtf8 } from "../../../../shared-ts/src/utils/digests.js";
|
|
7
5
|
import { parseDigestB64u } from "../../../../shared-ts/src/utils/canonicalPrimitives.js";
|
|
8
6
|
import { parseEd25519PublicKeyB64u, parseSecp256k1CompressedPublicKeyB64u } from "../../../../shared-ts/src/passkey-custody/primitives.js";
|
|
9
7
|
import "../../../../shared-ts/src/utils/encoders.js";
|
|
8
|
+
import { parseWalletSessionMintId } from "../../../../shared-ts/src/authorization/capabilityKinds.js";
|
|
9
|
+
import { buildFullOwnerPermissionsV1 } from "../../../../shared-ts/src/authorization/delegatedAuthority.js";
|
|
10
10
|
import { buildExactAdministeredSignerManifestV1 } from "../../../../shared-ts/src/device-linking/delegatedActivationPlan.js";
|
|
11
11
|
import { routerAbMpcMaterialActivationRefFromWire, routerAbMpcMaterialActivationRefToWire, sameRouterAbMpcMaterialActivationRef } from "../../../../shared-ts/src/utils/routerAbNormalSigningIdentity.js";
|
|
12
12
|
import { deriveRouterAbEd25519YaoRuntimePolicyBindingV1 } from "../../../../shared-ts/src/utils/routerAbEd25519YaoDigests.js";
|
|
@@ -17,6 +17,7 @@ import { isEmailOtpWalletAuthAuthority, isPasskeyWalletAuthAuthority, walletAuth
|
|
|
17
17
|
import { ROUTER_AB_ECDSA_DERIVATION_NORMAL_SIGNING_STATE_KIND_V1, buildRouterAbEcdsaDerivationActiveStateIdV1, buildRouterAbEcdsaDerivationPublicCapabilityV1, parseRouterAbEcdsaDerivationNormalSigningStateV1, sameRouterAbEcdsaDerivationNormalSigningStateV1, sameRouterAbEcdsaDerivationPublicCapabilityV1, sameRouterAbEcdsaRegistrationActivationReceiptV1, sameRouterAbEcdsaVerifiedClientActivationFactsV1, sameRouterAbPublicDigest32V1Wire } from "../../../../shared-ts/src/utils/routerAbEcdsaDerivation.js";
|
|
18
18
|
import { buildWalletAuthMethodRecordV2 } from "../../../../shared-ts/src/utils/walletAuthMethodRecord.js";
|
|
19
19
|
import { buildActiveWalletAuthorityV1, buildWalletSignerActivationSetV1, computeWalletAuthorityDigestB64u, computeWalletSignerActivationSetDigestB64u, extendEcdsaWalletAuthorityWithEd25519, isActiveEcdsaWalletAuthorityV1 } from "../../../../shared-ts/src/authorization/walletAuthority.js";
|
|
20
|
+
import { createRouterAbTraceContextV1 } from "../../../../shared-ts/src/utils/routerAbTraceContext.js";
|
|
20
21
|
import { ROUTER_AB_ED25519_NORMAL_SIGNING_STATE_KIND } from "../../../../shared-ts/src/utils/signingSessionSeal.js";
|
|
21
22
|
import { normalizeThresholdEd25519ParticipantIds } from "../../../../shared-ts/src/threshold/participants.js";
|
|
22
23
|
import { nearEd25519SigningKeyIdFromString, registrationEd25519AuthorityScopeFromAuthority, walletIdFromString } from "../../../../shared-ts/src/utils/registrationIds.js";
|
|
@@ -27,7 +28,6 @@ import "../../../../shared-ts/src/passkey-custody/index.js";
|
|
|
27
28
|
import { parseImplicitNearAccountId, parseNamedNearAccountId } from "../../../../shared-ts/src/utils/near.js";
|
|
28
29
|
import { registrationNearEd25519BranchKey } from "../../../../shared-ts/src/utils/registrationSignerPlan.js";
|
|
29
30
|
import { registrationIntentGrantFromString } from "../../../../shared-ts/src/utils/registrationIntent.js";
|
|
30
|
-
import { createRouterAbTraceContextV1 } from "../../../../shared-ts/src/utils/routerAbTraceContext.js";
|
|
31
31
|
import { buildTenantRootIdentityFromAuthenticatedDeploymentV1 } from "../../../../shared-ts/src/tenant-root/tenantRootIdentity.js";
|
|
32
32
|
import { DEFAULT_WALLET_SESSION_TTL_MS } from "../../../../shared-ts/src/threshold/sessionPolicy.js";
|
|
33
33
|
import { parseEcdsaDerivationPublicIdentity, thresholdEd25519AuthorityScopeFromWalletAuthAuthority } from "../../../../core/ThresholdService/validation.js";
|
|
@@ -2167,7 +2167,13 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
2167
2167
|
expectedOrigin: ownerProofContext.expectedOrigin,
|
|
2168
2168
|
expiresAtMs: args.input.authorization.kind === "wallet_session" ? args.setupClaims.expiresAtMs : ownerProofContext.expiresAtMs
|
|
2169
2169
|
});
|
|
2170
|
-
const
|
|
2170
|
+
const completion = source.kind === "stored_ceremony" ? source.ceremony.intent.completion : "wallet_session";
|
|
2171
|
+
if (completion === "owner_operations" && args.input.onSessionCommitted) return unissuedRegistrationCommit({
|
|
2172
|
+
ok: false,
|
|
2173
|
+
code: "invalid_body",
|
|
2174
|
+
message: "Owner-operation registration cannot seal a Wallet Session"
|
|
2175
|
+
});
|
|
2176
|
+
const initialSessionPlan = completion === "wallet_session" && sessionPredecessor.kind === "ed25519_only" && !registrationSignerBranchesFromPlan(source.ceremony.signerPlan).evmFamilyEcdsa ? {
|
|
2171
2177
|
kind: "initial_near",
|
|
2172
2178
|
store: this.registrationSessionStore,
|
|
2173
2179
|
request: {
|
|
@@ -2202,6 +2208,31 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
2202
2208
|
message: "NEAR provisioning committed a non-NEAR branch"
|
|
2203
2209
|
});
|
|
2204
2210
|
}
|
|
2211
|
+
if (completion === "owner_operations") {
|
|
2212
|
+
if (!this.registrationAuthority) throw new Error("Registration home completion is unavailable");
|
|
2213
|
+
const custody = await execution.custody;
|
|
2214
|
+
return {
|
|
2215
|
+
kind: "owner_registered",
|
|
2216
|
+
expectedOrigin: ownerProofContext.expectedOrigin,
|
|
2217
|
+
response: {
|
|
2218
|
+
...finalized,
|
|
2219
|
+
walletCustody: custody.outcome,
|
|
2220
|
+
registrationEstablishedSession: {
|
|
2221
|
+
kind: "owner_operations",
|
|
2222
|
+
walletId: finalized.walletId
|
|
2223
|
+
}
|
|
2224
|
+
},
|
|
2225
|
+
custodyWrite: custody.kind === "prepared" ? custody.write : null,
|
|
2226
|
+
activation: this.registrationAuthority.prepareEstablished({
|
|
2227
|
+
registration: {
|
|
2228
|
+
ceremonyId: args.input.registrationCeremonyId,
|
|
2229
|
+
walletId: finalized.walletId,
|
|
2230
|
+
state: "registering"
|
|
2231
|
+
},
|
|
2232
|
+
session: { kind: "none" }
|
|
2233
|
+
})
|
|
2234
|
+
};
|
|
2235
|
+
}
|
|
2205
2236
|
if (!this.registrationAuthority) throw new Error("Registration home completion is unavailable");
|
|
2206
2237
|
const [issuance, custody] = await Promise.allSettled([recordRegistrationPromiseTiming({
|
|
2207
2238
|
sink: args.serverTiming,
|
|
@@ -2306,6 +2337,16 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
2306
2337
|
async replayWalletRegistrationNearProvisioningCommit(receipt) {
|
|
2307
2338
|
if (receipt.operation !== "near_provisioning") throw new Error("Registration NEAR provisioning receipt operation is invalid");
|
|
2308
2339
|
if (receipt.committed.kind === "error") return replayedRegistrationCommit(receipt.committed.error);
|
|
2340
|
+
if (receipt.committed.kind === "near_owner_ready") {
|
|
2341
|
+
const response = receipt.committed.response;
|
|
2342
|
+
return replayedRegistrationCommit({
|
|
2343
|
+
...response,
|
|
2344
|
+
registrationEstablishedSession: {
|
|
2345
|
+
kind: "owner_operations",
|
|
2346
|
+
walletId: response.walletId
|
|
2347
|
+
}
|
|
2348
|
+
});
|
|
2349
|
+
}
|
|
2309
2350
|
if (receipt.committed.kind !== "near_ready") throw new Error("Registration NEAR provisioning receipt branch is invalid");
|
|
2310
2351
|
if (!isRegistrationNearReadyReceipt(receipt)) throw new Error("Registration NEAR provisioning receipt branch is invalid");
|
|
2311
2352
|
const authMethod = registrationReplayAuthMethodFields(receipt);
|
|
@@ -2530,6 +2571,7 @@ var CloudflareD1WalletRegistrationService = class {
|
|
|
2530
2571
|
nowMs: Date.now()
|
|
2531
2572
|
})
|
|
2532
2573
|
}), waitUntil ? void 0 : cleanup]);
|
|
2574
|
+
if (committed.registrationEstablishedSession.kind === "owner_operations") throw new Error("A Wallet Session continuation cannot complete owner-only registration");
|
|
2533
2575
|
const tokens = committed.registrationEstablishedSession.session.tokens;
|
|
2534
2576
|
if (!current || tokens.kind !== "near_ed25519_and_evm_family_ecdsa") throw new Error("NEAR continuation Wallet Session is no longer active");
|
|
2535
2577
|
recordRegistrationServerTiming(serverTiming, "near_finalize_total", totalStartedAtMs);
|
|
@@ -51,8 +51,20 @@ function normalizeWalletRegistrationSetupRequest(request) {
|
|
|
51
51
|
code: "invalid_body",
|
|
52
52
|
message: "authMethod is required"
|
|
53
53
|
};
|
|
54
|
+
const completion = request.completion;
|
|
55
|
+
if (completion !== "wallet_session" && completion !== "owner_operations") return {
|
|
56
|
+
ok: false,
|
|
57
|
+
code: "invalid_body",
|
|
58
|
+
message: "Registration completion is required"
|
|
59
|
+
};
|
|
60
|
+
if (completion === "owner_operations" && (signerSelection.value.signers.length !== 1 || signerSelection.value.signers[0]?.kind !== "near_ed25519" || authMethod.kind !== "passkey")) return {
|
|
61
|
+
ok: false,
|
|
62
|
+
code: "invalid_body",
|
|
63
|
+
message: "Owner-operation onboarding requires a NEAR-only wallet and a wallet-origin passkey"
|
|
64
|
+
};
|
|
54
65
|
return {
|
|
55
66
|
ok: true,
|
|
67
|
+
completion,
|
|
56
68
|
signerSelection: signerSelection.value,
|
|
57
69
|
authMethod
|
|
58
70
|
};
|
|
@@ -97,6 +97,7 @@ async function completeReservedRegistrationSetup(input, dependencies, admitted,
|
|
|
97
97
|
if (!signingRootId) return walletRegistrationSetupError("invalid_body", "registration requires a signing root");
|
|
98
98
|
const registrationOperation = reservation;
|
|
99
99
|
const intent = buildRegistrationIntent({
|
|
100
|
+
completion: normalized.completion,
|
|
100
101
|
nonceB64u: registrationCeremonyId.slice(4),
|
|
101
102
|
walletId: wallet.walletId,
|
|
102
103
|
authMethod: normalized.authMethod,
|
|
@@ -4,6 +4,7 @@ function registrationCommitCompletionWrite(execution) {
|
|
|
4
4
|
switch (execution.kind) {
|
|
5
5
|
case "unissued":
|
|
6
6
|
case "replayed": return null;
|
|
7
|
+
case "owner_registered":
|
|
7
8
|
case "session_issued":
|
|
8
9
|
case "session_issued_with_installation_projection":
|
|
9
10
|
if (!execution.custodyWrite) return execution.activation;
|
package/dist/esm/router/cloudflare/d1/registration/walletRegistrationEstablishedSessionIssuer.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { mpcMaterialActivationRefsEqual, parseEmailOtpChallengeId, parseThresholdEcdsaSessionId, parseThresholdEd25519SessionId, parseWebAuthnCredentialIdB64u } from "../../../../shared-ts/src/utils/domainIds.js";
|
|
2
|
-
import { parseAuthFactorId, parsePrincipalId } from "../../../../shared-ts/src/authorization/capabilityKinds.js";
|
|
3
2
|
import { base64UrlEncode } from "../../../../shared-ts/src/utils/base64.js";
|
|
4
3
|
import { alphabetizeStringify, sha256BytesUtf8 } from "../../../../shared-ts/src/utils/digests.js";
|
|
5
4
|
import { parseDigestB64u } from "../../../../shared-ts/src/utils/canonicalPrimitives.js";
|
|
6
5
|
import "../../../../shared-ts/src/utils/encoders.js";
|
|
6
|
+
import { parseAuthFactorId, parsePrincipalId } from "../../../../shared-ts/src/authorization/capabilityKinds.js";
|
|
7
7
|
import { routerAbMpcMaterialActivationRefFromWire } from "../../../../shared-ts/src/utils/routerAbNormalSigningIdentity.js";
|
|
8
8
|
import { isEmailOtpWalletAuthAuthority, walletAuthAuthorityRef } from "../../../../shared-ts/src/utils/walletAuthAuthority.js";
|
|
9
9
|
import { parseSessionOrigin, parseVerifiedOwnerProofId } from "../../../../authorization/domain.js";
|
package/dist/esm/router/cloudflare/d1/registration/walletRegistrationSessionCommitReceipt.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { parseWalletAuthMethodId, parseWalletId } from "../../../../shared-ts/src/utils/domainIds.js";
|
|
2
|
-
import { parseWalletSessionMintId } from "../../../../shared-ts/src/authorization/capabilityKinds.js";
|
|
3
2
|
import { parseDigestB64u } from "../../../../shared-ts/src/utils/canonicalPrimitives.js";
|
|
3
|
+
import { parseWalletSessionMintId } from "../../../../shared-ts/src/authorization/capabilityKinds.js";
|
|
4
4
|
import { parseWalletAuthAuthority } from "../../../../shared-ts/src/utils/walletAuthAuthority.js";
|
|
5
5
|
import { parseWalletAuthMethodRecordV2 } from "../../../../shared-ts/src/utils/walletAuthMethodRecord.js";
|
|
6
6
|
import { parseWalletAuthorityV1 } from "../../../../shared-ts/src/authorization/walletAuthority.js";
|
|
@@ -12,6 +12,7 @@ import "../../../../shared-ts/src/passkey-custody/index.js";
|
|
|
12
12
|
/** The home activation that a commit left for the record that completes its operation. */
|
|
13
13
|
function registrationCommitActivation(execution) {
|
|
14
14
|
switch (execution.kind) {
|
|
15
|
+
case "owner_registered":
|
|
15
16
|
case "session_issued":
|
|
16
17
|
case "session_issued_with_installation_projection": return execution.activation;
|
|
17
18
|
case "unissued":
|
|
@@ -45,6 +46,7 @@ function projectRegistrationEstablishedSessionV2(session) {
|
|
|
45
46
|
}
|
|
46
47
|
function projectRegistrationEstablishedSessionResultV2(result) {
|
|
47
48
|
switch (result.kind) {
|
|
49
|
+
case "owner_operations": throw new Error("Owner registration has no session projection");
|
|
48
50
|
case "issued": return projectRegistrationEstablishedSessionV2(result.session);
|
|
49
51
|
case "already_committed": return result.session;
|
|
50
52
|
default: return assertNeverRegistrationSessionResult(result);
|
|
@@ -55,6 +57,21 @@ function assertNeverRegistrationSessionResult(value) {
|
|
|
55
57
|
}
|
|
56
58
|
function projectWalletRegistrationSessionCommitReceiptV2(input) {
|
|
57
59
|
const response = input.execution.response;
|
|
60
|
+
if (input.execution.kind === "owner_registered") {
|
|
61
|
+
if (input.operation !== "near_provisioning" || !response.ok || response.kind !== "near_ed25519" || !("registrationEstablishedSession" in response) || response.registrationEstablishedSession.kind !== "owner_operations") throw new Error("Invalid owner registration receipt");
|
|
62
|
+
const { registrationEstablishedSession, ...finalized } = response;
|
|
63
|
+
return {
|
|
64
|
+
kind: "wallet_registration_session_commit_receipt_v2",
|
|
65
|
+
operation: "near_provisioning",
|
|
66
|
+
operationFingerprint: input.operationFingerprint,
|
|
67
|
+
registrationCeremonyId: input.registrationCeremonyId,
|
|
68
|
+
committed: {
|
|
69
|
+
kind: "near_owner_ready",
|
|
70
|
+
expectedOrigin: input.execution.expectedOrigin,
|
|
71
|
+
response: finalized
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
58
75
|
if (!response.ok) {
|
|
59
76
|
if (input.execution.kind !== "unissued") throw new Error("Registration error receipt has an issued-session marker");
|
|
60
77
|
return {
|
|
@@ -208,6 +225,24 @@ function parseWalletRegistrationSessionCommitReceiptV2(raw, parseCommitted) {
|
|
|
208
225
|
}
|
|
209
226
|
};
|
|
210
227
|
}
|
|
228
|
+
if (committedRecord.kind === "near_owner_ready") {
|
|
229
|
+
if (operation !== "near_provisioning" || !hasExactKeys(record, [
|
|
230
|
+
"kind",
|
|
231
|
+
"operation",
|
|
232
|
+
"operationFingerprint",
|
|
233
|
+
"registrationCeremonyId",
|
|
234
|
+
"committed"
|
|
235
|
+
])) return null;
|
|
236
|
+
const committed = parseCommitted(record.committed);
|
|
237
|
+
if (!committed || committed.kind !== "near_owner_ready") return null;
|
|
238
|
+
return {
|
|
239
|
+
kind: "wallet_registration_session_commit_receipt_v2",
|
|
240
|
+
operation,
|
|
241
|
+
operationFingerprint,
|
|
242
|
+
registrationCeremonyId,
|
|
243
|
+
committed
|
|
244
|
+
};
|
|
245
|
+
}
|
|
211
246
|
const walletId = parseWalletId(record.walletId);
|
|
212
247
|
const walletAuthMethodId = parseWalletAuthMethodId(record.walletAuthMethodId);
|
|
213
248
|
const authority = parseWalletAuthAuthority(record.authority);
|
package/dist/esm/router/cloudflare/d1/signingAdmission/d1RouterAbNormalSigningAdmissionStore.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isPlainObject, requireNonEmptyString } from "../../../../shared-ts/src/utils/validation.js";
|
|
2
|
-
import { normalizeRuntimePolicyScope } from "../../../../shared-ts/src/threshold/signingRootScope.js";
|
|
3
2
|
import { isD1DatabaseLike, parseD1JsonColumn } from "../../../../storage/d1Sql.js";
|
|
3
|
+
import { normalizeRuntimePolicyScope } from "../../../../shared-ts/src/threshold/signingRootScope.js";
|
|
4
4
|
import { ED25519_SIGNER_ACTIVATION_ID_PATH } from "../../../../core/d1WalletStore.js";
|
|
5
5
|
import { abusePrincipalKey, runtimePolicyScopeKey } from "../../../domains/signingOperations/routerAbNormalSigningAdmissionCore.js";
|
|
6
6
|
//#region src/router/cloudflare/d1/signingAdmission/d1RouterAbNormalSigningAdmissionStore.ts
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { parseWalletSessionMintId } from "../../../../shared-ts/src/authorization/capabilityKinds.js";
|
|
2
1
|
import { alphabetizeStringify } from "../../../../shared-ts/src/utils/digests.js";
|
|
3
2
|
import { parseDigestB64u } from "../../../../shared-ts/src/utils/canonicalPrimitives.js";
|
|
3
|
+
import { d1ChangedRows, parseD1JsonColumn } from "../../../../storage/d1Sql.js";
|
|
4
|
+
import { parseWalletSessionMintId } from "../../../../shared-ts/src/authorization/capabilityKinds.js";
|
|
4
5
|
import { buildVoiceIdWalletSessionChallenge, parseVoiceIdWalletSessionChallenge } from "../../../../shared-ts/src/authorization/voiceIdDeviceAssertion.js";
|
|
5
6
|
import { secureRandomBase64Url } from "../../../../shared-ts/src/utils/secureRandomId.js";
|
|
6
|
-
import { d1ChangedRows, parseD1JsonColumn } from "../../../../storage/d1Sql.js";
|
|
7
7
|
//#region src/router/cloudflare/d1/wallet/d1VoiceIdWalletSessionChallenges.ts
|
|
8
8
|
const CHALLENGE_LIFETIME_MS = 6e4;
|
|
9
9
|
const EXPIRY_CLEANUP_LIMIT = 64;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { sha256HexUtf8 } from "../../../../shared-ts/src/utils/digests.js";
|
|
2
2
|
import { buildEmailOtpWalletAuthAuthority, buildPasskeyWalletAuthAuthority, walletAuthAuthorityRef } from "../../../../shared-ts/src/utils/walletAuthAuthority.js";
|
|
3
|
+
import { EMAIL_OTP_CHANNEL, WALLET_EMAIL_OTP_ACTIONS, WALLET_EMAIL_OTP_TRANSACTION_SIGN_OPERATION } from "../../../../shared-ts/src/utils/emailOtpDomain.js";
|
|
3
4
|
import { webAuthnCredentialIdB64uFromCredential } from "../../../auth/webAuthnCredentialCodecs.js";
|
|
4
5
|
import { hashEmailOtpOperationBinding } from "../../../domains/emailOtp/emailOtpSessionRouteHelpers.js";
|
|
5
|
-
import { EMAIL_OTP_CHANNEL, WALLET_EMAIL_OTP_ACTIONS, WALLET_EMAIL_OTP_TRANSACTION_SIGN_OPERATION } from "../../../../shared-ts/src/utils/emailOtpDomain.js";
|
|
6
6
|
//#region src/router/cloudflare/d1/wallet/d1WalletAuthMethodBoundary.ts
|
|
7
7
|
function walletRegistrationFinalizeAuthMethodFromAuthority(authority) {
|
|
8
8
|
switch (authority.kind) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { base64UrlEncode } from "../../../../shared-ts/src/utils/base64.js";
|
|
2
2
|
import { alphabetizeStringify, sha256BytesUtf8 } from "../../../../shared-ts/src/utils/digests.js";
|
|
3
3
|
import "../../../../shared-ts/src/utils/encoders.js";
|
|
4
|
-
import { parseLinkedDeviceRevokeResultV1 } from "../../../../shared-ts/src/device-linking/deviceManagement.js";
|
|
5
4
|
import { D1_BATCH_CAS_GUARD_SQL } from "../../../../storage/d1Sql.js";
|
|
5
|
+
import { parseLinkedDeviceRevokeResultV1 } from "../../../../shared-ts/src/device-linking/deviceManagement.js";
|
|
6
6
|
//#region src/router/cloudflare/d1/wallet/d1WalletAuthMethodRevocationReplayStore.ts
|
|
7
7
|
const REVOCATION_PROOF_DIGEST_DOMAIN_V1 = "seams/wallet-auth-method-revocation-proof/v1";
|
|
8
8
|
/**
|