@rathnasgala2/adapter-github-pages 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.
- package/CHANGELOG.md +125 -0
- package/README.md +202 -0
- package/package.json +39 -0
- package/src/artifact-projection.js +78 -0
- package/src/capability.js +229 -0
- package/src/carrier.js +216 -0
- package/src/constants.js +156 -0
- package/src/deployment.js +333 -0
- package/src/index.d.ts +246 -0
- package/src/index.js +977 -0
- package/src/marker.js +73 -0
- package/src/oidc.js +515 -0
- package/src/public-read.js +61 -0
- package/src/recovery.js +784 -0
- package/src/redaction.js +112 -0
- package/src/request-catalog.js +417 -0
- package/src/rest.js +360 -0
- package/src/store.js +103 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to
|
|
7
|
+
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
8
|
+
|
|
9
|
+
## [Unreleased]
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- **PUBLISH-S4-6a — `ADAPTER_VERSION` is the installed package version.**
|
|
14
|
+
DEC-097 section 3 requires the capability document's `adapter.adapterVersion`
|
|
15
|
+
to byte-equal the locked package version, so the constant is now read from
|
|
16
|
+
this package's own `package.json` (`0.1.0`) instead of the hand-written
|
|
17
|
+
`2.0.0` no lock could ever record for a `0.1.0` package. The capability
|
|
18
|
+
document's `adapter.adapterVersion` and identity digest (`adapterDigest`,
|
|
19
|
+
derived from the name/version pair) change accordingly; no golden vector in
|
|
20
|
+
this package pinned the previous value. The repository-level
|
|
21
|
+
`test/adapter-version.test.mjs` proves the constant, the manifest and a lock
|
|
22
|
+
row pinning this package agree, and that `deploy.mjs` refuses any other pin.
|
|
23
|
+
- `callClassBindingDigest` is computed with schema 2.8.1's exported
|
|
24
|
+
`ACTIVE_DIGEST_PROFILES.providerCallClassBinding` (PUBLISH-S4-5); the local
|
|
25
|
+
`DOMAIN_PAGES_CALL_CLASS_BINDING` constant and export are gone. A test proves
|
|
26
|
+
the exported profile and the previous local `domainDigest` computation agree
|
|
27
|
+
byte-for-byte (preimage and digest) on the real nine rows, so the declared
|
|
28
|
+
digest is unchanged.
|
|
29
|
+
|
|
30
|
+
### Added
|
|
31
|
+
|
|
32
|
+
- `CALL_CLASS_BINDING` (PUBLISH-S4-4b, schema 2.8.0, LOCAL-52 (2)): the per-row
|
|
33
|
+
`pagesDeploymentId` source and recovery-only flag that used to be an
|
|
34
|
+
undeclared side table (`CALL_CLASS_ID_BINDING`) are now the declared
|
|
35
|
+
`limits.callClassBinding` rows of the capability document, bound by
|
|
36
|
+
`limits.callClassBindingDigest` under `GALA-PROVIDER-CALL-CLASS-BINDING-V2\0`
|
|
37
|
+
(exported as `DOMAIN_PAGES_CALL_CLASS_BINDING`, matched against the schema
|
|
38
|
+
package's golden vector). `requestTemplateCatalogDigest` is byte-identical to
|
|
39
|
+
before and is now pinned by a test. `callClassIdBinding(stage, callClass)`
|
|
40
|
+
returns the declared row; `CALL_CLASS_ID_BINDING` is gone.
|
|
41
|
+
|
|
42
|
+
- The complete DEC-097 section 7 nine-row request catalog (PUBLISH-S4-2):
|
|
43
|
+
`inspect/pages-site`, `activate/pages-create-deployment`,
|
|
44
|
+
`activate/pages-deployment-status`, `observe/pages-deployment-status`,
|
|
45
|
+
`inspect/pages-recovery-prior-status`,
|
|
46
|
+
`cleanup-staged/pages-cancel-deployment`,
|
|
47
|
+
`cleanup-staged/pages-recovery-prior-cancel`,
|
|
48
|
+
`rollback/pages-create-deployment` and `rollback/pages-deployment-status`,
|
|
49
|
+
sorted by member JCS bytes, each carrying the mandatory
|
|
50
|
+
`accept-encoding: identity` and `connection: close` headers. The
|
|
51
|
+
`pagesDeploymentId` segment is now selected statically by the call class from
|
|
52
|
+
either the intent's `pagesBuildVersion` or
|
|
53
|
+
`pagesRecovery.priorPagesBuildVersion`, and every request is checked against
|
|
54
|
+
its template before dispatch.
|
|
55
|
+
- `src/oidc.js`: the `gala-pages-oidc-v2` credential-source profile. The Pages
|
|
56
|
+
OIDC token is now a mandatory caller-supplied input (`pagesOidcToken` /
|
|
57
|
+
`destination.oidcToken`, with `pagesOidcClaims` / `destination.oidcClaims`
|
|
58
|
+
carrying the expected bindings) and a mandatory `oidc_token` member of the
|
|
59
|
+
create request entity. The adapter never mints it, performs no
|
|
60
|
+
issuer-signature or JWKS verification and makes no discovery network call.
|
|
61
|
+
- `src/recovery.js`: DEC-097 section 6.2 reconciliation recovery — validation of
|
|
62
|
+
the server-minted `pagesReconciliationRecovery` record, its
|
|
63
|
+
`pagesRunAttemptGapProof` and every `closed-no-destination-authority`
|
|
64
|
+
tombstone digest, plus the same-operation prior-attempt resolution
|
|
65
|
+
(`activate({mode: 'pages-reconciliation-recovery', pagesRecovery})` and the
|
|
66
|
+
separately callable `recoverPriorAttempt`).
|
|
67
|
+
- `src/redaction.js`: enforced, bidirectional credential redaction — the OIDC
|
|
68
|
+
token can never reach a header, evidence, digest, output, log or thrown
|
|
69
|
+
message, and the GitHub token can never reach the body.
|
|
70
|
+
|
|
71
|
+
### Changed
|
|
72
|
+
|
|
73
|
+
- **Breaking.** `activate`'s `expectedCurrentGenerationId` now follows adapter
|
|
74
|
+
protocol `2.1.0` (LOCAL-47): it is either a generation identity or the
|
|
75
|
+
`EXPECT_NOTHING_SERVED` sentinel, and `null`/`undefined` are refused with
|
|
76
|
+
`EXPECTED_GENERATION_FENCE_INVALID`. `rollback` builds its fence with
|
|
77
|
+
`fenceFor`. Both the sentinel and `fenceFor` are re-exported here.
|
|
78
|
+
- **Breaking.** `requireTemplate(templates, stage, callClass)` resolves by the
|
|
79
|
+
`(stage, callClass)` pair, and `callProvider(context, stage, callClass, ...)`
|
|
80
|
+
names both. The old call-class-only names (`pages-read-site`,
|
|
81
|
+
`pages-poll-deployment-status`) are gone.
|
|
82
|
+
- **Breaking.** `activate` requires a Pages OIDC token and its expected
|
|
83
|
+
bindings, and the destination must carry `repositoryId` and
|
|
84
|
+
`repositoryOwnerId` so the two admitted subject forms can be recomputed.
|
|
85
|
+
- The create request entity is now the exact compact JCS of the three members
|
|
86
|
+
`artifact_id`, `oidc_token` and `pages_build_version`; a string artifact id,
|
|
87
|
+
an unsafe integer, a missing/extra/reordered member and noncanonical JSON are
|
|
88
|
+
each refused locally.
|
|
89
|
+
|
|
90
|
+
- Real implementation over the adapter protocol (S4-T04, backlog W4-11),
|
|
91
|
+
replacing the S2-T15 scaffold placeholder:
|
|
92
|
+
- a deterministic one-member gzip/POSIX.1-1988 ustar Pages carrier whose bytes
|
|
93
|
+
are identical for identical inputs (fixed mtime, ownership, mode, entry
|
|
94
|
+
order, and a zeroed gzip MTIME/OS byte), with codec goldens and a lossless
|
|
95
|
+
round-trip test;
|
|
96
|
+
- the raw Pages REST catalog, declared as data and digested into the
|
|
97
|
+
capability declaration, with no opaque `actions/deploy-pages`, no branch
|
|
98
|
+
mutation and no assumed source commit (expanded to the full nine rows under
|
|
99
|
+
PUBLISH-S4-2, above);
|
|
100
|
+
- `pagesBuildVersion` derived from the domain-separated
|
|
101
|
+
repository/operation/attempt/run/artifact/generation projection, and a
|
|
102
|
+
refusal when the returned `pagesDeploymentId` does not equal it exactly;
|
|
103
|
+
- the exact eleven-status vocabulary, its temporary/terminal partition (with
|
|
104
|
+
`deployment_attempt_error` temporary) and the exact
|
|
105
|
+
`5, 8, 12, 18, 27, 30`-then-`30` poll schedule, with an unknown status and
|
|
106
|
+
an exhausted budget both holding the fence rather than releasing it;
|
|
107
|
+
- a never-followed `status_url`: every poll uses an independently constructed
|
|
108
|
+
suffix-free URL;
|
|
109
|
+
- integrity recheck of the staged carrier against the caller's frozen artifact
|
|
110
|
+
digest before promotion, and a crash-injection boundary between durable
|
|
111
|
+
carrier publication and the create call;
|
|
112
|
+
- credential-free public verification of the activated origin, and
|
|
113
|
+
`rollback: reupload` under a new generation identity.
|
|
114
|
+
- The full `@rathnasgala2/adapter-conformance-kit` suite passes against a local
|
|
115
|
+
fake provider that speaks real HTTP over the loopback interface and genuinely
|
|
116
|
+
gunzips and untars the carrier before serving it.
|
|
117
|
+
|
|
118
|
+
### Known gaps
|
|
119
|
+
|
|
120
|
+
- The live GitHub Pages deployment API is untested here; that is backlog W4-16.
|
|
121
|
+
Everything above is proven against the local fake only.
|
|
122
|
+
|
|
123
|
+
- Workspace scaffold placeholder: valid `package.json`, JSDoc-typed status
|
|
124
|
+
export, hand-maintained `.d.ts`, and a passing placeholder test. No runtime
|
|
125
|
+
behavior ships; implementation is scoped to S2-T19 (S2-T15).
|
package/README.md
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# @rathnasgala2/adapter-github-pages
|
|
2
|
+
|
|
3
|
+
The managed GitHub Pages deployment adapter (S4-T04, backlog W4-11). It
|
|
4
|
+
implements the eight `@rathnasgala2/adapter-protocol` lifecycle functions and
|
|
5
|
+
declares exactly the DEC-097 section 7 `github-pages` capability row.
|
|
6
|
+
|
|
7
|
+
## What it does
|
|
8
|
+
|
|
9
|
+
1. **stage** builds one deterministic gzip/POSIX.1-1988 ustar carrier from the
|
|
10
|
+
frozen artifact plus the reserved public generation marker, and hands it to
|
|
11
|
+
the caller-supplied Actions-artifact publisher. Nothing public changes:
|
|
12
|
+
`staging: private` is literal.
|
|
13
|
+
2. **activate** re-reads the served generation, checks the mandatory activation
|
|
14
|
+
fence, re-derives the artifact digest from the carrier bytes that will
|
|
15
|
+
actually be deployed, verifies the caller-supplied Pages OIDC token's
|
|
16
|
+
bindings, creates exactly one Pages deployment through the raw REST API with
|
|
17
|
+
the caller-supplied installation token, and polls the deployment API to a
|
|
18
|
+
terminal status. In `pages-reconciliation-recovery` mode it first resolves
|
|
19
|
+
the prior attempt (DEC-097 section 6.2) before any current create.
|
|
20
|
+
3. **observe** verifies the result through credential-free public reads of the
|
|
21
|
+
activated origin.
|
|
22
|
+
4. **rollback** is `reupload`: a fresh carrier for the selected historical
|
|
23
|
+
content under a _new_ generation identity.
|
|
24
|
+
|
|
25
|
+
## What it deliberately does not do
|
|
26
|
+
|
|
27
|
+
DEC-097 section 6.2 closes each of these, and the capability declaration states
|
|
28
|
+
them as the weakest true claim rather than hiding them:
|
|
29
|
+
|
|
30
|
+
- it never invokes the opaque `actions/deploy-pages` action;
|
|
31
|
+
- it never mutates a branch and never assumes a source commit — a branch-based
|
|
32
|
+
deployment would require `activation: branch-update`, which the closed
|
|
33
|
+
`github-pages` capability row forbids;
|
|
34
|
+
- it never mints, refreshes, logs or persists a token; the caller supplies the
|
|
35
|
+
installation token;
|
|
36
|
+
- it never uploads the Actions artifact itself: direct carrier upload is
|
|
37
|
+
workflow-owned (DEC-097 section 2.3), so the destination supplies a
|
|
38
|
+
`publishCarrier` callback;
|
|
39
|
+
- it never follows a provider-supplied `status_url`; that value is retained as
|
|
40
|
+
evidence and every poll uses an independently constructed suffix-free URL;
|
|
41
|
+
- it declares `concurrency: none`, because Pages offers no compare-and-set on
|
|
42
|
+
activation. `activate` still performs a read-then-compare against
|
|
43
|
+
`expectedCurrentGenerationId` immediately before the create call, but that is
|
|
44
|
+
honest best effort, not a provider fence;
|
|
45
|
+
- it never mints the Pages OIDC token and never verifies its issuer signature or
|
|
46
|
+
fetches a JWKS: the token is caller-supplied, the trust boundary is the
|
|
47
|
+
catalog-authorized runner token endpoint the workflow calls, and GitHub Pages
|
|
48
|
+
is the relying party that cryptographically validates the JWT;
|
|
49
|
+
- it never mints a `pagesReconciliationRecovery` record, a run-attempt gap proof
|
|
50
|
+
or a tombstone: it validates the server-minted record and refuses a malformed
|
|
51
|
+
one;
|
|
52
|
+
- it declares `providerInventoryAssurance: none` and never claims complete
|
|
53
|
+
deployed inventory; and
|
|
54
|
+
- it declares `cacheInvalidation: none` and has no purge authority.
|
|
55
|
+
|
|
56
|
+
## The activation fence (LOCAL-47)
|
|
57
|
+
|
|
58
|
+
`expectedCurrentGenerationId` is mandatory and is either a generation identity
|
|
59
|
+
or the explicit `EXPECT_NOTHING_SERVED` sentinel re-exported from this package.
|
|
60
|
+
`null` and `undefined` are refused with `EXPECTED_GENERATION_FENCE_INVALID`:
|
|
61
|
+
before adapter protocol `2.1.0` those spellings meant both "nothing is served"
|
|
62
|
+
and "do not fence me", and every adapter implemented the second reading, so a
|
|
63
|
+
first publish silently overwrote a live generation. Use `fenceFor(observed)` to
|
|
64
|
+
turn an observation into a fence.
|
|
65
|
+
|
|
66
|
+
## The nine-row request catalog
|
|
67
|
+
|
|
68
|
+
`src/request-catalog.js` declares exactly the nine DEC-097 section 7
|
|
69
|
+
`(stage, callClass)` rows — `inspect/pages-site`,
|
|
70
|
+
`activate/pages-create-deployment`, `activate/pages-deployment-status`,
|
|
71
|
+
`observe/pages-deployment-status`, `inspect/pages-recovery-prior-status`,
|
|
72
|
+
`cleanup-staged/pages-cancel-deployment`,
|
|
73
|
+
`cleanup-staged/pages-recovery-prior-cancel`, `rollback/pages-create-deployment`
|
|
74
|
+
and `rollback/pages-deployment-status` — sorted by member JCS bytes and digested
|
|
75
|
+
into `requestTemplateCatalogDigest`. Every row targets exactly
|
|
76
|
+
`https://api.github.com`, sends fixed `accept`, `accept-encoding: identity`,
|
|
77
|
+
`connection: close` and `x-github-api-version`, derives `host`, and carries one
|
|
78
|
+
`authorization` credential row with source `github-token` and prefix `Bearer `.
|
|
79
|
+
The two create rows add fixed `content-type: application/json`, derived
|
|
80
|
+
`content-length` and the `gala-pages-create-deployment-jcs-v2` body profile.
|
|
81
|
+
|
|
82
|
+
The `pagesDeploymentId` segment is chosen **statically by the call class**: the
|
|
83
|
+
seven ordinary/current rows take the intent's reserved 40-lowercase-hex
|
|
84
|
+
`pagesBuildVersion`, and the two `pages-recovery-prior-*` rows take
|
|
85
|
+
`pagesRecovery.priorPagesBuildVersion`. No provider response and no workflow
|
|
86
|
+
value can select it, and the two recovery-prior rows are refused outright in
|
|
87
|
+
`normal` mode.
|
|
88
|
+
|
|
89
|
+
Both facts are **declared**, not merely enforced: `CALL_CLASS_BINDING` is the
|
|
90
|
+
nine-row `limits.callClassBinding` block of the capability document
|
|
91
|
+
(`{stage, callClass, pagesDeploymentIdSource, recoveryOnly}`, JCS-sorted, schema
|
|
92
|
+
2.8.0 / LOCAL-52 (2)), bound by `limits.callClassBindingDigest` computed with
|
|
93
|
+
the schema package's own exported `providerCallClassBinding` profile
|
|
94
|
+
(`@rathnasgala2/schemas/digest-profiles`, 2.8.1) — the byte-identical
|
|
95
|
+
computation the contract validator checks, no longer a locally restated domain
|
|
96
|
+
string. It is deliberately not folded into `requestTemplateCatalogDigest`: the
|
|
97
|
+
template preimage is byte-identical to before the block was declared, and a test
|
|
98
|
+
pins that digest so a change to it is a contract change rather than a refactor.
|
|
99
|
+
`src/rest.js` resolves the source and the recovery-only rule from the declared
|
|
100
|
+
rows through `callClassIdBinding(stage, callClass)`.
|
|
101
|
+
|
|
102
|
+
## The create body and the two credentials
|
|
103
|
+
|
|
104
|
+
The create request entity is exactly the compact JCS of
|
|
105
|
+
`{artifact_id, oidc_token, pages_build_version}` — three members, no more and no
|
|
106
|
+
fewer, `artifact_id` a JSON integer in `1..9007199254740991`. `oidc_token` is
|
|
107
|
+
**mandatory**. The workflow's `deploy-github-pages` job acquires it from
|
|
108
|
+
`ACTIONS_ID_TOKEN_REQUEST_URL` (that is what its `id-token: write` is for) and
|
|
109
|
+
passes it in as `pagesOidcToken` (or `destination.oidcToken`) together with the
|
|
110
|
+
expected bindings as `pagesOidcClaims` (or `destination.oidcClaims`):
|
|
111
|
+
|
|
112
|
+
```js
|
|
113
|
+
await activate({
|
|
114
|
+
destination, // must also carry repositoryId and repositoryOwnerId
|
|
115
|
+
stageToken,
|
|
116
|
+
generationId,
|
|
117
|
+
expectedCurrentGenerationId: EXPECT_NOTHING_SERVED, // or a generation id
|
|
118
|
+
pagesOidcToken: process.env.PAGES_OIDC_TOKEN,
|
|
119
|
+
pagesOidcClaims: {
|
|
120
|
+
ref,
|
|
121
|
+
sha,
|
|
122
|
+
runId,
|
|
123
|
+
runAttempt,
|
|
124
|
+
jobWorkflowRef,
|
|
125
|
+
jobWorkflowSha,
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Before placing the JWT in the body — and only in the body — the adapter parses
|
|
131
|
+
its three compact segments, requires canonical unpadded base64url and
|
|
132
|
+
duplicate-key-free JSON header and payload, and checks issuer, audience
|
|
133
|
+
`https://github.com/<repository-owner>`, one of the two supported default
|
|
134
|
+
environment subject forms recomputed from the separately verified `repository`,
|
|
135
|
+
`repository_owner`, `repository_id` and `repository_owner_id` claims,
|
|
136
|
+
`environment: github-pages`, and the ref/SHA/run/`job_workflow_*` bindings the
|
|
137
|
+
caller supplies. The OIDC token never appears in a header, evidence, digest,
|
|
138
|
+
output, log or thrown message; the GitHub token never appears in the body. Both
|
|
139
|
+
directions are enforced by `src/redaction.js` and tested.
|
|
140
|
+
|
|
141
|
+
## Reconciliation recovery
|
|
142
|
+
|
|
143
|
+
`src/recovery.js` validates the server-minted `pagesReconciliationRecovery`
|
|
144
|
+
record (including its `recoveryDigest`, its `pagesRunAttemptGapProof` and every
|
|
145
|
+
`closed-no-destination-authority` tombstone digest) and then, before any current
|
|
146
|
+
carrier is created, polls the prior attempt's catalog-constructed status
|
|
147
|
+
endpoint using only `priorPagesBuildVersion`:
|
|
148
|
+
|
|
149
|
+
| prior observation | outcome |
|
|
150
|
+
| ------------------------------------- | ----------------------------------------------------------------- |
|
|
151
|
+
| terminal `succeed` | no new create; terminalize as `terminal-candidate` |
|
|
152
|
+
| terminal non-success | record the exact status; proceed with the fresh create |
|
|
153
|
+
| temporary status or 404 | exactly one cataloged cancel, then bounded polling |
|
|
154
|
+
| still-temporary/404/malformed/unknown | truthful evidence, no create, authority `reconciliation-required` |
|
|
155
|
+
|
|
156
|
+
`recoverPriorAttempt({destination, pagesRecovery})` exposes the same precheck
|
|
157
|
+
separately, so the deploy script can run it before `stage` uploads a carrier.
|
|
158
|
+
|
|
159
|
+
## The exact status vocabulary and poll schedule
|
|
160
|
+
|
|
161
|
+
The eleven accepted statuses, their temporary/terminal partition (with
|
|
162
|
+
`deployment_attempt_error` temporary, because GitHub retries it automatically)
|
|
163
|
+
and the exact `5, 8, 12, 18, 27, 30`-then-`30` poll schedule live in
|
|
164
|
+
`src/constants.js` and are asserted in `test/index.test.js`. An unknown,
|
|
165
|
+
malformed or ambiguous status can never release the destination fence.
|
|
166
|
+
|
|
167
|
+
## Destination shape
|
|
168
|
+
|
|
169
|
+
```js
|
|
170
|
+
{
|
|
171
|
+
(owner,
|
|
172
|
+
repository,
|
|
173
|
+
repositoryId,
|
|
174
|
+
repositoryOwnerId,
|
|
175
|
+
apiOrigin, // https origin; defaults to https://api.github.com
|
|
176
|
+
publicBaseUrl, // https origin of the activated Pages site
|
|
177
|
+
token, // caller-supplied installation token
|
|
178
|
+
oidcToken, // caller-supplied Pages OIDC JWT (or pass per-activate)
|
|
179
|
+
oidcClaims, // its expected ref/sha/run/job_workflow bindings
|
|
180
|
+
publishCarrier, // ({bytes, generationId, carrierDigest}) => {pagesArtifactId}
|
|
181
|
+
fetch,
|
|
182
|
+
publicFetch,
|
|
183
|
+
sleep,
|
|
184
|
+
runId,
|
|
185
|
+
runAttempt); // all optional injection points
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Evidence
|
|
190
|
+
|
|
191
|
+
`test/conformance.test.js` runs the full `@rathnasgala2/adapter-conformance-kit`
|
|
192
|
+
suite against a local fake provider that speaks real HTTP, genuinely gunzips and
|
|
193
|
+
untars the carrier this adapter produced, and serves the result from a separate
|
|
194
|
+
public origin. `test/carrier.test.js` holds the codec goldens. What none of that
|
|
195
|
+
can prove is the live GitHub Pages deployment API itself; that is backlog W4-16.
|
|
196
|
+
|
|
197
|
+
## Commands
|
|
198
|
+
|
|
199
|
+
```sh
|
|
200
|
+
npm run typecheck --workspace packages/adapter-github-pages
|
|
201
|
+
npm test --workspace packages/adapter-github-pages
|
|
202
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rathnasgala2/adapter-github-pages",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Managed GitHub Pages deployment adapter: deterministic gzip/ustar Pages carrier, raw Pages deployment REST catalog, bounded status polling and credential-free public verification.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": "24.18.0",
|
|
9
|
+
"npm": "11.16.0"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./src/index.d.ts",
|
|
14
|
+
"import": "./src/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./package.json": "./package.json"
|
|
17
|
+
},
|
|
18
|
+
"types": "./src/index.d.ts",
|
|
19
|
+
"files": [
|
|
20
|
+
"src/",
|
|
21
|
+
"README.md",
|
|
22
|
+
"CHANGELOG.md",
|
|
23
|
+
"LICENSE"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
27
|
+
"test": "node --test"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@rathnasgala2/adapter-protocol": "0.2.0",
|
|
34
|
+
"@rathnasgala2/schemas": "2.11.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@rathnasgala2/adapter-conformance-kit": "0.1.0"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The artifact-digest projection this adapter verifies against.
|
|
3
|
+
*
|
|
4
|
+
* DEC-097 section 8 fixes the projection as the UTF-8 path-sorted
|
|
5
|
+
* `{path, byteLength, sha256}` entry list under the `GALA-ARTIFACT-V2 `
|
|
6
|
+
* domain separator — the same projection `@rathnasgala2/template`'s
|
|
7
|
+
* manifest builder emits — so a digest this adapter recomputes from carrier
|
|
8
|
+
* bytes or from public HTTP reads is directly comparable to the frozen
|
|
9
|
+
* `artifact-manifest:2.0.0.artifactDigest` the workflow hands it.
|
|
10
|
+
*
|
|
11
|
+
* The reserved public-generation-marker coordinate is excluded: the marker
|
|
12
|
+
* is staged beside the frozen payload and is deliberately outside
|
|
13
|
+
* `artifactDigest` (brief section 5).
|
|
14
|
+
*
|
|
15
|
+
* @module
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { domainDigest, sha256Hex } from '@rathnasgala2/adapter-protocol';
|
|
19
|
+
|
|
20
|
+
import { DOMAIN_ARTIFACT, GENERATION_MARKER_PATH } from './constants.js';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @typedef {Readonly<{path: string, byteLength: string, sha256: string}>} ArtifactEntry
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Project one `{path, bytes}` pair onto its manifest entry.
|
|
28
|
+
*
|
|
29
|
+
* @param {string} entryPath the artifact-relative POSIX path
|
|
30
|
+
* @param {Buffer} bytes the file bytes
|
|
31
|
+
* @returns {ArtifactEntry} the projected entry
|
|
32
|
+
*/
|
|
33
|
+
export function projectEntry(entryPath, bytes) {
|
|
34
|
+
return Object.freeze({
|
|
35
|
+
path: entryPath,
|
|
36
|
+
byteLength: String(bytes.byteLength),
|
|
37
|
+
sha256: sha256Hex(bytes),
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Order a projected entry list by UTF-8 path.
|
|
43
|
+
*
|
|
44
|
+
* @param {readonly ArtifactEntry[]} entries the unordered entries
|
|
45
|
+
* @returns {ArtifactEntry[]} a new, path-ordered array
|
|
46
|
+
*/
|
|
47
|
+
export function orderEntries(entries) {
|
|
48
|
+
return [...entries].sort((left, right) =>
|
|
49
|
+
left.path < right.path ? -1 : left.path > right.path ? 1 : 0,
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Digest an already-projected, marker-excluding entry list.
|
|
55
|
+
*
|
|
56
|
+
* @param {readonly ArtifactEntry[]} entries the projected entries
|
|
57
|
+
* @returns {string} the `GALA-ARTIFACT-V2 ` artifact digest
|
|
58
|
+
*/
|
|
59
|
+
export function digestEntries(entries) {
|
|
60
|
+
return domainDigest(DOMAIN_ARTIFACT, orderEntries(entries));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Compute the artifact digest for a complete in-memory file set, excluding
|
|
65
|
+
* the reserved marker coordinate. Exported so a caller (the workflow's
|
|
66
|
+
* composition root, or a conformance fixture) can pass `stage` a truthful
|
|
67
|
+
* `artifactDigest` without restating the projection.
|
|
68
|
+
*
|
|
69
|
+
* @param {readonly Readonly<{path: string, bytes: Buffer}>[]} files the file set
|
|
70
|
+
* @returns {string} the artifact digest
|
|
71
|
+
*/
|
|
72
|
+
export function computeArtifactDigest(files) {
|
|
73
|
+
return digestEntries(
|
|
74
|
+
files
|
|
75
|
+
.filter((file) => file.path !== GENERATION_MARKER_PATH)
|
|
76
|
+
.map((file) => projectEntry(file.path, file.bytes)),
|
|
77
|
+
);
|
|
78
|
+
}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `describeCapabilities`: this adapter's exact `adapter-capability:2.0.0`
|
|
3
|
+
* declaration for the DEC-097 section 7 `github-pages` row, validated
|
|
4
|
+
* against the published schema and the protocol's exact-row table before it
|
|
5
|
+
* is ever returned.
|
|
6
|
+
*
|
|
7
|
+
* Nothing here is aspirational. `providerInventoryAssurance` is `none`
|
|
8
|
+
* because the Pages API never reports deployed inventory, `concurrency` is
|
|
9
|
+
* `none` because Pages offers no compare-and-set on activation, and
|
|
10
|
+
* `cacheInvalidation` is `none` because this adapter has no purge authority.
|
|
11
|
+
* The read-then-compare generation fence `activate` performs is a local,
|
|
12
|
+
* non-atomic best effort and is deliberately *not* declared as a provider
|
|
13
|
+
* concurrency guarantee.
|
|
14
|
+
*
|
|
15
|
+
* @module
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import {
|
|
19
|
+
ROLLBACK,
|
|
20
|
+
assertValidCapabilityDeclaration,
|
|
21
|
+
domainDigest,
|
|
22
|
+
getCapabilityRow,
|
|
23
|
+
} from '@rathnasgala2/adapter-protocol';
|
|
24
|
+
import { ACTIVE_DIGEST_PROFILES } from '@rathnasgala2/schemas/digest-profiles';
|
|
25
|
+
|
|
26
|
+
import {
|
|
27
|
+
ADAPTER_VERSION,
|
|
28
|
+
DOMAIN_ADAPTER_CAPABILITY,
|
|
29
|
+
DOMAIN_ADAPTER_IDENTITY,
|
|
30
|
+
DOMAIN_PAGES_COMPATIBILITY,
|
|
31
|
+
DOMAIN_PAGES_CREDENTIAL_EGRESS,
|
|
32
|
+
DOMAIN_PAGES_REQUEST_CATALOG,
|
|
33
|
+
DOMAIN_PAGES_RESPONSE_CATALOG,
|
|
34
|
+
DOMAIN_PAGES_TLS_PROFILE,
|
|
35
|
+
MAXIMUM_PAGES_CARRIER_BYTES,
|
|
36
|
+
PAGES_DEPLOYMENT_STATUSES,
|
|
37
|
+
POLL_SCHEDULE_SECONDS,
|
|
38
|
+
} from './constants.js';
|
|
39
|
+
import {
|
|
40
|
+
CALL_CLASS_BINDING,
|
|
41
|
+
REQUEST_TEMPLATE_PROFILE,
|
|
42
|
+
RESPONSE_PROFILES,
|
|
43
|
+
buildRequestTemplates,
|
|
44
|
+
} from './request-catalog.js';
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The schema package's own `providerCallClassBinding` digest profile
|
|
48
|
+
* (2.8.1). The inventory is typed as an open record, so the profile is
|
|
49
|
+
* required here once, by name, and its absence is a refusal rather than an
|
|
50
|
+
* `undefined` digest.
|
|
51
|
+
*/
|
|
52
|
+
export const CALL_CLASS_BINDING_PROFILE = (() => {
|
|
53
|
+
const profile = ACTIVE_DIGEST_PROFILES.providerCallClassBinding;
|
|
54
|
+
if (profile === undefined) {
|
|
55
|
+
throw new Error(
|
|
56
|
+
'PAGES_DIGEST_PROFILE_MISSING: @rathnasgala2/schemas/digest-profiles exports no providerCallClassBinding profile',
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
return profile;
|
|
60
|
+
})();
|
|
61
|
+
|
|
62
|
+
const ROW_OR_UNDEFINED = getCapabilityRow('github-pages');
|
|
63
|
+
if (ROW_OR_UNDEFINED === undefined) {
|
|
64
|
+
throw new Error(
|
|
65
|
+
'adapter-protocol does not declare a github-pages capability row',
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
/** The exact DEC-097 admission row for `github-pages`, never `undefined`. */
|
|
69
|
+
const ROW = /** @type {NonNullable<ReturnType<typeof getCapabilityRow>>} */ (
|
|
70
|
+
ROW_OR_UNDEFINED
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
/** This adapter's stable identity digest. */
|
|
74
|
+
export const ADAPTER_DIGEST = domainDigest(DOMAIN_ADAPTER_IDENTITY, {
|
|
75
|
+
name: '@rathnasgala2/adapter-github-pages',
|
|
76
|
+
version: ADAPTER_VERSION,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The exact TLS profile every provider call is made under. The adapter does
|
|
81
|
+
* not implement TLS itself (Node's `fetch` does); this record states the
|
|
82
|
+
* profile the adapter refuses to operate outside of, and is digested into
|
|
83
|
+
* the declaration so a reviewer can diff it.
|
|
84
|
+
*/
|
|
85
|
+
const TLS_PROFILE = Object.freeze({
|
|
86
|
+
profile: 'gala-pages-tls-v2',
|
|
87
|
+
minimumVersion: 'TLSv1.2',
|
|
88
|
+
requireCertificateVerification: true,
|
|
89
|
+
allowInsecureRedirects: false,
|
|
90
|
+
followRedirects: false,
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* The credential-egress profile: exactly one credential (a caller-supplied
|
|
95
|
+
* GitHub installation token) reaches exactly one header on exactly one
|
|
96
|
+
* origin. The adapter never mints, refreshes, logs or persists a token.
|
|
97
|
+
*/
|
|
98
|
+
const CREDENTIAL_EGRESS_PROFILE = Object.freeze({
|
|
99
|
+
profile: 'gala-pages-credential-egress-v2',
|
|
100
|
+
credentials: ['github-installation-token'],
|
|
101
|
+
mintsCredentials: false,
|
|
102
|
+
header: 'authorization',
|
|
103
|
+
permittedOriginCount: 1,
|
|
104
|
+
permittedPublicOriginCredentials: 0,
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Build and validate the declaration for one bound destination.
|
|
109
|
+
*
|
|
110
|
+
* @param {{apiOrigin: string, fileCountCeiling?: number}} context the
|
|
111
|
+
* canonical GitHub REST origin this adapter is bound to
|
|
112
|
+
* @returns {Readonly<Record<string, unknown>>} the validated declaration
|
|
113
|
+
*/
|
|
114
|
+
export function describeCapabilities(context) {
|
|
115
|
+
const requestTemplates = buildRequestTemplates(context.apiOrigin);
|
|
116
|
+
const compatibilityEvidence = {
|
|
117
|
+
profile: 'gala-pages-compatibility-evidence-v2',
|
|
118
|
+
acceptedDeploymentStatuses: [...PAGES_DEPLOYMENT_STATUSES],
|
|
119
|
+
pollScheduleSeconds: [...POLL_SCHEDULE_SECONDS],
|
|
120
|
+
usesOpaqueDeployPagesAction: false,
|
|
121
|
+
mutatesBranch: false,
|
|
122
|
+
followsCreateResponseStatusUrl: false,
|
|
123
|
+
claimsCompleteDeployedInventory: false,
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const declarationWithoutDigest = {
|
|
127
|
+
schemaId: 'urn:gala:schema:adapter-capability:2.0.0',
|
|
128
|
+
schemaVersion: '2.0.0',
|
|
129
|
+
adapter: {
|
|
130
|
+
adapterId: 'github-pages',
|
|
131
|
+
adapterVersion: ADAPTER_VERSION,
|
|
132
|
+
adapterDigest: ADAPTER_DIGEST,
|
|
133
|
+
},
|
|
134
|
+
contractVersion: '2.0.0',
|
|
135
|
+
protocolRange: '^2.0.0',
|
|
136
|
+
destinationKinds: ['github-pages'],
|
|
137
|
+
operations: [
|
|
138
|
+
'activate',
|
|
139
|
+
'cleanup-staged',
|
|
140
|
+
'inspect',
|
|
141
|
+
'observe',
|
|
142
|
+
'rollback',
|
|
143
|
+
'stage',
|
|
144
|
+
],
|
|
145
|
+
staging: ROW.staging,
|
|
146
|
+
activation: ROW.activation,
|
|
147
|
+
concurrency: ROW.concurrency,
|
|
148
|
+
idempotencyClass: ROW.idempotencyClass,
|
|
149
|
+
rollback: ROLLBACK,
|
|
150
|
+
verification: [...ROW.verification].sort(),
|
|
151
|
+
providerInventoryAssurance: ROW.providerInventoryAssurance,
|
|
152
|
+
configuration: {
|
|
153
|
+
redirects: false,
|
|
154
|
+
headers: false,
|
|
155
|
+
customDomains: false,
|
|
156
|
+
notFoundBehavior: ROW.notFoundBehavior,
|
|
157
|
+
immutableCaching: false,
|
|
158
|
+
},
|
|
159
|
+
cacheInvalidation: 'none',
|
|
160
|
+
limits: {
|
|
161
|
+
transport: 'http',
|
|
162
|
+
maximumFiles: '100000',
|
|
163
|
+
maximumFileBytes: '1073741824',
|
|
164
|
+
maximumArtifactBytes: '1073741824',
|
|
165
|
+
maximumProviderCallSeconds: 300,
|
|
166
|
+
maximumPathBytes: 255,
|
|
167
|
+
pathRuleProfile: 'gala-portable-v2',
|
|
168
|
+
requestTemplateProfile: REQUEST_TEMPLATE_PROFILE,
|
|
169
|
+
requestTemplateCatalogDigest: domainDigest(
|
|
170
|
+
DOMAIN_PAGES_REQUEST_CATALOG,
|
|
171
|
+
requestTemplates,
|
|
172
|
+
),
|
|
173
|
+
requestTemplates: [...requestTemplates],
|
|
174
|
+
// LOCAL-52 (2): the per-row `pagesDeploymentId` source and recovery-only
|
|
175
|
+
// flag, declared and bound by their own digest domain rather than folded
|
|
176
|
+
// into `requestTemplateCatalogDigest`, whose preimage is unchanged.
|
|
177
|
+
callClassBinding: [...CALL_CLASS_BINDING],
|
|
178
|
+
// Schema 2.8.1: the contract's own `providerCallClassBinding` profile,
|
|
179
|
+
// so the digest is the byte-identical result the validator checks
|
|
180
|
+
// rather than a locally re-derived domain string.
|
|
181
|
+
callClassBindingDigest: CALL_CLASS_BINDING_PROFILE.digest([
|
|
182
|
+
...CALL_CLASS_BINDING,
|
|
183
|
+
]),
|
|
184
|
+
responseProfileCatalogDigest: domainDigest(
|
|
185
|
+
DOMAIN_PAGES_RESPONSE_CATALOG,
|
|
186
|
+
[...RESPONSE_PROFILES],
|
|
187
|
+
),
|
|
188
|
+
providerCompatibilityEvidenceDigest: domainDigest(
|
|
189
|
+
DOMAIN_PAGES_COMPATIBILITY,
|
|
190
|
+
compatibilityEvidence,
|
|
191
|
+
),
|
|
192
|
+
tlsProfileDigest: domainDigest(DOMAIN_PAGES_TLS_PROFILE, TLS_PROFILE),
|
|
193
|
+
credentialEgressProfileDigest: domainDigest(
|
|
194
|
+
DOMAIN_PAGES_CREDENTIAL_EGRESS,
|
|
195
|
+
CREDENTIAL_EGRESS_PROFILE,
|
|
196
|
+
),
|
|
197
|
+
managedExecutionBudget: {
|
|
198
|
+
verifiedHandoffSeconds: 120,
|
|
199
|
+
pagesCarrierConstructionSeconds: 300,
|
|
200
|
+
pagesArtifactUploadSeconds: 600,
|
|
201
|
+
pagesArtifactVerificationSeconds: 120,
|
|
202
|
+
providerExecutionSeconds: 1500,
|
|
203
|
+
journalHandoffSeconds: 120,
|
|
204
|
+
totalSeconds: 1500,
|
|
205
|
+
},
|
|
206
|
+
pagesArtifactProfile: 'gala-pages-artifact-v2',
|
|
207
|
+
maximumPagesArtifactBytes: String(MAXIMUM_PAGES_CARRIER_BYTES),
|
|
208
|
+
maximumProviderRequestsPerStage: 128,
|
|
209
|
+
maximumProviderStageRequestBytes: '1073741824',
|
|
210
|
+
maximumProviderStageResponseBytes: '1048576',
|
|
211
|
+
maximumProviderStageResponseWireBytes: '1048576',
|
|
212
|
+
maximumProviderRequestHeadBytes: 16384,
|
|
213
|
+
maximumProviderRequestBodyBytes: '1048576',
|
|
214
|
+
maximumProviderResponseHeadBytes: 32768,
|
|
215
|
+
maximumProviderResponseBodyBytes: '1048576',
|
|
216
|
+
maximumProviderResponseWireBodyBytes: '1048576',
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
const declaration = Object.freeze({
|
|
221
|
+
...declarationWithoutDigest,
|
|
222
|
+
capabilityDigest: domainDigest(
|
|
223
|
+
DOMAIN_ADAPTER_CAPABILITY,
|
|
224
|
+
declarationWithoutDigest,
|
|
225
|
+
),
|
|
226
|
+
});
|
|
227
|
+
assertValidCapabilityDeclaration(declaration);
|
|
228
|
+
return declaration;
|
|
229
|
+
}
|