@moonpay/platform-sdk-core 0.2.2 → 0.3.0-next.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.cjs +73 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +44 -2
- package/dist/index.d.ts +44 -2
- package/dist/index.js +73 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -26,13 +26,19 @@ __export(src_exports, {
|
|
|
26
26
|
createClientContext: () => createClientContext,
|
|
27
27
|
createClientCore: () => createClientCore,
|
|
28
28
|
createFrameOrchestrator: () => createFrameOrchestrator,
|
|
29
|
+
createIdentity: () => createIdentity,
|
|
29
30
|
decryptCredentials: () => decryptCredentials,
|
|
30
31
|
deletePaymentMethod: () => deletePaymentMethod,
|
|
31
32
|
generateKeyPair: () => generateKeyPair,
|
|
33
|
+
getIdentity: () => getIdentity,
|
|
34
|
+
getIdentityUploadUrl: () => getIdentityUploadUrl,
|
|
32
35
|
getPaymentMethods: () => getPaymentMethods,
|
|
33
36
|
getQuote: () => getQuote,
|
|
34
37
|
getTransaction: () => getTransaction,
|
|
35
|
-
listTransactions: () => listTransactions
|
|
38
|
+
listTransactions: () => listTransactions,
|
|
39
|
+
submitIdentityFiles: () => submitIdentityFiles,
|
|
40
|
+
updateIdentity: () => updateIdentity,
|
|
41
|
+
verifyIdentity: () => verifyIdentity
|
|
36
42
|
});
|
|
37
43
|
module.exports = __toCommonJS(src_exports);
|
|
38
44
|
|
|
@@ -114,8 +120,60 @@ async function getTransaction(ctx, id) {
|
|
|
114
120
|
);
|
|
115
121
|
}
|
|
116
122
|
|
|
117
|
-
// src/api/
|
|
123
|
+
// src/api/identity.ts
|
|
118
124
|
var import_platform_protocol2 = require("@moonpay/platform-protocol");
|
|
125
|
+
async function createIdentity(ctx, body) {
|
|
126
|
+
const response = await ctx.fetch("/platform/v1/identities", {
|
|
127
|
+
method: "POST",
|
|
128
|
+
body: JSON.stringify(body)
|
|
129
|
+
});
|
|
130
|
+
if (response.status === 204) {
|
|
131
|
+
return (0, import_platform_protocol2.ok)({ data: null });
|
|
132
|
+
}
|
|
133
|
+
const parsed = await response.json().catch(() => ({}));
|
|
134
|
+
if (!response.ok) {
|
|
135
|
+
const error = parsed;
|
|
136
|
+
return (0, import_platform_protocol2.err)({
|
|
137
|
+
code: error.code ?? "unknown_error",
|
|
138
|
+
message: error.message ?? "Failed to create identity",
|
|
139
|
+
errors: error.errors
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
return (0, import_platform_protocol2.ok)(parsed);
|
|
143
|
+
}
|
|
144
|
+
async function getIdentity(ctx, id) {
|
|
145
|
+
return apiFetch(ctx, `/platform/v1/identities/${encodeURIComponent(id)}`);
|
|
146
|
+
}
|
|
147
|
+
async function updateIdentity(ctx, id, body) {
|
|
148
|
+
return apiFetch(ctx, `/platform/v1/identities/${encodeURIComponent(id)}`, {
|
|
149
|
+
method: "PATCH",
|
|
150
|
+
body: JSON.stringify(body)
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
async function verifyIdentity(ctx, id) {
|
|
154
|
+
return apiFetch(
|
|
155
|
+
ctx,
|
|
156
|
+
`/platform/v1/identities/${encodeURIComponent(id)}/verifications`,
|
|
157
|
+
{ method: "POST" }
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
async function getIdentityUploadUrl(ctx, id, body) {
|
|
161
|
+
return apiFetch(
|
|
162
|
+
ctx,
|
|
163
|
+
`/platform/v1/identities/${encodeURIComponent(id)}/files/upload-url`,
|
|
164
|
+
{ method: "POST", body: JSON.stringify(body) }
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
async function submitIdentityFiles(ctx, id, body) {
|
|
168
|
+
return apiFetch(
|
|
169
|
+
ctx,
|
|
170
|
+
`/platform/v1/identities/${encodeURIComponent(id)}/files`,
|
|
171
|
+
{ method: "POST", body: JSON.stringify(body) }
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// src/api/payment-methods.ts
|
|
176
|
+
var import_platform_protocol3 = require("@moonpay/platform-protocol");
|
|
119
177
|
async function getPaymentMethods(ctx) {
|
|
120
178
|
return apiFetch(ctx, "/platform/v1/payment-methods");
|
|
121
179
|
}
|
|
@@ -126,12 +184,12 @@ async function deletePaymentMethod(ctx, paymentMethodId) {
|
|
|
126
184
|
);
|
|
127
185
|
if (!response.ok) {
|
|
128
186
|
const data = await response.json().catch(() => ({}));
|
|
129
|
-
return (0,
|
|
187
|
+
return (0, import_platform_protocol3.err)({
|
|
130
188
|
code: data.code ?? "unknown_error",
|
|
131
189
|
message: data.message ?? "Failed to delete payment method"
|
|
132
190
|
});
|
|
133
191
|
}
|
|
134
|
-
return (0,
|
|
192
|
+
return (0, import_platform_protocol3.ok)(void 0);
|
|
135
193
|
}
|
|
136
194
|
|
|
137
195
|
// src/client.ts
|
|
@@ -151,7 +209,13 @@ function createClientCore(options) {
|
|
|
151
209
|
getPaymentMethods: () => getPaymentMethods(ctx),
|
|
152
210
|
listTransactions: (params) => listTransactions(ctx, params),
|
|
153
211
|
getTransaction: (id) => getTransaction(ctx, id),
|
|
154
|
-
deletePaymentMethod: (id) => deletePaymentMethod(ctx, id)
|
|
212
|
+
deletePaymentMethod: (id) => deletePaymentMethod(ctx, id),
|
|
213
|
+
createIdentity: (body) => createIdentity(ctx, body),
|
|
214
|
+
getIdentity: (id) => getIdentity(ctx, id),
|
|
215
|
+
updateIdentity: (id, body) => updateIdentity(ctx, id, body),
|
|
216
|
+
verifyIdentity: (id) => verifyIdentity(ctx, id),
|
|
217
|
+
getIdentityUploadUrl: (id, body) => getIdentityUploadUrl(ctx, id, body),
|
|
218
|
+
submitIdentityFiles: (id, body) => submitIdentityFiles(ctx, id, body)
|
|
155
219
|
};
|
|
156
220
|
}
|
|
157
221
|
|
|
@@ -1470,7 +1534,7 @@ function generateKeyPair() {
|
|
|
1470
1534
|
}
|
|
1471
1535
|
|
|
1472
1536
|
// src/frames/frame-orchestrator.ts
|
|
1473
|
-
var
|
|
1537
|
+
var import_platform_protocol4 = require("@moonpay/platform-protocol");
|
|
1474
1538
|
function createFrameOrchestrator(options) {
|
|
1475
1539
|
const { transport, channelId, url, container, hidden, handshakeTimeout = 15e3 } = options;
|
|
1476
1540
|
return new Promise((resolve, reject) => {
|
|
@@ -1485,13 +1549,13 @@ function createFrameOrchestrator(options) {
|
|
|
1485
1549
|
const unsubHandshake = transport.onMessage((msg) => {
|
|
1486
1550
|
if (msg.meta?.channelId !== channelId)
|
|
1487
1551
|
return;
|
|
1488
|
-
if (!handshakeComplete && msg.kind ===
|
|
1552
|
+
if (!handshakeComplete && msg.kind === import_platform_protocol4.HANDSHAKE_REQUEST_KIND) {
|
|
1489
1553
|
handshakeComplete = true;
|
|
1490
1554
|
clearTimeout(timer);
|
|
1491
1555
|
transport.sendMessage({
|
|
1492
1556
|
version: 2,
|
|
1493
1557
|
meta: { channelId },
|
|
1494
|
-
kind:
|
|
1558
|
+
kind: import_platform_protocol4.HANDSHAKE_ACK_KIND
|
|
1495
1559
|
});
|
|
1496
1560
|
resolve(handle);
|
|
1497
1561
|
return;
|
|
@@ -1528,6 +1592,7 @@ function createFrameOrchestrator(options) {
|
|
|
1528
1592
|
// src/frames/url-builder.ts
|
|
1529
1593
|
var FRAME_PATHS = {
|
|
1530
1594
|
connect: "/platform/v1/connect",
|
|
1595
|
+
auth: "/platform/v1/auth",
|
|
1531
1596
|
checkConnection: "/platform/v1/check-connection",
|
|
1532
1597
|
applePay: "/platform/v1/apple-pay",
|
|
1533
1598
|
googlePay: "/platform/v1/google-pay",
|