@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.
Files changed (182) hide show
  1. package/README.md +19 -4
  2. package/artifact-manifest.json +28 -13
  3. package/cloudflare-router-ab/build/deriver-a/build-stamp.json +1 -1
  4. package/cloudflare-router-ab/build/deriver-b/build-stamp.json +1 -1
  5. package/cloudflare-router-ab/build/router/build-stamp.json +1 -1
  6. package/cloudflare-router-ab/build/signing-worker/build-stamp.json +1 -1
  7. package/cloudflare-router-ab/build/tenant-root-control-plane/build-stamp.json +1 -1
  8. package/dist/esm/application-auth.js +2 -0
  9. package/dist/esm/auth/applicationAuth.js +85 -0
  10. package/dist/esm/auth/externalAuthService.js +149 -0
  11. package/dist/esm/auth/externalAuthStore.js +353 -0
  12. package/dist/esm/auth/externalOwnerOperations.js +82 -0
  13. package/dist/esm/authorization/domain.js +2 -2
  14. package/dist/esm/authorization/factorEvidence.js +1 -1
  15. package/dist/esm/authorization/service.js +2 -2
  16. package/dist/esm/authorization/vaultProxyUse.js +1 -1
  17. package/dist/esm/cloud-host.js +12 -11
  18. package/dist/esm/core/ThresholdService/validation.js +1 -1
  19. package/dist/esm/core/WebAuthnCredentialBindingStore.js +1 -1
  20. package/dist/esm/core/authService/webauthn.js +1 -1
  21. package/dist/esm/core/d1EcdsaSignerRead.js +1 -1
  22. package/dist/esm/core/d1WalletAuthMethodStore.js +2 -2
  23. package/dist/esm/core/d1WalletStore.js +1 -1
  24. package/dist/esm/core/deviceLinking/linkedDeviceEmailOtpGrant.js +1 -1
  25. package/dist/esm/core/deviceLinking/linkedDeviceManagement.js +1 -1
  26. package/dist/esm/core/deviceLinking/linkedDeviceSessionRecord.js +2 -2
  27. package/dist/esm/core/nearRelayerAccountProvisioning.js +2 -2
  28. package/dist/esm/hosted-wallet-gateway.js +3 -3
  29. package/dist/esm/index.js +1 -1
  30. package/dist/esm/router/auth/webAuthnCredentialCodecs.js +1 -1
  31. package/dist/esm/router/cloudflare/d1/auth/d1AuthorizedOperationRouteService.js +2 -0
  32. package/dist/esm/router/cloudflare/d1/auth/d1RecordedOwnerOperation.js +43 -0
  33. package/dist/esm/router/cloudflare/d1/auth/d1RouterApiAuthService.js +27 -3
  34. package/dist/esm/router/cloudflare/d1/authorization/d1AuthorizationStore.js +2 -2
  35. package/dist/esm/router/cloudflare/d1/authorization/d1VaultProxyStore.js +2 -2
  36. package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceAuthorityInstallService.js +3 -3
  37. package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceEd25519ExportRootStore.js +1 -1
  38. package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceOwnerAuthorizationProvider.js +2 -2
  39. package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceSessionStore.js +1 -1
  40. package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceSourceContributionPreparationPlanner.js +1 -1
  41. package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceTargetAuthenticatorStore.js +1 -1
  42. package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceTargetCredentialProvider.js +1 -1
  43. package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceTargetPlanner.js +1 -1
  44. package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceVerifiedLinkBuilder.js +2 -2
  45. package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceVerifiedLinkSourceReader.js +1 -1
  46. package/dist/esm/router/cloudflare/d1/ed25519Yao/d1Ed25519YaoCapabilityPersistence.js +1 -1
  47. package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeIssuer.js +1 -1
  48. package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeService.js +1 -1
  49. package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeStore.js +1 -1
  50. package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpRecords.js +2 -2
  51. package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpRecoveryService.js +3 -3
  52. package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpRegistrationEnrollmentFinalizer.js +1 -1
  53. package/dist/esm/router/cloudflare/d1/emailOtp/d1GoogleEmailOtpRegistrationAttemptStore.js +1 -1
  54. package/dist/esm/router/cloudflare/d1/emailOtp/d1GoogleEmailOtpSessionResolver.js +3 -3
  55. package/dist/esm/router/cloudflare/d1/oidc/d1OidcBoundary.js +7 -1
  56. package/dist/esm/router/cloudflare/d1/oidc/d1OidcVerificationService.js +1 -1
  57. package/dist/esm/router/cloudflare/d1/passkeyCustody/d1PasskeyCustodyRouteService.js +4 -4
  58. package/dist/esm/router/cloudflare/d1/passkeyCustody/d1WalletCustodyCommitStore.js +4 -4
  59. package/dist/esm/router/cloudflare/d1/passkeyCustody/d1WalletRecoveryGoogleEmailOtpRecords.js +1 -1
  60. package/dist/esm/router/cloudflare/d1/passkeyCustody/d1WalletRecoveryGoogleEmailOtpService.js +3 -3
  61. package/dist/esm/router/cloudflare/d1/registration/d1EvmFamilyEcdsaRegistrationBranch.js +1 -1
  62. package/dist/esm/router/cloudflare/d1/registration/d1RegistrationCeremonyRecords.js +11 -2
  63. package/dist/esm/router/cloudflare/d1/registration/d1RegistrationIntentService.js +1 -1
  64. package/dist/esm/router/cloudflare/d1/registration/d1WalletExecutionAuthority.js +9 -16
  65. package/dist/esm/router/cloudflare/d1/registration/d1WalletRegistrationCommitStore.js +1 -1
  66. package/dist/esm/router/cloudflare/d1/registration/d1WalletRegistrationService.js +46 -4
  67. package/dist/esm/router/cloudflare/d1/registration/d1WalletRegistrationSetup.js +12 -0
  68. package/dist/esm/router/cloudflare/d1/registration/d1WalletRegistrationSetupExecution.js +1 -0
  69. package/dist/esm/router/cloudflare/d1/registration/registrationCompletionWrite.js +1 -0
  70. package/dist/esm/router/cloudflare/d1/registration/walletRegistrationEstablishedSessionIssuer.js +1 -1
  71. package/dist/esm/router/cloudflare/d1/registration/walletRegistrationSessionCommitReceipt.js +36 -1
  72. package/dist/esm/router/cloudflare/d1/signingAdmission/d1RouterAbNormalSigningAdmissionStore.js +1 -1
  73. package/dist/esm/router/cloudflare/d1/wallet/authorizationSnapshotLayout.js +1 -0
  74. package/dist/esm/router/cloudflare/d1/wallet/d1VoiceIdWalletSessionChallenges.js +2 -2
  75. package/dist/esm/router/cloudflare/d1/wallet/d1WalletAuthMethodBoundary.js +1 -1
  76. package/dist/esm/router/cloudflare/d1/wallet/d1WalletAuthMethodRevocationReplayStore.js +1 -1
  77. package/dist/esm/router/cloudflare/d1/wallet/d1WalletAuthMethodService.js +6 -5
  78. package/dist/esm/router/cloudflare/d1/wallet/d1WalletAuthorityStore.js +2 -2
  79. package/dist/esm/router/cloudflare/d1/wallet/d1WalletAuthorizationCleanup.js +2 -1
  80. package/dist/esm/router/cloudflare/d1/wallet/d1WalletAuthorizationIntake.js +1 -1
  81. package/dist/esm/router/cloudflare/d1/wallet/d1WalletAuthorizationSnapshot.js +1 -1
  82. package/dist/esm/router/cloudflare/d1/wallet/d1WalletRelocationChallenges.js +1 -1
  83. package/dist/esm/router/cloudflare/d1/wallet/d1WalletRelocationOwnerRequest.js +2 -2
  84. package/dist/esm/router/cloudflare/d1/webauthn/d1WebAuthnAuthService.js +2 -2
  85. package/dist/esm/router/cloudflare/d1/webauthn/d1WebAuthnRecords.js +2 -2
  86. package/dist/esm/router/cloudflare/runtime/staticWalletConsoleBinding.js +9 -0
  87. package/dist/esm/router/cloudflare/runtime/walletConsoleOpsClient.js +6 -0
  88. package/dist/esm/router/cloudflare-adaptor.js +1 -1
  89. package/dist/esm/router/cloudflare.js +6139 -5567
  90. package/dist/esm/router/domains/ecdsa/routerAbEcdsaStrictRegistration.js +1 -1
  91. package/dist/esm/router/domains/ed25519Yao/export/routerAbEd25519YaoExport.js +5 -5
  92. package/dist/esm/router/domains/ed25519Yao/recovery/routerAbEd25519YaoRecovery.js +2 -2
  93. package/dist/esm/router/domains/ed25519Yao/recovery/routerAbEd25519YaoRecoveryWalletSessionAuthorization.js +1 -1
  94. package/dist/esm/router/domains/ed25519Yao/registration/routerAbEd25519YaoHttpRegistrationBackend.js +1 -1
  95. package/dist/esm/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistration.js +1 -1
  96. package/dist/esm/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistrationIntentAuthorization.js +1 -1
  97. package/dist/esm/router/domains/emailOtp/emailOtpRouteHandlers.js +2 -2
  98. package/dist/esm/router/domains/passkeyCustody/walletCustodyRegistrationCommit.js +1 -1
  99. package/dist/esm/router/domains/signingOperations/routerAbEcdsaDerivationNormalSigningRoute.js +2 -2
  100. package/dist/esm/router/domains/signingOperations/routerAbEd25519NormalSigningRoute.js +37 -3
  101. package/dist/esm/router/domains/signingOperations/routerAbOperationStepUp.js +1 -1
  102. package/dist/esm/router/domains/tenantRoot/tenantRootIdentityResolution.js +1 -1
  103. package/dist/esm/router/domains/walletRegistration/walletRegistrationReservation.js +18 -3
  104. package/dist/esm/router/domains/walletRegistration/walletRegistrationRoutes.js +12 -4
  105. package/dist/esm/router/domains/walletUnlock/walletUnlockRouteHandlers.js +3 -3
  106. package/dist/esm/router/framework/http.js +1 -1
  107. package/dist/esm/router/framework/routeDefinitions.js +2 -1
  108. package/dist/esm/router/transport/fetch/createFetchRouter.js +5 -3
  109. package/dist/esm/router/transport/fetch/routes/auth.js +1 -1
  110. package/dist/esm/router/transport/fetch/routes/deviceLinking.js +3 -3
  111. package/dist/esm/router/transport/fetch/routes/deviceLinkingOwnerAuthorization.js +1 -1
  112. package/dist/esm/router/transport/fetch/routes/ecdsaOperationStepUpFactor.js +3 -3
  113. package/dist/esm/router/transport/fetch/routes/externalAuth.js +351 -0
  114. package/dist/esm/router/transport/fetch/routes/normalSigningRouterProxy.js +1 -1
  115. package/dist/esm/router/transport/fetch/routes/passkeyCustody.js +46 -306
  116. package/dist/esm/router/transport/fetch/routes/sessions.js +4 -4
  117. package/dist/esm/router/transport/fetch/routes/syncAccount.js +2 -2
  118. package/dist/esm/router/transport/fetch/routes/syncAccountBootstrap.js +1 -1
  119. package/dist/esm/router/transport/fetch/routes/thresholdEcdsa.js +4 -4
  120. package/dist/esm/router/transport/fetch/routes/thresholdEd25519.js +6 -6
  121. package/dist/esm/router/transport/fetch/routes/walletExecutionLanePreflight.js +2 -2
  122. package/dist/esm/router/transport/fetch/routes/walletRegistration.js +4 -4
  123. package/dist/esm/router/transport/fetch/walletOwnerOperationAuthorization.js +306 -0
  124. package/dist/esm/shared-ts/src/auth/externalAuth.js +118 -0
  125. package/dist/esm/shared-ts/src/authorization/index.js +1 -1
  126. package/dist/esm/shared-ts/src/authorization/voiceIdDeviceAssertion.js +1 -1
  127. package/dist/esm/shared-ts/src/authorization/walletAuthority.js +2 -2
  128. package/dist/esm/shared-ts/src/authorization/{walletCustodyOperation.js → walletOwnerOperation.js} +4 -4
  129. package/dist/esm/shared-ts/src/device-linking/delegatedActivationPlan.js +1 -1
  130. package/dist/esm/shared-ts/src/device-linking/digests.js +1 -1
  131. package/dist/esm/shared-ts/src/device-linking/ed25519ExportRoot.js +1 -1
  132. package/dist/esm/shared-ts/src/device-linking/parsers.js +2 -2
  133. package/dist/esm/shared-ts/src/device-linking/sourceContribution.js +1 -1
  134. package/dist/esm/shared-ts/src/device-linking/walletSessionCredentialDelivery.js +1 -1
  135. package/dist/esm/shared-ts/src/device-linking/wireFields.js +2 -2
  136. package/dist/esm/shared-ts/src/passkey-custody/custodyEnvelope.js +1 -1
  137. package/dist/esm/shared-ts/src/passkey-custody/custodySecretBinding.js +1 -1
  138. package/dist/esm/shared-ts/src/signing-lanes/ownerContinuity.js +1 -1
  139. package/dist/esm/shared-ts/src/utils/routerAbEcdsaDerivation.js +1 -1
  140. package/dist/esm/shared-ts/src/utils/walletAuthAuthority.js +1 -1
  141. package/dist/esm/shared-ts/src/wallet-recovery/index.js +3 -3
  142. package/dist/esm/shared-ts/src/wallet-recovery/walletRecoveryCommittedProjection.js +1 -1
  143. package/dist/esm/shared-ts/src/wallet-recovery/walletRecoveryEnvelopeSet.js +1 -1
  144. package/dist/esm/threshold/session/signingSessionSeal/crypto/cipher.js +1 -1
  145. package/dist/esm/threshold/session/signingSessionSeal/service.js +1 -1
  146. package/dist/esm/threshold/session/signingSessionSeal/transport/fetch.js +1 -1
  147. package/dist/esm/threshold/session/signingSessionSeal/transport/shared.js +1 -1
  148. package/dist/types/shared-ts/src/auth/externalAuth.d.ts +127 -0
  149. package/dist/types/shared-ts/src/authorization/index.d.ts +1 -1
  150. package/dist/types/shared-ts/src/authorization/walletOwnerOperation.d.ts +10 -0
  151. package/dist/types/shared-ts/src/utils/registrationEstablishedSession.d.ts +4 -0
  152. package/dist/types/shared-ts/src/utils/registrationIntent.d.ts +2 -0
  153. package/dist/types/shared-ts/src/utils/walletManagementProtocol.d.ts +1 -1
  154. package/dist/types/wallet-server/src/application-auth.d.ts +3 -0
  155. package/dist/types/wallet-server/src/auth/applicationAuth.d.ts +29 -0
  156. package/dist/types/wallet-server/src/auth/externalAuthService.d.ts +55 -0
  157. package/dist/types/wallet-server/src/auth/externalAuthStore.d.ts +115 -0
  158. package/dist/types/wallet-server/src/auth/externalOwnerOperations.d.ts +18 -0
  159. package/dist/types/wallet-server/src/cloud-host.d.ts +2 -1
  160. package/dist/types/wallet-server/src/core/threeRouteRegistrationContracts.d.ts +12 -0
  161. package/dist/types/wallet-server/src/router/cloudflare/d1/auth/d1AuthorizedOperationRouteService.d.ts +5 -1
  162. package/dist/types/wallet-server/src/router/cloudflare/d1/auth/d1RecordedOwnerOperation.d.ts +16 -0
  163. package/dist/types/wallet-server/src/router/cloudflare/d1/oidc/d1OidcBoundary.d.ts +5 -0
  164. package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1RegistrationCeremonyRecords.d.ts +1 -0
  165. package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1WalletRegistrationSetup.d.ts +2 -0
  166. package/dist/types/wallet-server/src/router/cloudflare/d1/registration/walletRegistrationSessionCommitReceipt.d.ts +7 -1
  167. package/dist/types/wallet-server/src/router/cloudflare/d1/wallet/authorizationSnapshotLayout.d.ts +1 -1
  168. package/dist/types/wallet-server/src/router/cloudflare/d1/wallet/d1WalletAuthMethodService.d.ts +1 -0
  169. package/dist/types/wallet-server/src/router/cloudflare/runtime/staticWalletConsoleBinding.d.ts +2 -0
  170. package/dist/types/wallet-server/src/router/domains/signingOperations/routerAbEd25519NormalSigningRoute.d.ts +2 -2
  171. package/dist/types/wallet-server/src/router/domains/signingOperations/routerAbOperationStepUp.d.ts +1 -1
  172. package/dist/types/wallet-server/src/router/domains/walletRegistration/walletRegistrationInputs.d.ts +1 -0
  173. package/dist/types/wallet-server/src/router/domains/walletRegistration/walletRegistrationReservation.d.ts +11 -6
  174. package/dist/types/wallet-server/src/router/framework/apiCredentialPorts.d.ts +1 -0
  175. package/dist/types/wallet-server/src/router/framework/authServicePort.d.ts +12 -0
  176. package/dist/types/wallet-server/src/router/transport/fetch/routes/externalAuth.d.ts +5 -0
  177. package/dist/types/wallet-server/src/router/transport/fetch/walletOwnerOperationAuthorization.d.ts +23 -0
  178. package/migrations/d1-signer/0085_external_wallet_auth.sql +158 -0
  179. package/migrations/d1-signer/0086_application_auth.sql +67 -0
  180. package/migrations/d1-signer/0087_registration_without_session.sql +43 -0
  181. package/package.json +7 -2
  182. package/dist/types/shared-ts/src/authorization/walletCustodyOperation.d.ts +0 -10
