@cookiemunch/sdk 0.10.0 → 0.12.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 +12 -0
- package/dist/index.cjs +11 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +160 -8
- package/dist/index.js +11 -2
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +78 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -14,13 +14,13 @@ export * from './consent-sync.js';
|
|
|
14
14
|
export * from './executor-conformance.js';
|
|
15
15
|
export * from './token-exchange.js';
|
|
16
16
|
export type * from './fd-consent.js';
|
|
17
|
-
import type { CategoryRegistry, Identity, AccountOrgs, Site, SiteCreate, SiteConfig, SiteUpdate, SiteUpdateResult, IntegrationHealthReport, HealthWaiver, HealthWaiverInput, ProvisionRequest, ProvisionResult, PartnerLink, PartnerLinkCreate, PartnerCatalogEntry, ConsentDay, ConsentLogRow, RangeQuery, LogQuery, DsarRequest, DsarCreate, DsarCase, DsarCaseCreate, DsarCaseReceipt, DsarSettings, SubjectCard, IntegrationConnect, IntegrationConnectResult, DsarStatus, ScoredVendor, VendorInput, VendorRecord, RiskScore, RopaEntry, RopaInput, SignedReceipt, PreferenceRecord } from './types.js';
|
|
17
|
+
import type { CategoryRegistry, Identity, AccountOrgs, Site, SiteCreate, SiteConfig, SiteUpdate, SiteUpdateResult, IntegrationHealthReport, HealthWaiver, HealthWaiverInput, ProvisionRequest, ProvisionResult, PartnerLink, PartnerLinkCreate, PartnerCatalogEntry, ConsentDay, ConsentLogRow, RangeQuery, LogQuery, DsarRequest, DsarCreate, DsarCase, DsarCaseCreate, DsarCaseReceipt, DsarSettings, DsarSettingsInput, SubjectCard, IntegrationConnect, IntegrationConnectResult, DsarStatus, ScoredVendor, VendorInput, VendorRecord, RiskScore, RopaEntry, RopaInput, SignedReceipt, PreferenceRecord } from './types.js';
|
|
18
18
|
import type { ConformanceReport } from './executor-conformance.js';
|
|
19
19
|
/**
|
|
20
20
|
* This package's version, sent in the default User-Agent. Cloudflare answers a request with
|
|
21
21
|
* no recognisable User-Agent with `403 error code: 1010`; a test pins this to package.json.
|
|
22
22
|
*/
|
|
23
|
-
export declare const SDK_VERSION = "0.
|
|
23
|
+
export declare const SDK_VERSION = "0.12.0";
|
|
24
24
|
export interface CookieMunchOptions {
|
|
25
25
|
apiKey: string;
|
|
26
26
|
/** "https://api.cookiemunch.net" — the /v1 prefix is appended automatically. */
|
|
@@ -334,6 +334,51 @@ export interface DeclaredCookie extends DeclaredCookieInput {
|
|
|
334
334
|
source?: 'import';
|
|
335
335
|
/** The vendor whose preset declared it. */
|
|
336
336
|
vendor?: string;
|
|
337
|
+
/** The `purposes` languages that are machine translations (sites.translateCookies); absent = all human-written. */
|
|
338
|
+
machinePurposes?: string[];
|
|
339
|
+
}
|
|
340
|
+
/** GET/PUT/DELETE /v1/sites/:cbid/translation — the site's own translation account. Never the key. */
|
|
341
|
+
export interface TranslationConnection {
|
|
342
|
+
cbid: string;
|
|
343
|
+
connected: boolean;
|
|
344
|
+
provider: 'deepl' | 'google' | null;
|
|
345
|
+
keyLast4: string | null;
|
|
346
|
+
/** First 12 hex of SHA-256(key). */
|
|
347
|
+
keyFingerprint: string | null;
|
|
348
|
+
connectedAt: number | null;
|
|
349
|
+
/** On connect only: whether the key was checked with the provider first. */
|
|
350
|
+
verified?: boolean;
|
|
351
|
+
}
|
|
352
|
+
/** POST /v1/sites/:cbid/cookies/translate */
|
|
353
|
+
export interface CookieTranslateResult {
|
|
354
|
+
dryRun: boolean;
|
|
355
|
+
provider: 'deepl' | 'google' | null;
|
|
356
|
+
languages: string[];
|
|
357
|
+
/** Languages the provider cannot translate into. Reported, not a failure. */
|
|
358
|
+
unsupported: Array<{
|
|
359
|
+
language: string;
|
|
360
|
+
reason: string;
|
|
361
|
+
}>;
|
|
362
|
+
/** Languages whose provider call failed; nothing was stored for them. */
|
|
363
|
+
failed: Array<{
|
|
364
|
+
language: string;
|
|
365
|
+
error: string;
|
|
366
|
+
}>;
|
|
367
|
+
characters: number;
|
|
368
|
+
translated: number;
|
|
369
|
+
rows: number;
|
|
370
|
+
/** `text` is absent on a dry run. */
|
|
371
|
+
changes: Array<{
|
|
372
|
+
name: string;
|
|
373
|
+
language: string;
|
|
374
|
+
source: string;
|
|
375
|
+
text?: string;
|
|
376
|
+
}>;
|
|
377
|
+
skipped: Array<{
|
|
378
|
+
name: string;
|
|
379
|
+
language: string;
|
|
380
|
+
reason: string;
|
|
381
|
+
}>;
|
|
337
382
|
}
|
|
338
383
|
/** A platform whose cookies and storage a preset declares. */
|
|
339
384
|
export type CookiePresetVendor = 'atlas' | 'forumulate' | 'chatly' | 'cookiemunch' | 'referalli' | 'firstpromoter' | 'partnerstack' | 'tapfiliate' | 'impact'
|
|
@@ -708,6 +753,33 @@ export interface ConfigChange {
|
|
|
708
753
|
export interface PutConfigOptions {
|
|
709
754
|
keep?: 'unspecified';
|
|
710
755
|
}
|
|
756
|
+
/** What `POST /v1/dsar?dryRun=1` would do: nothing was filed, and no connected system was contacted. */
|
|
757
|
+
export interface DsarCreateDryRun {
|
|
758
|
+
dryRun: true;
|
|
759
|
+
/** The connections auto-planning would open a task on once the request is verified. */
|
|
760
|
+
plan: Array<{
|
|
761
|
+
id: string;
|
|
762
|
+
system: string;
|
|
763
|
+
preset?: string;
|
|
764
|
+
op: 'export' | 'erase' | 'optOut';
|
|
765
|
+
reached: true;
|
|
766
|
+
requireApproval?: true;
|
|
767
|
+
}>;
|
|
768
|
+
skipped: Array<{
|
|
769
|
+
system: string;
|
|
770
|
+
reason: string;
|
|
771
|
+
}>;
|
|
772
|
+
status: 'received';
|
|
773
|
+
verificationRequired: true;
|
|
774
|
+
/** The deadline it would get (epoch ms). */
|
|
775
|
+
dueAt: number;
|
|
776
|
+
/** On a processor site: the controller it would be forwarded to (`plan` and `skipped` are then empty). */
|
|
777
|
+
forwardTo?: {
|
|
778
|
+
controllerId: string;
|
|
779
|
+
name: string;
|
|
780
|
+
kind: 'cookiemunch' | 'webhook' | 'refer';
|
|
781
|
+
};
|
|
782
|
+
}
|
|
711
783
|
/** What a config write would do (`?dryRun=1`) — nothing is saved. */
|
|
712
784
|
export interface ConfigDryRun {
|
|
713
785
|
dryRun: true;
|
|
@@ -1167,6 +1239,24 @@ export interface ApiKeyPrefix {
|
|
|
1167
1239
|
/** The dated API version this key is pinned to. */
|
|
1168
1240
|
apiVersion?: string;
|
|
1169
1241
|
}
|
|
1242
|
+
/** A signed audit-anchor receipt (POST /v1/anchors). Verify `signature` (Ed25519, base64url) over the canonical JSON of every other field with the key `keyId` in /v1/partner/jwks.json. */
|
|
1243
|
+
export interface AnchorReceipt {
|
|
1244
|
+
id: string;
|
|
1245
|
+
org: string;
|
|
1246
|
+
stream: string;
|
|
1247
|
+
head: string;
|
|
1248
|
+
seq: number;
|
|
1249
|
+
receivedAt: string;
|
|
1250
|
+
keyId: string;
|
|
1251
|
+
alg: 'EdDSA';
|
|
1252
|
+
signature: string;
|
|
1253
|
+
}
|
|
1254
|
+
/** GET /v1/anchors/{stream}: newest first; pass `nextBefore` as `before` until it is null. */
|
|
1255
|
+
export interface AnchorList {
|
|
1256
|
+
stream: string;
|
|
1257
|
+
anchors: AnchorReceipt[];
|
|
1258
|
+
nextBefore: number | null;
|
|
1259
|
+
}
|
|
1170
1260
|
/** A live organisation's sandbox (GET /v1/sandbox). */
|
|
1171
1261
|
export interface SandboxOrg {
|
|
1172
1262
|
orgId: string;
|
|
@@ -2189,6 +2279,8 @@ export interface ExecutorHealth {
|
|
|
2189
2279
|
code?: string;
|
|
2190
2280
|
/** When a check last passed. */
|
|
2191
2281
|
lastSuccessAt?: number;
|
|
2282
|
+
/** The `X-Version` the system last answered with. */
|
|
2283
|
+
version?: string;
|
|
2192
2284
|
/** On reads: true when the last check is more than an hour old, with the command that re-checks it in `hint`. */
|
|
2193
2285
|
stale?: boolean;
|
|
2194
2286
|
hint?: string;
|
|
@@ -2746,6 +2838,30 @@ export interface CookieMunchClient {
|
|
|
2746
2838
|
}, opts?: {
|
|
2747
2839
|
dryRun?: boolean;
|
|
2748
2840
|
}): Promise<CookieSuggestionsDeclared>;
|
|
2841
|
+
/** The site's own translation account (DeepL or Google) for translateCookies. Never the key. */
|
|
2842
|
+
translation(cbid: string): Promise<TranslationConnection>;
|
|
2843
|
+
/**
|
|
2844
|
+
* Connect the site's own DeepL or Google Cloud Translation key (stored sealed, never returned).
|
|
2845
|
+
* `verify` checks it with the provider first, sending no text.
|
|
2846
|
+
*/
|
|
2847
|
+
connectTranslation(cbid: string, input: {
|
|
2848
|
+
provider: 'deepl' | 'google';
|
|
2849
|
+
key: string;
|
|
2850
|
+
}, opts?: {
|
|
2851
|
+
verify?: boolean;
|
|
2852
|
+
}): Promise<TranslationConnection>;
|
|
2853
|
+
/** Disconnect it; translations already stored stay. */
|
|
2854
|
+
disconnectTranslation(cbid: string): Promise<TranslationConnection>;
|
|
2855
|
+
/**
|
|
2856
|
+
* Machine-translate the missing `purposes` of the site's own declarations on its connected
|
|
2857
|
+
* account. Never overwrites text a row has. `dryRun` lists the changes and calls no provider.
|
|
2858
|
+
*/
|
|
2859
|
+
translateCookies(cbid: string, input?: {
|
|
2860
|
+
languages?: string[];
|
|
2861
|
+
names?: string[];
|
|
2862
|
+
}, opts?: {
|
|
2863
|
+
dryRun?: boolean;
|
|
2864
|
+
}): Promise<CookieTranslateResult>;
|
|
2749
2865
|
/** Remove every declaration a vendor preset made. */
|
|
2750
2866
|
removeCookiePreset(cbid: string, vendor: CookiePresetVendor | (string & {}), opts?: {
|
|
2751
2867
|
dryRun?: boolean;
|
|
@@ -2779,7 +2895,7 @@ export interface CookieMunchClient {
|
|
|
2779
2895
|
dryRun: true;
|
|
2780
2896
|
}): Promise<DeclarationDryRun>;
|
|
2781
2897
|
/**
|
|
2782
|
-
* Declare many at once (all-or-nothing). `replace` also removes declarations not listed;
|
|
2898
|
+
* Declare many at once (all-or-nothing). `replace` also removes your own declarations not listed (vendor-preset rows stay);
|
|
2783
2899
|
* `dryRun` answers with what would be stored and a diff, storing nothing.
|
|
2784
2900
|
*/
|
|
2785
2901
|
declareCookies(cbid: string, cookies: Array<DeclaredCookieInput & {
|
|
@@ -2866,8 +2982,26 @@ export interface CookieMunchClient {
|
|
|
2866
2982
|
* wrapped as `{ request }`, so `create(...).request.id` is what you pass here.
|
|
2867
2983
|
*/
|
|
2868
2984
|
get(id: string): Promise<DsarRequest>;
|
|
2869
|
-
|
|
2985
|
+
/**
|
|
2986
|
+
* `skipped`: connections scoped to another property (or to one, when the request names none), never planned for it.
|
|
2987
|
+
* `{ dryRun: true }` files nothing and contacts no connected system: it answers which connections the request would
|
|
2988
|
+
* reach once verified (`plan`) and which it would skip.
|
|
2989
|
+
*/
|
|
2990
|
+
create(input: DsarCreate & ResourceTagsInput, opts: {
|
|
2991
|
+
dryRun: true;
|
|
2992
|
+
}): Promise<DsarCreateDryRun>;
|
|
2993
|
+
create(input: DsarCreate & ResourceTagsInput, opts?: {
|
|
2994
|
+
dryRun?: false;
|
|
2995
|
+
}): Promise<{
|
|
2870
2996
|
request: DsarRequest;
|
|
2997
|
+
consent?: {
|
|
2998
|
+
count: number;
|
|
2999
|
+
sites: string[];
|
|
3000
|
+
};
|
|
3001
|
+
skipped?: Array<{
|
|
3002
|
+
system: string;
|
|
3003
|
+
reason: string;
|
|
3004
|
+
}>;
|
|
2871
3005
|
}>;
|
|
2872
3006
|
/** `opts.messageToSubject` replaces the line the subject reads in the notice — for a rejection, why. */
|
|
2873
3007
|
advance(id: string, toStatus: DsarStatus, opts?: {
|
|
@@ -2904,7 +3038,7 @@ export interface CookieMunchClient {
|
|
|
2904
3038
|
/** Requests carrying one X-Trace-Id (`GET /v1/dsar?trace=`). */
|
|
2905
3039
|
listByTrace(trace: string): Promise<DsarRequest[]>;
|
|
2906
3040
|
/** Requests with one origin (`GET /v1/dsar?origin=`): `account_deletion`, those a person's own account deletion opened. */
|
|
2907
|
-
listByOrigin(origin: 'account_deletion'): Promise<DsarRequest[]>;
|
|
3041
|
+
listByOrigin(origin: 'account_deletion' | 'processor_forward'): Promise<DsarRequest[]>;
|
|
2908
3042
|
/**
|
|
2909
3043
|
* Open a case fanned out to every connected system (POST /v1/dsar/requests). `opts.idempotencyKey`
|
|
2910
3044
|
* (16–128 chars) makes a retry answer the same case; `opts.trace` passes your X-Trace-Id on.
|
|
@@ -3334,6 +3468,26 @@ export interface CookieMunchClient {
|
|
|
3334
3468
|
versions(): Promise<ApiVersions>;
|
|
3335
3469
|
/** What the org may use: every plan feature (`whiteLabel`, `tcf`, …) and limit, in the suite-standard shape. Any key may read it. */
|
|
3336
3470
|
entitlements(): Promise<Entitlements>;
|
|
3471
|
+
/**
|
|
3472
|
+
* Audit anchoring: post the head of your own hash-chained log and get a receipt signed by Cookie Munch's
|
|
3473
|
+
* platform key. `seq` must strictly increase per stream; the same seq and head again returns the original
|
|
3474
|
+
* receipt, a different head for an anchored seq is a 409 (`anchor_head_mismatch`). Needs `anchors:write` / `anchors:read`.
|
|
3475
|
+
*/
|
|
3476
|
+
anchors: {
|
|
3477
|
+
/** Anchor `head` at `seq` on `stream` (POST /v1/anchors). */
|
|
3478
|
+
create(input: {
|
|
3479
|
+
stream: string;
|
|
3480
|
+
head: string;
|
|
3481
|
+
seq: number;
|
|
3482
|
+
}): Promise<AnchorReceipt>;
|
|
3483
|
+
/** A stream's receipts, newest first (GET /v1/anchors/{stream}). */
|
|
3484
|
+
list(stream: string, query?: {
|
|
3485
|
+
limit?: number;
|
|
3486
|
+
before?: number;
|
|
3487
|
+
}): Promise<AnchorList>;
|
|
3488
|
+
/** One receipt (GET /v1/anchors/{stream}/{id}). */
|
|
3489
|
+
get(stream: string, id: string): Promise<AnchorReceipt>;
|
|
3490
|
+
};
|
|
3337
3491
|
/**
|
|
3338
3492
|
* The organisation's sandbox: a separate test organisation with the same people and plan features, never billed.
|
|
3339
3493
|
* Its keys are test-format keys and its rights requests are all tests. `create` and `delete` need an unscoped key or `orgs:create`.
|
|
@@ -3543,9 +3697,7 @@ export interface CookieMunchClient {
|
|
|
3543
3697
|
/** A site's rights-request settings: graceDays (0–30; 7 for a new site, 0 until set for one that existed before). Requires dsar:read / dsar:write. */
|
|
3544
3698
|
dsarSettings: {
|
|
3545
3699
|
get(cbid: string): Promise<DsarSettings>;
|
|
3546
|
-
set(cbid: string, input:
|
|
3547
|
-
graceDays: number;
|
|
3548
|
-
}): Promise<DsarSettings>;
|
|
3700
|
+
set(cbid: string, input: DsarSettingsInput): Promise<DsarSettings>;
|
|
3549
3701
|
};
|
|
3550
3702
|
/** Cards for support, CRM and helpdesk sidebars (dsar:read), and one-call identity-provider connect (dsar:write). */
|
|
3551
3703
|
integrations: {
|
package/dist/index.js
CHANGED
|
@@ -88,7 +88,7 @@ async function exchangeOperatorToken(input) {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
// src/index.ts
|
|
91
|
-
var SDK_VERSION = "0.
|
|
91
|
+
var SDK_VERSION = "0.12.0";
|
|
92
92
|
var CookieMunchApiError = class extends Error {
|
|
93
93
|
constructor(status, message, code, body) {
|
|
94
94
|
super(message);
|
|
@@ -243,6 +243,10 @@ function createCookieMunch(opts) {
|
|
|
243
243
|
importCookieManifest: (cbid, input, o) => request("PUT", `/sites/${enc(cbid)}/cookies/presets/custom${qs({ dryRun: o?.dryRun ? "1" : void 0 })}`, input),
|
|
244
244
|
cookieSuggestions: (cbid) => get(`/sites/${enc(cbid)}/cookies/suggestions`),
|
|
245
245
|
declareCookieSuggestions: (cbid, input, o) => request("POST", `/sites/${enc(cbid)}/cookies/suggestions/declare${qs({ dryRun: o?.dryRun ? "1" : void 0 })}`, input ?? {}),
|
|
246
|
+
translation: (cbid) => get(`/sites/${enc(cbid)}/translation`),
|
|
247
|
+
connectTranslation: (cbid, input, o) => request("PUT", `/sites/${enc(cbid)}/translation${qs({ verify: o?.verify ? "1" : void 0 })}`, input),
|
|
248
|
+
disconnectTranslation: (cbid) => request("DELETE", `/sites/${enc(cbid)}/translation`),
|
|
249
|
+
translateCookies: (cbid, input, o) => request("POST", `/sites/${enc(cbid)}/cookies/translate${qs({ dryRun: o?.dryRun ? "1" : void 0 })}`, input ?? {}),
|
|
246
250
|
removeCookiePreset: (cbid, vendor, o) => request("DELETE", `/sites/${enc(cbid)}/cookies/presets/${enc(vendor)}${qs({ dryRun: o?.dryRun ? "1" : void 0 })}`),
|
|
247
251
|
deleteObservedCookie: (async (cbid, name, o) => {
|
|
248
252
|
const out = await request("DELETE", `/sites/${enc(cbid)}/observed-cookies/${enc(name)}${qs({ dryRun: o?.dryRun ? "1" : void 0 })}`);
|
|
@@ -298,7 +302,7 @@ function createCookieMunch(opts) {
|
|
|
298
302
|
dsar: {
|
|
299
303
|
list: () => get("/dsar"),
|
|
300
304
|
get: (id) => get(`/dsar/${enc(id)}`),
|
|
301
|
-
create: (input) => request("POST",
|
|
305
|
+
create: ((input, o) => request("POST", `/dsar${qs({ dryRun: o?.dryRun ? "1" : void 0 })}`, input)),
|
|
302
306
|
advance: (id, toStatus, opts2) => request("POST", `/dsar/${enc(id)}/advance`, { toStatus, ...opts2?.messageToSubject !== void 0 ? { messageToSubject: opts2.messageToSubject } : {} }),
|
|
303
307
|
response: (id) => request("GET", `/dsar/${enc(id)}/response`, void 0, true),
|
|
304
308
|
erase: (id, cbid, stamp) => request("POST", `/dsar/${enc(id)}/erase`, { cbid, stamp }),
|
|
@@ -477,6 +481,11 @@ function createCookieMunch(opts) {
|
|
|
477
481
|
usage: () => get("/usage"),
|
|
478
482
|
entitlements: () => get("/entitlements"),
|
|
479
483
|
versions: () => get("/versions"),
|
|
484
|
+
anchors: {
|
|
485
|
+
create: (input) => request("POST", "/anchors", input),
|
|
486
|
+
list: (stream, query) => get(`/anchors/${enc(stream)}${qs(query)}`),
|
|
487
|
+
get: (stream, id) => get(`/anchors/${enc(stream)}/${enc(id)}`)
|
|
488
|
+
},
|
|
480
489
|
sandbox: {
|
|
481
490
|
get: async () => (await get("/sandbox")).sandbox,
|
|
482
491
|
create: (input) => request("POST", "/sandbox", input ?? {}),
|