@cookiemunch/sdk 0.0.0-stage → 0.1.1
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/README.md +59 -2
- package/dist/chunk-G7ORTXTK.js +104 -0
- package/dist/chunk-G7ORTXTK.js.map +1 -0
- package/dist/consent.cjs +132 -0
- package/dist/consent.cjs.map +1 -0
- package/dist/consent.d.cts +88 -0
- package/dist/consent.d.ts +88 -0
- package/dist/consent.js +15 -0
- package/dist/consent.js.map +1 -0
- package/dist/index.cjs +475 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1714 -0
- package/dist/index.d.ts +1714 -0
- package/dist/index.js +353 -0
- package/dist/index.js.map +1 -0
- package/package.json +37 -3
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
CONSENT_COOKIE_NAME: () => CONSENT_COOKIE_NAME,
|
|
24
|
+
CookieMunchApiError: () => CookieMunchApiError,
|
|
25
|
+
createCookieMunch: () => createCookieMunch,
|
|
26
|
+
getConsent: () => getConsent,
|
|
27
|
+
isAllowed: () => isAllowed,
|
|
28
|
+
parseConsentValue: () => parseConsentValue,
|
|
29
|
+
readConsent: () => readConsent,
|
|
30
|
+
verifyWebhookSignature: () => verifyWebhookSignature
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(src_exports);
|
|
33
|
+
|
|
34
|
+
// src/consent.ts
|
|
35
|
+
var CONSENT_COOKIE_NAME = "CookieMunch";
|
|
36
|
+
function cookieHeaderOf(src) {
|
|
37
|
+
if (typeof src === "string") return src;
|
|
38
|
+
if (!src || typeof src !== "object") return "";
|
|
39
|
+
const h = src.headers;
|
|
40
|
+
if (!h) return "";
|
|
41
|
+
if (typeof h.get === "function") {
|
|
42
|
+
return h.get("cookie") ?? "";
|
|
43
|
+
}
|
|
44
|
+
const c = h.cookie;
|
|
45
|
+
return typeof c === "string" ? c : "";
|
|
46
|
+
}
|
|
47
|
+
function cookieValue(header, name) {
|
|
48
|
+
for (const part of header.split(";")) {
|
|
49
|
+
const eq = part.indexOf("=");
|
|
50
|
+
if (eq === -1) continue;
|
|
51
|
+
if (part.slice(0, eq).trim() === name) return part.slice(eq + 1).trim();
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
function bool(v) {
|
|
56
|
+
return typeof v === "boolean";
|
|
57
|
+
}
|
|
58
|
+
function decode(raw) {
|
|
59
|
+
try {
|
|
60
|
+
return decodeURIComponent(raw);
|
|
61
|
+
} catch {
|
|
62
|
+
return raw;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function normalize(o) {
|
|
66
|
+
if (!o || typeof o !== "object") return null;
|
|
67
|
+
const r = o;
|
|
68
|
+
if (!bool(r.preferences) || !bool(r.statistics) || !bool(r.marketing)) return null;
|
|
69
|
+
if (r.method !== "explicit" && r.method !== "implied") return null;
|
|
70
|
+
if (typeof r.ver !== "number" || typeof r.utc !== "number") return null;
|
|
71
|
+
if (typeof r.stamp !== "string" && typeof r.stamp !== "number") return null;
|
|
72
|
+
if (typeof r.region !== "string") return null;
|
|
73
|
+
const out = {
|
|
74
|
+
necessary: true,
|
|
75
|
+
// never trust a cookie that claims necessary:false
|
|
76
|
+
preferences: r.preferences,
|
|
77
|
+
statistics: r.statistics,
|
|
78
|
+
marketing: r.marketing,
|
|
79
|
+
method: r.method,
|
|
80
|
+
ver: r.ver,
|
|
81
|
+
utc: r.utc,
|
|
82
|
+
region: r.region,
|
|
83
|
+
stamp: String(r.stamp)
|
|
84
|
+
};
|
|
85
|
+
if (r.custom && typeof r.custom === "object" && !Array.isArray(r.custom)) {
|
|
86
|
+
const custom = {};
|
|
87
|
+
for (const [k, v] of Object.entries(r.custom)) if (bool(v)) custom[k] = v;
|
|
88
|
+
if (Object.keys(custom).length > 0) out.custom = custom;
|
|
89
|
+
}
|
|
90
|
+
return out;
|
|
91
|
+
}
|
|
92
|
+
function parseConsentValue(raw) {
|
|
93
|
+
if (!raw) return null;
|
|
94
|
+
const decoded = decode(raw);
|
|
95
|
+
try {
|
|
96
|
+
return normalize(JSON.parse(decoded));
|
|
97
|
+
} catch {
|
|
98
|
+
}
|
|
99
|
+
if (!decoded.includes("necessary")) return null;
|
|
100
|
+
const json = decoded.replace(/'/g, '"').replace(/([{,]\s*)([A-Za-z_][\w]*)\s*:/g, '$1"$2":');
|
|
101
|
+
try {
|
|
102
|
+
return normalize(JSON.parse(json));
|
|
103
|
+
} catch {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
var DAY_MS = 24 * 60 * 60 * 1e3;
|
|
108
|
+
function readConsent(source, opts = {}) {
|
|
109
|
+
const raw = cookieValue(cookieHeaderOf(source), opts.cookieName ?? CONSENT_COOKIE_NAME);
|
|
110
|
+
const consent = raw ? parseConsentValue(raw) : null;
|
|
111
|
+
if (!consent) return null;
|
|
112
|
+
if (typeof opts.minVersion === "number" && consent.ver < opts.minVersion) return null;
|
|
113
|
+
if (typeof opts.expiryDays === "number" && opts.expiryDays > 0) {
|
|
114
|
+
if ((opts.now ?? Date.now()) - consent.utc > opts.expiryDays * DAY_MS) return null;
|
|
115
|
+
}
|
|
116
|
+
return consent;
|
|
117
|
+
}
|
|
118
|
+
function getConsent(source, cookieName = CONSENT_COOKIE_NAME) {
|
|
119
|
+
return readConsent(source, { cookieName });
|
|
120
|
+
}
|
|
121
|
+
function isAllowed(consent, category) {
|
|
122
|
+
if (category === "necessary") return true;
|
|
123
|
+
if (!consent) return false;
|
|
124
|
+
if (category === "preferences") return consent.preferences === true;
|
|
125
|
+
if (category === "statistics") return consent.statistics === true;
|
|
126
|
+
if (category === "marketing") return consent.marketing === true;
|
|
127
|
+
return consent.custom?.[category] === true;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// src/webhooks.ts
|
|
131
|
+
var import_node_crypto = require("crypto");
|
|
132
|
+
function verifyWebhookSignature(input) {
|
|
133
|
+
const { payload, signature, timestamp, secret } = input;
|
|
134
|
+
if (!signature || timestamp == null || timestamp === "" || !secret) return false;
|
|
135
|
+
const tsRaw = String(timestamp);
|
|
136
|
+
const tsNum = Number(tsRaw);
|
|
137
|
+
if (!Number.isFinite(tsNum)) return false;
|
|
138
|
+
const tolerance = input.toleranceSeconds ?? 300;
|
|
139
|
+
if (tolerance > 0) {
|
|
140
|
+
const nowSec = Math.floor((input.now ?? Date.now()) / 1e3);
|
|
141
|
+
if (Math.abs(nowSec - tsNum) > tolerance) return false;
|
|
142
|
+
}
|
|
143
|
+
const expected = `sha256=${(0, import_node_crypto.createHmac)("sha256", secret).update(`${tsRaw}.${payload}`).digest("hex")}`;
|
|
144
|
+
const got = Buffer.from(signature);
|
|
145
|
+
const want = Buffer.from(expected);
|
|
146
|
+
if (got.length !== want.length) return false;
|
|
147
|
+
return (0, import_node_crypto.timingSafeEqual)(got, want);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// src/index.ts
|
|
151
|
+
var CookieMunchApiError = class extends Error {
|
|
152
|
+
constructor(status, message, code) {
|
|
153
|
+
super(message);
|
|
154
|
+
this.name = "CookieMunchApiError";
|
|
155
|
+
this.status = status;
|
|
156
|
+
if (code !== void 0) this.code = code;
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
function qs(query) {
|
|
160
|
+
if (!query) return "";
|
|
161
|
+
const parts = [];
|
|
162
|
+
for (const [k, v] of Object.entries(query)) {
|
|
163
|
+
if (v !== void 0) parts.push(`${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`);
|
|
164
|
+
}
|
|
165
|
+
return parts.length ? `?${parts.join("&")}` : "";
|
|
166
|
+
}
|
|
167
|
+
function toQuery(q) {
|
|
168
|
+
return q;
|
|
169
|
+
}
|
|
170
|
+
function createCookieMunch(opts) {
|
|
171
|
+
const base = `${opts.baseUrl.replace(/\/+$/, "")}/v1`;
|
|
172
|
+
const doFetch = opts.fetch ?? globalThis.fetch;
|
|
173
|
+
if (!doFetch) throw new Error("No fetch available; pass { fetch } in CookieMunchOptions.");
|
|
174
|
+
async function request(method, path, body, raw = false) {
|
|
175
|
+
const headers = { Authorization: `Bearer ${opts.apiKey}` };
|
|
176
|
+
const init = { method, headers };
|
|
177
|
+
if (body !== void 0) {
|
|
178
|
+
headers["Content-Type"] = "application/json";
|
|
179
|
+
init.body = JSON.stringify(body);
|
|
180
|
+
}
|
|
181
|
+
const res = await doFetch(`${base}${path}`, init);
|
|
182
|
+
if (!res.ok) {
|
|
183
|
+
let message = `request failed with status ${res.status}`;
|
|
184
|
+
let code;
|
|
185
|
+
try {
|
|
186
|
+
const data = await res.json();
|
|
187
|
+
if (typeof data.error === "string") message = data.error;
|
|
188
|
+
if (typeof data.code === "string") code = data.code;
|
|
189
|
+
} catch {
|
|
190
|
+
}
|
|
191
|
+
throw new CookieMunchApiError(res.status, message, code);
|
|
192
|
+
}
|
|
193
|
+
if (res.status === 204) return void 0;
|
|
194
|
+
if (raw) return res.text();
|
|
195
|
+
const contentType = res.headers.get("content-type") ?? "";
|
|
196
|
+
return contentType.includes("application/json") ? res.json() : res.text();
|
|
197
|
+
}
|
|
198
|
+
const get = (p) => request("GET", p);
|
|
199
|
+
const enc = encodeURIComponent;
|
|
200
|
+
return {
|
|
201
|
+
me: () => get("/me"),
|
|
202
|
+
languages: () => get("/languages"),
|
|
203
|
+
orgs: {
|
|
204
|
+
list: () => get("/orgs"),
|
|
205
|
+
create: (name, opts2) => request("POST", "/orgs", { name, ...opts2 ?? {} })
|
|
206
|
+
},
|
|
207
|
+
sites: {
|
|
208
|
+
list: () => get("/sites"),
|
|
209
|
+
create: (input) => request("POST", "/sites", input),
|
|
210
|
+
get: (cbid) => get(`/sites/${enc(cbid)}`),
|
|
211
|
+
delete: async (cbid) => {
|
|
212
|
+
await request("DELETE", `/sites/${enc(cbid)}`);
|
|
213
|
+
},
|
|
214
|
+
getConfig: (cbid) => get(`/sites/${enc(cbid)}/config`),
|
|
215
|
+
putConfig: (cbid, config, opts2) => request("PUT", `/sites/${enc(cbid)}/config${qs({ keep: opts2?.keep })}`, config),
|
|
216
|
+
patchConfig: (cbid, config) => request("PATCH", `/sites/${enc(cbid)}/config`, config),
|
|
217
|
+
dryRunConfig: (cbid, config, opts2) => request(
|
|
218
|
+
opts2?.mode === "put" ? "PUT" : "PATCH",
|
|
219
|
+
`/sites/${enc(cbid)}/config${qs({ dryRun: 1, keep: opts2?.mode === "put" ? opts2.keep : void 0 })}`,
|
|
220
|
+
config
|
|
221
|
+
),
|
|
222
|
+
cookies: (cbid) => get(`/sites/${enc(cbid)}/cookies`),
|
|
223
|
+
scan: (cbid) => request("POST", `/sites/${enc(cbid)}/scan`),
|
|
224
|
+
scanStatus: (cbid) => get(`/sites/${enc(cbid)}/scan`),
|
|
225
|
+
ab: (cbid) => get(`/sites/${enc(cbid)}/ab`),
|
|
226
|
+
policy: (cbid, o) => request(
|
|
227
|
+
"GET",
|
|
228
|
+
`/sites/${enc(cbid)}/policy${qs({ contactEmail: o?.contactEmail, effectiveDate: o?.effectiveDate, jurisdictions: o?.jurisdictions?.join(",") })}`,
|
|
229
|
+
void 0,
|
|
230
|
+
true
|
|
231
|
+
),
|
|
232
|
+
setAdPersonalization: (cbid, input) => request("POST", `/sites/${enc(cbid)}/elements/ad-personalization`, input),
|
|
233
|
+
analyzeSession: (cbid, input) => request("POST", `/sites/${enc(cbid)}/sentry`, input),
|
|
234
|
+
banner: (cbid) => get(`/sites/${enc(cbid)}/banner`),
|
|
235
|
+
blocked: (cbid) => get(`/sites/${enc(cbid)}/blocked`),
|
|
236
|
+
importDeclaration: (cbid, data) => request("POST", `/sites/${enc(cbid)}/import`, { data }),
|
|
237
|
+
applyImport: (cbid, data, o) => request("POST", `/sites/${enc(cbid)}/import${qs({ apply: "1", overwrite: o?.overwrite ? "1" : void 0 })}`, { data }),
|
|
238
|
+
declareCookie: (cbid, name, input) => request("PUT", `/sites/${enc(cbid)}/cookies/${enc(name)}`, input),
|
|
239
|
+
undeclareCookie: async (cbid, name) => {
|
|
240
|
+
await request("DELETE", `/sites/${enc(cbid)}/cookies/${enc(name)}`);
|
|
241
|
+
},
|
|
242
|
+
declareCookies: (cbid, cookies, o) => request("PUT", `/sites/${enc(cbid)}/cookies`, { cookies, ...o?.replace ? { replace: true } : {} }),
|
|
243
|
+
snippet: (cbid, opts2) => get(`/sites/${enc(cbid)}/snippet${qs({ blockingmode: opts2?.blockingMode, culture: opts2?.culture })}`),
|
|
244
|
+
previewToken: (cbid, o) => request("POST", `/sites/${enc(cbid)}/preview-token`, o ?? {}),
|
|
245
|
+
verify: (cbid, method) => request("POST", `/sites/${enc(cbid)}/verify`, { method }),
|
|
246
|
+
verifyChallenge: (cbid) => get(`/sites/${enc(cbid)}/verify/challenge`),
|
|
247
|
+
createBulk: (sites) => request("POST", "/sites/bulk", { sites }),
|
|
248
|
+
brand: (cbid) => request("POST", `/sites/${enc(cbid)}/brand`, {}),
|
|
249
|
+
getFlow: (cbid) => get(`/sites/${enc(cbid)}/flow`),
|
|
250
|
+
editFlow: (cbid, operations) => request("POST", `/sites/${enc(cbid)}/flow/ops`, { operations }),
|
|
251
|
+
setFlow: (cbid, config) => request("PUT", `/sites/${enc(cbid)}/flow`, config)
|
|
252
|
+
},
|
|
253
|
+
consent: {
|
|
254
|
+
verify: (cbid) => get(`/sites/${enc(cbid)}/consent/verify`),
|
|
255
|
+
stats: (cbid, query) => get(`/sites/${enc(cbid)}/consent/stats${qs(toQuery(query))}`),
|
|
256
|
+
log: (cbid, query) => get(`/sites/${enc(cbid)}/consent/log${qs(toQuery(query))}`),
|
|
257
|
+
export: (cbid, query) => request("GET", `/sites/${enc(cbid)}/consent/export${qs(toQuery(query))}`, void 0, true),
|
|
258
|
+
receipt: (cbid, stamp) => get(`/sites/${enc(cbid)}/receipt/${enc(stamp)}`),
|
|
259
|
+
eraseSubject: (cbid, stamp) => request("POST", `/sites/${enc(cbid)}/erase-consent`, { stamp }),
|
|
260
|
+
exportSubject: (cbid, stamp) => request("GET", `/sites/${enc(cbid)}/subject-export?stamp=${enc(stamp)}`),
|
|
261
|
+
ingest: async (input) => {
|
|
262
|
+
const res = await doFetch(`${opts.baseUrl.replace(/\/+$/, "")}/api/v1/consent`, {
|
|
263
|
+
method: "POST",
|
|
264
|
+
headers: { "Content-Type": "application/json" },
|
|
265
|
+
body: JSON.stringify(input)
|
|
266
|
+
});
|
|
267
|
+
if (!res.ok) {
|
|
268
|
+
let message = `consent ingest failed with status ${res.status}`;
|
|
269
|
+
let code;
|
|
270
|
+
try {
|
|
271
|
+
const data = await res.json();
|
|
272
|
+
if (typeof data.error === "string") message = data.error;
|
|
273
|
+
if (typeof data.code === "string") code = data.code;
|
|
274
|
+
} catch {
|
|
275
|
+
}
|
|
276
|
+
throw new CookieMunchApiError(res.status, message, code);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
dsar: {
|
|
281
|
+
list: () => get("/dsar"),
|
|
282
|
+
get: (id) => get(`/dsar/${enc(id)}`),
|
|
283
|
+
create: (input) => request("POST", "/dsar", input),
|
|
284
|
+
advance: (id, toStatus) => request("POST", `/dsar/${enc(id)}/advance`, { toStatus }),
|
|
285
|
+
response: (id) => request("GET", `/dsar/${enc(id)}/response`, void 0, true),
|
|
286
|
+
erase: (id, cbid, stamp) => request("POST", `/dsar/${enc(id)}/erase`, { cbid, stamp }),
|
|
287
|
+
export: (id, cbid, stamp) => request("POST", `/dsar/${enc(id)}/export`, { cbid, stamp }),
|
|
288
|
+
delete: async (id) => {
|
|
289
|
+
await request("DELETE", `/dsar/${enc(id)}`);
|
|
290
|
+
},
|
|
291
|
+
markTest: (id) => request("POST", `/dsar/${enc(id)}/mark-test`)
|
|
292
|
+
},
|
|
293
|
+
vendors: {
|
|
294
|
+
list: () => get("/vendors"),
|
|
295
|
+
create: (input) => request("POST", "/vendors", input)
|
|
296
|
+
},
|
|
297
|
+
ropa: {
|
|
298
|
+
list: () => get("/ropa"),
|
|
299
|
+
create: (input) => request("POST", "/ropa", input),
|
|
300
|
+
exportCsv: () => request("GET", "/ropa/export.csv", void 0, true)
|
|
301
|
+
},
|
|
302
|
+
brandKits: {
|
|
303
|
+
list: () => get("/brand-kits"),
|
|
304
|
+
create: (input) => request("POST", "/brand-kits", input),
|
|
305
|
+
delete: async (id) => {
|
|
306
|
+
await request("DELETE", `/brand-kits/${enc(id)}`);
|
|
307
|
+
}
|
|
308
|
+
},
|
|
309
|
+
identity: {
|
|
310
|
+
resolve: (identifiers) => request("POST", "/identity/resolve", { identifiers }),
|
|
311
|
+
link: (identifiers) => request("POST", "/identity/link", { identifiers }),
|
|
312
|
+
cluster: (subjectId) => get(`/identity/${enc(subjectId)}`)
|
|
313
|
+
},
|
|
314
|
+
vault: {
|
|
315
|
+
record: (identifiers, decisions) => request("POST", "/vault/record", { identifiers, decisions }),
|
|
316
|
+
current: (identifiers) => request("POST", "/vault/current", { identifiers }),
|
|
317
|
+
permits: (identifiers) => request("POST", "/vault/permits", { identifiers })
|
|
318
|
+
},
|
|
319
|
+
profile: {
|
|
320
|
+
get: (identifiers) => request("POST", "/profile/get", { identifiers }),
|
|
321
|
+
setAttributes: (identifiers, attributes) => request("POST", "/profile/attributes", { identifiers, attributes }),
|
|
322
|
+
activate: (identifiers, purpose) => request("POST", "/profile/activate", { identifiers, purpose })
|
|
323
|
+
},
|
|
324
|
+
subscriptions: {
|
|
325
|
+
topics: () => get("/subscriptions/topics"),
|
|
326
|
+
setTopics: (topics) => request("PUT", "/subscriptions/topics", { topics }),
|
|
327
|
+
get: (subjectId) => get(`/subscriptions/${enc(subjectId)}`),
|
|
328
|
+
set: (subjectId, topic, channel, optedIn) => request("PUT", `/subscriptions/${enc(subjectId)}`, { topic, channel, optedIn }),
|
|
329
|
+
unsubscribeAll: (subjectId) => request("POST", `/subscriptions/${enc(subjectId)}/unsubscribe-all`),
|
|
330
|
+
resubscribe: (subjectId) => request("POST", `/subscriptions/${enc(subjectId)}/resubscribe`),
|
|
331
|
+
activation: (subjectId, topics) => request("POST", `/subscriptions/${enc(subjectId)}/activation`, { topics })
|
|
332
|
+
},
|
|
333
|
+
assessments: {
|
|
334
|
+
templates: () => get("/assessments/templates"),
|
|
335
|
+
list: () => get("/assessments"),
|
|
336
|
+
start: (template, subject) => request("POST", "/assessments", { template, subject }),
|
|
337
|
+
get: (id) => get(`/assessments/${enc(id)}`),
|
|
338
|
+
answer: (id, questionId, value) => request("POST", `/assessments/${enc(id)}/answer`, { questionId, value }),
|
|
339
|
+
autoPopulateFromMap: (id) => request("POST", `/assessments/${enc(id)}/autopopulate-from-map`),
|
|
340
|
+
autoPopulate: (id, evidence, source) => request("POST", `/assessments/${enc(id)}/autopopulate`, { evidence, ...source !== void 0 ? { source } : {} }),
|
|
341
|
+
submit: (id) => request("POST", `/assessments/${enc(id)}/submit`),
|
|
342
|
+
approve: (id, by) => request("POST", `/assessments/${enc(id)}/approve`, { by }),
|
|
343
|
+
reject: (id, by, reason) => request("POST", `/assessments/${enc(id)}/reject`, { by, reason })
|
|
344
|
+
},
|
|
345
|
+
discovery: {
|
|
346
|
+
ingestMap: (map) => request("POST", "/discovery/map", { map }),
|
|
347
|
+
getMap: () => get("/discovery/map"),
|
|
348
|
+
ropaDrafts: () => get("/discovery/ropa-drafts"),
|
|
349
|
+
evidence: () => get("/discovery/evidence"),
|
|
350
|
+
drift: () => get("/discovery/drift"),
|
|
351
|
+
planEnforcement: (dialect, rules, opts2) => request("POST", "/discovery/enforcement", {
|
|
352
|
+
dialect,
|
|
353
|
+
rules,
|
|
354
|
+
...opts2?.permitsTable !== void 0 ? { permitsTable: opts2.permitsTable } : {},
|
|
355
|
+
...opts2?.policyPrefix !== void 0 ? { policyPrefix: opts2.policyPrefix } : {}
|
|
356
|
+
})
|
|
357
|
+
},
|
|
358
|
+
regulatory: {
|
|
359
|
+
feed: (jurisdictions) => get(`/regulatory/feed${qs({ jurisdictions: jurisdictions?.join(",") })}`),
|
|
360
|
+
upcoming: (days) => get(`/regulatory/upcoming${qs({ days })}`)
|
|
361
|
+
},
|
|
362
|
+
ai: {
|
|
363
|
+
getPolicy: () => get("/ai/policy"),
|
|
364
|
+
setPolicy: (policy) => request("PUT", "/ai/policy", { policy }),
|
|
365
|
+
inspect: (input) => request("POST", "/ai/inspect", input),
|
|
366
|
+
inventory: () => get("/ai/inventory"),
|
|
367
|
+
lineage: () => get("/ai/lineage"),
|
|
368
|
+
registerSystem: (input) => request("POST", "/ai/systems", input),
|
|
369
|
+
systems: () => get("/ai/systems"),
|
|
370
|
+
audit: (limit) => get(`/ai/audit${qs({ limit })}`)
|
|
371
|
+
},
|
|
372
|
+
fulfillment: {
|
|
373
|
+
sla: () => get("/dsar/sla"),
|
|
374
|
+
plan: (requestId, systems, includeHistorical) => request("POST", `/dsar/${enc(requestId)}/plan`, { systems, ...includeHistorical ? { includeHistorical: true } : {} }),
|
|
375
|
+
status: (requestId) => get(`/dsar/${enc(requestId)}/fulfillment`),
|
|
376
|
+
pendingTasks: (limit) => get(`/dsar/agent/tasks${qs({ limit })}`),
|
|
377
|
+
reportTask: (taskId, ok, error) => request("POST", `/dsar/agent/tasks/${enc(taskId)}/result`, { ok, ...error !== void 0 ? { error } : {} }),
|
|
378
|
+
executors: () => get("/dsar/executors"),
|
|
379
|
+
connectExecutor: (input) => request("POST", "/dsar/executors", input),
|
|
380
|
+
updateExecutor: (id, patch) => request("PATCH", `/dsar/executors/${enc(id)}`, patch),
|
|
381
|
+
disconnectExecutor: async (id) => {
|
|
382
|
+
await request("DELETE", `/dsar/executors/${enc(id)}`);
|
|
383
|
+
},
|
|
384
|
+
taskExport: (requestId, taskId) => get(`/dsar/${enc(requestId)}/tasks/${enc(taskId)}/export`),
|
|
385
|
+
task: (requestId, taskId) => get(`/dsar/${enc(requestId)}/tasks/${enc(taskId)}`),
|
|
386
|
+
testExecutor: (id, input) => request("POST", `/dsar/executors/${enc(id)}/test`, input)
|
|
387
|
+
},
|
|
388
|
+
preferences: {
|
|
389
|
+
list: () => get("/preferences"),
|
|
390
|
+
save: (subjectId, purposes) => request("POST", "/preferences", { subjectId, purposes }),
|
|
391
|
+
get: (subjectId) => get(`/preferences/${enc(subjectId)}`)
|
|
392
|
+
},
|
|
393
|
+
members: {
|
|
394
|
+
list: () => get("/members"),
|
|
395
|
+
invite: (email, role) => request("POST", "/members", { email, role }),
|
|
396
|
+
setRole: (userId, role) => request("PATCH", `/members/${enc(userId)}`, { role }),
|
|
397
|
+
remove: (userId) => request("DELETE", `/members/${enc(userId)}`)
|
|
398
|
+
},
|
|
399
|
+
keys: {
|
|
400
|
+
list: () => get("/keys"),
|
|
401
|
+
issue: (input) => request("POST", "/keys", input ?? {}),
|
|
402
|
+
revoke: async (prefix) => {
|
|
403
|
+
await request("DELETE", `/keys/${enc(prefix)}`);
|
|
404
|
+
},
|
|
405
|
+
roll: (prefix) => request("POST", `/keys/${enc(prefix)}/roll`),
|
|
406
|
+
update: (prefix, patch) => request("PATCH", `/keys/${enc(prefix)}`, patch)
|
|
407
|
+
},
|
|
408
|
+
usage: () => get("/usage"),
|
|
409
|
+
org: {
|
|
410
|
+
get: () => get("/org"),
|
|
411
|
+
update: (patch) => request("PATCH", "/org", patch)
|
|
412
|
+
},
|
|
413
|
+
audit: (limit) => get(`/audit${qs({ limit })}`),
|
|
414
|
+
assets: {
|
|
415
|
+
upload: (input) => request("POST", "/assets", input),
|
|
416
|
+
delete: async (urlOrFileName) => {
|
|
417
|
+
const name = urlOrFileName.split("/").pop() ?? urlOrFileName;
|
|
418
|
+
await request("DELETE", `/assets/${enc(name)}`);
|
|
419
|
+
}
|
|
420
|
+
},
|
|
421
|
+
reseller: {
|
|
422
|
+
list: () => get("/reseller/customers"),
|
|
423
|
+
create: (input) => request("POST", "/reseller/customers", input),
|
|
424
|
+
get: (id) => get(`/reseller/customers/${enc(id)}`),
|
|
425
|
+
update: (id, patch) => request("PATCH", `/reseller/customers/${enc(id)}`, patch),
|
|
426
|
+
deprovision: async (id, o) => {
|
|
427
|
+
await request("DELETE", `/reseller/customers/${enc(id)}${qs({ purge: o?.purge ? "true" : void 0 })}`);
|
|
428
|
+
},
|
|
429
|
+
listKeys: (id) => get(`/reseller/customers/${enc(id)}/keys`),
|
|
430
|
+
mintKey: (id, input) => request("POST", `/reseller/customers/${enc(id)}/keys`, input ?? {}),
|
|
431
|
+
revokeKey: async (id, prefix) => {
|
|
432
|
+
await request("DELETE", `/reseller/customers/${enc(id)}/keys/${enc(prefix)}`);
|
|
433
|
+
}
|
|
434
|
+
},
|
|
435
|
+
webhooks: {
|
|
436
|
+
list: () => get("/webhooks"),
|
|
437
|
+
create: (input) => request("POST", "/webhooks", input),
|
|
438
|
+
update: (id, patch) => request("PATCH", `/webhooks/${enc(id)}`, patch),
|
|
439
|
+
delete: async (id) => {
|
|
440
|
+
await request("DELETE", `/webhooks/${enc(id)}`);
|
|
441
|
+
},
|
|
442
|
+
rollSecret: (id) => request("POST", `/webhooks/${enc(id)}/roll`),
|
|
443
|
+
test: (id) => request("POST", `/webhooks/${enc(id)}/test`),
|
|
444
|
+
deadLetters: () => get("/webhooks/dead-letters"),
|
|
445
|
+
replayDeadLetter: (id) => request("POST", `/webhooks/dead-letters/${enc(id)}/replay`)
|
|
446
|
+
},
|
|
447
|
+
subjects: {
|
|
448
|
+
consent: (subjectId) => get(`/subjects/${enc(subjectId)}/consent`)
|
|
449
|
+
},
|
|
450
|
+
banners: {
|
|
451
|
+
list: () => get("/banners"),
|
|
452
|
+
create: (input) => request("POST", "/banners", input),
|
|
453
|
+
get: (id) => get(`/banners/${enc(id)}`),
|
|
454
|
+
update: (id, patch) => request("PUT", `/banners/${enc(id)}`, patch),
|
|
455
|
+
delete: async (id) => {
|
|
456
|
+
await request("DELETE", `/banners/${enc(id)}`);
|
|
457
|
+
},
|
|
458
|
+
assignments: (id) => get(`/banners/${enc(id)}/assignments`),
|
|
459
|
+
setAssignments: (id, cbids) => request("PUT", `/banners/${enc(id)}/assignments`, { cbids }),
|
|
460
|
+
publish: (id) => request("POST", `/banners/${enc(id)}/publish`)
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
465
|
+
0 && (module.exports = {
|
|
466
|
+
CONSENT_COOKIE_NAME,
|
|
467
|
+
CookieMunchApiError,
|
|
468
|
+
createCookieMunch,
|
|
469
|
+
getConsent,
|
|
470
|
+
isAllowed,
|
|
471
|
+
parseConsentValue,
|
|
472
|
+
readConsent,
|
|
473
|
+
verifyWebhookSignature
|
|
474
|
+
});
|
|
475
|
+
//# sourceMappingURL=index.cjs.map
|