@moonpay/platform-sdk-core 0.2.2 → 0.3.0-next.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
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__getProtoOf(mod2)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod2 || !mod2.__esModule ? __defProp(target, "default", { value: mod2, enumerable: true }) : target,
26
+ mod2
27
+ ));
18
28
  var __toCommonJS = (mod2) => __copyProps(__defProp({}, "__esModule", { value: true }), mod2);
19
29
 
20
30
  // src/index.ts
@@ -26,13 +36,19 @@ __export(src_exports, {
26
36
  createClientContext: () => createClientContext,
27
37
  createClientCore: () => createClientCore,
28
38
  createFrameOrchestrator: () => createFrameOrchestrator,
39
+ createIdentity: () => createIdentity,
29
40
  decryptCredentials: () => decryptCredentials,
30
41
  deletePaymentMethod: () => deletePaymentMethod,
31
42
  generateKeyPair: () => generateKeyPair,
43
+ getIdentity: () => getIdentity,
44
+ getIdentityUploadUrl: () => getIdentityUploadUrl,
32
45
  getPaymentMethods: () => getPaymentMethods,
33
46
  getQuote: () => getQuote,
34
47
  getTransaction: () => getTransaction,
35
- listTransactions: () => listTransactions
48
+ listTransactions: () => listTransactions,
49
+ submitIdentityFiles: () => submitIdentityFiles,
50
+ updateIdentity: () => updateIdentity,
51
+ verifyIdentity: () => verifyIdentity
36
52
  });
37
53
  module.exports = __toCommonJS(src_exports);
38
54
 
@@ -114,8 +130,60 @@ async function getTransaction(ctx, id) {
114
130
  );
115
131
  }
116
132
 
117
- // src/api/payment-methods.ts
133
+ // src/api/identity.ts
118
134
  var import_platform_protocol2 = require("@moonpay/platform-protocol");
135
+ async function createIdentity(ctx, body) {
136
+ const response = await ctx.fetch("/platform/v1/identities", {
137
+ method: "POST",
138
+ body: JSON.stringify(body)
139
+ });
140
+ if (response.status === 204) {
141
+ return (0, import_platform_protocol2.ok)({ data: null });
142
+ }
143
+ const parsed = await response.json().catch(() => ({}));
144
+ if (!response.ok) {
145
+ const error = parsed;
146
+ return (0, import_platform_protocol2.err)({
147
+ code: error.code ?? "unknown_error",
148
+ message: error.message ?? "Failed to create identity",
149
+ errors: error.errors
150
+ });
151
+ }
152
+ return (0, import_platform_protocol2.ok)(parsed);
153
+ }
154
+ async function getIdentity(ctx, id) {
155
+ return apiFetch(ctx, `/platform/v1/identities/${encodeURIComponent(id)}`);
156
+ }
157
+ async function updateIdentity(ctx, id, body) {
158
+ return apiFetch(ctx, `/platform/v1/identities/${encodeURIComponent(id)}`, {
159
+ method: "PATCH",
160
+ body: JSON.stringify(body)
161
+ });
162
+ }
163
+ async function verifyIdentity(ctx, id) {
164
+ return apiFetch(
165
+ ctx,
166
+ `/platform/v1/identities/${encodeURIComponent(id)}/verifications`,
167
+ { method: "POST" }
168
+ );
169
+ }
170
+ async function getIdentityUploadUrl(ctx, id, body) {
171
+ return apiFetch(
172
+ ctx,
173
+ `/platform/v1/identities/${encodeURIComponent(id)}/files/upload-url`,
174
+ { method: "POST", body: JSON.stringify(body) }
175
+ );
176
+ }
177
+ async function submitIdentityFiles(ctx, id, body) {
178
+ return apiFetch(
179
+ ctx,
180
+ `/platform/v1/identities/${encodeURIComponent(id)}/files`,
181
+ { method: "POST", body: JSON.stringify(body) }
182
+ );
183
+ }
184
+
185
+ // src/api/payment-methods.ts
186
+ var import_platform_protocol3 = require("@moonpay/platform-protocol");
119
187
  async function getPaymentMethods(ctx) {
120
188
  return apiFetch(ctx, "/platform/v1/payment-methods");
121
189
  }
@@ -126,12 +194,12 @@ async function deletePaymentMethod(ctx, paymentMethodId) {
126
194
  );
