insumer-verify 1.1.3 → 1.1.4

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 +68 -33
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -4,7 +4,7 @@ Client-side verifier for [InsumerAPI](https://insumermodel.com/developers/) atte
4
4
 
5
5
  **In production:** [DJD Agent Score](https://github.com/jacobsd32-cpu/djdagentscore) (Coinbase x402 ecosystem) uses insumer-verify for client-side cryptographic verification in their AI agent wallet trust scoring pipeline. [Case study](https://insumermodel.com/blog/djd-agent-score-insumer-api-integration.html).
6
6
 
7
- Part of the InsumerAPI ecosystem: [REST API](https://insumermodel.com/developers/) (17 endpoints, 31 chains) | [MCP server](https://www.npmjs.com/package/mcp-server-insumer) (npm) | [LangChain](https://pypi.org/project/langchain-insumer/) (PyPI) | [OpenAI GPT](https://chatgpt.com/g/g-699c5e43ce2481918b3f1e7f144c8a49-insumerapi-verify) (GPT Store)
7
+ Part of the InsumerAPI ecosystem: [REST API](https://insumermodel.com/developers/) (25 endpoints, 31 chains) | [MCP server](https://www.npmjs.com/package/mcp-server-insumer) (npm) | [LangChain](https://pypi.org/project/langchain-insumer/) (PyPI) | [OpenAI GPT](https://chatgpt.com/g/g-699c5e43ce2481918b3f1e7f144c8a49-insumerapi-verify) (GPT Store)
8
8
 
9
9
  ## Install
10
10
 
@@ -14,27 +14,28 @@ npm install insumer-verify
14
14
 
15
15
  ## Usage
16
16
 
17
- ### Node.js
17
+ Call InsumerAPI, get a signed attestation, verify it:
18
18
 
19
19
  ```typescript
20
20
  import { verifyAttestation } from "insumer-verify";
21
21
 
22
- // Call InsumerAPI
22
+ // 1. Call InsumerAPI
23
23
  const res = await fetch("https://api.insumermodel.com/v1/attest", {
24
24
  method: "POST",
25
25
  headers: {
26
26
  "Content-Type": "application/json",
27
- "X-API-Key": "your-api-key",
27
+ "X-API-Key": "insr_live_your_key_here",
28
28
  },
29
29
  body: JSON.stringify({
30
- wallet: "0x...",
30
+ wallet: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
31
31
  conditions: [
32
32
  {
33
33
  type: "token_balance",
34
34
  chainId: 1,
35
- contractAddress: "0xA0b8...",
36
- threshold: "1000000",
35
+ contractAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
36
+ threshold: 1000,
37
37
  decimals: 6,
38
+ label: "USDC >= 1000 on Ethereum",
38
39
  },
39
40
  ],
40
41
  }),
@@ -42,45 +43,79 @@ const res = await fetch("https://api.insumermodel.com/v1/attest", {
42
43
 
43
44
  const apiResponse = await res.json();
44
45
 
45
- // Verify the attestation
46
- const result = await verifyAttestation(apiResponse);
46
+ // 2. Verify the attestation (signature, condition hashes, freshness, expiry)
47
+ const result = await verifyAttestation(apiResponse, {
48
+ jwksUrl: "https://insumermodel.com/.well-known/jwks.json",
49
+ maxAge: 120,
50
+ });
47
51
 
48
52
  if (result.valid) {
49
- console.log("Attestation verified");
53
+ const { pass, results } = apiResponse.data.attestation;
54
+ console.log(`All conditions ${pass ? "met" : "not met"}`);
55
+ for (const r of results) {
56
+ console.log(` ${r.label}: ${r.met ? "met" : "not met"}`);
57
+ }
50
58
  } else {
51
59
  console.log("Verification failed:", result.checks);
52
60
  }
53
61
  ```
54
62
 
63
+ ### What the API returns
64
+
65
+ The attestation response you're verifying looks like this:
66
+
67
+ ```json
68
+ {
69
+ "ok": true,
70
+ "data": {
71
+ "attestation": {
72
+ "id": "ATST-A7C3E",
73
+ "pass": true,
74
+ "results": [
75
+ {
76
+ "condition": 0,
77
+ "met": true,
78
+ "label": "USDC >= 1000 on Ethereum",
79
+ "type": "token_balance",
80
+ "chainId": 1,
81
+ "evaluatedCondition": {
82
+ "chainId": 1,
83
+ "contractAddress": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
84
+ "decimals": 6,
85
+ "operator": "gte",
86
+ "threshold": 1000,
87
+ "type": "token_balance"
88
+ },
89
+ "conditionHash": "0x8a3b...",
90
+ "blockNumber": "0x129e3f7",
91
+ "blockTimestamp": "2026-02-28T12:34:56.000Z"
92
+ }
93
+ ],
94
+ "passCount": 1,
95
+ "failCount": 0,
96
+ "attestedAt": "2026-02-28T12:34:57.000Z",
97
+ "expiresAt": "2026-02-28T13:04:57.000Z"
98
+ },
99
+ "sig": "MEUCIQD...(base64 ECDSA signature)...",
100
+ "kid": "insumer-attest-v1"
101
+ },
102
+ "meta": { "version": "1.0", "creditsCharged": 1, "creditsRemaining": 99 }
103
+ }
104
+ ```
105
+
106
+ No balances. No amounts. Just a signed true/false per condition.
107
+
55
108
  ### Browser
56
109
 
57
110
  ```html
58
111
  <script type="module">
59
112
  import { verifyAttestation } from "https://esm.sh/insumer-verify";
60
113
 
61
- const res = await fetch("https://api.insumermodel.com/v1/attest", {
62
- method: "POST",
63
- headers: {
64
- "Content-Type": "application/json",
65
- "X-API-Key": "your-api-key",
66
- },
67
- body: JSON.stringify({
68
- wallet: "0x...",
69
- conditions: [
70
- {
71
- type: "token_balance",
72
- chainId: 1,
73
- contractAddress: "0xA0b8...",
74
- threshold: "1000000",
75
- decimals: 6,
76
- },
77
- ],
78
- }),
114
+ // apiResponse = attestation from your backend
115
+ const result = await verifyAttestation(apiResponse, {
116
+ jwksUrl: "https://insumermodel.com/.well-known/jwks.json",
79
117
  });
80
-
81
- const apiResponse = await res.json();
82
- const result = await verifyAttestation(apiResponse);
83
- console.log(result);
118
+ console.log(result.valid, result.checks);
84
119
  </script>
85
120
  ```
86
121
 
@@ -101,7 +136,7 @@ By default, insumer-verify uses the hardcoded InsumerAPI public key. You can opt
101
136
 
102
137
  ```typescript
103
138
  const result = await verifyAttestation(apiResponse, {
104
- jwksUrl: "https://insumermodel.com/.well-known/jwks.json"
139
+ jwksUrl: "https://insumermodel.com/.well-known/jwks.json",
105
140
  });
106
141
  ```
107
142
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "insumer-verify",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "Client-side verifier for InsumerAPI attestations. ECDSA P-256 signatures, condition hashes, block freshness, expiry. Zero dependencies. Used by DJD Agent Score (Coinbase x402).",
5
5
  "type": "module",
6
6
  "main": "build/index.js",