@gentid/sdk 1.0.0 → 1.0.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 +130 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,130 @@
1
+ # @gentid/sdk
2
+
3
+ TypeScript SDK for [GentID](https://gentid.com) — cryptographic identity infrastructure for AI agents.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @gentid/sdk
9
+ ```
10
+
11
+ Requires Node.js 18 or later.
12
+
13
+ ## Quick start
14
+
15
+ ```typescript
16
+ import { GentIDClient } from '@gentid/sdk';
17
+
18
+ const gentid = new GentIDClient({
19
+ apiKey: process.env.GENTID_API_KEY!, // gid_live_...
20
+ });
21
+
22
+ // 1. Create an agent identity
23
+ const agent = await gentid.createAgent({ name: 'payments-bot', owner: 'acme-corp' });
24
+ console.log(agent.id); // gentic:agent:a3f9d2c1e8b4
25
+
26
+ // ⚠ Store agent.privateKey securely — it is returned only once, never again.
27
+
28
+ // 2. Sign any action
29
+ const { signature } = await gentid.signMessage(agent.id, 'approve-payment-$500');
30
+
31
+ // 3. Verify from anywhere — no API key needed
32
+ const { valid } = await gentid.verifySignature(agent.id, 'approve-payment-$500', signature);
33
+ console.log(valid); // true
34
+ ```
35
+
36
+ ## API reference
37
+
38
+ ### Agents
39
+
40
+ ```typescript
41
+ // Create a new agent identity
42
+ const agent: CreatedAgent = await gentid.createAgent({ name: string, owner: string });
43
+ // agent.privateKey is returned ONCE — store it in your secrets vault
44
+
45
+ // Get an agent
46
+ const agent: Agent = await gentid.getAgent(agentId);
47
+
48
+ // List agents by owner
49
+ const { agents, total } = await gentid.listAgents('acme-corp', { limit: 50, offset: 0 });
50
+
51
+ // Status management
52
+ await gentid.suspendAgent(agentId); // temporarily disable
53
+ await gentid.reactivateAgent(agentId); // re-enable
54
+ await gentid.revokeAgent(agentId); // permanent — cannot be undone
55
+ ```
56
+
57
+ ### Signatures
58
+
59
+ ```typescript
60
+ // Sign a message with an agent's private key (stored server-side)
61
+ const { signature, messageHash, logId } = await gentid.signMessage(agentId, message);
62
+
63
+ // Verify a signature
64
+ const { valid } = await gentid.verifySignature(agentId, message, signature);
65
+ ```
66
+
67
+ ### Verification
68
+
69
+ ```typescript
70
+ // Public lookup — no API key required
71
+ // Anyone can verify an agent's identity and public key
72
+ const identity: LookupResult = await gentid.lookupAgent(agentId);
73
+ // { id, name, status, publicKey, algorithm, owner, issuedAt }
74
+
75
+ // Request human/domain verification for an agent
76
+ const record = await gentid.requestVerification(agentId, 'manual'); // 'email' | 'domain' | 'manual'
77
+
78
+ // Check verification status
79
+ const records = await gentid.getVerificationStatus(agentId);
80
+ ```
81
+
82
+ ## Error handling
83
+
84
+ All methods throw `GentIDError` on failure:
85
+
86
+ ```typescript
87
+ import { GentIDClient, GentIDError } from '@gentid/sdk';
88
+
89
+ try {
90
+ await gentid.getAgent('gentic:agent:invalid');
91
+ } catch (err) {
92
+ if (err instanceof GentIDError) {
93
+ console.error(err.statusCode); // 404
94
+ console.error(err.message); // "Agent not found"
95
+ console.error(err.code); // "AGENT_NOT_FOUND"
96
+ }
97
+ }
98
+ ```
99
+
100
+ ## Configuration
101
+
102
+ ```typescript
103
+ const gentid = new GentIDClient({
104
+ apiKey: 'gid_live_...', // required
105
+ baseUrl: 'https://api.gentid.com', // optional — this is the default
106
+ });
107
+ ```
108
+
109
+ ## Verifying webhook signatures
110
+
111
+ If you use GentID webhooks, verify the `X-GentID-Signature` header:
112
+
113
+ ```typescript
114
+ import crypto from 'crypto';
115
+
116
+ function verifyWebhook(secret: string, rawBody: string, signatureHeader: string): boolean {
117
+ const [tPart, v1Part] = signatureHeader.split(',');
118
+ const timestamp = tPart.replace('t=', '');
119
+ const expected = v1Part.replace('v1=', '');
120
+ const sig = crypto
121
+ .createHmac('sha256', secret)
122
+ .update(`${timestamp}.${rawBody}`)
123
+ .digest('hex');
124
+ return crypto.timingSafeEqual(Buffer.from(sig), Buffer.from(expected));
125
+ }
126
+ ```
127
+
128
+ ## License
129
+
130
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gentid/sdk",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "TypeScript SDK for GentID — cryptographic identity for AI agents",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",