@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.
package/src/carrier.js CHANGED
@@ -1,6 +1,7 @@
1
1
  /**
2
- * The deterministic Pages carrier codec (slice brief section 2.3: "its
3
- * deterministic one-member gzip/POSIX.1-1988 ustar bytes"). The carrier is
2
+ * The deterministic Pages carrier codec (slice brief section 2.3, as
3
+ * amended by a measurement: the bytes are an UNCOMPRESSED POSIX.1-1988 ustar
4
+ * tar). The carrier is
4
5
  * the *only* thing this adapter ever hands the provider, and it is
5
6
  * byte-deterministic for a given file set: identical inputs always produce
6
7
  * identical carrier bytes, so a lost create response can be recovered
@@ -8,19 +9,36 @@
8
9
  *
9
10
  * Determinism comes from fixing every field a tar writer would normally
10
11
  * take from the ambient environment: modification time `0`, owner/group id
11
- * `0`, empty owner/group names, a fixed file mode, no PAX or GNU extension
12
- * records, entries emitted in ascending UTF-8 path order, and a gzip member
13
- * written with a zeroed MTIME/OS byte.
12
+ * `0`, owner/group names fixed to `root`, a fixed file mode, no PAX or GNU
13
+ * extension records, and entries emitted in one deterministic order (below).
14
+ *
15
+ * Entry order: every entry, directory or file, is sorted by its full path
16
+ * string (directories carry their trailing `/`) in ascending code-unit order,
17
+ * so a directory entry always precedes everything inside it. The order is
18
+ * independent of the input order.
19
+ *
20
+ * Measured on GitHub Pages (actions/deploy-pages as oracle, same site files):
21
+ * a tar holding only file entries with EMPTY uname/gname is refused
22
+ * ("Deployment failed"); the same files with a directory entry (typeflag `5`,
23
+ * mode 0755) for every parent directory AND uname/gname `root` deploy. Which
24
+ * of the two matters is not yet separated, so both are emitted; both are
25
+ * harmless to an extractor.
26
+ *
27
+ * Measured on GitHub (actions/deploy-pages as oracle): Pages processes a
28
+ * deployment only when the artifact is a standard Actions artifact (the zip
29
+ * wrapper upload-artifact adds by default) whose single member is an
30
+ * uncompressed tar of the site. A gzip-compressed tar fails ("Deployment
31
+ * failed"), so this codec never compresses.
14
32
  *
15
33
  * @module
16
34
  */
17
35
 
18
- import { gunzipSync, gzipSync } from 'node:zlib';
19
-
20
36
  const BLOCK_BYTES = 512;
21
37
  const NAME_FIELD_BYTES = 100;
22
38
  const PREFIX_FIELD_BYTES = 155;
23
39
  const FILE_MODE = '0000644';
40
+ const DIRECTORY_MODE = '0000755';
41
+ const OWNER_NAME = 'root';
24
42
  const USTAR_MAGIC = 'ustar\0' + '00';
25
43
 
26
44
  /**
@@ -81,9 +99,9 @@ export function splitUstarPath(entryPath) {
81
99
  *
82
100
  * The carrier is extracted by the provider, not by this process, so the
83
101
  * only place an escaping member can be stopped is here, at the point it is
84
- * written. Only regular-file entries are ever emitted (typeflag `0`): this
85
- * codec has no link, device or directory entry, so a symlink/hardlink
86
- * member cannot exist to be followed.
102
+ * written. Only regular-file (typeflag `0`) and directory (typeflag `5`)
103
+ * entries are ever emitted: this codec has no link or device entry, so a
104
+ * symlink/hardlink member cannot exist to be followed.
87
105
  *
88
106
  * @param {string} entryPath the artifact-relative POSIX path
89
107
  * @returns {string} the accepted path
@@ -107,25 +125,30 @@ export function requireContainedPath(entryPath) {
107
125
  }
108
126
 
109
127
  /**
110
- * Build one 512-byte ustar header block for a regular file.
128
+ * Build one 512-byte ustar header block for a regular file or a directory.
111
129
  *
112
- * @param {string} entryPath the artifact-relative POSIX path
113
- * @param {number} byteLength the member's byte length
130
+ * @param {string} entryPath the artifact-relative POSIX path; a directory
131
+ * carries a trailing `/`
132
+ * @param {number} byteLength the member's byte length (`0` for a directory)
133
+ * @param {boolean} isDirectory whether this is a directory entry
114
134
  * @returns {Buffer} the header block, with its checksum applied
115
135
  */
