@openpolicy/sdk 0.0.9 → 0.0.10
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/README.md +90 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,3 +1,91 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@openpolicy/sdk`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> TypeScript SDK for defining privacy policies and terms of service as code.
|
|
4
|
+
|
|
5
|
+
Part of [OpenPolicy](https://openpolicy.sh) — a policy-as-code framework that compiles legal agreements from TypeScript at build time.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
bun add @openpolicy/sdk
|
|
11
|
+
# or: npm install @openpolicy/sdk
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
### Privacy policy
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
// privacy.config.ts
|
|
20
|
+
import { definePrivacyPolicy } from "@openpolicy/sdk";
|
|
21
|
+
|
|
22
|
+
export default definePrivacyPolicy({
|
|
23
|
+
effectiveDate: "2026-01-01",
|
|
24
|
+
company: {
|
|
25
|
+
name: "Acme",
|
|
26
|
+
legalName: "Acme, Inc.",
|
|
27
|
+
address: "123 Main St, San Francisco, CA 94105",
|
|
28
|
+
contact: "privacy@acme.com",
|
|
29
|
+
},
|
|
30
|
+
dataCollected: {
|
|
31
|
+
"Account information": ["Email address", "Display name"],
|
|
32
|
+
"Usage data": ["Pages visited", "Session duration"],
|
|
33
|
+
},
|
|
34
|
+
legalBasis: "Legitimate interests and user consent",
|
|
35
|
+
retention: {
|
|
36
|
+
"Account data": "Until account deletion",
|
|
37
|
+
"Analytics data": "13 months",
|
|
38
|
+
},
|
|
39
|
+
cookies: { essential: true, analytics: true, marketing: false },
|
|
40
|
+
thirdParties: [
|
|
41
|
+
{ name: "Vercel", purpose: "Hosting" },
|
|
42
|
+
{ name: "Plausible", purpose: "Privacy-friendly analytics" },
|
|
43
|
+
],
|
|
44
|
+
userRights: ["access", "erasure", "portability"],
|
|
45
|
+
jurisdictions: ["us", "eu"],
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Terms of service
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
// terms.config.ts
|
|
53
|
+
import { defineTermsOfService } from "@openpolicy/sdk";
|
|
54
|
+
|
|
55
|
+
export default defineTermsOfService({
|
|
56
|
+
effectiveDate: "2026-01-01",
|
|
57
|
+
company: {
|
|
58
|
+
name: "Acme",
|
|
59
|
+
legalName: "Acme, Inc.",
|
|
60
|
+
address: "123 Main St, San Francisco, CA 94105",
|
|
61
|
+
contact: "legal@acme.com",
|
|
62
|
+
},
|
|
63
|
+
acceptance: { methods: ["using the service", "creating an account"] },
|
|
64
|
+
eligibility: { minimumAge: 13 },
|
|
65
|
+
disclaimers: { serviceProvidedAsIs: true, noWarranties: true },
|
|
66
|
+
limitationOfLiability: { excludesIndirectDamages: true },
|
|
67
|
+
governingLaw: { jurisdiction: "Delaware, USA" },
|
|
68
|
+
changesPolicy: {
|
|
69
|
+
noticeMethod: "email or prominent notice on the website",
|
|
70
|
+
noticePeriodDays: 30,
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Compiling policies
|
|
76
|
+
|
|
77
|
+
The SDK exports types and helper functions for _defining_ policies. To compile them to Markdown or HTML, pair it with one of:
|
|
78
|
+
|
|
79
|
+
- **[`@openpolicy/vite`](https://openpolicy.sh/docs/getting-started/vite)** — Vite plugin (build-time, with hot-reload in dev)
|
|
80
|
+
- **[`@openpolicy/astro`](https://openpolicy.sh/docs/getting-started/astro)** — Astro integration
|
|
81
|
+
- **[`@openpolicy/cli`](https://openpolicy.sh/docs/getting-started/cli)** — `openpolicy generate` CLI command
|
|
82
|
+
|
|
83
|
+
## Documentation
|
|
84
|
+
|
|
85
|
+
Full field reference and guides: [openpolicy.sh/docs](https://openpolicy.sh/docs)
|
|
86
|
+
|
|
87
|
+
## Links
|
|
88
|
+
|
|
89
|
+
- [GitHub](https://github.com/jamiedavenport/openpolicy)
|
|
90
|
+
- [openpolicy.sh](https://openpolicy.sh)
|
|
91
|
+
- [npm](https://www.npmjs.com/package/@openpolicy/sdk)
|