@diviswap/sdk 1.7.7 → 1.7.9
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/cli/index.js +59 -11
- package/dist/cli/templates/nextjs-app/provider.tsx.hbs +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -6
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.d.mts +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/{wallet-BEGvzNtB.d.mts → wallet-CNiPxV5L.d.mts} +1 -1
- package/dist/{wallet-BEGvzNtB.d.ts → wallet-CNiPxV5L.d.ts} +1 -1
- package/package.json +1 -1
- package/src/cli/templates/nextjs-app/provider.tsx.hbs +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -9,6 +9,7 @@ var prompts = require('prompts');
|
|
|
9
9
|
var kleur = require('kleur');
|
|
10
10
|
var Handlebars = require('handlebars');
|
|
11
11
|
var crypto = require('crypto');
|
|
12
|
+
var https = require('https');
|
|
12
13
|
|
|
13
14
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
15
|
|
|
@@ -16,6 +17,7 @@ var prompts__default = /*#__PURE__*/_interopDefault(prompts);
|
|
|
16
17
|
var kleur__default = /*#__PURE__*/_interopDefault(kleur);
|
|
17
18
|
var Handlebars__default = /*#__PURE__*/_interopDefault(Handlebars);
|
|
18
19
|
var crypto__default = /*#__PURE__*/_interopDefault(crypto);
|
|
20
|
+
var https__default = /*#__PURE__*/_interopDefault(https);
|
|
19
21
|
|
|
20
22
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
21
23
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
@@ -334,12 +336,43 @@ async function generateWebhookFiles(ensureFile, framework, projectRoot) {
|
|
|
334
336
|
);
|
|
335
337
|
}
|
|
336
338
|
}
|
|
339
|
+
function httpsRequest(url, options) {
|
|
340
|
+
return new Promise((resolve, reject) => {
|
|
341
|
+
const parsedUrl = new URL(url);
|
|
342
|
+
const req = https__default.default.request(
|
|
343
|
+
{
|
|
344
|
+
hostname: parsedUrl.hostname,
|
|
345
|
+
port: 443,
|
|
346
|
+
path: parsedUrl.pathname + parsedUrl.search,
|
|
347
|
+
method: options.method,
|
|
348
|
+
headers: options.headers,
|
|
349
|
+
timeout: options.timeout
|
|
350
|
+
},
|
|
351
|
+
(res) => {
|
|
352
|
+
let data = "";
|
|
353
|
+
res.on("data", (chunk) => data += chunk);
|
|
354
|
+
res.on("end", () => {
|
|
355
|
+
resolve({ status: res.statusCode || 0, body: data });
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
);
|
|
359
|
+
req.on("error", reject);
|
|
360
|
+
req.on("timeout", () => {
|
|
361
|
+
req.destroy();
|
|
362
|
+
reject(new Error("Request timeout"));
|
|
363
|
+
});
|
|
364
|
+
if (options.body) {
|
|
365
|
+
req.write(options.body);
|
|
366
|
+
}
|
|
367
|
+
req.end();
|
|
368
|
+
});
|
|
369
|
+
}
|
|
337
370
|
async function validatePartnerCredentials(keyId, secretKey, authMethod = "hmac", environment = "sandbox") {
|
|
338
371
|
try {
|
|
339
|
-
const apiUrl = environment === "sandbox" ? "https://dev-api.
|
|
372
|
+
const apiUrl = environment === "sandbox" ? "https://dev-api.liberex.sv" : "https://api.liberex.sv";
|
|
340
373
|
const testPath = "/api/v1/fees";
|
|
341
|
-
const method = "
|
|
342
|
-
const body = "";
|
|
374
|
+
const method = "POST";
|
|
375
|
+
const body = "{}";
|
|
343
376
|
let headers = {
|
|
344
377
|
"Content-Type": "application/json",
|
|
345
378
|
"X-Client-Id": keyId
|
|
@@ -351,14 +384,13 @@ async function validatePartnerCredentials(keyId, secretKey, authMethod = "hmac",
|
|
|
351
384
|
const jwt = generateJWT(keyId, secretKey);
|
|
352
385
|
headers["Authorization"] = `Bearer ${jwt}`;
|
|
353
386
|
}
|
|
354
|
-
const
|
|
355
|
-
const timeoutId = setTimeout(() => controller.abort(), 1e4);
|
|
356
|
-
const response = await fetch(`${apiUrl}${testPath}`, {
|
|
387
|
+
const response = await httpsRequest(`${apiUrl}${testPath}`, {
|
|
357
388
|
method,
|
|
358
389
|
headers,
|
|
359
|
-
|
|
390
|
+
timeout: 1e4,
|
|
391
|
+
// 10 second timeout
|
|
392
|
+
body
|
|
360
393
|
});
|
|
361
|
-
clearTimeout(timeoutId);
|
|
362
394
|
if (response.status === 200 || response.status === 403) {
|
|
363
395
|
return {
|
|
364
396
|
valid: true,
|
|
@@ -381,6 +413,22 @@ async function validatePartnerCredentials(keyId, secretKey, authMethod = "hmac",
|
|
|
381
413
|
};
|
|
382
414
|
} catch (error) {
|
|
383
415
|
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
416
|
+
if (errorMessage.includes("ENOTFOUND") || errorMessage.includes("getaddrinfo")) {
|
|
417
|
+
return {
|
|
418
|
+
valid: true,
|
|
419
|
+
message: `Warning: DNS resolution failed for ${environment} API. Check your internet connection. Proceeding anyway...`
|
|
420
|
+
};
|
|
421
|
+
} else if (errorMessage.includes("ECONNREFUSED")) {
|
|
422
|
+
return {
|
|
423
|
+
valid: true,
|
|
424
|
+
message: `Warning: Connection refused by ${environment} API server. The server may be temporarily unavailable. Proceeding anyway...`
|
|
425
|
+
};
|
|
426
|
+
} else if (errorMessage.includes("timeout") || errorMessage.includes("ETIMEDOUT")) {
|
|
427
|
+
return {
|
|
428
|
+
valid: true,
|
|
429
|
+
message: `Warning: Request to ${environment} API timed out. Proceeding anyway...`
|
|
430
|
+
};
|
|
431
|
+
}
|
|
384
432
|
return {
|
|
385
433
|
valid: true,
|
|
386
434
|
message: `Warning: Could not connect to ${environment} API (${errorMessage}). Proceeding anyway...`
|
|
@@ -407,7 +455,7 @@ function generateJWT(keyId, secretKey, expiresIn = 300) {
|
|
|
407
455
|
const now = Math.floor(Date.now() / 1e3);
|
|
408
456
|
const payload = {
|
|
409
457
|
iss: keyId,
|
|
410
|
-
aud: "api.
|
|
458
|
+
aud: "api.liberex.sv",
|
|
411
459
|
exp: now + Math.min(expiresIn, 300),
|
|
412
460
|
iat: now
|
|
413
461
|
};
|
|
@@ -1874,12 +1922,12 @@ async function uninstall(options = {}) {
|
|
|
1874
1922
|
}
|
|
1875
1923
|
|
|
1876
1924
|
// package.json
|
|
1877
|
-
var version = "1.7.
|
|
1925
|
+
var version = "1.7.9";
|
|
1878
1926
|
|
|
1879
1927
|
// src/cli/index.ts
|
|
1880
1928
|
var program = new commander.Command();
|
|
1881
1929
|
program.name("diviswap-sdk").description("Diviswap SDK CLI - Streamline your crypto rails integration").version(version);
|
|
1882
|
-
program.command("init").description("Initialize Diviswap SDK in your existing project").option("-f, --framework <type>", "Framework type (nextjs-app, nextjs-pages, react, vue3, etc.)").option("-e, --env <environment>", "Environment (production or sandbox)"
|
|
1930
|
+
program.command("init").description("Initialize Diviswap SDK in your existing project").option("-f, --framework <type>", "Framework type (nextjs-app, nextjs-pages, react, vue3, etc.)").option("-e, --env <environment>", "Environment (production or sandbox)").option("--skip-install", "Skip automatic dependency installation").option("--skip-env", "Skip environment variable setup").option("--force", "Overwrite existing files").action(init);
|
|
1883
1931
|
program.command("create-app [project-name]").alias("create").description("Create a new project with Diviswap SDK pre-configured").option("-t, --template <type>", "Project template (nextjs, react, vue)", "nextjs").option("--use-npm", "Use npm instead of detecting package manager").option("--use-yarn", "Use Yarn instead of detecting package manager").option("--use-pnpm", "Use pnpm instead of detecting package manager").option("--typescript", "Use TypeScript (default)", true).option("--javascript", "Use JavaScript instead of TypeScript").option("--eslint", "Include ESLint configuration", true).option("--tailwind", "Include Tailwind CSS", true).option("--app", "Use App Router (Next.js only)", true).option("--src-dir", "Use src directory", true).option("--import-alias <alias>", "Import alias", "@/*").action(createApp);
|
|
1884
1932
|
program.command("uninstall").alias("remove").description("Remove Diviswap SDK files and configuration from your project").option("--force", "Skip confirmation prompt").option("--keep-config", "Keep environment variables").action(uninstall);
|
|
1885
1933
|
if (!process.argv.slice(2).length) {
|
|
@@ -192,7 +192,7 @@ export function DiviswapProvider({ children }: { children: React.ReactNode }) {
|
|
|
192
192
|
useEffect(() => {
|
|
193
193
|
if (customerId && customerEmail) {
|
|
194
194
|
const socketInstance = io(
|
|
195
|
-
process.env.NEXT_PUBLIC_DIVISWAP_WS_URL || 'wss://ws.
|
|
195
|
+
process.env.NEXT_PUBLIC_DIVISWAP_WS_URL || 'wss://ws.liberex.sv',
|
|
196
196
|
{
|
|
197
197
|
auth: {
|
|
198
198
|
customerId,
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { d as Address, x as ApiResponse, A as AuthCredentials, m as AuthMode, u as AuthResponse, h as CHAIN_IDS, g as ChainName, C as ComplianceStatus, e as CreateAddressRequest, v as CreatePayeeRequest, f as DeleteAddressRequest, D as Diviswap, a as DiviswapConfig, E as Environment, k as EthereumWallet, I as IndividualData, z as KybMetadata, b as KybStatus, F as KycDocumentRequest, y as KycMetadata, G as KycPersonalInfo, c as KycSessionResponse, K as KycStatus, r as LegacyDiviswapConfig, D as LiberEx, L as LiberExConfig, w as OfframpRequest, O as OnrampRequest, B as OrganizationInfo, o as PartnerDiviswapConfig, q as PartnerLiberExConfig, P as Payee, R as RegisterRequest, S as SetDefaultAddressRequest, T as Transaction, U as User, n as UserDiviswapConfig, p as UserLiberExConfig, W as WalletConnection, i as WalletTracker, l as WalletTrackingConfig, j as connectWallet, s as setupWalletTracking, t as trackCurrentWallet } from './wallet-
|
|
1
|
+
export { d as Address, x as ApiResponse, A as AuthCredentials, m as AuthMode, u as AuthResponse, h as CHAIN_IDS, g as ChainName, C as ComplianceStatus, e as CreateAddressRequest, v as CreatePayeeRequest, f as DeleteAddressRequest, D as Diviswap, a as DiviswapConfig, E as Environment, k as EthereumWallet, I as IndividualData, z as KybMetadata, b as KybStatus, F as KycDocumentRequest, y as KycMetadata, G as KycPersonalInfo, c as KycSessionResponse, K as KycStatus, r as LegacyDiviswapConfig, D as LiberEx, L as LiberExConfig, w as OfframpRequest, O as OnrampRequest, B as OrganizationInfo, o as PartnerDiviswapConfig, q as PartnerLiberExConfig, P as Payee, R as RegisterRequest, S as SetDefaultAddressRequest, T as Transaction, U as User, n as UserDiviswapConfig, p as UserLiberExConfig, W as WalletConnection, i as WalletTracker, l as WalletTrackingConfig, j as connectWallet, s as setupWalletTracking, t as trackCurrentWallet } from './wallet-CNiPxV5L.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Custom error classes for Diviswap SDK
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { d as Address, x as ApiResponse, A as AuthCredentials, m as AuthMode, u as AuthResponse, h as CHAIN_IDS, g as ChainName, C as ComplianceStatus, e as CreateAddressRequest, v as CreatePayeeRequest, f as DeleteAddressRequest, D as Diviswap, a as DiviswapConfig, E as Environment, k as EthereumWallet, I as IndividualData, z as KybMetadata, b as KybStatus, F as KycDocumentRequest, y as KycMetadata, G as KycPersonalInfo, c as KycSessionResponse, K as KycStatus, r as LegacyDiviswapConfig, D as LiberEx, L as LiberExConfig, w as OfframpRequest, O as OnrampRequest, B as OrganizationInfo, o as PartnerDiviswapConfig, q as PartnerLiberExConfig, P as Payee, R as RegisterRequest, S as SetDefaultAddressRequest, T as Transaction, U as User, n as UserDiviswapConfig, p as UserLiberExConfig, W as WalletConnection, i as WalletTracker, l as WalletTrackingConfig, j as connectWallet, s as setupWalletTracking, t as trackCurrentWallet } from './wallet-
|
|
1
|
+
export { d as Address, x as ApiResponse, A as AuthCredentials, m as AuthMode, u as AuthResponse, h as CHAIN_IDS, g as ChainName, C as ComplianceStatus, e as CreateAddressRequest, v as CreatePayeeRequest, f as DeleteAddressRequest, D as Diviswap, a as DiviswapConfig, E as Environment, k as EthereumWallet, I as IndividualData, z as KybMetadata, b as KybStatus, F as KycDocumentRequest, y as KycMetadata, G as KycPersonalInfo, c as KycSessionResponse, K as KycStatus, r as LegacyDiviswapConfig, D as LiberEx, L as LiberExConfig, w as OfframpRequest, O as OnrampRequest, B as OrganizationInfo, o as PartnerDiviswapConfig, q as PartnerLiberExConfig, P as Payee, R as RegisterRequest, S as SetDefaultAddressRequest, T as Transaction, U as User, n as UserDiviswapConfig, p as UserLiberExConfig, W as WalletConnection, i as WalletTracker, l as WalletTrackingConfig, j as connectWallet, s as setupWalletTracking, t as trackCurrentWallet } from './wallet-CNiPxV5L.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Custom error classes for Diviswap SDK
|
package/dist/index.js
CHANGED
|
@@ -1640,7 +1640,7 @@ var PartnerAuth = class {
|
|
|
1640
1640
|
*/
|
|
1641
1641
|
generateJWT(options = {}) {
|
|
1642
1642
|
const {
|
|
1643
|
-
audience = "api.
|
|
1643
|
+
audience = "api.liberex.sv",
|
|
1644
1644
|
expiresIn = 300,
|
|
1645
1645
|
// 5 minutes max
|
|
1646
1646
|
scopes = []
|
|
@@ -1739,11 +1739,11 @@ var UnifiedApiClient = class _UnifiedApiClient {
|
|
|
1739
1739
|
static getDefaultApiUrl(environment) {
|
|
1740
1740
|
switch (environment) {
|
|
1741
1741
|
case "production":
|
|
1742
|
-
return "https://api.
|
|
1742
|
+
return "https://api.liberex.sv";
|
|
1743
1743
|
case "sandbox":
|
|
1744
|
-
return "https://dev-api.
|
|
1744
|
+
return "https://dev-api.liberex.sv";
|
|
1745
1745
|
default:
|
|
1746
|
-
return "https://dev-api.
|
|
1746
|
+
return "https://dev-api.liberex.sv";
|
|
1747
1747
|
}
|
|
1748
1748
|
}
|
|
1749
1749
|
/**
|
|
@@ -1867,7 +1867,7 @@ var UnifiedApiClient = class _UnifiedApiClient {
|
|
|
1867
1867
|
const queryString = urlParts.length > 1 ? urlParts[1] : "";
|
|
1868
1868
|
if (this.config.authMethod === "jwt") {
|
|
1869
1869
|
const jwt = this.partnerAuth.generateJWT({
|
|
1870
|
-
audience: "api.
|
|
1870
|
+
audience: "api.liberex.sv",
|
|
1871
1871
|
expiresIn: 300
|
|
1872
1872
|
});
|
|
1873
1873
|
headers["Authorization"] = `Bearer ${jwt}`;
|
|
@@ -2019,7 +2019,7 @@ var _Diviswap = class _Diviswap {
|
|
|
2019
2019
|
* const token = await diviswap.getAccessToken();
|
|
2020
2020
|
* if (token) {
|
|
2021
2021
|
* // Use token for custom API calls
|
|
2022
|
-
* fetch('https://api.
|
|
2022
|
+
* fetch('https://api.liberex.sv/custom-endpoint', {
|
|
2023
2023
|
* headers: { 'Authorization': `Bearer ${token}` }
|
|
2024
2024
|
* });
|
|
2025
2025
|
* }
|