@cookiemunch/sdk 0.22.0 → 0.23.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 +6 -0
- package/dist/{chunk-7Q6XFXKS.js → chunk-VXN75KHK.js} +63 -3
- package/dist/chunk-VXN75KHK.js.map +1 -0
- package/dist/executor-conformance.d.ts +3 -1
- package/dist/index.cjs +65 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +35 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/rights.cjs +4 -2
- package/dist/rights.cjs.map +1 -1
- package/dist/rights.d.ts +10 -2
- package/dist/rights.js +5 -3
- package/dist/rights.js.map +1 -1
- package/dist/types.d.ts +6 -1
- package/package.json +5 -12
- package/LICENSE +0 -21
- package/dist/chunk-7Q6XFXKS.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Every published release, newest first. Dates are the day the version was cut.
|
|
4
4
|
|
|
5
|
+
## 0.23.0 (2026-11-11)
|
|
6
|
+
|
|
7
|
+
- Added: the `blocked` rights status. A callback answers `{ status: 'blocked', blocked: { reason, message } }` when the person must act first, and `status` is asked again on each read. `DsarCaseStatus` and case tasks carry `blocked`.
|
|
8
|
+
- Added: conformance rule `requests.access.no_secrets` (with `testSubjectEmail`): the test subject's export must hold no credential.
|
|
9
|
+
- Added: `orgs.createDryRun` (`POST /v1/orgs?dryRun=1`), with an optional `provision` plan.
|
|
10
|
+
|
|
5
11
|
## 0.22.0 (2026-11-11)
|
|
6
12
|
|
|
7
13
|
- Added: the rights handlers speak six rights (`access`, `erasure`, `rectification`, `portability`, `restriction`, `closure`); `deletion` and `erase` read as `erasure`, ids minted before read the same, and a `portability` callback falls back to `access`.
|
|
@@ -24,6 +24,28 @@ var CONFORMANCE_RULES = [
|
|
|
24
24
|
{ id: "version.header", title: "Answers carry X-Version (the highest contract version the executor supports)." }
|
|
25
25
|
];
|
|
26
26
|
var TEST_SUBJECT_RULE = { id: "lookup.test_subject.found", title: "A real test subject of yours (testSubjectEmail) is found: this rule alone reaches your own store through createRightsHandlers, which answers the canary itself." };
|
|
27
|
+
var EXPORT_RULE = { id: "requests.access.no_secrets", title: "An access request for your test subject (testSubjectEmail) finishes, and its export carries no credential: no password, password hash, secret, API key, token or private key, by field name or by shape." };
|
|
28
|
+
var SECRET_FIELD = /^(password|passwd|passwordhash|passhash|hashedpassword|secret|clientsecret|apikey|apisecret|accesstoken|refreshtoken|sessiontoken|idtoken|authtoken|privatekey|totpsecret|otpsecret|mfasecret|recoverycodes|salt)$/;
|
|
29
|
+
var SECRET_VALUE = /^(sk_(live|test)_|rk_(live|test)_|cmk_|ghp_|gho_|github_pat_|xox[abpr]-|AKIA[0-9A-Z]{16}|-----BEGIN [A-Z ]*PRIVATE KEY-----|\$2[aby]\$\d\d\$|\$argon2)/;
|
|
30
|
+
function secretPaths(v, path = "$", out = []) {
|
|
31
|
+
if (out.length >= 20) return out;
|
|
32
|
+
if (typeof v === "string") {
|
|
33
|
+
if (SECRET_VALUE.test(v.trim())) out.push(path);
|
|
34
|
+
return out;
|
|
35
|
+
}
|
|
36
|
+
if (Array.isArray(v)) {
|
|
37
|
+
v.forEach((x, i) => secretPaths(x, `${path}[${i}]`, out));
|
|
38
|
+
return out;
|
|
39
|
+
}
|
|
40
|
+
if (v && typeof v === "object") {
|
|
41
|
+
for (const [k, x] of Object.entries(v)) {
|
|
42
|
+
const p = `${path}.${k}`;
|
|
43
|
+
if (SECRET_FIELD.test(k.toLowerCase().replace(/[_-]/g, "")) && x !== null && x !== "" && x !== void 0) out.push(p);
|
|
44
|
+
else secretPaths(x, p, out);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return out;
|
|
48
|
+
}
|
|
27
49
|
var ERASE_RULE = { id: "requests.erase.removes_subject", title: "A real erasure of your throwaway subject (eraseSubjectEmail) finishes, and a lookup no longer finds them: this rule alone runs your own erase code." };
|
|
28
50
|
function randomTag() {
|
|
29
51
|
const bytes = new Uint8Array(8);
|
|
@@ -60,7 +82,7 @@ async function runExecutorConformance(o) {
|
|
|
60
82
|
const results = /* @__PURE__ */ new Map();
|
|
61
83
|
let version;
|
|
62
84
|
const set = (id, status, detail) => {
|
|
63
|
-
const rule = [...CONFORMANCE_RULES, TEST_SUBJECT_RULE, ERASE_RULE].find((r) => r.id === id);
|
|
85
|
+
const rule = [...CONFORMANCE_RULES, TEST_SUBJECT_RULE, EXPORT_RULE, ERASE_RULE].find((r) => r.id === id);
|
|
64
86
|
results.set(id, { id, title: rule.title, status, ...detail ? { detail } : {} });
|
|
65
87
|
};
|
|
66
88
|
const pass = (id) => set(id, "pass");
|
|
@@ -119,6 +141,9 @@ async function runExecutorConformance(o) {
|
|
|
119
141
|
const seeded = await call("POST", "/lookup", { emails: [o.testSubjectEmail] }, { "Idempotency-Key": key("lookup-seeded") });
|
|
120
142
|
if (seeded.status === 200 && field(seeded.json, "status") === "found") pass("lookup.test_subject.found");
|
|
121
143
|
else fail("lookup.test_subject.found", `${o.testSubjectEmail}: ${said(seeded)}`);
|
|
144
|
+
const seededId = field(seeded.json, "subjectId");
|
|
145
|
+
if (typeof seededId === "string" && seededId) await exportRule(seededId);
|
|
146
|
+
else skip(EXPORT_RULE.id, "needs the test subject, which the lookup did not find");
|
|
122
147
|
}
|
|
123
148
|
const bothNames = (a) => a.status === 400 ? " A body carries `identity` and `atlas` together, identical, and `emails` can be empty: accept all of that (see the v2 contract)." : "";
|
|
124
149
|
const byIdentity = await call("POST", "/lookup", { emails: [], identity, atlas: identity }, { "Idempotency-Key": key("lookup-identity") });
|
|
@@ -212,8 +237,42 @@ async function runExecutorConformance(o) {
|
|
|
212
237
|
if (gone.status === 200 && (field(gone.json, "status") === "no_match" || st === "completed_with_retention")) pass(rule);
|
|
213
238
|
else fail(rule, `the erasure said "${String(st)}", but a lookup afterwards: ${said(gone)}`);
|
|
214
239
|
}
|
|
240
|
+
async function exportRule(subject) {
|
|
241
|
+
const rule = EXPORT_RULE.id;
|
|
242
|
+
const opened = await call("POST", "/requests", { subjectId: subject, type: "access", caseId: `conformance-access-${run}`, reason: "Cookie Munch conformance check (test subject export)" }, { "Idempotency-Key": key("access") });
|
|
243
|
+
const id = field(opened.json, "id");
|
|
244
|
+
if (opened.status !== 200 && opened.status !== 201 || typeof id !== "string") return fail(rule, `the access request was not accepted: ${said(opened)}`);
|
|
245
|
+
let answer = opened;
|
|
246
|
+
const deadline = Date.now() + (o.eraseTimeoutMs ?? 3e4);
|
|
247
|
+
while (["pending", "processing"].includes(String(field(answer.json, "status"))) && Date.now() < deadline) {
|
|
248
|
+
await new Promise((r) => setTimeout(r, 500));
|
|
249
|
+
answer = await call("GET", `/requests/${encodeURIComponent(id)}`, void 0, { "Idempotency-Key": key("access-get") });
|
|
250
|
+
}
|
|
251
|
+
const st = field(answer.json, "status");
|
|
252
|
+
if (st !== "completed" && st !== "completed_with_retention") return fail(rule, `the access request ended as "${String(st)}", not completed`);
|
|
253
|
+
let bundle = field(answer.json, "result");
|
|
254
|
+
const url2 = field(bundle, "downloadUrl");
|
|
255
|
+
if (typeof url2 === "string") {
|
|
256
|
+
try {
|
|
257
|
+
const res = await doFetch(url2, { headers: { accept: "application/json" } });
|
|
258
|
+
const text = await res.text();
|
|
259
|
+
if (text.length > 5e6) return fail(rule, "the export is over 5 MB");
|
|
260
|
+
try {
|
|
261
|
+
bundle = JSON.parse(text);
|
|
262
|
+
} catch {
|
|
263
|
+
bundle = text;
|
|
264
|
+
}
|
|
265
|
+
} catch (err) {
|
|
266
|
+
return fail(rule, `the export's downloadUrl could not be read: ${err instanceof Error ? err.message : String(err)}`);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
if (bundle === void 0) return fail(rule, "the completed access request carried no result (inline, or { downloadUrl })");
|
|
270
|
+
const found = typeof bundle === "string" ? bundle.split(/\s+/).filter((w) => SECRET_VALUE.test(w)).map(() => "$ (text)") : secretPaths(bundle);
|
|
271
|
+
if (found.length) fail(rule, `the export carries what looks like a credential at ${[...new Set(found)].join(", ")}; leave credentials out of an access export`);
|
|
272
|
+
else pass(rule);
|
|
273
|
+
}
|
|
215
274
|
function report() {
|
|
216
|
-
const rules = [...CONFORMANCE_RULES, ...o.testSubjectEmail ? [TEST_SUBJECT_RULE] : [], ...o.eraseSubjectEmail ? [ERASE_RULE] : []].map((r) => results.get(r.id) ?? { id: r.id, title: r.title, status: "skip", detail: "not reached" });
|
|
275
|
+
const rules = [...CONFORMANCE_RULES, ...o.testSubjectEmail ? [TEST_SUBJECT_RULE, EXPORT_RULE] : [], ...o.eraseSubjectEmail ? [ERASE_RULE] : []].map((r) => results.get(r.id) ?? { id: r.id, title: r.title, status: "skip", detail: "not reached" });
|
|
217
276
|
const count = (s) => rules.filter((r) => r.status === s).length;
|
|
218
277
|
return { ok: count("fail") === 0, passed: count("pass"), failed: count("fail"), skipped: count("skip"), blocked: count("blocked"), rules, ...version ? { version } : {} };
|
|
219
278
|
}
|
|
@@ -223,6 +282,7 @@ export {
|
|
|
223
282
|
CANARY_ISSUER,
|
|
224
283
|
canaryIdentityFor,
|
|
225
284
|
CONFORMANCE_RULES,
|
|
285
|
+
secretPaths,
|
|
226
286
|
runExecutorConformance
|
|
227
287
|
};
|
|
228
|
-
//# sourceMappingURL=chunk-
|
|
288
|
+
//# sourceMappingURL=chunk-VXN75KHK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/executor-conformance.ts"],"sourcesContent":["/**\n * The cm-standard-v2 executor conformance kit.\n *\n * cm-standard-v2 is an open contract: any system that holds personal data can implement it and\n * be driven by Cookie Munch with no code on our side (docs: cookiemunch.net/docs/executor-contract-v2).\n * This kit checks an implementation rule by rule, and names the rule that fails. It is the same\n * suite Cookie Munch runs on `POST /v1/dsar/executors/{id}/test {conformance: true}`, and the\n * `cookiemunch executors conformance <baseUrl>` command runs it from a terminal or CI.\n *\n * It only ever touches the CANARY subject — an address no real person has. The contract asks every\n * implementation to treat the canary as an existing synthetic person: it is found by its email and\n * by its identity, requests on it move through the full state machine, and nothing real is ever\n * erased (the one exception is `eraseSubjectEmail`, a throwaway subject the caller names). So the kit can check that an erasure waits for `executeAfter`, that a cancel leaves the\n * person in place, and that an identity is never matched to someone else through a shared email —\n * without a real person's data being anywhere near it.\n *\n * No dependencies: `fetch` only, so it runs in Node 18+, a browser, or an edge runtime.\n */\n\n/** `blocked`: not run, because the rule named in `blockedBy` failed first and decides it. */\nexport type ConformanceStatus = 'pass' | 'fail' | 'skip' | 'blocked';\n\nexport interface ConformanceRuleResult {\n /** A stable id, e.g. `requests.execute_after.scheduled`. */\n id: string;\n /** What the rule says, in one sentence. */\n title: string;\n status: ConformanceStatus;\n /** What was seen, when it failed or was skipped. */\n detail?: string;\n /** With status `blocked`: the rule whose failure stopped this one. */\n blockedBy?: string;\n}\n\nexport interface ConformanceReport {\n /** True when no rule failed. */\n ok: boolean;\n passed: number;\n failed: number;\n skipped: number;\n /** Rules not run because an earlier failure decides them. */\n blocked: number;\n /** Set when the credential itself was refused: `missing_scope` (403) or `credential_refused` (401). */\n code?: 'missing_scope' | 'credential_refused';\n /** With `missing_scope`: the scopes the key needs, when known. */\n required?: string[];\n /** With `code`: the one thing to do next. */\n fix?: string;\n rules: ConformanceRuleResult[];\n /** The `X-Version` the executor answered with, when it sent one. */\n version?: string;\n}\n\nexport interface ConformanceOptions {\n /** The executor's base: the contract paths are `{baseUrl}/privacy/lookup` and so on. https (http only for localhost). */\n baseUrl: string;\n /** The credential Cookie Munch would send. */\n secret: string;\n /**\n * The canary address: `canary-<16 hex>@canary.cookiemunch.net`, per organisation\n * (`GET /v1/dsar/executors/presets` → `canaryEmail`).\n */\n canaryEmail: string;\n /** A subject you seeded in your own store. It is looked up and exported (an access request), never erased. Without it, `lookup.test_subject.found` and `requests.access.no_secrets` are skipped. */\n testSubjectEmail?: string;\n /**\n * A THROWAWAY subject you seeded in your own store. It IS erased, for real, through your own erase code, so reseed it\n * before each run. Without it, `requests.erase.removes_subject` does not run and nothing real is touched.\n */\n eraseSubjectEmail?: string;\n /** How long to wait for that erasure to finish, in ms. Default 30000. */\n eraseTimeoutMs?: number;\n /** How the secret is sent. Default `Authorization: Bearer {secret}`. */\n auth?: { header: string; format: string };\n /** Path prefix under baseUrl. Default `/privacy`. */\n prefix?: string;\n fetch?: typeof fetch;\n now?: () => number;\n /** A per-run tag for idempotency keys and case ids. Default random. */\n runId?: string;\n /** The scopes this system's key needs, when the caller knows them. Otherwise read off the system's own 403. */\n requiredScopes?: string[];\n /** Where to get a key with those scopes, added to `fix`. */\n keyHint?: string;\n}\n\n/** The issuer the canary identity carries. */\nexport const CANARY_ISSUER = 'https://canary.cookiemunch.net';\nconst CANARY_EMAIL_RE = /^canary-([0-9a-f]{16})@canary\\.cookiemunch\\.net$/;\n\n/** The canary subject's identity, derived from its address. */\nexport function canaryIdentityFor(canaryEmail: string): { iss: string; sub: string; ext: string } {\n const m = CANARY_EMAIL_RE.exec(canaryEmail.trim().toLowerCase());\n if (!m) throw new Error('canaryEmail must be the canary address canary-<16 hex>@canary.cookiemunch.net');\n return { iss: CANARY_ISSUER, sub: `canary_${m[1]}`, ext: `canary:${m[1]}` };\n}\n\n/** Every rule, in the order they run. */\nexport const CONFORMANCE_RULES: ReadonlyArray<{ id: string; title: string }> = [\n { id: 'auth.required', title: 'A request without the credential is refused (401, 403, or a 404 without X-Version).' },\n { id: 'lookup.email.found', title: 'The canary subject is found by its email.' },\n { id: 'lookup.identity.found', title: 'The canary subject is found by its identity alone (iss + sub), and it is the same subject.' },\n { id: 'lookup.unknown.no_match', title: 'An address nobody has answers { subjectId: null, status: \"no_match\" }.' },\n { id: 'lookup.identity_beats_email', title: 'An identity that matches no one is never matched through the email of someone else.' },\n { id: 'requests.bad_body.400', title: 'A request with an unknown type answers 400 { error, field }.' },\n { id: 'requests.alias.canonical_type', title: 'An alias (erasure) is accepted and answered with canonicalType \"deletion\".' },\n { id: 'requests.execute_after.scheduled', title: 'A deletion with a future executeAfter is \"scheduled\" with eta equal to executeAfter — nothing is deleted before it.' },\n { id: 'requests.idempotency.replay', title: 'The same Idempotency-Key with the same body returns the same request, not a second one.' },\n { id: 'requests.idempotency.mismatch_409', title: 'The same Idempotency-Key with a different body answers 409.' },\n { id: 'requests.get', title: 'GET /privacy/requests/{id} returns the request, still scheduled.' },\n { id: 'requests.unknown.404', title: 'An unknown request id answers 404.' },\n { id: 'requests.cancel.before_execute_after', title: 'A cancel before executeAfter answers status \"cancelled\".' },\n { id: 'requests.cancel.keeps_data', title: 'After a cancel the subject is still there: a lookup finds it.' },\n { id: 'version.header', title: 'Answers carry X-Version (the highest contract version the executor supports).' },\n];\n\n/** Asked for, not assumed: only with `testSubjectEmail`, so a run without one still reads as the 15 rules every receiver is held to. */\nconst TEST_SUBJECT_RULE = { id: 'lookup.test_subject.found', title: 'A real test subject of yours (testSubjectEmail) is found: this rule alone reaches your own store through createRightsHandlers, which answers the canary itself.' };\n\n/** With `testSubjectEmail` too: an access request reads that subject's export, which must carry no credential (Lucida CM6). */\nconst EXPORT_RULE = { id: 'requests.access.no_secrets', title: 'An access request for your test subject (testSubjectEmail) finishes, and its export carries no credential: no password, password hash, secret, API key, token or private key, by field name or by shape.' };\n\n/** Field names that hold a credential, compared lowercased with `_` and `-` removed. */\nconst SECRET_FIELD = /^(password|passwd|passwordhash|passhash|hashedpassword|secret|clientsecret|apikey|apisecret|accesstoken|refreshtoken|sessiontoken|idtoken|authtoken|privatekey|totpsecret|otpsecret|mfasecret|recoverycodes|salt)$/;\n/** Values shaped like a live credential, whatever the field is called. */\nconst SECRET_VALUE = /^(sk_(live|test)_|rk_(live|test)_|cmk_|ghp_|gho_|github_pat_|xox[abpr]-|AKIA[0-9A-Z]{16}|-----BEGIN [A-Z ]*PRIVATE KEY-----|\\$2[aby]\\$\\d\\d\\$|\\$argon2)/;\n\n/** The paths in an export that look like credentials (never their values). */\nexport function secretPaths(v: unknown, path = '$', out: string[] = []): string[] {\n if (out.length >= 20) return out;\n if (typeof v === 'string') { if (SECRET_VALUE.test(v.trim())) out.push(path); return out; }\n if (Array.isArray(v)) { v.forEach((x, i) => secretPaths(x, `${path}[${i}]`, out)); return out; }\n if (v && typeof v === 'object') {\n for (const [k, x] of Object.entries(v as Record<string, unknown>)) {\n const p = `${path}.${k}`;\n if (SECRET_FIELD.test(k.toLowerCase().replace(/[_-]/g, '')) && x !== null && x !== '' && x !== undefined) out.push(p);\n else secretPaths(x, p, out);\n }\n }\n return out;\n}\n\n/** Asked for by name: only with `eraseSubjectEmail`, because it really erases that subject. */\nconst ERASE_RULE = { id: 'requests.erase.removes_subject', title: 'A real erasure of your throwaway subject (eraseSubjectEmail) finishes, and a lookup no longer finds them: this rule alone runs your own erase code.' };\n\ntype Answer = { status: number; json: unknown; version: string | null; error?: string };\n\nfunction randomTag(): string {\n const bytes = new Uint8Array(8);\n const c = (globalThis as { crypto?: { getRandomValues?: (a: Uint8Array) => Uint8Array } }).crypto;\n if (c?.getRandomValues) c.getRandomValues(bytes);\n else for (let i = 0; i < bytes.length; i++) bytes[i] = Math.floor(Math.random() * 256);\n return Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');\n}\n\nfunction field(json: unknown, key: string): unknown {\n return json && typeof json === 'object' ? (json as Record<string, unknown>)[key] : undefined;\n}\n\n/** Run every rule against one executor. Never throws for an executor's answer; only for bad options. */\nexport async function runExecutorConformance(o: ConformanceOptions): Promise<ConformanceReport> {\n const doFetch = o.fetch ?? fetch;\n const now = o.now ?? (() => Date.now());\n const base = o.baseUrl.replace(/\\/+$/, '') + (o.prefix ?? '/privacy');\n let url: URL;\n try {\n url = new URL(base);\n } catch {\n throw new Error('baseUrl must be an absolute URL');\n }\n if (url.protocol !== 'https:' && !(url.protocol === 'http:' && /^(localhost|127\\.0\\.0\\.1|\\[::1\\])$/.test(url.hostname))) {\n throw new Error('baseUrl must be https (http only for localhost)');\n }\n for (const [name, v] of [['testSubjectEmail', o.testSubjectEmail], ['eraseSubjectEmail', o.eraseSubjectEmail]] as const) {\n if (v !== undefined && !/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(v)) throw new Error(`${name} must be an email address, not \"${v}\"`);\n }\n const lower = (x: string | undefined) => x?.trim().toLowerCase();\n if (o.eraseSubjectEmail && [lower(o.canaryEmail), lower(o.testSubjectEmail)].includes(lower(o.eraseSubjectEmail))) throw new Error('eraseSubjectEmail must be its own throwaway subject, not the canary or testSubjectEmail');\n const identity = canaryIdentityFor(o.canaryEmail);\n const canaryEmail = o.canaryEmail.trim().toLowerCase();\n const auth = o.auth ?? { header: 'Authorization', format: 'Bearer {secret}' };\n const run = o.runId ?? randomTag();\n const results = new Map<string, ConformanceRuleResult>();\n let version: string | undefined;\n\n const set = (id: string, status: ConformanceStatus, detail?: string): void => {\n const rule = [...CONFORMANCE_RULES, TEST_SUBJECT_RULE, EXPORT_RULE, ERASE_RULE].find((r) => r.id === id)!;\n results.set(id, { id, title: rule.title, status, ...(detail ? { detail } : {}) });\n };\n const pass = (id: string) => set(id, 'pass');\n const fail = (id: string, detail: string) => set(id, 'fail', detail);\n const skip = (id: string, detail: string) => set(id, 'skip', detail);\n\n async function call(method: string, path: string, body?: unknown, extra: Record<string, string> = {}, withAuth = true): Promise<Answer> {\n const headers: Record<string, string> = {\n accept: 'application/json',\n 'X-Version': '2',\n ...(withAuth ? { [auth.header]: auth.format.replace('{secret}', o.secret) } : {}),\n ...(body !== undefined ? { 'content-type': 'application/json' } : {}),\n ...extra,\n };\n try {\n const res = await doFetch(base + path, { method, headers, ...(body !== undefined ? { body: JSON.stringify(body) } : {}) });\n const text = await res.text().catch(() => '');\n let json: unknown;\n try {\n json = text ? JSON.parse(text) : undefined;\n } catch {\n json = undefined;\n }\n const v = res.headers.get('x-version');\n if (v && !version) version = v;\n return { status: res.status, json, version: v };\n } catch (err) {\n return { status: 0, json: undefined, version: null, error: err instanceof Error ? err.message : String(err) };\n }\n }\n const said = (a: Answer): string => (a.status === 0 ? `unreachable: ${a.error}` : `HTTP ${a.status} ${JSON.stringify(a.json ?? null).slice(0, 200)}`);\n const key = (rule: string) => `conformance:${run}:${rule}`;\n\n // auth.required\n const anon = await call('POST', '/lookup', { emails: [canaryEmail] }, {}, false);\n if (anon.status === 0) {\n // Nothing else can be judged against a system we cannot reach.\n for (const r of CONFORMANCE_RULES) skip(r.id, said(anon));\n fail('auth.required', said(anon));\n return report();\n }\n // A bare 404 (no X-Version) is a refusal that does not even admit the endpoint exists.\n if (anon.status === 401 || anon.status === 403 || (anon.status === 404 && !anon.version)) pass('auth.required');\n else fail('auth.required', `without a credential: ${said(anon)}`);\n\n // lookups\n const byEmail = await call('POST', '/lookup', { emails: [canaryEmail] }, { 'Idempotency-Key': key('lookup-email') });\n // The key itself is refused: every later rule would fail for this one reason, so it is the only failure.\n // A 404 with no X-Version is how createRightsHandlers answers a wrong secret: it does not admit the API exists.\n const hidden = byEmail.status === 404 && !byEmail.version;\n if (byEmail.status === 401 || byEmail.status === 403 || hidden) {\n fail('lookup.email.found', `the canary address: ${said(byEmail)}`);\n for (const r of CONFORMANCE_RULES) if (!results.has(r.id)) results.set(r.id, { id: r.id, title: r.title, status: 'blocked', blockedBy: 'lookup.email.found' });\n const code = byEmail.status === 403 ? 'missing_scope' as const : 'credential_refused' as const;\n const named = [...new Set(JSON.stringify(byEmail.json ?? '').match(/\\b[a-z_]+:[a-z_]+(?::[a-z_]+)*\\b/g) ?? [])];\n const required = o.requiredScopes?.length ? o.requiredScopes : named;\n const hint = o.keyHint ? ` ${o.keyHint}` : '';\n const fix = code === 'missing_scope'\n ? `This key may not call the rights API (HTTP 403).${required.length ? ` It needs ${required.join(' or ')}.` : ' Give it the rights scope that system documents.'}${hint}`\n : hidden\n ? `No rights API answered this key (HTTP 404, no X-Version). createRightsHandlers answers a wrong secret this way, so check the secret first, then the base URL.${hint}`\n : `This key was refused (HTTP 401): it is wrong, expired or revoked. Send a current one.${hint}`;\n return { ...report(), code, ...(code === 'missing_scope' && required.length ? { required } : {}), fix };\n }\n const subjectId = field(byEmail.json, 'subjectId');\n if (byEmail.status === 200 && field(byEmail.json, 'status') === 'found' && typeof subjectId === 'string' && subjectId) pass('lookup.email.found');\n else fail('lookup.email.found', `the canary address: ${said(byEmail)}`);\n\n if (o.testSubjectEmail) {\n const seeded = await call('POST', '/lookup', { emails: [o.testSubjectEmail] }, { 'Idempotency-Key': key('lookup-seeded') });\n if (seeded.status === 200 && field(seeded.json, 'status') === 'found') pass('lookup.test_subject.found');\n else fail('lookup.test_subject.found', `${o.testSubjectEmail}: ${said(seeded)}`);\n const seededId = field(seeded.json, 'subjectId');\n if (typeof seededId === 'string' && seededId) await exportRule(seededId);\n else skip(EXPORT_RULE.id, 'needs the test subject, which the lookup did not find');\n }\n\n // A receiver that takes the two names as alternatives refuses the body every real request is sent in.\n const bothNames = (a: Answer) => (a.status === 400 ? ' A body carries `identity` and `atlas` together, identical, and `emails` can be empty: accept all of that (see the v2 contract).' : '');\n const byIdentity = await call('POST', '/lookup', { emails: [], identity: identity, atlas: identity }, { 'Idempotency-Key': key('lookup-identity') });\n if (byIdentity.status === 200 && field(byIdentity.json, 'status') === 'found' && field(byIdentity.json, 'subjectId') === subjectId && typeof subjectId === 'string') {\n pass('lookup.identity.found');\n } else {\n fail('lookup.identity.found', `the canary identity ${identity.sub}: ${said(byIdentity)}${typeof subjectId === 'string' ? ` (by email it was ${subjectId})` : ''}${bothNames(byIdentity)}`);\n }\n\n const nobody = await call('POST', '/lookup', { emails: [`nobody-${run}@canary.cookiemunch.net`] }, { 'Idempotency-Key': key('lookup-nobody') });\n if (nobody.status === 200 && field(nobody.json, 'status') === 'no_match' && field(nobody.json, 'subjectId') === null) pass('lookup.unknown.no_match');\n else fail('lookup.unknown.no_match', said(nobody));\n\n const stranger = { iss: identity.iss, sub: `canary_other_${run}` };\n const crossed = await call('POST', '/lookup', { emails: [canaryEmail], identity: stranger, atlas: stranger }, { 'Idempotency-Key': key('lookup-crossed') });\n if (crossed.status === 200 && field(crossed.json, 'status') === 'no_match') pass('lookup.identity_beats_email');\n else {\n fail(\n 'lookup.identity_beats_email',\n `an identity nobody has (${stranger.sub}) with the canary's email: ${said(crossed)} — the email belongs to a different identity, so this must be no_match${bothNames(crossed)}`,\n );\n }\n\n // requests\n const bad = await call('POST', '/requests', { subjectId: subjectId ?? 'x', type: 'teleport', caseId: `conformance-${run}` }, { 'Idempotency-Key': key('bad-body') });\n if (bad.status === 400 && typeof field(bad.json, 'error') === 'string' && typeof field(bad.json, 'field') === 'string') pass('requests.bad_body.400');\n else fail('requests.bad_body.400', said(bad));\n\n if (typeof subjectId !== 'string') {\n for (const id of ['requests.alias.canonical_type', 'requests.execute_after.scheduled', 'requests.idempotency.replay', 'requests.idempotency.mismatch_409', 'requests.get', 'requests.cancel.before_execute_after', 'requests.cancel.keeps_data']) {\n skip(id, 'needs the canary subject, which the lookup did not find');\n }\n } else {\n const executeAfter = new Date(Math.ceil((now() + 3_600_000) / 1000) * 1000).toISOString();\n const body = { subjectId, type: 'erasure', executeAfter, caseId: `conformance-${run}`, reason: 'Cookie Munch conformance check (canary subject)' };\n const opened = await call('POST', '/requests', body, { 'Idempotency-Key': key('open') });\n const id = field(opened.json, 'id');\n const st = field(opened.json, 'status');\n if ((opened.status === 200 || opened.status === 201) && field(opened.json, 'canonicalType') === 'deletion') pass('requests.alias.canonical_type');\n else fail('requests.alias.canonical_type', `type \"erasure\": ${said(opened)}`);\n\n const eta = field(opened.json, 'eta');\n if ((opened.status === 200 || opened.status === 201) && st === 'scheduled' && typeof eta === 'string' && Date.parse(eta) === Date.parse(executeAfter)) {\n pass('requests.execute_after.scheduled');\n } else if (st === 'completed' || st === 'completed_with_retention' || st === 'processing') {\n fail('requests.execute_after.scheduled', `executeAfter is ${executeAfter}, an hour away, and the executor answered \"${String(st)}\": it acted before executeAfter`);\n } else {\n fail('requests.execute_after.scheduled', `expected status \"scheduled\" with eta ${executeAfter}: ${said(opened)}`);\n }\n\n const replay = await call('POST', '/requests', body, { 'Idempotency-Key': key('open') });\n if (typeof id === 'string' && (replay.status === 200 || replay.status === 201) && field(replay.json, 'id') === id) pass('requests.idempotency.replay');\n else fail('requests.idempotency.replay', `a retry with the same key: ${said(replay)}${typeof id === 'string' ? ` (first answer id ${id})` : ''}`);\n\n const mismatch = await call('POST', '/requests', { ...body, reason: 'a different body' }, { 'Idempotency-Key': key('open') });\n if (mismatch.status === 409) pass('requests.idempotency.mismatch_409');\n else fail('requests.idempotency.mismatch_409', `the same key with a different body: ${said(mismatch)}`);\n\n if (typeof id !== 'string') {\n skip('requests.get', 'no request id came back');\n skip('requests.cancel.before_execute_after', 'no request id came back');\n skip('requests.cancel.keeps_data', 'no request id came back');\n } else {\n const got = await call('GET', `/requests/${encodeURIComponent(id)}`, undefined, { 'Idempotency-Key': key('get') });\n if (got.status === 200 && field(got.json, 'id') === id && field(got.json, 'status') === 'scheduled') pass('requests.get');\n else fail('requests.get', said(got));\n\n const cancelled = await call('POST', `/requests/${encodeURIComponent(id)}/cancel`, {}, { 'Idempotency-Key': key('cancel') });\n if (cancelled.status === 200 && field(cancelled.json, 'status') === 'cancelled') pass('requests.cancel.before_execute_after');\n else fail('requests.cancel.before_execute_after', said(cancelled));\n\n const after = await call('POST', '/lookup', { emails: [canaryEmail] }, { 'Idempotency-Key': key('lookup-after-cancel') });\n if (after.status === 200 && field(after.json, 'status') === 'found') pass('requests.cancel.keeps_data');\n else fail('requests.cancel.keeps_data', `a lookup after the cancel: ${said(after)} — a cancel before executeAfter must leave the data intact`);\n }\n }\n\n const unknown = await call('GET', `/requests/conformance-missing-${run}`, undefined, { 'Idempotency-Key': key('unknown') });\n if (unknown.status === 404) pass('requests.unknown.404');\n else fail('requests.unknown.404', said(unknown));\n\n if (o.eraseSubjectEmail) await eraseRule(o.eraseSubjectEmail);\n\n if (version) pass('version.header');\n else fail('version.header', 'no answer carried an X-Version header');\n\n return report();\n\n async function eraseRule(email: string): Promise<void> {\n const rule = ERASE_RULE.id;\n const before = await call('POST', '/lookup', { emails: [email] }, { 'Idempotency-Key': key('erase-lookup') });\n const subject = field(before.json, 'subjectId');\n if (before.status !== 200 || field(before.json, 'status') !== 'found' || typeof subject !== 'string') {\n return fail(rule, `${email} must exist before the run, so seed it each time: ${said(before)}`);\n }\n const opened = await call('POST', '/requests', { subjectId: subject, type: 'deletion', caseId: `conformance-erase-${run}`, reason: 'Cookie Munch conformance check (throwaway subject)' }, { 'Idempotency-Key': key('erase') });\n const id = field(opened.json, 'id');\n if ((opened.status !== 200 && opened.status !== 201) || typeof id !== 'string') return fail(rule, `the erasure was not accepted: ${said(opened)}`);\n let st = field(opened.json, 'status');\n const deadline = Date.now() + (o.eraseTimeoutMs ?? 30_000);\n while ((st === 'pending' || st === 'processing') && Date.now() < deadline) {\n await new Promise((r) => setTimeout(r, 500));\n st = field((await call('GET', `/requests/${encodeURIComponent(id)}`, undefined, { 'Idempotency-Key': key('erase-get') })).json, 'status');\n }\n if (st !== 'completed' && st !== 'completed_with_retention') return fail(rule, `the erasure ended as \"${String(st)}\", not completed`);\n const gone = await call('POST', '/lookup', { emails: [email] }, { 'Idempotency-Key': key('erase-after') });\n // A retention is a declared exception: the contract lets that subject remain.\n if (gone.status === 200 && (field(gone.json, 'status') === 'no_match' || st === 'completed_with_retention')) pass(rule);\n else fail(rule, `the erasure said \"${String(st)}\", but a lookup afterwards: ${said(gone)}`);\n }\n\n async function exportRule(subject: string): Promise<void> {\n const rule = EXPORT_RULE.id;\n const opened = await call('POST', '/requests', { subjectId: subject, type: 'access', caseId: `conformance-access-${run}`, reason: 'Cookie Munch conformance check (test subject export)' }, { 'Idempotency-Key': key('access') });\n const id = field(opened.json, 'id');\n if ((opened.status !== 200 && opened.status !== 201) || typeof id !== 'string') return fail(rule, `the access request was not accepted: ${said(opened)}`);\n let answer = opened;\n const deadline = Date.now() + (o.eraseTimeoutMs ?? 30_000);\n while (['pending', 'processing'].includes(String(field(answer.json, 'status'))) && Date.now() < deadline) {\n await new Promise((r) => setTimeout(r, 500));\n answer = await call('GET', `/requests/${encodeURIComponent(id)}`, undefined, { 'Idempotency-Key': key('access-get') });\n }\n const st = field(answer.json, 'status');\n if (st !== 'completed' && st !== 'completed_with_retention') return fail(rule, `the access request ended as \"${String(st)}\", not completed`);\n let bundle = field(answer.json, 'result');\n const url = field(bundle, 'downloadUrl');\n if (typeof url === 'string') {\n try {\n const res = await doFetch(url, { headers: { accept: 'application/json' } });\n const text = await res.text();\n if (text.length > 5_000_000) return fail(rule, 'the export is over 5 MB');\n try { bundle = JSON.parse(text); } catch { bundle = text; }\n } catch (err) {\n return fail(rule, `the export's downloadUrl could not be read: ${err instanceof Error ? err.message : String(err)}`);\n }\n }\n if (bundle === undefined) return fail(rule, 'the completed access request carried no result (inline, or { downloadUrl })');\n const found = typeof bundle === 'string' ? bundle.split(/\\s+/).filter((w) => SECRET_VALUE.test(w)).map(() => '$ (text)') : secretPaths(bundle);\n if (found.length) fail(rule, `the export carries what looks like a credential at ${[...new Set(found)].join(', ')}; leave credentials out of an access export`);\n else pass(rule);\n }\n\n function report(): ConformanceReport {\n const rules = [...CONFORMANCE_RULES, ...(o.testSubjectEmail ? [TEST_SUBJECT_RULE, EXPORT_RULE] : []), ...(o.eraseSubjectEmail ? [ERASE_RULE] : [])].map((r) => results.get(r.id) ?? { id: r.id, title: r.title, status: 'skip' as const, detail: 'not reached' });\n const count = (s: ConformanceStatus) => rules.filter((r) => r.status === s).length;\n return { ok: count('fail') === 0, passed: count('pass'), failed: count('fail'), skipped: count('skip'), blocked: count('blocked'), rules, ...(version ? { version } : {}) };\n }\n}\n"],"mappings":";AAuFO,IAAM,gBAAgB;AAC7B,IAAM,kBAAkB;AAGjB,SAAS,kBAAkB,aAAgE;AAChG,QAAM,IAAI,gBAAgB,KAAK,YAAY,KAAK,EAAE,YAAY,CAAC;AAC/D,MAAI,CAAC,EAAG,OAAM,IAAI,MAAM,+EAA+E;AACvG,SAAO,EAAE,KAAK,eAAe,KAAK,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AI,EAAE,mBAAmB,CAAC,mBAAmB,WAAW,IAAI,CAAC,GAAI,GAAI,EAAE,oBAAoB,CAAC,UAAU,IAAI,CAAC,CAAE,EAAE,IAAI,CAAC,MAAM,QAAQ,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,OAAO,EAAE,OAAO,QAAQ,QAAiB,QAAQ,cAAc,CAAC;AAChQ,UAAM,QAAQ,CAAC,MAAyB,MAAM,OAAO,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE;AAC5E,WAAO,EAAE,IAAI,MAAM,MAAM,MAAM,GAAG,QAAQ,MAAM,MAAM,GAAG,QAAQ,MAAM,MAAM,GAAG,SAAS,MAAM,MAAM,GAAG,SAAS,MAAM,SAAS,GAAG,OAAO,GAAI,UAAU,EAAE,QAAQ,IAAI,CAAC,EAAG;AAAA,EAC5K;AACF;","names":["url"]}
|
|
@@ -57,7 +57,7 @@ export interface ConformanceOptions {
|
|
|
57
57
|
* (`GET /v1/dsar/executors/presets` → `canaryEmail`).
|
|
58
58
|
*/
|
|
59
59
|
canaryEmail: string;
|
|
60
|
-
/** A subject you seeded in your own store. It is
|
|
60
|
+
/** A subject you seeded in your own store. It is looked up and exported (an access request), never erased. Without it, `lookup.test_subject.found` and `requests.access.no_secrets` are skipped. */
|
|
61
61
|
testSubjectEmail?: string;
|
|
62
62
|
/**
|
|
63
63
|
* A THROWAWAY subject you seeded in your own store. It IS erased, for real, through your own erase code, so reseed it
|
|
@@ -95,5 +95,7 @@ export declare const CONFORMANCE_RULES: ReadonlyArray<{
|
|
|
95
95
|
id: string;
|
|
96
96
|
title: string;
|
|
97
97
|
}>;
|
|
98
|
+
/** The paths in an export that look like credentials (never their values). */
|
|
99
|
+
export declare function secretPaths(v: unknown, path?: string, out?: string[]): string[];
|
|
98
100
|
/** Run every rule against one executor. Never throws for an executor's answer; only for bad options. */
|
|
99
101
|
export declare function runExecutorConformance(o: ConformanceOptions): Promise<ConformanceReport>;
|
package/dist/index.cjs
CHANGED
|
@@ -37,6 +37,7 @@ __export(src_exports, {
|
|
|
37
37
|
parseConsentValue: () => parseConsentValue,
|
|
38
38
|
readConsent: () => readConsent,
|
|
39
39
|
runExecutorConformance: () => runExecutorConformance,
|
|
40
|
+
secretPaths: () => secretPaths,
|
|
40
41
|
verifyDecisionSignature: () => verifyDecisionSignature,
|
|
41
42
|
verifyToken: () => verifyToken,
|
|
42
43
|
verifyWebhookSignature: () => verifyWebhookSignature
|
|
@@ -279,6 +280,28 @@ var CONFORMANCE_RULES = [
|
|
|
279
280
|
{ id: "version.header", title: "Answers carry X-Version (the highest contract version the executor supports)." }
|
|
280
281
|
];
|
|
281
282
|
var TEST_SUBJECT_RULE = { id: "lookup.test_subject.found", title: "A real test subject of yours (testSubjectEmail) is found: this rule alone reaches your own store through createRightsHandlers, which answers the canary itself." };
|
|
283
|
+
var EXPORT_RULE = { id: "requests.access.no_secrets", title: "An access request for your test subject (testSubjectEmail) finishes, and its export carries no credential: no password, password hash, secret, API key, token or private key, by field name or by shape." };
|
|
284
|
+
var SECRET_FIELD = /^(password|passwd|passwordhash|passhash|hashedpassword|secret|clientsecret|apikey|apisecret|accesstoken|refreshtoken|sessiontoken|idtoken|authtoken|privatekey|totpsecret|otpsecret|mfasecret|recoverycodes|salt)$/;
|
|
285
|
+
var SECRET_VALUE = /^(sk_(live|test)_|rk_(live|test)_|cmk_|ghp_|gho_|github_pat_|xox[abpr]-|AKIA[0-9A-Z]{16}|-----BEGIN [A-Z ]*PRIVATE KEY-----|\$2[aby]\$\d\d\$|\$argon2)/;
|
|
286
|
+
function secretPaths(v, path = "$", out = []) {
|
|
287
|
+
if (out.length >= 20) return out;
|
|
288
|
+
if (typeof v === "string") {
|
|
289
|
+
if (SECRET_VALUE.test(v.trim())) out.push(path);
|
|
290
|
+
return out;
|
|
291
|
+
}
|
|
292
|
+
if (Array.isArray(v)) {
|
|
293
|
+
v.forEach((x, i) => secretPaths(x, `${path}[${i}]`, out));
|
|
294
|
+
return out;
|
|
295
|
+
}
|
|
296
|
+
if (v && typeof v === "object") {
|
|
297
|
+
for (const [k, x] of Object.entries(v)) {
|
|
298
|
+
const p = `${path}.${k}`;
|
|
299
|
+
if (SECRET_FIELD.test(k.toLowerCase().replace(/[_-]/g, "")) && x !== null && x !== "" && x !== void 0) out.push(p);
|
|
300
|
+
else secretPaths(x, p, out);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return out;
|
|
304
|
+
}
|
|
282
305
|
var ERASE_RULE = { id: "requests.erase.removes_subject", title: "A real erasure of your throwaway subject (eraseSubjectEmail) finishes, and a lookup no longer finds them: this rule alone runs your own erase code." };
|
|
283
306
|
function randomTag() {
|
|
284
307
|
const bytes = new Uint8Array(8);
|
|
@@ -315,7 +338,7 @@ async function runExecutorConformance(o) {
|
|
|
315
338
|
const results = /* @__PURE__ */ new Map();
|
|
316
339
|
let version;
|
|
317
340
|
const set = (id, status, detail) => {
|
|
318
|
-
const rule = [...CONFORMANCE_RULES, TEST_SUBJECT_RULE, ERASE_RULE].find((r) => r.id === id);
|
|
341
|
+
const rule = [...CONFORMANCE_RULES, TEST_SUBJECT_RULE, EXPORT_RULE, ERASE_RULE].find((r) => r.id === id);
|
|
319
342
|
results.set(id, { id, title: rule.title, status, ...detail ? { detail } : {} });
|
|
320
343
|
};
|
|
321
344
|
const pass = (id) => set(id, "pass");
|
|
@@ -374,6 +397,9 @@ async function runExecutorConformance(o) {
|
|
|
374
397
|
const seeded = await call("POST", "/lookup", { emails: [o.testSubjectEmail] }, { "Idempotency-Key": key("lookup-seeded") });
|
|
375
398
|
if (seeded.status === 200 && field(seeded.json, "status") === "found") pass("lookup.test_subject.found");
|
|
376
399
|
else fail("lookup.test_subject.found", `${o.testSubjectEmail}: ${said(seeded)}`);
|
|
400
|
+
const seededId = field(seeded.json, "subjectId");
|
|
401
|
+
if (typeof seededId === "string" && seededId) await exportRule(seededId);
|
|
402
|
+
else skip(EXPORT_RULE.id, "needs the test subject, which the lookup did not find");
|
|
377
403
|
}
|
|
378
404
|
const bothNames = (a) => a.status === 400 ? " A body carries `identity` and `atlas` together, identical, and `emails` can be empty: accept all of that (see the v2 contract)." : "";
|
|
379
405
|
const byIdentity = await call("POST", "/lookup", { emails: [], identity, atlas: identity }, { "Idempotency-Key": key("lookup-identity") });
|
|
@@ -467,8 +493,42 @@ async function runExecutorConformance(o) {
|
|
|
467
493
|
if (gone.status === 200 && (field(gone.json, "status") === "no_match" || st === "completed_with_retention")) pass(rule);
|
|
468
494
|
else fail(rule, `the erasure said "${String(st)}", but a lookup afterwards: ${said(gone)}`);
|
|
469
495
|
}
|
|
496
|
+
async function exportRule(subject) {
|
|
497
|
+
const rule = EXPORT_RULE.id;
|
|
498
|
+
const opened = await call("POST", "/requests", { subjectId: subject, type: "access", caseId: `conformance-access-${run}`, reason: "Cookie Munch conformance check (test subject export)" }, { "Idempotency-Key": key("access") });
|
|
499
|
+
const id = field(opened.json, "id");
|
|
500
|
+
if (opened.status !== 200 && opened.status !== 201 || typeof id !== "string") return fail(rule, `the access request was not accepted: ${said(opened)}`);
|
|
501
|
+
let answer = opened;
|
|
502
|
+
const deadline = Date.now() + (o.eraseTimeoutMs ?? 3e4);
|
|
503
|
+
while (["pending", "processing"].includes(String(field(answer.json, "status"))) && Date.now() < deadline) {
|
|
504
|
+
await new Promise((r) => setTimeout(r, 500));
|
|
505
|
+
answer = await call("GET", `/requests/${encodeURIComponent(id)}`, void 0, { "Idempotency-Key": key("access-get") });
|
|
506
|
+
}
|
|
507
|
+
const st = field(answer.json, "status");
|
|
508
|
+
if (st !== "completed" && st !== "completed_with_retention") return fail(rule, `the access request ended as "${String(st)}", not completed`);
|
|
509
|
+
let bundle = field(answer.json, "result");
|
|
510
|
+
const url2 = field(bundle, "downloadUrl");
|
|
511
|
+
if (typeof url2 === "string") {
|
|
512
|
+
try {
|
|
513
|
+
const res = await doFetch(url2, { headers: { accept: "application/json" } });
|
|
514
|
+
const text = await res.text();
|
|
515
|
+
if (text.length > 5e6) return fail(rule, "the export is over 5 MB");
|
|
516
|
+
try {
|
|
517
|
+
bundle = JSON.parse(text);
|
|
518
|
+
} catch {
|
|
519
|
+
bundle = text;
|
|
520
|
+
}
|
|
521
|
+
} catch (err) {
|
|
522
|
+
return fail(rule, `the export's downloadUrl could not be read: ${err instanceof Error ? err.message : String(err)}`);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
if (bundle === void 0) return fail(rule, "the completed access request carried no result (inline, or { downloadUrl })");
|
|
526
|
+
const found = typeof bundle === "string" ? bundle.split(/\s+/).filter((w) => SECRET_VALUE.test(w)).map(() => "$ (text)") : secretPaths(bundle);
|
|
527
|
+
if (found.length) fail(rule, `the export carries what looks like a credential at ${[...new Set(found)].join(", ")}; leave credentials out of an access export`);
|
|
528
|
+
else pass(rule);
|
|
529
|
+
}
|
|
470
530
|
function report() {
|
|
471
|
-
const rules = [...CONFORMANCE_RULES, ...o.testSubjectEmail ? [TEST_SUBJECT_RULE] : [], ...o.eraseSubjectEmail ? [ERASE_RULE] : []].map((r) => results.get(r.id) ?? { id: r.id, title: r.title, status: "skip", detail: "not reached" });
|
|
531
|
+
const rules = [...CONFORMANCE_RULES, ...o.testSubjectEmail ? [TEST_SUBJECT_RULE, EXPORT_RULE] : [], ...o.eraseSubjectEmail ? [ERASE_RULE] : []].map((r) => results.get(r.id) ?? { id: r.id, title: r.title, status: "skip", detail: "not reached" });
|
|
472
532
|
const count = (s) => rules.filter((r) => r.status === s).length;
|
|
473
533
|
return { ok: count("fail") === 0, passed: count("pass"), failed: count("fail"), skipped: count("skip"), blocked: count("blocked"), rules, ...version ? { version } : {} };
|
|
474
534
|
}
|
|
@@ -511,7 +571,7 @@ async function exchangeOperatorToken(input) {
|
|
|
511
571
|
}
|
|
512
572
|
|
|
513
573
|
// src/index.ts
|
|
514
|
-
var SDK_VERSION = "0.
|
|
574
|
+
var SDK_VERSION = "0.23.0";
|
|
515
575
|
var CookieMunchApiError = class extends Error {
|
|
516
576
|
constructor(status, message, code, body) {
|
|
517
577
|
super(message);
|
|
@@ -601,6 +661,7 @@ function createCookieMunch(opts) {
|
|
|
601
661
|
orgs: {
|
|
602
662
|
list: (o) => get(`/orgs${metaQs(o)}`),
|
|
603
663
|
create: (name, opts2) => request("POST", "/orgs", { name, ...opts2 ?? {} }),
|
|
664
|
+
createDryRun: (name, opts2) => request("POST", "/orgs?dryRun=1", { name, ...opts2 ?? {} }),
|
|
604
665
|
deleteSandbox: (id) => request("DELETE", `/orgs/${enc(id)}?hard=1`)
|
|
605
666
|
},
|
|
606
667
|
metadata: {
|
|
@@ -1070,6 +1131,7 @@ function createCookieMunch(opts) {
|
|
|
1070
1131
|
parseConsentValue,
|
|
1071
1132
|
readConsent,
|
|
1072
1133
|
runExecutorConformance,
|
|
1134
|
+
secretPaths,
|
|
1073
1135
|
verifyDecisionSignature,
|
|
1074
1136
|
verifyToken,
|
|
1075
1137
|
verifyWebhookSignature
|