@voidaisdk/bridge-sdk 0.0.3 → 0.0.5

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.
@@ -9,9 +9,7 @@ export declare class VoidAIBridgeClient {
9
9
  readonly ready: Promise<void>;
10
10
  constructor(config: BridgeConfig);
11
11
  /**
12
- * Authenticate and set Authorization header for subsequent requests.
13
- * New flow: POST /api/v1/auth/login
14
- * Fallback: GET /api/v1/auth/validate-api-key (legacy)
12
+ * Authenticate via POST /api/v1/auth/login and set Authorization header.
15
13
  */
16
14
  private authenticate;
17
15
  private setAccessToken;
@@ -32,15 +30,6 @@ export declare class VoidAIBridgeClient {
32
30
  login(): Promise<string>;
33
31
  private tryDecodeTokenToValidationData;
34
32
  private base64UrlDecode;
35
- /**
36
- * Validate API key with the backend
37
- * @throws Error if API key is invalid
38
- */
39
- validateApiKey(): Promise<ApiKeyValidationData>;
40
- /**
41
- * Get validation URL - uses baseUrl from config
42
- */
43
- private getValidationUrl;
44
33
  /**
45
34
  * Get validated API key data
46
35
  */
@@ -17,31 +17,15 @@ class VoidAIBridgeClient {
17
17
  },
18
18
  });
19
19
  // Start auth immediately. Requests will await this promise.
20
- // New flow: POST /auth/login to get JWT. Fallback to validate-api-key for backward compatibility.
21
20
  this.ready = this.authenticate().then(() => undefined);
22
21
  }
23
22
  /**
24
- * Authenticate and set Authorization header for subsequent requests.
25
- * New flow: POST /api/v1/auth/login
26
- * Fallback: GET /api/v1/auth/validate-api-key (legacy)
23
+ * Authenticate via POST /api/v1/auth/login and set Authorization header.
27
24
  */
28
25
  async authenticate() {
29
- try {
30
- const token = await this.login();
31
- this.setAccessToken(token);
32
- // Populate validatedApiKeyData from JWT payload (best-effort) so existing getters keep working.
33
- this.validatedApiKeyData = this.tryDecodeTokenToValidationData(token);
34
- }
35
- catch (error) {
36
- // If login isn't available or fails unexpectedly, fallback to legacy validation
37
- // (do not break current working functionality).
38
- try {
39
- await this.validateApiKey();
40
- }
41
- catch (fallbackError) {
42
- throw error;
43
- }
44
- }
26
+ const token = await this.login();
27
+ this.setAccessToken(token);
28
+ this.validatedApiKeyData = this.tryDecodeTokenToValidationData(token);
45
29
  }
