@rathnasgala2/adapter-github-pages 0.1.0 → 0.1.2

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,23 @@
1
+ /**
2
+ * Build and validate the declaration for one bound destination.
3
+ *
4
+ * @param {{apiOrigin: string, fileCountCeiling?: number}} context the
5
+ * canonical GitHub REST origin this adapter is bound to
6
+ * @returns {Readonly<Record<string, unknown>>} the validated declaration
7
+ */
8
+ export function describeCapabilities(context: {
9
+ apiOrigin: string;
10
+ fileCountCeiling?: number;
11
+ }): Readonly<Record<string, unknown>>;
12
+ /**
13
+ * The schema package's own `providerCallClassBinding` digest profile
14
+ * (2.8.1). The inventory is typed as an open record, so the profile is
15
+ * required here once, by name, and its absence is a refusal rather than an
16
+ * `undefined` digest.
17
+ *
18
+ * @type {NonNullable<(typeof ACTIVE_DIGEST_PROFILES)['providerCallClassBinding']>}
19
+ */
20
+ export const CALL_CLASS_BINDING_PROFILE: NonNullable<(typeof ACTIVE_DIGEST_PROFILES)["providerCallClassBinding"]>;
21
+ /** This adapter's stable identity digest. */
22
+ export const ADAPTER_DIGEST: string;
23
+ import { ACTIVE_DIGEST_PROFILES } from '@rathnasgala2/schemas/digest-profiles';
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Split one POSIX path into the ustar `prefix`/`name` pair, refusing any
3
+ * path that cannot be represented without a GNU/PAX extension record (which
4
+ * would make the carrier writer-dependent rather than deterministic).
5
+ *
6
+ * @param {string} entryPath the artifact-relative POSIX path
7
+ * @returns {{name: string, prefix: string}} the split fields
8
+ */
9
+ export function splitUstarPath(entryPath: string): {
10
+ name: string;
11
+ prefix: string;
12
+ };
13
+ /**
14
+ * Refuse any member path that would not extract inside the carrier root.
15
+ *
16
+ * The carrier is extracted by the provider, not by this process, so the
17
+ * only place an escaping member can be stopped is here, at the point it is
18
+ * written. Only regular-file (typeflag `0`) and directory (typeflag `5`)
19
+ * entries are ever emitted: this codec has no link or device entry, so a
20
+ * symlink/hardlink member cannot exist to be followed.
21
+ *
22
+ * @param {string} entryPath the artifact-relative POSIX path
23
+ * @returns {string} the accepted path
24
+ */
25
+ export function requireContainedPath(entryPath: string): string;
26
+ /**
27
+ * Encode a complete file set as deterministic uncompressed ustar
28
+ * carrier bytes (never gzip; see the module comment).
29
+ *
30
+ * @param {readonly CarrierFile[]} files the complete artifact file set,
31
+ * including the reserved public generation marker
32
+ * @returns {Buffer} the carrier bytes
33
+ */
34
+ export function encodeCarrier(files: readonly CarrierFile[]): Buffer;
35
+ /**
36
+ * Decode carrier bytes back into the exact file set they were built from.
37
+ * The adapter itself never needs this (it only ever writes a carrier); it
38
+ * exists so a caller — the Pages provider, a conformance fixture or a
39
+ * codec golden test — can prove the round trip is lossless.
40
+ *
41
+ * @param {Buffer} carrier the carrier bytes
42
+ * @returns {CarrierFile[]} the decoded file set, in carrier order; directory
43
+ * entries (typeflag `5`) are skipped
44
+ */
45
+ export function decodeCarrier(carrier: Buffer): CarrierFile[];
46
+ export type CarrierFile = Readonly<{
47
+ path: string;
48
+ bytes: Buffer;
49
+ }>;
@@ -0,0 +1,86 @@
1
+ /**
2
+ * This adapter's installed package version, read from its own `package.json`
3
+ * rather than restated by hand: DEC-097 section 3 requires the capability
4
+ * document's `adapter.adapterVersion` to byte-equal the locked package
5
+ * version, and the only value that can never drift from what a lock records
6
+ * for this package is the version the package manifest itself declares.
7
+ */
8
+ export const ADAPTER_VERSION: string;
9
+ /**
10
+ * The reserved artifact-relative coordinate the public generation marker is
11
+ * staged at (brief section 5). Freeze rejects an artifact route colliding
12
+ * with it; this adapter adds it to the deterministic Pages carrier.
13
+ */
14
+ export const GENERATION_MARKER_PATH: ".well-known/gala-generation.json";
15
+ /**
16
+ * The exact twelve accepted `GET /repos/{owner}/{repo}/pages/deployments/{id}`
17
+ * status values (brief section 6.2, plus `deployment_queued`, which GitHub's
18
+ * REST reference lists and a real run returned on 2026-10-06). Anything else
19
+ * is unknown and can never release the destination fence.
20
+ */
21
+ export const PAGES_DEPLOYMENT_STATUSES: readonly string[];
22
+ /**
23
+ * Temporary statuses: polling continues and the fence stays held.
24
+ * `deployment_queued` is the state before `deployment_in_progress`, and
25
+ * `deployment_attempt_error` is temporary because GitHub retries it
26
+ * automatically (brief section 6.2).
27
+ */
28
+ export const TEMPORARY_STATUSES: readonly string[];
29
+ /** Terminal failure statuses: the deployment can never later succeed. */
30
+ export const TERMINAL_FAILURE_STATUSES: readonly string[];
31
+ /** The single success status. */
32
+ export const SUCCESS_STATUS: "succeed";
33
+ /**
34
+ * The exact poll schedule in seconds: `5, 8, 12, 18, 27, 30`, then `30`
35
+ * repeatedly while the fixed budget permits (brief section 6.2).
36
+ */
37
+ export const POLL_SCHEDULE_SECONDS: readonly number[];
38
+ /** The repeated tail wait, in seconds, once the schedule is exhausted. */
39
+ export const POLL_TAIL_SECONDS: 30;
40
+ /** Fixed activation-detection polling budget, in seconds. */
41
+ export const POLL_BUDGET_SECONDS: 1500;
42
+ /** Hard ceiling on the deterministic Pages carrier, in bytes. */
43
+ export const MAXIMUM_PAGES_CARRIER_BYTES: 1073741824;
44
+ /** Domain separator: `adapter-capability:2.0.0.capabilityDigest`. */
45
+ export const DOMAIN_ADAPTER_CAPABILITY: "GALA-ADAPTER-CAPABILITY-V2\0";
46
+ /** Domain separator shared with the template's artifact-manifest projection. */
47
+ export const DOMAIN_ARTIFACT: "GALA-ARTIFACT-V2 ";
48
+ /** Domain separator: this adapter's own identity digest. */
49
+ export const DOMAIN_ADAPTER_IDENTITY: "GALA-PAGES-ADAPTER-IDENTITY-V2\0";
50
+ /** Domain separator: the `pagesBuildVersion` projection (brief section 6.2). */
51
+ export const DOMAIN_PAGES_BUILD_VERSION: "GALA-PAGES-BUILD-VERSION-V2\0";
52
+ /** Domain separator: the physical Pages destination mutation key. */
53
+ export const DOMAIN_PAGES_DESTINATION: "GALA-PAGES-DESTINATION-V2\0";
54
+ /** Domain separator: the stage token projection. */
55
+ export const DOMAIN_PAGES_STAGE_TOKEN: "GALA-PAGES-STAGE-TOKEN-V2\0";
56
+ /** Domain separator: the frozen provider request-template catalog. */
57
+ export const DOMAIN_PAGES_REQUEST_CATALOG: "GALA-PAGES-REQUEST-CATALOG-V2\0";
58
+ /** Domain separator: the frozen provider response-profile catalog. */
59
+ export const DOMAIN_PAGES_RESPONSE_CATALOG: "GALA-PAGES-RESPONSE-CATALOG-V2\0";
60
+ /** Domain separator: the provider compatibility evidence record. */
61
+ export const DOMAIN_PAGES_COMPATIBILITY: "GALA-PAGES-COMPATIBILITY-V2\0";
62
+ /** Domain separator: the TLS profile record. */
63
+ export const DOMAIN_PAGES_TLS_PROFILE: "GALA-PAGES-TLS-PROFILE-V2\0";
64
+ /** Domain separator: the credential-egress profile record. */
65
+ export const DOMAIN_PAGES_CREDENTIAL_EGRESS: "GALA-PAGES-CREDENTIAL-EGRESS-V2\0";
66
+ /** Domain separator: an intervening run attempt's no-authority tombstone. */
67
+ export const DOMAIN_PAGES_NO_AUTHORITY_RUN_ATTEMPT: "GALA-PAGES-NO-AUTHORITY-RUN-ATTEMPT-V2\0";
68
+ /** Domain separator: the run-attempt gap proof record. */
69
+ export const DOMAIN_PAGES_RUN_ATTEMPT_GAP_PROOF: "GALA-PAGES-RUN-ATTEMPT-GAP-PROOF-V2\0";
70
+ /** Domain separator: the `pagesReconciliationRecovery` record. */
71
+ export const DOMAIN_PAGES_RECONCILIATION_RECOVERY: "GALA-PAGES-RECONCILIATION-RECOVERY-V2\0";
72
+ /**
73
+ * The two admitted `destinationMutationAuthority.mode` values (DEC-097
74
+ * section 6.2). `normal` forbids every `pages-recovery-*` call.
75
+ */
76
+ export const NORMAL_MODE: "normal";
77
+ /** The recovery mode that admits the two `pages-recovery-*` call classes. */
78
+ export const RECOVERY_MODE: "pages-reconciliation-recovery";
79
+ /** The two admitted authority modes. */
80
+ export const AUTHORITY_MODES: readonly string[];
81
+ /**
82
+ * Bounded budget, in seconds, for the complete recovery-prior
83
+ * status/poll/cancel/poll sequence. Recovery authorization budgets this in
84
+ * addition to the ordinary fresh carrier/create/current poll sequence.
85
+ */
86
+ export const RECOVERY_POLL_BUDGET_SECONDS: 300;
@@ -0,0 +1,107 @@
1
+ /**
2
+ * The `pagesBuildVersion`: the workflow run's head commit SHA (`GITHUB_SHA`,
3
+ * the OIDC `sha` claim). GitHub validates `pages_build_version` as a commit
4
+ * of the repository (measured on 2026-10-04: any other 40-hex value, such as
5
+ * a synthetic hash, answers 404), so a synthetic derivation can never deploy.
6
+ * `pagesDeploymentId` must equal it exactly.
7
+ *
8
+ * @param {{headSha?: string | undefined}} projection the run's head commit
9
+ * @returns {string} the 40-character lowercase hexadecimal build version
10
+ */
11
+ export function derivePagesBuildVersion(projection: {
12
+ headSha?: string | undefined;
13
+ }): string;
14
+ /**
15
+ * Refuse a create-body text that is not the exact compact JCS of the three
16
+ * admitted members. Exported so a fixture can prove a duplicated, extra,
17
+ * missing or reordered member is refused without reaching a provider.
18
+ *
19
+ * @param {string} bodyText the serialized request entity
20
+ * @returns {void}
21
+ */
22
+ export function assertCanonicalCreateBody(bodyText: string): void;
23
+ /**
24
+ * Build the exact `gala-pages-create-deployment-jcs-v2` request entity.
25
+ *
26
+ * @param {{
27
+ * pagesArtifactId: string | number,
28
+ * pagesBuildVersion: string,
29
+ * oidcToken: string,
30
+ * githubToken: string
31
+ * }} input the body inputs
32
+ * @returns {Readonly<{bodyText: string, byteCount: number, artifactId: number}>}
33
+ * the canonical body text and its non-secret measurements
34
+ */
35
+ export function buildCreateDeploymentBody(input: {
36
+ pagesArtifactId: string | number;
37
+ pagesBuildVersion: string;
38
+ oidcToken: string;
39
+ githubToken: string;
40
+ }): Readonly<{
41
+ bodyText: string;
42
+ byteCount: number;
43
+ artifactId: number;
44
+ }>;
45
+ /**
46
+ * Issue the single create-deployment call and return the closed provider
47
+ * identity projection. `createResponseStatusUrl` is carried only on the
48
+ * `createResponseObserved: true` branch and only when it equals the exact
49
+ * expected shape; it is evidence, never a URL this adapter follows.
50
+ *
51
+ * The OIDC token is verified against its expected bindings and then placed
52
+ * only in the body. Neither credential can reach the returned evidence: the
53
+ * whole projection is scanned before it is returned, and every failure
54
+ * message is scrubbed.
55
+ *
56
+ * @param {import('./rest.js').RestContext} context the bound REST context
57
+ * @param {{
58
+ * pagesArtifactId: string | number,
59
+ * pagesBuildVersion: string,
60
+ * oidcToken: string,
61
+ * oidcExpectation: import('./oidc.js').PagesOidcExpectation,
62
+ * stage?: string
63
+ * }} input the create inputs
64
+ * @returns {Promise<Readonly<Record<string, unknown>>>} the provider identity
65
+ */
66
+ export function createDeployment(context: import("./rest.js").RestContext, input: {
67
+ pagesArtifactId: string | number;
68
+ pagesBuildVersion: string;
69
+ oidcToken: string;
70
+ oidcExpectation: import("./oidc.js").PagesOidcExpectation;
71
+ stage?: string;
72
+ }): Promise<Readonly<Record<string, unknown>>>;
73
+ /**
74
+ * Poll one deployment to a terminal state under the fixed budget, waiting
75
+ * exactly `5, 8, 12, 18, 27, 30` seconds and then repeating `30`.
76
+ *
77
+ * @param {import('./rest.js').RestContext} context the bound REST context
78
+ * @param {string} pagesDeploymentId the deployment identity, used only to
79
+ * name the deployment in diagnostics; the request target's segment is
80
+ * selected statically by the call class from the bound context
81
+ * @param {{
82
+ * sleep?: (seconds: number) => Promise<void>,
83
+ * budgetSeconds?: number,
84
+ * stage?: string
85
+ * }} options polling controls; `sleep` is injectable so a test proves the
86
+ * schedule without spending it in wall-clock time
87
+ * @returns {Promise<{
88
+ * status: string,
89
+ * succeeded: boolean,
90
+ * observedStatuses: string[],
91
+ * waitedSeconds: number[]
92
+ * }>} the terminal observation
93
+ */
94
+ export function pollDeployment(context: import("./rest.js").RestContext, pagesDeploymentId: string, options: {
95
+ sleep?: (seconds: number) => Promise<void>;
96
+ budgetSeconds?: number;
97
+ stage?: string;
98
+ }): Promise<{
99
+ status: string;
100
+ succeeded: boolean;
101
+ observedStatuses: string[];
102
+ waitedSeconds: number[];
103
+ }>;
104
+ /** The exact three member names of the create request entity, in JCS order. */
105
+ export const CREATE_BODY_MEMBERS: readonly string[];
106
+ /** The inclusive upper bound on `artifact_id` (exact JSON/JCS identity). */
107
+ export const MAXIMUM_ARTIFACT_ID: 9007199254740991;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * This adapter's one typed failure class (PUB-H6). Every refusal this
3
+ * package raises -- OIDC verification, the Pages REST catalog, the request
4
+ * catalog, carrier construction, capability declaration, recovery --
5
+ * throws `PagesAdapterError`, which carries a stable `code` as a real
6
+ * property so a consumer can discriminate
7
+ * `error.code === 'PAGES_OIDC_SUBJECT_MISMATCH'` without parsing
8
+ * `.message`. `.message` is `${code}: ${detail}`, so a log line or the
9
+ * credential-hygiene scan still matches a code inside the message.
10
+ *
11
+ * The closed code vocabulary this class carries is documented in
12
+ * `README.md`.
13
+ *
14
+ * @module
15
+ */
16
+ /**
17
+ * A typed failure this adapter raises, carrying a stable `code`
18
+ * alongside the ordinary `Error` message.
19
+ */
20
+ export class PagesAdapterError extends Error {
21
+ /**
22
+ * @param {string} code stable, machine-readable failure code
23
+ * @param {string} detail human-readable detail (never a token byte)
24
+ */
25
+ constructor(code: string, detail: string);
26
+ /** @type {string} */
27
+ code: string;
28
+ }
@@ -0,0 +1,316 @@
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
+ * failure?: PublicRedirectFailure
20
+ * }>>} the inspection result
21
+ */
22
+ export function inspectDestination(destination: PagesDestination): Promise<Readonly<{
23
+ currentGenerationId: string | null;
24
+ retainedHistory: readonly Readonly<Record<string, unknown>>[];
25
+ releaseGenerationsOnDisk: readonly string[];
26
+ providerSiteObserved: boolean;
27
+ findings: readonly string[];
28
+ failure?: PublicRedirectFailure;
29
+ }>>;
30
+ /**
31
+ * `preflight`: check every declared route against the portable path rules
32
+ * and the reserved marker coordinate, and report the currently served
33
+ * generation for fencing. No provider mutation of any kind occurs here.
34
+ *
35
+ * @param {{
36
+ * destination: PagesDestination,
37
+ * entries: readonly {path: string}[],
38
+ * expectedGenerationId?: string
39
+ * }} input the preflight input
40
+ * @returns {Promise<Readonly<{
41
+ * verdict: 'proceed' | 'refuse',
42
+ * observedGenerationId: string | null,
43
+ * findings: readonly string[]
44
+ * }>>} the preflight result
45
+ */
46
+ export function preflight(input: {
47
+ destination: PagesDestination;
48
+ entries: readonly {
49
+ path: string;
50
+ }[];
51
+ expectedGenerationId?: string;
52
+ }): Promise<Readonly<{
53
+ verdict: "proceed" | "refuse";
54
+ observedGenerationId: string | null;
55
+ findings: readonly string[];
56
+ }>>;
57
+ /**
58
+ * `stage`: build the deterministic Pages carrier and publish it through the
59
+ * caller-supplied Actions-artifact publisher. Nothing public changes here —
60
+ * `staging: private` is literal: the carrier is an Actions artifact that no
61
+ * public origin serves.
62
+ *
63
+ * @param {{
64
+ * destination: PagesDestination,
65
+ * operationId: string,
66
+ * attemptId: string,
67
+ * idempotencyKey: string,
68
+ * generationId: string,
69
+ * artifactId: string,
70
+ * artifactDigest: string,
71
+ * files: readonly StagedFile[]
72
+ * }} input the stage input
73
+ * @returns {Promise<Readonly<{
74
+ * stageToken: string,
75
+ * stagedPath: string,
76
+ * fileCount: number,
77
+ * byteCount: string,
78
+ * carrierDigest: string,
79
+ * pagesArtifactId: string,
80
+ * idempotent: boolean
81
+ * }>>} the stage result
82
+ */
83
+ export function stage(input: {
84
+ destination: PagesDestination;
85
+ operationId: string;
86
+ attemptId: string;
87
+ idempotencyKey: string;
88
+ generationId: string;
89
+ artifactId: string;
90
+ artifactDigest: string;
91
+ files: readonly StagedFile[];
92
+ }): Promise<Readonly<{
93
+ stageToken: string;
94
+ stagedPath: string;
95
+ fileCount: number;
96
+ byteCount: string;
97
+ carrierDigest: string;
98
+ pagesArtifactId: string;
99
+ idempotent: boolean;
100
+ }>>;
101
+ /**
102
+ * Resolve the prior attempt of an unresolved Pages fence before any current
103
+ * carrier is uploaded or created. Exposed separately so the deploy script
104
+ * can run the DEC-097 section 6.2 precheck *before* it calls `stage` (this
105
+ * package's carrier upload happens in `stage`); `activate` runs it again,
106
+ * ahead of any current create, when it is given recovery inputs.
107
+ *
108
+ * @param {{
109
+ * destination: PagesDestination,
110
+ * pagesRecovery: Readonly<Record<string, unknown>>
111
+ * }} input the recovery input
112
+ * @returns {Promise<import('./recovery.js').PriorAttemptObservation>} the
113
+ * truthful prior-attempt observation
114
+ */
115
+ export function recoverPriorAttempt(input: {
116
+ destination: PagesDestination;
117
+ pagesRecovery: Readonly<Record<string, unknown>>;
118
+ }): Promise<import("./recovery.js").PriorAttemptObservation>;
119
+ /**
120
+ * `activate`: create exactly one Pages deployment for a staged carrier and
121
+ * poll it to a terminal status (`activation: provider-promotion`).
122
+ *
123
+ * `expectedCurrentGenerationId` is the adapter-protocol `2.1.0` fence:
124
+ * either a generation identity or the explicit `EXPECT_NOTHING_SERVED`
125
+ * sentinel. `null` and `undefined` are refused with
126
+ * `EXPECTED_GENERATION_FENCE_INVALID` (LOCAL-47) — there is no unfenced
127
+ * activation. The check itself is a read-then-compare performed immediately
128
+ * before the create call: honest best effort, not a provider fence, because
129
+ * GitHub Pages exposes no compare-and-set on activation, which is exactly
130
+ * why this adapter declares `concurrency: none`.
131
+ *
132
+ * In `pages-reconciliation-recovery` mode the prior attempt is resolved
133
+ * first, before any current create, per DEC-097 section 6.2.
134
+ *
135
+ * @param {{
136
+ * destination: PagesDestination,
137
+ * stageToken: string,
138
+ * generationId: string,
139
+ * expectedCurrentGenerationId: string,
140
+ * expectedArtifactDigest?: string,
141
+ * pagesOidcToken?: string,
142
+ * pagesOidcClaims?: import('./oidc.js').PagesOidcExpectation,
143
+ * mode?: string,
144
+ * pagesRecovery?: Readonly<Record<string, unknown>>,
145
+ * crashInjectionHook?: () => void | Promise<void>
146
+ * }} input the activate input; `crashInjectionHook`, when supplied (only
147
+ * ever by a conformance fixture), is awaited after the carrier is durably
148
+ * published but strictly before the create-deployment call
149
+ * @returns {Promise<Readonly<Record<string, unknown>>>} the decision
150
+ */
151
+ export function activate(input: {
152
+ destination: PagesDestination;
153
+ stageToken: string;
154
+ generationId: string;
155
+ expectedCurrentGenerationId: string;
156
+ expectedArtifactDigest?: string;
157
+ pagesOidcToken?: string;
158
+ pagesOidcClaims?: import("./oidc.js").PagesOidcExpectation;
159
+ mode?: string;
160
+ pagesRecovery?: Readonly<Record<string, unknown>>;
161
+ crashInjectionHook?: () => void | Promise<void>;
162
+ }): Promise<Readonly<Record<string, unknown>>>;
163
+ /**
164
+ * `observe`: verify the activated generation through credential-free public
165
+ * reads. `providerInventoryAssurance` is `none`, so this verifies exactly
166
+ * the routes this run staged plus the marker; it never claims the deployed
167
+ * inventory is complete.
168
+ *
169
+ * @param {{
170
+ * destination: PagesDestination,
171
+ * generationId: string,
172
+ * expectedArtifactDigest: string
173
+ * }} input the observe input
174
+ * @returns {Promise<Readonly<{
175
+ * verified: boolean,
176
+ * observedArtifactDigest: string | null,
177
+ * currentGenerationId: string | null,
178
+ * markerValid: boolean,
179
+ * claimsCompleteInventory: false,
180
+ * findings: readonly string[],
181
+ * failure?: PublicRedirectFailure
182
+ * }>>} the observation result
183
+ */
184
+ export function observe(input: {
185
+ destination: PagesDestination;
186
+ generationId: string;
187
+ expectedArtifactDigest: string;
188
+ }): Promise<Readonly<{
189
+ verified: boolean;
190
+ observedArtifactDigest: string | null;
191
+ currentGenerationId: string | null;
192
+ markerValid: boolean;
193
+ claimsCompleteInventory: false;
194
+ findings: readonly string[];
195
+ failure?: PublicRedirectFailure;
196
+ }>>;
197
+ /**
198
+ * `cleanupStaged`: drop this operation's staged carrier from run-scoped
199
+ * memory and, when an abandoned generation is named, cancel its in-flight
200
+ * deployment through the cataloged cancel call. It never cancels or
201
+ * disturbs a generation that is currently served or retained.
202
+ *
203
+ * @param {{
204
+ * destination: PagesDestination,
205
+ * stageToken: string,
206
+ * generationId?: string
207
+ * }} input the cleanup input
208
+ * @returns {Promise<Readonly<{removed: boolean, cancelled: boolean}>>} whether
209
+ * staged state was removed and whether a deployment was cancelled
210
+ */
211
+ export function cleanupStaged(input: {
212
+ destination: PagesDestination;
213
+ stageToken: string;
214
+ generationId?: string;
215
+ }): Promise<Readonly<{
216
+ removed: boolean;
217
+ cancelled: boolean;
218
+ }>>;
219
+ /**
220
+ * `rollback`: `rollback: reupload` semantics. GitHub Pages cannot natively
221
+ * re-promote a historical deployment, so a rollback stages a fresh carrier
222
+ * for the selected historical content under a *new* generation identity and
223
+ * activates it through the ordinary create/poll path.
224
+ *
225
+ * The historical bytes are not recoverable from the provider (Pages exposes
226
+ * no artifact read-back), so the caller supplies them through `files`. The
227
+ * run-scoped stage memory is used only when the target generation was
228
+ * staged by this same run.
229
+ *
230
+ * @param {{
231
+ * destination: PagesDestination,
232
+ * targetGenerationId: string,
233
+ * newGenerationId: string,
234
+ * newArtifactId: string,
235
+ * operationId: string,
236
+ * attemptId: string,
237
+ * idempotencyKey: string,
238
+ * files?: readonly StagedFile[],
239
+ * artifactDigest?: string,
240
+ * pagesOidcToken?: string,
241
+ * pagesOidcClaims?: import('./oidc.js').PagesOidcExpectation
242
+ * }} input the rollback input
243
+ * @returns {Promise<Readonly<Record<string, unknown>>>} the activation decision
244
+ */
245
+ export function rollback(input: {
246
+ destination: PagesDestination;
247
+ targetGenerationId: string;
248
+ newGenerationId: string;
249
+ newArtifactId: string;
250
+ operationId: string;
251
+ attemptId: string;
252
+ idempotencyKey: string;
253
+ files?: readonly StagedFile[];
254
+ artifactDigest?: string;
255
+ pagesOidcToken?: string;
256
+ pagesOidcClaims?: import("./oidc.js").PagesOidcExpectation;
257
+ }): Promise<Readonly<Record<string, unknown>>>;
258
+ export { PagesAdapterError } from "./errors.js";
259
+ export { computeArtifactDigest } from "./artifact-projection.js";
260
+ export { buildValidatedMarker } from "./marker.js";
261
+ export { forgetDestination } from "./store.js";
262
+ /** This package's runtime status: fully implemented per S4-T04 (W4-11). */
263
+ export const PACKAGE_STATUS: Readonly<{
264
+ name: "@rathnasgala2/adapter-github-pages";
265
+ implemented: true;
266
+ implementingTask: "S4-T04";
267
+ }>;
268
+ /**
269
+ * The classified failure the adapter reports when the public origin answers
270
+ * with a redirect instead of the route: the destination's `publicBaseUrl` no
271
+ * longer names the host that serves the site (typically a custom domain was
272
+ * attached while the repository still carries the `github.io` base). The
273
+ * adapter follows no redirect, so it cannot tell what the origin serves.
274
+ */
275
+ export type PublicRedirectFailure = Readonly<{
276
+ code: "PAGES_PUBLIC_REDIRECT";
277
+ toHost: string | null;
278
+ location: string | null;
279
+ }>;
280
+ export type PagesDestination = Readonly<{
281
+ owner: string;
282
+ repository: string;
283
+ repositoryId?: string | number;
284
+ repositoryOwnerId?: string | number;
285
+ apiOrigin?: string;
286
+ oidcToken?: string;
287
+ oidcClaims?: import("./oidc.js").PagesOidcExpectation;
288
+ publicBaseUrl: string;
289
+ verificationBaseUrl?: string;
290
+ token: string;
291
+ publishCarrier: (input: {
292
+ bytes: Buffer;
293
+ generationId: string;
294
+ carrierDigest: string;
295
+ }) => Promise<{
296
+ pagesArtifactId: string | number;
297
+ artifactDigest?: string;
298
+ byteCount?: number;
299
+ }>;
300
+ fetch?: typeof globalThis.fetch;
301
+ publicFetch?: typeof globalThis.fetch;
302
+ sleep?: (seconds: number) => Promise<void>;
303
+ runId?: string;
304
+ runAttempt?: number;
305
+ headSha?: string;
306
+ }>;
307
+ export type StagedFile = Readonly<{
308
+ path: string;
309
+ bytes: Buffer;
310
+ }>;
311
+ export { EXPECT_NOTHING_SERVED, fenceFor, generateUuidV7 } from "@rathnasgala2/adapter-protocol";
312
+ export { decodeCarrier, encodeCarrier } from "./carrier.js";
313
+ export { GENERATION_MARKER_PATH, ADAPTER_VERSION, NORMAL_MODE, RECOVERY_MODE } from "./constants.js";
314
+ export { PAGES_OIDC_ENVIRONMENT, PAGES_OIDC_ISSUER, PAGES_OIDC_PROFILE, buildSubjectForms, verifyPagesOidcToken } from "./oidc.js";
315
+ export { GAP_PROOF_PROFILE, NO_AUTHORITY_STATE, RECOVERY_RECORD_PROFILE, buildInterveningAttempts, buildRunAttemptGapProof, computeGapProofDigest, computeInterveningAttemptDigest, computeRecoveryDigest, sealRecoveryRecord, validateReconciliationRecovery, validateRunAttemptGapProof } from "./recovery.js";
316
+ 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";