@diviswap/sdk 1.9.0 → 2.0.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/dist/cli/index.js CHANGED
@@ -886,34 +886,82 @@ Validating partner credentials with ${environment} API...`
886
886
  features,
887
887
  projectRoot: process.cwd()
888
888
  });
889
- if (!options.skipEnv && keyId && secretKey) {
890
- const envFile = framework.includes("nextjs") ? ".env.local" : ".env";
891
- const envPath = path.join(process.cwd(), envFile);
892
- let envContent = "";
893
- if (fs.existsSync(envPath)) {
894
- envContent = fs.readFileSync(envPath, "utf-8");
889
+ if (!options.skipEnv) {
890
+ const envExampleFile = ".env.example";
891
+ const envExamplePath = path.join(process.cwd(), envExampleFile);
892
+ const gitignorePath = path.join(process.cwd(), ".gitignore");
893
+ const envExampleContent = `# Diviswap SDK Configuration (Partner Authentication)
894
+ # IMPORTANT: These are EXAMPLE values only. Replace with your actual credentials.
895
+ # NEVER commit your actual .env or .env.local files to version control!
896
+
897
+ # Partner Key ID (starts with pk_)
898
+ DIVISWAP_PARTNER_KEY_ID=pk_your_key_id_here
899
+
900
+ # Partner Secret Key (starts with sk_)
901
+ # WARNING: Keep this secret! Never share or commit to git.
902
+ # Store securely using environment variables or a secrets manager.
903
+ DIVISWAP_PARTNER_SECRET_KEY=sk_your_secret_key_here
904
+
905
+ # Environment: 'production' or 'sandbox'
906
+ NEXT_PUBLIC_DIVISWAP_ENV=${environment}
907
+ `;
908
+ if (!fs.existsSync(envExamplePath)) {
909
+ fs.appendFileSync(envExamplePath, envExampleContent);
910
+ console.log(
911
+ kleur__default.default.green(`\u2705 Created ${envExampleFile} template`)
912
+ );
895
913
  }
896
- const envVars = [
897
- `DIVISWAP_PARTNER_KEY_ID=${keyId}`,
898
- `DIVISWAP_PARTNER_SECRET_KEY=${secretKey}`,
899
- `NEXT_PUBLIC_DIVISWAP_ENV=${environment}`
900
- ];
901
- const newEnvVars = envVars.filter((envVar) => {
902
- const key = envVar.split("=")[0];
903
- return !envContent.includes(key);
904
- });
905
- if (newEnvVars.length > 0) {
906
- const separator = envContent && !envContent.endsWith("\n") ? "\n" : "";
914
+ let gitignoreContent = "";
915
+ if (fs.existsSync(gitignorePath)) {
916
+ gitignoreContent = fs.readFileSync(gitignorePath, "utf-8");
917
+ }
918
+ const gitignoreEntries = [".env", ".env.local", ".env.*.local"];
919
+ const missingEntries = gitignoreEntries.filter(
920
+ (entry) => !gitignoreContent.includes(entry)
921
+ );
922
+ if (missingEntries.length > 0) {
923
+ const separator = gitignoreContent && !gitignoreContent.endsWith("\n") ? "\n" : "";
907
924
  fs.appendFileSync(
908
- envPath,
909
- separator + "# Diviswap SDK Configuration (Partner Authentication)\n" + newEnvVars.join("\n") + "\n"
925
+ gitignorePath,
926
+ separator + "# Environment variables (secrets)\n" + missingEntries.join("\n") + "\n"
910
927
  );
911
928
  console.log(
912
929
  kleur__default.default.green(
913
- `\u2705 Updated ${envFile} with partner authentication credentials`
930
+ `\u2705 Updated .gitignore to protect environment files`
914
931
  )
915
932
  );
916
933
  }
934
+ console.log(
935
+ kleur__default.default.yellow(
936
+ "\n\u26A0\uFE0F IMPORTANT SECURITY NOTICE:\n"
937
+ )
938
+ );
939
+ console.log(
940
+ " Your partner credentials were validated but NOT written to files."
941
+ );
942
+ console.log(
943
+ " For security, you must manually add them to your environment:\n"
944
+ );
945
+ console.log(
946
+ kleur__default.default.cyan(
947
+ ` 1. Create a ${framework.includes("nextjs") ? ".env.local" : ".env"} file (already in .gitignore)`
948
+ )
949
+ );
950
+ console.log(
951
+ kleur__default.default.cyan(
952
+ ` 2. Add your credentials (use .env.example as a template)`
953
+ )
954
+ );
955
+ console.log(
956
+ kleur__default.default.cyan(
957
+ " 3. NEVER commit this file to version control"
958
+ )
959
+ );
960
+ console.log(
961
+ kleur__default.default.cyan(
962
+ " 4. In production, use environment variables or a secrets manager\n"
963
+ )
964
+ );
917
965
  }
918
966
  if (framework.includes("nextjs")) {
919
967
  console.log("\nUpdating Next.js configuration...");
@@ -2185,7 +2233,7 @@ async function uninstall(options = {}) {
2185
2233
  }
2186
2234
 
2187
2235
  // package.json
2188
- var version = "1.9.0";
2236
+ var version = "2.0.0";
2189
2237
 
2190
2238
  // src/cli/index.ts
2191
2239
  var program = new commander.Command();
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-Cohx6L51.mjs';
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-DO1Nbsfk.mjs';
2
2
 
3
3
  /**
4
4
  * Custom error classes for Diviswap SDK
@@ -25,36 +25,18 @@ declare class ConfigurationError extends DiviswapError {
25
25
  declare const LiberExError: typeof DiviswapError;
26
26
 
27
27
  /**
28
- * Web3 utilities for handling transaction results
28
+ * Wallet transaction result types (supports various wallet libraries)
29
29
  */
30
- /**
31
- * Type representing the various formats that sendTransaction can return
32
- * - Direct hash string: '0x...'
33
- * - Object with hash property: {hash: '0x...'}
34
- * - Template literal type from viem: `0x${string}`
35
- */
36
- type SendTransactionResult = string | {
30
+ type SendTransactionResult = {
37
31
  hash: string;
38
- } | `0x${string}`;
32
+ } | {
33
+ transactionHash: string;
34
+ } | string;
39
35
  /**
40
- * Safely extract transaction hash from various sendTransaction result formats
41
- *
42
- * Different Web3 libraries and wallet connectors return transaction hashes in different formats:
43
- * - wagmi's sendTransactionAsync: typically returns the hash directly as a string
44
- * - Some wallets: return an object with a hash property
45
- * - viem: uses template literal types `0x${string}`
46
- *
47
- * This utility handles all these cases and extracts the hash string reliably.
48
- *
49
- * @param result - The result from sendTransaction/sendTransactionAsync
50
- * @returns The transaction hash as a string
51
- *
52
- * @example
53
- * ```typescript
54
- * const result = await sendTransactionAsync({...});
55
- * const hash = extractTransactionHash(result);
56
- * // hash is now guaranteed to be a string like '0x...'
57
- * ```
36
+ * Extract transaction hash from various wallet return types
37
+ * Handles different wallet libraries (wagmi, ethers, web3.js, etc.)
38
+ * @param result Transaction result from wallet
39
+ * @returns Transaction hash
58
40
  */
59
41
  declare function extractTransactionHash(result: SendTransactionResult): string;
60
42
 
@@ -70,11 +52,10 @@ interface DepositAddresses {
70
52
  }
71
53
  declare const PRODUCTION_DEPOSIT_ADDRESSES: DepositAddresses;
72
54
  declare const SANDBOX_DEPOSIT_ADDRESSES: DepositAddresses;
73
- declare const DEVELOPMENT_DEPOSIT_ADDRESSES: DepositAddresses;
74
55
  /**
75
56
  * Get deposit addresses for the current environment
76
57
  */
77
- declare function getDepositAddresses(environment: 'production' | 'sandbox' | 'development'): DepositAddresses;
58
+ declare function getDepositAddresses(environment: 'production' | 'sandbox'): DepositAddresses;
78
59
  /**
79
60
  * Chain ID to chain name mapping
80
61
  */
@@ -88,4 +69,4 @@ declare const CHAIN_NAME_TO_ID: Record<string, number>;
88
69
  */
89
70
  declare const STABLECOIN_ADDRESSES: Record<string, Record<string, string>>;
90
71
 
91
- export { AuthenticationError, CHAIN_ID_TO_NAME, CHAIN_NAME_TO_ID, ConfigurationError, DEVELOPMENT_DEPOSIT_ADDRESSES, DiviswapError, LiberExError, NetworkError, PRODUCTION_DEPOSIT_ADDRESSES, SANDBOX_DEPOSIT_ADDRESSES, STABLECOIN_ADDRESSES, type SendTransactionResult, ValidationError, extractTransactionHash, getDepositAddresses };
72
+ export { AuthenticationError, CHAIN_ID_TO_NAME, CHAIN_NAME_TO_ID, ConfigurationError, DiviswapError, LiberExError, NetworkError, PRODUCTION_DEPOSIT_ADDRESSES, SANDBOX_DEPOSIT_ADDRESSES, STABLECOIN_ADDRESSES, type SendTransactionResult, ValidationError, extractTransactionHash, getDepositAddresses };
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-Cohx6L51.js';
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-DO1Nbsfk.js';
2
2
 
3
3
  /**
4
4
  * Custom error classes for Diviswap SDK
@@ -25,36 +25,18 @@ declare class ConfigurationError extends DiviswapError {
25
25
  declare const LiberExError: typeof DiviswapError;
26
26
 
27
27
  /**
28
- * Web3 utilities for handling transaction results
28
+ * Wallet transaction result types (supports various wallet libraries)
29
29
  */
30
- /**
31
- * Type representing the various formats that sendTransaction can return
32
- * - Direct hash string: '0x...'
33
- * - Object with hash property: {hash: '0x...'}
34
- * - Template literal type from viem: `0x${string}`
35
- */
36
- type SendTransactionResult = string | {
30
+ type SendTransactionResult = {
37
31
  hash: string;
38
- } | `0x${string}`;
32
+ } | {
33
+ transactionHash: string;
34
+ } | string;
39
35
  /**
40
- * Safely extract transaction hash from various sendTransaction result formats
41
- *
42
- * Different Web3 libraries and wallet connectors return transaction hashes in different formats:
43
- * - wagmi's sendTransactionAsync: typically returns the hash directly as a string
44
- * - Some wallets: return an object with a hash property
45
- * - viem: uses template literal types `0x${string}`
46
- *
47
- * This utility handles all these cases and extracts the hash string reliably.
48
- *
49
- * @param result - The result from sendTransaction/sendTransactionAsync
50
- * @returns The transaction hash as a string
51
- *
52
- * @example
53
- * ```typescript
54
- * const result = await sendTransactionAsync({...});
55
- * const hash = extractTransactionHash(result);
56
- * // hash is now guaranteed to be a string like '0x...'
57
- * ```
36
+ * Extract transaction hash from various wallet return types
37
+ * Handles different wallet libraries (wagmi, ethers, web3.js, etc.)
38
+ * @param result Transaction result from wallet
39
+ * @returns Transaction hash
58
40
  */
59
41
  declare function extractTransactionHash(result: SendTransactionResult): string;
60
42
 
@@ -70,11 +52,10 @@ interface DepositAddresses {
70
52
  }
71
53
  declare const PRODUCTION_DEPOSIT_ADDRESSES: DepositAddresses;
72
54
  declare const SANDBOX_DEPOSIT_ADDRESSES: DepositAddresses;
73
- declare const DEVELOPMENT_DEPOSIT_ADDRESSES: DepositAddresses;
74
55
  /**
75
56
  * Get deposit addresses for the current environment
76
57
  */
77
- declare function getDepositAddresses(environment: 'production' | 'sandbox' | 'development'): DepositAddresses;
58
+ declare function getDepositAddresses(environment: 'production' | 'sandbox'): DepositAddresses;
78
59
  /**
79
60
  * Chain ID to chain name mapping
80
61
  */
@@ -88,4 +69,4 @@ declare const CHAIN_NAME_TO_ID: Record<string, number>;
88
69
  */
89
70
  declare const STABLECOIN_ADDRESSES: Record<string, Record<string, string>>;
90
71
 
91
- export { AuthenticationError, CHAIN_ID_TO_NAME, CHAIN_NAME_TO_ID, ConfigurationError, DEVELOPMENT_DEPOSIT_ADDRESSES, DiviswapError, LiberExError, NetworkError, PRODUCTION_DEPOSIT_ADDRESSES, SANDBOX_DEPOSIT_ADDRESSES, STABLECOIN_ADDRESSES, type SendTransactionResult, ValidationError, extractTransactionHash, getDepositAddresses };
72
+ export { AuthenticationError, CHAIN_ID_TO_NAME, CHAIN_NAME_TO_ID, ConfigurationError, DiviswapError, LiberExError, NetworkError, PRODUCTION_DEPOSIT_ADDRESSES, SANDBOX_DEPOSIT_ADDRESSES, STABLECOIN_ADDRESSES, type SendTransactionResult, ValidationError, extractTransactionHash, getDepositAddresses };