@newtype-ai/nit-sdk 0.3.0 → 0.3.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 +34 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,14 +14,19 @@ npm install @newtype-ai/nit-sdk
|
|
|
14
14
|
import { verifyAgent } from '@newtype-ai/nit-sdk';
|
|
15
15
|
|
|
16
16
|
// The agent sends you a login payload (generated by `nit sign --login your-app.com`)
|
|
17
|
-
const result = await verifyAgent(payload
|
|
17
|
+
const result = await verifyAgent(payload, {
|
|
18
|
+
policy: { max_identities_per_machine: 10, min_age_seconds: 3600 }
|
|
19
|
+
});
|
|
18
20
|
|
|
19
|
-
if (result.verified) {
|
|
21
|
+
if (result.verified && result.admitted) {
|
|
20
22
|
// result.agent_id — the agent's permanent UUID
|
|
21
23
|
// result.card — the agent's card for your domain (skills, description, etc.)
|
|
22
24
|
// result.wallet — { solana, evm } chain addresses
|
|
25
|
+
// result.identity — registration time, machine/IP identity counts, login history
|
|
23
26
|
// result.readToken — for fetching updated cards later
|
|
24
27
|
console.log(`Welcome, ${result.card?.name}`);
|
|
28
|
+
} else if (result.verified && !result.admitted) {
|
|
29
|
+
console.log('Identity verified but does not meet trust policy');
|
|
25
30
|
} else {
|
|
26
31
|
console.log(`Verification failed: ${result.error}`);
|
|
27
32
|
}
|
|
@@ -31,10 +36,10 @@ if (result.verified) {
|
|
|
31
36
|
|
|
32
37
|
1. The agent runs `nit sign --login your-app.com` to generate a signed login payload
|
|
33
38
|
2. The agent sends the payload to your app
|
|
34
|
-
3. Your app calls `verifyAgent(payload)` — this hits `api.newtype-ai.org/agent-card/verify`
|
|
35
|
-
4. You get back `{ verified
|
|
39
|
+
3. Your app calls `verifyAgent(payload, { policy })` — this hits `api.newtype-ai.org/agent-card/verify`
|
|
40
|
+
4. You get back `{ verified, admitted, agent_id, card, identity, attestation, ... }` or `{ verified: false, error }`
|
|
36
41
|
|
|
37
|
-
|
|
42
|
+
The server acts as an **identity registry** — it stores identity metadata, evaluates your trust policy, and returns a decision alongside raw signals. Like Stripe Radar: evaluates rules server-side for convenience, returns metadata for transparency.
|
|
38
43
|
|
|
39
44
|
## API
|
|
40
45
|
|
|
@@ -44,8 +49,30 @@ That's it. The server verifies the Ed25519 signature against the agent's registe
|
|
|
44
49
|
|-----------|------|-------------|
|
|
45
50
|
| `payload` | `LoginPayload` | `{ agent_id, domain, timestamp, signature }` from the agent |
|
|
46
51
|
| `options.apiUrl` | `string` | Override API URL (default: `https://api.newtype-ai.org`) |
|
|
47
|
-
|
|
48
|
-
|
|
52
|
+
| `options.policy` | `VerifyPolicy` | Trust rules the server evaluates (all optional) |
|
|
53
|
+
|
|
54
|
+
**Policy fields:**
|
|
55
|
+
|
|
56
|
+
| Field | Type | Description |
|
|
57
|
+
|-------|------|-------------|
|
|
58
|
+
| `max_identities_per_ip` | `number` | Reject if too many identities from same registration IP |
|
|
59
|
+
| `max_identities_per_machine` | `number` | Reject if too many identities from same machine |
|
|
60
|
+
| `min_age_seconds` | `number` | Reject identities younger than this (e.g., 5) |
|
|
61
|
+
| `max_login_rate_per_hour` | `number` | Reject if login rate is too high |
|
|
62
|
+
|
|
63
|
+
**Returns** `Promise<VerifyResult>`:
|
|
64
|
+
|
|
65
|
+
| Field | Type | Description |
|
|
66
|
+
|-------|------|-------------|
|
|
67
|
+
| `verified` | `boolean` | Ed25519 signature is valid |
|
|
68
|
+
| `admitted` | `boolean` | Identity meets your policy (`true` if no policy specified) |
|
|
69
|
+
| `agent_id` | `string` | Agent's permanent UUID |
|
|
70
|
+
| `card` | `AgentCard` | Agent's card for your domain |
|
|
71
|
+
| `branch` | `string` | Which branch the card came from (domain or `"main"`) |
|
|
72
|
+
| `wallet` | `{ solana, evm }` | Chain addresses |
|
|
73
|
+
| `readToken` | `string` | For fetching updated cards (30-day expiry) |
|
|
74
|
+
| `identity` | `IdentityMetadata` | Registration time, machine/IP counts, login history |
|
|
75
|
+
| `attestation` | `ServerAttestation` | Server's Ed25519 signature over the result |
|
|
49
76
|
|
|
50
77
|
## Full Integration Guide
|
|
51
78
|
|