UNPKG

@openpolicy/sdk

Version:

Public API for defining privacy policies with OpenPolicy

262 lines (261 loc) 7.71 kB
import { dataCollected, thirdParties } from "./auto-collected.js"; //#region ../core/dist/index.d.ts type PolicyCategory = "privacy" | "cookie"; type Jurisdiction = "us" | "eu" | "ca" | "au" | "nz" | "other"; type LegalBasis = "consent" | "contract" | "legal_obligation" | "vital_interests" | "public_task" | "legitimate_interests"; type CompanyConfig = { name: string; legalName: string; address: string; contact: string; }; type EffectiveDate = `${number}-${number}-${number}`; type DataCollection = Record<string, string[]>; type Retention$1 = Record<string, string>; type ThirdParty = { name: string; purpose: string; policyUrl?: string; }; type ChildrenConfig = { underAge: number; noticeUrl?: string; }; type CookiePolicyCookies = { essential: boolean; [key: string]: boolean; }; type TrackingTechnology = string; type ConsentMechanism = { hasBanner: boolean; hasPreferencePanel: boolean; canWithdraw: boolean; }; type OpenPolicyConfig = { company: CompanyConfig; effectiveDate: EffectiveDate; jurisdictions: Jurisdiction[]; dataCollected?: DataCollection; legalBasis?: LegalBasis | LegalBasis[]; retention?: Retention$1; children?: ChildrenConfig; thirdParties?: ThirdParty[]; cookies?: CookiePolicyCookies; trackingTechnologies?: TrackingTechnology[]; consentMechanism?: ConsentMechanism; policies?: PolicyCategory[]; }; //#endregion //#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 legalBasis: LegalBasis[]; }; 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/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 declare function defineConfig(config: OpenPolicyConfig): OpenPolicyConfig; //#endregion export { type ChildrenConfig, type CompanyConfig, Compliance, type ConsentMechanism, type CookiePolicyCookies, DataCategories, type DataCollection, type EffectiveDate, Ignore, type Jurisdiction, LegalBases, type LegalBasis, type OpenPolicyConfig, type PolicyCategory, Providers, type Retention, type Retention$1 as RetentionMap, type ThirdParty, type TrackingTechnology, collecting, dataCollected, defineConfig, thirdParties, thirdParty }; //# sourceMappingURL=index.d.ts.map