@cookiemunch/sdk 0.4.1 → 0.5.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 +7 -0
- package/dist/index.cjs +33 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +101 -4
- package/dist/index.d.ts +101 -4
- package/dist/index.js +32 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -390,6 +390,20 @@ interface VerifyWebhookInput {
|
|
|
390
390
|
*/
|
|
391
391
|
declare function verifyWebhookSignature(input: VerifyWebhookInput): boolean;
|
|
392
392
|
|
|
393
|
+
interface MintConsentSyncTokenInput {
|
|
394
|
+
/** The site's consent-sync secret (`cmss_…`). */
|
|
395
|
+
secret: string;
|
|
396
|
+
/** The site the token is for. A token for one site is refused by every other. */
|
|
397
|
+
cbid: string;
|
|
398
|
+
/** Who is signed in: 1–128 of `A-Z a-z 0-9 . _ : @ + / = ~ -`. Use an opaque id. */
|
|
399
|
+
subject: string;
|
|
400
|
+
/** Lifetime in seconds. Default 3600; at most 86400 (Cookie Munch refuses longer). */
|
|
401
|
+
ttlSeconds?: number;
|
|
402
|
+
/** Current time in ms (injectable for tests). */
|
|
403
|
+
now?: number;
|
|
404
|
+
}
|
|
405
|
+
declare function mintConsentSyncToken(input: MintConsentSyncTokenInput): string;
|
|
406
|
+
|
|
393
407
|
/**
|
|
394
408
|
* @cookiemunch/sdk — a small, typed REST client for the Cookie Munch Developer API
|
|
395
409
|
* (the /v1 surface). Construct it with an API key; the org is derived server-side
|
|
@@ -404,7 +418,7 @@ declare function verifyWebhookSignature(input: VerifyWebhookInput): boolean;
|
|
|
404
418
|
* This package's version, sent in the default User-Agent. Cloudflare answers a request with
|
|
405
419
|
* no recognisable User-Agent with `403 error code: 1010`; a test pins this to package.json.
|
|
406
420
|
*/
|
|
407
|
-
declare const SDK_VERSION = "0.
|
|
421
|
+
declare const SDK_VERSION = "0.5.0";
|
|
408
422
|
interface CookieMunchOptions {
|
|
409
423
|
apiKey: string;
|
|
410
424
|
/** "https://api.cookiemunch.net" — the /v1 prefix is appended automatically. */
|
|
@@ -422,8 +436,8 @@ interface CookieMunchOptions {
|
|
|
422
436
|
/**
|
|
423
437
|
* Thrown for any non-2xx response. `message` is the server's `error` field when present;
|
|
424
438
|
* `code` is populated from the server's `code` field whenever the error body carries one
|
|
425
|
-
* (e.g.
|
|
426
|
-
*
|
|
439
|
+
* (e.g. `forbidden` on a scope failure, whose `message` is `insufficient_scope`,
|
|
440
|
+
* or `banner_in_use` on a banner-library conflict). It's `undefined` when the body has no `code`.
|
|
427
441
|
*/
|
|
428
442
|
declare class CookieMunchApiError extends Error {
|
|
429
443
|
readonly status: number;
|
|
@@ -1327,6 +1341,38 @@ type RightsCaptchaProvider = 'turnstile' | 'hcaptcha' | 'recaptcha_v2' | 'recapt
|
|
|
1327
1341
|
* The rights page's captcha in force: your own keys (`own`, recommended) or none (`off`, the default).
|
|
1328
1342
|
* Cookie Munch's own captcha is never used on rights pages. The secret is never returned.
|
|
1329
1343
|
*/
|
|
1344
|
+
/** Whether hosted consent sync is set up for a site. The secret itself is never read back. */
|
|
1345
|
+
interface ConsentSyncSecret {
|
|
1346
|
+
cbid: string;
|
|
1347
|
+
configured: boolean;
|
|
1348
|
+
secretLast4: string | null;
|
|
1349
|
+
/** Epoch ms the current secret was minted. */
|
|
1350
|
+
createdAt: number | null;
|
|
1351
|
+
}
|
|
1352
|
+
/**
|
|
1353
|
+
* Who a preference-centre token is for: a site of your organisation and exactly one of `email`
|
|
1354
|
+
* (resolved as the emailed preference link resolves it) or `subjectId`.
|
|
1355
|
+
*/
|
|
1356
|
+
type CenterTokenInput = {
|
|
1357
|
+
cbid: string;
|
|
1358
|
+
ttlSeconds?: number;
|
|
1359
|
+
} & ({
|
|
1360
|
+
email: string;
|
|
1361
|
+
subjectId?: never;
|
|
1362
|
+
} | {
|
|
1363
|
+
subjectId: string;
|
|
1364
|
+
email?: never;
|
|
1365
|
+
});
|
|
1366
|
+
/** A preference-centre token. A credential: hand it to `CookieMunch.setSubjectToken`, never put it in a shared URL or a log. */
|
|
1367
|
+
interface CenterToken {
|
|
1368
|
+
token: string;
|
|
1369
|
+
/** ISO 8601. */
|
|
1370
|
+
expiresAt: string;
|
|
1371
|
+
}
|
|
1372
|
+
/** A freshly minted or rotated consent-sync secret: `secret` is shown this once. */
|
|
1373
|
+
interface ConsentSyncSecretMinted extends ConsentSyncSecret {
|
|
1374
|
+
secret: string;
|
|
1375
|
+
}
|
|
1330
1376
|
interface RightsCaptcha {
|
|
1331
1377
|
/** `site`: the site's own setting; `org`: the organisation default; `default`: neither (off). */
|
|
1332
1378
|
source: 'site' | 'org' | 'default';
|
|
@@ -1407,6 +1453,24 @@ interface RightsIdentityInput {
|
|
|
1407
1453
|
*/
|
|
1408
1454
|
trustEmailClaim?: boolean;
|
|
1409
1455
|
}
|
|
1456
|
+
/** The organisation's own data-controller identity (GET /v1/org/controller). */
|
|
1457
|
+
interface OrgControllerIdentity {
|
|
1458
|
+
/** False when none is set; then only `updatedAt` (null) is present. */
|
|
1459
|
+
set: boolean;
|
|
1460
|
+
legalName?: string;
|
|
1461
|
+
contactEmail?: string;
|
|
1462
|
+
address?: string;
|
|
1463
|
+
/** The Data Protection Officer: a name, an email address, or both. */
|
|
1464
|
+
dpoContact?: string;
|
|
1465
|
+
updatedAt: number | null;
|
|
1466
|
+
}
|
|
1467
|
+
/** Replaces the identity: a field left out is removed. `legalName` is required. */
|
|
1468
|
+
interface OrgControllerInput {
|
|
1469
|
+
legalName: string;
|
|
1470
|
+
contactEmail?: string;
|
|
1471
|
+
address?: string;
|
|
1472
|
+
dpoContact?: string;
|
|
1473
|
+
}
|
|
1410
1474
|
interface MailProviderTestResult {
|
|
1411
1475
|
ok: boolean;
|
|
1412
1476
|
sentTo: string;
|
|
@@ -2717,6 +2781,16 @@ interface CookieMunchClient {
|
|
|
2717
2781
|
/** One subject's record. A subject with none has empty `purposes`. */
|
|
2718
2782
|
get(subjectId: string): Promise<PreferenceRecord>;
|
|
2719
2783
|
};
|
|
2784
|
+
/** The hosted preference centre, opened for a visitor your server has signed in. */
|
|
2785
|
+
preferenceCenter: {
|
|
2786
|
+
/**
|
|
2787
|
+
* Mint a preference-centre token (POST /v1/preference-center/tokens) for the page to pass to
|
|
2788
|
+
* `CookieMunch.setSubjectToken`. Server-side only: the token opens that subject's subscriptions
|
|
2789
|
+
* and profile until `expiresAt`. `ttlSeconds` defaults to 3600, at most 86400. Needs
|
|
2790
|
+
* subscriptions:write and profile:write, plus identity:read when minting by email.
|
|
2791
|
+
*/
|
|
2792
|
+
mintToken(input: CenterTokenInput): Promise<CenterToken>;
|
|
2793
|
+
};
|
|
2720
2794
|
members: {
|
|
2721
2795
|
list(): Promise<Member[]>;
|
|
2722
2796
|
invite(email: string, role: string): Promise<{
|
|
@@ -2785,6 +2859,17 @@ interface CookieMunchClient {
|
|
|
2785
2859
|
/** Send a test through your provider. `to` defaults to the reply-to, else the from address. */
|
|
2786
2860
|
test(to?: string): Promise<MailProviderTestResult>;
|
|
2787
2861
|
};
|
|
2862
|
+
/**
|
|
2863
|
+
* Your organisation's own data-controller identity: who every rights notice names, before any site config
|
|
2864
|
+
* `controller` block. Needed for a notice on a request filed without a cbid when you have several sites.
|
|
2865
|
+
* An unscoped key, or `rights:write`.
|
|
2866
|
+
*/
|
|
2867
|
+
controller: {
|
|
2868
|
+
get(): Promise<OrgControllerIdentity>;
|
|
2869
|
+
/** Replace it: a field left out is removed. */
|
|
2870
|
+
set(input: OrgControllerInput): Promise<OrgControllerIdentity>;
|
|
2871
|
+
remove(): Promise<void>;
|
|
2872
|
+
};
|
|
2788
2873
|
/**
|
|
2789
2874
|
* The default captcha for your rights pages, for every site without its own (`rightsCaptcha`): your own
|
|
2790
2875
|
* keys (recommended) or off. Without one, rights pages have no captcha.
|
|
@@ -2866,6 +2951,18 @@ interface CookieMunchClient {
|
|
|
2866
2951
|
rightsLinks: {
|
|
2867
2952
|
create(cbid: string, input: RightsLinkInput): Promise<RightsLink>;
|
|
2868
2953
|
};
|
|
2954
|
+
/**
|
|
2955
|
+
* A site's consent-sync signing secret: your server signs consent-sync tokens with it
|
|
2956
|
+
* (`mintConsentSyncToken`) so a visitor's decision syncs across their browsers. `rotate` mints the
|
|
2957
|
+
* first one or replaces it (the old one stops at once) and is the only time the secret is returned.
|
|
2958
|
+
* Reading needs sites:read; rotate and remove need sites:write and consent:write.
|
|
2959
|
+
*/
|
|
2960
|
+
consentSyncSecret: {
|
|
2961
|
+
get(cbid: string): Promise<ConsentSyncSecret>;
|
|
2962
|
+
rotate(cbid: string): Promise<ConsentSyncSecretMinted>;
|
|
2963
|
+
/** Turn hosted consent sync off for the site. */
|
|
2964
|
+
remove(cbid: string): Promise<ConsentSyncSecret>;
|
|
2965
|
+
};
|
|
2869
2966
|
/**
|
|
2870
2967
|
* A site's rights-page captcha: your own Turnstile, hCaptcha or reCAPTCHA keys (recommended), or off. A site
|
|
2871
2968
|
* without its own setting uses the organisation default (`org.rightsCaptcha`), else off. Requires sites:read / sites:write.
|
|
@@ -2922,4 +3019,4 @@ interface CookieMunchClient {
|
|
|
2922
3019
|
}
|
|
2923
3020
|
declare function createCookieMunch(opts: CookieMunchOptions): CookieMunchClient;
|
|
2924
3021
|
|
|
2925
|
-
export { type AbResult, type AccountOrg, type AccountOrgs, type AdPersonalizationInput, type AiInspectInput, type AiInspectResult, type ApiKey, type ApiKeyIssueInput, type ApiKeyIssued, type ApiKeyPrefix, type ApiKeyReport, type ApiKeyUpdate, type AppliedImport, type AssetUpload, type AuditEntry, type BannerRecord, type BannerSummary, type BlockedReport, type BrandExtractionResult, type BrandKit, type BrandKitCreate, type BrandSuggestion, type BulkSiteInput, type BulkSiteResult, type ButtonParityFinding, type ButtonParityLint, type ButtonParityScan, type CategorizedCookie, type ChildKeyInput, type ConfigChange, type ConfigDryRun, type ConfigWarning, type ConsentDay, type ConsentDecisionInput, type ConsentIngestInput, type ConsentLogRow, type CookieDeclaration, CookieMunchApiError, type CookieMunchClient, type CookieMunchOptions, type CookiePreset, type CookiePresetManifest, type CookiePresetParams, type CookiePresetResult, type CookiePresetVendor, type CspSources, type DeclarationDiff, type DeclarationDryRun, type DeclarationWarning, type DeclaredCookie, type DeclaredCookieInput, type DnsRecordInstruction, type DsarCreate, type DsarEraseResult, type DsarExecutor, type DsarExecutorCreated, type DsarExecutorDryRun, type DsarExecutorInput, type DsarExecutorPatch, type DsarExecutorPresetInput, type DsarExportResult, type DsarRequest, type DsarStatus, type DsarTask, type DsarTaskEvent, type DsarTaskExport, type DsarTaskLogEntry, type DsarTaskOutcome, type DsarType, type EnforcementRuleInput, type ExecutorHealth, type ExecutorPresetName, type ExecutorPresetUpgrade, type ExecutorPresets, type ExecutorProfile, type ExecutorTestInput, type ExecutorTestResult, type ExecutorWebhookDelivery, type ExecutorWebhookTestResult, type FlowIssue, type FlowOp, type FlowOpResponse, type FulfillmentOp, type HealthRow, type Identifier, type Identity, type ImportedCookie, type ImportedDeclaration, type InstallSnippet, type IntegrationHealthReport, type LegalBasis, type LogQuery, type MailProvider, type MailProviderInput, type MailProviderKind, type MailProviderTestResult, type Member, type ObservedPurgeResult, type OptInMethod, type Org, type OrgUpdate, type ParityControlSummary, type PartnerCatalogEntry, type PartnerId, type PartnerLink, type PartnerLinkCreate, type PlanSource, type PolicyOptions, type PreferenceItem, type PreferenceRecord, type PreviewToken, type PreviewTokenOptions, type ProfileAttributeInput, type ProvisionRequest, type ProvisionResult, type ProvisionStep, type PublicDsarFiled, type PublicDsarPending, type PublicVerification, type PutConfigOptions, type RangeQuery, type Regulation, type RegulationSummary, type RegulatoryFeedResult, type ResellerChild, type ResellerChildCreate, type ResellerChildList, type ResellerChildPatch, type RetiredCookie, type RightKind, type RightsCaptcha, type RightsCaptchaInput, type RightsCaptchaProvider, type RightsIdentity, type RightsIdentityInput, type RightsIdentityType, type RightsLink, type RightsLinkInput, type RightsPageDocument, type RightsPageDomain, type RightsPageDomainList, type RightsPageDraft, type RightsPageDraftConflict, type RightsPageDryRun, type RightsPageIssue, type RightsPagePublishResult, type RightsPagePublished, type RightsPagePublisher, type RightsPageVersions, type RightsPageWriteOptions, type RiskScore, type RopaEntry, type RopaInput, SDK_VERSION, type ScanResult, type ScanStatus, type ScoredVendor, type ScrollbarTheme, type SessionAnalysisInput, type SignedReceipt, type Site, type SiteConfig, type SiteCookie, type SiteCreate, type SiteFlow, type SiteUpdate, type SiteUpdateResult, type SnippetOptions, type StorageType, type SubscriptionTopicInput, type SuggestedRejectStyle, type SupportedLanguage, type Usage, type VendorInput, type VendorRecord, type VerifyResult, type VerifyWebhookInput, type WebhookCreate, type WebhookDeadLetter, type WebhookKeyForm, type WebhookStage, type WebhookSubscription, type WebhookTestResult, type WebhookUpdate, createCookieMunch, verifyWebhookSignature };
|
|
3022
|
+
export { type AbResult, type AccountOrg, type AccountOrgs, type AdPersonalizationInput, type AiInspectInput, type AiInspectResult, type ApiKey, type ApiKeyIssueInput, type ApiKeyIssued, type ApiKeyPrefix, type ApiKeyReport, type ApiKeyUpdate, type AppliedImport, type AssetUpload, type AuditEntry, type BannerRecord, type BannerSummary, type BlockedReport, type BrandExtractionResult, type BrandKit, type BrandKitCreate, type BrandSuggestion, type BulkSiteInput, type BulkSiteResult, type ButtonParityFinding, type ButtonParityLint, type ButtonParityScan, type CategorizedCookie, type CenterToken, type CenterTokenInput, type ChildKeyInput, type ConfigChange, type ConfigDryRun, type ConfigWarning, type ConsentDay, type ConsentDecisionInput, type ConsentIngestInput, type ConsentLogRow, type ConsentSyncSecret, type ConsentSyncSecretMinted, type CookieDeclaration, CookieMunchApiError, type CookieMunchClient, type CookieMunchOptions, type CookiePreset, type CookiePresetManifest, type CookiePresetParams, type CookiePresetResult, type CookiePresetVendor, type CspSources, type DeclarationDiff, type DeclarationDryRun, type DeclarationWarning, type DeclaredCookie, type DeclaredCookieInput, type DnsRecordInstruction, type DsarCreate, type DsarEraseResult, type DsarExecutor, type DsarExecutorCreated, type DsarExecutorDryRun, type DsarExecutorInput, type DsarExecutorPatch, type DsarExecutorPresetInput, type DsarExportResult, type DsarRequest, type DsarStatus, type DsarTask, type DsarTaskEvent, type DsarTaskExport, type DsarTaskLogEntry, type DsarTaskOutcome, type DsarType, type EnforcementRuleInput, type ExecutorHealth, type ExecutorPresetName, type ExecutorPresetUpgrade, type ExecutorPresets, type ExecutorProfile, type ExecutorTestInput, type ExecutorTestResult, type ExecutorWebhookDelivery, type ExecutorWebhookTestResult, type FlowIssue, type FlowOp, type FlowOpResponse, type FulfillmentOp, type HealthRow, type Identifier, type Identity, type ImportedCookie, type ImportedDeclaration, type InstallSnippet, type IntegrationHealthReport, type LegalBasis, type LogQuery, type MailProvider, type MailProviderInput, type MailProviderKind, type MailProviderTestResult, type Member, type MintConsentSyncTokenInput, type ObservedPurgeResult, type OptInMethod, type Org, type OrgControllerIdentity, type OrgControllerInput, type OrgUpdate, type ParityControlSummary, type PartnerCatalogEntry, type PartnerId, type PartnerLink, type PartnerLinkCreate, type PlanSource, type PolicyOptions, type PreferenceItem, type PreferenceRecord, type PreviewToken, type PreviewTokenOptions, type ProfileAttributeInput, type ProvisionRequest, type ProvisionResult, type ProvisionStep, type PublicDsarFiled, type PublicDsarPending, type PublicVerification, type PutConfigOptions, type RangeQuery, type Regulation, type RegulationSummary, type RegulatoryFeedResult, type ResellerChild, type ResellerChildCreate, type ResellerChildList, type ResellerChildPatch, type RetiredCookie, type RightKind, type RightsCaptcha, type RightsCaptchaInput, type RightsCaptchaProvider, type RightsIdentity, type RightsIdentityInput, type RightsIdentityType, type RightsLink, type RightsLinkInput, type RightsPageDocument, type RightsPageDomain, type RightsPageDomainList, type RightsPageDraft, type RightsPageDraftConflict, type RightsPageDryRun, type RightsPageIssue, type RightsPagePublishResult, type RightsPagePublished, type RightsPagePublisher, type RightsPageVersions, type RightsPageWriteOptions, type RiskScore, type RopaEntry, type RopaInput, SDK_VERSION, type ScanResult, type ScanStatus, type ScoredVendor, type ScrollbarTheme, type SessionAnalysisInput, type SignedReceipt, type Site, type SiteConfig, type SiteCookie, type SiteCreate, type SiteFlow, type SiteUpdate, type SiteUpdateResult, type SnippetOptions, type StorageType, type SubscriptionTopicInput, type SuggestedRejectStyle, type SupportedLanguage, type Usage, type VendorInput, type VendorRecord, type VerifyResult, type VerifyWebhookInput, type WebhookCreate, type WebhookDeadLetter, type WebhookKeyForm, type WebhookStage, type WebhookSubscription, type WebhookTestResult, type WebhookUpdate, createCookieMunch, mintConsentSyncToken, verifyWebhookSignature };
|
package/dist/index.d.ts
CHANGED
|
@@ -390,6 +390,20 @@ interface VerifyWebhookInput {
|
|
|
390
390
|
*/
|
|
391
391
|
declare function verifyWebhookSignature(input: VerifyWebhookInput): boolean;
|
|
392
392
|
|
|
393
|
+
interface MintConsentSyncTokenInput {
|
|
394
|
+
/** The site's consent-sync secret (`cmss_…`). */
|
|
395
|
+
secret: string;
|
|
396
|
+
/** The site the token is for. A token for one site is refused by every other. */
|
|
397
|
+
cbid: string;
|
|
398
|
+
/** Who is signed in: 1–128 of `A-Z a-z 0-9 . _ : @ + / = ~ -`. Use an opaque id. */
|
|
399
|
+
subject: string;
|
|
400
|
+
/** Lifetime in seconds. Default 3600; at most 86400 (Cookie Munch refuses longer). */
|
|
401
|
+
ttlSeconds?: number;
|
|
402
|
+
/** Current time in ms (injectable for tests). */
|
|
403
|
+
now?: number;
|
|
404
|
+
}
|
|
405
|
+
declare function mintConsentSyncToken(input: MintConsentSyncTokenInput): string;
|
|
406
|
+
|
|
393
407
|
/**
|
|
394
408
|
* @cookiemunch/sdk — a small, typed REST client for the Cookie Munch Developer API
|
|
395
409
|
* (the /v1 surface). Construct it with an API key; the org is derived server-side
|
|
@@ -404,7 +418,7 @@ declare function verifyWebhookSignature(input: VerifyWebhookInput): boolean;
|
|
|
404
418
|
* This package's version, sent in the default User-Agent. Cloudflare answers a request with
|
|
405
419
|
* no recognisable User-Agent with `403 error code: 1010`; a test pins this to package.json.
|
|
406
420
|
*/
|
|
407
|
-
declare const SDK_VERSION = "0.
|
|
421
|
+
declare const SDK_VERSION = "0.5.0";
|
|
408
422
|
interface CookieMunchOptions {
|
|
409
423
|
apiKey: string;
|
|
410
424
|
/** "https://api.cookiemunch.net" — the /v1 prefix is appended automatically. */
|
|
@@ -422,8 +436,8 @@ interface CookieMunchOptions {
|
|
|
422
436
|
/**
|
|
423
437
|
* Thrown for any non-2xx response. `message` is the server's `error` field when present;
|
|
424
438
|
* `code` is populated from the server's `code` field whenever the error body carries one
|
|
425
|
-
* (e.g.
|
|
426
|
-
*
|
|
439
|
+
* (e.g. `forbidden` on a scope failure, whose `message` is `insufficient_scope`,
|
|
440
|
+
* or `banner_in_use` on a banner-library conflict). It's `undefined` when the body has no `code`.
|
|
427
441
|
*/
|
|
428
442
|
declare class CookieMunchApiError extends Error {
|
|
429
443
|
readonly status: number;
|
|
@@ -1327,6 +1341,38 @@ type RightsCaptchaProvider = 'turnstile' | 'hcaptcha' | 'recaptcha_v2' | 'recapt
|
|
|
1327
1341
|
* The rights page's captcha in force: your own keys (`own`, recommended) or none (`off`, the default).
|
|
1328
1342
|
* Cookie Munch's own captcha is never used on rights pages. The secret is never returned.
|
|
1329
1343
|
*/
|
|
1344
|
+
/** Whether hosted consent sync is set up for a site. The secret itself is never read back. */
|
|
1345
|
+
interface ConsentSyncSecret {
|
|
1346
|
+
cbid: string;
|
|
1347
|
+
configured: boolean;
|
|
1348
|
+
secretLast4: string | null;
|
|
1349
|
+
/** Epoch ms the current secret was minted. */
|
|
1350
|
+
createdAt: number | null;
|
|
1351
|
+
}
|
|
1352
|
+
/**
|
|
1353
|
+
* Who a preference-centre token is for: a site of your organisation and exactly one of `email`
|
|
1354
|
+
* (resolved as the emailed preference link resolves it) or `subjectId`.
|
|
1355
|
+
*/
|
|
1356
|
+
type CenterTokenInput = {
|
|
1357
|
+
cbid: string;
|
|
1358
|
+
ttlSeconds?: number;
|
|
1359
|
+
} & ({
|
|
1360
|
+
email: string;
|
|
1361
|
+
subjectId?: never;
|
|
1362
|
+
} | {
|
|
1363
|
+
subjectId: string;
|
|
1364
|
+
email?: never;
|
|
1365
|
+
});
|
|
1366
|
+
/** A preference-centre token. A credential: hand it to `CookieMunch.setSubjectToken`, never put it in a shared URL or a log. */
|
|
1367
|
+
interface CenterToken {
|
|
1368
|
+
token: string;
|
|
1369
|
+
/** ISO 8601. */
|
|
1370
|
+
expiresAt: string;
|
|
1371
|
+
}
|
|
1372
|
+
/** A freshly minted or rotated consent-sync secret: `secret` is shown this once. */
|
|
1373
|
+
interface ConsentSyncSecretMinted extends ConsentSyncSecret {
|
|
1374
|
+
secret: string;
|
|
1375
|
+
}
|
|
1330
1376
|
interface RightsCaptcha {
|
|
1331
1377
|
/** `site`: the site's own setting; `org`: the organisation default; `default`: neither (off). */
|
|
1332
1378
|
source: 'site' | 'org' | 'default';
|
|
@@ -1407,6 +1453,24 @@ interface RightsIdentityInput {
|
|
|
1407
1453
|
*/
|
|
1408
1454
|
trustEmailClaim?: boolean;
|
|
1409
1455
|
}
|
|
1456
|
+
/** The organisation's own data-controller identity (GET /v1/org/controller). */
|
|
1457
|
+
interface OrgControllerIdentity {
|
|
1458
|
+
/** False when none is set; then only `updatedAt` (null) is present. */
|
|
1459
|
+
set: boolean;
|
|
1460
|
+
legalName?: string;
|
|
1461
|
+
contactEmail?: string;
|
|
1462
|
+
address?: string;
|
|
1463
|
+
/** The Data Protection Officer: a name, an email address, or both. */
|
|
1464
|
+
dpoContact?: string;
|
|
1465
|
+
updatedAt: number | null;
|
|
1466
|
+
}
|
|
1467
|
+
/** Replaces the identity: a field left out is removed. `legalName` is required. */
|
|
1468
|
+
interface OrgControllerInput {
|
|
1469
|
+
legalName: string;
|
|
1470
|
+
contactEmail?: string;
|
|
1471
|
+
address?: string;
|
|
1472
|
+
dpoContact?: string;
|
|
1473
|
+
}
|
|
1410
1474
|
interface MailProviderTestResult {
|
|
1411
1475
|
ok: boolean;
|
|
1412
1476
|
sentTo: string;
|
|
@@ -2717,6 +2781,16 @@ interface CookieMunchClient {
|
|
|
2717
2781
|
/** One subject's record. A subject with none has empty `purposes`. */
|
|
2718
2782
|
get(subjectId: string): Promise<PreferenceRecord>;
|
|
2719
2783
|
};
|
|
2784
|
+
/** The hosted preference centre, opened for a visitor your server has signed in. */
|
|
2785
|
+
preferenceCenter: {
|
|
2786
|
+
/**
|
|
2787
|
+
* Mint a preference-centre token (POST /v1/preference-center/tokens) for the page to pass to
|
|
2788
|
+
* `CookieMunch.setSubjectToken`. Server-side only: the token opens that subject's subscriptions
|
|
2789
|
+
* and profile until `expiresAt`. `ttlSeconds` defaults to 3600, at most 86400. Needs
|
|
2790
|
+
* subscriptions:write and profile:write, plus identity:read when minting by email.
|
|
2791
|
+
*/
|
|
2792
|
+
mintToken(input: CenterTokenInput): Promise<CenterToken>;
|
|
2793
|
+
};
|
|
2720
2794
|
members: {
|
|
2721
2795
|
list(): Promise<Member[]>;
|
|
2722
2796
|
invite(email: string, role: string): Promise<{
|
|
@@ -2785,6 +2859,17 @@ interface CookieMunchClient {
|
|
|
2785
2859
|
/** Send a test through your provider. `to` defaults to the reply-to, else the from address. */
|
|
2786
2860
|
test(to?: string): Promise<MailProviderTestResult>;
|
|
2787
2861
|
};
|
|
2862
|
+
/**
|
|
2863
|
+
* Your organisation's own data-controller identity: who every rights notice names, before any site config
|
|
2864
|
+
* `controller` block. Needed for a notice on a request filed without a cbid when you have several sites.
|
|
2865
|
+
* An unscoped key, or `rights:write`.
|
|
2866
|
+
*/
|
|
2867
|
+
controller: {
|
|
2868
|
+
get(): Promise<OrgControllerIdentity>;
|
|
2869
|
+
/** Replace it: a field left out is removed. */
|
|
2870
|
+
set(input: OrgControllerInput): Promise<OrgControllerIdentity>;
|
|
2871
|
+
remove(): Promise<void>;
|
|
2872
|
+
};
|
|
2788
2873
|
/**
|
|
2789
2874
|
* The default captcha for your rights pages, for every site without its own (`rightsCaptcha`): your own
|
|
2790
2875
|
* keys (recommended) or off. Without one, rights pages have no captcha.
|
|
@@ -2866,6 +2951,18 @@ interface CookieMunchClient {
|
|
|
2866
2951
|
rightsLinks: {
|
|
2867
2952
|
create(cbid: string, input: RightsLinkInput): Promise<RightsLink>;
|
|
2868
2953
|
};
|
|
2954
|
+
/**
|
|
2955
|
+
* A site's consent-sync signing secret: your server signs consent-sync tokens with it
|
|
2956
|
+
* (`mintConsentSyncToken`) so a visitor's decision syncs across their browsers. `rotate` mints the
|
|
2957
|
+
* first one or replaces it (the old one stops at once) and is the only time the secret is returned.
|
|
2958
|
+
* Reading needs sites:read; rotate and remove need sites:write and consent:write.
|
|
2959
|
+
*/
|
|
2960
|
+
consentSyncSecret: {
|
|
2961
|
+
get(cbid: string): Promise<ConsentSyncSecret>;
|
|
2962
|
+
rotate(cbid: string): Promise<ConsentSyncSecretMinted>;
|
|
2963
|
+
/** Turn hosted consent sync off for the site. */
|
|
2964
|
+
remove(cbid: string): Promise<ConsentSyncSecret>;
|
|
2965
|
+
};
|
|
2869
2966
|
/**
|
|
2870
2967
|
* A site's rights-page captcha: your own Turnstile, hCaptcha or reCAPTCHA keys (recommended), or off. A site
|
|
2871
2968
|
* without its own setting uses the organisation default (`org.rightsCaptcha`), else off. Requires sites:read / sites:write.
|
|
@@ -2922,4 +3019,4 @@ interface CookieMunchClient {
|
|
|
2922
3019
|
}
|
|
2923
3020
|
declare function createCookieMunch(opts: CookieMunchOptions): CookieMunchClient;
|
|
2924
3021
|
|
|
2925
|
-
export { type AbResult, type AccountOrg, type AccountOrgs, type AdPersonalizationInput, type AiInspectInput, type AiInspectResult, type ApiKey, type ApiKeyIssueInput, type ApiKeyIssued, type ApiKeyPrefix, type ApiKeyReport, type ApiKeyUpdate, type AppliedImport, type AssetUpload, type AuditEntry, type BannerRecord, type BannerSummary, type BlockedReport, type BrandExtractionResult, type BrandKit, type BrandKitCreate, type BrandSuggestion, type BulkSiteInput, type BulkSiteResult, type ButtonParityFinding, type ButtonParityLint, type ButtonParityScan, type CategorizedCookie, type ChildKeyInput, type ConfigChange, type ConfigDryRun, type ConfigWarning, type ConsentDay, type ConsentDecisionInput, type ConsentIngestInput, type ConsentLogRow, type CookieDeclaration, CookieMunchApiError, type CookieMunchClient, type CookieMunchOptions, type CookiePreset, type CookiePresetManifest, type CookiePresetParams, type CookiePresetResult, type CookiePresetVendor, type CspSources, type DeclarationDiff, type DeclarationDryRun, type DeclarationWarning, type DeclaredCookie, type DeclaredCookieInput, type DnsRecordInstruction, type DsarCreate, type DsarEraseResult, type DsarExecutor, type DsarExecutorCreated, type DsarExecutorDryRun, type DsarExecutorInput, type DsarExecutorPatch, type DsarExecutorPresetInput, type DsarExportResult, type DsarRequest, type DsarStatus, type DsarTask, type DsarTaskEvent, type DsarTaskExport, type DsarTaskLogEntry, type DsarTaskOutcome, type DsarType, type EnforcementRuleInput, type ExecutorHealth, type ExecutorPresetName, type ExecutorPresetUpgrade, type ExecutorPresets, type ExecutorProfile, type ExecutorTestInput, type ExecutorTestResult, type ExecutorWebhookDelivery, type ExecutorWebhookTestResult, type FlowIssue, type FlowOp, type FlowOpResponse, type FulfillmentOp, type HealthRow, type Identifier, type Identity, type ImportedCookie, type ImportedDeclaration, type InstallSnippet, type IntegrationHealthReport, type LegalBasis, type LogQuery, type MailProvider, type MailProviderInput, type MailProviderKind, type MailProviderTestResult, type Member, type ObservedPurgeResult, type OptInMethod, type Org, type OrgUpdate, type ParityControlSummary, type PartnerCatalogEntry, type PartnerId, type PartnerLink, type PartnerLinkCreate, type PlanSource, type PolicyOptions, type PreferenceItem, type PreferenceRecord, type PreviewToken, type PreviewTokenOptions, type ProfileAttributeInput, type ProvisionRequest, type ProvisionResult, type ProvisionStep, type PublicDsarFiled, type PublicDsarPending, type PublicVerification, type PutConfigOptions, type RangeQuery, type Regulation, type RegulationSummary, type RegulatoryFeedResult, type ResellerChild, type ResellerChildCreate, type ResellerChildList, type ResellerChildPatch, type RetiredCookie, type RightKind, type RightsCaptcha, type RightsCaptchaInput, type RightsCaptchaProvider, type RightsIdentity, type RightsIdentityInput, type RightsIdentityType, type RightsLink, type RightsLinkInput, type RightsPageDocument, type RightsPageDomain, type RightsPageDomainList, type RightsPageDraft, type RightsPageDraftConflict, type RightsPageDryRun, type RightsPageIssue, type RightsPagePublishResult, type RightsPagePublished, type RightsPagePublisher, type RightsPageVersions, type RightsPageWriteOptions, type RiskScore, type RopaEntry, type RopaInput, SDK_VERSION, type ScanResult, type ScanStatus, type ScoredVendor, type ScrollbarTheme, type SessionAnalysisInput, type SignedReceipt, type Site, type SiteConfig, type SiteCookie, type SiteCreate, type SiteFlow, type SiteUpdate, type SiteUpdateResult, type SnippetOptions, type StorageType, type SubscriptionTopicInput, type SuggestedRejectStyle, type SupportedLanguage, type Usage, type VendorInput, type VendorRecord, type VerifyResult, type VerifyWebhookInput, type WebhookCreate, type WebhookDeadLetter, type WebhookKeyForm, type WebhookStage, type WebhookSubscription, type WebhookTestResult, type WebhookUpdate, createCookieMunch, verifyWebhookSignature };
|
|
3022
|
+
export { type AbResult, type AccountOrg, type AccountOrgs, type AdPersonalizationInput, type AiInspectInput, type AiInspectResult, type ApiKey, type ApiKeyIssueInput, type ApiKeyIssued, type ApiKeyPrefix, type ApiKeyReport, type ApiKeyUpdate, type AppliedImport, type AssetUpload, type AuditEntry, type BannerRecord, type BannerSummary, type BlockedReport, type BrandExtractionResult, type BrandKit, type BrandKitCreate, type BrandSuggestion, type BulkSiteInput, type BulkSiteResult, type ButtonParityFinding, type ButtonParityLint, type ButtonParityScan, type CategorizedCookie, type CenterToken, type CenterTokenInput, type ChildKeyInput, type ConfigChange, type ConfigDryRun, type ConfigWarning, type ConsentDay, type ConsentDecisionInput, type ConsentIngestInput, type ConsentLogRow, type ConsentSyncSecret, type ConsentSyncSecretMinted, type CookieDeclaration, CookieMunchApiError, type CookieMunchClient, type CookieMunchOptions, type CookiePreset, type CookiePresetManifest, type CookiePresetParams, type CookiePresetResult, type CookiePresetVendor, type CspSources, type DeclarationDiff, type DeclarationDryRun, type DeclarationWarning, type DeclaredCookie, type DeclaredCookieInput, type DnsRecordInstruction, type DsarCreate, type DsarEraseResult, type DsarExecutor, type DsarExecutorCreated, type DsarExecutorDryRun, type DsarExecutorInput, type DsarExecutorPatch, type DsarExecutorPresetInput, type DsarExportResult, type DsarRequest, type DsarStatus, type DsarTask, type DsarTaskEvent, type DsarTaskExport, type DsarTaskLogEntry, type DsarTaskOutcome, type DsarType, type EnforcementRuleInput, type ExecutorHealth, type ExecutorPresetName, type ExecutorPresetUpgrade, type ExecutorPresets, type ExecutorProfile, type ExecutorTestInput, type ExecutorTestResult, type ExecutorWebhookDelivery, type ExecutorWebhookTestResult, type FlowIssue, type FlowOp, type FlowOpResponse, type FulfillmentOp, type HealthRow, type Identifier, type Identity, type ImportedCookie, type ImportedDeclaration, type InstallSnippet, type IntegrationHealthReport, type LegalBasis, type LogQuery, type MailProvider, type MailProviderInput, type MailProviderKind, type MailProviderTestResult, type Member, type MintConsentSyncTokenInput, type ObservedPurgeResult, type OptInMethod, type Org, type OrgControllerIdentity, type OrgControllerInput, type OrgUpdate, type ParityControlSummary, type PartnerCatalogEntry, type PartnerId, type PartnerLink, type PartnerLinkCreate, type PlanSource, type PolicyOptions, type PreferenceItem, type PreferenceRecord, type PreviewToken, type PreviewTokenOptions, type ProfileAttributeInput, type ProvisionRequest, type ProvisionResult, type ProvisionStep, type PublicDsarFiled, type PublicDsarPending, type PublicVerification, type PutConfigOptions, type RangeQuery, type Regulation, type RegulationSummary, type RegulatoryFeedResult, type ResellerChild, type ResellerChildCreate, type ResellerChildList, type ResellerChildPatch, type RetiredCookie, type RightKind, type RightsCaptcha, type RightsCaptchaInput, type RightsCaptchaProvider, type RightsIdentity, type RightsIdentityInput, type RightsIdentityType, type RightsLink, type RightsLinkInput, type RightsPageDocument, type RightsPageDomain, type RightsPageDomainList, type RightsPageDraft, type RightsPageDraftConflict, type RightsPageDryRun, type RightsPageIssue, type RightsPagePublishResult, type RightsPagePublished, type RightsPagePublisher, type RightsPageVersions, type RightsPageWriteOptions, type RiskScore, type RopaEntry, type RopaInput, SDK_VERSION, type ScanResult, type ScanStatus, type ScoredVendor, type ScrollbarTheme, type SessionAnalysisInput, type SignedReceipt, type Site, type SiteConfig, type SiteCookie, type SiteCreate, type SiteFlow, type SiteUpdate, type SiteUpdateResult, type SnippetOptions, type StorageType, type SubscriptionTopicInput, type SuggestedRejectStyle, type SupportedLanguage, type Usage, type VendorInput, type VendorRecord, type VerifyResult, type VerifyWebhookInput, type WebhookCreate, type WebhookDeadLetter, type WebhookKeyForm, type WebhookStage, type WebhookSubscription, type WebhookTestResult, type WebhookUpdate, createCookieMunch, mintConsentSyncToken, verifyWebhookSignature };
|
package/dist/index.js
CHANGED
|
@@ -26,8 +26,23 @@ function verifyWebhookSignature(input) {
|
|
|
26
26
|
return timingSafeEqual(got, want);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
// src/consent-sync.ts
|
|
30
|
+
import { createHmac as createHmac2 } from "crypto";
|
|
31
|
+
var SUBJECT_RE = /^[A-Za-z0-9._:@+/=~-]{1,128}$/;
|
|
32
|
+
function mintConsentSyncToken(input) {
|
|
33
|
+
if (!input.secret) throw new Error("mintConsentSyncToken: secret is required");
|
|
34
|
+
if (!input.cbid) throw new Error("mintConsentSyncToken: cbid is required");
|
|
35
|
+
if (!SUBJECT_RE.test(input.subject)) throw new Error("mintConsentSyncToken: subject must be 1\u2013128 characters of A-Z a-z 0-9 . _ : @ + / = ~ -");
|
|
36
|
+
const ttl = Math.floor(input.ttlSeconds ?? 3600);
|
|
37
|
+
if (!(ttl >= 1 && ttl <= 86400)) throw new Error("mintConsentSyncToken: ttlSeconds must be between 1 and 86400");
|
|
38
|
+
const iat = Math.floor((input.now ?? Date.now()) / 1e3);
|
|
39
|
+
const payload = Buffer.from(JSON.stringify({ c: input.cbid, s: input.subject, iat, exp: iat + ttl })).toString("base64url");
|
|
40
|
+
const sig = createHmac2("sha256", input.secret).update(`cms1.${payload}`).digest("base64url");
|
|
41
|
+
return `cms1.${payload}.${sig}`;
|
|
42
|
+
}
|
|
43
|
+
|
|
29
44
|
// src/index.ts
|
|
30
|
-
var SDK_VERSION = "0.
|
|
45
|
+
var SDK_VERSION = "0.5.0";
|
|
31
46
|
var CookieMunchApiError = class extends Error {
|
|
32
47
|
constructor(status, message, code, body) {
|
|
33
48
|
super(message);
|
|
@@ -329,6 +344,9 @@ function createCookieMunch(opts) {
|
|
|
329
344
|
save: (subjectId, purposes) => request("POST", "/preferences", { subjectId, purposes }),
|
|
330
345
|
get: (subjectId) => get(`/preferences/${enc(subjectId)}`)
|
|
331
346
|
},
|
|
347
|
+
preferenceCenter: {
|
|
348
|
+
mintToken: (input) => request("POST", "/preference-center/tokens", input)
|
|
349
|
+
},
|
|
332
350
|
members: {
|
|
333
351
|
list: () => get("/members"),
|
|
334
352
|
invite: (email, role) => request("POST", "/members", { email, role }),
|
|
@@ -359,6 +377,13 @@ function createCookieMunch(opts) {
|
|
|
359
377
|
},
|
|
360
378
|
test: (to) => request("POST", "/org/mail-provider/test", to ? { to } : {})
|
|
361
379
|
},
|
|
380
|
+
controller: {
|
|
381
|
+
get: () => get("/org/controller"),
|
|
382
|
+
set: (input) => request("PUT", "/org/controller", input),
|
|
383
|
+
remove: async () => {
|
|
384
|
+
await request("DELETE", "/org/controller");
|
|
385
|
+
}
|
|
386
|
+
},
|
|
362
387
|
rightsCaptcha: {
|
|
363
388
|
get: () => get("/org/rights-captcha"),
|
|
364
389
|
set: (input) => request("PUT", "/org/rights-captcha", input),
|
|
@@ -407,6 +432,11 @@ function createCookieMunch(opts) {
|
|
|
407
432
|
rightsLinks: {
|
|
408
433
|
create: (cbid, input) => request("POST", `/sites/${enc(cbid)}/rights-links`, input)
|
|
409
434
|
},
|
|
435
|
+
consentSyncSecret: {
|
|
436
|
+
get: (cbid) => get(`/sites/${enc(cbid)}/consent-sync-secret`),
|
|
437
|
+
rotate: (cbid) => request("POST", `/sites/${enc(cbid)}/consent-sync-secret`),
|
|
438
|
+
remove: (cbid) => request("DELETE", `/sites/${enc(cbid)}/consent-sync-secret`)
|
|
439
|
+
},
|
|
410
440
|
rightsCaptcha: {
|
|
411
441
|
get: (cbid) => get(`/sites/${enc(cbid)}/rights-captcha`),
|
|
412
442
|
set: (cbid, input) => request("PUT", `/sites/${enc(cbid)}/rights-captcha`, input),
|
|
@@ -441,6 +471,7 @@ export {
|
|
|
441
471
|
createCookieMunch,
|
|
442
472
|
getConsent,
|
|
443
473
|
isAllowed,
|
|
474
|
+
mintConsentSyncToken,
|
|
444
475
|
parseConsentValue,
|
|
445
476
|
readConsent,
|
|
446
477
|
verifyWebhookSignature
|