dhali-js 3.0.3 → 3.0.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dhali-js",
3
- "version": "3.0.3",
3
+ "version": "3.0.4",
4
4
  "description": "A JavaScript library for managing XRPL payment channels and generating auth tokens for Dhali APIs",
5
5
  "main": "src/index.js",
6
6
  "type": "commonjs",
@@ -49,7 +49,7 @@ class DhaliEthChannelManager {
49
49
 
50
50
  if (!this.destinationAddress) {
51
51
  try {
52
- this.destinationAddress = this.public_config.DHALI_PUBLIC_ADDRESSES[this.currency.network][this.currency.code].wallet_id.toLowerCase();
52
+ this.destinationAddress = this.public_config.DHALI_PUBLIC_ADDRESSES[this.currency.network][this.currency.code].wallet_id;
53
53
  } catch (e) {
54
54
  throw new Error("Destination address not found in public_config for this protocol/currency: " + e.message);
55
55
  }
@@ -332,7 +332,7 @@ class DhaliEthChannelManager {
332
332
  scale: this.currency.scale,
333
333
  issuer: this.currency.tokenAddress || null
334
334
  },
335
- destination_account: this.destinationAddress.toLowerCase(),
335
+ destination_account: this.destinationAddress,
336
336
  authorized_to_claim: allowed,
337
337
  channel_id: channelId,
338
338
  signature: signature
@@ -294,4 +294,32 @@ describe("DhaliEthChannelManager", () => {
294
294
  mockHttp
295
295
  );
296
296
  });
297
+
298
+ test("getAuthToken preserves destination_account casing", async () => {
299
+ const mixedCaseDestination = "0x71C7656EC7ab88b098defB751B7401B5f6d8976F";
300
+ const mixedCaseConfig = {
301
+ DHALI_PUBLIC_ADDRESSES: {
302
+ ETHEREUM: {
303
+ ETH: { wallet_id: mixedCaseDestination }
304
+ }
305
+ },
306
+ CONTRACTS: {
307
+ ETHEREUM: { contract_address: "0x0000000000000000000000000000000000000003" }
308
+ }
309
+ };
310
+
311
+ const localManager = new DhaliEthChannelManager(mockWalletClient, mockPublicClient, currency, null, mixedCaseConfig);
312
+
313
+ // Mock required dependencies for getAuthToken
314
+ configUtils.retrieveChannelIdFromFirestoreRest.mockResolvedValue("0xChannelId");
315
+ const amountHex = BigInt(1000).toString(16).padStart(64, '0');
316
+ mockPublicClient.call = jest.fn().mockResolvedValue({ data: "0x" + "0".repeat(64 * 4) + amountHex });
317
+ mockWalletClient.signTypedData.mockResolvedValue("0xSignature");
318
+
319
+ const token = await localManager.getAuthToken(100);
320
+ const decoded = JSON.parse(Buffer.from(token, "base64").toString("utf8"));
321
+
322
+ expect(decoded.destination_account).toBe(mixedCaseDestination);
323
+ expect(decoded.destination_account).not.toBe(mixedCaseDestination.toLowerCase());
324
+ });
297
325
  });