@astrasyncai/verification-gateway 2.3.9 → 2.4.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 +64 -9
- package/dist/adapter-interface/interface.d.mts +2 -2
- package/dist/adapter-interface/interface.d.ts +2 -2
- package/dist/adapters/express.d.mts +2 -2
- package/dist/adapters/express.d.ts +2 -2
- package/dist/adapters/express.js +6 -0
- package/dist/adapters/express.js.map +1 -1
- package/dist/adapters/express.mjs +6 -0
- package/dist/adapters/express.mjs.map +1 -1
- package/dist/adapters/mcp.d.mts +1 -1
- package/dist/adapters/mcp.d.ts +1 -1
- package/dist/adapters/mcp.js +44 -4
- package/dist/adapters/mcp.js.map +1 -1
- package/dist/adapters/mcp.mjs +44 -4
- package/dist/adapters/mcp.mjs.map +1 -1
- package/dist/adapters/nextjs.d.mts +2 -2
- package/dist/adapters/nextjs.d.ts +2 -2
- package/dist/adapters/nextjs.js +6 -0
- package/dist/adapters/nextjs.js.map +1 -1
- package/dist/adapters/nextjs.mjs +6 -0
- package/dist/adapters/nextjs.mjs.map +1 -1
- package/dist/adapters/sdk.d.mts +2 -2
- package/dist/adapters/sdk.d.ts +2 -2
- package/dist/adapters/sdk.js +6 -0
- package/dist/adapters/sdk.js.map +1 -1
- package/dist/adapters/sdk.mjs +6 -0
- package/dist/adapters/sdk.mjs.map +1 -1
- package/dist/agent/index.d.mts +2 -2
- package/dist/agent/index.d.ts +2 -2
- package/dist/bin/astrasync.js +348 -0
- package/dist/browser/background.js +6 -0
- package/dist/browser/background.js.map +1 -1
- package/dist/browser/background.mjs +6 -0
- package/dist/browser/background.mjs.map +1 -1
- package/dist/browser/browser-adapter.d.mts +2 -2
- package/dist/browser/browser-adapter.d.ts +2 -2
- package/dist/cli/index.d.mts +2 -2
- package/dist/cli/index.d.ts +2 -2
- package/dist/cursor/cursor-adapter.d.mts +2 -2
- package/dist/cursor/cursor-adapter.d.ts +2 -2
- package/dist/cursor/extension.d.mts +2 -2
- package/dist/cursor/extension.d.ts +2 -2
- package/dist/cursor/extension.js +6 -0
- package/dist/cursor/extension.js.map +1 -1
- package/dist/cursor/extension.mjs +6 -0
- package/dist/cursor/extension.mjs.map +1 -1
- package/dist/{express-BiB51d5t.d.mts → express-4Vau6x6X.d.mts} +1 -1
- package/dist/{express-D6tEDU08.d.ts → express-Nq-wWICa.d.ts} +1 -1
- package/dist/gateway/gateway.d.mts +2 -2
- package/dist/gateway/gateway.d.ts +2 -2
- package/dist/gateway/gateway.js +6 -0
- package/dist/gateway/gateway.js.map +1 -1
- package/dist/gateway/gateway.mjs +6 -0
- package/dist/gateway/gateway.mjs.map +1 -1
- package/dist/git-trigger/git-hooks.d.mts +2 -2
- package/dist/git-trigger/git-hooks.d.ts +2 -2
- package/dist/{index-8DFMpITk.d.ts → index-B-EovXnY.d.ts} +1 -1
- package/dist/{index-Yt02MRyu.d.ts → index-CxwCN7AC.d.ts} +1 -1
- package/dist/{index-CAykfMWK.d.mts → index-DiToN8gh.d.mts} +1 -1
- package/dist/{index-B--6fiDp.d.mts → index-DkyPV14Y.d.mts} +1 -1
- package/dist/index.d.mts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -0
- package/dist/index.mjs.map +1 -1
- package/dist/local-evaluator/evaluator.d.mts +2 -2
- package/dist/local-evaluator/evaluator.d.ts +2 -2
- package/dist/{nextjs-CpxqfQqD.d.mts → nextjs-BTR7Oix-.d.mts} +1 -1
- package/dist/{nextjs-CK5F_tVZ.d.ts → nextjs-DO_4crcp.d.ts} +1 -1
- package/dist/registration/index.d.mts +218 -0
- package/dist/registration/index.d.ts +218 -0
- package/dist/registration/index.js +212 -0
- package/dist/registration/index.js.map +1 -0
- package/dist/registration/index.mjs +172 -0
- package/dist/registration/index.mjs.map +1 -0
- package/dist/{sdk-yJjO7yzn.d.mts → sdk-DSLCyXIX.d.mts} +1 -1
- package/dist/{sdk-BMvauMgP.d.ts → sdk-TnHXD-Oh.d.ts} +1 -1
- package/dist/transport/index.d.mts +2 -2
- package/dist/transport/index.d.ts +2 -2
- package/dist/{types-UYT4GdPW.d.mts → types-BVp22KkN.d.mts} +12 -0
- package/dist/{types-UYT4GdPW.d.ts → types-BVp22KkN.d.ts} +12 -0
- package/dist/{types-ppkhdldJ.d.ts → types-DVCWReEN.d.ts} +1 -1
- package/dist/{types-CKafuHDn.d.mts → types-pU2O0BFq.d.mts} +1 -1
- package/dist/ui/index.d.mts +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/package.json +14 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as LocalPolicy, P as PDLSSContext, V as VerificationDecision, a as LocalPurposeRule } from '../types-
|
|
2
|
-
import '../types-
|
|
1
|
+
import { L as LocalPolicy, P as PDLSSContext, V as VerificationDecision, a as LocalPurposeRule } from '../types-pU2O0BFq.mjs';
|
|
2
|
+
import '../types-BVp22KkN.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Local PDLSS Evaluator
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as LocalPolicy, P as PDLSSContext, V as VerificationDecision, a as LocalPurposeRule } from '../types-
|
|
2
|
-
import '../types-
|
|
1
|
+
import { L as LocalPolicy, P as PDLSSContext, V as VerificationDecision, a as LocalPurposeRule } from '../types-DVCWReEN.js';
|
|
2
|
+
import '../types-BVp22KkN.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Local PDLSS Evaluator
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as next_server from 'next/server';
|
|
2
2
|
import { NextRequest } from 'next/server';
|
|
3
|
-
import { N as NextJsMiddlewareOptions } from './types-
|
|
3
|
+
import { N as NextJsMiddlewareOptions } from './types-BVp22KkN.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Create Next.js middleware for agent verification.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as next_server from 'next/server';
|
|
2
2
|
import { NextRequest } from 'next/server';
|
|
3
|
-
import { N as NextJsMiddlewareOptions } from './types-
|
|
3
|
+
import { N as NextJsMiddlewareOptions } from './types-BVp22KkN.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Create Next.js middleware for agent verification.
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/** Configuration for the AstraSync SDK client. */
|
|
2
|
+
interface AstraSyncConfig {
|
|
3
|
+
/** API key (kya_ prefixed). Used as Bearer token. */
|
|
4
|
+
apiKey?: string;
|
|
5
|
+
/** Email for email+password authentication. */
|
|
6
|
+
email?: string;
|
|
7
|
+
/** Password for email+password authentication. */
|
|
8
|
+
password?: string;
|
|
9
|
+
/** secp256k1 private key for crypto signing. Used WITH apiKey or email+password. */
|
|
10
|
+
privateKey?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Base URL for the AstraSync API.
|
|
13
|
+
* Defaults to ASTRASYNC_API_URL env or `https://astrasync.ai` (production).
|
|
14
|
+
* For staging, pass `https://staging.astrasync.ai`.
|
|
15
|
+
*/
|
|
16
|
+
baseUrl?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Multi-protocol declarations the agent participates in.
|
|
20
|
+
* Promoted from `metadata.protocols[]` to a first-class field in agent-registration v1.0.0.
|
|
21
|
+
*/
|
|
22
|
+
type AgentProtocol = 'a2a' | 'acp' | 'ap2' | 'ucp' | 'mpp' | 'x402' | 'erc8004' | 'vi' | 'agentpay' | 'tap' | 'other';
|
|
23
|
+
/** PDLSS purpose configuration. */
|
|
24
|
+
interface PDLSSPurpose {
|
|
25
|
+
categories: string[];
|
|
26
|
+
allowedActions?: string[];
|
|
27
|
+
deniedActions?: string[];
|
|
28
|
+
}
|
|
29
|
+
/** PDLSS duration configuration. */
|
|
30
|
+
interface PDLSSDuration {
|
|
31
|
+
startTime?: string | null;
|
|
32
|
+
endTime?: string | null;
|
|
33
|
+
timezone?: string | null;
|
|
34
|
+
maxSessionDuration?: number | null;
|
|
35
|
+
ttl?: number | null;
|
|
36
|
+
allowedDays?: number[] | null;
|
|
37
|
+
allowedHours?: {
|
|
38
|
+
start: number;
|
|
39
|
+
end: number;
|
|
40
|
+
} | null;
|
|
41
|
+
}
|
|
42
|
+
/** PDLSS limits configuration. */
|
|
43
|
+
interface PDLSSLimits {
|
|
44
|
+
autonomousThreshold?: number | null;
|
|
45
|
+
stepUpThreshold?: number | null;
|
|
46
|
+
approvalThreshold?: number | null;
|
|
47
|
+
maxTransactionsPerDay?: number | null;
|
|
48
|
+
maxTransactionsPerHour?: number | null;
|
|
49
|
+
maxTotalValue?: number | null;
|
|
50
|
+
currency?: string;
|
|
51
|
+
}
|
|
52
|
+
/** PDLSS scope configuration. */
|
|
53
|
+
interface PDLSSScope {
|
|
54
|
+
resources?: string[];
|
|
55
|
+
resourceTypes?: string[];
|
|
56
|
+
jurisdictions?: string[];
|
|
57
|
+
excludedResources?: string[];
|
|
58
|
+
counterparties?: string[];
|
|
59
|
+
excludedCounterparties?: string[];
|
|
60
|
+
}
|
|
61
|
+
/** PDLSS self-instantiation configuration. */
|
|
62
|
+
interface PDLSSSelfInstantiation {
|
|
63
|
+
allowed: boolean;
|
|
64
|
+
maxSubAgents?: number | null;
|
|
65
|
+
inheritPermissions?: boolean | null;
|
|
66
|
+
allowedPurposes?: string[] | null;
|
|
67
|
+
requireApproval?: boolean | null;
|
|
68
|
+
maxDepth?: number | null;
|
|
69
|
+
}
|
|
70
|
+
/** Full PDLSS configuration. */
|
|
71
|
+
interface PDLSSConfig {
|
|
72
|
+
purpose: PDLSSPurpose;
|
|
73
|
+
duration?: PDLSSDuration;
|
|
74
|
+
limits?: PDLSSLimits;
|
|
75
|
+
scope?: PDLSSScope;
|
|
76
|
+
selfInstantiation?: PDLSSSelfInstantiation;
|
|
77
|
+
}
|
|
78
|
+
/** Model metadata for registration. */
|
|
79
|
+
interface ModelConfig {
|
|
80
|
+
modelName: string;
|
|
81
|
+
modelProvider: string;
|
|
82
|
+
modelType?: 'llm' | 'embedding' | 'image' | 'audio' | 'multimodal' | 'code' | 'other';
|
|
83
|
+
contextWindow?: number;
|
|
84
|
+
maxTokens?: number;
|
|
85
|
+
}
|
|
86
|
+
/** Framework metadata for registration. */
|
|
87
|
+
interface FrameworkConfig {
|
|
88
|
+
frameworkName: string;
|
|
89
|
+
frameworkVersion: string;
|
|
90
|
+
}
|
|
91
|
+
/** Options for agent registration. */
|
|
92
|
+
interface RegisterOptions {
|
|
93
|
+
name: string;
|
|
94
|
+
description?: string;
|
|
95
|
+
agentType?: string;
|
|
96
|
+
apiEndpoint?: string;
|
|
97
|
+
model?: ModelConfig;
|
|
98
|
+
framework?: FrameworkConfig;
|
|
99
|
+
/** Multi-protocol declarations (e.g. ['acp', 'ap2', 'a2a']). First-class as of v1.0.0. */
|
|
100
|
+
protocols?: AgentProtocol[];
|
|
101
|
+
metadata?: Record<string, unknown>;
|
|
102
|
+
pdlss?: PDLSSConfig;
|
|
103
|
+
}
|
|
104
|
+
/** Response from agent registration. */
|
|
105
|
+
interface RegistrationResponse {
|
|
106
|
+
success: boolean;
|
|
107
|
+
message: string;
|
|
108
|
+
data: {
|
|
109
|
+
agent: AgentRecord;
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/** Agent record from the API. */
|
|
113
|
+
interface AgentRecord {
|
|
114
|
+
kyaAgentId: string;
|
|
115
|
+
name: string;
|
|
116
|
+
description?: string;
|
|
117
|
+
agentType: string;
|
|
118
|
+
agentStatus: string;
|
|
119
|
+
trustScore: number;
|
|
120
|
+
astrasyncIdLevel1?: string | null;
|
|
121
|
+
tempId?: string | null;
|
|
122
|
+
metadata?: Record<string, unknown>;
|
|
123
|
+
createdAt: string;
|
|
124
|
+
updatedAt: string;
|
|
125
|
+
}
|
|
126
|
+
/** Public agent verification response. */
|
|
127
|
+
interface VerifyResponse {
|
|
128
|
+
success: boolean;
|
|
129
|
+
data: {
|
|
130
|
+
agentUuid: string;
|
|
131
|
+
agentName: string;
|
|
132
|
+
agentDescription: string;
|
|
133
|
+
agentTrustScore: number;
|
|
134
|
+
agentStatus: string;
|
|
135
|
+
ownerName?: string;
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
/** Health check response. */
|
|
139
|
+
interface HealthResponse {
|
|
140
|
+
status: string;
|
|
141
|
+
service: string;
|
|
142
|
+
version: string;
|
|
143
|
+
}
|
|
144
|
+
/** Error response from the API. */
|
|
145
|
+
interface ApiErrorResponse {
|
|
146
|
+
success: false;
|
|
147
|
+
error: string;
|
|
148
|
+
code?: string;
|
|
149
|
+
kydUrl?: string;
|
|
150
|
+
ownerNotified?: boolean;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* AstraSync SDK client for registering and managing AI agents.
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```typescript
|
|
158
|
+
* const client = new AstraSync({ apiKey: 'kya_your_api_key' });
|
|
159
|
+
* const result = await client.register({
|
|
160
|
+
* name: 'My Agent',
|
|
161
|
+
* model: { modelName: 'gpt-4o', modelProvider: 'openai', modelType: 'llm' },
|
|
162
|
+
* });
|
|
163
|
+
* ```
|
|
164
|
+
*
|
|
165
|
+
* For staging, pass `baseUrl: 'https://staging.astrasync.ai'`.
|
|
166
|
+
*/
|
|
167
|
+
declare class AstraSync {
|
|
168
|
+
private readonly baseUrl;
|
|
169
|
+
private readonly apiKey?;
|
|
170
|
+
private readonly email?;
|
|
171
|
+
private readonly password?;
|
|
172
|
+
private readonly privateKey?;
|
|
173
|
+
private cachedJwt?;
|
|
174
|
+
private jwtExpiresAt?;
|
|
175
|
+
constructor(config?: AstraSyncConfig);
|
|
176
|
+
/**
|
|
177
|
+
* Register a new AI agent on the AstraSync KYA Platform.
|
|
178
|
+
* Sends full payload including model, framework, PDLSS, and metadata.
|
|
179
|
+
*/
|
|
180
|
+
register(options: RegisterOptions): Promise<RegistrationResponse>;
|
|
181
|
+
/**
|
|
182
|
+
* Look up an agent's public profile by ASTRA ID or UUID.
|
|
183
|
+
*/
|
|
184
|
+
verify(agentId: string): Promise<VerifyResponse>;
|
|
185
|
+
/**
|
|
186
|
+
* Check API health.
|
|
187
|
+
*/
|
|
188
|
+
health(): Promise<HealthResponse>;
|
|
189
|
+
private request;
|
|
190
|
+
private getAuthToken;
|
|
191
|
+
/**
|
|
192
|
+
* Sign a request using secp256k1 (ethers.js).
|
|
193
|
+
* Canonical message format: METHOD:ENDPOINT:SORTED_JSON_BODY
|
|
194
|
+
* Must match apps/backend/src/services/signature-verify.service.ts exactly.
|
|
195
|
+
*/
|
|
196
|
+
private signRequest;
|
|
197
|
+
/** Recursively sort object keys for canonical JSON representation. */
|
|
198
|
+
private sortObjectKeys;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** Base error class for AstraSync SDK errors. */
|
|
202
|
+
declare class AstraSyncError extends Error {
|
|
203
|
+
readonly code?: string;
|
|
204
|
+
readonly statusCode: number;
|
|
205
|
+
constructor(message: string, statusCode: number, code?: string);
|
|
206
|
+
}
|
|
207
|
+
/** Thrown when KYD verification is required before agent registration. */
|
|
208
|
+
declare class KYDRequiredError extends AstraSyncError {
|
|
209
|
+
readonly kydUrl: string;
|
|
210
|
+
readonly ownerNotified: boolean;
|
|
211
|
+
constructor(response: ApiErrorResponse);
|
|
212
|
+
}
|
|
213
|
+
/** Thrown when authentication fails. */
|
|
214
|
+
declare class AuthenticationError extends AstraSyncError {
|
|
215
|
+
constructor(message: string);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export { type AgentProtocol, type AgentRecord, AstraSync, type AstraSyncConfig, AstraSyncError, AuthenticationError, type FrameworkConfig, type HealthResponse, KYDRequiredError, type ModelConfig, type PDLSSConfig, type PDLSSDuration, type PDLSSLimits, type PDLSSPurpose, type PDLSSScope, type PDLSSSelfInstantiation, type RegisterOptions, type RegistrationResponse, type VerifyResponse };
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/** Configuration for the AstraSync SDK client. */
|
|
2
|
+
interface AstraSyncConfig {
|
|
3
|
+
/** API key (kya_ prefixed). Used as Bearer token. */
|
|
4
|
+
apiKey?: string;
|
|
5
|
+
/** Email for email+password authentication. */
|
|
6
|
+
email?: string;
|
|
7
|
+
/** Password for email+password authentication. */
|
|
8
|
+
password?: string;
|
|
9
|
+
/** secp256k1 private key for crypto signing. Used WITH apiKey or email+password. */
|
|
10
|
+
privateKey?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Base URL for the AstraSync API.
|
|
13
|
+
* Defaults to ASTRASYNC_API_URL env or `https://astrasync.ai` (production).
|
|
14
|
+
* For staging, pass `https://staging.astrasync.ai`.
|
|
15
|
+
*/
|
|
16
|
+
baseUrl?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Multi-protocol declarations the agent participates in.
|
|
20
|
+
* Promoted from `metadata.protocols[]` to a first-class field in agent-registration v1.0.0.
|
|
21
|
+
*/
|
|
22
|
+
type AgentProtocol = 'a2a' | 'acp' | 'ap2' | 'ucp' | 'mpp' | 'x402' | 'erc8004' | 'vi' | 'agentpay' | 'tap' | 'other';
|
|
23
|
+
/** PDLSS purpose configuration. */
|
|
24
|
+
interface PDLSSPurpose {
|
|
25
|
+
categories: string[];
|
|
26
|
+
allowedActions?: string[];
|
|
27
|
+
deniedActions?: string[];
|
|
28
|
+
}
|
|
29
|
+
/** PDLSS duration configuration. */
|
|
30
|
+
interface PDLSSDuration {
|
|
31
|
+
startTime?: string | null;
|
|
32
|
+
endTime?: string | null;
|
|
33
|
+
timezone?: string | null;
|
|
34
|
+
maxSessionDuration?: number | null;
|
|
35
|
+
ttl?: number | null;
|
|
36
|
+
allowedDays?: number[] | null;
|
|
37
|
+
allowedHours?: {
|
|
38
|
+
start: number;
|
|
39
|
+
end: number;
|
|
40
|
+
} | null;
|
|
41
|
+
}
|
|
42
|
+
/** PDLSS limits configuration. */
|
|
43
|
+
interface PDLSSLimits {
|
|
44
|
+
autonomousThreshold?: number | null;
|
|
45
|
+
stepUpThreshold?: number | null;
|
|
46
|
+
approvalThreshold?: number | null;
|
|
47
|
+
maxTransactionsPerDay?: number | null;
|
|
48
|
+
maxTransactionsPerHour?: number | null;
|
|
49
|
+
maxTotalValue?: number | null;
|
|
50
|
+
currency?: string;
|
|
51
|
+
}
|
|
52
|
+
/** PDLSS scope configuration. */
|
|
53
|
+
interface PDLSSScope {
|
|
54
|
+
resources?: string[];
|
|
55
|
+
resourceTypes?: string[];
|
|
56
|
+
jurisdictions?: string[];
|
|
57
|
+
excludedResources?: string[];
|
|
58
|
+
counterparties?: string[];
|
|
59
|
+
excludedCounterparties?: string[];
|
|
60
|
+
}
|
|
61
|
+
/** PDLSS self-instantiation configuration. */
|
|
62
|
+
interface PDLSSSelfInstantiation {
|
|
63
|
+
allowed: boolean;
|
|
64
|
+
maxSubAgents?: number | null;
|
|
65
|
+
inheritPermissions?: boolean | null;
|
|
66
|
+
allowedPurposes?: string[] | null;
|
|
67
|
+
requireApproval?: boolean | null;
|
|
68
|
+
maxDepth?: number | null;
|
|
69
|
+
}
|
|
70
|
+
/** Full PDLSS configuration. */
|
|
71
|
+
interface PDLSSConfig {
|
|
72
|
+
purpose: PDLSSPurpose;
|
|
73
|
+
duration?: PDLSSDuration;
|
|
74
|
+
limits?: PDLSSLimits;
|
|
75
|
+
scope?: PDLSSScope;
|
|
76
|
+
selfInstantiation?: PDLSSSelfInstantiation;
|
|
77
|
+
}
|
|
78
|
+
/** Model metadata for registration. */
|
|
79
|
+
interface ModelConfig {
|
|
80
|
+
modelName: string;
|
|
81
|
+
modelProvider: string;
|
|
82
|
+
modelType?: 'llm' | 'embedding' | 'image' | 'audio' | 'multimodal' | 'code' | 'other';
|
|
83
|
+
contextWindow?: number;
|
|
84
|
+
maxTokens?: number;
|
|
85
|
+
}
|
|
86
|
+
/** Framework metadata for registration. */
|
|
87
|
+
interface FrameworkConfig {
|
|
88
|
+
frameworkName: string;
|
|
89
|
+
frameworkVersion: string;
|
|
90
|
+
}
|
|
91
|
+
/** Options for agent registration. */
|
|
92
|
+
interface RegisterOptions {
|
|
93
|
+
name: string;
|
|
94
|
+
description?: string;
|
|
95
|
+
agentType?: string;
|
|
96
|
+
apiEndpoint?: string;
|
|
97
|
+
model?: ModelConfig;
|
|
98
|
+
framework?: FrameworkConfig;
|
|
99
|
+
/** Multi-protocol declarations (e.g. ['acp', 'ap2', 'a2a']). First-class as of v1.0.0. */
|
|
100
|
+
protocols?: AgentProtocol[];
|
|
101
|
+
metadata?: Record<string, unknown>;
|
|
102
|
+
pdlss?: PDLSSConfig;
|
|
103
|
+
}
|
|
104
|
+
/** Response from agent registration. */
|
|
105
|
+
interface RegistrationResponse {
|
|
106
|
+
success: boolean;
|
|
107
|
+
message: string;
|
|
108
|
+
data: {
|
|
109
|
+
agent: AgentRecord;
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/** Agent record from the API. */
|
|
113
|
+
interface AgentRecord {
|
|
114
|
+
kyaAgentId: string;
|
|
115
|
+
name: string;
|
|
116
|
+
description?: string;
|
|
117
|
+
agentType: string;
|
|
118
|
+
agentStatus: string;
|
|
119
|
+
trustScore: number;
|
|
120
|
+
astrasyncIdLevel1?: string | null;
|
|
121
|
+
tempId?: string | null;
|
|
122
|
+
metadata?: Record<string, unknown>;
|
|
123
|
+
createdAt: string;
|
|
124
|
+
updatedAt: string;
|
|
125
|
+
}
|
|
126
|
+
/** Public agent verification response. */
|
|
127
|
+
interface VerifyResponse {
|
|
128
|
+
success: boolean;
|
|
129
|
+
data: {
|
|
130
|
+
agentUuid: string;
|
|
131
|
+
agentName: string;
|
|
132
|
+
agentDescription: string;
|
|
133
|
+
agentTrustScore: number;
|
|
134
|
+
agentStatus: string;
|
|
135
|
+
ownerName?: string;
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
/** Health check response. */
|
|
139
|
+
interface HealthResponse {
|
|
140
|
+
status: string;
|
|
141
|
+
service: string;
|
|
142
|
+
version: string;
|
|
143
|
+
}
|
|
144
|
+
/** Error response from the API. */
|
|
145
|
+
interface ApiErrorResponse {
|
|
146
|
+
success: false;
|
|
147
|
+
error: string;
|
|
148
|
+
code?: string;
|
|
149
|
+
kydUrl?: string;
|
|
150
|
+
ownerNotified?: boolean;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* AstraSync SDK client for registering and managing AI agents.
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```typescript
|
|
158
|
+
* const client = new AstraSync({ apiKey: 'kya_your_api_key' });
|
|
159
|
+
* const result = await client.register({
|
|
160
|
+
* name: 'My Agent',
|
|
161
|
+
* model: { modelName: 'gpt-4o', modelProvider: 'openai', modelType: 'llm' },
|
|
162
|
+
* });
|
|
163
|
+
* ```
|
|
164
|
+
*
|
|
165
|
+
* For staging, pass `baseUrl: 'https://staging.astrasync.ai'`.
|
|
166
|
+
*/
|
|
167
|
+
declare class AstraSync {
|
|
168
|
+
private readonly baseUrl;
|
|
169
|
+
private readonly apiKey?;
|
|
170
|
+
private readonly email?;
|
|
171
|
+
private readonly password?;
|
|
172
|
+
private readonly privateKey?;
|
|
173
|
+
private cachedJwt?;
|
|
174
|
+
private jwtExpiresAt?;
|
|
175
|
+
constructor(config?: AstraSyncConfig);
|
|
176
|
+
/**
|
|
177
|
+
* Register a new AI agent on the AstraSync KYA Platform.
|
|
178
|
+
* Sends full payload including model, framework, PDLSS, and metadata.
|
|
179
|
+
*/
|
|
180
|
+
register(options: RegisterOptions): Promise<RegistrationResponse>;
|
|
181
|
+
/**
|
|
182
|
+
* Look up an agent's public profile by ASTRA ID or UUID.
|
|
183
|
+
*/
|
|
184
|
+
verify(agentId: string): Promise<VerifyResponse>;
|
|
185
|
+
/**
|
|
186
|
+
* Check API health.
|
|
187
|
+
*/
|
|
188
|
+
health(): Promise<HealthResponse>;
|
|
189
|
+
private request;
|
|
190
|
+
private getAuthToken;
|
|
191
|
+
/**
|
|
192
|
+
* Sign a request using secp256k1 (ethers.js).
|
|
193
|
+
* Canonical message format: METHOD:ENDPOINT:SORTED_JSON_BODY
|
|
194
|
+
* Must match apps/backend/src/services/signature-verify.service.ts exactly.
|
|
195
|
+
*/
|
|
196
|
+
private signRequest;
|
|
197
|
+
/** Recursively sort object keys for canonical JSON representation. */
|
|
198
|
+
private sortObjectKeys;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** Base error class for AstraSync SDK errors. */
|
|
202
|
+
declare class AstraSyncError extends Error {
|
|
203
|
+
readonly code?: string;
|
|
204
|
+
readonly statusCode: number;
|
|
205
|
+
constructor(message: string, statusCode: number, code?: string);
|
|
206
|
+
}
|
|
207
|
+
/** Thrown when KYD verification is required before agent registration. */
|
|
208
|
+
declare class KYDRequiredError extends AstraSyncError {
|
|
209
|
+
readonly kydUrl: string;
|
|
210
|
+
readonly ownerNotified: boolean;
|
|
211
|
+
constructor(response: ApiErrorResponse);
|
|
212
|
+
}
|
|
213
|
+
/** Thrown when authentication fails. */
|
|
214
|
+
declare class AuthenticationError extends AstraSyncError {
|
|
215
|
+
constructor(message: string);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export { type AgentProtocol, type AgentRecord, AstraSync, type AstraSyncConfig, AstraSyncError, AuthenticationError, type FrameworkConfig, type HealthResponse, KYDRequiredError, type ModelConfig, type PDLSSConfig, type PDLSSDuration, type PDLSSLimits, type PDLSSPurpose, type PDLSSScope, type PDLSSSelfInstantiation, type RegisterOptions, type RegistrationResponse, type VerifyResponse };
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/registration/index.ts
|
|
31
|
+
var registration_exports = {};
|
|
32
|
+
__export(registration_exports, {
|
|
33
|
+
AstraSync: () => AstraSync,
|
|
34
|
+
AstraSyncError: () => AstraSyncError,
|
|
35
|
+
AuthenticationError: () => AuthenticationError,
|
|
36
|
+
KYDRequiredError: () => KYDRequiredError
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(registration_exports);
|
|
39
|
+
|
|
40
|
+
// src/registration/errors.ts
|
|
41
|
+
var AstraSyncError = class extends Error {
|
|
42
|
+
constructor(message, statusCode, code) {
|
|
43
|
+
super(message);
|
|
44
|
+
this.name = "AstraSyncError";
|
|
45
|
+
this.statusCode = statusCode;
|
|
46
|
+
this.code = code;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var KYDRequiredError = class extends AstraSyncError {
|
|
50
|
+
constructor(response) {
|
|
51
|
+
const kydUrl = response.kydUrl || "https://astrasync.ai/developer-profile";
|
|
52
|
+
super(
|
|
53
|
+
`KYD verification required before registering agents.
|
|
54
|
+
Complete your KYD profile at: ${kydUrl}`,
|
|
55
|
+
403,
|
|
56
|
+
"KYD_REQUIRED"
|
|
57
|
+
);
|
|
58
|
+
this.name = "KYDRequiredError";
|
|
59
|
+
this.kydUrl = kydUrl;
|
|
60
|
+
this.ownerNotified = response.ownerNotified || false;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
var AuthenticationError = class extends AstraSyncError {
|
|
64
|
+
constructor(message) {
|
|
65
|
+
super(message, 401, "AUTH_FAILED");
|
|
66
|
+
this.name = "AuthenticationError";
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// src/registration/api.ts
|
|
71
|
+
var DEFAULT_BASE_URL = "https://astrasync.ai";
|
|
72
|
+
var AstraSync = class {
|
|
73
|
+
constructor(config = {}) {
|
|
74
|
+
this.baseUrl = (config.baseUrl || process.env.ASTRASYNC_API_URL || DEFAULT_BASE_URL).replace(
|
|
75
|
+
/\/+$/,
|
|
76
|
+
""
|
|
77
|
+
);
|
|
78
|
+
this.apiKey = config.apiKey || process.env.ASTRASYNC_API_KEY;
|
|
79
|
+
this.email = config.email;
|
|
80
|
+
this.password = config.password;
|
|
81
|
+
this.privateKey = config.privateKey;
|
|
82
|
+
if (!this.apiKey && !this.email) {
|
|
83
|
+
throw new AuthenticationError(
|
|
84
|
+
"Authentication required. Provide apiKey, or email+password. Set ASTRASYNC_API_KEY env var or pass config to constructor."
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
if (this.email && !this.password) {
|
|
88
|
+
throw new AuthenticationError("Password is required when using email authentication.");
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Register a new AI agent on the AstraSync KYA Platform.
|
|
93
|
+
* Sends full payload including model, framework, PDLSS, and metadata.
|
|
94
|
+
*/
|
|
95
|
+
async register(options) {
|
|
96
|
+
const body = {
|
|
97
|
+
name: options.name,
|
|
98
|
+
...options.description && { description: options.description },
|
|
99
|
+
...options.agentType && { agentType: options.agentType },
|
|
100
|
+
...options.apiEndpoint && { apiEndpoint: options.apiEndpoint },
|
|
101
|
+
...options.model && { model: options.model },
|
|
102
|
+
...options.framework && { framework: options.framework },
|
|
103
|
+
...options.protocols && { protocols: options.protocols },
|
|
104
|
+
...options.metadata && { metadata: options.metadata },
|
|
105
|
+
...options.pdlss && { pdlss: options.pdlss }
|
|
106
|
+
};
|
|
107
|
+
return this.request("POST", "/api/agents/register", body);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Look up an agent's public profile by ASTRA ID or UUID.
|
|
111
|
+
*/
|
|
112
|
+
async verify(agentId) {
|
|
113
|
+
return this.request("GET", `/api/agents/verify/${agentId}`);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Check API health.
|
|
117
|
+
*/
|
|
118
|
+
async health() {
|
|
119
|
+
const res = await fetch(`${this.baseUrl}/api/health/`);
|
|
120
|
+
if (!res.ok) {
|
|
121
|
+
throw new AstraSyncError(`Health check failed: ${res.status}`, res.status);
|
|
122
|
+
}
|
|
123
|
+
return res.json();
|
|
124
|
+
}
|
|
125
|
+
// ── Private helpers ──────────────────────────────────────────────
|
|
126
|
+
async request(method, endpoint, body) {
|
|
127
|
+
const url = `${this.baseUrl}${endpoint}`;
|
|
128
|
+
const headers = {
|
|
129
|
+
"Content-Type": "application/json"
|
|
130
|
+
};
|
|
131
|
+
const token = await this.getAuthToken();
|
|
132
|
+
headers["Authorization"] = `Bearer ${token}`;
|
|
133
|
+
if (this.privateKey) {
|
|
134
|
+
const signature = await this.signRequest(method, endpoint, body || {});
|
|
135
|
+
headers["X-AstraSync-Signature"] = signature;
|
|
136
|
+
}
|
|
137
|
+
const res = await fetch(url, {
|
|
138
|
+
method,
|
|
139
|
+
headers,
|
|
140
|
+
...body ? { body: JSON.stringify(body) } : {}
|
|
141
|
+
});
|
|
142
|
+
if (!res.ok) {
|
|
143
|
+
const errorBody = await res.json().catch(() => ({ error: res.statusText }));
|
|
144
|
+
if (res.status === 403 && errorBody.code === "KYD_REQUIRED") {
|
|
145
|
+
throw new KYDRequiredError(errorBody);
|
|
146
|
+
}
|
|
147
|
+
throw new AstraSyncError(
|
|
148
|
+
errorBody.error || `Request failed: ${res.status}`,
|
|
149
|
+
res.status,
|
|
150
|
+
errorBody.code
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
return res.json();
|
|
154
|
+
}
|
|
155
|
+
async getAuthToken() {
|
|
156
|
+
if (this.apiKey) {
|
|
157
|
+
return this.apiKey;
|
|
158
|
+
}
|
|
159
|
+
if (this.cachedJwt && this.jwtExpiresAt && Date.now() < this.jwtExpiresAt) {
|
|
160
|
+
return this.cachedJwt;
|
|
161
|
+
}
|
|
162
|
+
const res = await fetch(`${this.baseUrl}/api/auth/login`, {
|
|
163
|
+
method: "POST",
|
|
164
|
+
headers: { "Content-Type": "application/json" },
|
|
165
|
+
body: JSON.stringify({ email: this.email, password: this.password })
|
|
166
|
+
});
|
|
167
|
+
if (!res.ok) {
|
|
168
|
+
const errorBody = await res.json().catch(() => ({}));
|
|
169
|
+
throw new AuthenticationError(
|
|
170
|
+
errorBody.message || errorBody.error || "Login failed"
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
const data = await res.json();
|
|
174
|
+
this.cachedJwt = data.data.token;
|
|
175
|
+
this.jwtExpiresAt = Date.now() + 6 * 24 * 60 * 60 * 1e3;
|
|
176
|
+
return this.cachedJwt;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Sign a request using secp256k1 (ethers.js).
|
|
180
|
+
* Canonical message format: METHOD:ENDPOINT:SORTED_JSON_BODY
|
|
181
|
+
* Must match apps/backend/src/services/signature-verify.service.ts exactly.
|
|
182
|
+
*/
|
|
183
|
+
async signRequest(method, endpoint, body) {
|
|
184
|
+
const { Wallet } = await import("ethers");
|
|
185
|
+
const sorted = this.sortObjectKeys(body);
|
|
186
|
+
const canonical = `${method}:${endpoint}:${JSON.stringify(sorted)}`;
|
|
187
|
+
const wallet = new Wallet(this.privateKey);
|
|
188
|
+
return wallet.signMessage(canonical);
|
|
189
|
+
}
|
|
190
|
+
/** Recursively sort object keys for canonical JSON representation. */
|
|
191
|
+
sortObjectKeys(obj) {
|
|
192
|
+
if (obj === null || typeof obj !== "object") {
|
|
193
|
+
return obj;
|
|
194
|
+
}
|
|
195
|
+
if (Array.isArray(obj)) {
|
|
196
|
+
return obj.map((item) => this.sortObjectKeys(item));
|
|
197
|
+
}
|
|
198
|
+
const sorted = {};
|
|
199
|
+
for (const key of Object.keys(obj).sort()) {
|
|
200
|
+
sorted[key] = this.sortObjectKeys(obj[key]);
|
|
201
|
+
}
|
|
202
|
+
return sorted;
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
206
|
+
0 && (module.exports = {
|
|
207
|
+
AstraSync,
|
|
208
|
+
AstraSyncError,
|
|
209
|
+
AuthenticationError,
|
|
210
|
+
KYDRequiredError
|
|
211
|
+
});
|
|
212
|
+
//# sourceMappingURL=index.js.map
|