@cookiemunch/sdk 0.31.0 → 0.33.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.31.0";
23
+ export declare const SDK_VERSION = "0.33.0";
24
24
  export interface CookieMunchOptions {
25
25
  apiKey: string;
26
26
  /** "https://api.cookiemunch.net" — the /v1 prefix is appended automatically. */
@@ -693,14 +693,19 @@ export interface CookiePlanInput {
693
693
  name: string;
694
694
  }>;
695
695
  replace?: boolean;
696
- /** Vendor → its params, applied in key order, each seeing the steps before it. `custom` takes the body of `PUT …/cookies/presets/custom`. */
696
+ /** Own rows to give to a preset in `presets` that declares the same name: removed in the cookies step, declared by the preset. Each must end up declared by a preset, or the run is refused. */
697
+ handOver?: string[];
698
+ /** Vendor → its params, applied in key order, each seeing the steps before it. `custom` takes the body of `PUT …/cookies/presets/custom` (plan only). */
697
699
  presets?: Partial<Record<CookiePresetVendor, CookiePresetParams>> & {
698
700
  custom?: CustomPresetInput;
699
701
  };
700
702
  }
701
- /** What the steps, in order, would produce. Nothing was stored. */
703
+ /** What the steps, in order, would produce (`planCookies`: nothing stored) or did store (`applyCookies`). */
702
704
  export interface CookiePlanResult {
703
- dryRun: true;
705
+ /** Set by `planCookies`. */
706
+ dryRun?: true;
707
+ /** Set by `applyCookies`. */
708
+ applied?: true;
704
709
  /** Each step's own dry-run answer, plus `step` (`cookies` or `presets.<vendor>`) and its diff against the step before. */
705
710
  steps: Array<{
706
711
  step: string;
@@ -3203,6 +3208,11 @@ export interface CookieMunchClient {
3203
3208
  * preset in `presets` in key order, against one scratch copy — exactly what the real calls in that order produce.
3204
3209
  */
3205
3210
  planCookies(cbid: string, input: CookiePlanInput): Promise<CookiePlanResult>;
3211
+ /**
3212
+ * Apply what `planCookies` shows, all or nothing: the same steps on a scratch copy, stored only when every
3213
+ * step (and the `handOver` check) passes, each preset registered as its PUT would. A refusal stores nothing.
3214
+ */
3215
+ applyCookies(cbid: string, input: CookiePlanInput): Promise<CookiePlanResult>;
3206
3216
  snippet(cbid: string, opts?: SnippetOptions): Promise<InstallSnippet>;
3207
3217
  /**
3208
3218
  * Mint a short-lived signed token to see the banner as a visitor in a given region and
@@ -4080,3 +4090,12 @@ export interface CookieMunchClient {
4080
4090
  };
4081
4091
  }
4082
4092
  export declare function createCookieMunch(opts: CookieMunchOptions): CookieMunchClient;
4093
+ /**
4094
+ * The account-link URL for a person your server has verified is signed in (CM-14): wraps
4095
+ * `rightsLinks.create` (POST /v1/sites/{cbid}/rights-links) and answers just the `url`. Pass a client,
4096
+ * or the options to build one with a `dsar:rights-links` (or `dsar:write`) key. Call it from a route
4097
+ * that reads the subject from your own session, never from the browser's input.
4098
+ */
4099
+ export declare function rightsLink(clientOrOptions: Pick<CookieMunchClient, 'rightsLinks'> | CookieMunchOptions, input: RightsLinkInput & {
4100
+ cbid: string;
4101
+ }): Promise<string>;
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.31.0";
92
+ var SDK_VERSION = "0.33.0";
93
93
  var CookieMunchApiError = class extends Error {
94
94
  constructor(status, message, code, body) {
95
95
  super(message);
@@ -269,6 +269,7 @@ function createCookieMunch(opts) {
269
269
  }),
270
270
  declareCookies: (cbid, cookies, o) => request("PUT", `/sites/${enc(cbid)}/cookies${qs({ dryRun: o?.dryRun ? "1" : void 0 })}`, { cookies, ...o?.replace ? { replace: true } : {} }),
271
271
  planCookies: (cbid, input) => request("POST", `/sites/${enc(cbid)}/cookies/plan`, input),
272
+ applyCookies: (cbid, input) => request("POST", `/sites/${enc(cbid)}/cookies/apply`, input),
272
273
  snippet: (cbid, opts2) => get(`/sites/${enc(cbid)}/snippet${qs({ blockingmode: opts2?.blockingMode, culture: opts2?.culture })}`),
273
274
  previewToken: (cbid, o) => request("POST", `/sites/${enc(cbid)}/preview-token`, o ?? {}),
274
275
  verify: (cbid, method) => request("POST", `/sites/${enc(cbid)}/verify`, { method }),
@@ -630,6 +631,11 @@ function createCookieMunch(opts) {
630
631
  }
631
632
  };
632
633
  }
634
+ async function rightsLink(clientOrOptions, input) {
635
+ const client = "rightsLinks" in clientOrOptions ? clientOrOptions : createCookieMunch(clientOrOptions);
636
+ const { cbid, ...body } = input;
637
+ return (await client.rightsLinks.create(cbid, body)).url;
638
+ }
633
639
  export {
634
640
  CANARY_ISSUER,
635
641
  CONFORMANCE_RULES,
@@ -647,6 +653,7 @@ export {
647
653
  mintConsentSyncToken,
648
654
  parseConsentValue,
649
655
  readConsent,
656
+ rightsLink,
650
657
  runExecutorConformance,
651
658
  secretPaths,
652
659
  verifyDecisionSignature,