46
30
  setAccessToken(token) {
47
31
  this.accessToken = token;
@@ -56,7 +40,7 @@ class VoidAIBridgeClient {
56
40
  getLoginUrl() {
57
41
  const baseUrl = this.config.getBaseUrl();
58
42
  const cleanBase = baseUrl.replace(/\/$/, '');
59
- return `${cleanBase}/api/v1/auth/login`;
43
+ return `${cleanBase}/v1/auth/login`;
60
44
  }
61
45
  /**
62
46
  * Get EVM bridge contract address for burn operations.
@@ -130,53 +114,6 @@ class VoidAIBridgeClient {
130
114
  // @ts-ignore
131
115
  return atob(padded);
132
116
  }
133
- /**
134
- * Validate API key with the backend
135
- * @throws Error if API key is invalid
136
- */
137
- async validateApiKey() {
138
- try {
139
- // Use a temporary axios instance for validation since baseUrl might be different
140
- const validationUrl = this.getValidationUrl();
141
- const response = await axios_1.default.get(validationUrl, {
142
- headers: {
143
- 'api-key': this.config.apiKey,
144
- },
145
- timeout: 10000,
146
- });
147
- if (response.data.success) {
148
- this.validatedApiKeyData = response.data.data;
149
- return response.data.data;
150
- }
151
- else {
152
- const error = new Error(response.data.error.message);
153
- error.code = response.data.error.code;
154
- throw error;
155
- }
156
- }
157
- catch (error) {
158
- // If validation fails, ensure we don't keep stale validated data around.
159
- this.validatedApiKeyData = null;
160
- if (axios_1.default.isAxiosError(error)) {
161
- if (error.response?.status === 401) {
162
- const errorData = error.response.data;
163
- const apiError = new Error(errorData.error?.message || 'API key is invalid or inactive');
164
- apiError.code = errorData.error?.code || 'INVALID_API_KEY';
165
- throw apiError;
166
- }
167
- throw new Error(`Failed to validate API key: ${error.message}`);
168
- }
169
- throw error;
170
- }
171
- }
172
- /**
173
- * Get validation URL - uses baseUrl from config
174
- */
175
- getValidationUrl() {
176
- const baseUrl = this.config.getBaseUrl();
177
- const cleanBase = baseUrl.replace(/\/$/, '');
178
- return `${cleanBase}/api/v1/auth/validate-api-key`;
179
- }
180
117
  /**
181
118
  * Get validated API key data
182
119
  */
@@ -285,7 +222,7 @@ class VoidAIBridgeClient {
285
222
  * Bridge swap operation
286
223
  */
287
224
  async bridgeSwap(payload) {
288
- return this.post('api/v1/bridge/swap', payload);
225
+ return this.post('v1/bridge/swap', payload);
289
226
  }
290
227
  /**
291
228
  * Route transaction operation (SWAP / BRIDGE / CCIP)
@@ -297,7 +234,7 @@ class VoidAIBridgeClient {
297
234
  ...payload,
298
235
  amount: String(payload.amount),
299
236
  };
300
- return this.post('api/v1/bridge/route-transaction', normalizedPayload);
237
+ return this.post('v1/bridge/route-transaction', normalizedPayload);
301
238
  }
302
239
  /**
303
240
  * Cancel a CCIP route transaction
@@ -309,7 +246,7 @@ class VoidAIBridgeClient {
309
246
  toToken: params.toToken,
310
247
  uuid: params.uuid,
311
248
  };
312
- return this.delete('api/v1/bridge/cancel-ccip', queryParams);
249
+ return this.delete('v1/bridge/cancel-ccip', queryParams);
313
250
  }
314
251
  /**
315
252
  * Cancel a router swap transaction
@@ -318,13 +255,13 @@ class VoidAIBridgeClient {
318
255
  const queryParams = {
319
256
  uuid: params.uuid,
320
257
  };
321
- return this.delete('api/v1/bridge/cancel-router-swap', queryParams);
258
+ return this.delete('v1/bridge/cancel-router-swap', queryParams);
322
259
  }
323
260
  /**
324
261
  * Cancel a bridge swap transaction
325
262
  */
326
263
  async cancelBridgeSwap(params) {
327
- return this.patch('api/v1/bridge/swap/cancel', params);
264
+ return this.patch('v1/bridge/swap/cancel', params);
328
265
  }
329
266
  /**
330
267
  * Get recent API transactions (tenant-level)
@@ -334,19 +271,19 @@ class VoidAIBridgeClient {
334
271
  page: String(page),
335
272
  limit: String(limit),
336
273
  };
337
- return this.get('api/v1/bridge/api-transactions', queryParams);
274
+ return this.get('v1/bridge/api-transactions', queryParams);
338
275
  }
339
276
  /**
340
277
  * Manually validate a bridge burn transaction (EVM burn completion)
341
278
  */
342
279
  async validateBurn(params) {
343
- return this.post('api/v1/bridge/validate-burn', params);
280
+ return this.post('v1/bridge/validate-burn', params);
344
281
  }
345
282
  /**
346
283
  * Manually confirm a CCIP transaction
347
284
  */
348
285
  async confirmCcipTransaction(params) {
349
- const path = `api/v1/bridge/transactions/${encodeURIComponent(params.transactionId)}/tx`;
286
+ const path = `v1/bridge/transactions/${encodeURIComponent(params.transactionId)}/tx`;
350
287
  const body = {
351
288
  txnHash: params.txnHash,
352
289
  operationType: params.operationType,
@@ -372,7 +309,7 @@ class VoidAIBridgeClient {
372
309
  if (options?.chainId !== undefined) {
373
310
  params.chain_id = options.chainId;
374
311
  }
375
- const response = await this.get('api/v1/chain/chains', params);
312
+ const response = await this.get('v1/chain/chains', params);
376
313
  if (!response.success || !response.data) {
377
314
  throw new Error(response.message || 'Failed to fetch chains');
378
315
  }
@@ -386,7 +323,7 @@ class VoidAIBridgeClient {
386
323
  page: String(page),
387
324
  limit: String(limit),
388
325
  };
389
- const response = await this.get('api/v1/asset/assets', queryParams);
326
+ const response = await this.get('v1/asset/assets', queryParams);
390
327
  if (!response.success || !response.data) {
391
328
  throw new Error(response.message || 'Failed to fetch assets');
392
329
  }
@@ -406,9 +343,7 @@ class VoidAIBridgeClient {
406
343
  toToken: params.toToken,
407
344
  amount: String(params.amount),
408
345
  };
409
- return this.get('api/v1/bridge/call-fee', queryParams, false, {
410
- headers: { 'x-api-key': this.config.apiKey },
411
- });
346
+ return this.get('v1/bridge/call-fee', queryParams);
412
347
  }
413
348
  /**
414
349
  * Get router swap fee estimate
@@ -422,7 +357,7 @@ class VoidAIBridgeClient {
422
357
  operationType: params.operationType,
423
358
  toAddress: params.toAddress,
424
359
  };
425
- return this.get('api/v1/router-swap/call-fee', queryParams, false, { headers: { 'x-api-key': this.config.apiKey } });
360
+ return this.get('v1/router-swap/call-fee', queryParams);
426
361
  }
427
362
  /**
428
363
  * Normalize and rethrow errors with backend message (if available) so
package/dist/config.js CHANGED
@@ -27,15 +27,15 @@ class BridgeConfig {
27
27
  exports.BridgeConfig = BridgeConfig;
28
28
  BridgeConfig.DEFAULTS = {
29
29
  devnet: {
30
- baseUrl: 'https://api-sdk-dev.voidai.envistudios.com/',
30
+ baseUrl: 'https://api-sdk-dev.voidai.envistudios.com/api',
31
31
  bridgeContractAddress: '0x6266ce15aC4f32F096Ff91881dd887a0F4bBa569',
32
32
  },
33
33
  testnet: {
34
- baseUrl: 'https://sdk-backend.voidai.com/',
34
+ baseUrl: 'https://sdk-backend.voidai.com/api',
35
35
  bridgeContractAddress: '0x4aA4396BfD6F268b427077079800F420dF947b63',
36
36
  },
37
37
  mainnet: {
38
- baseUrl: 'https://api-sdk.voidai.envistudios.com/',
39
- bridgeContractAddress: '0x604e8Ef901C0E69E79463D997ba7D0724A909b84',
38
+ baseUrl: 'https://d45byonnywfx1.cloudfront.net/sdk',
39
+ bridgeContractAddress: '0x4aA4396BfD6F268b427077079800F420dF947b63',
40
40
  },
41
41
  };