@cookiemunch/sdk 0.3.0 → 0.4.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/dist/index.js CHANGED
@@ -27,6 +27,7 @@ function verifyWebhookSignature(input) {
27
27
  }
28
28
 
29
29
  // src/index.ts
30
+ var SDK_VERSION = "0.4.1";
30
31
  var CookieMunchApiError = class extends Error {
31
32
  constructor(status, message, code, body) {
32
33
  super(message);
@@ -53,7 +54,8 @@ function createCookieMunch(opts) {
53
54
  const doFetch = opts.fetch ?? globalThis.fetch;
54
55
  if (!doFetch) throw new Error("No fetch available; pass { fetch } in CookieMunchOptions.");
55
56
  async function request(method, path, body, raw = false) {
56
- const headers = { Authorization: `Bearer ${opts.apiKey}` };
57
+ const headers = { Authorization: `Bearer ${opts.apiKey}`, "User-Agent": opts.userAgent ?? `cookiemunch-js/${SDK_VERSION}` };
58
+ if (opts.strictUnknownFields && method !== "GET") headers["Prefer"] = "strict-unknown-fields";
57
59
  const init = { method, headers };
58
60
  if (body !== void 0) {
59
61
  headers["Content-Type"] = "application/json";
@@ -91,9 +93,13 @@ function createCookieMunch(opts) {
91
93
  list: () => get("/sites"),
92
94
  create: (input) => request("POST", "/sites", input),
93
95
  get: (cbid) => get(`/sites/${enc(cbid)}`),
96
+ update: (cbid, patch, o) => request("PATCH", `/sites/${enc(cbid)}${qs({ dryRun: o?.dryRun ? "1" : void 0 })}`, patch),
94
97
  delete: async (cbid) => {
95
98
  await request("DELETE", `/sites/${enc(cbid)}`);
96
99
  },
100
+ listPartners: (cbid) => get(`/sites/${enc(cbid)}/partners`),
101
+ linkPartner: (cbid, input, o) => request("POST", `/sites/${enc(cbid)}/partners${qs({ dryRun: o?.dryRun ? "1" : void 0 })}`, input),
102
+ unlinkPartner: (cbid, linkId) => request("DELETE", `/sites/${enc(cbid)}/partners/${enc(linkId)}`),
97
103
  getConfig: (cbid) => get(`/sites/${enc(cbid)}/config`),
98
104
  putConfig: (cbid, config, opts2) => request("PUT", `/sites/${enc(cbid)}/config${qs({ keep: opts2?.keep })}`, config),
99
105
  patchConfig: (cbid, config) => request("PATCH", `/sites/${enc(cbid)}/config`, config),
@@ -137,6 +143,14 @@ function createCookieMunch(opts) {
137
143
  const out = await request("DELETE", `/sites/${enc(cbid)}/cookies/${enc(name)}/retire${qs({ dryRun: o?.dryRun ? "1" : void 0 })}`);
138
144
  return o?.dryRun ? out : void 0;
139
145
  }),
146
+ cookiePresets: (cbid) => get(`/sites/${enc(cbid)}/cookies/presets`),
147
+ applyCookiePreset: (cbid, vendor, params, o) => request("PUT", `/sites/${enc(cbid)}/cookies/presets/${enc(vendor)}${qs({ dryRun: o?.dryRun ? "1" : void 0 })}`, params ?? {}),
148
+ removeCookiePreset: (cbid, vendor, o) => request("DELETE", `/sites/${enc(cbid)}/cookies/presets/${enc(vendor)}${qs({ dryRun: o?.dryRun ? "1" : void 0 })}`),
149
+ deleteObservedCookie: (async (cbid, name, o) => {
150
+ const out = await request("DELETE", `/sites/${enc(cbid)}/observed-cookies/${enc(name)}${qs({ dryRun: o?.dryRun ? "1" : void 0 })}`);
151
+ return o?.dryRun ? out : void 0;
152
+ }),
153
+ purgeObservedCookies: (cbid, input, o) => request("POST", `/sites/${enc(cbid)}/observed-cookies/purge${qs({ dryRun: o?.dryRun ? "1" : void 0 })}`, input),
140
154
  undeclareCookie: (async (cbid, name, o) => {
141
155
  const out = await request("DELETE", `/sites/${enc(cbid)}/cookies/${enc(name)}${qs({ dryRun: o?.dryRun ? "1" : void 0 })}`);
142
156
  return o?.dryRun ? out : void 0;
@@ -183,7 +197,7 @@ function createCookieMunch(opts) {
183
197
  list: () => get("/dsar"),
184
198
  get: (id) => get(`/dsar/${enc(id)}`),
185
199
  create: (input) => request("POST", "/dsar", input),
186
- advance: (id, toStatus) => request("POST", `/dsar/${enc(id)}/advance`, { toStatus }),
200
+ advance: (id, toStatus, opts2) => request("POST", `/dsar/${enc(id)}/advance`, { toStatus, ...opts2?.messageToSubject !== void 0 ? { messageToSubject: opts2.messageToSubject } : {} }),
187
201
  response: (id) => request("GET", `/dsar/${enc(id)}/response`, void 0, true),
188
202
  erase: (id, cbid, stamp) => request("POST", `/dsar/${enc(id)}/erase`, { cbid, stamp }),
189
203
  export: (id, cbid, stamp) => request("POST", `/dsar/${enc(id)}/export`, { cbid, stamp }),
@@ -297,6 +311,9 @@ function createCookieMunch(opts) {
297
311
  connectExecutor: (input) => request("POST", "/dsar/executors", input),
298
312
  updateExecutor: (id, patch) => request("PATCH", `/dsar/executors/${enc(id)}`, patch),
299
313
  dryRunConnectExecutor: (input) => request("POST", "/dsar/executors?dryRun=1", input),
314
+ executorPresets: () => get("/dsar/executors/presets"),
315
+ upgradeExecutorPreset: (id, input = {}) => request("POST", `/dsar/executors/${enc(id)}/upgrade-preset`, input),
316
+ dryRunUpgradeExecutorPreset: (id, input = {}) => request("POST", `/dsar/executors/${enc(id)}/upgrade-preset?dryRun=1`, input),
300
317
  dryRunUpdateExecutor: (id, patch) => request("PATCH", `/dsar/executors/${enc(id)}?dryRun=1`, patch),
301
318
  testExecutorWebhook: (id, delivery) => request("POST", `/dsar/executors/${enc(id)}/webhook/test`, delivery),
302
319
  executorWebhookDeliveries: (id) => get(`/dsar/executors/${enc(id)}/webhook/deliveries`),
@@ -325,9 +342,12 @@ function createCookieMunch(opts) {
325
342
  await request("DELETE", `/keys/${enc(prefix)}`);
326
343
  },
327
344
  roll: (prefix) => request("POST", `/keys/${enc(prefix)}/roll`),
328
- update: (prefix, patch) => request("PATCH", `/keys/${enc(prefix)}`, patch)
345
+ update: (prefix, patch) => request("PATCH", `/keys/${enc(prefix)}`, patch),
346
+ report: (o) => get(`/keys/report${qs({ unusedDays: o?.unusedDays, expiringDays: o?.expiringDays })}`)
329
347
  },
330
348
  usage: () => get("/usage"),
349
+ integrationHealth: (cbid) => get(`/integration-health${qs({ cbid })}`),
350
+ provision: (input, o) => request("POST", `/provision${qs({ dryRun: o?.dryRun ? "1" : void 0 })}`, input),
331
351
  org: {
332
352
  get: () => get("/org"),
333
353
  update: (patch) => request("PATCH", "/org", patch),
@@ -417,6 +437,7 @@ function createCookieMunch(opts) {
417
437
  export {
418
438
  CONSENT_COOKIE_NAME,
419
439
  CookieMunchApiError,
440
+ SDK_VERSION,
420
441
  createCookieMunch,
421
442
  getConsent,
422
443
  isAllowed,