UNPKG

@openpolicy/sdk

Version:

Public API for defining privacy policies with OpenPolicy

244 lines (243 loc) 8.59 kB
import { ScannedCollectionKeys, ScannedCookieKeys, cookies, dataCollected, thirdParties } from "./auto-collected.js"; import { A as Voluntary, C as OpenPolicyConfig, D as Statutory, E as ProvisionRequirement, M as computePrivacyVersion, O as ThirdParty, S as Locale, T as ProvisionBasis, _ as Dpo, a as ConsentMechanism, b as Jurisdiction, c as Contractual, d as CookiePolicyCookies, f as CookieUsage, g as DataContextEntry, h as DataContext, i as CompanyConfig, j as computeCookieVersion, k as TrackingTechnology, l as CookieContext, m as DataConfig, n as AutomatedDecisionMaking, o as Contact, p as DataCollection, r as ChildrenConfig, s as ContractPrerequisite, t as AutomatedDecision, u as CookieContextEntry, v as EffectiveDate, w as PolicyCategory, x as LegalBasis, y as EuRepresentative } from "./index-BnGK1COr.js"; //#region src/collecting.d.ts /** * Sentinel used as a label value to explicitly exclude a field from the * compiled privacy policy. Every key of the `value` passed to `collecting()` * must appear in the label record — pass `Ignore` for fields that should not * appear in the policy (e.g. `hashedPassword: Ignore`). * * It is a `unique symbol` so it cannot collide with a real label string and * so the type checker treats it nominally. */ declare const Ignore: unique symbol; /** * Declares data collected at the point of storage. Returns `value` unchanged * at runtime — the Vite plugin / CLI static analyser (OP-152) will scan calls * to `collecting()` at build time and merge the declarations into the * compiled privacy policy. * * The third argument is a plain object literal whose **keys** are field names * matching your stored value (for convenient access without a typed callback) * and whose **values** are the human-readable labels used in the compiled * policy. Only the string values are used by the analyser; the object is * never evaluated at runtime. This shape lets you: * - keep `value` matching your ORM/table schema exactly, * - describe fields with friendly labels for the policy, * - exclude a field from the policy by setting its label to `Ignore` * (imported from `@openpolicy/sdk`) — every key of `value` must appear * in the label record, so e.g. `hashedPassword: Ignore` is how you hide * a sensitive column. * * The category argument and the string values of the label record must be * string literals — dynamic values are silently skipped by the analyser. * * @example * ```ts * import { collecting, Ignore } from "@openpolicy/sdk"; * * export async function createUser( * name: string, * email: string, * hashedPassword: string, * ) { * return db.insert(users).values( * collecting( * "Account Information", * { name, email, hashedPassword }, // real ORM columns — returned unchanged * { name: "Name", email: "Email address", hashedPassword: Ignore }, * ), * ); * } * ``` */ declare function collecting<T>(_category: string, value: T, _label: Record<keyof T, string | typeof Ignore>): T; //#endregion //#region src/compliance.d.ts declare const Compliance: { readonly GDPR: { readonly jurisdictions: Jurisdiction[]; }; readonly UK_GDPR: { readonly jurisdictions: Jurisdiction[]; }; readonly CCPA: { readonly jurisdictions: Jurisdiction[]; }; }; //#endregion //#region src/data.d.ts declare const DataCategories: { readonly AccountInfo: { readonly "Account Information": readonly ["Name", "Email address"]; }; readonly SessionData: { readonly "Session Data": readonly ["IP address", "User agent", "Browser type"]; }; readonly PaymentInfo: { readonly "Payment Information": readonly ["Card last 4 digits", "Billing name", "Billing address"]; }; readonly UsageData: { readonly "Usage Data": readonly ["Pages visited", "Features used", "Time spent"]; }; readonly DeviceInfo: { readonly "Device Information": readonly ["Device type", "Operating system", "Browser version"]; }; readonly LocationData: { readonly "Location Data": readonly ["Country", "City", "Timezone"]; }; readonly Communications: { readonly Communications: readonly ["Email content", "Support tickets"]; }; }; declare const Retention: { readonly UntilAccountDeletion: "Until account deletion"; readonly UntilSessionExpiry: "Until session expiry"; readonly ThirtyDays: "30 days"; readonly NinetyDays: "90 days"; readonly OneYear: "1 year"; readonly ThreeYears: "3 years"; readonly AsRequiredByLaw: "As required by applicable law"; }; declare const LegalBases: { readonly Consent: "consent"; readonly Contract: "contract"; readonly LegalObligation: "legal_obligation"; readonly VitalInterests: "vital_interests"; readonly PublicTask: "public_task"; readonly LegitimateInterests: "legitimate_interests"; }; //#endregion //#region src/define-cookie.d.ts declare function defineCookie(_category: string): void; //#endregion //#region src/providers.d.ts declare const Providers: { Stripe: { name: string; purpose: string; policyUrl: string; }; Paddle: { name: string; purpose: string; policyUrl: string; }; LemonSqueezy: { name: string; purpose: string; policyUrl: string; }; PayPal: { name: string; purpose: string; policyUrl: string; }; GoogleAnalytics: { name: string; purpose: string; policyUrl: string; }; PostHog: { name: string; purpose: string; policyUrl: string; }; Plausible: { name: string; purpose: string; policyUrl: string; }; Mixpanel: { name: string; purpose: string; policyUrl: string; }; Vercel: { name: string; purpose: string; policyUrl: string; }; Cloudflare: { name: string; purpose: string; policyUrl: string; }; AWS: { name: string; purpose: string; policyUrl: string; }; Auth0: { name: string; purpose: string; policyUrl: string; }; Clerk: { name: string; purpose: string; policyUrl: string; }; Resend: { name: string; purpose: string; policyUrl: string; }; Postmark: { name: string; purpose: string; policyUrl: string; }; SendGrid: { name: string; purpose: string; policyUrl: string; }; Loops: { name: string; purpose: string; policyUrl: string; }; Sentry: { name: string; purpose: string; policyUrl: string; }; Datadog: { name: string; purpose: string; policyUrl: string; }; }; //#endregion //#region src/third-parties.d.ts declare function thirdParty(_name: string, _purpose: string, _policyUrl: string): void; //#endregion //#region src/index.d.ts type ScannedDataKey = keyof ScannedCollectionKeys & string; type ScannedCookieKey = keyof ScannedCookieKeys & string; type DataKey<Collected> = Extract<keyof Collected, string> | ScannedDataKey; type CookieKey<Used> = Extract<keyof Used, string> | ScannedCookieKey; type OpenPolicyConfigWithGenerics<Collected extends Record<string, string[]>, CookieUsed extends { essential: true; [k: string]: boolean; }> = Omit<OpenPolicyConfig, "data" | "cookies"> & { data?: { collected: Collected; context: { [P in DataKey<Collected>]: DataContextEntry }; }; cookies?: { used: CookieUsed; context: { [P in CookieKey<CookieUsed>]: CookieContextEntry }; }; }; declare function defineConfig<Collected extends Record<string, string[]> = Record<string, string[]>, CookieUsed extends { essential: true; [k: string]: boolean; } = { essential: true; [k: string]: boolean; }>(config: OpenPolicyConfigWithGenerics<Collected, CookieUsed>): OpenPolicyConfig; //#endregion export { type AutomatedDecision, type AutomatedDecisionMaking, type ChildrenConfig, type CompanyConfig, Compliance, type ConsentMechanism, type Contact, ContractPrerequisite, Contractual, type CookieContext, type CookieContextEntry, type CookiePolicyCookies, type CookieUsage, DataCategories, type DataCollection, type DataConfig, type DataContext, type DataContextEntry, type Dpo, type EffectiveDate, type EuRepresentative, Ignore, type Jurisdiction, LegalBases, type LegalBasis, type Locale, type OpenPolicyConfig, type PolicyCategory, Providers, type ProvisionBasis, type ProvisionRequirement, Retention, type ScannedCollectionKeys, type ScannedCookieKeys, Statutory, type ThirdParty, type TrackingTechnology, Voluntary, collecting, computeCookieVersion, computePrivacyVersion, cookies, dataCollected, defineConfig, defineCookie, thirdParties, thirdParty }; //# sourceMappingURL=index.d.ts.map