@seams/wallet-server 0.15.6 → 0.17.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 +4 -4
- package/THIRD_PARTY_NOTICES.md +102 -1
- package/artifact-manifest.json +27 -22
- 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/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/cloudflare-router-ab/migrations/postgres/0001_role_store.sql +567 -0
- package/dist/esm/authorization/factorEvidence.js +49 -8
- package/dist/esm/authorization/vaultProxyUse.js +15 -15
- package/dist/esm/core/SessionService.js +1 -0
- package/dist/esm/core/ThresholdService/kv.js +2 -0
- package/dist/esm/core/ThresholdService/routerAb/ecdsaDerivationPoolFillHandlers.js +3 -0
- package/dist/esm/core/d1IdentityStore.js +3 -1
- package/dist/esm/core/d1TenantStore.js +4 -1
- package/dist/esm/core/d1WalletAuthMethodStore.js +3 -1
- package/dist/esm/core/d1WalletStore.js +5 -2
- package/dist/esm/core/deviceLinking/linkedDeviceManagement.js +1 -4
- package/dist/esm/core/deviceLinking/linkedDeviceSession.js +2 -0
- package/dist/esm/core/deviceLinking/requestProof.js +1 -0
- package/dist/esm/core/routerAbSigning/RouterAbEcdsaPresignRuntime.js +2 -0
- package/dist/esm/core/routerAbSigning/RouterAbNormalSigningRuntime.js +3 -0
- package/dist/esm/core/rpcClients/near/NearClient.js +8 -0
- package/dist/esm/core/signingMaterial/ordinaryInactiveSignerMaterialReservation.js +0 -1
- package/dist/esm/localHostedWalletGatewayHandler.js +2 -2
- package/dist/esm/localIntendedEcdsaFinalizeFault.js +1 -1
- package/dist/esm/localIntendedLinkExecuteFault.js +1 -1
- package/dist/esm/localIntendedMaterialAdmissionFault.js +2 -2
- package/dist/esm/localIntendedRevokeFault.js +1 -1
- package/dist/esm/localIntendedSessionAdmissionFault.js +1 -1
- package/dist/esm/localIntendedYaoExportFault.js +1 -1
- package/dist/esm/localIntendedYaoFault.js +1 -1
- package/dist/esm/localIntendedYaoFinalizeFault.js +1 -1
- package/dist/esm/localIntendedYaoRecoveryFault.js +3 -3
- package/dist/esm/localIntendedYaoSigningFault.js +1 -1
- package/dist/esm/localRegistrationSetupAuthority.js +1 -0
- package/dist/esm/router/cloudflare/d1/auth/d1RouterApiAuthService.js +2 -2
- package/dist/esm/router/cloudflare/d1/authorization/d1AuthorizationStore.js +5 -0
- package/dist/esm/router/cloudflare/d1/authorization/d1VaultProxyStore.js +1 -0
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceAuthorityInstallService.js +1 -0
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceEd25519ExportRootStore.js +2 -0
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceEmailOtpGrantStore.js +2 -0
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceEmailOtpTargetFactor.js +3 -0
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceOwnerAuthorizationProvider.js +2 -3
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceRequestProofNonceStore.js +2 -0
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceSessionStore.js +3 -0
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceSourceContributionPreparationPlanner.js +6 -2
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceTargetAuthenticatorStore.js +3 -0
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceTargetCredentialProvider.js +10 -2
- package/dist/esm/router/cloudflare/d1/deviceLinking/d1LinkedDeviceTargetPlanner.js +3 -0
- package/dist/esm/router/cloudflare/d1/ed25519Yao/d1Ed25519YaoCapabilityPersistence.js +6 -1
- package/dist/esm/router/cloudflare/d1/ed25519Yao/d1Ed25519YaoLifecycleDecisionStore.js +2 -0
- package/dist/esm/router/cloudflare/d1/ed25519Yao/d1Ed25519YaoProductRegistrationPartitionedStateStore.js +1 -1
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeIssuer.js +5 -0
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeService.js +8 -0
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeStore.js +6 -1
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpChallengeVerifier.js +4 -0
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpEnrollmentStore.js +1 -0
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpGrantStore.js +1 -0
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpRecoveryService.js +4 -0
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpRegistrationEnrollmentFinalizer.js +2 -0
- package/dist/esm/router/cloudflare/d1/emailOtp/d1EmailOtpServerSealRuntime.js +1 -0
- package/dist/esm/router/cloudflare/d1/emailOtp/d1GoogleEmailOtpRegistrationAttemptStore.js +3 -0
- package/dist/esm/router/cloudflare/d1/emailOtp/d1GoogleEmailOtpSessionResolver.js +6 -0
- package/dist/esm/router/cloudflare/d1/identity/d1IdentityService.js +1 -0
- package/dist/esm/router/cloudflare/d1/oidc/d1OidcBoundary.js +2 -4
- package/dist/esm/router/cloudflare/d1/oidc/d1OidcVerificationService.js +4 -0
- package/dist/esm/router/cloudflare/d1/passkeyCustody/d1PasskeyCustodyEnvelopeStore.js +4 -0
- package/dist/esm/router/cloudflare/d1/passkeyCustody/d1WalletCustodyCommitStore.js +7 -0
- package/dist/esm/router/cloudflare/d1/passkeyCustody/d1WalletRecoveryGoogleEmailOtpAttemptStore.js +1 -0
- package/dist/esm/router/cloudflare/d1/passkeyCustody/d1WalletRecoveryGoogleEmailOtpService.js +8 -0
- package/dist/esm/router/cloudflare/d1/registration/d1RegistrationCeremonyRecordStore.js +3 -0
- package/dist/esm/router/cloudflare/d1/registration/d1RegistrationCeremonyStore.js +1 -0
- package/dist/esm/router/cloudflare/d1/registration/d1RegistrationIntentService.js +1 -0
- package/dist/esm/router/cloudflare/d1/registration/d1RegistrationSessionTransaction.js +1 -1
- package/dist/esm/router/cloudflare/d1/registration/d1WalletOperationStore.js +2 -0
- package/dist/esm/router/cloudflare/d1/registration/d1WalletRegistrationCommitStore.js +3 -0
- package/dist/esm/router/cloudflare/d1/registration/d1WalletRegistrationService.js +24 -0
- package/dist/esm/router/cloudflare/d1/signingAdmission/d1RouterAbNormalSigningAdmissionStore.js +3 -0
- package/dist/esm/router/cloudflare/d1/versionedJson/d1VersionedJsonRecordStore.js +6 -0
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletAddSignerService.js +11 -0
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletAuthMethodRevocationReplayStore.js +2 -0
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletAuthMethodService.js +16 -0
- package/dist/esm/router/cloudflare/d1/wallet/d1WalletAuthorityStore.js +3 -1
- package/dist/esm/router/cloudflare/d1/webauthn/d1WebAuthnAuthService.js +4 -0
- package/dist/esm/router/cloudflare/d1/webauthn/d1WebAuthnStore.js +5 -1
- package/dist/esm/router/cloudflare/durableObjects/versionedJsonRecordStore.js +6 -0
- package/dist/esm/router/cloudflare/runtime/ed25519SessionAdapter.js +6 -0
- package/dist/esm/router/cloudflare/runtime/walletAuthorizationRelocationRoutes.js +117 -117
- package/dist/esm/router/cloudflare/runtime/walletPlacementRoutes.js +51 -51
- package/dist/esm/router/cloudflare/signingLanes/cloudflareOrdinaryInactiveSignerMaterialReservation.js +3 -3
- package/dist/esm/router/cloudflare.js +114 -61
- package/dist/esm/router/domains/ecdsa/routerAbEcdsaStrictRegistration.js +1 -1
- package/dist/esm/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistration.js +2 -1
- package/dist/esm/router/domains/ed25519Yao/capabilityLifecycle/routerAbEd25519YaoProductRegistrationRequestScopedRuntime.js +2 -1
- package/dist/esm/router/domains/ed25519Yao/export/routerAbEd25519YaoExport.js +6 -8
- package/dist/esm/router/domains/ed25519Yao/recovery/routerAbEd25519YaoRecovery.js +11 -9
- package/dist/esm/router/domains/ed25519Yao/registration/routerAbEd25519YaoHttpRegistrationBackend.js +2 -1
- package/dist/esm/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistration.js +11 -9
- package/dist/esm/router/domains/ed25519Yao/registration/routerAbEd25519YaoRegistrationIntentAuthorization.js +2 -3
- package/dist/esm/router/domains/signingOperations/routerAbNormalSigningAdmissionCore.js +2 -4
- package/dist/esm/router/domains/walletRegistration/registrationSessionSeal.js +1 -1
- package/dist/esm/router/framework/http.js +1 -1
- package/dist/esm/router/framework/ror/staticProvider.js +1 -0
- package/dist/esm/router/ror.js +1 -0
- package/dist/esm/shared-ts/src/authorization/delegatedAuthority.js +1 -1
- package/dist/esm/shared-ts/src/authorization/operationFingerprint.js +6 -0
- package/dist/esm/shared-ts/src/device-linking/sourceContribution.js +5 -5
- package/dist/esm/shared-ts/src/near/nearClient.js +6 -0
- package/dist/esm/shared-ts/src/tenant-root/tenantRootIdentity.js +5 -0
- package/dist/esm/shared-ts/src/utils/domainIds.js +7 -0
- package/dist/esm/shared-ts/src/utils/routerAbEd25519Yao.js +7 -6
- package/dist/esm/storage/tenantRoute.js +4 -0
- package/dist/esm/threshold/session/signingSessionSeal/crypto/cipher.js +1 -1
- package/dist/esm/threshold/session/signingSessionSeal/crypto/shamir3PassWasm.js +1 -1
- package/dist/esm/threshold/session/signingSessionSeal/guards/backends.js +2 -0
- package/dist/esm/threshold/session/signingSessionSeal/guards/index.js +2 -1
- package/dist/esm/threshold/session/signingSessionSeal/idempotencyBackends.js +3 -0
- package/dist/types/shared-ts/src/authorization/capabilityKinds.d.ts +14 -14
- package/dist/types/shared-ts/src/authorization/delegatedAuthority.d.ts +1 -1
- package/dist/types/shared-ts/src/device-linking/ed25519ExportRoot.d.ts +1 -1
- package/dist/types/shared-ts/src/device-linking/requestProof.d.ts +1 -1
- package/dist/types/shared-ts/src/device-linking/sourceContribution.d.ts +5 -5
- package/dist/types/shared-ts/src/passkey-custody/custodyEnvelope.d.ts +3 -3
- package/dist/types/shared-ts/src/passkey-custody/custodySecretBinding.d.ts +1 -1
- package/dist/types/shared-ts/src/tenant-root/tenantRootIdentity.d.ts +1 -1
- package/dist/types/shared-ts/src/tenant-root/tenantRootOperationRecord.d.ts +2 -2
- package/dist/types/shared-ts/src/utils/base64.d.ts +2 -2
- package/dist/types/shared-ts/src/utils/digestEncoding.d.ts +1 -1
- package/dist/types/shared-ts/src/utils/digests.d.ts +2 -2
- package/dist/types/shared-ts/src/utils/emailOtpDomain.d.ts +16 -16
- package/dist/types/shared-ts/src/utils/emailOtpRecoveryKey.d.ts +1 -1
- package/dist/types/shared-ts/src/utils/routerAbEcdsaDerivation.d.ts +10 -10
- package/dist/types/shared-ts/src/utils/routerAbEd25519Yao.d.ts +12 -11
- package/dist/types/shared-ts/src/utils/routerAbPublicKeyset.d.ts +3 -3
- package/dist/types/shared-ts/src/utils/routerAbTraceContext.d.ts +1 -1
- package/dist/types/shared-ts/src/utils/signerDomain.d.ts +15 -15
- package/dist/types/shared-ts/src/utils/signingSessionSeal.d.ts +11 -11
- package/dist/types/shared-ts/src/utils/walletSessionFailure.d.ts +8 -8
- package/dist/types/shared-ts/src/utils/webauthnDeviceInfo.d.ts +2 -2
- package/dist/types/shared-ts/src/utils/wireSchema.d.ts +1 -1
- package/dist/types/shared-ts/src/wallet-recovery/recoveryKeyId.d.ts +1 -1
- package/dist/types/wallet-server/src/authorization/factorEvidence.d.ts +6 -6
- package/dist/types/wallet-server/src/core/ecdsaMaterialReadSnapshot.d.ts +1 -1
- package/dist/types/wallet-server/src/core/threeRouteRegistrationContracts.typecheck.d.ts +6 -6
- package/dist/types/wallet-server/src/router/auth/webAuthnCredentialCodecs.d.ts +1 -1
- package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceTargetCredentialProvider.d.ts +1 -1
- package/dist/types/wallet-server/src/router/cloudflare/d1/deviceLinking/d1LinkedDeviceTargetPlanner.d.ts +3 -3
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/d1WalletRegistrationRead.d.ts +2 -2
- package/dist/types/wallet-server/src/router/cloudflare/d1/registration/walletRegistrationEstablishedSessionIssuer.d.ts +2 -2
- 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/d1WalletRelocationOwner.d.ts +9 -9
- package/dist/types/wallet-server/src/router/cloudflare/signingLanes/cloudflareOrdinaryInactiveSignerMaterialReservation.d.ts +6 -6
- package/dist/types/wallet-server/src/router/domains/signingOperations/signingPrepareSession.d.ts +2 -2
- package/dist/types/wallet-server/src/router/domains/walletRegistration/walletRegistrationSetupPayload.d.ts +1 -1
- package/dist/types/wallet-server/src/router/domains/walletUnlock/walletUnlockRequestedCapabilitiesValidation.d.ts +3 -3
- package/dist/types/wallet-server/src/router/framework/apiCredentialPorts.d.ts +1 -1
- package/dist/types/wallet-server/src/router/framework/routeAuthPolicy.d.ts +2 -2
- package/dist/types/wallet-server/src/router/framework/routeExecutionContext.d.ts +1 -1
- package/dist/types/wallet-server/src/router/transport/fetch/routes/deviceLinkingOwnerAuthorization.d.ts +1 -1
- package/migrations/d1-signer/0082_wallet_signature_completions.sql +39 -0
- package/package.json +4 -5
|
@@ -0,0 +1,567 @@
|
|
|
1
|
+
-- PostgreSQL role-private schema. Apply once to an empty database.
|
|
2
|
+
-- Row-count failures must abort the implicit transaction before its commit.
|
|
3
|
+
CREATE FUNCTION public.require_tenant_root_row_count(actual BIGINT, expected BIGINT)
|
|
4
|
+
RETURNS BIGINT LANGUAGE plpgsql AS $$
|
|
5
|
+
BEGIN
|
|
6
|
+
IF actual <> expected THEN
|
|
7
|
+
RAISE EXCEPTION 'tenant-root affected-row requirement failed: expected %, actual %',
|
|
8
|
+
expected, actual USING ERRCODE = '23514';
|
|
9
|
+
END IF;
|
|
10
|
+
RETURN actual;
|
|
11
|
+
END;
|
|
12
|
+
$$;
|
|
13
|
+
|
|
14
|
+
CREATE TABLE tenant_root_command_replays (
|
|
15
|
+
replay_key_digest_hex TEXT PRIMARY KEY CHECK (
|
|
16
|
+
length(replay_key_digest_hex) = 64
|
|
17
|
+
AND replay_key_digest_hex !~ '[^0-9a-f]'
|
|
18
|
+
),
|
|
19
|
+
tenant_identity_digest_hex TEXT NOT NULL CHECK (
|
|
20
|
+
length(tenant_identity_digest_hex) = 64
|
|
21
|
+
AND tenant_identity_digest_hex !~ '[^0-9a-f]'
|
|
22
|
+
),
|
|
23
|
+
custody_lineage_b64u TEXT NOT NULL CHECK (length(custody_lineage_b64u) = 22),
|
|
24
|
+
session_id_hex TEXT NOT NULL CHECK (
|
|
25
|
+
length(session_id_hex) = 32
|
|
26
|
+
AND session_id_hex !~ '[^0-9a-f]'
|
|
27
|
+
),
|
|
28
|
+
nonce_hex TEXT NOT NULL CHECK (
|
|
29
|
+
length(nonce_hex) = 64
|
|
30
|
+
AND nonce_hex !~ '[^0-9a-f]'
|
|
31
|
+
),
|
|
32
|
+
role TEXT NOT NULL CHECK (role = public.tenant_root_store_role()),
|
|
33
|
+
command_digest_hex TEXT NOT NULL CHECK (
|
|
34
|
+
length(command_digest_hex) = 64
|
|
35
|
+
AND command_digest_hex !~ '[^0-9a-f]'
|
|
36
|
+
),
|
|
37
|
+
status TEXT NOT NULL CHECK (status IN ('reserved', 'executed', 'completed', 'failed')),
|
|
38
|
+
receipt_b64u TEXT,
|
|
39
|
+
receipt_digest_hex TEXT CHECK (
|
|
40
|
+
receipt_digest_hex IS NULL OR (
|
|
41
|
+
length(receipt_digest_hex) = 64
|
|
42
|
+
AND receipt_digest_hex !~ '[^0-9a-f]'
|
|
43
|
+
)
|
|
44
|
+
),
|
|
45
|
+
reserved_at_ms BIGINT NOT NULL CHECK (reserved_at_ms > 0),
|
|
46
|
+
executed_at_ms BIGINT,
|
|
47
|
+
terminal_at_ms BIGINT,
|
|
48
|
+
admission_digest_hex TEXT CHECK (
|
|
49
|
+
admission_digest_hex IS NULL OR (
|
|
50
|
+
length(admission_digest_hex) = 64
|
|
51
|
+
AND admission_digest_hex !~ '[^0-9a-f]'
|
|
52
|
+
)
|
|
53
|
+
),
|
|
54
|
+
refresh_state_b64u TEXT CHECK (
|
|
55
|
+
refresh_state_b64u IS NULL OR (
|
|
56
|
+
length(refresh_state_b64u) > 0
|
|
57
|
+
AND length(refresh_state_b64u) <= 174764
|
|
58
|
+
AND refresh_state_b64u !~ '[^A-Za-z0-9_-]'
|
|
59
|
+
)
|
|
60
|
+
),
|
|
61
|
+
refresh_state_digest_hex TEXT CHECK (
|
|
62
|
+
refresh_state_digest_hex IS NULL OR (
|
|
63
|
+
length(refresh_state_digest_hex) = 64
|
|
64
|
+
AND refresh_state_digest_hex !~ '[^0-9a-f]'
|
|
65
|
+
)
|
|
66
|
+
),
|
|
67
|
+
CHECK (
|
|
68
|
+
(status = 'reserved' AND receipt_b64u IS NULL
|
|
69
|
+
AND receipt_digest_hex IS NULL AND executed_at_ms IS NULL
|
|
70
|
+
AND terminal_at_ms IS NULL)
|
|
71
|
+
OR (status = 'executed' AND receipt_b64u IS NULL
|
|
72
|
+
AND receipt_digest_hex IS NULL AND executed_at_ms IS NOT NULL
|
|
73
|
+
AND executed_at_ms >= reserved_at_ms
|
|
74
|
+
AND terminal_at_ms IS NULL)
|
|
75
|
+
OR (status = 'completed' AND receipt_b64u IS NOT NULL
|
|
76
|
+
AND length(receipt_b64u) > 0
|
|
77
|
+
AND receipt_digest_hex IS NOT NULL
|
|
78
|
+
AND executed_at_ms IS NOT NULL
|
|
79
|
+
AND executed_at_ms >= reserved_at_ms
|
|
80
|
+
AND terminal_at_ms IS NOT NULL
|
|
81
|
+
AND terminal_at_ms >= executed_at_ms)
|
|
82
|
+
OR (status = 'failed' AND receipt_b64u IS NOT NULL
|
|
83
|
+
AND length(receipt_b64u) > 0
|
|
84
|
+
AND receipt_digest_hex IS NOT NULL AND executed_at_ms IS NULL
|
|
85
|
+
AND terminal_at_ms IS NOT NULL
|
|
86
|
+
AND terminal_at_ms >= reserved_at_ms)
|
|
87
|
+
)
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
CREATE TABLE tenant_root_creation_tombstones (
|
|
91
|
+
tenant_identity_digest_hex TEXT NOT NULL CHECK (
|
|
92
|
+
length(tenant_identity_digest_hex) = 64
|
|
93
|
+
AND tenant_identity_digest_hex !~ '[^0-9a-f]'
|
|
94
|
+
),
|
|
95
|
+
custody_lineage_b64u TEXT NOT NULL CHECK (length(custody_lineage_b64u) = 22),
|
|
96
|
+
role TEXT NOT NULL CHECK (role = public.tenant_root_store_role()),
|
|
97
|
+
session_id_hex TEXT NOT NULL CHECK (
|
|
98
|
+
length(session_id_hex) = 32
|
|
99
|
+
AND session_id_hex !~ '[^0-9a-f]'
|
|
100
|
+
),
|
|
101
|
+
created_at_ms BIGINT NOT NULL CHECK (created_at_ms > 0),
|
|
102
|
+
PRIMARY KEY (tenant_identity_digest_hex, custody_lineage_b64u, role)
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
CREATE TABLE tenant_root_recovery_attempts (
|
|
106
|
+
recovery_set_id_b64u TEXT PRIMARY KEY CHECK (length(recovery_set_id_b64u) = 22),
|
|
107
|
+
tenant_identity_digest_hex TEXT NOT NULL CHECK (length(tenant_identity_digest_hex) = 64),
|
|
108
|
+
custody_lineage_b64u TEXT NOT NULL CHECK (length(custody_lineage_b64u) = 22),
|
|
109
|
+
role TEXT NOT NULL CHECK (role = public.tenant_root_store_role()),
|
|
110
|
+
command_b64u TEXT NOT NULL CHECK (length(command_b64u) BETWEEN 1 AND 21846),
|
|
111
|
+
admitted_at_ms BIGINT NOT NULL CHECK (admitted_at_ms > 0),
|
|
112
|
+
lifecycle TEXT NOT NULL CHECK (lifecycle IN ('provisioning', 'pending', 'packaged', 'destroying', 'destruction_scheduled', 'destroyed')),
|
|
113
|
+
encrypted_material_b64u TEXT,
|
|
114
|
+
encrypted_package_b64u TEXT,
|
|
115
|
+
package_digest_b64u TEXT,
|
|
116
|
+
destruction_receipt TEXT,
|
|
117
|
+
descriptor_b64u TEXT,
|
|
118
|
+
package_length BIGINT,
|
|
119
|
+
CHECK (
|
|
120
|
+
(lifecycle = 'packaged' AND descriptor_b64u IS NOT NULL AND length(descriptor_b64u) BETWEEN 1 AND 21846 AND package_length IS NOT NULL AND package_length BETWEEN 1 AND 16384)
|
|
121
|
+
OR (lifecycle <> 'packaged' AND descriptor_b64u IS NULL AND package_length IS NULL)
|
|
122
|
+
),
|
|
123
|
+
CHECK (
|
|
124
|
+
(lifecycle IN ('provisioning', 'destroying') AND encrypted_material_b64u IS NULL AND encrypted_package_b64u IS NULL AND package_digest_b64u IS NULL AND destruction_receipt IS NULL)
|
|
125
|
+
OR (lifecycle = 'pending' AND encrypted_material_b64u IS NOT NULL AND encrypted_package_b64u IS NULL AND package_digest_b64u IS NULL AND destruction_receipt IS NULL)
|
|
126
|
+
OR (lifecycle = 'packaged' AND encrypted_material_b64u IS NULL AND encrypted_package_b64u IS NOT NULL AND package_digest_b64u IS NOT NULL AND length(package_digest_b64u) = 43 AND destruction_receipt IS NULL)
|
|
127
|
+
OR (lifecycle IN ('destruction_scheduled', 'destroyed') AND encrypted_material_b64u IS NULL AND encrypted_package_b64u IS NULL AND package_digest_b64u IS NULL AND destruction_receipt IS NOT NULL)
|
|
128
|
+
)
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
CREATE TABLE tenant_root_recovery_retention_keys (
|
|
132
|
+
recovery_set_id_b64u TEXT NOT NULL CHECK (length(recovery_set_id_b64u) = 22),
|
|
133
|
+
role TEXT NOT NULL CHECK (role = public.tenant_root_store_role()),
|
|
134
|
+
key_version BIGINT NOT NULL CHECK (key_version > 0),
|
|
135
|
+
sealed_key_json TEXT NOT NULL CHECK (length(sealed_key_json) BETWEEN 1 AND 4096),
|
|
136
|
+
PRIMARY KEY (recovery_set_id_b64u, key_version)
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
CREATE TABLE tenant_root_refresh_supersessions (
|
|
140
|
+
replay_key_digest_hex TEXT PRIMARY KEY CHECK (
|
|
141
|
+
length(replay_key_digest_hex) = 64
|
|
142
|
+
AND replay_key_digest_hex !~ '[^0-9a-f]'
|
|
143
|
+
),
|
|
144
|
+
tenant_identity_digest_hex TEXT NOT NULL CHECK (
|
|
145
|
+
length(tenant_identity_digest_hex) = 64
|
|
146
|
+
AND tenant_identity_digest_hex !~ '[^0-9a-f]'
|
|
147
|
+
),
|
|
148
|
+
custody_lineage_b64u TEXT NOT NULL CHECK (length(custody_lineage_b64u) = 22),
|
|
149
|
+
role TEXT NOT NULL CHECK (role = public.tenant_root_store_role()),
|
|
150
|
+
superseded_by_replay_key_digest_hex TEXT NOT NULL CHECK (
|
|
151
|
+
length(superseded_by_replay_key_digest_hex) = 64
|
|
152
|
+
AND superseded_by_replay_key_digest_hex !~ '[^0-9a-f]'
|
|
153
|
+
),
|
|
154
|
+
superseded_at_ms BIGINT NOT NULL CHECK (superseded_at_ms > 0)
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
CREATE TABLE tenant_root_restore_import_keys (
|
|
158
|
+
tenant_identity_digest_hex TEXT NOT NULL CHECK (
|
|
159
|
+
length(tenant_identity_digest_hex) = 64
|
|
160
|
+
AND tenant_identity_digest_hex !~ '[^0-9a-f]'
|
|
161
|
+
),
|
|
162
|
+
custody_lineage_b64u TEXT NOT NULL CHECK (length(custody_lineage_b64u) = 22),
|
|
163
|
+
restore_session_id_hex TEXT NOT NULL CHECK (
|
|
164
|
+
length(restore_session_id_hex) = 32
|
|
165
|
+
AND restore_session_id_hex !~ '[^0-9a-f]'
|
|
166
|
+
),
|
|
167
|
+
role TEXT NOT NULL CHECK (role = public.tenant_root_store_role()),
|
|
168
|
+
generation BIGINT NOT NULL CHECK (generation > 0),
|
|
169
|
+
import_key_id TEXT NOT NULL CHECK (length(import_key_id) > 0),
|
|
170
|
+
replay_key_digest_hex TEXT NOT NULL CHECK (
|
|
171
|
+
length(replay_key_digest_hex) = 64
|
|
172
|
+
AND replay_key_digest_hex !~ '[^0-9a-f]'
|
|
173
|
+
),
|
|
174
|
+
command_digest_hex TEXT NOT NULL CHECK (
|
|
175
|
+
length(command_digest_hex) = 64
|
|
176
|
+
AND command_digest_hex !~ '[^0-9a-f]'
|
|
177
|
+
),
|
|
178
|
+
operation_digest_hex TEXT NOT NULL CHECK (
|
|
179
|
+
length(operation_digest_hex) = 64
|
|
180
|
+
AND operation_digest_hex !~ '[^0-9a-f]'
|
|
181
|
+
),
|
|
182
|
+
recovery_set_id_b64u TEXT NOT NULL CHECK (length(recovery_set_id_b64u) = 22),
|
|
183
|
+
manifest_digest_hex TEXT NOT NULL CHECK (
|
|
184
|
+
length(manifest_digest_hex) = 64
|
|
185
|
+
AND manifest_digest_hex !~ '[^0-9a-f]'
|
|
186
|
+
),
|
|
187
|
+
stable_root_commitment_b64u TEXT NOT NULL CHECK (length(stable_root_commitment_b64u) > 0),
|
|
188
|
+
share_commitment_b64u TEXT NOT NULL CHECK (length(share_commitment_b64u) = 46),
|
|
189
|
+
destination_fingerprint_hex TEXT NOT NULL CHECK (
|
|
190
|
+
length(destination_fingerprint_hex) = 64
|
|
191
|
+
AND destination_fingerprint_hex !~ '[^0-9a-f]'
|
|
192
|
+
),
|
|
193
|
+
public_key_b64u TEXT NOT NULL CHECK (length(public_key_b64u) > 0),
|
|
194
|
+
encrypted_ikm_json TEXT CHECK (
|
|
195
|
+
encrypted_ikm_json IS NULL OR (encrypted_ikm_json IS JSON)
|
|
196
|
+
),
|
|
197
|
+
envelope_digest_hex TEXT CHECK (
|
|
198
|
+
envelope_digest_hex IS NULL OR (
|
|
199
|
+
length(envelope_digest_hex) = 64
|
|
200
|
+
AND envelope_digest_hex !~ '[^0-9a-f]'
|
|
201
|
+
)
|
|
202
|
+
),
|
|
203
|
+
encrypted_imported_share_json TEXT CHECK (
|
|
204
|
+
encrypted_imported_share_json IS NULL OR (encrypted_imported_share_json IS JSON)
|
|
205
|
+
),
|
|
206
|
+
issued_at_ms BIGINT NOT NULL CHECK (issued_at_ms > 0),
|
|
207
|
+
expires_at_ms BIGINT NOT NULL CHECK (expires_at_ms > issued_at_ms),
|
|
208
|
+
lifecycle TEXT NOT NULL CHECK (
|
|
209
|
+
lifecycle IN ('issued', 'superseded', 'installed', 'expired', 'closed')
|
|
210
|
+
),
|
|
211
|
+
installed_at_ms BIGINT,
|
|
212
|
+
receipt_digest_hex TEXT CHECK (
|
|
213
|
+
receipt_digest_hex IS NULL OR (
|
|
214
|
+
length(receipt_digest_hex) = 64
|
|
215
|
+
AND receipt_digest_hex !~ '[^0-9a-f]'
|
|
216
|
+
)
|
|
217
|
+
),
|
|
218
|
+
created_at_ms BIGINT NOT NULL CHECK (created_at_ms > 0),
|
|
219
|
+
updated_at_ms BIGINT NOT NULL CHECK (updated_at_ms >= created_at_ms),
|
|
220
|
+
PRIMARY KEY (
|
|
221
|
+
tenant_identity_digest_hex,
|
|
222
|
+
custody_lineage_b64u,
|
|
223
|
+
restore_session_id_hex,
|
|
224
|
+
role,
|
|
225
|
+
generation
|
|
226
|
+
),
|
|
227
|
+
UNIQUE (replay_key_digest_hex),
|
|
228
|
+
UNIQUE (
|
|
229
|
+
tenant_identity_digest_hex,
|
|
230
|
+
custody_lineage_b64u,
|
|
231
|
+
restore_session_id_hex,
|
|
232
|
+
role,
|
|
233
|
+
import_key_id
|
|
234
|
+
),
|
|
235
|
+
CHECK (
|
|
236
|
+
(lifecycle IN ('issued', 'superseded', 'expired', 'closed')
|
|
237
|
+
AND installed_at_ms IS NULL AND receipt_digest_hex IS NULL
|
|
238
|
+
AND envelope_digest_hex IS NULL AND encrypted_imported_share_json IS NULL
|
|
239
|
+
AND (lifecycle = 'closed') = (encrypted_ikm_json IS NULL))
|
|
240
|
+
OR (lifecycle = 'installed'
|
|
241
|
+
AND installed_at_ms IS NOT NULL
|
|
242
|
+
AND installed_at_ms >= issued_at_ms
|
|
243
|
+
AND receipt_digest_hex IS NOT NULL
|
|
244
|
+
AND envelope_digest_hex IS NOT NULL
|
|
245
|
+
AND encrypted_imported_share_json IS NOT NULL
|
|
246
|
+
AND encrypted_ikm_json IS NOT NULL)
|
|
247
|
+
)
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
CREATE TABLE tenant_root_restore_import_sessions (
|
|
251
|
+
tenant_identity_digest_hex TEXT NOT NULL CHECK (
|
|
252
|
+
length(tenant_identity_digest_hex) = 64
|
|
253
|
+
AND tenant_identity_digest_hex !~ '[^0-9a-f]'
|
|
254
|
+
),
|
|
255
|
+
custody_lineage_b64u TEXT NOT NULL CHECK (length(custody_lineage_b64u) = 22),
|
|
256
|
+
restore_session_id_hex TEXT NOT NULL CHECK (
|
|
257
|
+
length(restore_session_id_hex) = 32
|
|
258
|
+
AND restore_session_id_hex !~ '[^0-9a-f]'
|
|
259
|
+
),
|
|
260
|
+
closed_at_ms BIGINT NOT NULL CHECK (closed_at_ms > 0), role TEXT NOT NULL DEFAULT 'deriver_a' CHECK (
|
|
261
|
+
role = public.tenant_root_store_role()
|
|
262
|
+
), activation_operation TEXT CHECK (
|
|
263
|
+
activation_operation IS NULL OR activation_operation = 'initial_creation'
|
|
264
|
+
), activation_receipt_b64u TEXT CHECK (
|
|
265
|
+
activation_receipt_b64u IS NULL OR length(activation_receipt_b64u) BETWEEN 1 AND 32768
|
|
266
|
+
), activation_receipt_digest_hex TEXT CHECK (
|
|
267
|
+
activation_receipt_digest_hex IS NULL OR (
|
|
268
|
+
length(activation_receipt_digest_hex) = 64
|
|
269
|
+
AND activation_receipt_digest_hex !~ '[^0-9a-f]'
|
|
270
|
+
)
|
|
271
|
+
), cleanup_receipt_b64u TEXT CHECK (
|
|
272
|
+
cleanup_receipt_b64u IS NULL OR length(cleanup_receipt_b64u) BETWEEN 1 AND 32768
|
|
273
|
+
), cleanup_receipt_digest_hex TEXT CHECK (
|
|
274
|
+
cleanup_receipt_digest_hex IS NULL OR (
|
|
275
|
+
length(cleanup_receipt_digest_hex) = 64
|
|
276
|
+
AND cleanup_receipt_digest_hex !~ '[^0-9a-f]'
|
|
277
|
+
)
|
|
278
|
+
), cleanup_grant_b64u TEXT CHECK (
|
|
279
|
+
cleanup_grant_b64u IS NULL OR (
|
|
280
|
+
length(cleanup_grant_b64u) BETWEEN 1 AND 32768
|
|
281
|
+
AND activation_operation IS NULL
|
|
282
|
+
AND activation_receipt_b64u IS NULL
|
|
283
|
+
AND activation_receipt_digest_hex IS NULL
|
|
284
|
+
)
|
|
285
|
+
),
|
|
286
|
+
PRIMARY KEY (
|
|
287
|
+
tenant_identity_digest_hex,
|
|
288
|
+
custody_lineage_b64u,
|
|
289
|
+
restore_session_id_hex
|
|
290
|
+
)
|
|
291
|
+
);
|
|
292
|
+
|
|
293
|
+
CREATE TABLE tenant_root_restore_refresh_attempts (
|
|
294
|
+
tenant_identity_digest_hex TEXT NOT NULL CHECK (
|
|
295
|
+
length(tenant_identity_digest_hex) = 64
|
|
296
|
+
AND tenant_identity_digest_hex !~ '[^0-9a-f]'
|
|
297
|
+
),
|
|
298
|
+
custody_lineage_b64u TEXT NOT NULL CHECK (length(custody_lineage_b64u) = 22),
|
|
299
|
+
restore_session_id_hex TEXT NOT NULL CHECK (
|
|
300
|
+
length(restore_session_id_hex) = 32
|
|
301
|
+
AND restore_session_id_hex !~ '[^0-9a-f]'
|
|
302
|
+
),
|
|
303
|
+
role TEXT NOT NULL CHECK (role = public.tenant_root_store_role()),
|
|
304
|
+
generation BIGINT NOT NULL CHECK (generation > 0),
|
|
305
|
+
import_key_id TEXT NOT NULL CHECK (length(import_key_id) BETWEEN 1 AND 128),
|
|
306
|
+
import_replay_key_digest_hex TEXT NOT NULL CHECK (
|
|
307
|
+
length(import_replay_key_digest_hex) = 64
|
|
308
|
+
AND import_replay_key_digest_hex !~ '[^0-9a-f]'
|
|
309
|
+
),
|
|
310
|
+
import_command_digest_hex TEXT NOT NULL CHECK (
|
|
311
|
+
length(import_command_digest_hex) = 64
|
|
312
|
+
AND import_command_digest_hex !~ '[^0-9a-f]'
|
|
313
|
+
),
|
|
314
|
+
import_operation_digest_hex TEXT NOT NULL CHECK (
|
|
315
|
+
length(import_operation_digest_hex) = 64
|
|
316
|
+
AND import_operation_digest_hex !~ '[^0-9a-f]'
|
|
317
|
+
),
|
|
318
|
+
recovery_set_id_b64u TEXT NOT NULL CHECK (length(recovery_set_id_b64u) = 22),
|
|
319
|
+
manifest_digest_hex TEXT NOT NULL CHECK (
|
|
320
|
+
length(manifest_digest_hex) = 64
|
|
321
|
+
AND manifest_digest_hex !~ '[^0-9a-f]'
|
|
322
|
+
),
|
|
323
|
+
stable_root_commitment_b64u TEXT NOT NULL CHECK (length(stable_root_commitment_b64u) = 43),
|
|
324
|
+
share_commitment_b64u TEXT NOT NULL CHECK (length(share_commitment_b64u) = 46),
|
|
325
|
+
destination_fingerprint_hex TEXT NOT NULL CHECK (
|
|
326
|
+
length(destination_fingerprint_hex) = 64
|
|
327
|
+
AND destination_fingerprint_hex !~ '[^0-9a-f]'
|
|
328
|
+
),
|
|
329
|
+
import_public_key_b64u TEXT NOT NULL CHECK (length(import_public_key_b64u) = 43),
|
|
330
|
+
import_issued_at_ms BIGINT NOT NULL CHECK (import_issued_at_ms > 0),
|
|
331
|
+
import_expires_at_ms BIGINT NOT NULL CHECK (import_expires_at_ms > import_issued_at_ms),
|
|
332
|
+
refresh_command_digest_hex TEXT NOT NULL CHECK (
|
|
333
|
+
length(refresh_command_digest_hex) = 64
|
|
334
|
+
AND refresh_command_digest_hex !~ '[^0-9a-f]'
|
|
335
|
+
),
|
|
336
|
+
refresh_issued_at_ms BIGINT NOT NULL CHECK (refresh_issued_at_ms > 0),
|
|
337
|
+
refresh_expires_at_ms BIGINT NOT NULL CHECK (refresh_expires_at_ms > refresh_issued_at_ms),
|
|
338
|
+
admitted_at_ms BIGINT NOT NULL CHECK (admitted_at_ms > 0),
|
|
339
|
+
encrypted_seed_json TEXT CHECK (
|
|
340
|
+
encrypted_seed_json IS NULL OR (encrypted_seed_json IS JSON)
|
|
341
|
+
),
|
|
342
|
+
encrypted_refreshed_share_json TEXT CHECK (
|
|
343
|
+
encrypted_refreshed_share_json IS NULL OR (encrypted_refreshed_share_json IS JSON)
|
|
344
|
+
),
|
|
345
|
+
installation_evidence_b64u TEXT CHECK (
|
|
346
|
+
installation_evidence_b64u IS NULL OR length(installation_evidence_b64u) BETWEEN 1 AND 8192
|
|
347
|
+
),
|
|
348
|
+
installation_evidence_digest_hex TEXT CHECK (
|
|
349
|
+
installation_evidence_digest_hex IS NULL OR (
|
|
350
|
+
length(installation_evidence_digest_hex) = 64
|
|
351
|
+
AND installation_evidence_digest_hex !~ '[^0-9a-f]'
|
|
352
|
+
)
|
|
353
|
+
),
|
|
354
|
+
lifecycle TEXT NOT NULL CHECK (lifecycle IN ('pending', 'refreshed', 'closed')),
|
|
355
|
+
refreshed_at_ms BIGINT CHECK (refreshed_at_ms IS NULL OR refreshed_at_ms >= admitted_at_ms),
|
|
356
|
+
created_at_ms BIGINT NOT NULL CHECK (created_at_ms > 0),
|
|
357
|
+
updated_at_ms BIGINT NOT NULL CHECK (updated_at_ms >= created_at_ms), promotion_lifecycle TEXT NOT NULL DEFAULT 'unstarted' CHECK (
|
|
358
|
+
promotion_lifecycle IN ('unstarted', 'reserved', 'completed')
|
|
359
|
+
), promotion_reserved_at_ms BIGINT CHECK (
|
|
360
|
+
promotion_reserved_at_ms IS NULL OR promotion_reserved_at_ms > 0
|
|
361
|
+
), encrypted_online_role_share_json TEXT CHECK (
|
|
362
|
+
encrypted_online_role_share_json IS NULL OR (encrypted_online_role_share_json IS JSON)
|
|
363
|
+
), provider_canary_receipt_b64u TEXT CHECK (
|
|
364
|
+
provider_canary_receipt_b64u IS NULL OR length(provider_canary_receipt_b64u) BETWEEN 1 AND 32768
|
|
365
|
+
), promotion_completed_at_ms BIGINT CHECK (
|
|
366
|
+
promotion_completed_at_ms IS NULL OR promotion_completed_at_ms > 0
|
|
367
|
+
),
|
|
368
|
+
PRIMARY KEY (import_replay_key_digest_hex),
|
|
369
|
+
UNIQUE (
|
|
370
|
+
tenant_identity_digest_hex,
|
|
371
|
+
custody_lineage_b64u,
|
|
372
|
+
restore_session_id_hex,
|
|
373
|
+
role,
|
|
374
|
+
generation
|
|
375
|
+
),
|
|
376
|
+
CHECK (
|
|
377
|
+
(lifecycle = 'pending'
|
|
378
|
+
AND encrypted_seed_json IS NOT NULL
|
|
379
|
+
AND encrypted_refreshed_share_json IS NULL
|
|
380
|
+
AND installation_evidence_b64u IS NULL
|
|
381
|
+
AND installation_evidence_digest_hex IS NULL
|
|
382
|
+
AND refreshed_at_ms IS NULL)
|
|
383
|
+
OR (lifecycle = 'refreshed'
|
|
384
|
+
AND encrypted_seed_json IS NOT NULL
|
|
385
|
+
AND encrypted_refreshed_share_json IS NOT NULL
|
|
386
|
+
AND installation_evidence_b64u IS NOT NULL
|
|
387
|
+
AND installation_evidence_digest_hex IS NOT NULL
|
|
388
|
+
AND refreshed_at_ms IS NOT NULL)
|
|
389
|
+
OR (lifecycle = 'closed'
|
|
390
|
+
AND encrypted_seed_json IS NULL
|
|
391
|
+
AND encrypted_refreshed_share_json IS NULL
|
|
392
|
+
AND installation_evidence_b64u IS NULL
|
|
393
|
+
AND installation_evidence_digest_hex IS NULL
|
|
394
|
+
AND refreshed_at_ms IS NULL)
|
|
395
|
+
)
|
|
396
|
+
);
|
|
397
|
+
|
|
398
|
+
CREATE TABLE tenant_root_role_shares (
|
|
399
|
+
tenant_identity_digest_hex TEXT NOT NULL CHECK (
|
|
400
|
+
length(tenant_identity_digest_hex) = 64
|
|
401
|
+
AND tenant_identity_digest_hex !~ '[^0-9a-f]'
|
|
402
|
+
),
|
|
403
|
+
custody_lineage_b64u TEXT NOT NULL CHECK (length(custody_lineage_b64u) = 22),
|
|
404
|
+
tenant_root_share_epoch BIGINT NOT NULL CHECK (tenant_root_share_epoch > 0),
|
|
405
|
+
role TEXT NOT NULL CHECK (role = public.tenant_root_store_role()),
|
|
406
|
+
lifecycle TEXT NOT NULL CHECK (lifecycle IN ('pending', 'active', 'retired')),
|
|
407
|
+
ciphertext_json TEXT NOT NULL CHECK ((ciphertext_json IS JSON)),
|
|
408
|
+
revision BIGINT NOT NULL CHECK (revision > 0),
|
|
409
|
+
created_at_ms BIGINT NOT NULL CHECK (created_at_ms > 0),
|
|
410
|
+
updated_at_ms BIGINT NOT NULL CHECK (updated_at_ms >= created_at_ms),
|
|
411
|
+
PRIMARY KEY (
|
|
412
|
+
tenant_identity_digest_hex,
|
|
413
|
+
custody_lineage_b64u,
|
|
414
|
+
tenant_root_share_epoch,
|
|
415
|
+
role
|
|
416
|
+
)
|
|
417
|
+
);
|
|
418
|
+
|
|
419
|
+
CREATE TABLE tenant_root_root_use_admissions (
|
|
420
|
+
tenant_identity_digest_hex TEXT NOT NULL CHECK (
|
|
421
|
+
length(tenant_identity_digest_hex) = 64
|
|
422
|
+
AND tenant_identity_digest_hex !~ '[^0-9a-f]'
|
|
423
|
+
),
|
|
424
|
+
custody_lineage_b64u TEXT NOT NULL CHECK (length(custody_lineage_b64u) = 22),
|
|
425
|
+
role TEXT NOT NULL CHECK (role = public.tenant_root_store_role()),
|
|
426
|
+
attempt_kind TEXT NOT NULL CHECK (
|
|
427
|
+
attempt_kind IN ('ed25519_yao_pair_session', 'ecdsa_operation')
|
|
428
|
+
),
|
|
429
|
+
attempt_key_hex TEXT NOT NULL CHECK (
|
|
430
|
+
length(attempt_key_hex) BETWEEN 32 AND 96
|
|
431
|
+
AND attempt_key_hex !~ '[^0-9a-f]'
|
|
432
|
+
),
|
|
433
|
+
tenant_root_share_epoch BIGINT NOT NULL CHECK (tenant_root_share_epoch > 0),
|
|
434
|
+
activation_receipt_digest_hex TEXT NOT NULL CHECK (
|
|
435
|
+
length(activation_receipt_digest_hex) = 64
|
|
436
|
+
AND activation_receipt_digest_hex !~ '[^0-9a-f]'
|
|
437
|
+
),
|
|
438
|
+
attempt_digest_hex TEXT NOT NULL CHECK (
|
|
439
|
+
length(attempt_digest_hex) = 64
|
|
440
|
+
AND attempt_digest_hex !~ '[^0-9a-f]'
|
|
441
|
+
),
|
|
442
|
+
first_binding_digest_hex TEXT NOT NULL CHECK (
|
|
443
|
+
length(first_binding_digest_hex) = 64
|
|
444
|
+
AND first_binding_digest_hex !~ '[^0-9a-f]'
|
|
445
|
+
),
|
|
446
|
+
issued_at_ms BIGINT NOT NULL CHECK (issued_at_ms > 0),
|
|
447
|
+
expires_at_ms BIGINT NOT NULL CHECK (expires_at_ms > issued_at_ms),
|
|
448
|
+
status TEXT NOT NULL CHECK (status IN ('admitted', 'claimed', 'settled', 'cancelled')),
|
|
449
|
+
admitted_at_ms BIGINT NOT NULL CHECK (admitted_at_ms > 0),
|
|
450
|
+
pair_object_id TEXT CHECK (
|
|
451
|
+
pair_object_id IS NULL
|
|
452
|
+
OR (attempt_kind = 'ed25519_yao_pair_session' AND length(pair_object_id) = 64 AND pair_object_id !~ '[^0-9a-f]')
|
|
453
|
+
),
|
|
454
|
+
preparation_digest_hex TEXT
|
|
455
|
+
CHECK (preparation_digest_hex IS NULL OR (
|
|
456
|
+
length(preparation_digest_hex) = 64
|
|
457
|
+
AND preparation_digest_hex !~ '[^0-9a-f]'
|
|
458
|
+
)),
|
|
459
|
+
PRIMARY KEY (
|
|
460
|
+
tenant_identity_digest_hex,
|
|
461
|
+
custody_lineage_b64u,
|
|
462
|
+
role,
|
|
463
|
+
attempt_kind,
|
|
464
|
+
attempt_key_hex
|
|
465
|
+
)
|
|
466
|
+
);
|
|
467
|
+
|
|
468
|
+
CREATE TABLE tenant_root_source_retirements (
|
|
469
|
+
tenant_identity_digest_hex TEXT NOT NULL CHECK (length(tenant_identity_digest_hex) = 64),
|
|
470
|
+
custody_lineage_b64u TEXT NOT NULL CHECK (length(custody_lineage_b64u) = 22),
|
|
471
|
+
role TEXT NOT NULL CHECK (role = public.tenant_root_store_role()),
|
|
472
|
+
active_receipt_digest_b64u TEXT NOT NULL CHECK (length(active_receipt_digest_b64u) = 43),
|
|
473
|
+
destination_receipt_digest_b64u TEXT NOT NULL CHECK (length(destination_receipt_digest_b64u) = 43),
|
|
474
|
+
retired_at_ms BIGINT NOT NULL CHECK (retired_at_ms > 0),
|
|
475
|
+
PRIMARY KEY (tenant_identity_digest_hex, custody_lineage_b64u)
|
|
476
|
+
);
|
|
477
|
+
|
|
478
|
+
CREATE INDEX tenant_root_command_replays_tenant_status
|
|
479
|
+
ON tenant_root_command_replays (
|
|
480
|
+
tenant_identity_digest_hex,
|
|
481
|
+
custody_lineage_b64u,
|
|
482
|
+
role,
|
|
483
|
+
status
|
|
484
|
+
);
|
|
485
|
+
|
|
486
|
+
CREATE INDEX tenant_root_recovery_attempts_lineage ON tenant_root_recovery_attempts (tenant_identity_digest_hex, custody_lineage_b64u);
|
|
487
|
+
|
|
488
|
+
CREATE INDEX tenant_root_restore_import_keys_current
|
|
489
|
+
ON tenant_root_restore_import_keys (
|
|
490
|
+
tenant_identity_digest_hex,
|
|
491
|
+
custody_lineage_b64u,
|
|
492
|
+
restore_session_id_hex,
|
|
493
|
+
role,
|
|
494
|
+
generation DESC
|
|
495
|
+
);
|
|
496
|
+
|
|
497
|
+
CREATE INDEX tenant_root_restore_refresh_attempts_session
|
|
498
|
+
ON tenant_root_restore_refresh_attempts (
|
|
499
|
+
tenant_identity_digest_hex,
|
|
500
|
+
custody_lineage_b64u,
|
|
501
|
+
restore_session_id_hex,
|
|
502
|
+
role,
|
|
503
|
+
lifecycle
|
|
504
|
+
);
|
|
505
|
+
|
|
506
|
+
CREATE UNIQUE INDEX tenant_root_role_shares_active
|
|
507
|
+
ON tenant_root_role_shares (tenant_identity_digest_hex, role)
|
|
508
|
+
WHERE lifecycle = 'active';
|
|
509
|
+
|
|
510
|
+
CREATE INDEX tenant_root_role_shares_lifecycle
|
|
511
|
+
ON tenant_root_role_shares (
|
|
512
|
+
tenant_identity_digest_hex,
|
|
513
|
+
role,
|
|
514
|
+
lifecycle,
|
|
515
|
+
tenant_root_share_epoch
|
|
516
|
+
);
|
|
517
|
+
|
|
518
|
+
CREATE INDEX tenant_root_root_use_admissions_by_attempt
|
|
519
|
+
ON tenant_root_root_use_admissions (role, attempt_kind, attempt_key_hex);
|
|
520
|
+
|
|
521
|
+
CREATE INDEX tenant_root_root_use_admissions_by_epoch
|
|
522
|
+
ON tenant_root_root_use_admissions (
|
|
523
|
+
tenant_identity_digest_hex,
|
|
524
|
+
custody_lineage_b64u,
|
|
525
|
+
tenant_root_share_epoch,
|
|
526
|
+
status
|
|
527
|
+
);
|
|
528
|
+
|
|
529
|
+
-- A retired lineage cannot regain live role or recovery material.
|
|
530
|
+
CREATE FUNCTION public.reject_retired_tenant_root_lineage() RETURNS TRIGGER
|
|
531
|
+
LANGUAGE plpgsql AS $$
|
|
532
|
+
BEGIN
|
|
533
|
+
IF TG_TABLE_NAME = 'tenant_root_recovery_attempts' THEN
|
|
534
|
+
IF NEW.lifecycle NOT IN ('provisioning', 'pending', 'packaged') THEN
|
|
535
|
+
RETURN NEW;
|
|
536
|
+
END IF;
|
|
537
|
+
END IF;
|
|
538
|
+
IF EXISTS (
|
|
539
|
+
SELECT 1 FROM public.tenant_root_source_retirements
|
|
540
|
+
WHERE tenant_identity_digest_hex = NEW.tenant_identity_digest_hex
|
|
541
|
+
AND custody_lineage_b64u = NEW.custody_lineage_b64u
|
|
542
|
+
) THEN
|
|
543
|
+
RAISE EXCEPTION 'tenant root source lineage is retired' USING ERRCODE = '23514';
|
|
544
|
+
END IF;
|
|
545
|
+
RETURN NEW;
|
|
546
|
+
END;
|
|
547
|
+
$$;
|
|
548
|
+
|
|
549
|
+
CREATE TRIGGER tenant_root_role_shares_source_retired
|
|
550
|
+
BEFORE INSERT OR UPDATE ON tenant_root_role_shares
|
|
551
|
+
FOR EACH ROW EXECUTE FUNCTION public.reject_retired_tenant_root_lineage();
|
|
552
|
+
|
|
553
|
+
CREATE TRIGGER tenant_root_command_replays_source_retired
|
|
554
|
+
BEFORE INSERT OR UPDATE ON tenant_root_command_replays
|
|
555
|
+
FOR EACH ROW EXECUTE FUNCTION public.reject_retired_tenant_root_lineage();
|
|
556
|
+
|
|
557
|
+
CREATE TRIGGER tenant_root_restore_import_keys_source_retired
|
|
558
|
+
BEFORE INSERT OR UPDATE ON tenant_root_restore_import_keys
|
|
559
|
+
FOR EACH ROW EXECUTE FUNCTION public.reject_retired_tenant_root_lineage();
|
|
560
|
+
|
|
561
|
+
CREATE TRIGGER tenant_root_restore_refresh_attempts_source_retired
|
|
562
|
+
BEFORE INSERT OR UPDATE ON tenant_root_restore_refresh_attempts
|
|
563
|
+
FOR EACH ROW EXECUTE FUNCTION public.reject_retired_tenant_root_lineage();
|
|
564
|
+
|
|
565
|
+
CREATE TRIGGER tenant_root_recovery_attempts_source_retired
|
|
566
|
+
BEFORE INSERT OR UPDATE ON tenant_root_recovery_attempts
|
|
567
|
+
FOR EACH ROW EXECUTE FUNCTION public.reject_retired_tenant_root_lineage();
|
|
@@ -7,12 +7,27 @@ import { computeCapabilityOperationFingerprintDigest } from "../shared-ts/src/au
|
|
|
7
7
|
const FACTOR_EVIDENCE_DIGEST_DOMAIN_V1 = "seams:authorization:factor-evidence:v1";
|
|
8
8
|
const EVIDENCE_SET_DIGEST_DOMAIN_V1 = "seams:authorization:evidence-set:v1";
|
|
9
9
|
var VerifiedWalletOperationEvidenceSetProof = class {
|
|
10
|
+
kind = "verified_wallet_operation_evidence_set";
|
|
11
|
+
tenantId;
|
|
12
|
+
principalId;
|
|
13
|
+
walletId;
|
|
14
|
+
authorityRef;
|
|
15
|
+
requestOrigin;
|
|
16
|
+
audience;
|
|
17
|
+
evidenceSetId;
|
|
18
|
+
evidence;
|
|
19
|
+
evidenceSetDigest;
|
|
20
|
+
operation;
|
|
21
|
+
laneDigest;
|
|
22
|
+
intentDigest;
|
|
23
|
+
displayDigest;
|
|
24
|
+
assurance = "step_up";
|
|
25
|
+
verifiedAtMs;
|
|
26
|
+
expiresAtMs;
|
|
10
27
|
retainVerifiedEvidenceProof() {
|
|
11
28
|
return true;
|
|
12
29
|
}
|
|
13
30
|
constructor(fields) {
|
|
14
|
-
this.kind = "verified_wallet_operation_evidence_set";
|
|
15
|
-
this.assurance = "step_up";
|
|
16
31
|
this.retainVerifiedEvidenceProof();
|
|
17
32
|
requireWalletOperationEvidenceSetFields(fields);
|
|
18
33
|
this.tenantId = fields.tenantId;
|
|
@@ -82,10 +97,23 @@ function buildVerifiedWalletSessionEmailOtpFactorResult(fields) {
|
|
|
82
97
|
}
|
|
83
98
|
/** Nominal server-only owner proofs; private constructors block browser forgery. */
|
|
84
99
|
var VerifiedOwnerWalletSessionProof = class {
|
|
100
|
+
__proofBrand = true;
|
|
101
|
+
kind = "verified_owner_proof_v1";
|
|
102
|
+
proofId;
|
|
103
|
+
method;
|
|
104
|
+
authSource;
|
|
105
|
+
tenantId;
|
|
106
|
+
principalId;
|
|
107
|
+
walletId;
|
|
108
|
+
authority;
|
|
109
|
+
origin;
|
|
110
|
+
audience;
|
|
111
|
+
replayIdentity;
|
|
112
|
+
verifiedAtMs;
|
|
113
|
+
expiresAtMs;
|
|
114
|
+
purpose = "wallet_session";
|
|
115
|
+
operation;
|
|
85
116
|
constructor(fields) {
|
|
86
|
-
this.__proofBrand = true;
|
|
87
|
-
this.kind = "verified_owner_proof_v1";
|
|
88
|
-
this.purpose = "wallet_session";
|
|
89
117
|
requireOwnerProofFields(fields);
|
|
90
118
|
this.proofId = fields.proofId;
|
|
91
119
|
this.method = fields.method;
|
|
@@ -102,10 +130,23 @@ var VerifiedOwnerWalletSessionProof = class {
|
|
|
102
130
|
}
|
|
103
131
|
};
|
|
104
132
|
var VerifiedOwnerOperationProof = class {
|
|
133
|
+
__proofBrand = true;
|
|
134
|
+
kind = "verified_owner_proof_v1";
|
|
135
|
+
proofId;
|
|
136
|
+
method;
|
|
137
|
+
authSource;
|
|
138
|
+
tenantId;
|
|
139
|
+
principalId;
|
|
140
|
+
walletId;
|
|
141
|
+
authority;
|
|
142
|
+
origin;
|
|
143
|
+
audience;
|
|
144
|
+
replayIdentity;
|
|
145
|
+
verifiedAtMs;
|
|
146
|
+
expiresAtMs;
|
|
147
|
+
purpose = "operation";
|
|
148
|
+
operation;
|
|
105
149
|
constructor(fields) {
|
|
106
|
-
this.__proofBrand = true;
|
|
107
|
-
this.kind = "verified_owner_proof_v1";
|
|
108
|
-
this.purpose = "operation";
|
|
109
150
|
requireOwnerProofFields(fields);
|
|
110
151
|
this.proofId = fields.proofId;
|
|
111
152
|
this.method = fields.method;
|
|
@@ -118,24 +118,24 @@ function createVaultProxyUseRouteExtension(input) {
|
|
|
118
118
|
return new VaultProxyUseRouteExtension(input.service, input.now ?? Date.now);
|
|
119
119
|
}
|
|
120
120
|
var VaultProxyUseRouteExtension = class {
|
|
121
|
+
kind = "fetch_route_extension";
|
|
122
|
+
id = "vault_proxy_use";
|
|
123
|
+
routes = [defineRoute({
|
|
124
|
+
id: "vault_proxy_use",
|
|
125
|
+
surface: "relay",
|
|
126
|
+
method: "POST",
|
|
127
|
+
path: "/vault/proxy-use",
|
|
128
|
+
auth: {
|
|
129
|
+
plane: "public",
|
|
130
|
+
proof: "intent_grant",
|
|
131
|
+
rationale: "The exact one-use capability grant authorizes this vault proxy operation."
|
|
132
|
+
},
|
|
133
|
+
metering: { kind: "none" },
|
|
134
|
+
summary: "Use one persisted vault secret through the configured gateway"
|
|
135
|
+
})];
|
|
121
136
|
constructor(service, now) {
|
|
122
137
|
this.service = service;
|
|
123
138
|
this.now = now;
|
|
124
|
-
this.kind = "fetch_route_extension";
|
|
125
|
-
this.id = "vault_proxy_use";
|
|
126
|
-
this.routes = [defineRoute({
|
|
127
|
-
id: "vault_proxy_use",
|
|
128
|
-
surface: "relay",
|
|
129
|
-
method: "POST",
|
|
130
|
-
path: "/vault/proxy-use",
|
|
131
|
-
auth: {
|
|
132
|
-
plane: "public",
|
|
133
|
-
proof: "intent_grant",
|
|
134
|
-
rationale: "The exact one-use capability grant authorizes this vault proxy operation."
|
|
135
|
-
},
|
|
136
|
-
metering: { kind: "none" },
|
|
137
|
-
summary: "Use one persisted vault secret through the configured gateway"
|
|
138
|
-
})];
|
|
139
139
|
}
|
|
140
140
|
async handleFetchRoute(input) {
|
|
141
141
|
const parsed = await parseVaultProxyUseRequest(await readJson(input.request), this.now());
|
|
@@ -7,6 +7,7 @@ function normalizeParsedCorsOrigin(url) {
|
|
|
7
7
|
return `${proto}//${host}${rawPort && !(proto === "https:" && rawPort === "443") && !(proto === "http:" && rawPort === "80") ? `:${rawPort}` : ""}`;
|
|
8
8
|
}
|
|
9
9
|
var SessionService = class {
|
|
10
|
+
cfg;
|
|
10
11
|
constructor(cfg) {
|
|
11
12
|
this.cfg = cfg || {};
|
|
12
13
|
}
|