@cookiemunch/sdk 0.13.1 → 0.14.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/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.13.1";
23
+ export declare const SDK_VERSION = "0.14.0";
24
24
  export interface CookieMunchOptions {
25
25
  apiKey: string;
26
26
  /** "https://api.cookiemunch.net" — the /v1 prefix is appended automatically. */
@@ -467,7 +467,7 @@ export interface CookieSuggestionsDeclared {
467
467
  declared?: DeclaredCookie[];
468
468
  diff?: DeclarationDiff;
469
469
  }
470
- /** Preset parameters: Atlas `frontendApiHost`/`crossSubdomainCookies`/`publishableKey`; Chatly `publicId`/`dragging`/`storage`/`tracking`/`category`; referral and affiliate presets (referalli, firstpromoter, partnerstack, tapfiliate, impact) `cookieDomain`/`cookieDays`/`category`, referalli `legacyName`, impact `campaignId`. */
470
+ /** Preset parameters: Atlas `frontendApiHost`/`crossSubdomainCookies`/`publishableKey`; Chatly `publicId`/`dragging`/`storage`/`tracking`/`category`; referral and affiliate presets (referalli, firstpromoter, partnerstack, tapfiliate, impact) `cookieDomain`/`cookieDays`/`category`, referalli `legacyName`/`programHandle`, impact `campaignId`. */
471
471
  export interface CookiePresetParams {
472
472
  frontendApiHost?: string;
473
473
  crossSubdomainCookies?: boolean;
@@ -492,6 +492,8 @@ export interface CookiePresetParams {
492
492
  cookieDays?: number;
493
493
  /** referalli: default true, also declare referally_ctx (the pre-rename copy aff.js still writes). */
494
494
  legacyName?: boolean;
495
+ /** referalli: your program handle(s), up to 10; without cookieDays the lifetime is the programs' public cookieWindowDays. */
496
+ programHandle?: string | string[];
495
497
  /** impact: your program id; declares IR_<campaignId> too. */
496
498
  campaignId?: string;
497
499
  }
@@ -616,6 +618,28 @@ export interface DeclarationDiff {
616
618
  after: DeclaredCookie;
617
619
  }>;
618
620
  }
621
+ /** POST /v1/sites/:cbid/cookies/plan — the declarations PUT, then each preset in key order. */
622
+ export interface CookiePlanInput {
623
+ cookies?: Array<DeclaredCookieInput & {
624
+ name: string;
625
+ }>;
626
+ replace?: boolean;
627
+ /** Vendor → its params, applied in key order, each seeing the steps before it. */
628
+ presets?: Partial<Record<CookiePresetVendor, CookiePresetParams>>;
629
+ }
630
+ /** What the steps, in order, would produce. Nothing was stored. */
631
+ export interface CookiePlanResult {
632
+ dryRun: true;
633
+ /** Each step's own dry-run answer, plus `step` (`cookies` or `presets.<vendor>`) and its diff against the step before. */
634
+ steps: Array<{
635
+ step: string;
636
+ diff: DeclarationDiff;
637
+ [k: string]: unknown;
638
+ }>;
639
+ declared: DeclaredCookie[];
640
+ count: number;
641
+ diff: DeclarationDiff;
642
+ }
619
643
  /** The answer to a `dryRun` declaration write: nothing was stored. */
620
644
  export interface DeclarationDryRun {
621
645
  dryRun: true;
@@ -774,6 +798,18 @@ export interface DsarCreateDryRun {
774
798
  purpose: string;
775
799
  }>;
776
800
  effect?: string;
801
+ /** `{ preview: true }` only: what the system's `profile.preview` reported for the subject (reads only). */
802
+ preview?: {
803
+ ok: true;
804
+ records: Array<{
805
+ type: string;
806
+ count: number;
807
+ }>;
808
+ raw?: string;
809
+ } | {
810
+ ok: false;
811
+ reason: string;
812
+ };
777
813
  }>;
778
814
  skipped: Array<{
779
815
  system: string;
@@ -1248,6 +1284,8 @@ export interface ApiKeyPrefix {
1248
1284
  strictUnknownFields?: boolean;
1249
1285
  /** The dated API version this key is pinned to. */
1250
1286
  apiVersion?: string;
1287
+ /** A bound child key's parent (the scoped key that minted it): it works only while that key does. null = independent. */
1288
+ parentPrefix?: string | null;
1251
1289
  }
1252
1290
  /** 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. */
1253
1291
  export interface AnchorReceipt {
@@ -1340,6 +1378,8 @@ export interface ApiKeyIssued {
1340
1378
  expiresAt?: number | null;
1341
1379
  scopes?: string[] | null;
1342
1380
  cbids?: string[] | null;
1381
+ /** Minted by a scoped key: the key it is bound to (it stops working when that key is revoked, rolled or expires). null = independent. */
1382
+ parentPrefix?: string | null;
1343
1383
  /** No expiry, or one over 365 days. */
1344
1384
  warnings?: string[];
1345
1385
  /** With `secretRecipient`: the key, sealed (and `key` absent). */
@@ -2923,6 +2963,11 @@ export interface CookieMunchClient {
2923
2963
  dryRun?: true;
2924
2964
  diff?: DeclarationDiff;
2925
2965
  }>;
2966
+ /**
2967
+ * Plan a provisioning run, storing nothing: the declarations PUT (`cookies`, `replace`), then each
2968
+ * preset in `presets` in key order, against one scratch copy — exactly what the real calls in that order produce.
2969
+ */
2970
+ planCookies(cbid: string, input: CookiePlanInput): Promise<CookiePlanResult>;
2926
2971
  snippet(cbid: string, opts?: SnippetOptions): Promise<InstallSnippet>;
2927
2972
  /**
2928
2973
  * Mint a short-lived signed token to see the banner as a visitor in a given region and
@@ -2997,10 +3042,12 @@ export interface CookieMunchClient {
2997
3042
  /**
2998
3043
  * `skipped`: connections scoped to another property (or to one, when the request names none), never planned for it.
2999
3044
  * `{ dryRun: true }` files nothing and contacts no connected system: it answers which connections the request would
3000
- * reach once verified (`plan`) and which it would skip.
3045
+ * reach once verified (`plan`) and which it would skip. Add `preview: true` to also ask each planned system its
3046
+ * lookup and `profile.preview` for the subject (reads only, nothing filed): `plan[].preview`.
3001
3047
  */
3002
3048
  create(input: DsarCreate & ResourceTagsInput, opts: {
3003
3049
  dryRun: true;
3050
+ preview?: boolean;
3004
3051
  }): Promise<DsarCreateDryRun>;
3005
3052
  create(input: DsarCreate & ResourceTagsInput, opts?: {
3006
3053
  dryRun?: false;
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.13.1";
91
+ var SDK_VERSION = "0.14.0";
92
92
  var CookieMunchApiError = class extends Error {
93
93
  constructor(status, message, code, body) {
94
94
  super(message);
@@ -258,6 +258,7 @@ function createCookieMunch(opts) {
258
258
  return o?.dryRun ? out : void 0;
259
259
  }),
260
260
  declareCookies: (cbid, cookies, o) => request("PUT", `/sites/${enc(cbid)}/cookies${qs({ dryRun: o?.dryRun ? "1" : void 0 })}`, { cookies, ...o?.replace ? { replace: true } : {} }),
261
+ planCookies: (cbid, input) => request("POST", `/sites/${enc(cbid)}/cookies/plan`, input),
261
262
  snippet: (cbid, opts2) => get(`/sites/${enc(cbid)}/snippet${qs({ blockingmode: opts2?.blockingMode, culture: opts2?.culture })}`),
262
263
  previewToken: (cbid, o) => request("POST", `/sites/${enc(cbid)}/preview-token`, o ?? {}),
263
264
  verify: (cbid, method) => request("POST", `/sites/${enc(cbid)}/verify`, { method }),
@@ -302,7 +303,7 @@ function createCookieMunch(opts) {
302
303
  dsar: {
303
304
  list: () => get("/dsar"),
304
305
  get: (id) => get(`/dsar/${enc(id)}`),
305
- create: ((input, o) => request("POST", `/dsar${qs({ dryRun: o?.dryRun ? "1" : void 0 })}`, input)),
306
+ create: ((input, o) => request("POST", `/dsar${qs({ dryRun: o?.dryRun ? "1" : void 0, preview: o?.preview ? "1" : void 0 })}`, input)),
306
307
  advance: (id, toStatus, opts2) => request("POST", `/dsar/${enc(id)}/advance`, { toStatus, ...opts2?.messageToSubject !== void 0 ? { messageToSubject: opts2.messageToSubject } : {} }),
307
308
  response: (id) => request("GET", `/dsar/${enc(id)}/response`, void 0, true),
308
309
  erase: (id, cbid, stamp) => request("POST", `/dsar/${enc(id)}/erase`, { cbid, stamp }),