@@ -1,9 +1,10 @@
1
1
  import { parseChallengeSubjectId, parseEmailOtpChallengeId, parseOrgId, parseProviderSubject, parseWalletAuthMethodId, parseWebAuthnCredentialIdB64u, parseWebAuthnRpId } from "../../../../shared-ts/src/utils/domainIds.js";
2
2
  import { normalizeOptionalTrimmedString } from "../../../../shared-ts/src/utils/normalize.js";
3
- import { buildDelegatedWalletAuthorityV1, buildFullOwnerPermissionsV1, sameDelegatedWalletAuthorityV1 } from "../../../../shared-ts/src/authorization/delegatedAuthority.js";
4
3
  import { base64UrlDecode, base64UrlEncode } from "../../../../shared-ts/src/utils/base64.js";
5
4
  import { alphabetizeStringify } from "../../../../shared-ts/src/utils/digests.js";
6
5
  import "../../../../shared-ts/src/utils/encoders.js";
6
+ import { toRecordValue } from "../auth/d1RouterApiAuthBoundary.js";
7
+ import { buildDelegatedWalletAuthorityV1, buildFullOwnerPermissionsV1, sameDelegatedWalletAuthorityV1 } from "../../../../shared-ts/src/authorization/delegatedAuthority.js";
7
8
  import { parseWalletAddAuthMethodRegistrationOptions } from "../../../../shared-ts/src/utils/addAuthMethodRegistration.js";