127
195
  if (!response.ok) {
128
196
  const data = await response.json().catch(() => ({}));
129
- return (0, import_platform_protocol2.err)({
197
+ return (0, import_platform_protocol3.err)({
130
198
  code: data.code ?? "unknown_error",
131
199
  message: data.message ?? "Failed to delete payment method"
132
200
  });
133
201
  }
134
- return (0, import_platform_protocol2.ok)(void 0);
202
+ return (0, import_platform_protocol3.ok)(void 0);
135
203
  }
136
204
 
137
205
  // src/client.ts
@@ -151,7 +219,13 @@ function createClientCore(options) {
151
219
  getPaymentMethods: () => getPaymentMethods(ctx),
152
220
  listTransactions: (params) => listTransactions(ctx, params),
153
221
  getTransaction: (id) => getTransaction(ctx, id),
154
- deletePaymentMethod: (id) => deletePaymentMethod(ctx, id)
222
+ deletePaymentMethod: (id) => deletePaymentMethod(ctx, id),
223
+ createIdentity: (body) => createIdentity(ctx, body),
224
+ getIdentity: (id) => getIdentity(ctx, id),
225
+ updateIdentity: (id, body) => updateIdentity(ctx, id, body),
226
+ verifyIdentity: (id) => verifyIdentity(ctx, id),
227
+ getIdentityUploadUrl: (id, body) => getIdentityUploadUrl(ctx, id, body),
228
+ submitIdentityFiles: (id, body) => submitIdentityFiles(ctx, id, body)
155
229
  };
156
230
  }
157
231
 
@@ -728,8 +802,9 @@ function aoutput2(out, instance) {
728
802
  }
729
803
  }
730
804
 
731
- // ../../node_modules/.bun/@noble+hashes@1.7.0/node_modules/@noble/hashes/esm/crypto.js
732
- var crypto = typeof globalThis === "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
805
+ // ../../node_modules/.bun/@noble+hashes@1.7.0/node_modules/@noble/hashes/esm/cryptoNode.js
806
+ var nc = __toESM(require("crypto"), 1);
807
+ var crypto = nc && typeof nc === "object" && "webcrypto" in nc ? nc.webcrypto : nc && typeof nc === "object" && "randomBytes" in nc ? nc : void 0;
733
808
 
734
809
  // ../../node_modules/.bun/@noble+hashes@1.7.0/node_modules/@noble/hashes/esm/utils.js
735
810
  var createView2 = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
@@ -1470,7 +1545,7 @@ function generateKeyPair() {
1470
1545
  }
1471
1546
 
1472
1547
  // src/frames/frame-orchestrator.ts
1473
- var import_platform_protocol3 = require("@moonpay/platform-protocol");
1548
+ var import_platform_protocol4 = require("@moonpay/platform-protocol");
1474
1549
  function createFrameOrchestrator(options) {
1475
1550
  const { transport, channelId, url, container, hidden, handshakeTimeout = 15e3 } = options;
1476
1551
  return new Promise((resolve, reject) => {
@@ -1485,13 +1560,13 @@ function createFrameOrchestrator(options) {
1485
1560
  const unsubHandshake = transport.onMessage((msg) => {
1486
1561
  if (msg.meta?.channelId !== channelId)
1487
1562
  return;
1488
- if (!handshakeComplete && msg.kind === import_platform_protocol3.HANDSHAKE_REQUEST_KIND) {
1563
+ if (!handshakeComplete && msg.kind === import_platform_protocol4.HANDSHAKE_REQUEST_KIND) {
1489
1564
  handshakeComplete = true;
1490
1565
  clearTimeout(timer);
1491
1566
  transport.sendMessage({
1492
1567
  version: 2,
1493
1568
  meta: { channelId },
1494
- kind: import_platform_protocol3.HANDSHAKE_ACK_KIND
1569
+ kind: import_platform_protocol4.HANDSHAKE_ACK_KIND
1495
1570
  });
1496
1571
  resolve(handle);
1497
1572
  return;
@@ -1561,6 +1636,28 @@ function buildFrameUrl(path, query = {}, options = {}) {
1561
1636
  }
1562
1637
  return url.href;
1563
1638
  }
1639
+ // Annotate the CommonJS export names for ESM import in node:
1640
+ 0 && (module.exports = {
1641
+ FRAME_PATHS,
1642
+ apiFetch,
1643
+ buildFrameUrl,
1644
+ createClientContext,
1645
+ createClientCore,
1646
+ createFrameOrchestrator,
1647
+ createIdentity,
1648
+ decryptCredentials,
1649
+ deletePaymentMethod,
1650
+ generateKeyPair,
1651
+ getIdentity,
1652
+ getIdentityUploadUrl,
1653
+ getPaymentMethods,
1654
+ getQuote,
1655
+ getTransaction,
1656
+ listTransactions,
1657
+ submitIdentityFiles,
1658
+ updateIdentity,
1659
+ verifyIdentity
1660
+ });
1564
1661
  /*! Bundled license information:
1565
1662
 
1566
1663
  @noble/ciphers/esm/utils.js: