@cookiemunch/sdk 0.37.0 → 0.39.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 +17 -0
- package/dist/index.cjs +19 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +172 -6
- package/dist/index.js +19 -2
- package/dist/index.js.map +1 -1
- package/dist/rights.cjs +88 -17
- package/dist/rights.cjs.map +1 -1
- package/dist/rights.d.ts +58 -3
- package/dist/rights.js +85 -17
- package/dist/rights.js.map +1 -1
- package/dist/types.d.ts +14 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ import type { ConformanceReport } from './executor-conformance.js';
|
|
|
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.39.0";
|
|
24
24
|
export interface CookieMunchOptions {
|
|
25
25
|
apiKey: string;
|
|
26
26
|
/** "https://api.cookiemunch.net" — the /v1 prefix is appended automatically. */
|
|
@@ -840,6 +840,8 @@ export interface AbResult {
|
|
|
840
840
|
export interface InstallSnippet {
|
|
841
841
|
/** The exact `<script>` tag to paste into `<head>`. */
|
|
842
842
|
snippet: string;
|
|
843
|
+
/** The same tag as attributes, in order and unescaped: set exactly these on a `<script>` your loader creates. */
|
|
844
|
+
attributes: Record<string, string>;
|
|
843
845
|
/** URL of the consent.js embed file (the embed/CDN origin). */
|
|
844
846
|
src: string;
|
|
845
847
|
/** The API origin (beacons + consent-tcf.js). Present when the server reports it. */
|
|
@@ -938,12 +940,110 @@ export interface DsarCreateDryRun {
|
|
|
938
940
|
};
|
|
939
941
|
}
|
|
940
942
|
/** What a config write would do (`?dryRun=1`) — nothing is saved. */
|
|
943
|
+
/** A tenant: a site for one of your customers, who is the controller for its own visitors (POST /v1/sites/{cbid}/tenants). */
|
|
944
|
+
export interface Tenant {
|
|
945
|
+
tenantCbid: string;
|
|
946
|
+
cbid: string;
|
|
947
|
+
/** The parent site's cbid. */
|
|
948
|
+
parent: string;
|
|
949
|
+
/** Your id for this customer, unique per parent. */
|
|
950
|
+
externalId: string;
|
|
951
|
+
/** A path tenant's path on your host. */
|
|
952
|
+
path?: string;
|
|
953
|
+
domain: string;
|
|
954
|
+
name?: string;
|
|
955
|
+
aliases?: string[];
|
|
956
|
+
verified: boolean;
|
|
957
|
+
rightsPageUrl: string;
|
|
958
|
+
/** What the tenant's pages put on the embed tag: data-cbid, and data-scope-path for a path tenant. */
|
|
959
|
+
snippetAttributes: Record<string, string>;
|
|
960
|
+
/** On a create: the externalId already had a tenant. */
|
|
961
|
+
existing?: boolean;
|
|
962
|
+
warnings?: Array<{
|
|
963
|
+
code: string;
|
|
964
|
+
message: string;
|
|
965
|
+
}>;
|
|
966
|
+
}
|
|
967
|
+
export interface TenantInput {
|
|
968
|
+
externalId: string;
|
|
969
|
+
name?: string;
|
|
970
|
+
/** A path tenant on your own host, such as `/ana`. Send `path` or `domains`. */
|
|
971
|
+
path?: string;
|
|
972
|
+
/** A tenant with a domain of its own: the first is its domain, the rest aliases. */
|
|
973
|
+
domains?: string[];
|
|
974
|
+
/** The customer as controller for their visitors. */
|
|
975
|
+
controller?: {
|
|
976
|
+
name: string;
|
|
977
|
+
email?: string;
|
|
978
|
+
url?: string;
|
|
979
|
+
address?: string;
|
|
980
|
+
[k: string]: unknown;
|
|
981
|
+
};
|
|
982
|
+
/** Copied from the parent at creation. Default all three. */
|
|
983
|
+
inherit?: Array<'banner' | 'categories' | 'cookies'>;
|
|
984
|
+
}
|
|
985
|
+
export interface TenantPage {
|
|
986
|
+
tenants: Tenant[];
|
|
987
|
+
nextCursor: string | null;
|
|
988
|
+
total: number;
|
|
989
|
+
}
|
|
990
|
+
/** POST /v1/sites/{cbid}/move. */
|
|
991
|
+
export interface SiteMoveInput {
|
|
992
|
+
/** The new host (no scheme or path). */
|
|
993
|
+
to: string;
|
|
994
|
+
/** The old host. Default: the site's domain. */
|
|
995
|
+
from?: string;
|
|
996
|
+
/** Keep the old domain as an alias. Default true. */
|
|
997
|
+
keepOld?: boolean;
|
|
998
|
+
/** Days sessions from the old sign-in issuer keep verifying (0–30). Default 14. */
|
|
999
|
+
trustOldDays?: number;
|
|
1000
|
+
}
|
|
1001
|
+
export interface SiteMoveResult {
|
|
1002
|
+
dryRun?: true;
|
|
1003
|
+
/** False when a step was refused; call again after fixing it. */
|
|
1004
|
+
ok: boolean;
|
|
1005
|
+
from: string;
|
|
1006
|
+
to: string;
|
|
1007
|
+
changes: Array<{
|
|
1008
|
+
resource: 'site' | 'config' | 'rightsIdentity' | 'executor';
|
|
1009
|
+
id?: string;
|
|
1010
|
+
field: string;
|
|
1011
|
+
before: unknown;
|
|
1012
|
+
after: unknown;
|
|
1013
|
+
}>;
|
|
1014
|
+
steps: Array<{
|
|
1015
|
+
resource: string;
|
|
1016
|
+
id?: string;
|
|
1017
|
+
status: number;
|
|
1018
|
+
error?: unknown;
|
|
1019
|
+
}>;
|
|
1020
|
+
notRun?: Array<{
|
|
1021
|
+
resource: string;
|
|
1022
|
+
id?: string;
|
|
1023
|
+
}>;
|
|
1024
|
+
/** What a move cannot rewrite, and what to do instead. */
|
|
1025
|
+
notChanged?: Array<{
|
|
1026
|
+
resource: string;
|
|
1027
|
+
value: string;
|
|
1028
|
+
reason: string;
|
|
1029
|
+
}>;
|
|
1030
|
+
/** After a refusal: the body to send again once it is fixed. */
|
|
1031
|
+
retry?: {
|
|
1032
|
+
body: {
|
|
1033
|
+
to: string;
|
|
1034
|
+
from: string;
|
|
1035
|
+
};
|
|
1036
|
+
note: string;
|
|
1037
|
+
};
|
|
1038
|
+
}
|
|
941
1039
|
export interface ConfigDryRun {
|
|
942
1040
|
dryRun: true;
|
|
943
1041
|
/** The config as it would be saved. */
|
|
944
1042
|
config: SiteConfig;
|
|
945
1043
|
/** Every leaf that would change. */
|
|
946
1044
|
diff: ConfigChange[];
|
|
1045
|
+
/** False: the site has never had a config saved, so `diff` is against the defaults. */
|
|
1046
|
+
storedConfig?: false;
|
|
947
1047
|
warnings?: ConfigWarning[];
|
|
948
1048
|
/** Consent-button parity of the would-be config (see {@link ButtonParityFinding}). */
|
|
949
1049
|
designWarnings: ButtonParityFinding[];
|
|
@@ -1882,6 +1982,11 @@ export interface RightsIdentity {
|
|
|
1882
1982
|
sessionCookieName?: string;
|
|
1883
1983
|
/** Present (true) only when set: clerk/atlas tokens without the verified claim are accepted. */
|
|
1884
1984
|
trustEmailClaim?: true;
|
|
1985
|
+
/** The setting a move replaced (`keepPreviousDays`): its sessions verify until `until` (ms). */
|
|
1986
|
+
previous?: {
|
|
1987
|
+
issuer: string;
|
|
1988
|
+
until: number;
|
|
1989
|
+
};
|
|
1885
1990
|
status: 'verified' | 'not_configured';
|
|
1886
1991
|
verifiedAt: number | null;
|
|
1887
1992
|
updatedAt: number | null;
|
|
@@ -1912,6 +2017,8 @@ export interface RightsIdentityInput {
|
|
|
1912
2017
|
* address it puts in the email claim is verified: a token without the verified claim is accepted.
|
|
1913
2018
|
*/
|
|
1914
2019
|
trustEmailClaim?: boolean;
|
|
2020
|
+
/** The issuer or key set changes (a domain move): sessions signed by the old one verify for this many days (1–30). */
|
|
2021
|
+
keepPreviousDays?: number;
|
|
1915
2022
|
}
|
|
1916
2023
|
/** The organisation's own data-controller identity (GET /v1/org/controller). */
|
|
1917
2024
|
export interface OrgControllerIdentity {
|
|
@@ -2384,6 +2491,8 @@ export interface ExecutorProfile {
|
|
|
2384
2491
|
};
|
|
2385
2492
|
}
|
|
2386
2493
|
/** A system connected to run part of a rights request. Credentials are never included. */
|
|
2494
|
+
/** A case source or origin a connection's `approvalExcept` may name. */
|
|
2495
|
+
export type ApprovalExcept = 'product' | 'identity' | 'rights_page' | 'admin' | 'account_deletion' | 'processor_forward';
|
|
2387
2496
|
export interface DsarExecutor {
|
|
2388
2497
|
id: string;
|
|
2389
2498
|
/** The name it answers to in a fulfillment plan, e.g. `identity` or `crm`. */
|
|
@@ -2444,6 +2553,8 @@ export interface DsarExecutor {
|
|
|
2444
2553
|
completionsUrl?: string;
|
|
2445
2554
|
/** True: its erasures wait (status `awaiting_approval`) for `approveTask` or `rejectTask`. */
|
|
2446
2555
|
requireApproval?: boolean;
|
|
2556
|
+
/** With requireApproval: case sources/origins whose erasures skip it, e.g. ['account_deletion']. A legal hold always waits. */
|
|
2557
|
+
approvalExcept?: ApprovalExcept[];
|
|
2447
2558
|
/** Systems whose tasks must finish first. */
|
|
2448
2559
|
runAfter?: string[];
|
|
2449
2560
|
/** A sandbox fixture: no system behind it. */
|
|
@@ -2531,6 +2642,8 @@ export interface DsarExecutorPresetInput {
|
|
|
2531
2642
|
orchestrator?: 1 | 2;
|
|
2532
2643
|
/** Park its erasures for a person's approval. Default false. */
|
|
2533
2644
|
requireApproval?: boolean;
|
|
2645
|
+
/** With requireApproval: case sources/origins whose erasures skip it, e.g. ['account_deletion']. A legal hold always waits. */
|
|
2646
|
+
approvalExcept?: ApprovalExcept[];
|
|
2534
2647
|
/**
|
|
2535
2648
|
* Any of the preset's params by name, as `executorPresets()` lists them: `{ programId }` for referalli
|
|
2536
2649
|
* (one program of a shared organisation), `{ projectId }` for lucida, `{ scopeName, scopeId }` for
|
|
@@ -2679,6 +2792,8 @@ export interface DsarExecutorInput {
|
|
|
2679
2792
|
orchestrator?: 1 | 2;
|
|
2680
2793
|
/** Park its erasures for a person's approval. Default false. */
|
|
2681
2794
|
requireApproval?: boolean;
|
|
2795
|
+
/** With requireApproval: case sources/origins whose erasures skip it, e.g. ['account_deletion']. A legal hold always waits. */
|
|
2796
|
+
approvalExcept?: ApprovalExcept[];
|
|
2682
2797
|
}
|
|
2683
2798
|
export type DsarExecutorCreated = DsarExecutor & {
|
|
2684
2799
|
warnings?: Array<{
|
|
@@ -2705,6 +2820,8 @@ export interface DsarExecutorPatch {
|
|
|
2705
2820
|
orchestrator?: 1 | 2;
|
|
2706
2821
|
/** Park its erasures for approval; false stops parking new ones (parked ones still wait). */
|
|
2707
2822
|
requireApproval?: boolean;
|
|
2823
|
+
/** With requireApproval: case sources/origins whose erasures skip it, e.g. ['account_deletion']. A legal hold always waits. */
|
|
2824
|
+
approvalExcept?: ApprovalExcept[] | null;
|
|
2708
2825
|
/**
|
|
2709
2826
|
* Another preset of the same family (cm-standard-v1 → cm-standard-v2) moves the connection in place, keeping its
|
|
2710
2827
|
* id, credentials and history; any other preset change is 409 immutable_field.
|
|
@@ -2964,6 +3081,10 @@ export interface CookieMunchClient {
|
|
|
2964
3081
|
update(cbid: string, patch: SiteUpdate, opts?: {
|
|
2965
3082
|
dryRun?: boolean;
|
|
2966
3083
|
}): Promise<SiteUpdateResult>;
|
|
3084
|
+
/** Move the site to a new domain: every stored value naming the old host, rewritten. Call again after a refusal to finish. */
|
|
3085
|
+
move(cbid: string, input: SiteMoveInput, opts?: {
|
|
3086
|
+
dryRun?: boolean;
|
|
3087
|
+
}): Promise<SiteMoveResult>;
|
|
2967
3088
|
delete(cbid: string): Promise<void>;
|
|
2968
3089
|
/** Purge a SANDBOX site: its consent ledger, declarations and test rights requests too. Anything else: 403 not_a_sandbox. */
|
|
2969
3090
|
deleteSandbox(cbid: string): Promise<SandboxPurge>;
|
|
@@ -3780,15 +3901,15 @@ export interface CookieMunchClient {
|
|
|
3780
3901
|
issue(input?: ApiKeyIssueInput): Promise<ApiKeyIssued>;
|
|
3781
3902
|
/** Revoke a key by its prefix. Immediate. */
|
|
3782
3903
|
revoke(prefix: string): Promise<void>;
|
|
3783
|
-
/**
|
|
3904
|
+
/** Full-access or account key (`orgs:keys`): list another org's key prefixes. Same answer as `list()`. */
|
|
3784
3905
|
listInOrg(orgId: string): Promise<ApiKeyPrefix[]>;
|
|
3785
|
-
/**
|
|
3906
|
+
/** Full-access or account key (`orgs:keys`): mint a key in another org of the same account. `scopes` is required with an account key. */
|
|
3786
3907
|
createInOrg(orgId: string, input: ApiKeyIssueInput): Promise<ApiKeyIssued>;
|
|
3787
|
-
/**
|
|
3908
|
+
/** Full-access or account key (`orgs:keys`): update a key in another org. Same body and answer as `update()`. */
|
|
3788
3909
|
updateInOrg(orgId: string, prefix: string, patch: ApiKeyUpdate): Promise<{
|
|
3789
3910
|
ok: true;
|
|
3790
3911
|
}>;
|
|
3791
|
-
/**
|
|
3912
|
+
/** Full-access or account key (`orgs:keys`): revoke a key in another org. Immediate. */
|
|
3792
3913
|
revokeInOrg(orgId: string, prefix: string): Promise<void>;
|
|
3793
3914
|
/** Rotate a key: a new secret, returned once, with the same scopes, lock and expiry. The old one stops working. */
|
|
3794
3915
|
roll(prefix: string): Promise<ApiKeyIssued>;
|
|
@@ -3863,7 +3984,9 @@ export interface CookieMunchClient {
|
|
|
3863
3984
|
delete(): Promise<SandboxPurge>;
|
|
3864
3985
|
};
|
|
3865
3986
|
/** Every link a site's privacy wiring depends on, one row each with `ok` and a fix hint. `cbid` may be omitted with one site. */
|
|
3866
|
-
integrationHealth(cbid?: string
|
|
3987
|
+
integrationHealth(cbid?: string, opts?: {
|
|
3988
|
+
preDeploy?: boolean;
|
|
3989
|
+
}): Promise<IntegrationHealthReport>;
|
|
3867
3990
|
/** Waive a health check you chose not to meet: the row reports `ok: null` with `waived`. Audited. */
|
|
3868
3991
|
healthWaivers: {
|
|
3869
3992
|
list(cbid?: string): Promise<{
|
|
@@ -4037,6 +4160,49 @@ export interface CookieMunchClient {
|
|
|
4037
4160
|
/** Turn hosted consent sync off for the site. */
|
|
4038
4161
|
remove(cbid: string): Promise<ConsentSyncSecret>;
|
|
4039
4162
|
};
|
|
4163
|
+
/**
|
|
4164
|
+
* Sites for your own customers (a creator, a shop), each the controller for its own visitors. A path tenant lives on
|
|
4165
|
+
* your host and is not counted against the plan's domains; its cases reach your cm-standard-v2 connections with
|
|
4166
|
+
* `scope.tenant` = externalId. Every call takes the parent site's cbid and your id for the customer.
|
|
4167
|
+
*/
|
|
4168
|
+
tenants: {
|
|
4169
|
+
create(parentCbid: string, input: TenantInput, opts?: {
|
|
4170
|
+
dryRun?: boolean;
|
|
4171
|
+
}): Promise<Tenant>;
|
|
4172
|
+
/** Up to 100; each is idempotent by externalId, so send the same list again to resume. */
|
|
4173
|
+
createBulk(parentCbid: string, tenants: TenantInput[], opts?: {
|
|
4174
|
+
dryRun?: boolean;
|
|
4175
|
+
}): Promise<{
|
|
4176
|
+
dryRun?: boolean;
|
|
4177
|
+
results: Array<Partial<Tenant> & {
|
|
4178
|
+
ok: boolean;
|
|
4179
|
+
status: number;
|
|
4180
|
+
error?: string;
|
|
4181
|
+
code?: string;
|
|
4182
|
+
field?: string;
|
|
4183
|
+
}>;
|
|
4184
|
+
}>;
|
|
4185
|
+
list(parentCbid: string, opts?: {
|
|
4186
|
+
limit?: number;
|
|
4187
|
+
cursor?: string;
|
|
4188
|
+
}): Promise<TenantPage>;
|
|
4189
|
+
/** Every tenant, page after page. */
|
|
4190
|
+
listAll(parentCbid: string): AsyncGenerator<Tenant>;
|
|
4191
|
+
get(parentCbid: string, externalId: string): Promise<Tenant>;
|
|
4192
|
+
update(parentCbid: string, externalId: string, patch: {
|
|
4193
|
+
name?: string | null;
|
|
4194
|
+
path?: string;
|
|
4195
|
+
controller?: TenantInput['controller'];
|
|
4196
|
+
}, opts?: {
|
|
4197
|
+
dryRun?: boolean;
|
|
4198
|
+
}): Promise<Tenant>;
|
|
4199
|
+
delete(parentCbid: string, externalId: string, opts?: {
|
|
4200
|
+
dryRun?: boolean;
|
|
4201
|
+
}): Promise<void | {
|
|
4202
|
+
dryRun: true;
|
|
4203
|
+
wouldDelete: Tenant;
|
|
4204
|
+
}>;
|
|
4205
|
+
};
|
|
4040
4206
|
/**
|
|
4041
4207
|
* A site's rights-page captcha: your own Turnstile, hCaptcha or reCAPTCHA keys (recommended), or off. A site
|
|
4042
4208
|
* without its own setting uses the organisation default (`org.rightsCaptcha`), else off. Requires sites:read / sites:write.
|
package/dist/index.js
CHANGED
|
@@ -89,7 +89,7 @@ async function exchangeOperatorToken(input) {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
// src/index.ts
|
|
92
|
-
var SDK_VERSION = "0.
|
|
92
|
+
var SDK_VERSION = "0.39.0";
|
|
93
93
|
var CookieMunchApiError = class extends Error {
|
|
94
94
|
constructor(status, message, code, body) {
|
|
95
95
|
super(message);
|
|
@@ -198,6 +198,7 @@ function createCookieMunch(opts) {
|
|
|
198
198
|
create: (input) => request("POST", "/sites", input),
|
|
199
199
|
get: (cbid) => get(`/sites/${enc(cbid)}`),
|
|
200
200
|
update: (cbid, patch, o) => request("PATCH", `/sites/${enc(cbid)}${qs({ dryRun: o?.dryRun ? "1" : void 0 })}`, patch),
|
|
201
|
+
move: (cbid, input, o) => request("POST", `/sites/${enc(cbid)}/move${qs({ dryRun: o?.dryRun ? "1" : void 0 })}`, input),
|
|
201
202
|
delete: async (cbid) => {
|
|
202
203
|
await request("DELETE", `/sites/${enc(cbid)}`);
|
|
203
204
|
},
|
|
@@ -515,7 +516,7 @@ function createCookieMunch(opts) {
|
|
|
515
516
|
create: (input) => request("POST", "/sandbox", input ?? {}),
|
|
516
517
|
delete: () => request("DELETE", "/sandbox")
|
|
517
518
|
},
|
|
518
|
-
integrationHealth: (cbid) => get(`/integration-health${qs({ cbid })}`),
|
|
519
|
+
integrationHealth: (cbid, opts2) => get(`/integration-health${qs({ cbid, ...opts2?.preDeploy ? { preDeploy: "1" } : {} })}`),
|
|
519
520
|
healthWaivers: {
|
|
520
521
|
list: (cbid) => get(`/integration-health/waivers${qs({ cbid })}`),
|
|
521
522
|
set: (input) => request("PUT", "/integration-health/waivers", input),
|
|
@@ -604,6 +605,22 @@ function createCookieMunch(opts) {
|
|
|
604
605
|
rotate: (cbid) => request("POST", `/sites/${enc(cbid)}/consent-sync-secret`),
|
|
605
606
|
remove: (cbid) => request("DELETE", `/sites/${enc(cbid)}/consent-sync-secret`)
|
|
606
607
|
},
|
|
608
|
+
tenants: {
|
|
609
|
+
create: (p, input, o) => request("POST", `/sites/${enc(p)}/tenants${qs({ dryRun: o?.dryRun ? "1" : void 0 })}`, input),
|
|
610
|
+
createBulk: (p, tenants, o) => request("POST", `/sites/${enc(p)}/tenants/bulk${qs({ dryRun: o?.dryRun ? "1" : void 0 })}`, { tenants }),
|
|
611
|
+
list: (p, o) => get(`/sites/${enc(p)}/tenants${qs({ limit: o?.limit !== void 0 ? String(o.limit) : void 0, cursor: o?.cursor })}`),
|
|
612
|
+
async *listAll(p) {
|
|
613
|
+
let cursor;
|
|
614
|
+
do {
|
|
615
|
+
const page = await get(`/sites/${enc(p)}/tenants${qs({ limit: "500", cursor })}`);
|
|
616
|
+
yield* page.tenants;
|
|
617
|
+
cursor = page.nextCursor ?? void 0;
|
|
618
|
+
} while (cursor);
|
|
619
|
+
},
|
|
620
|
+
get: (p, id) => get(`/sites/${enc(p)}/tenants/${enc(id)}`),
|
|
621
|
+
update: (p, id, patch, o) => request("PATCH", `/sites/${enc(p)}/tenants/${enc(id)}${qs({ dryRun: o?.dryRun ? "1" : void 0 })}`, patch),
|
|
622
|
+
delete: (p, id, o) => request("DELETE", `/sites/${enc(p)}/tenants/${enc(id)}${qs({ dryRun: o?.dryRun ? "1" : void 0 })}`)
|
|
623
|
+
},
|
|
607
624
|
rightsCaptcha: {
|
|
608
625
|
get: (cbid) => get(`/sites/${enc(cbid)}/rights-captcha`),
|
|
609
626
|
set: (cbid, input) => request("PUT", `/sites/${enc(cbid)}/rights-captcha`, input),
|