@rathnasgala2/adapter-github-pages 0.1.0 → 0.1.1

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.
@@ -0,0 +1,299 @@
1
+ /**
2
+ * `describeCapabilities`: the exact `github-pages` capability row.
3
+ *
4
+ * @param {PagesDestination} destination the bound destination
5
+ * @returns {Promise<Readonly<Record<string, unknown>>>} the declaration
6
+ */
7
+ export function describeCapabilities(destination: PagesDestination): Promise<Readonly<Record<string, unknown>>>;
8
+ /**
9
+ * `inspectDestination`: report the currently served generation from a live
10
+ * public read plus the provider's own site state, never from memory.
11
+ *
12
+ * @param {PagesDestination} destination the bound destination
13
+ * @returns {Promise<Readonly<{
14
+ * currentGenerationId: string | null,
15
+ * retainedHistory: readonly Readonly<Record<string, unknown>>[],
16
+ * releaseGenerationsOnDisk: readonly string[],
17
+ * providerSiteObserved: boolean,
18
+ * findings: readonly string[]
19
+ * }>>} the inspection result
20
+ */
21
+ export function inspectDestination(destination: PagesDestination): Promise<Readonly<{
22
+ currentGenerationId: string | null;
23
+ retainedHistory: readonly Readonly<Record<string, unknown>>[];
24
+ releaseGenerationsOnDisk: readonly string[];
25
+ providerSiteObserved: boolean;
26
+ findings: readonly string[];
27
+ }>>;
28
+ /**
29
+ * `preflight`: check every declared route against the portable path rules
30
+ * and the reserved marker coordinate, and report the currently served
31
+ * generation for fencing. No provider mutation of any kind occurs here.
32
+ *
33
+ * @param {{
34
+ * destination: PagesDestination,
35
+ * entries: readonly {path: string}[],
36
+ * expectedGenerationId?: string
37
+ * }} input the preflight input
38
+ * @returns {Promise<Readonly<{
39
+ * verdict: 'proceed' | 'refuse',
40
+ * observedGenerationId: string | null,
41
+ * findings: readonly string[]
42
+ * }>>} the preflight result
43
+ */
44
+ export function preflight(input: {
45
+ destination: PagesDestination;
46
+ entries: readonly {
47
+ path: string;
48
+ }[];
49
+ expectedGenerationId?: string;
50
+ }): Promise<Readonly<{
51
+ verdict: "proceed" | "refuse";
52
+ observedGenerationId: string | null;
53
+ findings: readonly string[];
54
+ }>>;
55
+ /**
56
+ * `stage`: build the deterministic Pages carrier and publish it through the
57
+ * caller-supplied Actions-artifact publisher. Nothing public changes here —
58
+ * `staging: private` is literal: the carrier is an Actions artifact that no
59
+ * public origin serves.
60
+ *
61
+ * @param {{
62
+ * destination: PagesDestination,
63
+ * operationId: string,
64
+ * attemptId: string,
65
+ * idempotencyKey: string,
66
+ * generationId: string,
67
+ * artifactId: string,
68
+ * artifactDigest: string,
69
+ * files: readonly StagedFile[]
70
+ * }} input the stage input
71
+ * @returns {Promise<Readonly<{
72
+ * stageToken: string,
73
+ * stagedPath: string,
74
+ * fileCount: number,
75
+ * byteCount: string,
76
+ * carrierDigest: string,
77
+ * pagesArtifactId: string,
78
+ * idempotent: boolean
79
+ * }>>} the stage result
80
+ */
81
+ export function stage(input: {
82
+ destination: PagesDestination;
83
+ operationId: string;
84
+ attemptId: string;
85
+ idempotencyKey: string;
86
+ generationId: string;
87
+ artifactId: string;
88
+ artifactDigest: string;
89
+ files: readonly StagedFile[];
90
+ }): Promise<Readonly<{
91
+ stageToken: string;
92
+ stagedPath: string;
93
+ fileCount: number;
94
+ byteCount: string;
95
+ carrierDigest: string;
96
+ pagesArtifactId: string;
97
+ idempotent: boolean;
98
+ }>>;
99
+ /**
100
+ * Resolve the prior attempt of an unresolved Pages fence before any current
101
+ * carrier is uploaded or created. Exposed separately so the deploy script
102
+ * can run the DEC-097 section 6.2 precheck *before* it calls `stage` (this
103
+ * package's carrier upload happens in `stage`); `activate` runs it again,
104
+ * ahead of any current create, when it is given recovery inputs.
105
+ *
106
+ * @param {{
107
+ * destination: PagesDestination,
108
+ * pagesRecovery: Readonly<Record<string, unknown>>
109
+ * }} input the recovery input
110
+ * @returns {Promise<import('./recovery.js').PriorAttemptObservation>} the
111
+ * truthful prior-attempt observation
112
+ */
113
+ export function recoverPriorAttempt(input: {
114
+ destination: PagesDestination;
115
+ pagesRecovery: Readonly<Record<string, unknown>>;
116
+ }): Promise<import("./recovery.js").PriorAttemptObservation>;
117
+ /**
118
+ * `activate`: create exactly one Pages deployment for a staged carrier and
119
+ * poll it to a terminal status (`activation: provider-promotion`).
120
+ *
121
+ * `expectedCurrentGenerationId` is the adapter-protocol `2.1.0` fence:
122
+ * either a generation identity or the explicit `EXPECT_NOTHING_SERVED`
123
+ * sentinel. `null` and `undefined` are refused with
124
+ * `EXPECTED_GENERATION_FENCE_INVALID` (LOCAL-47) — there is no unfenced
125
+ * activation. The check itself is a read-then-compare performed immediately
126
+ * before the create call: honest best effort, not a provider fence, because
127
+ * GitHub Pages exposes no compare-and-set on activation, which is exactly
128
+ * why this adapter declares `concurrency: none`.
129
+ *
130
+ * In `pages-reconciliation-recovery` mode the prior attempt is resolved
131
+ * first, before any current create, per DEC-097 section 6.2.
132
+ *
133
+ * @param {{
134
+ * destination: PagesDestination,
135
+ * stageToken: string,
136
+ * generationId: string,
137
+ * expectedCurrentGenerationId: string,
138
+ * expectedArtifactDigest?: string,
139
+ * pagesOidcToken?: string,
140
+ * pagesOidcClaims?: import('./oidc.js').PagesOidcExpectation,
141
+ * mode?: string,
142
+ * pagesRecovery?: Readonly<Record<string, unknown>>,
143
+ * crashInjectionHook?: () => void | Promise<void>
144
+ * }} input the activate input; `crashInjectionHook`, when supplied (only
145
+ * ever by a conformance fixture), is awaited after the carrier is durably
146
+ * published but strictly before the create-deployment call
147
+ * @returns {Promise<Readonly<Record<string, unknown>>>} the decision
148
+ */
149
+ export function activate(input: {
150
+ destination: PagesDestination;
151
+ stageToken: string;
152
+ generationId: string;
153
+ expectedCurrentGenerationId: string;
154
+ expectedArtifactDigest?: string;
155
+ pagesOidcToken?: string;
156
+ pagesOidcClaims?: import("./oidc.js").PagesOidcExpectation;
157
+ mode?: string;
158
+ pagesRecovery?: Readonly<Record<string, unknown>>;
159
+ crashInjectionHook?: () => void | Promise<void>;
160
+ }): Promise<Readonly<Record<string, unknown>>>;
161
+ /**
162
+ * `observe`: verify the activated generation through credential-free public
163
+ * reads. `providerInventoryAssurance` is `none`, so this verifies exactly
164
+ * the routes this run staged plus the marker; it never claims the deployed
165
+ * inventory is complete.
166
+ *
167
+ * @param {{
168
+ * destination: PagesDestination,
169
+ * generationId: string,
170
+ * expectedArtifactDigest: string
171
+ * }} input the observe input
172
+ * @returns {Promise<Readonly<{
173
+ * verified: boolean,
174
+ * observedArtifactDigest: string | null,
175
+ * currentGenerationId: string | null,
176
+ * markerValid: boolean,
177
+ * claimsCompleteInventory: false,
178
+ * findings: readonly string[]
179
+ * }>>} the observation result
180
+ */
181
+ export function observe(input: {
182
+ destination: PagesDestination;
183
+ generationId: string;
184
+ expectedArtifactDigest: string;
185
+ }): Promise<Readonly<{
186
+ verified: boolean;
187
+ observedArtifactDigest: string | null;
188
+ currentGenerationId: string | null;
189
+ markerValid: boolean;
190
+ claimsCompleteInventory: false;
191
+ findings: readonly string[];
192
+ }>>;
193
+ /**
194
+ * `cleanupStaged`: drop this operation's staged carrier from run-scoped
195
+ * memory and, when an abandoned generation is named, cancel its in-flight
196
+ * deployment through the cataloged cancel call. It never cancels or
197
+ * disturbs a generation that is currently served or retained.
198
+ *
199
+ * @param {{
200
+ * destination: PagesDestination,
201
+ * stageToken: string,
202
+ * generationId?: string
203
+ * }} input the cleanup input
204
+ * @returns {Promise<Readonly<{removed: boolean, cancelled: boolean}>>} whether
205
+ * staged state was removed and whether a deployment was cancelled
206
+ */
207
+ export function cleanupStaged(input: {
208
+ destination: PagesDestination;
209
+ stageToken: string;
210
+ generationId?: string;
211
+ }): Promise<Readonly<{
212
+ removed: boolean;
213
+ cancelled: boolean;
214
+ }>>;
215
+ /**
216
+ * `rollback`: `rollback: reupload` semantics. GitHub Pages cannot natively
217
+ * re-promote a historical deployment, so a rollback stages a fresh carrier
218
+ * for the selected historical content under a *new* generation identity and
219
+ * activates it through the ordinary create/poll path.
220
+ *
221
+ * The historical bytes are not recoverable from the provider (Pages exposes
222
+ * no artifact read-back), so the caller supplies them through `files`. The
223
+ * run-scoped stage memory is used only when the target generation was
224
+ * staged by this same run.
225
+ *
226
+ * @param {{
227
+ * destination: PagesDestination,
228
+ * targetGenerationId: string,
229
+ * newGenerationId: string,
230
+ * newArtifactId: string,
231
+ * operationId: string,
232
+ * attemptId: string,
233
+ * idempotencyKey: string,
234
+ * files?: readonly StagedFile[],
235
+ * artifactDigest?: string,
236
+ * pagesOidcToken?: string,
237
+ * pagesOidcClaims?: import('./oidc.js').PagesOidcExpectation
238
+ * }} input the rollback input
239
+ * @returns {Promise<Readonly<Record<string, unknown>>>} the activation decision
240
+ */
241
+ export function rollback(input: {
242
+ destination: PagesDestination;
243
+ targetGenerationId: string;
244
+ newGenerationId: string;
245
+ newArtifactId: string;
246
+ operationId: string;
247
+ attemptId: string;
248
+ idempotencyKey: string;
249
+ files?: readonly StagedFile[];
250
+ artifactDigest?: string;
251
+ pagesOidcToken?: string;
252
+ pagesOidcClaims?: import("./oidc.js").PagesOidcExpectation;
253
+ }): Promise<Readonly<Record<string, unknown>>>;
254
+ export { PagesAdapterError } from "./errors.js";
255
+ export { computeArtifactDigest } from "./artifact-projection.js";
256
+ export { buildValidatedMarker } from "./marker.js";
257
+ export { forgetDestination } from "./store.js";
258
+ /** This package's runtime status: fully implemented per S4-T04 (W4-11). */
259
+ export const PACKAGE_STATUS: Readonly<{
260
+ name: "@rathnasgala2/adapter-github-pages";
261
+ implemented: true;
262
+ implementingTask: "S4-T04";
263
+ }>;
264
+ export type PagesDestination = Readonly<{
265
+ owner: string;
266
+ repository: string;
267
+ repositoryId?: string | number;
268
+ repositoryOwnerId?: string | number;
269
+ apiOrigin?: string;
270
+ oidcToken?: string;
271
+ oidcClaims?: import("./oidc.js").PagesOidcExpectation;
272
+ publicBaseUrl: string;
273
+ token: string;
274
+ publishCarrier: (input: {
275
+ bytes: Buffer;
276
+ generationId: string;
277
+ carrierDigest: string;
278
+ }) => Promise<{
279
+ pagesArtifactId: string | number;
280
+ artifactDigest?: string;
281
+ byteCount?: number;
282
+ }>;
283
+ fetch?: typeof globalThis.fetch;
284
+ publicFetch?: typeof globalThis.fetch;
285
+ sleep?: (seconds: number) => Promise<void>;
286
+ runId?: string;
287
+ runAttempt?: number;
288
+ headSha?: string;
289
+ }>;
290
+ export type StagedFile = Readonly<{
291
+ path: string;
292
+ bytes: Buffer;
293
+ }>;
294
+ export { EXPECT_NOTHING_SERVED, fenceFor, generateUuidV7 } from "@rathnasgala2/adapter-protocol";
295
+ export { decodeCarrier, encodeCarrier } from "./carrier.js";
296
+ export { GENERATION_MARKER_PATH, ADAPTER_VERSION, NORMAL_MODE, RECOVERY_MODE } from "./constants.js";
297
+ export { PAGES_OIDC_ENVIRONMENT, PAGES_OIDC_ISSUER, PAGES_OIDC_PROFILE, buildSubjectForms, verifyPagesOidcToken } from "./oidc.js";
298
+ export { GAP_PROOF_PROFILE, NO_AUTHORITY_STATE, RECOVERY_RECORD_PROFILE, buildInterveningAttempts, buildRunAttemptGapProof, computeGapProofDigest, computeInterveningAttemptDigest, computeRecoveryDigest, sealRecoveryRecord, validateReconciliationRecovery, validateRunAttemptGapProof } from "./recovery.js";
299
+ export { CALL_CLASS_BINDING, GITHUB_API_ORIGIN, PAGES_CALL_PLAN, REQUEST_TEMPLATE_PROFILE, buildRequestTemplates, callClassIdBinding, requireTemplate } from "./request-catalog.js";
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Build one schema-valid marker, throwing rather than returning an invalid
3
+ * document: an invalid marker must never reach a carrier.
4
+ *
5
+ * @param {{artifactId: string, artifactDigest: string, generationId: string}} identity
6
+ * the marker's three identity fields
7
+ * @returns {Readonly<Record<string, unknown>>} the validated marker
8
+ */
9
+ export function buildValidatedMarker(identity: {
10
+ artifactId: string;
11
+ artifactDigest: string;
12
+ generationId: string;
13
+ }): Readonly<Record<string, unknown>>;
14
+ /**
15
+ * Parse and validate marker bytes read back from the public origin.
16
+ *
17
+ * @param {Buffer} bytes the raw marker bytes
18
+ * @returns {{marker: Record<string, unknown> | null, findings: string[]}} the
19
+ * parsed marker, or `null` with one finding explaining why it was refused
20
+ */
21
+ export function parsePublicMarker(bytes: Buffer): {
22
+ marker: Record<string, unknown> | null;
23
+ findings: string[];
24
+ };
25
+ /** The exact schema identity every marker is validated against. */
26
+ export const MARKER_SCHEMA_ID: "urn:gala:schema:public-generation-marker:2.0.0";
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Decode one canonical unpadded base64url segment.
3
+ *
4
+ * @param {string} segment the segment text
5
+ * @param {string} label the segment name, for the diagnostic
6
+ * @returns {Buffer} the decoded bytes
7
+ */
8
+ export function decodeCanonicalBase64Url(segment: string, label: string): Buffer;
9
+ /**
10
+ * Parse one JSON object, refusing any duplicate member name at any depth.
11
+ *
12
+ * `JSON.parse` silently keeps the last of two identical member names, which
13
+ * would let a crafted token present one `sub` to a scanner and another to a
14
+ * parser. This scanner rejects that before the value is used.
15
+ *
16
+ * @param {string} text the JSON text
17
+ * @param {string} label the value's name, for the diagnostic
18
+ * @returns {Record<string, unknown>} the parsed object
19
+ */
20
+ export function parseDuplicateKeyFreeJsonObject(text: string, label: string): Record<string, unknown>;
21
+ /**
22
+ * The two GitHub-supported default-environment subject forms, recomputed
23
+ * from the separately verified identity claims.
24
+ *
25
+ * @param {{
26
+ * owner: string,
27
+ * repository: string,
28
+ * repositoryId: string,
29
+ * repositoryOwnerId: string
30
+ * }} identity the verified identity claims
31
+ * @returns {{name: string, id: string}} the two admitted subject forms
32
+ */
33
+ export function buildSubjectForms(identity: {
34
+ owner: string;
35
+ repository: string;
36
+ repositoryId: string;
37
+ repositoryOwnerId: string;
38
+ }): {
39
+ name: string;
40
+ id: string;
41
+ };
42
+ /**
43
+ * Verify one caller-supplied Pages OIDC JWT against its expected bindings.
44
+ *
45
+ * Performs no network call and no signature verification; see this module's
46
+ * header for why that is correct and where the real trust boundary is.
47
+ *
48
+ * @param {unknown} token the caller-supplied compact JWT
49
+ * @param {PagesOidcExpectation} expected the expected bindings
50
+ * @param {() => number} [now] the clock source used for the `exp`/`iat`/`nbf`
51
+ * checks, in epoch milliseconds. Defaults to `Date.now`; a test supplies a
52
+ * fixed function to check the {@link PAGES_OIDC_CLOCK_SKEW_SECONDS}
53
+ * boundary deterministically instead of racing the real clock.
54
+ * @returns {Readonly<{
55
+ * profile: string,
56
+ * subjectForm: 'name' | 'identifier',
57
+ * issuerSignatureVerified: false,
58
+ * tokenByteCount: number
59
+ * }>} non-secret evidence about the accepted token
60
+ */
61
+ export function verifyPagesOidcToken(token: unknown, expected: PagesOidcExpectation, now?: () => number): Readonly<{
62
+ profile: string;
63
+ subjectForm: "name" | "identifier";
64
+ issuerSignatureVerified: false;
65
+ tokenByteCount: number;
66
+ }>;
67
+ /**
68
+ * Validate one caller-supplied expectation record before it is used.
69
+ *
70
+ * @param {unknown} expected the caller-supplied expectation
71
+ * @returns {PagesOidcExpectation} the validated expectation
72
+ */
73
+ export function requireOidcExpectation(expected: unknown): PagesOidcExpectation;
74
+ /** The closed credential-source profile this module implements. */
75
+ export const PAGES_OIDC_PROFILE: "gala-pages-oidc-v2";
76
+ /** The exact required `iss` claim. */
77
+ export const PAGES_OIDC_ISSUER: "https://token.actions.githubusercontent.com";
78
+ /** The exact required `environment` claim and subject environment segment. */
79
+ export const PAGES_OIDC_ENVIRONMENT: "github-pages";
80
+ /** Inclusive byte bounds on the compact JWT (DEC-097 section 7). */
81
+ export const PAGES_OIDC_MINIMUM_BYTES: 1;
82
+ /**
83
+ * Inclusive upper byte bound on the compact JWT: a memory bound with headroom,
84
+ * not an expected size. GitHub controls the actual token size.
85
+ */
86
+ export const PAGES_OIDC_MAXIMUM_BYTES: 32768;
87
+ /**
88
+ * PUB-L5: clock-skew tolerance, in seconds, for the belt-and-braces
89
+ * `exp`/`iat`/`nbf` checks below. GitHub Pages is the relying party that
90
+ * authoritatively rejects a stale or not-yet-valid token (this module's own
91
+ * header explains why that is the real trust boundary); this check exists
92
+ * only to fail closed earlier, with a clearer diagnostic, when it costs
93
+ * nothing to do so. 300 seconds is generous enough to absorb ordinary
94
+ * runner/host clock drift without weakening the check.
95
+ */
96
+ export const PAGES_OIDC_CLOCK_SKEW_SECONDS: 300;
97
+ export type PagesOidcExpectation = Readonly<{
98
+ owner: string;
99
+ repository: string;
100
+ repositoryId: string | number;
101
+ repositoryOwnerId: string | number;
102
+ ref: string;
103
+ sha: string;
104
+ runId: string | number;
105
+ runAttempt: string | number;
106
+ jobWorkflowRef: string;
107
+ jobWorkflowSha: string;
108
+ }>;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @typedef {Readonly<{
3
+ * publicBaseUrl: string,
4
+ * fetch?: typeof globalThis.fetch
5
+ * }>} PublicContext
6
+ */
7
+ /**
8
+ * Join the canonical base path to an artifact-relative route exactly once.
9
+ *
10
+ * @param {string} publicBaseUrl the destination's public base URL
11
+ * @param {string} artifactRelativePath the artifact-relative POSIX path
12
+ * @returns {string} the absolute public URL
13
+ */
14
+ export function publicUrlFor(publicBaseUrl: string, artifactRelativePath: string): string;
15
+ /**
16
+ * Read one public route.
17
+ *
18
+ * @param {PublicContext} context the public-origin context
19
+ * @param {string} artifactRelativePath the artifact-relative POSIX path
20
+ * @returns {Promise<{status: number, bytes: Buffer | null, etag: string | null}>}
21
+ * the bounded observation; `bytes` is `null` for any non-`200` status
22
+ */
23
+ export function readPublic(context: PublicContext, artifactRelativePath: string): Promise<{
24
+ status: number;
25
+ bytes: Buffer | null;
26
+ etag: string | null;
27
+ }>;
28
+ /** Maximum bytes any single public read will accept. */
29
+ export const MAXIMUM_PUBLIC_BODY_BYTES: 33554432;
30
+ export type PublicContext = Readonly<{
31
+ publicBaseUrl: string;
32
+ fetch?: typeof globalThis.fetch;
33
+ }>;
@@ -0,0 +1,175 @@
1
+ /**
2
+ * Compute one intervening attempt's immutable tombstone digest:
3
+ * `SHA256(UTF8("GALA-PAGES-NO-AUTHORITY-RUN-ATTEMPT-V2\0") ||
4
+ * JCS({repositoryId,runId,runAttempt,authorityState}))`.
5
+ *
6
+ * @param {{
7
+ * repositoryId: string | number,
8
+ * runId: string | number,
9
+ * runAttempt: number
10
+ * }} input the tombstone coordinates
11
+ * @returns {string} the `decisionDigest`
12
+ */
13
+ export function computeInterveningAttemptDigest(input: {
14
+ repositoryId: string | number;
15
+ runId: string | number;
16
+ runAttempt: number;
17
+ }): string;
18
+ /**
19
+ * Build the exact ordered tombstone set for one attempt fence: every integer
20
+ * strictly between the prior and claiming attempts, sorted by `runAttempt`.
21
+ * An adjacent claim carries the exact empty array.
22
+ *
23
+ * @param {{
24
+ * repositoryId: string | number,
25
+ * runId: string | number,
26
+ * priorRunAttempt: number,
27
+ * claimingRunAttempt: number
28
+ * }} input the fence coordinates
29
+ * @returns {readonly Readonly<{
30
+ * runAttempt: number,
31
+ * authorityState: string,
32
+ * decisionDigest: string
33
+ * }>[]} the ordered tombstone rows
34
+ */
35
+ export function buildInterveningAttempts(input: {
36
+ repositoryId: string | number;
37
+ runId: string | number;
38
+ priorRunAttempt: number;
39
+ claimingRunAttempt: number;
40
+ }): readonly Readonly<{
41
+ runAttempt: number;
42
+ authorityState: string;
43
+ decisionDigest: string;
44
+ }>[];
45
+ /**
46
+ * Compute a gap proof's `proofDigest` over the record with `proofDigest`
47
+ * omitted.
48
+ *
49
+ * @param {Readonly<Record<string, unknown>>} proof the gap proof record
50
+ * @returns {string} the `proofDigest`
51
+ */
52
+ export function computeGapProofDigest(proof: Readonly<Record<string, unknown>>): string;
53
+ /**
54
+ * Build the complete `pagesRunAttemptGapProof` the authorization
55
+ * transaction must have produced for one fence.
56
+ *
57
+ * @param {{
58
+ * repositoryId: string | number,
59
+ * runId: string | number,
60
+ * priorRunAttempt: number,
61
+ * claimingRunAttempt: number
62
+ * }} input the fence coordinates
63
+ * @returns {Readonly<Record<string, unknown>>} the complete gap proof
64
+ */
65
+ export function buildRunAttemptGapProof(input: {
66
+ repositoryId: string | number;
67
+ runId: string | number;
68
+ priorRunAttempt: number;
69
+ claimingRunAttempt: number;
70
+ }): Readonly<Record<string, unknown>>;
71
+ /**
72
+ * Validate one server-supplied gap proof: exact member set, bounded
73
+ * coordinates, set equality of the intervening attempts with every integer
74
+ * strictly between the two coordinates, `runAttempt` ordering, every
75
+ * tombstone digest, and the `proofDigest` itself.
76
+ *
77
+ * @param {unknown} proof the candidate gap proof
78
+ * @param {{repositoryId: string | number}} binding the repository identity
79
+ * the tombstone digests are bound to
80
+ * @returns {Readonly<Record<string, unknown>>} the validated proof
81
+ */
82
+ export function validateRunAttemptGapProof(proof: unknown, binding: {
83
+ repositoryId: string | number;
84
+ }): Readonly<Record<string, unknown>>;
85
+ /**
86
+ * Compute a recovery record's `recoveryDigest` over the record with
87
+ * `recoveryDigest` omitted.
88
+ *
89
+ * @param {Readonly<Record<string, unknown>>} recovery the recovery record
90
+ * @returns {string} the `recoveryDigest`
91
+ */
92
+ export function computeRecoveryDigest(recovery: Readonly<Record<string, unknown>>): string;
93
+ /**
94
+ * Seal one otherwise complete recovery record by computing its digest. Only
95
+ * a fixture uses this: the real record is server-minted.
96
+ *
97
+ * @param {Readonly<Record<string, unknown>>} withoutDigest the record with no
98
+ * `recoveryDigest`
99
+ * @returns {Readonly<Record<string, unknown>>} the sealed record
100
+ */
101
+ export function sealRecoveryRecord(withoutDigest: Readonly<Record<string, unknown>>): Readonly<Record<string, unknown>>;
102
+ /**
103
+ * Validate one server-supplied `pagesReconciliationRecovery` record. This
104
+ * adapter never mints one; a malformed record is refused before any provider
105
+ * call.
106
+ *
107
+ * @param {unknown} recovery the candidate record
108
+ * @param {{repositoryId: string | number}} binding the repository identity
109
+ * @returns {Readonly<Record<string, unknown>>} the validated record
110
+ */
111
+ export function validateReconciliationRecovery(recovery: unknown, binding: {
112
+ repositoryId: string | number;
113
+ }): Readonly<Record<string, unknown>>;
114
+ /**
115
+ * Refuse a recovery-prior call outside recovery mode. `normal` forbids every
116
+ * recovery-prior call and does not reserve that branch's budget.
117
+ *
118
+ * @param {string} mode the authority mode
119
+ * @returns {void}
120
+ */
121
+ export function assertRecoveryModePermitted(mode: string): void;
122
+ /**
123
+ * Resolve the prior attempt before any current carrier is uploaded or
124
+ * created (DEC-097 section 6.2).
125
+ *
126
+ * - terminal `succeed`: the same operation's proposed generation was already
127
+ * selected. No new create is performed and the current fence terminalizes
128
+ * as `terminal-candidate`.
129
+ * - a terminal non-success: immutable, so the prior create can never
130
+ * activate. The exact prior status is recorded and the caller proceeds
131
+ * with the fresh current carrier/create.
132
+ * - a temporary status or 404: exactly one cataloged cancel of that prior
133
+ * build version, then bounded polling.
134
+ * - still-temporary, 404, malformed, unknown or nonterminal at the recovery
135
+ * deadline: truthful evidence, no current create, authority returns to
136
+ * `reconciliation-required`.
137
+ *
138
+ * @param {import('./rest.js').RestContext} context a REST context already
139
+ * bound to `pages-reconciliation-recovery` mode and the prior build version
140
+ * @param {{
141
+ * sleep?: (seconds: number) => Promise<void>,
142
+ * budgetSeconds?: number
143
+ * }} [options] bounded polling controls
144
+ * @returns {Promise<PriorAttemptObservation>} the truthful observation
145
+ */
146
+ export function resolvePriorAttempt(context: import("./rest.js").RestContext, options?: {
147
+ sleep?: (seconds: number) => Promise<void>;
148
+ budgetSeconds?: number;
149
+ }): Promise<PriorAttemptObservation>;
150
+ /** The `profile` const of a `pagesReconciliationRecovery` record. */
151
+ export const RECOVERY_RECORD_PROFILE: "gala-pages-reconciliation-recovery-v2";
152
+ /** The `profile` const of a `pagesRunAttemptGapProof` record. */
153
+ export const GAP_PROOF_PROFILE: "gala-pages-run-attempt-gap-proof-v2";
154
+ /** The single admitted `authorityState` of an intervening run attempt. */
155
+ export const NO_AUTHORITY_STATE: "closed-no-destination-authority";
156
+ /** The inclusive bounds DEC-097 places on the two fence coordinates. */
157
+ export const PRIOR_RUN_ATTEMPT_BOUNDS: Readonly<{
158
+ minimum: 1;
159
+ maximum: 50;
160
+ }>;
161
+ /** The inclusive bounds on a claiming run attempt. */
162
+ export const CLAIMING_RUN_ATTEMPT_BOUNDS: Readonly<{
163
+ minimum: 2;
164
+ maximum: 51;
165
+ }>;
166
+ export type PriorAttemptObservation = Readonly<{
167
+ profile: "gala-pages-recovery-observation-v2";
168
+ priorPagesBuildVersion: string;
169
+ outcome: "prior-succeeded" | "prior-terminal-failure" | "reconciliation-required";
170
+ authorityState: "terminal-candidate" | "proceed-with-fresh-create" | "reconciliation-required";
171
+ priorStatus: string | null;
172
+ observedStatuses: readonly string[];
173
+ cancelCallCount: number;
174
+ reason: string;
175
+ }>;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Replace every occurrence of every secret in one string.
3
+ *
4
+ * @param {string} text the text to scrub
5
+ * @param {readonly (string | undefined)[]} secrets the secret byte strings
6
+ * @returns {string} the scrubbed text
7
+ */
8
+ export function scrubSecrets(text: string, secrets: readonly (string | undefined)[]): string;
9
+ /**
10
+ * Collect every string that appears anywhere in a JSON-like value, including
11
+ * object keys, so a secret cannot hide in a nested evidence member.
12
+ *
13
+ * @param {unknown} value the value to walk
14
+ * @param {string[]} [into] the accumulator
15
+ * @returns {string[]} every string found
16
+ */
17
+ export function collectStrings(value: unknown, into?: string[]): string[];
18
+ /**
19
+ * Refuse a value that carries any secret's bytes anywhere inside it.
20
+ *
21
+ * @param {unknown} value the value to check (evidence, headers, a body text)
22
+ * @param {readonly (string | undefined)[]} secrets the secret byte strings
23
+ * @param {string} label where the value is bound for, for the diagnostic
24
+ * @returns {void}
25
+ * @throws {Error} `PAGES_SECRET_LEAK_DETECTED` when a secret is present
26
+ */
27
+ export function assertFreeOfSecrets(value: unknown, secrets: readonly (string | undefined)[], label: string): void;
28
+ /**
29
+ * Run one function with every thrown message scrubbed of every secret.
30
+ *
31
+ * @template T
32
+ * @param {readonly (string | undefined)[]} secrets the secret byte strings
33
+ * @param {() => Promise<T>} run the function to run
34
+ * @returns {Promise<T>} the function's result
35
+ */
36
+ export function withRedactedFailures<T>(secrets: readonly (string | undefined)[], run: () => Promise<T>): Promise<T>;
37
+ export { REDACTION_PLACEHOLDER };
38
+ import { REDACTION_PLACEHOLDER } from '@rathnasgala2/adapter-protocol';