@hasna/infinity 0.1.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 (112) hide show
  1. package/LICENSE +3 -0
  2. package/README.md +331 -0
  3. package/dist/cli.js +2965 -0
  4. package/dist/http-api.js +6448 -0
  5. package/dist/index.js +28536 -0
  6. package/dist/migrate.js +346 -0
  7. package/dist/self-hosted-migrate.js +2064 -0
  8. package/dist/self-hosted.js +13180 -0
  9. package/dist/types/authcapsules/codewith-local.d.ts +109 -0
  10. package/dist/types/authcapsules/infinity-agent-policy.d.ts +57 -0
  11. package/dist/types/authcapsules/os-isolated-runner.d.ts +87 -0
  12. package/dist/types/authority/authority.d.ts +342 -0
  13. package/dist/types/authority/effect-journal.d.ts +205 -0
  14. package/dist/types/authority/mutation-journal.d.ts +163 -0
  15. package/dist/types/authority/mutation-tuple.d.ts +26 -0
  16. package/dist/types/authority/state.d.ts +75 -0
  17. package/dist/types/authority/store.d.ts +15 -0
  18. package/dist/types/brokers/checkpoint/archive.d.ts +21 -0
  19. package/dist/types/brokers/checkpoint/bundle.d.ts +22 -0
  20. package/dist/types/brokers/checkpoint/bytes.d.ts +4 -0
  21. package/dist/types/brokers/checkpoint/clean-verifier-finalization.d.ts +62 -0
  22. package/dist/types/brokers/checkpoint/clean-verifier.d.ts +145 -0
  23. package/dist/types/brokers/checkpoint/final-trust-authority.d.ts +55 -0
  24. package/dist/types/brokers/checkpoint/idempotency.d.ts +25 -0
  25. package/dist/types/brokers/checkpoint/journaled-store.d.ts +9 -0
  26. package/dist/types/brokers/checkpoint/manifest-signature.d.ts +135 -0
  27. package/dist/types/brokers/checkpoint/manifest.d.ts +57 -0
  28. package/dist/types/brokers/checkpoint/s3-store.d.ts +215 -0
  29. package/dist/types/brokers/checkpoint/seal-authority.d.ts +86 -0
  30. package/dist/types/brokers/checkpoint/service.d.ts +198 -0
  31. package/dist/types/brokers/checkpoint/signing-message.d.ts +22 -0
  32. package/dist/types/brokers/checkpoint/store.d.ts +76 -0
  33. package/dist/types/brokers/checkpoint/verifier-cleanup-authority.d.ts +108 -0
  34. package/dist/types/brokers/checkpoint/verifier-cleanup.d.ts +391 -0
  35. package/dist/types/brokers/checkpoint/verifier.d.ts +225 -0
  36. package/dist/types/brokers/composition.d.ts +86 -0
  37. package/dist/types/brokers/git/github-app.d.ts +216 -0
  38. package/dist/types/brokers/git/promotion.d.ts +418 -0
  39. package/dist/types/brokers/persistence/contracts.d.ts +77 -0
  40. package/dist/types/brokers/persistence/memory.d.ts +5 -0
  41. package/dist/types/brokers/persistence/migration.d.ts +6 -0
  42. package/dist/types/brokers/persistence/postgres.d.ts +74 -0
  43. package/dist/types/cli/main.d.ts +2 -0
  44. package/dist/types/cli/operation-journal.d.ts +47 -0
  45. package/dist/types/cli/run.d.ts +15 -0
  46. package/dist/types/client/operator-client.d.ts +100 -0
  47. package/dist/types/contracts/dtos.d.ts +198 -0
  48. package/dist/types/contracts/events.d.ts +45 -0
  49. package/dist/types/contracts/fence.d.ts +39 -0
  50. package/dist/types/contracts/operations.d.ts +91 -0
  51. package/dist/types/contracts/runspec.d.ts +75 -0
  52. package/dist/types/contracts/validators.d.ts +8 -0
  53. package/dist/types/core/clock.d.ts +12 -0
  54. package/dist/types/core/errors.d.ts +18 -0
  55. package/dist/types/core/ids.d.ts +10 -0
  56. package/dist/types/core/int64.d.ts +7 -0
  57. package/dist/types/core/strict-json.d.ts +8 -0
  58. package/dist/types/core/validation.d.ts +25 -0
  59. package/dist/types/golden/disposable-task.d.ts +108 -0
  60. package/dist/types/golden/source-pins.d.ts +77 -0
  61. package/dist/types/http/api.d.ts +52 -0
  62. package/dist/types/http/bearer-auth.d.ts +8 -0
  63. package/dist/types/http/main.d.ts +3 -0
  64. package/dist/types/http/self-hosted-main.d.ts +17 -0
  65. package/dist/types/index.d.ts +65 -0
  66. package/dist/types/mcp/schema.d.ts +7 -0
  67. package/dist/types/node-agent/agent.d.ts +174 -0
  68. package/dist/types/node-agent/contracts.d.ts +119 -0
  69. package/dist/types/node-agent/macos-service.d.ts +33 -0
  70. package/dist/types/node-agent/service-cli.d.ts +26 -0
  71. package/dist/types/persistence/composition.d.ts +49 -0
  72. package/dist/types/persistence/migrate-main.d.ts +2 -0
  73. package/dist/types/persistence/migrations.d.ts +30 -0
  74. package/dist/types/persistence/postgres-accounts-operation.d.ts +26 -0
  75. package/dist/types/persistence/postgres-authority.d.ts +69 -0
  76. package/dist/types/persistence/postgres-external-mutation-journal.d.ts +22 -0
  77. package/dist/types/persistence/postgres-json.d.ts +1 -0
  78. package/dist/types/persistence/postgres-mutation-journal.d.ts +31 -0
  79. package/dist/types/persistence/postgres-reconciler.d.ts +34 -0
  80. package/dist/types/persistence/postgres-sandbox-dispatch-authority.d.ts +9 -0
  81. package/dist/types/persistence/self-hosted-migrate-main.d.ts +2 -0
  82. package/dist/types/ports/accounts-operation.d.ts +336 -0
  83. package/dist/types/ports/accounts.d.ts +293 -0
  84. package/dist/types/ports/sandbox-dispatch-authority.d.ts +154 -0
  85. package/dist/types/ports/sandboxes.d.ts +40 -0
  86. package/dist/types/providers/sandbox-dispatch.d.ts +143 -0
  87. package/dist/types/runtime/config.d.ts +61 -0
  88. package/dist/types/runtime/postgres.d.ts +18 -0
  89. package/dist/types/runtime/provider-activation.d.ts +45 -0
  90. package/dist/types/runtime/server.d.ts +68 -0
  91. package/dist/types/testing/accounts-fake.d.ts +31 -0
  92. package/dist/types/testing/fakes.d.ts +2 -0
  93. package/dist/types/testing/node-control-plane-fake.d.ts +20 -0
  94. package/dist/types/testing/reference.d.ts +27 -0
  95. package/dist/types/testing/sandboxes-fake.d.ts +22 -0
  96. package/evidence/provider-live-daytona-v3.json +1 -0
  97. package/evidence/provider-live-e2b-v3.json +1 -0
  98. package/evidence/provider-production-route-daytona-v1.json +1 -0
  99. package/evidence/provider-production-route-e2b-v1.json +1 -0
  100. package/migrations/0001_authority.sql +689 -0
  101. package/migrations/0002_effect_step_global_owner.sql +2 -0
  102. package/migrations/0003_effect_journal_observed_head.sql +34 -0
  103. package/migrations/0004_authority_mutation_journal_binding.sql +15 -0
  104. package/migrations/20260710_checkpoint_broker_v1.sql +163 -0
  105. package/migrations/20260711_accounts_operation_v1.sql +137 -0
  106. package/migrations/20260711_checkpoint_trust_v2.sql +17 -0
  107. package/migrations/20260711_verifier_cleanup_v2.sql +169 -0
  108. package/migrations/20260711_z_accounts_claim_authority_v2.sql +172 -0
  109. package/migrations/20260711_zz_sandbox_dispatch_authority_v1.sql +143 -0
  110. package/migrations/20260712_sandbox_dispatch_authority_v2.sql +58 -0
  111. package/migrations/external-journal/0001_external_authority_mutation_journal.sql +175 -0
  112. package/package.json +47 -0
