@chitmark/sdk 0.5.1 → 0.5.2
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 +10 -10
- package/package.json +1 -6
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Official TypeScript / JavaScript SDK for Chitmark: trust decisions on agent-mediated actions, tuned by business outcomes.
|
|
4
4
|
|
|
5
|
-
AI agents and multi-account farms drain free tiers, trial credits, and API allowances while looking exactly like your best customers. Chitmark scores each action in under 50 ms and returns `allow`, `challenge`, or `deny
|
|
5
|
+
AI agents and multi-account farms drain free tiers, trial credits, and API allowances while looking exactly like your best customers. Chitmark scores each action in under 50 ms and returns `allow`, `challenge`, or `deny`. Then your outcomes (conversion, credit burn, chargeback) come back through `feedback` and tune the next decision.
|
|
6
6
|
|
|
7
7
|
[](https://www.npmjs.com/package/@chitmark/sdk)
|
|
8
8
|
|
|
@@ -26,7 +26,7 @@ import { Chitmark } from "@chitmark/sdk";
|
|
|
26
26
|
const chitmark = new Chitmark({
|
|
27
27
|
apiKey: process.env.CHITMARK_API_KEY!,
|
|
28
28
|
// Optional, defaults shown
|
|
29
|
-
onDegraded: "challenge", //
|
|
29
|
+
onDegraded: "challenge", // timeouts return a challenge, they never throw or allow
|
|
30
30
|
timeoutMs: 800,
|
|
31
31
|
piiMode: "hashed", // 'hashed' | 'none' | 'raw'
|
|
32
32
|
env: "production",
|
|
@@ -58,11 +58,11 @@ if (verdict.decision === "challenge") {
|
|
|
58
58
|
| **feedback** | `chitmark.feedback()` | `POST /v1/feedback` | After an outcome is known |
|
|
59
59
|
| **challenge** | `chitmark.challenge()` | `POST /v1/challenge` | On `challenge` or `degraded` |
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
Timeouts and transport errors return a degraded challenge verdict and never throw on `verify`. HTTP errors throw `ChitmarkApiError` with the status attached. Set `onDegraded` to `challenge` (the only supported value), never allow on degraded.
|
|
62
62
|
|
|
63
|
-
###
|
|
63
|
+
### Report outcomes
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
Store the `eventId` from verify on the account row, then report what happened against that same id. Never guess or derive the id from email or IP.
|
|
66
66
|
|
|
67
67
|
```typescript
|
|
68
68
|
// At signup: persist the join key
|
|
@@ -70,7 +70,7 @@ db.accounts.update(userId, { chitmarkEventId: verdict.eventId });
|
|
|
70
70
|
|
|
71
71
|
// Later, when a label matures:
|
|
72
72
|
await chitmark.feedback({
|
|
73
|
-
eventId: account.chitmarkEventId, // the stored join key
|
|
73
|
+
eventId: account.chitmarkEventId, // the stored join key
|
|
74
74
|
outcome: "credit_burn", // converted | chargeback | abuse_confirmed | ...
|
|
75
75
|
value: 87.4, // dollar amount: `unit` rides along (default "usd")
|
|
76
76
|
observedAt: "2026-08-06T04:00:00Z",
|
|
@@ -79,9 +79,9 @@ await chitmark.feedback({
|
|
|
79
79
|
|
|
80
80
|
Exact duplicate feedback bodies derive the same warehouse id, so retrying a connector never double-counts a burned value.
|
|
81
81
|
|
|
82
|
-
###
|
|
82
|
+
### Handle a challenge
|
|
83
83
|
|
|
84
|
-
When verify returns `challenge`, issue one, solve it on the client, and complete it. Proof-of-work difficulty is server-issued (4 by default, up to 6 at higher risk tiers): about 65k hashes, milliseconds for one
|
|
84
|
+
When verify returns `challenge`, issue one, solve it on the client, and complete it. Proof-of-work difficulty is server-issued (4 by default, up to 6 at higher risk tiers): about 65k hashes, milliseconds for one real user, costly at farm scale.
|
|
85
85
|
|
|
86
86
|
```typescript
|
|
87
87
|
import { createHash } from "node:crypto";
|
|
@@ -111,7 +111,7 @@ if (issued.instructions.type === "pow") {
|
|
|
111
111
|
}
|
|
112
112
|
```
|
|
113
113
|
|
|
114
|
-
###
|
|
114
|
+
### Verify the receipt
|
|
115
115
|
|
|
116
116
|
Every production verdict ships a `verdictToken`: an ES256 JWT bound to session, origin, and event. Verify it before acting on high-value decisions:
|
|
117
117
|
|
|
@@ -170,7 +170,7 @@ prompt: `Integrate Chitmark into my app following https://chitmark.com/SKILL.md`
|
|
|
170
170
|
- [API reference](https://chitmark.com/docs)
|
|
171
171
|
- [Quickstart](https://chitmark.com/docs/quickstart)
|
|
172
172
|
- [OpenAPI contract](https://chitmark.com/openapi.yaml)
|
|
173
|
-
- [
|
|
173
|
+
- [Examples repository](https://github.com/nonameuserd/chitmark-examples)
|
|
174
174
|
|
|
175
175
|
## License
|
|
176
176
|
|
package/package.json
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chitmark/sdk",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
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",
|
|
7
7
|
"homepage": "https://chitmark.com",
|
|
8
|
-
"repository": {
|
|
9
|
-
"type": "git",
|
|
10
|
-
"url": "https://github.com/nonameuserd/Chitmark.git",
|
|
11
|
-
"directory": "packages/sdk"
|
|
12
|
-
},
|
|
13
8
|
"keywords": [
|
|
14
9
|
"chitmark",
|
|
15
10
|
"open-agent-ledger",
|