@dcentralab/d402-client 0.1.0 → 0.1.1

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/index.mjs CHANGED
@@ -325,7 +325,9 @@ function normalizeAddress(address) {
325
325
  }
326
326
  function decodePaymentResponse(header) {
327
327
  try {
328
- const decoded = Buffer.from(header, "base64").toString("utf-8");
328
+ const binString = atob(header);
329
+ const bytes = Uint8Array.from(binString, (m) => m.codePointAt(0));
330
+ const decoded = new TextDecoder().decode(bytes);
329
331
  return JSON.parse(decoded);
330
332
  } catch (error) {
331
333
  throw new Error(`Failed to decode payment response: ${error}`);
@@ -425,11 +427,14 @@ __export(encoder_exports, {
425
427
  safeBase64Encode: () => safeBase64Encode
426
428
  });
427
429
  function safeBase64Encode(data) {
428
- const buffer = typeof data === "string" ? Buffer.from(data, "utf-8") : data;
429
- return buffer.toString("base64");
430
+ const bytes = new TextEncoder().encode(data);
431
+ const binString = Array.from(bytes, (byte) => String.fromCodePoint(byte)).join("");
432
+ return btoa(binString);
430
433
  }
431
434
  function safeBase64Decode(data) {
432
- return Buffer.from(data, "base64").toString("utf-8");
435
+ const binString = atob(data);
436
+ const bytes = Uint8Array.from(binString, (m) => m.codePointAt(0));
437
+ return new TextDecoder().decode(bytes);
433
438
  }
434
439
  function encodePayment(payment) {
435
440
  const jsonString = JSON.stringify(payment);