8
9
  import { normalizeRuntimePolicyScope } from "../../../../shared-ts/src/threshold/signingRootScope.js";
9
10
  import { buildEmailOtpWalletAuthAuthority, walletAuthAuthorityRef } from "../../../../shared-ts/src/utils/walletAuthAuthority.js";
@@ -12,14 +13,13 @@ import { buildWalletAuthMethodRecordV2, computeWalletAuthMethodRevokeOperationFi
12
13
  import { deriveWebAuthnAuthenticatorDeviceInfo } from "../../../../shared-ts/src/utils/webauthnDeviceInfo.js";
13
14
  import { parseSessionOrigin } from "../../../../authorization/domain.js";
14
15
  import { secureRandomBase64Url } from "../../../../shared-ts/src/utils/secureRandomId.js";
16
+ import { EMAIL_OTP_CHANNEL, WALLET_EMAIL_OTP_ACTIONS, WALLET_EMAIL_OTP_UNLOCK_OPERATION } from "../../../../shared-ts/src/utils/emailOtpDomain.js";
17
+ import { parseWebAuthnClientDataJsonBase64url, webAuthnOriginHostnameOrEmpty } from "../../../auth/webAuthnCredentialCodecs.js";
15
18
  import { PASSKEY_PRF_FIRST_SALT_V1, PASSKEY_PRF_SECOND_SALT_V1 } from "../../../../shared-ts/src/utils/signingSessionSeal.js";
16
19
  import { parsePasskeyCustodyEnvelopeRecord } from "../../../../shared-ts/src/passkey-custody/custodyEnvelope.js";
17
20
  import "../../../../shared-ts/src/passkey-custody/index.js";
18
21
  import { addAuthMethodIntentGrantFromString, computeAddAuthMethodIntentDigestB64u } from "../../../../shared-ts/src/utils/registrationIntent.js";
19
- import { parseWebAuthnClientDataJsonBase64url, webAuthnOriginHostnameOrEmpty } from "../../../auth/webAuthnCredentialCodecs.js";
20
- import { EMAIL_OTP_CHANNEL, WALLET_EMAIL_OTP_ACTIONS, WALLET_EMAIL_OTP_UNLOCK_OPERATION } from "../../../../shared-ts/src/utils/emailOtpDomain.js";
21
22
  import { resolveWalletAuthMethodIdForAuthority } from "../../../../core/signingLanes/WalletExecutionLaneProjection.js";
22
- import { toRecordValue } from "../auth/d1RouterApiAuthBoundary.js";
23
23
  import { d1HostIsWithinWebAuthnRpId, resolveD1AddAuthMethodExistingAuth, resolveD1AddSignerExistingAuth, verifyD1LinkedDeviceFreshRevokeProofV1, walletAuthAuthorityFromRegistrationAuthority } from "./d1WalletAuthMethodBoundary.js";
24
24
  import { parseWalletIdForIntent } from "../registration/d1RegistrationCeremonyRecords.js";
25
25
  import { admitAddWalletAuthMethod } from "../../../../shared-ts/src/utils/addWalletAuthMethod.js";
@@ -1413,7 +1413,8 @@ var CloudflareD1WalletAuthMethodService = class {
1413
1413
  provider,
1414
1414
  providerUserId,
1415
1415
  emailHashHex: record.emailHashHex
1416
- }), record.walletAuthMethodId)
1416
+ }), record.walletAuthMethodId),
1417
+ walletAuthority
1417
1418
  };
1418
1419
  } catch (error) {
1419
1420
  return {
@@ -1,11 +1,11 @@
1
1
  import { mpcMaterialActivationRefsEqual, parseLinkDeviceSessionId, parseLinkedDeviceEnrollmentId, parseWalletAuthorityId, parseWalletId, parseWalletRecoveryOperationId } from "../../../../shared-ts/src/utils/domainIds.js";
2
+ import { parseDigestB64u } from "../../../../shared-ts/src/utils/canonicalPrimitives.js";
3
+ import { d1ChangedRows, parseD1JsonColumn } from "../../../../storage/d1Sql.js";
2
4
  import { parseDeviceId } from "../../../../shared-ts/src/authorization/capabilityKinds.js";
3
5
  import { parseDelegatedWalletPermissionSetV1 } from "../../../../shared-ts/src/authorization/delegatedAuthority.js";
4
- import { parseDigestB64u } from "../../../../shared-ts/src/utils/canonicalPrimitives.js";
5
6
  import { parseWalletAuthMethodRecordV2 } from "../../../../shared-ts/src/utils/walletAuthMethodRecord.js";
6
7
  import { buildRevokedWalletAuthorityV1, computeWalletAuthorityDigestB64u, parseWalletAuthorityV1, parseWalletSignerActivationSetV1, walletAuthorityDigestsMatchV1 } from "../../../../shared-ts/src/authorization/walletAuthority.js";
7
8
  import { buildWalletSessionCapabilitySubjectsV1 } from "../../../../authorization/domain.js";
8
- import { d1ChangedRows, parseD1JsonColumn } from "../../../../storage/d1Sql.js";
9
9
  import { prepareD1WalletPutSignerStatement } from "../../../../core/d1WalletStore.js";
10
10
  import { prepareD1WalletAuthMethodV2PutStatement } from "../../../../core/d1WalletAuthMethodStore.js";
11
11
  import { prepareD1WalletSessionAuthorityProjectionStatements } from "../authorization/walletSessionAuthorityProjection.js";
@@ -1,8 +1,8 @@
1
1
  import { requireCanonicalString, requireRecord } from "../../../../shared-ts/src/utils/validation.js";
2
2
  import { parseUnixMs } from "../../../../shared-ts/src/passkey-custody/primitives.js";
3
- import { parseNonNegativeSafeInteger } from "../../../../shared-ts/src/device-linking/wireFields.js";
4
3
  import { D1_BATCH_CAS_GUARD_SQL } from "../../../../storage/d1Sql.js";
5
4
  import { prepareD1TenantStatement } from "../../../../core/d1TenantStore.js";
5
+ import { parseNonNegativeSafeInteger } from "../../../../shared-ts/src/device-linking/wireFields.js";
6
6
  import { evictWalletEd25519CapabilityCache } from "../ed25519Yao/d1Ed25519YaoProductRegistrationPartitionedStateStore.js";
7
7
  import { AuthorizationSnapshotLayout } from "./authorizationSnapshotLayout.js";
8
8
  //#region src/router/cloudflare/d1/wallet/d1WalletAuthorizationCleanup.ts
@@ -35,6 +35,7 @@ const TABLES = [
35
35
  "wallet_recovery_code_locators",
36
36
  "wallets",
37
37
  "wallet_auth_methods",
38
+ "external_auth_associations",
38
39
  "wallet_relocation_approvals",
39
40
  "wallet_authorities",
40
41
  "wallet_relocation_authorization_import_receipts",
@@ -1,9 +1,9 @@
1
1
  import { requireCanonicalString, requireRecord } from "../../../../shared-ts/src/utils/validation.js";
2
2
  import { sha256HexUtf8 } from "../../../../shared-ts/src/utils/digests.js";
3
3
  import { parseUnixMs } from "../../../../shared-ts/src/passkey-custody/primitives.js";
4
- import { parseNonNegativeSafeInteger } from "../../../../shared-ts/src/device-linking/wireFields.js";
5
4
  import { D1_BATCH_CAS_GUARD_SQL } from "../../../../storage/d1Sql.js";
6
5
  import { prepareD1TenantStatement } from "../../../../core/d1TenantStore.js";
6
+ import { parseNonNegativeSafeInteger } from "../../../../shared-ts/src/device-linking/wireFields.js";
7
7
  import { AuthorizationSnapshotLayout } from "./authorizationSnapshotLayout.js";
8
8
  import { D1WalletAuthorizationHistory } from "./d1WalletAuthorizationHistory.js";
9
9
  import "./d1WalletAuthorizationSnapshot.js";
@@ -1,8 +1,8 @@
1
1
  import { requireCanonicalString } from "../../../../shared-ts/src/utils/validation.js";
2
2
  import { sha256HexUtf8 } from "../../../../shared-ts/src/utils/digests.js";
3
- import { parseNonNegativeSafeInteger } from "../../../../shared-ts/src/device-linking/wireFields.js";
4
3
  import { D1_BATCH_CAS_GUARD_SQL } from "../../../../storage/d1Sql.js";
5
4
  import { prepareD1TenantStatement } from "../../../../core/d1TenantStore.js";
5
+ import { parseNonNegativeSafeInteger } from "../../../../shared-ts/src/device-linking/wireFields.js";
6
6
  import { AuthorizationSnapshotLayout } from "./authorizationSnapshotLayout.js";
7
7
  //#region src/router/cloudflare/d1/wallet/d1WalletAuthorizationSnapshot.ts
8
8
  const CHUNK_BYTES = 32768;
@@ -1,8 +1,8 @@
1
1
  import { parseWalletAuthMethodId, parseWalletAuthorityId, parseWalletId } from "../../../../shared-ts/src/utils/domainIds.js";
2
2
  import { isPlainObject, requireCanonicalString } from "../../../../shared-ts/src/utils/validation.js";
3
+ import { D1_BATCH_CAS_GUARD_SQL } from "../../../../storage/d1Sql.js";
3
4
  import { parseSessionOrigin } from "../../../../authorization/domain.js";
4
5
  import { secureRandomBase64Url } from "../../../../shared-ts/src/utils/secureRandomId.js";
5
- import { D1_BATCH_CAS_GUARD_SQL } from "../../../../storage/d1Sql.js";
6
6
  //#region src/router/cloudflare/d1/wallet/d1WalletRelocationChallenges.ts
7
7
  const MAX_CHALLENGE_LIFETIME_MS = 3e5;
8
8
  var WalletRelocationChallengeBinding = class WalletRelocationChallengeBinding {
@@ -1,8 +1,8 @@
1
- import { buildDelegatedWalletAuthorityV1, buildFullOwnerPermissionsV1, sameDelegatedWalletAuthorityV1 } from "../../../../shared-ts/src/authorization/delegatedAuthority.js";
2
1
  import { sha256HexUtf8 } from "../../../../shared-ts/src/utils/digests.js";
2
+ import { D1_BATCH_CAS_GUARD_SQL } from "../../../../storage/d1Sql.js";
3
+ import { buildDelegatedWalletAuthorityV1, buildFullOwnerPermissionsV1, sameDelegatedWalletAuthorityV1 } from "../../../../shared-ts/src/authorization/delegatedAuthority.js";
3
4
  import { buildWalletSessionCapabilitySubjectsV1, parseSessionOrigin, walletSessionCapabilitySubjectsV1Equal } from "../../../../authorization/domain.js";
4
5
  import { digestOpaqueValue } from "../../../../authorization/service.js";
5
- import { D1_BATCH_CAS_GUARD_SQL } from "../../../../storage/d1Sql.js";
6
6
  import { extractBearerCredential } from "../../../auth/routerApiKeyAuth.js";
7
7
  import { WalletRelocationChallengeBinding } from "./d1WalletRelocationChallenges.js";
8
8
  //#region src/router/cloudflare/d1/wallet/d1WalletRelocationOwnerRequest.ts
@@ -1,11 +1,11 @@
1
1
  import { parseWebAuthnRpId } from "../../../../shared-ts/src/utils/domainIds.js";
2
2
  import { normalizeOptionalTrimmedString } from "../../../../shared-ts/src/utils/normalize.js";
3
3
  import { parseDigestB64u } from "../../../../shared-ts/src/utils/canonicalPrimitives.js";
4
+ import { failedVerification, failure } from "../../../../shared-ts/src/utils/failure.js";
5
+ import { nonNegativeSafeInteger, optionalNonNegativeInteger, parseD1BoundaryWalletId, parseD1BoundaryWalletIdResult, parseJsonObject } from "../auth/d1RouterApiAuthBoundary.js";
4
6
  import { WalletLifecycleLocator } from "../../../../authorization/lifecycleRouting.js";
5
7
  import { secureRandomBase64Url } from "../../../../shared-ts/src/utils/secureRandomId.js";
6
- import { failedVerification, failure } from "../../../../shared-ts/src/utils/failure.js";
7
8
  import { decodeWebAuthnBase64UrlOrBase64, parseWebAuthnAuthenticationCredential, parseWebAuthnClientDataJsonBase64url, webAuthnCredentialIdB64uFromCredential, webAuthnOriginHostnameOrEmpty } from "../../../auth/webAuthnCredentialCodecs.js";
8
- import { nonNegativeSafeInteger, optionalNonNegativeInteger, parseD1BoundaryWalletId, parseD1BoundaryWalletIdResult, parseJsonObject } from "../auth/d1RouterApiAuthBoundary.js";
9
9
  import { parseWebAuthnAuthenticatorRowDeviceInfo, webAuthnSyncWalletBindingFromCredentialBinding } from "./d1WebAuthnRecords.js";
10
10
  import { d1HostIsWithinWebAuthnRpId } from "../wallet/d1WalletAuthMethodBoundary.js";
11
11
  import { webAuthnAuthenticationFailure, webAuthnLoginEd25519, webAuthnSyncCredentialBinding } from "../../../../core/authService/webauthnVerificationOutcomes.js";
@@ -1,7 +1,8 @@
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 { normalizeOptionalTrimmedString } from "../../../../shared-ts/src/utils/normalize.js";
4
3
  import { parseEnvelopeRevision } from "../../../../shared-ts/src/passkey-custody/primitives.js";
4
+ import { nonNegativeSafeInteger, optionalNonNegativeInteger, positiveInteger } from "../auth/d1RouterApiAuthBoundary.js";
5
+ import { parseDeviceId } from "../../../../shared-ts/src/authorization/capabilityKinds.js";
5
6
  import { normalizeRuntimePolicyScope } from "../../../../shared-ts/src/threshold/signingRootScope.js";
6
7
  import { parseWalletAuthMethodRecordV2 } from "../../../../shared-ts/src/utils/walletAuthMethodRecord.js";
7
8
  import { parseWalletAuthorityV1 } from "../../../../shared-ts/src/authorization/walletAuthority.js";
@@ -9,7 +10,6 @@ import { parseWebAuthnAuthenticatorDeviceInfoJson } from "../../../../shared-ts/
9
10
  import { hasExactKeys } from "../../../../shared-ts/src/utils/exactKeys.js";
10
11
  import "../../../../shared-ts/src/passkey-custody/index.js";
11
12
  import { parseRecoveryCodeReservationId } from "../../../../shared-ts/src/wallet-recovery/recoveryCodeReservation.js";
12
- import { nonNegativeSafeInteger, optionalNonNegativeInteger, positiveInteger } from "../auth/d1RouterApiAuthBoundary.js";
13
13
  //#region src/router/cloudflare/d1/webauthn/d1WebAuthnRecords.ts
14
14
  function parseWebAuthnAuthenticatorRowDeviceInfo(raw) {
15
15
  return parseWebAuthnAuthenticatorDeviceInfoJson(raw);
@@ -1,3 +1,4 @@
1
+ import { parseExternalAuthConfiguration } from "../../../shared-ts/src/auth/externalAuth.js";
1
2
  import { failure } from "../../../shared-ts/src/utils/failure.js";
2
3
  import { ROUTER_API_CREDENTIAL_SCOPES } from "../../framework/apiCredentialPorts.js";
3
4
  import { WALLET_CONSOLE_OP_PATHS_V1, decodeWalletConsoleTenantRootActiveLineageRequestV1 } from "./walletConsoleOps.js";
@@ -16,6 +17,10 @@ function parseStaticWalletConsoleBindingConfigV1(value) {
16
17
  scopes: requiredScopeList(credential.scopes)
17
18
  },
18
19
  deployment: {
20
+ externalAuth: parseExternalAuthConfiguration(deployment.externalAuth ?? {
21
+ kind: "disabled",
22
+ revision: 0
23
+ }),
19
24
  orgId: requiredConfigText(deployment.orgId, "deployment.orgId"),
20
25
  projectId: requiredConfigText(deployment.projectId, "deployment.projectId"),
21
26
  environmentId: requiredConfigText(deployment.environmentId, "deployment.environmentId"),
@@ -97,6 +102,10 @@ function registrationContextResponse(config, value) {
97
102
  }
98
103
  function projectEnvironment(config) {
99
104
  return {
105
+ externalAuth: config.deployment.externalAuth ?? {
106
+ kind: "disabled",
107
+ revision: 0
108
+ },
100
109
  id: config.deployment.environmentId,
101
110
  projectId: config.deployment.projectId,
102
111
  key: config.deployment.environmentKey,
@@ -1,3 +1,4 @@
1
+ import { parseExternalAuthConfiguration } from "../../../shared-ts/src/auth/externalAuth.js";
1
2
  import { ROUTER_API_CREDENTIAL_SCOPES } from "../../framework/apiCredentialPorts.js";
2
3
  import { unavailableRegistrationContext, walletRegistrationContext } from "../../auth/walletRegistrationContext.js";
3
4
  import { WALLET_CONSOLE_OP_PATHS_V1, WALLET_CONSOLE_SERVICE_ORIGIN_V1, decodeWalletConsoleTenantRootActiveLineageResponseV1 } from "./walletConsoleOps.js";
@@ -23,6 +24,7 @@ const PRINCIPAL_FIELDS = new Set([
23
24
  "scopes"
24
25
  ]);
25
26
  const PROJECT_ENVIRONMENT_FIELDS = new Set([
27
+ "externalAuth",
26
28
  "id",
27
29
  "projectId",
28
30
  "key",
@@ -143,6 +145,10 @@ function parseProjectEnvironment(value) {
143
145
  projectId,
144
146
  key,
145
147
  signingRootVersion,
148
+ externalAuth: parseExternalAuthConfiguration(record.externalAuth ?? {
149
+ kind: "disabled",
150
+ revision: 0
151
+ }),
146
152
  ...status ? { status } : {}
147
153
  };
148
154
  }
@@ -1,6 +1,6 @@
1
1
  import { ROUTER_AB_PUBLIC_KEYSET_PATH, ROUTER_AB_PUBLIC_KEYSET_VERSION_V2, ROUTER_AB_PUBLIC_KEYSET_WELL_KNOWN_PATH, parseRouterAbPublicKeysetV2 } from "../shared-ts/src/utils/routerAbPublicKeyset.js";
2
- import { defineRoute, matchesRouteDefinitionRequest } from "./framework/routeDefinitions.js";
3
2
  import { extractBearerCredential, extractRouterApiEnvironmentId, resolveSourceIpFromFetchHeaders } from "./auth/routerApiKeyAuth.js";
3
+ import { defineRoute, matchesRouteDefinitionRequest } from "./framework/routeDefinitions.js";
4
4
  import { InMemoryRouterAbNormalSigningAdmissionStore, createInMemoryRouterAbNormalSigningAdmissionAdapter, createInMemoryRouterAbNormalSigningAdmissionStore, createRouterAbNormalSigningAdmissionAdapter } from "./domains/signingOperations/routerAbNormalSigningAdmissionCore.js";
5
5
  import { CloudflareD1RouterAbNormalSigningAdmissionStore, createCloudflareD1RouterAbNormalSigningAdmissionStore } from "./cloudflare/d1/signingAdmission/d1RouterAbNormalSigningAdmissionStore.js";
6
6
  import { getRouterApiRouteExtensionRoutes } from "./framework/routeExtensions.js";