@newtype-ai/nit-sdk 0.2.2 → 0.3.0
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 +6 -5
- package/dist/index.d.ts +33 -1
- package/dist/index.js +2 -1
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -18,8 +18,9 @@ const result = await verifyAgent(payload);
|
|
|
18
18
|
|
|
19
19
|
if (result.verified) {
|
|
20
20
|
// result.agent_id — the agent's permanent UUID
|
|
21
|
-
// result.card — the agent's
|
|
22
|
-
// result.
|
|
21
|
+
// result.card — the agent's card for your domain (skills, description, etc.)
|
|
22
|
+
// result.wallet — { solana, evm } chain addresses
|
|
23
|
+
// result.readToken — for fetching updated cards later
|
|
23
24
|
console.log(`Welcome, ${result.card?.name}`);
|
|
24
25
|
} else {
|
|
25
26
|
console.log(`Verification failed: ${result.error}`);
|
|
@@ -31,7 +32,7 @@ if (result.verified) {
|
|
|
31
32
|
1. The agent runs `nit sign --login your-app.com` to generate a signed login payload
|
|
32
33
|
2. The agent sends the payload to your app
|
|
33
34
|
3. Your app calls `verifyAgent(payload)` — this hits `api.newtype-ai.org/agent-card/verify`
|
|
34
|
-
4. You get back `{ verified: true, agent_id, card }` or `{ verified: false, error }`
|
|
35
|
+
4. You get back `{ verified: true, agent_id, card, branch, wallet, readToken }` or `{ verified: false, error }`
|
|
35
36
|
|
|
36
37
|
That's it. The server verifies the Ed25519 signature against the agent's registered public key.
|
|
37
38
|
|
|
@@ -44,11 +45,11 @@ That's it. The server verifies the Ed25519 signature against the agent's registe
|
|
|
44
45
|
| `payload` | `LoginPayload` | `{ agent_id, domain, timestamp, signature }` from the agent |
|
|
45
46
|
| `options.apiUrl` | `string` | Override API URL (default: `https://api.newtype-ai.org`) |
|
|
46
47
|
|
|
47
|
-
Returns `Promise<VerifyResult>` — either `{ verified: true, agent_id, domain, card,
|
|
48
|
+
Returns `Promise<VerifyResult>` — either `{ verified: true, agent_id, domain, card, branch, wallet, readToken }` or `{ verified: false, error }`.
|
|
48
49
|
|
|
49
50
|
## Full Integration Guide
|
|
50
51
|
|
|
51
|
-
See [app-integration.md](
|
|
52
|
+
See [docs/app-integration.md](docs/app-integration.md) for the complete flow, endpoint spec, code examples in multiple languages, fetching updated cards, and security notes.
|
|
52
53
|
|
|
53
54
|
## License
|
|
54
55
|
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ interface LoginPayload {
|
|
|
10
10
|
domain: string;
|
|
11
11
|
timestamp: number;
|
|
12
12
|
signature: string;
|
|
13
|
+
/** Agent's public key. Present in nit >= 0.6.0. */
|
|
14
|
+
public_key?: string;
|
|
13
15
|
}
|
|
14
16
|
/** A skill listed in an agent's card. */
|
|
15
17
|
interface AgentCardSkill {
|
|
@@ -43,9 +45,33 @@ interface AgentCard {
|
|
|
43
45
|
iconUrl?: string;
|
|
44
46
|
documentationUrl?: string;
|
|
45
47
|
}
|
|
48
|
+
/** Identity metadata returned by the server. */
|
|
49
|
+
interface IdentityMetadata {
|
|
50
|
+
registration_timestamp: number | null;
|
|
51
|
+
machine_identity_count: number;
|
|
52
|
+
ip_identity_count: number;
|
|
53
|
+
total_logins: number;
|
|
54
|
+
last_login_timestamp: number | null;
|
|
55
|
+
unique_domains: number;
|
|
56
|
+
}
|
|
57
|
+
/** App-defined trust policy. Server evaluates and returns admitted: true/false. */
|
|
58
|
+
interface VerifyPolicy {
|
|
59
|
+
max_identities_per_ip?: number;
|
|
60
|
+
max_identities_per_machine?: number;
|
|
61
|
+
min_age_seconds?: number;
|
|
62
|
+
max_login_rate_per_hour?: number;
|
|
63
|
+
}
|
|
64
|
+
/** Server attestation proving the server endorsed this verification. */
|
|
65
|
+
interface ServerAttestation {
|
|
66
|
+
server_signature: string;
|
|
67
|
+
server_url: string;
|
|
68
|
+
server_public_key: string;
|
|
69
|
+
}
|
|
46
70
|
/** Successful verification result. */
|
|
47
71
|
interface VerifySuccess {
|
|
48
72
|
verified: true;
|
|
73
|
+
/** Whether the identity meets the app's policy. True if no policy were specified. */
|
|
74
|
+
admitted: boolean;
|
|
49
75
|
agent_id: string;
|
|
50
76
|
domain: string;
|
|
51
77
|
card: AgentCard | null;
|
|
@@ -58,6 +84,10 @@ interface VerifySuccess {
|
|
|
58
84
|
} | null;
|
|
59
85
|
/** HMAC-signed read token for fetching the agent's domain branch card. 30-day expiry. */
|
|
60
86
|
readToken: string;
|
|
87
|
+
/** Identity metadata — registration time, login count, machine/IP grouping, etc. */
|
|
88
|
+
identity?: IdentityMetadata;
|
|
89
|
+
/** Server attestation (if server signing key is configured). */
|
|
90
|
+
attestation?: ServerAttestation;
|
|
61
91
|
}
|
|
62
92
|
/** Failed verification result. */
|
|
63
93
|
interface VerifyFailure {
|
|
@@ -68,6 +98,8 @@ type VerifyResult = VerifySuccess | VerifyFailure;
|
|
|
68
98
|
interface VerifyOptions {
|
|
69
99
|
/** Override the API base URL. Defaults to https://api.newtype-ai.org */
|
|
70
100
|
apiUrl?: string;
|
|
101
|
+
/** App-defined trust policy. Server evaluates and returns admitted: true/false. */
|
|
102
|
+
policy?: VerifyPolicy;
|
|
71
103
|
}
|
|
72
104
|
interface FetchCardOptions {
|
|
73
105
|
/** Override the base URL for agent card hosting. Defaults to https://agent-{agent_id}.newtype-ai.org */
|
|
@@ -107,4 +139,4 @@ declare function verifyAgent(payload: LoginPayload, options?: VerifyOptions): Pr
|
|
|
107
139
|
*/
|
|
108
140
|
declare function fetchAgentCard(agentId: string, domain: string, readToken: string, options?: FetchCardOptions): Promise<AgentCard | null>;
|
|
109
141
|
|
|
110
|
-
export { type AgentCard, type AgentCardSkill, type FetchCardOptions, type LoginPayload, type VerifyFailure, type VerifyOptions, type VerifyResult, type VerifySuccess, fetchAgentCard, verifyAgent };
|
|
142
|
+
export { type AgentCard, type AgentCardSkill, type FetchCardOptions, type IdentityMetadata, type LoginPayload, type ServerAttestation, type VerifyFailure, type VerifyOptions, type VerifyPolicy, type VerifyResult, type VerifySuccess, fetchAgentCard, verifyAgent };
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,8 @@ async function verifyAgent(payload, options) {
|
|
|
9
9
|
agent_id: payload.agent_id,
|
|
10
10
|
domain: payload.domain,
|
|
11
11
|
timestamp: payload.timestamp,
|
|
12
|
-
signature: payload.signature
|
|
12
|
+
signature: payload.signature,
|
|
13
|
+
...options?.policy ? { policy: options.policy } : {}
|
|
13
14
|
})
|
|
14
15
|
});
|
|
15
16
|
return res.json();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@newtype-ai/nit-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Verify agent identity with one function call",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,7 +16,9 @@
|
|
|
16
16
|
},
|
|
17
17
|
"main": "./dist/index.js",
|
|
18
18
|
"types": "./dist/index.d.ts",
|
|
19
|
-
"files": [
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
20
22
|
"scripts": {
|
|
21
23
|
"build": "tsup",
|
|
22
24
|
"prepublishOnly": "npm run build"
|