@profullstack/coinpay 0.4.5 → 0.4.6

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/wallet.js +7 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@profullstack/coinpay",
3
- "version": "0.4.5",
3
+ "version": "0.4.6",
4
4
  "description": "CoinPay SDK & CLI — Accept cryptocurrency payments (BTC, ETH, SOL, POL, BCH, USDC) with wallet and swap support",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
package/src/wallet.js CHANGED
@@ -523,7 +523,7 @@ export class WalletClient {
523
523
  }),
524
524
  });
525
525
 
526
- client.#walletId = result.wallet_id;
526
+ client.#walletId = result.data?.wallet_id || result.wallet_id;
527
527
 
528
528
  return client;
529
529
  }
@@ -582,7 +582,7 @@ export class WalletClient {
582
582
  }),
583
583
  });
584
584
 
585
- client.#walletId = result.wallet_id;
585
+ client.#walletId = result.data?.wallet_id || result.wallet_id;
586
586
 
587
587
  return client;
588
588
  }
@@ -644,10 +644,12 @@ export class WalletClient {
644
644
  }
645
645
 
646
646
  // Get challenge
647
- const { challenge } = await this.#request(`/web-wallet/auth/challenge`, {
647
+ const challengeRes = await this.#request(`/web-wallet/auth/challenge`, {
648
648
  method: 'POST',
649
649
  body: JSON.stringify({ wallet_id: this.#walletId }),
650
650
  });
651
+ const challenge = challengeRes.data?.challenge || challengeRes.challenge;
652
+ const challengeId = challengeRes.data?.challenge_id || challengeRes.challenge_id;
651
653
 
652
654
  // Sign challenge
653
655
  const { privateKey } = deriveKeyPair(this.#seed, 'ETH', 0);
@@ -658,12 +660,12 @@ export class WalletClient {
658
660
  method: 'POST',
659
661
  body: JSON.stringify({
660
662
  wallet_id: this.#walletId,
661
- challenge_id: result.challenge_id,
663
+ challenge_id: challengeId,
662
664
  signature,
663
665
  }),
664
666
  });
665
667
 
666
- this.#authToken = result.auth_token;
668
+ this.#authToken = result.data?.auth_token || result.auth_token;
667
669
  }
668
670
 
669
671
  /**