@newtype-ai/nit-sdk 0.2.3 → 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 CHANGED
@@ -49,7 +49,7 @@ Returns `Promise<VerifyResult>` — either `{ verified: true, agent_id, domain,
49
49
 
50
50
  ## Full Integration Guide
51
51
 
52
- See [app-integration.md](https://github.com/newtype-ai/newtype-ai/blob/main/docs/app-integration.md) for the complete flow, endpoint spec, and examples in multiple languages.
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.
53
53
 
54
54
  ## License
55
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.2.3",
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": ["dist"],
19
+ "files": [
20
+ "dist"
21
+ ],
20
22
  "scripts": {
21
23
  "build": "tsup",
22
24
  "prepublishOnly": "npm run build"