@chitmark/sdk 0.1.0 → 0.1.1

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.
Files changed (2) hide show
  1. package/README.md +43 -36
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,16 +1,8 @@
1
1
  # @chitmark/sdk
2
2
 
3
- Official TypeScript / JavaScript SDK for **Chitmark by Open Agent Ledger** — trust decisions on agent-mediated actions, tuned by business outcomes (`verify` / `feedback` / `challenge`). Day-one wedge: agent-farming defense at signup/trial; outcomes label scoring, not a payments product.
3
+ Official TypeScript / JavaScript SDK for Chitmark — trust decisions on agent-mediated actions, tuned by business outcomes (`verify` / `feedback` / `challenge`).
4
4
 
5
- Three verbs:
6
-
7
- | Verb | Method | Endpoint | When |
8
- | :------------ | :--------------------- | :------------------- | :--------------------------- |
9
- | **verify** | `chitmark.verify()` | `POST /v1/verify` | At signup / trial / action |
10
- | **feedback** | `chitmark.feedback()` | `POST /v1/feedback` | After an outcome is known |
11
- | **challenge** | `chitmark.challenge()` | `POST /v1/challenge` | On `challenge` or `degraded` |
12
-
13
- **Golden rule:** fail to `challenge`, never to `allow`. Timeouts return a degraded challenge verdict.
5
+ [![npm version](https://img.shields.io/npm/v/@chitmark/sdk.svg)](https://www.npmjs.com/package/@chitmark/sdk)
14
6
 
15
7
  ## Install
16
8
 
@@ -20,12 +12,14 @@ npm install @chitmark/sdk
20
12
  pnpm add @chitmark/sdk
21
13
  ```
22
14
 
15
+ Requires Node ≥ 24.
16
+
23
17
  ## Quick start
24
18
 
25
19
  ```typescript
26
20
  import { Chitmark } from "@chitmark/sdk";
27
21
 
28
- export const chitmark = new Chitmark({
22
+ const chitmark = new Chitmark({
29
23
  apiKey: process.env.CHITMARK_API_KEY!,
30
24
  // Optional — defaults shown
31
25
  onDegraded: "challenge", // NEVER 'allow'
@@ -34,7 +28,7 @@ export const chitmark = new Chitmark({
34
28
  env: "production",
35
29
  });
36
30
 
37
- const v = await chitmark.verify({
31
+ const verdict = await chitmark.verify({
38
32
  action: "signup",
39
33
  session: "sess_9f3a",
40
34
  surface: "app.acme.com/signup",
@@ -46,17 +40,47 @@ const v = await chitmark.verify({
46
40
  },
47
41
  });
48
42
 
49
- // Store v.eventId on the account row for feedback joins
50
- // With piiMode: "hashed", email/ip are minimized before the wire.
43
+ // Persist verdict.eventId on the account row — feedback joins only on that id.
44
+ ```
45
+
46
+ ## API
47
+
48
+ Three verbs:
49
+
50
+ | Verb | Method | Endpoint | When |
51
+ | :------------ | :--------------------- | :------------------- | :--------------------------- |
52
+ | **verify** | `chitmark.verify()` | `POST /v1/verify` | At signup / trial / action |
53
+ | **feedback** | `chitmark.feedback()` | `POST /v1/feedback` | After an outcome is known |
54
+ | **challenge** | `chitmark.challenge()` | `POST /v1/challenge` | On `challenge` or `degraded` |
55
+
56
+ **Golden rule:** fail to `challenge`, never to `allow`. Timeouts return a degraded challenge verdict.
57
+
58
+ ### Feedback
59
+
60
+ ```typescript
61
+ await chitmark.feedback({
62
+ eventId: verdict.eventId, // stored at signup
63
+ outcome: "credit_burn", // outcomes label scoring
64
+ value: 87.4,
65
+ unit: "usd",
66
+ });
51
67
  ```
52
68
 
53
- ## Edge (Cloudflare Workers)
69
+ ### PII
70
+
71
+ | Mode | Behavior |
72
+ | :------------ | :----------------------------------------------------------- |
73
+ | `hashed` (default) | SHA-256 email, /24 IP truncation, minimized form fields |
74
+ | `none` | Derived/header-shape signals only (Web Bot Auth preserved) |
75
+ | `raw` | Tenant opt-in only; triggers higher compliance review |
76
+
77
+ ## Cloudflare Workers
54
78
 
55
79
  ```typescript
56
80
  import { Chitmark } from "@chitmark/sdk/edge";
57
81
 
58
82
  const chitmark = new Chitmark({ apiKey: env.CHITMARK_API_KEY });
59
- const v = await chitmark.verifyRequest(req, { action: "signup" });
83
+ const verdict = await chitmark.verifyRequest(req, { action: "signup" });
60
84
  ```
61
85
 
62
86
  ## Express middleware
@@ -68,29 +92,12 @@ const chitmark = new Chitmark({ apiKey: process.env.CHITMARK_API_KEY! });
68
92
  app.post("/signup", chitmarkGate(chitmark, "signup"), signupHandler);
69
93
  ```
70
94
 
71
- ## PII modes
72
-
73
- - **`hashed` (default)** — SHA-256 email, /24 IP truncation, minimized form fields
74
- - **`none`** — derived/header-shape signals only (Web Bot Auth headers preserved)
75
- - **`raw`** — tenant opt-in only; triggers higher compliance review
76
-
77
- ## Feedback
78
-
79
- ```typescript
80
- // Store v.eventId on the account row at signup — feedback joins only on that id.
81
- await chitmark.feedback({
82
- eventId: v.eventId,
83
- outcome: "credit_burn", // outcomes label scoring
84
- value: 87.4,
85
- unit: "usd",
86
- });
87
- ```
88
-
89
95
  ## Resources
90
96
 
91
97
  - [API reference](https://chitmark.com/docs)
92
98
  - [OpenAPI contract](https://chitmark.com/openapi.yaml)
93
99
  - [GitHub](https://github.com/nonameuserd/Chitmark)
94
- - Node ≥ 24 (workers-compatible `@chitmark/sdk/edge` subpath for Cloudflare)
95
100
 
96
- **License:** proprietary — see [LICENSE](LICENSE).
101
+ ## License
102
+
103
+ Proprietary — see [LICENSE](LICENSE).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chitmark/sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Official TypeScript SDK for Chitmark by Open Agent Ledger — trust decisions on agent-mediated actions (verify, feedback, challenge)",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Open Agent Ledger",