@dainprotocol/service-sdk 1.2.0 → 1.2.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/dist/client/client-auth.d.ts +90 -9
- package/dist/client/client-auth.js +177 -90
- package/dist/client/client-auth.js.map +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/service-auth.d.ts +61 -0
- package/dist/client/service-auth.js +93 -0
- package/dist/client/service-auth.js.map +1 -0
- package/dist/client/user-auth.d.ts +74 -0
- package/dist/client/user-auth.js +137 -0
- package/dist/client/user-auth.js.map +1 -0
- package/dist/service/auth.d.ts +25 -35
- package/dist/service/auth.js +76 -77
- package/dist/service/auth.js.map +1 -1
- package/dist/service/server.js +51 -61
- package/dist/service/server.js.map +1 -1
- package/dist/service/types.d.ts +6 -0
- package/package.json +3 -1
|
@@ -1,14 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* JWT Authentication Config (Users)
|
|
3
|
+
*/
|
|
4
|
+
export interface DainClientAuthConfigJWT {
|
|
5
|
+
/** JWT access token from DAIN ID OAuth */
|
|
6
|
+
jwt: string;
|
|
7
|
+
/** Smart Account ID (optional, will be extracted from JWT if not provided) */
|
|
3
8
|
smartAccountId?: string;
|
|
9
|
+
/** Smart Account PDA on Solana (optional) */
|
|
10
|
+
smartAccountPDA?: string;
|
|
11
|
+
/** Webhook URL for async operations (optional) */
|
|
12
|
+
webhookUrl?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Keypair Authentication Config (Services/Agents)
|
|
16
|
+
*/
|
|
17
|
+
export interface DainClientAuthConfigKeypair {
|
|
18
|
+
/** Base58 encoded private key */
|
|
4
19
|
privateKeyBase58?: string;
|
|
20
|
+
/** Agent ID */
|
|
5
21
|
agentId?: string;
|
|
22
|
+
/** Organization ID */
|
|
6
23
|
orgId?: string;
|
|
24
|
+
/** API Key (alternative to privateKeyBase58/agentId/orgId) */
|
|
7
25
|
apiKey?: string;
|
|
26
|
+
/** Smart Account PDA on Solana (optional) */
|
|
8
27
|
smartAccountPDA?: string;
|
|
28
|
+
/** Webhook URL for async operations (optional) */
|
|
9
29
|
webhookUrl?: string;
|
|
10
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Union type for authentication config
|
|
33
|
+
*/
|
|
34
|
+
export type DainClientAuthConfig = DainClientAuthConfigJWT | DainClientAuthConfigKeypair;
|
|
35
|
+
/**
|
|
36
|
+
* Unified DainClientAuth class
|
|
37
|
+
*
|
|
38
|
+
* Supports both JWT (users) and Keypair (services/agents) authentication
|
|
39
|
+
*/
|
|
11
40
|
export declare class DainClientAuth {
|
|
41
|
+
private authType;
|
|
12
42
|
private jwt?;
|
|
13
43
|
private smartAccountId?;
|
|
14
44
|
private privateKey?;
|
|
@@ -17,35 +47,86 @@ export declare class DainClientAuth {
|
|
|
17
47
|
private publicKey?;
|
|
18
48
|
private smartAccountPDA?;
|
|
19
49
|
private webhookUrl?;
|
|
20
|
-
private readonly authMethod;
|
|
21
50
|
constructor(config: DainClientAuthConfig);
|
|
51
|
+
/**
|
|
52
|
+
* Decode JWT payload (without verification)
|
|
53
|
+
* @private
|
|
54
|
+
*/
|
|
55
|
+
private decodeJWTPayload;
|
|
56
|
+
/**
|
|
57
|
+
* Parse API key into components
|
|
58
|
+
* @private
|
|
59
|
+
*/
|
|
22
60
|
private parseApiKey;
|
|
23
61
|
/**
|
|
24
|
-
* Sign request
|
|
25
|
-
*
|
|
62
|
+
* Sign request
|
|
63
|
+
* - JWT mode: returns empty (no signing needed)
|
|
64
|
+
* - Keypair mode: signs with Ed25519
|
|
26
65
|
*/
|
|
27
66
|
signRequest(method: string, path: string, body: string): Promise<{
|
|
28
67
|
signature: string;
|
|
29
68
|
timestamp: string;
|
|
30
69
|
}>;
|
|
31
70
|
/**
|
|
32
|
-
* Get headers for
|
|
33
|
-
*
|
|
71
|
+
* Get headers for HTTP requests
|
|
72
|
+
* - JWT mode: returns Authorization Bearer header
|
|
73
|
+
* - Keypair mode: returns signature headers
|
|
34
74
|
*/
|
|
35
75
|
getHeaders(signature: string, timestamp: string): Record<string, string>;
|
|
76
|
+
/**
|
|
77
|
+
* Sign a message (keypair mode only)
|
|
78
|
+
*/
|
|
36
79
|
signMessage(message: string): string;
|
|
80
|
+
/**
|
|
81
|
+
* Verify a message signature (static method)
|
|
82
|
+
*/
|
|
37
83
|
static verifyMessage(message: string, signature: string, publicKey: Uint8Array): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Verify SSE event signature (keypair mode only)
|
|
86
|
+
*/
|
|
38
87
|
verifyEventSignature(data: string, signature: string, timestamp: string, publicKeyBase58: string): boolean;
|
|
39
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Check if using JWT authentication
|
|
90
|
+
*/
|
|
91
|
+
isJWT(): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Get JWT token (JWT mode only)
|
|
94
|
+
*/
|
|
40
95
|
getJWT(): string | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* Get smart account ID (JWT mode only)
|
|
98
|
+
*/
|
|
41
99
|
getSmartAccountId(): string | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* Get agent ID (keypair mode only)
|
|
102
|
+
*/
|
|
42
103
|
getAgentId(): string | undefined;
|
|
104
|
+
/**
|
|
105
|
+
* Get org ID (keypair mode only)
|
|
106
|
+
*/
|
|
43
107
|
getOrgId(): string | undefined;
|
|
108
|
+
/**
|
|
109
|
+
* Get public key (keypair mode only)
|
|
110
|
+
*/
|
|
44
111
|
getPublicKey(): Uint8Array | undefined;
|
|
112
|
+
/**
|
|
113
|
+
* Get public key as base58 (keypair mode only)
|
|
114
|
+
*/
|
|
45
115
|
getPublicKeyBase58(): string | undefined;
|
|
116
|
+
/**
|
|
117
|
+
* Get smart account PDA
|
|
118
|
+
*/
|
|
46
119
|
getSmartAccountPDA(): string | undefined;
|
|
120
|
+
/**
|
|
121
|
+
* Get webhook URL
|
|
122
|
+
*/
|
|
47
123
|
getWebhookUrl(): string | undefined;
|
|
124
|
+
/**
|
|
125
|
+
* Serialize auth config
|
|
126
|
+
*/
|
|
48
127
|
serialize(): string;
|
|
128
|
+
/**
|
|
129
|
+
* Deserialize auth config
|
|
130
|
+
*/
|
|
49
131
|
static deserialize(serialized: string): DainClientAuth;
|
|
50
132
|
}
|
|
51
|
-
export {};
|
|
@@ -3,74 +3,100 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DainClientAuth = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
//File: src/client/client-auth.ts
|
|
6
|
+
/**
|
|
7
|
+
* Unified Authentication for DAIN Services
|
|
8
|
+
*
|
|
9
|
+
* Supports two authentication modes:
|
|
10
|
+
* 1. JWT (for end users) - NO orgId, NO agentId, NO keypair
|
|
11
|
+
* 2. Keypair (for services/agents) - uses orgId, agentId, Ed25519 keypair
|
|
12
|
+
*/
|
|
6
13
|
const ed25519_1 = require("@noble/curves/ed25519");
|
|
7
14
|
const sha256_1 = require("@noble/hashes/sha256");
|
|
8
15
|
const utils_1 = require("@noble/hashes/utils");
|
|
9
16
|
const bs58_1 = tslib_1.__importDefault(require("bs58"));
|
|
17
|
+
/**
|
|
18
|
+
* Type guard to check if config is JWT
|
|
19
|
+
*/
|
|
20
|
+
function isJWTConfig(config) {
|
|
21
|
+
return 'jwt' in config && typeof config.jwt === 'string';
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Unified DainClientAuth class
|
|
25
|
+
*
|
|
26
|
+
* Supports both JWT (users) and Keypair (services/agents) authentication
|
|
27
|
+
*/
|
|
10
28
|
class DainClientAuth {
|
|
11
|
-
//
|
|
29
|
+
// Auth type
|
|
30
|
+
authType;
|
|
31
|
+
// JWT fields (users only)
|
|
12
32
|
jwt;
|
|
13
33
|
smartAccountId;
|
|
14
|
-
//
|
|
34
|
+
// Keypair fields (services/agents only)
|
|
15
35
|
privateKey;
|
|
16
36
|
agentId;
|
|
17
37
|
orgId;
|
|
18
38
|
publicKey;
|
|
39
|
+
// Shared fields
|
|
19
40
|
smartAccountPDA;
|
|
20
|
-
// Common
|
|
21
41
|
webhookUrl;
|
|
22
|
-
authMethod;
|
|
23
42
|
constructor(config) {
|
|
24
|
-
|
|
25
|
-
|
|
43
|
+
if (isJWTConfig(config)) {
|
|
44
|
+
// JWT Authentication (Users)
|
|
45
|
+
this.authType = 'jwt';
|
|
46
|
+
if (!config.jwt) {
|
|
47
|
+
throw new Error('JWT token is required for user authentication');
|
|
48
|
+
}
|
|
26
49
|
this.jwt = config.jwt;
|
|
27
|
-
|
|
28
|
-
this.webhookUrl = config.webhookUrl;
|
|
29
|
-
// Extract smartAccountId from JWT if not provided
|
|
50
|
+
// Extract smartAccountId from config or decode from JWT
|
|
30
51
|
if (config.smartAccountId) {
|
|
31
52
|
this.smartAccountId = config.smartAccountId;
|
|
32
53
|
}
|
|
33
54
|
else {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
this.smartAccountId = payload.smart_account_id || payload.sub;
|
|
37
|
-
if (!this.smartAccountId) {
|
|
38
|
-
throw new Error('JWT missing smart_account_id/sub claim');
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
catch (error) {
|
|
42
|
-
throw new Error(`Invalid JWT: ${error instanceof Error ? error.message : String(error)}`);
|
|
43
|
-
}
|
|
55
|
+
const payload = this.decodeJWTPayload(config.jwt);
|
|
56
|
+
this.smartAccountId = payload.smart_account_id || payload.sub;
|
|
44
57
|
}
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
// Priority 2: Legacy API Key (Services)
|
|
48
|
-
if (config.apiKey) {
|
|
49
|
-
const { privateKey, agentId, orgId, publicKey } = this.parseApiKey(config.apiKey);
|
|
50
|
-
this.privateKey = privateKey;
|
|
51
|
-
this.agentId = agentId;
|
|
52
|
-
this.orgId = orgId;
|
|
53
|
-
this.publicKey = publicKey;
|
|
54
|
-
this.webhookUrl = config.webhookUrl;
|
|
55
58
|
this.smartAccountPDA = config.smartAccountPDA;
|
|
56
|
-
this.authMethod = 'legacy';
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
// Priority 3: Legacy Keypair (Services)
|
|
60
|
-
if (config.privateKeyBase58 && config.agentId && config.orgId) {
|
|
61
|
-
this.privateKey = bs58_1.default.decode(config.privateKeyBase58);
|
|
62
|
-
this.agentId = config.agentId.replace('agent_', '');
|
|
63
|
-
this.orgId = config.orgId.replace('org_', '');
|
|
64
|
-
this.publicKey = ed25519_1.ed25519.getPublicKey(this.privateKey);
|
|
65
59
|
this.webhookUrl = config.webhookUrl;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
// Keypair Authentication (Services/Agents)
|
|
63
|
+
this.authType = 'keypair';
|
|
64
|
+
if (config.apiKey) {
|
|
65
|
+
const { privateKey, agentId, orgId, publicKey } = this.parseApiKey(config.apiKey);
|
|
66
|
+
this.privateKey = privateKey;
|
|
67
|
+
this.agentId = agentId;
|
|
68
|
+
this.orgId = orgId;
|
|
69
|
+
this.publicKey = publicKey;
|
|
70
|
+
}
|
|
71
|
+
else if (config.privateKeyBase58 && config.agentId && config.orgId) {
|
|
72
|
+
this.privateKey = bs58_1.default.decode(config.privateKeyBase58);
|
|
73
|
+
this.agentId = config.agentId.replace('agent_', '');
|
|
74
|
+
this.orgId = config.orgId.replace('org_', '');
|
|
75
|
+
this.publicKey = ed25519_1.ed25519.getPublicKey(this.privateKey);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
throw new Error('Invalid configuration. Provide either jwt (for users) or apiKey/privateKeyBase58+agentId+orgId (for services/agents).');
|
|
79
|
+
}
|
|
66
80
|
this.smartAccountPDA = config.smartAccountPDA;
|
|
67
|
-
this.
|
|
68
|
-
return;
|
|
81
|
+
this.webhookUrl = config.webhookUrl;
|
|
69
82
|
}
|
|
70
|
-
throw new Error('Invalid auth config. Provide either:\n' +
|
|
71
|
-
' - jwt (for users)\n' +
|
|
72
|
-
' - apiKey OR (privateKeyBase58 + agentId + orgId) (for services)');
|
|
73
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Decode JWT payload (without verification)
|
|
86
|
+
* @private
|
|
87
|
+
*/
|
|
88
|
+
decodeJWTPayload(jwt) {
|
|
89
|
+
const parts = jwt.split('.');
|
|
90
|
+
if (parts.length !== 3) {
|
|
91
|
+
throw new Error('Invalid JWT format');
|
|
92
|
+
}
|
|
93
|
+
const payload = Buffer.from(parts[1], 'base64').toString('utf-8');
|
|
94
|
+
return JSON.parse(payload);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Parse API key into components
|
|
98
|
+
* @private
|
|
99
|
+
*/
|
|
74
100
|
parseApiKey(apiKey) {
|
|
75
101
|
const parts = apiKey.split('_');
|
|
76
102
|
if (parts.length !== 5 || parts[0] !== 'sk' || parts[1] !== 'agent') {
|
|
@@ -84,15 +110,16 @@ class DainClientAuth {
|
|
|
84
110
|
return { privateKey, agentId, orgId, publicKey };
|
|
85
111
|
}
|
|
86
112
|
/**
|
|
87
|
-
* Sign request
|
|
88
|
-
*
|
|
113
|
+
* Sign request
|
|
114
|
+
* - JWT mode: returns empty (no signing needed)
|
|
115
|
+
* - Keypair mode: signs with Ed25519
|
|
89
116
|
*/
|
|
90
117
|
async signRequest(method, path, body) {
|
|
91
|
-
if (this.
|
|
118
|
+
if (this.authType === 'jwt') {
|
|
92
119
|
// JWT doesn't need request signing
|
|
93
120
|
return { signature: '', timestamp: '' };
|
|
94
121
|
}
|
|
95
|
-
//
|
|
122
|
+
// Keypair signing for services/agents
|
|
96
123
|
const timestamp = Date.now().toString();
|
|
97
124
|
const message = `${method}:${path}:${timestamp}:${body}`;
|
|
98
125
|
const messageHash = (0, sha256_1.sha256)(message);
|
|
@@ -100,44 +127,56 @@ class DainClientAuth {
|
|
|
100
127
|
return { signature: (0, utils_1.bytesToHex)(signature), timestamp };
|
|
101
128
|
}
|
|
102
129
|
/**
|
|
103
|
-
* Get headers for
|
|
104
|
-
*
|
|
130
|
+
* Get headers for HTTP requests
|
|
131
|
+
* - JWT mode: returns Authorization Bearer header
|
|
132
|
+
* - Keypair mode: returns signature headers
|
|
105
133
|
*/
|
|
106
134
|
getHeaders(signature, timestamp) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
135
|
+
const baseHeaders = {};
|
|
136
|
+
if (this.smartAccountPDA) {
|
|
137
|
+
baseHeaders["X-DAIN-SMART-ACCOUNT-PDA"] = this.smartAccountPDA;
|
|
138
|
+
}
|
|
139
|
+
if (this.webhookUrl) {
|
|
140
|
+
baseHeaders["X-DAIN-WEBHOOK-URL"] = this.webhookUrl;
|
|
141
|
+
}
|
|
142
|
+
if (this.authType === 'jwt') {
|
|
143
|
+
// JWT authentication headers
|
|
144
|
+
return {
|
|
145
|
+
...baseHeaders,
|
|
110
146
|
"Authorization": `Bearer ${this.jwt}`,
|
|
111
|
-
"X-DAIN-SMART-ACCOUNT-ID": this.smartAccountId,
|
|
112
147
|
};
|
|
113
|
-
if (this.webhookUrl) {
|
|
114
|
-
headers["X-DAIN-WEBHOOK-URL"] = this.webhookUrl;
|
|
115
|
-
}
|
|
116
|
-
return headers;
|
|
117
148
|
}
|
|
118
|
-
//
|
|
149
|
+
// Keypair authentication headers
|
|
119
150
|
return {
|
|
151
|
+
...baseHeaders,
|
|
120
152
|
"X-DAIN-SIGNATURE": signature,
|
|
121
153
|
"X-DAIN-TIMESTAMP": timestamp,
|
|
122
154
|
"X-DAIN-AGENT-ID": this.agentId,
|
|
123
155
|
"X-DAIN-ORG-ID": this.orgId,
|
|
124
156
|
"X-DAIN-ADDRESS": bs58_1.default.encode(this.publicKey),
|
|
125
|
-
"X-DAIN-SMART-ACCOUNT-PDA": this.smartAccountPDA || '',
|
|
126
|
-
"X-DAIN-WEBHOOK-URL": this.webhookUrl || '',
|
|
127
157
|
};
|
|
128
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* Sign a message (keypair mode only)
|
|
161
|
+
*/
|
|
129
162
|
signMessage(message) {
|
|
130
|
-
if (this.
|
|
131
|
-
throw new Error('
|
|
163
|
+
if (this.authType === 'jwt') {
|
|
164
|
+
throw new Error('signMessage not available in JWT mode');
|
|
132
165
|
}
|
|
133
166
|
const messageHash = (0, sha256_1.sha256)(message);
|
|
134
167
|
const signature = ed25519_1.ed25519.sign(messageHash, this.privateKey);
|
|
135
168
|
return (0, utils_1.bytesToHex)(signature);
|
|
136
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* Verify a message signature (static method)
|
|
172
|
+
*/
|
|
137
173
|
static verifyMessage(message, signature, publicKey) {
|
|
138
174
|
const messageHash = (0, sha256_1.sha256)(message);
|
|
139
175
|
return ed25519_1.ed25519.verify(signature, messageHash, publicKey);
|
|
140
176
|
}
|
|
177
|
+
/**
|
|
178
|
+
* Verify SSE event signature (keypair mode only)
|
|
179
|
+
*/
|
|
141
180
|
verifyEventSignature(data, signature, timestamp, publicKeyBase58) {
|
|
142
181
|
try {
|
|
143
182
|
const message = `${data}:${timestamp}`;
|
|
@@ -150,76 +189,124 @@ class DainClientAuth {
|
|
|
150
189
|
return false;
|
|
151
190
|
}
|
|
152
191
|
}
|
|
153
|
-
//
|
|
154
|
-
|
|
155
|
-
|
|
192
|
+
// ===== Getter Methods =====
|
|
193
|
+
/**
|
|
194
|
+
* Check if using JWT authentication
|
|
195
|
+
*/
|
|
196
|
+
isJWT() {
|
|
197
|
+
return this.authType === 'jwt';
|
|
156
198
|
}
|
|
199
|
+
/**
|
|
200
|
+
* Get JWT token (JWT mode only)
|
|
201
|
+
*/
|
|
157
202
|
getJWT() {
|
|
158
203
|
return this.jwt;
|
|
159
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* Get smart account ID (JWT mode only)
|
|
207
|
+
*/
|
|
160
208
|
getSmartAccountId() {
|
|
161
209
|
return this.smartAccountId;
|
|
162
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* Get agent ID (keypair mode only)
|
|
213
|
+
*/
|
|
163
214
|
getAgentId() {
|
|
164
215
|
return this.agentId;
|
|
165
216
|
}
|
|
217
|
+
/**
|
|
218
|
+
* Get org ID (keypair mode only)
|
|
219
|
+
*/
|
|
166
220
|
getOrgId() {
|
|
167
221
|
return this.orgId;
|
|
168
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* Get public key (keypair mode only)
|
|
225
|
+
*/
|
|
169
226
|
getPublicKey() {
|
|
170
227
|
return this.publicKey;
|
|
171
228
|
}
|
|
229
|
+
/**
|
|
230
|
+
* Get public key as base58 (keypair mode only)
|
|
231
|
+
*/
|
|
172
232
|
getPublicKeyBase58() {
|
|
173
233
|
return this.publicKey ? bs58_1.default.encode(this.publicKey) : undefined;
|
|
174
234
|
}
|
|
235
|
+
/**
|
|
236
|
+
* Get smart account PDA
|
|
237
|
+
*/
|
|
175
238
|
getSmartAccountPDA() {
|
|
176
239
|
return this.smartAccountPDA;
|
|
177
240
|
}
|
|
241
|
+
/**
|
|
242
|
+
* Get webhook URL
|
|
243
|
+
*/
|
|
178
244
|
getWebhookUrl() {
|
|
179
245
|
return this.webhookUrl;
|
|
180
246
|
}
|
|
247
|
+
// ===== Serialization =====
|
|
248
|
+
/**
|
|
249
|
+
* Serialize auth config
|
|
250
|
+
*/
|
|
181
251
|
serialize() {
|
|
182
|
-
if (this.
|
|
252
|
+
if (this.authType === 'jwt') {
|
|
183
253
|
const data = {
|
|
184
254
|
authMethod: 'jwt',
|
|
185
255
|
jwt: this.jwt,
|
|
186
256
|
smartAccountId: this.smartAccountId,
|
|
187
|
-
|
|
257
|
+
smartAccountPDA: this.smartAccountPDA,
|
|
258
|
+
webhookUrl: this.webhookUrl
|
|
259
|
+
};
|
|
260
|
+
return Buffer.from(JSON.stringify(data)).toString('base64');
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
const data = {
|
|
264
|
+
authMethod: 'keypair',
|
|
265
|
+
privateKey: Array.from(this.privateKey),
|
|
266
|
+
agentId: this.agentId,
|
|
267
|
+
orgId: this.orgId,
|
|
268
|
+
publicKey: Array.from(this.publicKey),
|
|
269
|
+
smartAccountPDA: this.smartAccountPDA,
|
|
270
|
+
webhookUrl: this.webhookUrl
|
|
188
271
|
};
|
|
189
272
|
return bs58_1.default.encode(Buffer.from(JSON.stringify(data)));
|
|
190
273
|
}
|
|
191
|
-
const data = {
|
|
192
|
-
authMethod: 'legacy',
|
|
193
|
-
privateKey: Array.from(this.privateKey),
|
|
194
|
-
agentId: this.agentId,
|
|
195
|
-
orgId: this.orgId,
|
|
196
|
-
publicKey: Array.from(this.publicKey),
|
|
197
|
-
smartAccountPDA: this.smartAccountPDA,
|
|
198
|
-
webhookUrl: this.webhookUrl,
|
|
199
|
-
};
|
|
200
|
-
return bs58_1.default.encode(Buffer.from(JSON.stringify(data)));
|
|
201
274
|
}
|
|
275
|
+
/**
|
|
276
|
+
* Deserialize auth config
|
|
277
|
+
*/
|
|
202
278
|
static deserialize(serialized) {
|
|
203
279
|
try {
|
|
280
|
+
// Try JWT format first (base64)
|
|
281
|
+
try {
|
|
282
|
+
const data = JSON.parse(Buffer.from(serialized, 'base64').toString());
|
|
283
|
+
if (data.authMethod === 'jwt') {
|
|
284
|
+
return new DainClientAuth({
|
|
285
|
+
jwt: data.jwt,
|
|
286
|
+
smartAccountId: data.smartAccountId,
|
|
287
|
+
smartAccountPDA: data.smartAccountPDA,
|
|
288
|
+
webhookUrl: data.webhookUrl
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
catch {
|
|
293
|
+
// Not JWT format, try keypair
|
|
294
|
+
}
|
|
295
|
+
// Try keypair format (bs58)
|
|
204
296
|
const data = JSON.parse(Buffer.from(bs58_1.default.decode(serialized)).toString());
|
|
205
|
-
if (data.authMethod === '
|
|
297
|
+
if (data.authMethod === 'keypair') {
|
|
206
298
|
return new DainClientAuth({
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
299
|
+
privateKeyBase58: bs58_1.default.encode(new Uint8Array(data.privateKey)),
|
|
300
|
+
agentId: data.agentId,
|
|
301
|
+
orgId: data.orgId,
|
|
302
|
+
smartAccountPDA: data.smartAccountPDA,
|
|
303
|
+
webhookUrl: data.webhookUrl
|
|
210
304
|
});
|
|
211
305
|
}
|
|
212
|
-
|
|
213
|
-
return new DainClientAuth({
|
|
214
|
-
privateKeyBase58: bs58_1.default.encode(new Uint8Array(data.privateKey)),
|
|
215
|
-
agentId: data.agentId,
|
|
216
|
-
orgId: data.orgId,
|
|
217
|
-
smartAccountPDA: data.smartAccountPDA,
|
|
218
|
-
webhookUrl: data.webhookUrl,
|
|
219
|
-
});
|
|
306
|
+
throw new Error('Unknown auth method');
|
|
220
307
|
}
|
|
221
308
|
catch (error) {
|
|
222
|
-
throw new Error(
|
|
309
|
+
throw new Error('Failed to deserialize DainClientAuth: ' + error.message);
|
|
223
310
|
}
|
|
224
311
|
}
|
|
225
312
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-auth.js","sourceRoot":"","sources":["../../src/client/client-auth.ts"],"names":[],"mappings":";;;;AAAA,iCAAiC;AACjC,mDAAgD;AAChD,iDAA8C;AAC9C,+CAAiD;AACjD,wDAAwB;
|
|
1
|
+
{"version":3,"file":"client-auth.js","sourceRoot":"","sources":["../../src/client/client-auth.ts"],"names":[],"mappings":";;;;AAAA,iCAAiC;AACjC;;;;;;GAMG;AACH,mDAAgD;AAChD,iDAA8C;AAC9C,+CAAiD;AACjD,wDAAwB;AA+CxB;;GAEG;AACH,SAAS,WAAW,CAAC,MAA4B;IAC/C,OAAO,KAAK,IAAI,MAAM,IAAI,OAAQ,MAAc,CAAC,GAAG,KAAK,QAAQ,CAAC;AACpE,CAAC;AAED;;;;GAIG;AACH,MAAa,cAAc;IACzB,YAAY;IACJ,QAAQ,CAAoB;IAEpC,0BAA0B;IAClB,GAAG,CAAU;IACb,cAAc,CAAU;IAEhC,wCAAwC;IAChC,UAAU,CAAc;IACxB,OAAO,CAAU;IACjB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O,CAAC,CAAC;QACvF,CAAC;IACH,CAAC;CACF;AAjUD,wCAiUC"}
|
package/dist/client/index.js
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./client"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./client-auth"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./client-auth"), exports); // Unified auth: JWT (users) + Keypair (services/agents)
|
|
6
6
|
tslib_1.__exportStar(require("./api-sdk"), exports);
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
package/dist/client/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":";;;AAAA,mDAAyB;AACzB,wDAA8B;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":";;;AAAA,mDAAyB;AACzB,wDAA8B,CAAE,wDAAwD;AACxF,oDAA0B"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Service/Agent Authentication - Legacy Keypair-based
|
|
3
|
+
*
|
|
4
|
+
* This class is for SERVICE and AGENT authentication using legacy keypair-based signatures.
|
|
5
|
+
* End users should NOT use this class - they must use DainUserAuth with JWT tokens.
|
|
6
|
+
*/
|
|
7
|
+
import { DainClientAuth } from './client-auth';
|
|
8
|
+
export interface DainServiceAuthConfig {
|
|
9
|
+
/** Service API key (format: sk_agent_org_<orgId>_<agentId>_<keypair>) */
|
|
10
|
+
apiKey?: string;
|
|
11
|
+
/** OR provide individual components: */
|
|
12
|
+
/** Base58-encoded Ed25519 private key */
|
|
13
|
+
privateKeyBase58?: string;
|
|
14
|
+
/** Agent ID */
|
|
15
|
+
agentId?: string;
|
|
16
|
+
/** Organization ID */
|
|
17
|
+
orgId?: string;
|
|
18
|
+
/** Smart Account PDA on Solana (optional) */
|
|
19
|
+
smartAccountPDA?: string;
|
|
20
|
+
/** Webhook URL for async operations (optional) */
|
|
21
|
+
webhookUrl?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* DainServiceAuth - Legacy keypair-based authentication for services and agents
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* // Authenticate as a service with API key
|
|
29
|
+
* const serviceAuth = new DainServiceAuth({
|
|
30
|
+
* apiKey: "sk_agent_org_123_agent_456_<base58key>"
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* // OR with individual components
|
|
34
|
+
* const serviceAuth = new DainServiceAuth({
|
|
35
|
+
* privateKeyBase58: "49bhyNKM...",
|
|
36
|
+
* agentId: "agent_456",
|
|
37
|
+
* orgId: "org_123"
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare class DainServiceAuth extends DainClientAuth {
|
|
42
|
+
constructor(config: DainServiceAuthConfig);
|
|
43
|
+
/**
|
|
44
|
+
* Get the service's agent ID
|
|
45
|
+
*/
|
|
46
|
+
getServiceAgentId(): string;
|
|
47
|
+
/**
|
|
48
|
+
* Get the service's organization ID
|
|
49
|
+
*/
|
|
50
|
+
getServiceOrgId(): string;
|
|
51
|
+
/**
|
|
52
|
+
* Override to prevent JWT methods
|
|
53
|
+
* @deprecated Not supported for service authentication
|
|
54
|
+
*/
|
|
55
|
+
getSmartAccountId(): never;
|
|
56
|
+
/**
|
|
57
|
+
* Override to prevent JWT methods
|
|
58
|
+
* @deprecated Not supported for service authentication
|
|
59
|
+
*/
|
|
60
|
+
getJWT(): never;
|
|
61
|
+
}
|