116
- function buildHeaderBlock(entryPath, byteLength) {
136
+ function buildHeaderBlock(entryPath, byteLength, isDirectory) {
117
137
  const block = Buffer.alloc(BLOCK_BYTES);
118
- const { name, prefix } = splitUstarPath(requireContainedPath(entryPath));
138
+ requireContainedPath(isDirectory ? entryPath.slice(0, -1) : entryPath);
139
+ const { name, prefix } = splitUstarPath(entryPath);
119
140
 
120
141
  writeField(block, 0, NAME_FIELD_BYTES, name);
121
- writeField(block, 100, 8, FILE_MODE);
142
+ writeField(block, 100, 8, isDirectory ? DIRECTORY_MODE : FILE_MODE);
122
143
  writeField(block, 108, 8, '0000000');
123
144
  writeField(block, 116, 8, '0000000');
124
145
  writeField(block, 124, 12, byteLength.toString(8).padStart(11, '0'));
125
146
  writeField(block, 136, 12, '00000000000');
126
147
  block.fill(0x20, 148, 156);
127
- block.write('0', 156, 1, 'ascii');
148
+ block.write(isDirectory ? '5' : '0', 156, 1, 'ascii');
128
149
  writeField(block, 257, 8, USTAR_MAGIC);
150
+ writeField(block, 265, 32, OWNER_NAME);
151
+ writeField(block, 297, 32, OWNER_NAME);
129
152
  writeField(block, 345, PREFIX_FIELD_BYTES, prefix);
130
153
 
131
154
  let checksum = 0;
@@ -137,21 +160,39 @@ function buildHeaderBlock(entryPath, byteLength) {
137
160
  }
138
161
 
139
162
  /**
140
- * Encode a complete file set as deterministic one-member gzip/ustar carrier
141
- * bytes.
163
+ * Encode a complete file set as deterministic uncompressed ustar
164
+ * carrier bytes (never gzip; see the module comment).
142
165
  *
143
166
  * @param {readonly CarrierFile[]} files the complete artifact file set,
144
167
  * including the reserved public generation marker
145
168
  * @returns {Buffer} the carrier bytes
146
169
  */
147
170
  export function encodeCarrier(files) {
148
- const ordered = [...files].sort((left, right) =>
171
+ /** @type {Set<string>} */
172
+ const directories = new Set();
173
+ for (const file of files) {
174
+ const segments = file.path.split('/');
175
+ for (let depth = 1; depth < segments.length; depth += 1) {
176
+ directories.add(`${segments.slice(0, depth).join('/')}/`);
177
+ }
178
+ }
179
+ /** @type {{path: string, bytes: Buffer, isDirectory: boolean}[]} */
180
+ const ordered = [
181
+ ...[...directories].map((path) => ({
182
+ path,
183
+ bytes: Buffer.alloc(0),
184
+ isDirectory: true,
185
+ })),
186
+ ...files.map((file) => ({ ...file, isDirectory: false })),
187
+ ].sort((left, right) =>
149
188
  left.path < right.path ? -1 : left.path > right.path ? 1 : 0,
150
189
  );
151
190
  /** @type {Buffer[]} */
152
191
  const blocks = [];
153
192
  for (const file of ordered) {
154
- blocks.push(buildHeaderBlock(file.path, file.bytes.byteLength));
193
+ blocks.push(
194
+ buildHeaderBlock(file.path, file.bytes.byteLength, file.isDirectory),
195
+ );
155
196
  blocks.push(file.bytes);
156
197
  const remainder = file.bytes.byteLength % BLOCK_BYTES;
157
198
  if (remainder !== 0) {
@@ -160,12 +201,7 @@ export function encodeCarrier(files) {
160
201
  }
161
202
  blocks.push(Buffer.alloc(BLOCK_BYTES * 2));
162
203
 
163
- const gzipped = gzipSync(Buffer.concat(blocks), { level: 9 });
164
- // Zero the gzip header's MTIME (bytes 4..7) and OS (byte 9) fields, the
165
- // only two places zlib is permitted to record ambient facts.
166
- gzipped.writeUInt32LE(0, 4);
167
- gzipped.writeUInt8(0xff, 9);
168
- return gzipped;
204
+ return Buffer.concat(blocks);
169
205
  }
170
206
 
171
207
  /**
@@ -175,10 +211,16 @@ export function encodeCarrier(files) {
175
211
  * codec golden test — can prove the round trip is lossless.
176
212
  *
177
213
  * @param {Buffer} carrier the carrier bytes
178
- * @returns {CarrierFile[]} the decoded file set, in carrier order
214
+ * @returns {CarrierFile[]} the decoded file set, in carrier order; directory
215
+ * entries (typeflag `5`) are skipped
179
216
  */
180
217
  export function decodeCarrier(carrier) {
181
- const tar = gunzipSync(carrier);
218
+ if (carrier.byteLength >= 2 && carrier[0] === 0x1f && carrier[1] === 0x8b) {
219
+ throw new RangeError(
220
+ 'PAGES_CARRIER_GZIP_REFUSED: the Pages carrier must be an uncompressed ustar tar; GitHub Pages fails a gzip-compressed artifact',
221
+ );
222
+ }
223
+ const tar = carrier;
182
224
  /** @type {CarrierFile[]} */
183
225
  const files = [];
184
226
  let offset = 0;
@@ -194,10 +236,12 @@ export function decodeCarrier(carrier) {
194
236
  8,
195
237
  );
196
238
  offset += BLOCK_BYTES;
197
- files.push({
198
- path: prefix === '' ? name : `${prefix}/${name}`,
199
- bytes: Buffer.from(tar.subarray(offset, offset + size)),
200
- });
239
+ if (String.fromCharCode(Number(header[156])) !== '5') {
240
+ files.push({
241
+ path: prefix === '' ? name : `${prefix}/${name}`,
242
+ bytes: Buffer.from(tar.subarray(offset, offset + size)),
243
+ });
244
+ }
201
245
  offset += Math.ceil(size / BLOCK_BYTES) * BLOCK_BYTES;
202
246
  }
203
247
  return files;
package/src/constants.js CHANGED
@@ -32,11 +32,13 @@ export const ADAPTER_VERSION = /** @type {string} */ (
32
32
  export const GENERATION_MARKER_PATH = '.well-known/gala-generation.json';
33
33
 
34
34
  /**
35
- * The exact eleven accepted `GET /repos/{owner}/{repo}/pages/deployments/{id}`
36
- * status values (brief section 6.2). Anything else is unknown and can never
37
- * release the destination fence.
35
+ * The exact twelve accepted `GET /repos/{owner}/{repo}/pages/deployments/{id}`
36
+ * status values (brief section 6.2, plus `deployment_queued`, which GitHub's
37
+ * REST reference lists and a real run returned on 2026-10-06). Anything else
38
+ * is unknown and can never release the destination fence.
38
39
  */
39
40
  export const PAGES_DEPLOYMENT_STATUSES = Object.freeze([
41
+ 'deployment_queued',
40
42
  'deployment_in_progress',
41
43
  'syncing_files',
42
44
  'finished_file_sync',
@@ -52,10 +54,12 @@ export const PAGES_DEPLOYMENT_STATUSES = Object.freeze([
52
54
 
53
55
  /**
54
56
  * Temporary statuses: polling continues and the fence stays held.
57
+ * `deployment_queued` is the state before `deployment_in_progress`, and
55
58
  * `deployment_attempt_error` is temporary because GitHub retries it
56
59
  * automatically (brief section 6.2).
57
60
  */
58
61
  export const TEMPORARY_STATUSES = Object.freeze([
62
+ 'deployment_queued',
59
63
  'deployment_in_progress',
60
64
  'syncing_files',
61
65
  'finished_file_sync',
package/src/deployment.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * The Pages deployment call sequence: the `pagesBuildVersion` projection,
3
3
  * the exact `gala-pages-create-deployment-jcs-v2` request entity, the single
4
- * create call, and the bounded poll loop over the exact eleven accepted
4
+ * create call, and the bounded poll loop over the exact twelve accepted
5
5
  * statuses (DEC-097 sections 6.2 and 7).
6
6
  *
7
7
  * The create body is the one place either credential is allowed to meet the
@@ -13,10 +13,10 @@
13
13
  * @module
14
14
  */
15
15
 
16
- import { canonicalizeJson, domainDigest } from '@rathnasgala2/adapter-protocol';
16
+ import { PagesAdapterError } from './errors.js';
17
+ import { canonicalizeJson } from '@rathnasgala2/adapter-protocol';
17
18
 
18
19
  import {
19
- DOMAIN_PAGES_BUILD_VERSION,
20
20
  POLL_BUDGET_SECONDS,
21
21
  POLL_SCHEDULE_SECONDS,
22
22
  POLL_TAIL_SECONDS,
@@ -43,36 +43,24 @@ export const MAXIMUM_ARTIFACT_ID = 9007199254740991;
43
43
  const BUILD_VERSION_PATTERN = /^[0-9a-f]{40}$/u;
44
44
 
45
45
  /**
46
- * Derive the `pagesBuildVersion`: the first 40 lowercase hex characters of
47
- * the domain-separated repository/operation/attempt/run/artifact/generation
48
- * projection (DEC-097 section 6.2). `pagesDeploymentId` must equal it
49
- * exactly.
46
+ * The `pagesBuildVersion`: the workflow run's head commit SHA (`GITHUB_SHA`,
47
+ * the OIDC `sha` claim). GitHub validates `pages_build_version` as a commit
48
+ * of the repository (measured on 2026-10-04: any other 40-hex value, such as
49
+ * a synthetic hash, answers 404), so a synthetic derivation can never deploy.
50
+ * `pagesDeploymentId` must equal it exactly.
50
51
  *
51
- * @param {{
52
- * destinationKey: string,
53
- * operationId: string,
54
- * attemptId: string,
55
- * runId?: string,
56
- * runAttempt?: number,
57
- * artifactId: string,
58
- * artifactDigest: string,
59
- * generationId: string
60
- * }} projection the closed projection inputs
52
+ * @param {{headSha?: string | undefined}} projection the run's head commit
61
53
  * @returns {string} the 40-character lowercase hexadecimal build version
62
54
  */
63
55
  export function derivePagesBuildVersion(projection) {
64
- return domainDigest(DOMAIN_PAGES_BUILD_VERSION, {
65
- destinationKey: projection.destinationKey,
66
- operationId: projection.operationId,
67
- attemptId: projection.attemptId,
68
- runId: projection.runId ?? null,
69
- runAttempt: projection.runAttempt ?? null,
70
- artifactId: projection.artifactId,
71
- artifactDigest: projection.artifactDigest,
72
- generationId: projection.generationId,
73
- })
74
- .slice('sha256:'.length)
75
- .slice(0, 40);
56
+ const value = projection.headSha;
57
+ if (typeof value !== 'string' || !BUILD_VERSION_PATTERN.test(value)) {
58
+ throw new PagesAdapterError(
59
+ 'PAGES_HEAD_SHA_INVALID',
60
+ 'the destination must carry the run head commit SHA (headSha) as exactly 40 lowercase hexadecimal characters',
61
+ );
62
+ }
63
+ return value;
76
64
  }
77
65
 
78
66
  /**
@@ -89,13 +77,15 @@ export function assertCanonicalCreateBody(bodyText) {
89
77
  try {
90
78
  parsed = JSON.parse(bodyText);
91
79
  } catch {
92
- throw new Error(
93
- 'PAGES_CREATE_BODY_NONCANONICAL: the create request entity is not JSON',
80
+ throw new PagesAdapterError(
81
+ 'PAGES_CREATE_BODY_NONCANONICAL',
82
+ 'the create request entity is not JSON',
94
83
  );
95
84
  }
96
85
  if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {
97
- throw new Error(
98
- 'PAGES_CREATE_BODY_NONCANONICAL: the create request entity is not a JSON object',
86
+ throw new PagesAdapterError(
87
+ 'PAGES_CREATE_BODY_NONCANONICAL',
88
+ 'the create request entity is not a JSON object',
99
89
  );
100
90
  }
101
91
  const keys = Object.keys(/** @type {Record<string, unknown>} */ (parsed));
@@ -103,13 +93,15 @@ export function assertCanonicalCreateBody(bodyText) {
103
93
  keys.length !== CREATE_BODY_MEMBERS.length ||
104
94
  !CREATE_BODY_MEMBERS.every((name, index) => keys[index] === name)
105
95
  ) {
106
- throw new Error(
107
- `PAGES_CREATE_BODY_NONCANONICAL: the create request entity must have exactly the three members ${CREATE_BODY_MEMBERS.join(', ')} in JCS order`,
96
+ throw new PagesAdapterError(
97
+ `PAGES_CREATE_BODY_NONCANONICAL`,
98
+ `the create request entity must have exactly the three members ${CREATE_BODY_MEMBERS.join(', ')} in JCS order`,
108
99
  );
109
100
  }
110
101
  if (canonicalizeJson(parsed) !== bodyText) {
111
- throw new Error(
112
- 'PAGES_CREATE_BODY_NONCANONICAL: the create request entity is not compact RFC 8785 JCS',
102
+ throw new PagesAdapterError(
103
+ 'PAGES_CREATE_BODY_NONCANONICAL',
104
+ 'the create request entity is not compact RFC 8785 JCS',
113
105
  );
114
106
  }
115
107
  }
@@ -134,18 +126,21 @@ export function buildCreateDeploymentBody(input) {
134
126
  artifactId > MAXIMUM_ARTIFACT_ID ||
135
127
  String(artifactId) !== String(input.pagesArtifactId)
136
128
  ) {
137
- throw new Error(
138
- `PAGES_ARTIFACT_ID_INVALID: ${JSON.stringify(String(input.pagesArtifactId))} is not a JSON integer in 1..${MAXIMUM_ARTIFACT_ID}; a string artifact id, a non-integer and an unsafe integer are all refused`,
129
+ throw new PagesAdapterError(
130
+ `PAGES_ARTIFACT_ID_INVALID`,
131
+ `${JSON.stringify(String(input.pagesArtifactId))} is not a JSON integer in 1..${MAXIMUM_ARTIFACT_ID}; a string artifact id, a non-integer and an unsafe integer are all refused`,
139
132
  );
140
133
  }
141
134
  if (!BUILD_VERSION_PATTERN.test(input.pagesBuildVersion)) {
142
- throw new Error(
143
- 'PAGES_BUILD_VERSION_INVALID: pages_build_version must be exactly 40 lowercase hexadecimal characters',
135
+ throw new PagesAdapterError(
136
+ 'PAGES_BUILD_VERSION_INVALID',
137
+ 'pages_build_version must be exactly 40 lowercase hexadecimal characters',
144
138
  );
145
139
  }
146
140
  if (typeof input.oidcToken !== 'string' || input.oidcToken === '') {
147
- throw new Error(
148
- 'PAGES_OIDC_TOKEN_REQUIRED: oidc_token is a mandatory member of the create request entity',
141
+ throw new PagesAdapterError(
142
+ 'PAGES_OIDC_TOKEN_REQUIRED',
143
+ 'oidc_token is a mandatory member of the create request entity',
149
144
  );
150
145
  }
151
146
  const bodyText = canonicalizeJson({
@@ -155,8 +150,9 @@ export function buildCreateDeploymentBody(input) {
155
150
  });
156
151
  assertCanonicalCreateBody(bodyText);
157
152
  if (bodyText.includes(input.githubToken)) {
158
- throw new Error(
159
- 'PAGES_SECRET_LEAK_DETECTED: the GitHub token reached the create request body; DEC-097 section 7 forbids it',
153
+ throw new PagesAdapterError(
154
+ 'PAGES_SECRET_LEAK_DETECTED',
155
+ 'the GitHub token reached the create request body; DEC-097 section 7 forbids it',
160
156
  );
161
157
  }
162
158
  return Object.freeze({
@@ -211,8 +207,9 @@ export async function createDeployment(context, input) {
211
207
  const parsed = /** @type {Record<string, unknown>} */ (response.body ?? {});
212
208
  const observedId = parsed.id === undefined ? undefined : String(parsed.id);
213
209
  if (observedId !== input.pagesBuildVersion) {
214
- throw new Error(
215
- `PAGES_DEPLOYMENT_ID_MISMATCH: provider returned deployment id ${JSON.stringify(observedId)} for requested pages_build_version ${JSON.stringify(input.pagesBuildVersion)}`,
210
+ throw new PagesAdapterError(
211
+ `PAGES_DEPLOYMENT_ID_MISMATCH`,
212
+ `provider returned deployment id ${JSON.stringify(observedId)} for requested pages_build_version ${JSON.stringify(input.pagesBuildVersion)}`,
216
213
  );
217
214
  }
218
215
 
@@ -223,8 +220,9 @@ export async function createDeployment(context, input) {
223
220
  : undefined;
224
221
  const pollUrl = buildPollUrl(context, input.pagesBuildVersion);
225
222
  if (observedStatusUrl === pollUrl) {
226
- throw new Error(
227
- 'PAGES_STATUS_URL_EQUALS_POLL_URL: DEC-097 section 7 forbids equality between the create response status_url and the independently constructed poll URL',
223
+ throw new PagesAdapterError(
224
+ 'PAGES_STATUS_URL_EQUALS_POLL_URL',
225
+ 'DEC-097 section 7 forbids equality between the create response status_url and the independently constructed poll URL',
228
226
  );
229
227
  }
230
228
 
@@ -294,8 +292,9 @@ export async function pollDeployment(context, pagesDeploymentId, options) {
294
292
  observedStatuses.push(status);
295
293
 
296
294
  if (!PAGES_DEPLOYMENT_STATUSES.includes(status)) {
297
- throw new Error(
298
- `PAGES_DEPLOYMENT_STATUS_UNKNOWN: ${JSON.stringify(status)} is outside the eleven accepted statuses; the destination fence stays held`,
295
+ throw new PagesAdapterError(
296
+ `PAGES_DEPLOYMENT_STATUS_UNKNOWN`,
297
+ `${JSON.stringify(status)} is outside the twelve accepted statuses; the destination fence stays held`,
299
298
  );
300
299
  }
301
300
  if (status === SUCCESS_STATUS) {
@@ -305,15 +304,17 @@ export async function pollDeployment(context, pagesDeploymentId, options) {
305
304
  return { status, succeeded: false, observedStatuses, waitedSeconds };
306
305
  }
307
306
  if (!TEMPORARY_STATUSES.includes(status)) {
308
- throw new Error(
309
- `PAGES_DEPLOYMENT_STATUS_UNPARTITIONED: ${JSON.stringify(status)} is neither temporary nor terminal`,
307
+ throw new PagesAdapterError(
308
+ `PAGES_DEPLOYMENT_STATUS_UNPARTITIONED`,
309
+ `${JSON.stringify(status)} is neither temporary nor terminal`,
310
310
  );
311
311
  }
312
312
 
313
313
  const wait = POLL_SCHEDULE_SECONDS[attempt] ?? POLL_TAIL_SECONDS;
314
314
  if (spent + wait > budget) {
315
- throw new Error(
316
- `PAGES_DEPLOYMENT_POLL_BUDGET_EXHAUSTED: ${pagesDeploymentId} was still ${status} after ${spent} seconds; the outcome is ambiguous and the destination fence stays held`,
315
+ throw new PagesAdapterError(
316
+ `PAGES_DEPLOYMENT_POLL_BUDGET_EXHAUSTED`,
317
+ `${pagesDeploymentId} was still ${status} after ${spent} seconds; the outcome is ambiguous and the destination fence stays held`,
317
318
  );
318
319
  }
319
320
  spent += wait;
@@ -328,6 +329,10 @@ export async function pollDeployment(context, pagesDeploymentId, options) {
328
329
  */
329
330
  function defaultSleep(seconds) {
330
331
  return new Promise((resolve) => {
331
- setTimeout(resolve, seconds * 1000).unref();
332
+ // Referenced on purpose: an unreferenced timer let the event loop drain while
333
+ // the only pending work was this sleep, and Node exited with code 13
334
+ // ("unsettled top-level await") mid-poll on a real run. The poll budget
335
+ // bounds the wait; nothing else keeps the process alive during it.
336
+ setTimeout(resolve, seconds * 1000);
332
337
  });
333
338
  }
package/src/errors.js ADDED
@@ -0,0 +1,32 @@
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
+ /**
18
+ * A typed failure this adapter raises, carrying a stable `code`
19
+ * alongside the ordinary `Error` message.
20
+ */
21
+ export class PagesAdapterError extends Error {
22
+ /**
23
+ * @param {string} code stable, machine-readable failure code
24
+ * @param {string} detail human-readable detail (never a token byte)
25
+ */
26
+ constructor(code, detail) {
27
+ super(`${code}: ${detail}`);
28
+ this.name = 'PagesAdapterError';
29
+ /** @type {string} */
30
+ this.code = code;
31
+ }
32
+ }