@coffre/conformance 0.10.1 → 0.11.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.
@@ -246,8 +246,9 @@ function randomToken() {
246
246
  return randomBytes(32).toString("base64url");
247
247
  }
248
248
  /**
249
- * The built-in client accepts any loopback URI, because local dev ports vary;
250
- * every other redirect URI must match a registered one exactly.
249
+ * The built-in client accepts any loopback URI, because local dev ports vary,
250
+ * and any URI under an origin it was given (a tunnel to the app); every other
251
+ * redirect URI must match a registered one exactly.
251
252
  */
252
253
  function allowsRedirect(client, uri) {
253
254
  if (client.redirectUris.includes(uri)) return true;
@@ -258,7 +259,8 @@ function allowsRedirect(client, uri) {
258
259
  } catch {
259
260
  return false;
260
261
  }
261
- return url.protocol === "http:" && (url.hostname === "127.0.0.1" || url.hostname === "localhost") && url.username === "" && url.password === "" && !uri.includes("#");
262
+ if (url.username !== "" || url.password !== "" || uri.includes("#")) return false;
263
+ return url.protocol === "http:" && (url.hostname === "127.0.0.1" || url.hostname === "localhost") || client.redirectOrigins.includes(url.origin);
262
264
  }
263
265
  /** RFC 7636 §4.6, S256 only. */
264
266
  function verifies(verifier, challenge) {
@@ -1391,6 +1393,7 @@ const DEFAULT_CLIENT = Object.freeze({
1391
1393
  var DevIdp = class {
1392
1394
  #server = null;
1393
1395
  #port = 0;
1396
+ #publicOrigin;
1394
1397
  #clients = /* @__PURE__ */ new Map();
1395
1398
  #subjects = /* @__PURE__ */ new Map();
1396
1399
  #gitHubAccounts = /* @__PURE__ */ new Map();
@@ -1410,18 +1413,22 @@ var DevIdp = class {
1410
1413
  githubApp;
1411
1414
  constructor(options = {}) {
1412
1415
  this.autoApprove = options.autoApprove ?? false;
1416
+ this.#publicOrigin = options.publicOrigin === void 0 ? void 0 : new URL(options.publicOrigin).origin;
1417
+ const redirectOrigins = (options.redirectOrigins ?? []).map((each) => new URL(each).origin);
1413
1418
  this.githubApp = new FakeGitHubApp(() => this.origin, options.githubAppKey);
1414
1419
  this.#clients.set(DEFAULT_CLIENT.clientId, {
1415
1420
  ...DEFAULT_CLIENT,
1416
1421
  redirectUris: [],
1417
- anyLoopbackRedirect: true
1422
+ anyLoopbackRedirect: true,
1423
+ redirectOrigins
1418
1424
  });
1419
1425
  for (const client of options.clients ?? []) this.registerClient(client);
1420
1426
  this.#clients.set(this.githubApp.clientId, {
1421
1427
  clientId: this.githubApp.clientId,
1422
1428
  clientSecret: this.githubApp.clientSecret,
1423
1429
  redirectUris: [],
1424
- anyLoopbackRedirect: true
1430
+ anyLoopbackRedirect: true,
1431
+ redirectOrigins
1425
1432
  });
1426
1433
  const authz = new AuthorizationServer(this);
1427
1434
  this.#routes = [
@@ -1433,7 +1440,7 @@ var DevIdp = class {
1433
1440
  }
1434
1441
  get origin() {
1435
1442
  if (this.#port === 0) throw new Error("DevIdp is not started");
1436
- return `http://127.0.0.1:${this.#port}`;
1443
+ return this.#publicOrigin ?? `http://127.0.0.1:${this.#port}`;
1437
1444
  }
1438
1445
  /** Matches the Cloudflare Access team-domain issuer shape. */
1439
1446
  get issuer() {
@@ -1503,7 +1510,8 @@ var DevIdp = class {
1503
1510
  clientId: client.clientId,
1504
1511
  clientSecret: client.clientSecret,
1505
1512
  redirectUris: [...client.redirectUris],
1506
- anyLoopbackRedirect: false
1513
+ anyLoopbackRedirect: false,
1514
+ redirectOrigins: []
1507
1515
  });
1508
1516
  }
1509
1517
  client(clientId) {
package/dist/idp.d.ts CHANGED
@@ -182,6 +182,8 @@ interface DevIdpClient {
182
182
  interface RegisteredClient extends DevIdpClient {
183
183
  /** Accept any http://127.0.0.1 or http://localhost redirect URI, on any port. */
184
184
  anyLoopbackRedirect: boolean;
185
+ /** Also accept redirect URIs under these origins (a tunnel to the app). Only for the built-in clients. */
186
+ redirectOrigins: readonly string[];
185
187
  }
186
188
  interface DevIdpOptions {
187
189
  /** Registered alongside the built-in `coffre-local` client. */
@@ -190,6 +192,14 @@ interface DevIdpOptions {
190
192
  autoApprove?: boolean;
191
193
  /** The fake GitHub App's private key, PKCS #1 PEM: made at start unless given. */
192
194
  githubAppKey?: string;
195
+ /**
196
+ * The origin a browser reaches this server at, when that is not its loopback
197
+ * address (a tunnel to it): the issuer, and every URL it publishes, name it.
198
+ * It still listens on loopback only.
199
+ */
200
+ publicOrigin?: string;
201
+ /** Origins besides loopback that the built-in clients may redirect to: the app's, behind the same tunnel. */
202
+ redirectOrigins?: readonly string[];
193
203
  }
194
204
  /** Built in, so local dev needs no registration step. */
195
205
  export declare const DEFAULT_CLIENT: Readonly<{
package/dist/idp.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as FakeGitHubApp, i as WorkloadIssuer, n as DevIdp, o as fakeInstallations, r as GITHUB_RUN, s as PERSONAS, t as DEFAULT_CLIENT } from "./idp-B8u4UPA4.js";
1
+ import { a as FakeGitHubApp, i as WorkloadIssuer, n as DevIdp, o as fakeInstallations, r as GITHUB_RUN, s as PERSONAS, t as DEFAULT_CLIENT } from "./idp-B9CQgH3O.js";
2
2
  export { DEFAULT_CLIENT, DevIdp, FakeGitHubApp, GITHUB_RUN, PERSONAS, WorkloadIssuer, fakeInstallations };
package/dist/main.js CHANGED
@@ -1,4 +1,4 @@
1
- import { c as defaultGitHubAccount, n as DevIdp, r as GITHUB_RUN } from "./idp-B8u4UPA4.js";
1
+ import { c as defaultGitHubAccount, n as DevIdp, r as GITHUB_RUN } from "./idp-B9CQgH3O.js";
2
2
  import { createRequire } from "node:module";
3
3
  import { delimiter, dirname, join, relative, resolve } from "node:path";
4
4
  import { inspect, parseArgs } from "node:util";
@@ -64,6 +64,7 @@ const KEYS = {
64
64
  function drainingConfig(server) {
65
65
  writeFileSync(join(server, "conformance.js"), [
66
66
  "import app from './index.js';",
67
+ "export * from './index.js';",
67
68
  "export default {",
68
69
  " ...app,",
69
70
  " async fetch(request, env, ctx) {",
@@ -84,7 +85,7 @@ function drainingConfig(server) {
84
85
  }
85
86
  if (import.meta.main) console.log(drainingConfig(resolve(process.argv[2])));
86
87
  //#endregion
87
- //#region ../client/dist/index.js
88
+ //#region ../client/dist/src-CDyZe9vW.js
88
89
  /** Two colons or more, in hex: an IPv6 address, as `::1` or `2001:db8::1:443` with its port. */
89
90
  const IPV6 = /[0-9a-f]*:[0-9a-f]*:[0-9a-f:]*/i;
90
91
  const TIMEOUT_OR_REFUSAL = /* @__PURE__ */ new Set([
@@ -226,7 +227,7 @@ function createClient(options) {
226
227
  /**
227
228
  * Protected, a person holds their role's protected column there
228
229
  * (docs/design/roles.md); whoever manages the project's environments
229
- * protects one, and only an Owner of the whole instance unprotects it.
230
+ * protects one, and only an Owner of its project, or of the whole instance, unprotects it.
230
231
  */
231
232
  protect: (path, on = true) => call("PATCH /projects/:project/:environment", place(path), { protected: on }),
232
233
  /** What deleting an archived environment would erase and revoke; changes nothing. */
@@ -320,7 +321,11 @@ function createClient(options) {
320
321
  * values, which only the credential proxy (`/use`) takes. The value is
321
322
  * in the answer, and only there; it is revoked as a token is.
322
323
  */
323
- handles: { create: (input) => call("POST /handles", {}, input) },
324
+ handles: {
325
+ create: (input) => call("POST /handles", {}, input),
326
+ /** Ends a handle of the caller's own, as `coffre run` does once its command ends. */
327
+ revoke: (id) => call("DELETE /handles/:id", { id })
328
+ },
324
329
  /** Trust bindings: which CI runs may sign in as a service, by their platform's ID token. */
325
330
  bindings: {
326
331
  list: (member) => call("GET /members/:member/bindings", { member }),
@@ -2499,7 +2504,8 @@ async function checkpoints(deployment, { admin }) {
2499
2504
  }
2500
2505
  /**
2501
2506
  * Every version the app says it stored names the vault's entry for the key
2502
- * it was sealed with, `key.wrap` for a write and `key.rewrap` for a restore:
2507
+ * it was sealed with, `key.wrap` for a write and `key.rewrap` for a restore,
2508
+ * a mark and a loosening:
2503
2509
  * the same member, request and operation, the same secret and version. And
2504
2510
  * every value read is the vault's to log: the app keeps no reads of its own.
2505
2511
  */
@@ -2507,10 +2513,10 @@ async function writesAgree(deployment) {
2507
2513
  return using(deployment.database(), async (sql) => {
2508
2514
  const entries = await sql.query("SELECT * FROM audit_log ORDER BY seq");
2509
2515
  const bySeq = new Map(entries.map((entry) => [String(entry.seq), entry]));
2510
- const writes = entries.filter((entry) => entry.author === "app" && entry.decision === "allow" && (entry.action === "secret.write" || entry.action === "secret.restore"));
2516
+ const writes = entries.filter((entry) => entry.author === "app" && entry.decision === "allow" && (entry.action === "secret.write" || entry.action === "secret.restore" || entry.action === "secret.loosen"));
2511
2517
  for (const entry of entries.filter((row) => row.author === "app" && row.decision === "allow")) expect(entry.action !== "secret.read", "the app logged an allowed read of a value", entry);
2512
2518
  for (const entry of writes) {
2513
- const seal = entry.action === "secret.write" ? "key.wrap" : "key.rewrap";
2519
+ const seal = entry.action === "secret.write" && JSON.parse(entry.metadata).kept === void 0 ? "key.wrap" : "key.rewrap";
2514
2520
  const key = entry.related_seq === null ? void 0 : bySeq.get(String(entry.related_seq));
2515
2521
  expect(key !== void 0 && key.author === "vault" && key.action === seal && key.decision === "allow", `a ${entry.action} names no ${seal} of the vault's`, {
2516
2522
  entry,
@@ -3075,6 +3081,46 @@ async function references(deployment, { admin, reader, leaver }, canaries) {
3075
3081
  }
3076
3082
  /** A key prod has and dev does not, for the missing-keys check; archived once checked. */
3077
3083
  const PROD_ONLY = "CONFORMANCE_PROD_ONLY";
3084
+ const LOOSE = "CONFORMANCE_LOOSENED";
3085
+ /**
3086
+ * A sensitive value is made a secret in place by an Owner alone (R30): the
3087
+ * leaver, a developer on dev, is refused, and told the listing does not
3088
+ * offer it; the admin's mark answers no value, and the reader, a viewer on
3089
+ * dev, reads it after, as a secret, its old version still sensitive. Its
3090
+ * own `secret.loosen`, which "keys behind writes" holds to the vault's
3091
+ * `key.rewrap`. The key is archived after.
3092
+ */
3093
+ async function loosening({ admin, reader, leaver }) {
3094
+ const value = canary();
3095
+ const path = `${DEV}/${LOOSE}`;
3096
+ await admin.api.secrets.set(DEV, { [LOOSE]: {
3097
+ value,
3098
+ sensitivity: "sensitive"
3099
+ } });
3100
+ try {
3101
+ await refused$1("a viewer read a sensitive value", reader.api.secrets.reveal(path));
3102
+ expect((await leaver.api.secrets.list(DEV)).loosenable === false, "a developer on dev is told they make a sensitive value a secret in place");
3103
+ await refused$1("a developer on dev made a sensitive value a secret in place", leaver.api.secrets.set(DEV, { [LOOSE]: { sensitivity: "secret" } }));
3104
+ expect((await admin.api.secrets.list(DEV)).loosenable === true, "the admin, an Owner of the whole instance, is told they do not loosen");
3105
+ const marked = await admin.api.secrets.set(DEV, { [LOOSE]: { sensitivity: "secret" } });
3106
+ expect(!JSON.stringify(marked).includes(value), "the admin's loosening answered the value", marked);
3107
+ expect(JSON.stringify(marked.keys[LOOSE]) === JSON.stringify({
3108
+ version: 2,
3109
+ sensitivity: "secret"
3110
+ }), "the loosening made no new secret version", marked.keys);
3111
+ expect((await reader.api.secrets.reveal(path)).values[LOOSE] === value, "the reader did not read the loosened value as dev's secret");
3112
+ const versions = (await admin.api.secrets.history(path)).versions.map((version) => version.sensitivity);
3113
+ expect(versions.join() === "secret,sensitive", "the loosening changed the old version too, or made none", versions);
3114
+ const logged = (await admin.api.audit.list({
3115
+ path,
3116
+ limit: 50
3117
+ })).entries.filter((entry) => entry.action === "secret.loosen");
3118
+ expect(logged.length === 1 && logged[0].metadata.from === "sensitive" && logged[0].metadata.to === "secret", "the loosening is not its own entry, saying both levels", logged);
3119
+ } finally {
3120
+ await admin.api.secrets.set(DEV, { [LOOSE]: null });
3121
+ }
3122
+ return "the admin makes a sensitive value a secret in place, answered no value, as a new version, logged as secret.loosen; a developer on dev may not";
3123
+ }
3078
3124
  /**
3079
3125
  * Within a project, key names are not secret; values are. What dev is
3080
3126
  * missing is compared with every sibling: the reader, a viewer on dev who
@@ -3322,11 +3368,16 @@ function getCalls({ places, secrets, members, services }) {
3322
3368
  "GET /members/:member/access": members.map((member) => ({ params: { member } })),
3323
3369
  "GET /members/:member/tokens": services.map((member) => ({ params: { member } })),
3324
3370
  "GET /members/:member/bindings": services.map((member) => ({ params: { member } })),
3371
+ "GET /members/:member/bindings/:id/enrollments": services.map((member) => ({ params: {
3372
+ member,
3373
+ id: "00000000-0000-4000-8000-000000000000"
3374
+ } })),
3325
3375
  "GET /workloads/lookup": [{
3326
3376
  params: {},
3327
3377
  input: { github: "acme/api" }
3328
3378
  }],
3329
3379
  "GET /workloads/repositories": [{ params: {} }],
3380
+ "GET /freezes": [{ params: {} }],
3330
3381
  "GET /roles": [{ params: {} }],
3331
3382
  "GET /settings": [{ params: {} }],
3332
3383
  "GET /sessions": [{ params: {} }],
@@ -5110,6 +5161,7 @@ async function conform(deployment, options) {
5110
5161
  await report.check("inheritance", all, ({ people, canaries }) => inheritance(people, canaries));
5111
5162
  await report.check("personal configs", { people }, ({ people }) => personalConfigs(deployment, people));
5112
5163
  await report.check("references", all, ({ people, canaries }) => references(deployment, people, canaries));
5164
+ await report.check("loosening", { people }, ({ people }) => loosening(people));
5113
5165
  await report.check("missing keys", { people }, ({ people }) => missingKeys(people));
5114
5166
  await report.check("MCP connect", { people }, ({ people }) => mcpConnect(deployment, people));
5115
5167
  await report.check("MCP read", all, ({ people, canaries }) => mcpRead(deployment, people, canaries));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coffre/conformance",
3
- "version": "0.10.1",
3
+ "version": "0.11.0",
4
4
  "description": "Checks a coffre deployment from outside: what it must never do, whatever code it runs.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -31,8 +31,8 @@
31
31
  "dependencies": {
32
32
  "jose": "6.2.3",
33
33
  "pg": "8.16.3",
34
- "@coffre/cli": "0.10.1",
35
- "@coffre/db": "0.10.1"
34
+ "@coffre/db": "0.11.0",
35
+ "@coffre/cli": "0.11.0"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/node": "26.1.1",
@@ -41,7 +41,7 @@
41
41
  "tsdown": "0.23.0",
42
42
  "typescript": "5.9.3",
43
43
  "vite": "8.1.5",
44
- "@coffre/client": "0.10.1"
44
+ "@coffre/client": "0.11.0"
45
45
  },
46
46
  "scripts": {
47
47
  "build": "tsdown",
@@ -110,7 +110,8 @@ export async function checkpoints(deployment: Deployment, { admin }: People): Pr
110
110
 
111
111
  /**
112
112
  * Every version the app says it stored names the vault's entry for the key
113
- * it was sealed with, `key.wrap` for a write and `key.rewrap` for a restore:
113
+ * it was sealed with, `key.wrap` for a write and `key.rewrap` for a restore,
114
+ * a mark and a loosening:
114
115
  * the same member, request and operation, the same secret and version. And
115
116
  * every value read is the vault's to log: the app keeps no reads of its own.
116
117
  */
@@ -123,12 +124,13 @@ export async function writesAgree(deployment: Deployment): Promise<string> {
123
124
  }>('SELECT * FROM audit_log ORDER BY seq');
124
125
  const bySeq = new Map(entries.map((entry) => [String(entry.seq), entry]));
125
126
  const writes = entries.filter((entry) => entry.author === 'app' && entry.decision === 'allow'
126
- && (entry.action === 'secret.write' || entry.action === 'secret.restore'));
127
+ && (entry.action === 'secret.write' || entry.action === 'secret.restore' || entry.action === 'secret.loosen'));
127
128
  for (const entry of entries.filter((row) => row.author === 'app' && row.decision === 'allow')) {
128
129
  expect(entry.action !== 'secret.read', 'the app logged an allowed read of a value', entry);
129
130
  }
130
131
  for (const entry of writes) {
131
- const seal = entry.action === 'secret.write' ? 'key.wrap' : 'key.rewrap';
132
+ // A write of a new value wraps a new key; a restore, a mark (which says the version it `kept`) and a loosening rewrap one.
133
+ const seal = entry.action === 'secret.write' && JSON.parse(entry.metadata).kept === undefined ? 'key.wrap' : 'key.rewrap';
132
134
  const key = entry.related_seq === null ? undefined : bySeq.get(String(entry.related_seq));
133
135
  expect(key !== undefined && key.author === 'vault' && key.action === seal && key.decision === 'allow',
134
136
  `a ${entry.action} names no ${seal} of the vault's`, { entry, key });
@@ -238,6 +238,40 @@ export async function references(deployment: Deployment, { admin, reader, leaver
238
238
  /** A key prod has and dev does not, for the missing-keys check; archived once checked. */
239
239
  const PROD_ONLY = 'CONFORMANCE_PROD_ONLY';
240
240
 
241
+ const LOOSE = 'CONFORMANCE_LOOSENED';
242
+
243
+ /**
244
+ * A sensitive value is made a secret in place by an Owner alone (R30): the
245
+ * leaver, a developer on dev, is refused, and told the listing does not
246
+ * offer it; the admin's mark answers no value, and the reader, a viewer on
247
+ * dev, reads it after, as a secret, its old version still sensitive. Its
248
+ * own `secret.loosen`, which "keys behind writes" holds to the vault's
249
+ * `key.rewrap`. The key is archived after.
250
+ */
251
+ export async function loosening({ admin, reader, leaver }: People): Promise<string> {
252
+ const value = canary();
253
+ const path = `${DEV}/${LOOSE}`;
254
+ await admin.api.secrets.set(DEV, { [LOOSE]: { value, sensitivity: 'sensitive' } });
255
+ try {
256
+ await refused('a viewer read a sensitive value', reader.api.secrets.reveal(path));
257
+ expect((await leaver.api.secrets.list(DEV)).loosenable === false, 'a developer on dev is told they make a sensitive value a secret in place');
258
+ await refused('a developer on dev made a sensitive value a secret in place', leaver.api.secrets.set(DEV, { [LOOSE]: { sensitivity: 'secret' } }));
259
+ expect((await admin.api.secrets.list(DEV)).loosenable === true, 'the admin, an Owner of the whole instance, is told they do not loosen');
260
+ const marked = await admin.api.secrets.set(DEV, { [LOOSE]: { sensitivity: 'secret' } });
261
+ expect(!JSON.stringify(marked).includes(value), "the admin's loosening answered the value", marked);
262
+ expect(JSON.stringify(marked.keys[LOOSE]) === JSON.stringify({ version: 2, sensitivity: 'secret' }), 'the loosening made no new secret version', marked.keys);
263
+ const read = await reader.api.secrets.reveal(path);
264
+ expect(read.values[LOOSE] === value, "the reader did not read the loosened value as dev's secret");
265
+ const versions = (await admin.api.secrets.history(path)).versions.map((version) => version.sensitivity);
266
+ expect(versions.join() === 'secret,sensitive', 'the loosening changed the old version too, or made none', versions);
267
+ const logged = (await admin.api.audit.list({ path, limit: 50 })).entries.filter((entry) => entry.action === 'secret.loosen');
268
+ expect(logged.length === 1 && logged[0]!.metadata.from === 'sensitive' && logged[0]!.metadata.to === 'secret', 'the loosening is not its own entry, saying both levels', logged);
269
+ } finally {
270
+ await admin.api.secrets.set(DEV, { [LOOSE]: null });
271
+ }
272
+ return 'the admin makes a sensitive value a secret in place, answered no value, as a new version, logged as secret.loosen; a developer on dev may not';
273
+ }
274
+
241
275
  /**
242
276
  * Within a project, key names are not secret; values are. What dev is
243
277
  * missing is compared with every sibling: the reader, a viewer on dev who
package/src/draining.ts CHANGED
@@ -25,6 +25,8 @@ export function drainingConfig(server: string): string {
25
25
  join(server, 'conformance.js'),
26
26
  [
27
27
  "import app from './index.js';",
28
+ // The app's other exports, its Durable Object classes (`CoffreSockets`), which its config binds by name.
29
+ "export * from './index.js';",
28
30
  'export default {',
29
31
  ' ...app,',
30
32
  ' async fetch(request, env, ctx) {',
@@ -75,8 +75,9 @@ export function randomToken(): string {
75
75
  }
76
76
 
77
77
  /**
78
- * The built-in client accepts any loopback URI, because local dev ports vary;
79
- * every other redirect URI must match a registered one exactly.
78
+ * The built-in client accepts any loopback URI, because local dev ports vary,
79
+ * and any URI under an origin it was given (a tunnel to the app); every other
80
+ * redirect URI must match a registered one exactly.
80
81
  */
81
82
  export function allowsRedirect(client: RegisteredClient, uri: string): boolean {
82
83
  if (client.redirectUris.includes(uri)) return true;
@@ -87,13 +88,9 @@ export function allowsRedirect(client: RegisteredClient, uri: string): boolean {
87
88
  } catch {
88
89
  return false;
89
90
  }
90
- return (
91
- url.protocol === 'http:' &&
92
- (url.hostname === '127.0.0.1' || url.hostname === 'localhost') &&
93
- url.username === '' &&
94
- url.password === '' &&
95
- !uri.includes('#')
96
- );
91
+ if (url.username !== '' || url.password !== '' || uri.includes('#')) return false;
92
+ const loopback = url.protocol === 'http:' && (url.hostname === '127.0.0.1' || url.hostname === 'localhost');
93
+ return loopback || client.redirectOrigins.includes(url.origin);
97
94
  }
98
95
 
99
96
  /** RFC 7636 §4.6, S256 only. */
package/src/idp/idp.ts CHANGED
@@ -28,6 +28,8 @@ export interface DevIdpClient {
28
28
  export interface RegisteredClient extends DevIdpClient {
29
29
  /** Accept any http://127.0.0.1 or http://localhost redirect URI, on any port. */
30
30
  anyLoopbackRedirect: boolean;
31
+ /** Also accept redirect URIs under these origins (a tunnel to the app). Only for the built-in clients. */
32
+ redirectOrigins: readonly string[];
31
33
  }
32
34
 
33
35
  export interface DevIdpOptions {
@@ -37,6 +39,14 @@ export interface DevIdpOptions {
37
39
  autoApprove?: boolean;
38
40
  /** The fake GitHub App's private key, PKCS #1 PEM: made at start unless given. */
39
41
  githubAppKey?: string;
42
+ /**
43
+ * The origin a browser reaches this server at, when that is not its loopback
44
+ * address (a tunnel to it): the issuer, and every URL it publishes, name it.
45
+ * It still listens on loopback only.
46
+ */
47
+ publicOrigin?: string;
48
+ /** Origins besides loopback that the built-in clients may redirect to: the app's, behind the same tunnel. */
49
+ redirectOrigins?: readonly string[];
40
50
  }
41
51
 
42
52
  /** Built in, so local dev needs no registration step. */
@@ -59,6 +69,7 @@ export const DEFAULT_CLIENT = Object.freeze({
59
69
  export class DevIdp {
60
70
  #server: Server | null = null;
61
71
  #port = 0;
72
+ #publicOrigin: string | undefined;
62
73
  #clients = new Map<string, RegisteredClient>();
63
74
  #subjects = new Map<string, string>();
64
75
  #gitHubAccounts = new Map<string, GitHubAccount>();
@@ -85,11 +96,14 @@ export class DevIdp {
85
96
 
86
97
  constructor(options: DevIdpOptions = {}) {
87
98
  this.autoApprove = options.autoApprove ?? false;
99
+ this.#publicOrigin = options.publicOrigin === undefined ? undefined : new URL(options.publicOrigin).origin;
100
+ const redirectOrigins = (options.redirectOrigins ?? []).map((each) => new URL(each).origin);
88
101
  this.githubApp = new FakeGitHubApp(() => this.origin, options.githubAppKey);
89
102
  this.#clients.set(DEFAULT_CLIENT.clientId, {
90
103
  ...DEFAULT_CLIENT,
91
104
  redirectUris: [],
92
105
  anyLoopbackRedirect: true,
106
+ redirectOrigins,
93
107
  });
94
108
  for (const client of options.clients ?? []) this.registerClient(client);
95
109
  // The GitHub App's own OAuth client, which signs people in as the fake GitHub's do.
@@ -98,6 +112,7 @@ export class DevIdp {
98
112
  clientSecret: this.githubApp.clientSecret,
99
113
  redirectUris: [],
100
114
  anyLoopbackRedirect: true,
115
+ redirectOrigins,
101
116
  });
102
117
 
103
118
  const authz = new AuthorizationServer(this);
@@ -106,7 +121,7 @@ export class DevIdp {
106
121
 
107
122
  get origin(): string {
108
123
  if (this.#port === 0) throw new Error('DevIdp is not started');
109
- return `http://127.0.0.1:${this.#port}`;
124
+ return this.#publicOrigin ?? `http://127.0.0.1:${this.#port}`;
110
125
  }
111
126
 
112
127
  /** Matches the Cloudflare Access team-domain issuer shape. */
@@ -185,6 +200,7 @@ export class DevIdp {
185
200
  clientSecret: client.clientSecret,
186
201
  redirectUris: [...client.redirectUris],
187
202
  anyLoopbackRedirect: false,
203
+ redirectOrigins: [],
188
204
  });
189
205
  }
190
206
 
package/src/suite.ts CHANGED
@@ -7,7 +7,7 @@ import { bulkLimit, crossSite, grantScoping, instanceRoles, membersOnly, offboar
7
7
  import { checkpoints, deletedTail, forgedVaultEntry, missingEntry, noAuditNoValue, revealAudited, rewrittenEntry, verification, writesAgree } from './checks/audit.ts';
8
8
  import { earlierCheckpoint } from './checks/checkpoints.ts';
9
9
  import { deletion } from './checks/deletion.ts';
10
- import { folders, forks, inheritance, missingKeys, personalConfigs, references } from './checks/environments.ts';
10
+ import { folders, forks, inheritance, loosening, missingKeys, personalConfigs, references } from './checks/environments.ts';
11
11
  import { appLogin, vaultLogin } from './checks/logins.ts';
12
12
  import { mcpRead, mcpChanges, mcpConnect, mcpValues } from './checks/mcp.ts';
13
13
  import { accessAuthorship, memberTampering, noAuditNoAccess, sealingRace } from './checks/members.ts';
@@ -42,6 +42,7 @@ export async function conform(deployment: Deployment, options: { bulkLimit: numb
42
42
  await report.check('inheritance', all, ({ people, canaries }) => inheritance(people, canaries));
43
43
  await report.check('personal configs', { people }, ({ people }) => personalConfigs(deployment, people));
44
44
  await report.check('references', all, ({ people, canaries }) => references(deployment, people, canaries));
45
+ await report.check('loosening', { people }, ({ people }) => loosening(people));
45
46
  await report.check('missing keys', { people }, ({ people }) => missingKeys(people));
46
47
  // Before offboarding: the leaver's CLI session is one of the credentials /mcp must refuse.
47
48
  await report.check('MCP connect', { people }, ({ people }) => mcpConnect(deployment, people));