@moonpay/platform-sdk-core 0.3.0 → 1.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/index.cjs CHANGED
@@ -75,19 +75,19 @@ function createClientContext(options = {}) {
75
75
  }
76
76
 
77
77
  // src/api/fetch-wrapper.ts
78
- var import_platform_protocol = require("@moonpay/platform-protocol");
78
+ var import_result = require("@moonpay/platform-protocol/result");
79
79
  async function apiFetch(ctx, path, options) {
80
80
  const response = await ctx.fetch(path, options);
81
81
  const data = await response.json();
82
82
  if (!response.ok) {
83
83
  const error = data;
84
- return (0, import_platform_protocol.err)({
84
+ return (0, import_result.err)({
85
85
  code: error.code ?? "unknown_error",
86
86
  message: error.message ?? "An unknown error occurred",
87
87
  errors: error.errors
88
88
  });
89
89
  }
90
- return (0, import_platform_protocol.ok)(data);
90
+ return (0, import_result.ok)(data);
91
91
  }
92
92
 
93
93
  // src/api/get-quote.ts
@@ -121,25 +121,25 @@ async function getTransaction(ctx, id) {
121
121
  }
122
122
 
123
123
  // src/api/identity.ts
124
- var import_platform_protocol2 = require("@moonpay/platform-protocol");
124
+ var import_result2 = require("@moonpay/platform-protocol/result");
125
125
  async function createIdentity(ctx, body) {
126
126
  const response = await ctx.fetch("/platform/v1/identities", {
127
127
  method: "POST",
128
128
  body: JSON.stringify(body)
129
129
  });
130
130
  if (response.status === 204) {
131
- return (0, import_platform_protocol2.ok)({ data: null });
131
+ return (0, import_result2.ok)({ data: null });
132
132
  }
133
133
  const parsed = await response.json().catch(() => ({}));
134
134
  if (!response.ok) {
135
135
  const error = parsed;
136
- return (0, import_platform_protocol2.err)({
136
+ return (0, import_result2.err)({
137
137
  code: error.code ?? "unknown_error",
138
138
  message: error.message ?? "Failed to create identity",
139
139
  errors: error.errors
140
140
  });
141
141
  }
142
- return (0, import_platform_protocol2.ok)(parsed);
142
+ return (0, import_result2.ok)(parsed);
143
143
  }
144
144
  async function getIdentity(ctx, id) {
145
145
  return apiFetch(ctx, `/platform/v1/identities/${encodeURIComponent(id)}`);
@@ -173,7 +173,7 @@ async function submitIdentityFiles(ctx, id, body) {
173
173
  }
174
174
 
175
175
  // src/api/payment-methods.ts
176
- var import_platform_protocol3 = require("@moonpay/platform-protocol");
176
+ var import_result3 = require("@moonpay/platform-protocol/result");
177
177
  async function getPaymentMethods(ctx) {
178
178
  return apiFetch(ctx, "/platform/v1/payment-methods");
179
179
  }
@@ -184,12 +184,12 @@ async function deletePaymentMethod(ctx, paymentMethodId) {
184
184
  );
185
185
  if (!response.ok) {
186
186
  const data = await response.json().catch(() => ({}));
187
- return (0, import_platform_protocol3.err)({
187
+ return (0, import_result3.err)({
188
188
  code: data.code ?? "unknown_error",
189
189
  message: data.message ?? "Failed to delete payment method"
190
190
  });
191
191
  }
192
- return (0, import_platform_protocol3.ok)(void 0);
192
+ return (0, import_result3.ok)(void 0);
193
193
  }
194
194
 
195
195
  // src/client.ts
@@ -219,7 +219,7 @@ function createClientCore(options) {
219
219
  };
220
220
  }
221
221
 
222
- // ../../node_modules/.bun/@noble+ciphers@1.2.0/node_modules/@noble/ciphers/esm/_assert.js
222
+ // ../../node_modules/@noble/ciphers/esm/_assert.js
223
223
  function isBytes(a) {
224
224
  return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
225
225
  }
@@ -243,7 +243,7 @@ function aoutput(out, instance) {
243
243
  }
244
244
  }
245
245
 
246
- // ../../node_modules/.bun/@noble+ciphers@1.2.0/node_modules/@noble/ciphers/esm/utils.js
246
+ // ../../node_modules/@noble/ciphers/esm/utils.js
247
247
  var u8 = (arr) => new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);
248
248
  var u32 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
249
249
  var createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
@@ -352,7 +352,7 @@ function clean(...arrays) {
352
352
  }
353
353
  }
354
354
 
355
- // ../../node_modules/.bun/@noble+ciphers@1.2.0/node_modules/@noble/ciphers/esm/_polyval.js
355
+ // ../../node_modules/@noble/ciphers/esm/_polyval.js
356
356
  var BLOCK_SIZE = 16;
357
357
  var ZEROS16 = /* @__PURE__ */ new Uint8Array(16);
358
358
  var ZEROS32 = u32(ZEROS16);
@@ -542,7 +542,7 @@ function wrapConstructorWithKey(hashCons) {
542
542
  var ghash = wrapConstructorWithKey((key, expectedLength) => new GHASH(key, expectedLength));
543
543
  var polyval = wrapConstructorWithKey((key, expectedLength) => new Polyval(key, expectedLength));
544
544
 
545
- // ../../node_modules/.bun/@noble+ciphers@1.2.0/node_modules/@noble/ciphers/esm/aes.js
545
+ // ../../node_modules/@noble/ciphers/esm/aes.js
546
546
  var BLOCK_SIZE2 = 16;
547
547
  var BLOCK_SIZE32 = 4;
548
548
  var EMPTY_BLOCK = /* @__PURE__ */ new Uint8Array(BLOCK_SIZE2);
@@ -758,7 +758,7 @@ var gcm = /* @__PURE__ */ wrapCipher({ blockSize: 16, nonceLength: 12, tagLength
758
758
  };
759
759
  });
760
760
 
761
- // ../../node_modules/.bun/@noble+hashes@1.7.0/node_modules/@noble/hashes/esm/_assert.js
761
+ // ../../node_modules/@noble/hashes/esm/_assert.js
762
762
  function anumber(n) {
763
763
  if (!Number.isSafeInteger(n) || n < 0)
764
764
  throw new Error("positive integer expected, got " + n);
@@ -792,10 +792,10 @@ function aoutput2(out, instance) {
792
792
  }
793
793
  }
794
794
 
795
- // ../../node_modules/.bun/@noble+hashes@1.7.0/node_modules/@noble/hashes/esm/crypto.js
795
+ // ../../node_modules/@noble/hashes/esm/crypto.js
796
796
  var crypto = typeof globalThis === "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
797
797
 
798
- // ../../node_modules/.bun/@noble+hashes@1.7.0/node_modules/@noble/hashes/esm/utils.js
798
+ // ../../node_modules/@noble/hashes/esm/utils.js
799
799
  var createView2 = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
800
800
  var rotr = (word, shift) => word << 32 - shift | word >>> shift;
801
801
  function utf8ToBytes2(str) {
@@ -833,7 +833,7 @@ function randomBytes(bytesLength = 32) {
833
833
  throw new Error("crypto.getRandomValues must be defined");
834
834
  }
835
835
 
836
- // ../../node_modules/.bun/@noble+hashes@1.7.0/node_modules/@noble/hashes/esm/_md.js
836
+ // ../../node_modules/@noble/hashes/esm/_md.js
837
837
  function setBigUint642(view, byteOffset, value, isLE2) {
838
838
  if (typeof view.setBigUint64 === "function")
839
839
  return view.setBigUint64(byteOffset, value, isLE2);
@@ -935,7 +935,7 @@ var HashMD = class extends Hash {
935
935
  }
936
936
  };
937
937
 
938
- // ../../node_modules/.bun/@noble+curves@1.8.0/node_modules/@noble/curves/esm/abstract/utils.js
938
+ // ../../node_modules/@noble/curves/esm/abstract/utils.js
939
939
  var _0n = /* @__PURE__ */ BigInt(0);
940
940
  function isBytes3(a) {
941
941
  return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
@@ -1053,7 +1053,7 @@ function validateObject(object, validators, optValidators = {}) {
1053
1053
  return object;
1054
1054
  }
1055
1055
 
1056
- // ../../node_modules/.bun/@noble+curves@1.8.0/node_modules/@noble/curves/esm/abstract/modular.js
1056
+ // ../../node_modules/@noble/curves/esm/abstract/modular.js
1057
1057
  var _0n2 = BigInt(0);
1058
1058
  var _1n = BigInt(1);
1059
1059
  function mod(a, b) {
@@ -1085,7 +1085,7 @@ function pow2(x, power, modulo) {
1085
1085
  return res;
1086
1086
  }
1087
1087
 
1088
- // ../../node_modules/.bun/@noble+curves@1.8.0/node_modules/@noble/curves/esm/abstract/montgomery.js
1088
+ // ../../node_modules/@noble/curves/esm/abstract/montgomery.js
1089
1089
  var _0n3 = BigInt(0);
1090
1090
  var _1n2 = BigInt(1);
1091
1091
  function validateOpts(curve) {
@@ -1203,7 +1203,7 @@ function montgomery(curveDef) {
1203
1203
  };
1204
1204
  }
1205
1205
 
1206
- // ../../node_modules/.bun/@noble+curves@1.8.0/node_modules/@noble/curves/esm/ed25519.js
1206
+ // ../../node_modules/@noble/curves/esm/ed25519.js
1207
1207
  var ED25519_P = BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");
1208
1208
  var _0n4 = BigInt(0);
1209
1209
  var _1n3 = BigInt(1);
@@ -1250,7 +1250,7 @@ var x25519 = /* @__PURE__ */ (() => montgomery({
1250
1250
  randomBytes
1251
1251
  }))();
1252
1252
 
1253
- // ../../node_modules/.bun/@noble+hashes@1.7.0/node_modules/@noble/hashes/esm/hmac.js
1253
+ // ../../node_modules/@noble/hashes/esm/hmac.js
1254
1254
  var HMAC = class extends Hash {
1255
1255
  constructor(hash, _key) {
1256
1256
  super();
@@ -1315,7 +1315,7 @@ var HMAC = class extends Hash {
1315
1315
  var hmac = (hash, key, message) => new HMAC(hash, key).update(message).digest();
1316
1316
  hmac.create = (hash, key) => new HMAC(hash, key);
1317
1317
 
1318
- // ../../node_modules/.bun/@noble+hashes@1.7.0/node_modules/@noble/hashes/esm/hkdf.js
1318
+ // ../../node_modules/@noble/hashes/esm/hkdf.js
1319
1319
  function extract(hash, ikm, salt) {
1320
1320
  ahash(hash);
1321
1321
  if (salt === void 0)
@@ -1350,7 +1350,7 @@ function expand(hash, prk, info, length = 32) {
1350
1350
  }
1351
1351
  var hkdf = (hash, ikm, salt, info, length) => expand(hash, extract(hash, ikm, salt), info, length);
1352
1352
 
1353
- // ../../node_modules/.bun/@noble+hashes@1.7.0/node_modules/@noble/hashes/esm/sha256.js
1353
+ // ../../node_modules/@noble/hashes/esm/sha256.js
1354
1354
  var SHA256_K = /* @__PURE__ */ new Uint32Array([
1355
1355
  1116352408,
1356
1356
  1899447441,
@@ -1534,7 +1534,7 @@ function generateKeyPair() {
1534
1534
  }
1535
1535
 
1536
1536
  // src/frames/frame-orchestrator.ts
1537
- var import_platform_protocol4 = require("@moonpay/platform-protocol");
1537
+ var import_protocol = require("@moonpay/platform-protocol/protocol");
1538
1538
  function createFrameOrchestrator(options) {
1539
1539
  const { transport, channelId, url, container, hidden, handshakeTimeout = 15e3 } = options;
1540
1540
  return new Promise((resolve, reject) => {
@@ -1549,13 +1549,13 @@ function createFrameOrchestrator(options) {
1549
1549
  const unsubHandshake = transport.onMessage((msg) => {
1550
1550
  if (msg.meta?.channelId !== channelId)
1551
1551
  return;
1552
- if (!handshakeComplete && msg.kind === import_platform_protocol4.HANDSHAKE_REQUEST_KIND) {
1552
+ if (!handshakeComplete && msg.kind === import_protocol.HANDSHAKE_REQUEST_KIND) {
1553
1553
  handshakeComplete = true;
1554
1554
  clearTimeout(timer);
1555
1555
  transport.sendMessage({
1556
1556
  version: 2,
1557
1557
  meta: { channelId },
1558
- kind: import_platform_protocol4.HANDSHAKE_ACK_KIND
1558
+ kind: import_protocol.HANDSHAKE_ACK_KIND
1559
1559
  });
1560
1560
  resolve(handle);
1561
1561
  return;