@dainprotocol/service-sdk 1.2.1 → 1.2.3

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.
@@ -1,51 +1,85 @@
1
- interface DainClientAuthConfig {
2
- jwt?: string;
1
+ /**
2
+ * CLIENT-SIDE JWT Authentication (Users Only)
3
+ *
4
+ * Users authenticate with JWT tokens from DAIN ID OAuth.
5
+ * NO orgId, NO agentId, NO keypair - completely removed for client-side.
6
+ *
7
+ * For SERVICE-SIDE keypair authentication (services/agents), see /src/service/auth.ts
8
+ */
9
+ /**
10
+ * JWT Authentication Config (Users)
11
+ */
12
+ export interface DainClientAuthConfig {
13
+ /** JWT access token from DAIN ID OAuth */
14
+ jwt: string;
15
+ /** Smart Account ID (optional, will be extracted from JWT if not provided) */
3
16
  smartAccountId?: string;
4
- privateKeyBase58?: string;
5
- agentId?: string;
6
- orgId?: string;
7
- apiKey?: string;
17
+ /** Smart Account PDA on Solana (optional) */
8
18
  smartAccountPDA?: string;
19
+ /** Webhook URL for async operations (optional) */
9
20
  webhookUrl?: string;
10
21
  }
22
+ /**
23
+ * DainClientAuth - JWT-only authentication for users
24
+ *
25
+ * This class is for CLIENT-SIDE use only (e.g., butterfly-web).
26
+ * Users authenticate with JWT tokens - NO keypairs, NO orgId, NO agentId.
27
+ *
28
+ * For SERVICE-SIDE authentication with keypairs, use the service SDK's built-in auth.
29
+ */
11
30
  export declare class DainClientAuth {
12
- private jwt?;
13
- private smartAccountId?;
14
- private privateKey?;
15
- private agentId?;
16
- private orgId?;
17
- private publicKey?;
31
+ private jwt;
32
+ private smartAccountId;
18
33
  private smartAccountPDA?;
19
34
  private webhookUrl?;
20
- private readonly authMethod;
21
35
  constructor(config: DainClientAuthConfig);
22
- private parseApiKey;
23
36
  /**
24
- * Sign request for legacy authentication
25
- * For JWT auth, returns empty values (not needed)
37
+ * Decode JWT payload (without verification)
38
+ * @private
26
39
  */
27
- signRequest(method: string, path: string, body: string): Promise<{
40
+ private decodeJWTPayload;
41
+ /**
42
+ * Sign request - NOT NEEDED for JWT (returns empty for compatibility)
43
+ */
44
+ signRequest(_method: string, _path: string, _body: string): Promise<{
28
45
  signature: string;
29
46
  timestamp: string;
30
47
  }>;
31
48
  /**
32
- * Get headers for authentication
33
- * Returns different headers based on auth method
49
+ * Get headers for HTTP requests
50
+ */
51
+ getHeaders(_signature: string, _timestamp: string): Record<string, string>;
52
+ /**
53
+ * Check if using JWT authentication (always true for client-side)
54
+ */
55
+ isJWT(): boolean;
56
+ /**
57
+ * Get JWT token
58
+ */
59
+ getJWT(): string;
60
+ /**
61
+ * Get smart account ID
62
+ */
63
+ getSmartAccountId(): string;
64
+ /**
65
+ * Get smart account PDA
34
66
  */
35
- getHeaders(signature: string, timestamp: string): Record<string, string>;
36
- signMessage(message: string): string;
37
- static verifyMessage(message: string, signature: string, publicKey: Uint8Array): boolean;
38
- verifyEventSignature(data: string, signature: string, timestamp: string, publicKeyBase58: string): boolean;
39
- getAuthMethod(): 'jwt' | 'legacy';
40
- getJWT(): string | undefined;
41
- getSmartAccountId(): string | undefined;
42
- getAgentId(): string | undefined;
43
- getOrgId(): string | undefined;
44
- getPublicKey(): Uint8Array | undefined;
45
- getPublicKeyBase58(): string | undefined;
46
67
  getSmartAccountPDA(): string | undefined;
68
+ /**
69
+ * Get webhook URL
70
+ */
47
71
  getWebhookUrl(): string | undefined;
72
+ /**
73
+ * Verify SSE event signature from service
74
+ * (Services sign their event responses, users verify them)
75
+ */
76
+ verifyEventSignature(data: string, signature: string, timestamp: string, publicKeyBase58: string): boolean;
77
+ /**
78
+ * Serialize auth config
79
+ */
48
80
  serialize(): string;
81
+ /**
82
+ * Deserialize auth config
83
+ */
49
84
  static deserialize(serialized: string): DainClientAuth;
50
85
  }
51
- export {};
@@ -1,225 +1,161 @@
1
1
  "use strict";
2
+ //File: src/client/client-auth.ts
3
+ /**
4
+ * CLIENT-SIDE JWT Authentication (Users Only)
5
+ *
6
+ * Users authenticate with JWT tokens from DAIN ID OAuth.
7
+ * NO orgId, NO agentId, NO keypair - completely removed for client-side.
8
+ *
9
+ * For SERVICE-SIDE keypair authentication (services/agents), see /src/service/auth.ts
10
+ */
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
12
  exports.DainClientAuth = void 0;
4
- const tslib_1 = require("tslib");
5
- //File: src/client/client-auth.ts
6
- const ed25519_1 = require("@noble/curves/ed25519");
7
- const sha256_1 = require("@noble/hashes/sha256");
8
- const utils_1 = require("@noble/hashes/utils");
9
- const bs58_1 = tslib_1.__importDefault(require("bs58"));
13
+ /**
14
+ * DainClientAuth - JWT-only authentication for users
15
+ *
16
+ * This class is for CLIENT-SIDE use only (e.g., butterfly-web).
17
+ * Users authenticate with JWT tokens - NO keypairs, NO orgId, NO agentId.
18
+ *
19
+ * For SERVICE-SIDE authentication with keypairs, use the service SDK's built-in auth.
20
+ */
10
21
  class DainClientAuth {
11
- // JWT fields (user auth)
12
22
  jwt;
13
23
  smartAccountId;
14
- // Legacy fields (service auth)
15
- privateKey;
16
- agentId;
17
- orgId;
18
- publicKey;
19
24
  smartAccountPDA;
20
- // Common
21
25
  webhookUrl;
22
- authMethod;
23
26
  constructor(config) {
24
- // Priority 1: JWT Authentication (Users from DAIN ID)
25
- if (config.jwt) {
26
- this.jwt = config.jwt;
27
- this.authMethod = 'jwt';
28
- this.webhookUrl = config.webhookUrl;
29
- // Extract smartAccountId from JWT if not provided
30
- if (config.smartAccountId) {
31
- this.smartAccountId = config.smartAccountId;
32
- }
33
- else {
34
- try {
35
- const payload = JSON.parse(Buffer.from(config.jwt.split('.')[1], 'base64').toString());
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
- }
44
- }
45
- return;
27
+ if (!config.jwt) {
28
+ throw new Error('JWT token is required for user authentication');
46
29
  }
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
- this.smartAccountPDA = config.smartAccountPDA;
56
- this.authMethod = 'legacy';
57
- return;
30
+ this.jwt = config.jwt;
31
+ // Extract smartAccountId from config or decode from JWT
32
+ if (config.smartAccountId) {
33
+ this.smartAccountId = config.smartAccountId;
58
34
  }
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
- this.webhookUrl = config.webhookUrl;
66
- this.smartAccountPDA = config.smartAccountPDA;
67
- this.authMethod = 'legacy';
68
- return;
35
+ else {
36
+ const payload = this.decodeJWTPayload(config.jwt);
37
+ this.smartAccountId = payload.smart_account_id || payload.sub;
69
38
  }
70
- throw new Error('Invalid auth config. Provide either:\n' +
71
- ' - jwt (for users)\n' +
72
- ' - apiKey OR (privateKeyBase58 + agentId + orgId) (for services)');
39
+ this.smartAccountPDA = config.smartAccountPDA;
40
+ this.webhookUrl = config.webhookUrl;
73
41
  }
74
- parseApiKey(apiKey) {
75
- const parts = apiKey.split('_');
76
- if (parts.length !== 5 || parts[0] !== 'sk' || parts[1] !== 'agent') {
77
- throw new Error('Invalid API key format');
42
+ /**
43
+ * Decode JWT payload (without verification)
44
+ * @private
45
+ */
46
+ decodeJWTPayload(jwt) {
47
+ const parts = jwt.split('.');
48
+ if (parts.length !== 3) {
49
+ throw new Error('Invalid JWT format');
78
50
  }
79
- const orgId = parts[2].replace('org_', '');
80
- const agentId = parts[3].replace('agent_', '');
81
- const privateKeyBase58 = parts[4];
82
- const privateKey = bs58_1.default.decode(privateKeyBase58).slice(0, 32);
83
- const publicKey = bs58_1.default.decode(privateKeyBase58).slice(32);
84
- return { privateKey, agentId, orgId, publicKey };
51
+ const payload = Buffer.from(parts[1], 'base64').toString('utf-8');
52
+ return JSON.parse(payload);
85
53
  }
86
54
  /**
87
- * Sign request for legacy authentication
88
- * For JWT auth, returns empty values (not needed)
55
+ * Sign request - NOT NEEDED for JWT (returns empty for compatibility)
89
56
  */
90
- async signRequest(method, path, body) {
91
- if (this.authMethod === 'jwt') {
92
- // JWT doesn't need request signing
93
- return { signature: '', timestamp: '' };
94
- }
95
- // Legacy: Sign request
96
- const timestamp = Date.now().toString();
97
- const message = `${method}:${path}:${timestamp}:${body}`;
98
- const messageHash = (0, sha256_1.sha256)(message);
99
- const signature = ed25519_1.ed25519.sign(messageHash, this.privateKey);
100
- return { signature: (0, utils_1.bytesToHex)(signature), timestamp };
57
+ async signRequest(_method, _path, _body) {
58
+ return { signature: '', timestamp: '' };
101
59
  }
102
60
  /**
103
- * Get headers for authentication
104
- * Returns different headers based on auth method
61
+ * Get headers for HTTP requests
105
62
  */
106
- getHeaders(signature, timestamp) {
107
- if (this.authMethod === 'jwt') {
108
- // JWT Authentication
109
- const headers = {
110
- "Authorization": `Bearer ${this.jwt}`,
111
- "X-DAIN-SMART-ACCOUNT-ID": this.smartAccountId,
112
- };
113
- if (this.webhookUrl) {
114
- headers["X-DAIN-WEBHOOK-URL"] = this.webhookUrl;
115
- }
116
- return headers;
117
- }
118
- // Legacy Authentication
119
- return {
120
- "X-DAIN-SIGNATURE": signature,
121
- "X-DAIN-TIMESTAMP": timestamp,
122
- "X-DAIN-AGENT-ID": this.agentId,
123
- "X-DAIN-ORG-ID": this.orgId,
124
- "X-DAIN-ADDRESS": bs58_1.default.encode(this.publicKey),
125
- "X-DAIN-SMART-ACCOUNT-PDA": this.smartAccountPDA || '',
126
- "X-DAIN-WEBHOOK-URL": this.webhookUrl || '',
63
+ getHeaders(_signature, _timestamp) {
64
+ const headers = {
65
+ "Authorization": `Bearer ${this.jwt}`,
127
66
  };
128
- }
129
- signMessage(message) {
130
- if (this.authMethod === 'jwt') {
131
- throw new Error('JWT auth does not support message signing');
67
+ if (this.smartAccountPDA) {
68
+ headers["X-DAIN-SMART-ACCOUNT-PDA"] = this.smartAccountPDA;
132
69
  }
133
- const messageHash = (0, sha256_1.sha256)(message);
134
- const signature = ed25519_1.ed25519.sign(messageHash, this.privateKey);
135
- return (0, utils_1.bytesToHex)(signature);
136
- }
137
- static verifyMessage(message, signature, publicKey) {
138
- const messageHash = (0, sha256_1.sha256)(message);
139
- return ed25519_1.ed25519.verify(signature, messageHash, publicKey);
140
- }
141
- verifyEventSignature(data, signature, timestamp, publicKeyBase58) {
142
- try {
143
- const message = `${data}:${timestamp}`;
144
- const messageHash = (0, sha256_1.sha256)(message);
145
- const publicKey = bs58_1.default.decode(publicKeyBase58);
146
- return ed25519_1.ed25519.verify(signature, messageHash, publicKey);
147
- }
148
- catch (error) {
149
- console.error('Error verifying event signature:', error);
150
- return false;
70
+ if (this.webhookUrl) {
71
+ headers["X-DAIN-WEBHOOK-URL"] = this.webhookUrl;
151
72
  }
73
+ return headers;
152
74
  }
153
- // Getters
154
- getAuthMethod() {
155
- return this.authMethod;
75
+ // ===== Getter Methods =====
76
+ /**
77
+ * Check if using JWT authentication (always true for client-side)
78
+ */
79
+ isJWT() {
80
+ return true;
156
81
  }
82
+ /**
83
+ * Get JWT token
84
+ */
157
85
  getJWT() {
158
86
  return this.jwt;
159
87
  }
88
+ /**
89
+ * Get smart account ID
90
+ */
160
91
  getSmartAccountId() {
161
92
  return this.smartAccountId;
162
93
  }
163
- getAgentId() {
164
- return this.agentId;
165
- }
166
- getOrgId() {
167
- return this.orgId;
168
- }
169
- getPublicKey() {
170
- return this.publicKey;
171
- }
172
- getPublicKeyBase58() {
173
- return this.publicKey ? bs58_1.default.encode(this.publicKey) : undefined;
174
- }
94
+ /**
95
+ * Get smart account PDA
96
+ */
175
97
  getSmartAccountPDA() {
176
98
  return this.smartAccountPDA;
177
99
  }
100
+ /**
101
+ * Get webhook URL
102
+ */
178
103
  getWebhookUrl() {
179
104
  return this.webhookUrl;
180
105
  }
181
- serialize() {
182
- if (this.authMethod === 'jwt') {
183
- const data = {
184
- authMethod: 'jwt',
185
- jwt: this.jwt,
186
- smartAccountId: this.smartAccountId,
187
- webhookUrl: this.webhookUrl,
188
- };
189
- return bs58_1.default.encode(Buffer.from(JSON.stringify(data)));
106
+ /**
107
+ * Verify SSE event signature from service
108
+ * (Services sign their event responses, users verify them)
109
+ */
110
+ verifyEventSignature(data, signature, timestamp, publicKeyBase58) {
111
+ try {
112
+ // This is for verifying SERVICE signatures, not user signatures
113
+ // Import crypto libs only when needed
114
+ const { ed25519 } = require("@noble/curves/ed25519");
115
+ const { sha256 } = require("@noble/hashes/sha256");
116
+ const bs58 = require("bs58");
117
+ const message = `${data}:${timestamp}`;
118
+ const messageHash = sha256(message);
119
+ const publicKey = bs58.decode(publicKeyBase58);
120
+ return ed25519.verify(signature, messageHash, publicKey);
121
+ }
122
+ catch (error) {
123
+ console.error('Error verifying event signature:', error);
124
+ return false;
190
125
  }
126
+ }
127
+ // ===== Serialization =====
128
+ /**
129
+ * Serialize auth config
130
+ */
131
+ serialize() {
191
132
  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),
133
+ authMethod: 'jwt',
134
+ jwt: this.jwt,
135
+ smartAccountId: this.smartAccountId,
197
136
  smartAccountPDA: this.smartAccountPDA,
198
- webhookUrl: this.webhookUrl,
137
+ webhookUrl: this.webhookUrl
199
138
  };
200
- return bs58_1.default.encode(Buffer.from(JSON.stringify(data)));
139
+ return Buffer.from(JSON.stringify(data)).toString('base64');
201
140
  }
141
+ /**
142
+ * Deserialize auth config
143
+ */
202
144
  static deserialize(serialized) {
203
145
  try {
204
- const data = JSON.parse(Buffer.from(bs58_1.default.decode(serialized)).toString());
205
- if (data.authMethod === 'jwt') {
206
- return new DainClientAuth({
207
- jwt: data.jwt,
208
- smartAccountId: data.smartAccountId,
209
- webhookUrl: data.webhookUrl,
210
- });
146
+ const data = JSON.parse(Buffer.from(serialized, 'base64').toString());
147
+ if (data.authMethod !== 'jwt') {
148
+ throw new Error('Invalid auth method - client-side only supports JWT');
211
149
  }
212
- // Legacy or missing authMethod (backward compatibility)
213
150
  return new DainClientAuth({
214
- privateKeyBase58: bs58_1.default.encode(new Uint8Array(data.privateKey)),
215
- agentId: data.agentId,
216
- orgId: data.orgId,
151
+ jwt: data.jwt,
152
+ smartAccountId: data.smartAccountId,
217
153
  smartAccountPDA: data.smartAccountPDA,
218
- webhookUrl: data.webhookUrl,
154
+ webhookUrl: data.webhookUrl
219
155
  });
220
156
  }
221
157
  catch (error) {
222
- throw new Error(`Failed to deserialize DainClientAuth: ${error.message}`);
158
+ throw new Error('Failed to deserialize DainClientAuth: ' + error.message);
223
159
  }
224
160
  }
225
161
  }
@@ -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;AAkBxB,MAAa,cAAc;IACzB,yBAAyB;IACjB,GAAG,CAAU;IACb,cAAc,CAAU;IAEhC,+BAA+B;IACvB,UAAU,CAAc;IACxB,OAAO,CAAU;IACjB,KAAK,CAAU;IACf,SAAS,CAAc;IACvB,eAAe,CAAU;IAEjC,SAAS;IACD,UAAU,CAAU;IACX,UAAU,CAAmB;IAE9C,YAAY,MAA4B;QACtC,sDAAsD;QACtD,IAAI,MAAM,CAAC,GAAG,EAAE,CAAC;YACf,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC;YACtB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;YACxB,IAAI,CAAC,UAAU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YACH,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;YAEtE,IAAI,IAAI,CAAC,UAAU,KAAK,KAAK,EAAE,CAAC;gBAC9B,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;YACzE,CAAC;YAED,OAAO,IAAI,cAAc,CAAC;gBACxB,GAAG,EAAE,IAAI,CAAC,GAAG;gBACb,cAAc,EAAE,IAAI,CAAC,cAAc;gBACnC,eAAe,EAAE,IAAI,CAAC,eAAe;gBACrC,UAAU,EAAE,IAAI,CAAC,UAAU;aAC5B,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,wCAAwC,GAAI,KAAe,CAAC,OAAO,CAAC,CAAC;QACvF,CAAC;IACH,CAAC;CACF;AArKD,wCAqKC"}
@@ -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
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":";;;AAAA,mDAAyB;AACzB,wDAA8B;AAC9B,oDAA0B"}
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
+ }
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ //File: src/client/service-auth.ts
3
+ /**
4
+ * Service/Agent Authentication - Legacy Keypair-based
5
+ *
6
+ * This class is for SERVICE and AGENT authentication using legacy keypair-based signatures.
7
+ * End users should NOT use this class - they must use DainUserAuth with JWT tokens.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.DainServiceAuth = void 0;
11
+ const client_auth_1 = require("./client-auth");
12
+ /**
13
+ * DainServiceAuth - Legacy keypair-based authentication for services and agents
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * // Authenticate as a service with API key
18
+ * const serviceAuth = new DainServiceAuth({
19
+ * apiKey: "sk_agent_org_123_agent_456_<base58key>"
20
+ * });
21
+ *
22
+ * // OR with individual components
23
+ * const serviceAuth = new DainServiceAuth({
24
+ * privateKeyBase58: "49bhyNKM...",
25
+ * agentId: "agent_456",
26
+ * orgId: "org_123"
27
+ * });
28
+ * ```
29
+ */
30
+ class DainServiceAuth extends client_auth_1.DainClientAuth {
31
+ constructor(config) {
32
+ if (!config.apiKey && !(config.privateKeyBase58 && config.agentId && config.orgId)) {
33
+ throw new Error('Invalid service authentication configuration.\n' +
34
+ 'Provide either:\n' +
35
+ ' - apiKey: "sk_agent_org_<orgId>_<agentId>_<keypair>"\n' +
36
+ ' OR\n' +
37
+ ' - privateKeyBase58, agentId, and orgId\n\n' +
38
+ 'Note: This is for SERVICES and AGENTS only.\n' +
39
+ 'If you are authenticating as a user, use DainUserAuth with a JWT token instead.');
40
+ }
41
+ // Call parent with legacy auth config
42
+ super({
43
+ apiKey: config.apiKey,
44
+ privateKeyBase58: config.privateKeyBase58,
45
+ agentId: config.agentId,
46
+ orgId: config.orgId,
47
+ smartAccountPDA: config.smartAccountPDA,
48
+ webhookUrl: config.webhookUrl,
49
+ });
50
+ // Verify auth method is legacy
51
+ if (this.getAuthMethod() !== 'legacy') {
52
+ throw new Error('DainServiceAuth must use legacy authentication');
53
+ }
54
+ }
55
+ /**
56
+ * Get the service's agent ID
57
+ */
58
+ getServiceAgentId() {
59
+ const agentId = this.getAgentId();
60
+ if (!agentId) {
61
+ throw new Error('Agent ID not available');
62
+ }
63
+ return agentId;
64
+ }
65
+ /**
66
+ * Get the service's organization ID
67
+ */
68
+ getServiceOrgId() {
69
+ const orgId = this.getOrgId();
70
+ if (!orgId) {
71
+ throw new Error('Organization ID not available');
72
+ }
73
+ return orgId;
74
+ }
75
+ /**
76
+ * Override to prevent JWT methods
77
+ * @deprecated Not supported for service authentication
78
+ */
79
+ getSmartAccountId() {
80
+ throw new Error('getSmartAccountId() is not supported for service authentication.\n' +
81
+ 'Use getServiceAgentId() instead.');
82
+ }
83
+ /**
84
+ * Override to prevent JWT methods
85
+ * @deprecated Not supported for service authentication
86
+ */
87
+ getJWT() {
88
+ throw new Error('getJWT() is not supported for service authentication.\n' +
89
+ 'Services use keypair-based authentication, not JWT.');
90
+ }
91
+ }
92
+ exports.DainServiceAuth = DainServiceAuth;
93
+ //# sourceMappingURL=service-auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-auth.js","sourceRoot":"","sources":["../../src/client/service-auth.ts"],"names":[],"mappings":";AAAA,kCAAkC;AAClC;;;;;GAKG;;;AAEH,+CAA+C;AAqB/C;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAa,eAAgB,SAAQ,4BAAc;IACjD,YAAY,MAA6B;QACvC,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,CAAC,gBAAgB,IAAI,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YACnF,MAAM,IAAI,KAAK,CACb,iDAAiD;gBACjD,mBAAmB;gBACnB,0DAA0D;gBAC1D,QAAQ;gBACR,8CAA8C;gBAC9C,+CAA+C;gBAC/C,iFAAiF,CAClF,CAAC;QACJ,CAAC;QAED,sCAAsC;QACtC,KAAK,CAAC;YACJ,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;YACzC,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,eAAe,EAAE,MAAM,CAAC,eAAe;YACvC,UAAU,EAAE,MAAM,CAAC,UAAU;SA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