@@ -0,0 +1,145 @@
1
+ import { type AuthenticatedFenceContext, type BrokerFence } from "../../contracts/fence";
2
+ import { type AuthorityReceiptCryptographyPort } from "./seal-authority";
3
+ import { type CheckpointProvenanceReceiptCryptographyPort, type FenceAuthorityPort } from "./service";
4
+ import { type CheckpointManifestSigningTrustHeadResolverPort, type CheckpointManifestSigningTrustHeadVerifierPort, type CheckpointManifestSigningTrustResolverPort, type CheckpointManifestSignatureVerifierPort } from "./manifest-signature";
5
+ import type { VersionedObjectStore } from "./store";
6
+ import { type CleanVerifierHandoff, type PassingVerificationReceipt, type VerificationReceiptCryptographyPort } from "./verifier";
7
+ import { type ManagedVerifierSandboxHandle, type SandboxesVerifierCleanupReceipt, type SandboxesVerifierAllocationReceiptVerifierPort, type SandboxesVerifierCleanupReceiptVerifierPort, type SandboxesVerifierQuarantineReceipt, type SandboxesVerifierQuarantineReceiptVerifierPort, type VerifierCleanupAuthorityPort, type VerifierCleanupGrant } from "./verifier-cleanup";
8
+ import type { CleanVerifierFinalizationAuthorityPort } from "./clean-verifier-finalization";
9
+ export interface VerifierEvidenceLoaderPort {
10
+ loadDigest(digest: string, mediaType: "application/json" | "application/octet-stream"): Promise<Uint8Array>;
11
+ loadExactSourceBase(input: {
12
+ repositoryId: string;
13
+ objectFormat: "sha1" | "sha256";
14
+ expectedBaseOid: string;
15
+ sourceSnapshotSha256: string;
16
+ }): Promise<Uint8Array>;
17
+ }
18
+ export interface ManagedVerifierSandboxResult {
19
+ schemaVersion: "infinity.managed-verifier-result/v1";
20
+ verdict: "pass" | "fail";
21
+ expectedBaseOid: string;
22
+ candidateOid: string;
23
+ candidateTreeOid: string;
24
+ candidateParentOids: string[];
25
+ advertisedRefs: string[];
26
+ prerequisites: string[];
27
+ gitBundleVerified: boolean;
28
+ strictObjectVerificationPassed: boolean;
29
+ sourceBaseVerified: boolean;
30
+ binaryDiffMatchesCandidate: boolean;
31
+ packerEvidenceValidated: boolean;
32
+ pathPolicyPassed: boolean;
33
+ secretScanPassed: boolean;
34
+ requiredTestsPassed: boolean;
35
+ skippedRequiredTests: number;
36
+ secretFindingCount: number;
37
+ networkAccessObserved: boolean;
38
+ credentialMaterialObserved: boolean;
39
+ producerStateObserved: boolean;
40
+ testReceiptSha256: string;
41
+ secretScanReceiptSha256: string;
42
+ startedAt: string;
43
+ completedAt: string;
44
+ fence: BrokerFence;
45
+ resourceId: string;
46
+ resourceLeaseId: string;
47
+ resourceLifecycleGeneration: number | bigint;
48
+ nativeIncarnationId: string;
49
+ providerHandleSha256: string;
50
+ dependentResourceClosureSha256: string;
51
+ verifierImageSha256: string;
52
+ resourceLimitsSha256: string;
53
+ testCommandsSha256: string;
54
+ attestation: Readonly<{
55
+ keyId: string;
56
+ algorithm: "ecdsa-p256-sha256";
57
+ signedResultSha256: string;
58
+ signatureBase64: string;
59
+ signatureSha256: string;
60
+ }>;
61
+ }
62
+ export interface ManagedVerifierResultAttestationPort {
63
+ verifyDigest(input: {
64
+ domain: "infinity.managed-verifier-result/v1";
65
+ digest: string;
66
+ keyId: string;
67
+ algorithm: "ecdsa-p256-sha256";
68
+ signature: Uint8Array;
69
+ }): Promise<boolean>;
70
+ }
71
+ export interface ManagedVerifierSandboxPort {
72
+ allocate(input: {
73
+ fence: BrokerFence;
74
+ verifierImageSha256: string;
75
+ credentialMode: "none";
76
+ networkMode: "deny_all";
77
+ reuseProducerState: false;
78
+ }): Promise<ManagedVerifierSandboxHandle>;
79
+ verify(input: {
80
+ handle: ManagedVerifierSandboxHandle;
81
+ fence: BrokerFence;
82
+ manifestCanonicalBytes: Uint8Array;
83
+ gitBundleBytes: Uint8Array;
84
+ binaryDiffBytes: Uint8Array;
85
+ packerEvidenceBytes: Uint8Array;
86
+ sourceBaseBytes: Uint8Array;
87
+ runSpecBytes: Uint8Array;
88
+ testPlanBytes: Uint8Array;
89
+ secretScanPolicyBytes: Uint8Array;
90
+ networkPolicyBytes: Uint8Array;
91
+ }): Promise<ManagedVerifierSandboxResult>;
92
+ destroy(input: {
93
+ handle: ManagedVerifierSandboxHandle;
94
+ grant: VerifierCleanupGrant;
95
+ }): Promise<SandboxesVerifierCleanupReceipt>;
96
+ quarantineInvalidAllocation(input: {
97
+ untrustedHandle: unknown;
98
+ verificationFence: BrokerFence;
99
+ }): Promise<SandboxesVerifierQuarantineReceipt>;
100
+ quarantineCleanupFailure(input: {
101
+ handle: ManagedVerifierSandboxHandle;
102
+ verificationFence: BrokerFence;
103
+ failureCode: "cleanup_authority_or_provider_failure";
104
+ }): Promise<SandboxesVerifierQuarantineReceipt>;
105
+ }
106
+ export interface CleanCheckpointVerifierLimits {
107
+ maxManifestBytes: number;
108
+ maxBundleBytes: number;
109
+ maxSourceSnapshotBytes: number;
110
+ maxDeclaredInputBytes: number;
111
+ }
112
+ export declare class CleanCheckpointVerifier {
113
+ private readonly dependencies;
114
+ private readonly limits;
115
+ private readonly resourceLimitsSha256;
116
+ private currentManifestSigningTrustHead;
117
+ private signingTrustHeadResolution;
118
+ constructor(dependencies: {
119
+ authority: FenceAuthorityPort;
120
+ authorityCryptography: AuthorityReceiptCryptographyPort;
121
+ manifestSignatureVerifier: CheckpointManifestSignatureVerifierPort;
122
+ manifestSigningTrustResolver: CheckpointManifestSigningTrustResolverPort;
123
+ manifestSigningTrustHeadResolver: CheckpointManifestSigningTrustHeadResolverPort;
124
+ manifestSigningTrustHeadVerifier: CheckpointManifestSigningTrustHeadVerifierPort;
125
+ provenanceReceiptCryptography: CheckpointProvenanceReceiptCryptographyPort;
126
+ store: VersionedObjectStore;
127
+ evidence: VerifierEvidenceLoaderPort;
128
+ sandbox: ManagedVerifierSandboxPort;
129
+ resultAttestation: ManagedVerifierResultAttestationPort;
130
+ cleanupAuthority: VerifierCleanupAuthorityPort;
131
+ sandboxesAllocationReceiptVerifier: SandboxesVerifierAllocationReceiptVerifierPort;
132
+ sandboxesCleanupReceiptVerifier: SandboxesVerifierCleanupReceiptVerifierPort;
133
+ sandboxesQuarantineReceiptVerifier: SandboxesVerifierQuarantineReceiptVerifierPort;
134
+ verificationReceiptCryptography: VerificationReceiptCryptographyPort;
135
+ finalizationAuthority: CleanVerifierFinalizationAuthorityPort;
136
+ }, limits: CleanCheckpointVerifierLimits);
137
+ verify(handoff: CleanVerifierHandoff, authenticated: AuthenticatedFenceContext): Promise<PassingVerificationReceipt>;
138
+ private loadDeclared;
139
+ private resolveCurrentSigningTrustHead;
140
+ private revalidate;
141
+ private verifyManagedResultAttestation;
142
+ }
143
+ export declare function parseManagedVerifierResult(value: unknown, objectFormat: "sha1" | "sha256"): ManagedVerifierSandboxResult;
144
+ export { parseManagedVerifierSandboxHandle, parseSandboxesVerifierAllocationReceipt, parseSandboxesVerifierCleanupReceipt, parseSandboxesVerifierQuarantineReceipt, parseVerifierCleanupCommitReceipt, parseVerifierCleanupGrant, sandboxesVerifierAllocationReceiptDigest, sandboxesVerifierCleanupReceiptDigest, sandboxesVerifierQuarantineReceiptCanonicalBytes, sandboxesVerifierQuarantineReceiptDigest, verifierCleanupCommitReceiptDigest, verifierCleanupGrantDigest, verifierCleanupGrantRequestDigest, verifierCleanupOperationDigest, verifierCleanupTarget, verifierInvalidAllocationEvidenceDigest, verifierQuarantineSubjectDigest, verifyRecordAndReadbackVerifierQuarantine, verifySandboxesVerifierAllocationReceipt, verifySandboxesVerifierCleanupReceipt, verifySandboxesVerifierQuarantineReceipt, } from "./verifier-cleanup";
145
+ export type { ManagedVerifierDependentResource, ManagedVerifierProviderHandle, ManagedVerifierSandboxHandle, SandboxesVerifierAllocationReceipt, SandboxesVerifierAllocationReceiptAttestation, SandboxesVerifierAllocationReceiptCore, SandboxesVerifierAllocationReceiptVerifierPort, SandboxesResourceAbsence, SandboxesVerifierCleanupReceipt, SandboxesVerifierCleanupReceiptAttestation, SandboxesVerifierCleanupReceiptCore, SandboxesVerifierCleanupReceiptVerifierPort, SandboxesVerifierQuarantineReceipt, SandboxesVerifierQuarantineReceiptAttestation, SandboxesVerifierQuarantineReceiptCore, SandboxesVerifierQuarantineReceiptVerifierPort, VerifiedVerifierCleanupEvidence, VerifierCleanupAuthorityPort, VerifierCleanupFenceAuthorityPort, VerifierCleanupCommitReceipt, VerifierCleanupGrant, VerifierCleanupGrantAuthorityPort, VerifierCleanupGrantBinding, VerifierCleanupGrantCore, VerifierCleanupTarget, VerifierQuarantineExpectation, VerifierQuarantineReason, } from "./verifier-cleanup";
@@ -0,0 +1,55 @@
1
+ import type { BrokerFence } from "../../contracts/fence";
2
+ import { type SqlExecutor } from "../persistence/postgres";
3
+ import { type CheckpointManifestSigningTrustHead, type CheckpointManifestSigningTrustHeadResolverPort, type CheckpointManifestSigningTrustHeadVerifierPort } from "./manifest-signature";
4
+ import type { CheckpointManifestSigningTrustFinalizationAuthorityPort } from "./seal-authority";
5
+ import { type AuthoritySignedPassingVerificationReceipt, type PassingVerificationReceipt, type VerificationReceiptCurrentTrustEffectContext, type VerificationReceiptFinalTrustAuthorization, type VerificationReceiptFinalTrustAuthorityPort, type VerificationReceiptFinalTrustCryptographyPort } from "./verifier";
6
+ export declare class PostgresVerificationReceiptFinalTrustAuthority implements VerificationReceiptFinalTrustAuthorityPort, CheckpointManifestSigningTrustFinalizationAuthorityPort {
7
+ private readonly dependencies;
8
+ constructor(dependencies: {
9
+ sql: SqlExecutor;
10
+ cryptography: VerificationReceiptFinalTrustCryptographyPort;
11
+ });
12
+ recordVerifiedCurrentHead(headInput: CheckpointManifestSigningTrustHead): Promise<void>;
13
+ lockCurrentHead(input: {
14
+ transaction: SqlExecutor;
15
+ expectedHead: CheckpointManifestSigningTrustHead;
16
+ }): Promise<{
17
+ head: CheckpointManifestSigningTrustHead;
18
+ databaseTime: Date;
19
+ }>;
20
+ authorizePassingReceipt(input: {
21
+ signedReceipt: AuthoritySignedPassingVerificationReceipt;
22
+ signedReceiptSha256: string;
23
+ manifestSigningKeyId: string;
24
+ expectedCurrentSigningTrustHead: CheckpointManifestSigningTrustHead;
25
+ }): Promise<VerificationReceiptFinalTrustAuthorization>;
26
+ verifyCurrentAuthorization(input: {
27
+ signedReceipt: AuthoritySignedPassingVerificationReceipt;
28
+ signedReceiptSha256: string;
29
+ manifestSigningKeyId: string;
30
+ authorization: VerificationReceiptFinalTrustAuthorization;
31
+ }): Promise<{
32
+ verified: boolean;
33
+ databaseTime: Date;
34
+ currentSigningTrustHead: CheckpointManifestSigningTrustHead;
35
+ }>;
36
+ withCurrentAuthorization<T>(input: {
37
+ receipt: PassingVerificationReceipt;
38
+ action: string;
39
+ promotionFence: BrokerFence;
40
+ }, effect: (context: VerificationReceiptCurrentTrustEffectContext) => Promise<T>): Promise<T>;
41
+ private verifyAuthorizationCryptography;
42
+ private isPersistedAuthorization;
43
+ private requireCurrent;
44
+ private readCurrent;
45
+ }
46
+ export declare class PostgresRecordedManifestSigningTrustHeadResolver implements CheckpointManifestSigningTrustHeadResolverPort {
47
+ private readonly dependencies;
48
+ constructor(dependencies: {
49
+ sql: SqlExecutor;
50
+ upstream: CheckpointManifestSigningTrustHeadResolverPort;
51
+ verifier: CheckpointManifestSigningTrustHeadVerifierPort;
52
+ authority: PostgresVerificationReceiptFinalTrustAuthority;
53
+ });
54
+ resolveCurrentSigningTrust(input: Parameters<CheckpointManifestSigningTrustHeadResolverPort["resolveCurrentSigningTrust"]>[0]): Promise<CheckpointManifestSigningTrustHead>;
55
+ }
@@ -0,0 +1,25 @@
1
+ import type { BrokerFence } from "../../contracts/fence";
2
+ export interface IdempotentExecutionContext {
3
+ readonly fence: BrokerFence;
4
+ readonly executionLeaseMs?: number;
5
+ }
6
+ export interface IdempotentExecutor<T> {
7
+ execute(operationId: string, operationDigest: string, effect: () => Promise<T>, context?: IdempotentExecutionContext, classifyResult?: (result: T) => "committed" | "unknown_requires_review"): Promise<T>;
8
+ }
9
+ export type IdempotentResolution<T> = Readonly<{
10
+ state: "missing";
11
+ }> | Readonly<{
12
+ state: "in_flight";
13
+ }> | Readonly<{
14
+ state: "unknown_requires_review";
15
+ result?: T;
16
+ }> | Readonly<{
17
+ state: "committed";
18
+ result: T;
19
+ }>;
20
+ export declare class IdempotentOperationLedger<T> implements IdempotentExecutor<T> {
21
+ private readonly entries;
22
+ resolve(operationId: string, operationDigest: string): IdempotentResolution<T>;
23
+ commit(operationId: string, operationDigest: string, result: T): T;
24
+ execute(operationId: string, operationDigest: string, effect: () => Promise<T>, _context?: IdempotentExecutionContext, classifyResult?: (result: T) => "committed" | "unknown_requires_review"): Promise<T>;
25
+ }
@@ -0,0 +1,9 @@
1
+ import { type ProviderStepExecutor } from "../persistence/contracts";
2
+ import type { PutVersionedObjectInput, VersionedObjectRead, VersionedObjectRef, VersionedObjectStore } from "./store";
3
+ export declare class ProviderJournaledVersionedObjectStore implements VersionedObjectStore {
4
+ private readonly store;
5
+ private readonly providerSteps;
6
+ constructor(store: VersionedObjectStore, providerSteps: ProviderStepExecutor);
7
+ putIfAbsent(input: PutVersionedObjectInput): Promise<VersionedObjectRef>;
8
+ getVersion(reference: VersionedObjectRef): Promise<VersionedObjectRead>;
9
+ }
@@ -0,0 +1,135 @@
1
+ import { type BrokerFence } from "../../contracts/fence";
2
+ import { type Int64 } from "../../core/int64";
3
+ import { type CheckpointManifest } from "./manifest";
4
+ import { CHECKPOINT_MANIFEST_SIGNATURE_DOMAIN } from "./signing-message";
5
+ export type CheckpointManifestSigningKeyStatus = "active" | "retired" | "revoked";
6
+ export interface CheckpointManifestSigningKeyRecordInput {
7
+ keyId: string;
8
+ algorithm: "ecdsa-p256-sha256";
9
+ publicKeySpkiSha256: string;
10
+ activatedAt: string;
11
+ status: CheckpointManifestSigningKeyStatus;
12
+ statusChangedAt: string;
13
+ }
14
+ export interface CheckpointManifestSigningKeyRecord extends Readonly<CheckpointManifestSigningKeyRecordInput> {
15
+ }
16
+ export interface CheckpointManifestSigningTrustInput {
17
+ schemaVersion: "infinity.checkpoint-manifest-signing-trust/v1";
18
+ trustAnchorSha256: string;
19
+ keyHistorySha256: string;
20
+ keys: readonly CheckpointManifestSigningKeyRecordInput[];
21
+ }
22
+ export interface CheckpointManifestSigningTrust extends Omit<Readonly<CheckpointManifestSigningTrustInput>, "keys"> {
23
+ readonly keys: readonly CheckpointManifestSigningKeyRecord[];
24
+ }
25
+ export interface CheckpointManifestSigningTrustHeadCore {
26
+ schemaVersion: "infinity.checkpoint-manifest-signing-trust-head/v1";
27
+ signingTrust: CheckpointManifestSigningTrust;
28
+ headSequence: Int64;
29
+ observationSequence: Int64;
30
+ authorityChallengeSha256: string;
31
+ fence: BrokerFence;
32
+ authorityEventId: string;
33
+ observedAt: string;
34
+ expiresAt: string;
35
+ }
36
+ export interface CheckpointManifestSigningTrustHeadAttestation {
37
+ schemaVersion: "infinity.checkpoint-manifest-signing-trust-head-attestation/v1";
38
+ keyId: string;
39
+ algorithm: "ecdsa-p256-sha256";
40
+ signedCoreSha256: string;
41
+ signatureBase64: string;
42
+ signatureSha256: string;
43
+ receiptSha256: string;
44
+ }
45
+ export interface CheckpointManifestSigningTrustHead extends CheckpointManifestSigningTrustHeadCore {
46
+ attestation: CheckpointManifestSigningTrustHeadAttestation;
47
+ }
48
+ export interface CheckpointManifestSigningTrustHeadVerifierPort {
49
+ verifyDigest(input: {
50
+ domain: "infinity.checkpoint-manifest-signing-trust-head/v1";
51
+ digest: string;
52
+ keyId: string;
53
+ algorithm: "ecdsa-p256-sha256";
54
+ signature: Uint8Array;
55
+ }): Promise<boolean>;
56
+ }
57
+ export interface CheckpointManifestSigningTrustHeadResolverPort {
58
+ resolveCurrentSigningTrust(input: {
59
+ fence: BrokerFence;
60
+ authorityChallengeSha256: string;
61
+ minimumHeadSequence?: Int64;
62
+ minimumObservationSequence?: Int64;
63
+ }): Promise<CheckpointManifestSigningTrustHead>;
64
+ }
65
+ /**
66
+ * Resolves the exact historical, authority-signed trust snapshot named by a
67
+ * sealed checkpoint. Implementations are responsible for authenticating the
68
+ * snapshot under the requested recovery trust anchor; callers still
69
+ * close-parse it and recompute its exact history digest before use.
70
+ */
71
+ export interface CheckpointManifestSigningTrustResolverPort {
72
+ resolveSigningTrust(input: {
73
+ trustAnchorSha256: string;
74
+ keyHistorySha256: string;
75
+ }): Promise<CheckpointManifestSigningTrustInput | CheckpointManifestSigningTrust>;
76
+ }
77
+ export interface CheckpointManifestSignatureVerificationResult {
78
+ verified: boolean;
79
+ signingKeyId: string;
80
+ publicKeySpkiSha256: string;
81
+ trustAnchorSha256: string;
82
+ keyHistorySha256: string;
83
+ }
84
+ /**
85
+ * The implementation must verify signingMessageDigest as a 32-byte prehash
86
+ * with the exact public key resolved from signingKey and must validate that
87
+ * key history against the independently pinned recovery trust anchor.
88
+ */
89
+ export interface CheckpointManifestSignatureVerifierPort {
90
+ verify(input: {
91
+ domain: typeof CHECKPOINT_MANIFEST_SIGNATURE_DOMAIN;
92
+ messageType: "digest";
93
+ digestAlgorithm: "sha256";
94
+ manifestCanonicalBytes: Uint8Array;
95
+ manifestDigest: string;
96
+ signingMessageDigest: string;
97
+ signingMessageDigestBytes: Uint8Array;
98
+ checkpointId: string;
99
+ fence: BrokerFence;
100
+ signature: Uint8Array;
101
+ signingKeyId: string;
102
+ signingKey: CheckpointManifestSigningKeyRecord;
103
+ algorithm: "ecdsa-p256-sha256";
104
+ signingTrust: CheckpointManifestSigningTrust;
105
+ }): Promise<CheckpointManifestSignatureVerificationResult>;
106
+ }
107
+ export declare function checkpointManifestKeyHistoryDigest(input: {
108
+ trustAnchorSha256: string;
109
+ keys: readonly CheckpointManifestSigningKeyRecordInput[] | readonly CheckpointManifestSigningKeyRecord[];
110
+ }): string;
111
+ export declare function parseCheckpointManifestSigningTrust(value: unknown): CheckpointManifestSigningTrust;
112
+ export declare function parseCheckpointManifestSigningTrustHead(value: unknown, expectedFenceInput: BrokerFence): CheckpointManifestSigningTrustHead;
113
+ export declare function checkpointManifestSigningTrustHeadDigest(head: CheckpointManifestSigningTrustHead): string;
114
+ export declare function verifyCheckpointManifestSigningTrustHead(input: {
115
+ head: CheckpointManifestSigningTrustHead;
116
+ expectedFence: BrokerFence;
117
+ expectedAuthorityChallengeSha256?: string;
118
+ databaseTime?: Date;
119
+ }, verifier: CheckpointManifestSigningTrustHeadVerifierPort): Promise<CheckpointManifestSigningTrustHead>;
120
+ export declare function assertCheckpointManifestSigningTrustHeadFreshAtDatabaseTime(headInput: CheckpointManifestSigningTrustHead, databaseTimeInput: Date): void;
121
+ export declare function assertCheckpointManifestSigningTrustHeadMonotonic(previous: Pick<CheckpointManifestSigningTrustHead, "headSequence" | "observationSequence" | "observedAt" | "signingTrust"> | undefined, current: CheckpointManifestSigningTrustHead): void;
122
+ export declare function verifyCheckpointManifestSignature(input: {
123
+ manifest: CheckpointManifest;
124
+ manifestCanonicalBytes: Uint8Array;
125
+ manifestDigest: string;
126
+ trustedSigningTime: string;
127
+ checkpointId: string;
128
+ fence: BrokerFence;
129
+ signature: Uint8Array;
130
+ signingKeyId: string;
131
+ algorithm: "ecdsa-p256-sha256";
132
+ signingTrust: CheckpointManifestSigningTrustInput | CheckpointManifestSigningTrust;
133
+ currentSigningTrust: CheckpointManifestSigningTrustInput | CheckpointManifestSigningTrust;
134
+ requireCurrentSigningKeyActive?: boolean;
135
+ }, verifier: CheckpointManifestSignatureVerifierPort): Promise<void>;
@@ -0,0 +1,57 @@
1
+ import { type BrokerFence, type BrokerFenceInput } from "../../contracts/fence";
2
+ import { type Int64 } from "../../core/int64";
3
+ export type CheckpointArtifactName = "git_bundle" | "binary_diff" | "test_plan" | "packer_evidence" | "provenance_receipt";
4
+ export interface CheckpointArtifactRefInput {
5
+ logical_name: CheckpointArtifactName;
6
+ media_type: string;
7
+ byte_length: number;
8
+ sha256: string;
9
+ bucket_alias: string;
10
+ object_key: string;
11
+ version_id: string;
12
+ store_checksum_sha256: string;
13
+ kms_key_alias: string;
14
+ encryption_context_sha256: string;
15
+ }
16
+ export interface CheckpointArtifactRef extends Readonly<CheckpointArtifactRefInput> {
17
+ }
18
+ export interface CheckpointManifestInput {
19
+ schema_version: "infinity.checkpoint-manifest/v1";
20
+ checkpoint_id: string;
21
+ project_id: string;
22
+ repository_id: string;
23
+ fence: BrokerFenceInput;
24
+ authority_activation_receipt_sha256: string;
25
+ route_activation_receipt_sha256: string;
26
+ attempt_lease_grant_sha256: string;
27
+ run_spec_sha256: string;
28
+ policy_sha256: string;
29
+ object_format: "sha1" | "sha256";
30
+ expected_base_oid: string;
31
+ target_ref: string;
32
+ candidate_oid: string;
33
+ candidate_parent_oid: string;
34
+ candidate_tree_oid: string;
35
+ operation_input_sha256: string;
36
+ packer_image_sha256: string;
37
+ packer_identity: string;
38
+ executor_identity: string;
39
+ data_class: "public" | "internal_non_sensitive" | "sensitive_restricted";
40
+ created_at: string;
41
+ signing_trust_head_sha256: string;
42
+ signing_trust_authority_event_id: string;
43
+ signing_trust_head_sequence: Int64;
44
+ signing_trust_observation_sequence: Int64;
45
+ retention_class: "phase1_evidence" | "recovery_only_secret_quarantine";
46
+ artifacts: CheckpointArtifactRefInput[];
47
+ scan_receipt_sha256: string;
48
+ provenance_verification_receipt_sha256: string;
49
+ }
50
+ export interface CheckpointManifest extends Omit<Readonly<CheckpointManifestInput>, "fence" | "artifacts"> {
51
+ readonly fence: BrokerFence;
52
+ readonly artifacts: readonly CheckpointArtifactRef[];
53
+ }
54
+ export declare function parseCheckpointManifest(value: unknown): CheckpointManifest;
55
+ export declare function checkpointManifestDigest(manifest: CheckpointManifest): string;
56
+ /** Exact RFC-8785-style bytes whose SHA-256 digest is signed by the manifest key. */
57
+ export declare function checkpointManifestCanonicalBytes(manifest: CheckpointManifest): Uint8Array;
@@ -0,0 +1,215 @@
1
+ import { parseBrokerFence } from "../../contracts/fence";
2
+ import { type BinarySource } from "./bytes";
3
+ import type { PutVersionedObjectInput, VersionedObjectRef, VersionedObjectStore } from "./store";
4
+ export interface S3PutObjectRequest {
5
+ Bucket: string;
6
+ Key: string;
7
+ Body: Uint8Array;
8
+ ContentType: string;
9
+ ContentLength: number;
10
+ IfNoneMatch: "*";
11
+ ChecksumAlgorithm: "SHA256";
12
+ ChecksumSHA256: string;
13
+ ServerSideEncryption: "aws:kms";
14
+ SSEKMSKeyId: string;
15
+ SSEKMSEncryptionContext: string;
16
+ ObjectLockMode: "COMPLIANCE";
17
+ ObjectLockRetainUntilDate: Date;
18
+ Metadata: Readonly<Record<string, string>>;
19
+ }
20
+ export interface S3PutObjectResponse {
21
+ VersionId?: string;
22
+ ChecksumSHA256?: string;
23
+ ServerSideEncryption?: string;
24
+ SSEKMSKeyId?: string;
25
+ ObjectLockMode?: string;
26
+ ObjectLockRetainUntilDate?: Date | string;
27
+ RequestId?: string;
28
+ }
29
+ export interface S3GetObjectRequest {
30
+ Bucket: string;
31
+ Key: string;
32
+ VersionId: string;
33
+ ChecksumMode: "ENABLED";
34
+ }
35
+ export interface S3GetObjectResponse {
36
+ Body?: BinarySource;
37
+ VersionId?: string;
38
+ ContentLength?: number;
39
+ ChecksumSHA256?: string;
40
+ ServerSideEncryption?: string;
41
+ SSEKMSKeyId?: string;
42
+ ObjectLockMode?: string;
43
+ ObjectLockRetainUntilDate?: Date | string;
44
+ RequestId?: string;
45
+ }
46
+ export interface S3ObjectVersionSummary {
47
+ Key?: string;
48
+ VersionId?: string;
49
+ Size?: number;
50
+ }
51
+ export interface S3HeadObjectVersionResponse {
52
+ VersionId?: string;
53
+ ContentLength?: number;
54
+ ChecksumSHA256?: string;
55
+ ServerSideEncryption?: string;
56
+ SSEKMSKeyId?: string;
57
+ ObjectLockMode?: string;
58
+ ObjectLockRetainUntilDate?: Date | string;
59
+ RequestId?: string;
60
+ Metadata?: Readonly<Record<string, string>>;
61
+ }
62
+ export interface S3EvidenceClient {
63
+ putObject(request: S3PutObjectRequest): Promise<S3PutObjectResponse>;
64
+ getObject(request: S3GetObjectRequest): Promise<S3GetObjectResponse>;
65
+ listObjectVersions(request: {
66
+ Bucket: string;
67
+ Prefix: string;
68
+ MaxKeys: number;
69
+ }): Promise<{
70
+ Versions?: readonly S3ObjectVersionSummary[];
71
+ IsTruncated?: boolean;
72
+ }>;
73
+ headObjectVersion(request: {
74
+ Bucket: string;
75
+ Key: string;
76
+ VersionId: string;
77
+ ChecksumMode: "ENABLED";
78
+ }): Promise<S3HeadObjectVersionResponse>;
79
+ }
80
+ export interface S3EvidenceBucketControls {
81
+ versioning: "Enabled" | "Suspended" | "Disabled";
82
+ versioningSuspensionDenied: boolean;
83
+ objectLockEnabled: boolean;
84
+ defaultRetentionMode: "COMPLIANCE" | "GOVERNANCE" | "NONE";
85
+ defaultRetentionDays: number;
86
+ lifecycleMinimumRetentionDays: number;
87
+ accountBlockPublicAccess: boolean;
88
+ blockPublicAcls: boolean;
89
+ ignorePublicAcls: boolean;
90
+ blockPublicPolicy: boolean;
91
+ restrictPublicBuckets: boolean;
92
+ objectOwnership: "BucketOwnerEnforced" | "Other";
93
+ aclWritesDenied: boolean;
94
+ tlsOnlyEnforced: boolean;
95
+ defaultEncryption: "aws:kms" | "AES256" | "none";
96
+ kmsKeyId: string;
97
+ unexpectedKmsKeyDenied: boolean;
98
+ encryptionContextRequired: boolean;
99
+ createOnlyConditionalWritesEnforced: boolean;
100
+ unversionedReadsDenied: boolean;
101
+ crossProjectAccessDenied: boolean;
102
+ cloudTrailDataEventsEnabled: boolean;
103
+ cloudTrailKmsEventsEnabled: boolean;
104
+ controlChangeAlarmsEnabled: boolean;
105
+ runtimeDeleteDenied: boolean;
106
+ runtimeVersionDeleteDenied: boolean;
107
+ runtimeDeleteMarkersDenied: boolean;
108
+ runtimeBypassGovernanceDenied: boolean;
109
+ runtimeKmsKeyDeletionDenied: boolean;
110
+ }
111
+ export interface S3EvidenceBucketInspector {
112
+ inspect(bucket: string): Promise<S3EvidenceBucketControls>;
113
+ }
114
+ export interface S3EvidenceFenceAuthorityPort {
115
+ revalidate(fence: ReturnType<typeof parseBrokerFence>): Promise<{
116
+ fence: ReturnType<typeof parseBrokerFence>;
117
+ databaseTime: Date;
118
+ }>;
119
+ }
120
+ export interface S3KmsContextAuditPort {
121
+ verifyAcceptedPut(input: {
122
+ bucketName: string;
123
+ objectKey: string;
124
+ versionId: string;
125
+ operationId: string;
126
+ operationDigest: string;
127
+ fenceSha256: string;
128
+ kmsKeyId: string;
129
+ encryptionContextSha256: string;
130
+ expectedChecksumSha256: string;
131
+ }): Promise<{
132
+ versionId: string;
133
+ putProviderRequestId: string;
134
+ auditProviderRequestId: string;
135
+ encryptionContextSha256: string;
136
+ auditReceiptSha256: string;
137
+ }>;
138
+ }
139
+ export interface S3VersionedObjectStoreConfig {
140
+ bucketAlias: string;
141
+ bucketName: string;
142
+ kmsKeyId: string;
143
+ kmsKeyAlias: string;
144
+ retentionDays: number;
145
+ inspector: S3EvidenceBucketInspector;
146
+ authority: S3EvidenceFenceAuthorityPort;
147
+ kmsContextAudit: S3KmsContextAuditPort;
148
+ }
149
+ export declare class S3AmbiguousWriteError extends Error {
150
+ constructor(message?: string, options?: {
151
+ cause?: unknown;
152
+ });
153
+ }
154
+ export declare class S3ConditionalWriteConflictError extends Error {
155
+ constructor(message?: string);
156
+ }
157
+ export declare class S3VersionedObjectStore implements VersionedObjectStore {
158
+ private readonly client;
159
+ readonly bucketAlias: string;
160
+ private readonly bucketName;
161
+ private readonly kmsKeyId;
162
+ private readonly kmsKeyAlias;
163
+ private readonly retentionDays;
164
+ private readonly inspector;
165
+ private readonly authority;
166
+ private readonly kmsContextAudit;
167
+ constructor(client: S3EvidenceClient, config: S3VersionedObjectStoreConfig);
168
+ verifyBucketControls(): Promise<string>;
169
+ putIfAbsent(input: PutVersionedObjectInput): Promise<VersionedObjectRef>;
170
+ getVersion(reference: VersionedObjectRef): Promise<{
171
+ bytes: Uint8Array;
172
+ getProviderRequestId: string;
173
+ }>;
174
+ private validatePutResponse;
175
+ private reconcileAmbiguousPut;
176
+ }
177
+ export interface AwsSdkV3S3CommandFactory {
178
+ putObject(input: S3PutObjectRequest): unknown;
179
+ getObject(input: S3GetObjectRequest): unknown;
180
+ listObjectVersions(input: {
181
+ Bucket: string;
182
+ Prefix: string;
183
+ MaxKeys: number;
184
+ }): unknown;
185
+ headObject(input: {
186
+ Bucket: string;
187
+ Key: string;
188
+ VersionId: string;
189
+ ChecksumMode: "ENABLED";
190
+ }): unknown;
191
+ }
192
+ export interface AwsSdkV3Client {
193
+ send(command: unknown): Promise<unknown>;
194
+ }
195
+ export declare class AwsSdkV3S3EvidenceClient implements S3EvidenceClient {
196
+ private readonly client;
197
+ private readonly commands;
198
+ constructor(client: AwsSdkV3Client, commands: AwsSdkV3S3CommandFactory);
199
+ putObject(request: S3PutObjectRequest): Promise<S3PutObjectResponse>;
200
+ getObject(request: S3GetObjectRequest): Promise<S3GetObjectResponse>;
201
+ listObjectVersions(request: {
202
+ Bucket: string;
203
+ Prefix: string;
204
+ MaxKeys: number;
205
+ }): Promise<{
206
+ Versions?: readonly S3ObjectVersionSummary[];
207
+ IsTruncated?: boolean;
208
+ }>;
209
+ headObjectVersion(request: {
210
+ Bucket: string;
211
+ Key: string;
212
+ VersionId: string;
213
+ ChecksumMode: "ENABLED";
214
+ }): Promise<S3HeadObjectVersionResponse>;
215
+ }