@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 +28 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -5
- package/dist/index.d.ts +13 -5
- package/dist/index.js +19 -25
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Result
|
|
1
|
+
import { DevPlatformApiError, GetQuoteError, GetTransactionsError, CreateIdentityError, GetIdentityError, GetIdentityUploadUrlError, SubmitIdentityFilesError, UpdateIdentityError, VerifyIdentityError, GetPaymentMethodsError } from '@moonpay/platform-protocol/api/errors';
|
|
2
|
+
import { Result } from '@moonpay/platform-protocol/result';
|
|
3
|
+
import { GetQuoteParams, Quote, TransactionWithStages, Transaction, PaginationInfo, ListPaymentMethodsResponse } from '@moonpay/platform-protocol/api';
|
|
4
|
+
import { CreateIdentityRequestBody, Identity, IdentityFileUploadUrlRequestBody, IdentityFileUploadUrl, SubmitIdentityFilesRequestBody, UpdateIdentityRequestBody, IdentityVerificationResponse } from '@moonpay/platform-protocol/api/identity';
|
|
5
|
+
import { ProtocolMessage } from '@moonpay/platform-protocol/protocol';
|
|
6
|
+
import { DecryptedCredentials } from '@moonpay/platform-protocol/models/connection';
|
|
3
7
|
|
|
4
8
|
/** Internal state container for authenticated API access. */
|
|
5
9
|
interface ClientContext {
|
|
@@ -20,7 +24,7 @@ declare function apiFetch<T>(ctx: ClientContext, path: string, options?: Request
|
|
|
20
24
|
|
|
21
25
|
/** The API wraps the quote in a `{ data: ... }` envelope. */
|
|
22
26
|
interface GetQuoteApiResponse {
|
|
23
|
-
data:
|
|
27
|
+
data: Quote;
|
|
24
28
|
}
|
|
25
29
|
declare function getQuote(ctx: ClientContext, params: GetQuoteParams): Promise<Result<GetQuoteApiResponse, GetQuoteError>>;
|
|
26
30
|
|
|
@@ -63,7 +67,9 @@ declare function verifyIdentity(ctx: ClientContext, id: string): Promise<Result<
|
|
|
63
67
|
declare function getIdentityUploadUrl(ctx: ClientContext, id: string, body: IdentityFileUploadUrlRequestBody): Promise<Result<UploadUrlEnvelope, GetIdentityUploadUrlError>>;
|
|
64
68
|
declare function submitIdentityFiles(ctx: ClientContext, id: string, body: SubmitIdentityFilesRequestBody): Promise<Result<IdentityEnvelope, SubmitIdentityFilesError>>;
|
|
65
69
|
|
|
66
|
-
declare function getPaymentMethods(ctx: ClientContext): Promise<Result<
|
|
70
|
+
declare function getPaymentMethods(ctx: ClientContext): Promise<Result<{
|
|
71
|
+
data: ListPaymentMethodsResponse;
|
|
72
|
+
}, GetPaymentMethodsError>>;
|
|
67
73
|
declare function deletePaymentMethod(ctx: ClientContext, paymentMethodId: string): Promise<Result<void, DevPlatformApiError>>;
|
|
68
74
|
|
|
69
75
|
/** Options for creating a frame (iframe or WebView). */
|
|
@@ -128,7 +134,9 @@ interface CoreClient {
|
|
|
128
134
|
getQuote(params: GetQuoteParams): Promise<Result<{
|
|
129
135
|
data: Quote;
|
|
130
136
|
}, GetQuoteError>>;
|
|
131
|
-
getPaymentMethods(): Promise<Result<
|
|
137
|
+
getPaymentMethods(): Promise<Result<{
|
|
138
|
+
data: ListPaymentMethodsResponse;
|
|
139
|
+
}, GetPaymentMethodsError>>;
|
|
132
140
|
listTransactions(params?: ListTransactionsParams): Promise<Result<{
|
|
133
141
|
data: Transaction[];
|
|
134
142
|
pageInfo: PaginationInfo;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Result
|
|
1
|
+
import { DevPlatformApiError, GetQuoteError, GetTransactionsError, CreateIdentityError, GetIdentityError, GetIdentityUploadUrlError, SubmitIdentityFilesError, UpdateIdentityError, VerifyIdentityError, GetPaymentMethodsError } from '@moonpay/platform-protocol/api/errors';
|
|
2
|
+
import { Result } from '@moonpay/platform-protocol/result';
|
|
3
|
+
import { GetQuoteParams, Quote, TransactionWithStages, Transaction, PaginationInfo, ListPaymentMethodsResponse } from '@moonpay/platform-protocol/api';
|
|
4
|
+
import { CreateIdentityRequestBody, Identity, IdentityFileUploadUrlRequestBody, IdentityFileUploadUrl, SubmitIdentityFilesRequestBody, UpdateIdentityRequestBody, IdentityVerificationResponse } from '@moonpay/platform-protocol/api/identity';
|
|
5
|
+
import { ProtocolMessage } from '@moonpay/platform-protocol/protocol';
|
|
6
|
+
import { DecryptedCredentials } from '@moonpay/platform-protocol/models/connection';
|
|
3
7
|
|
|
4
8
|
/** Internal state container for authenticated API access. */
|
|
5
9
|
interface ClientContext {
|
|
@@ -20,7 +24,7 @@ declare function apiFetch<T>(ctx: ClientContext, path: string, options?: Request
|
|
|
20
24
|
|
|
21
25
|
/** The API wraps the quote in a `{ data: ... }` envelope. */
|
|
22
26
|
interface GetQuoteApiResponse {
|
|
23
|
-
data:
|
|
27
|
+
data: Quote;
|
|
24
28
|
}
|
|
25
29
|
declare function getQuote(ctx: ClientContext, params: GetQuoteParams): Promise<Result<GetQuoteApiResponse, GetQuoteError>>;
|
|
26
30
|
|
|
@@ -63,7 +67,9 @@ declare function verifyIdentity(ctx: ClientContext, id: string): Promise<Result<
|
|
|
63
67
|
declare function getIdentityUploadUrl(ctx: ClientContext, id: string, body: IdentityFileUploadUrlRequestBody): Promise<Result<UploadUrlEnvelope, GetIdentityUploadUrlError>>;
|
|
64
68
|
declare function submitIdentityFiles(ctx: ClientContext, id: string, body: SubmitIdentityFilesRequestBody): Promise<Result<IdentityEnvelope, SubmitIdentityFilesError>>;
|
|
65
69
|
|
|
66
|
-
declare function getPaymentMethods(ctx: ClientContext): Promise<Result<
|
|
70
|
+
declare function getPaymentMethods(ctx: ClientContext): Promise<Result<{
|
|
71
|
+
data: ListPaymentMethodsResponse;
|
|
72
|
+
}, GetPaymentMethodsError>>;
|
|
67
73
|
declare function deletePaymentMethod(ctx: ClientContext, paymentMethodId: string): Promise<Result<void, DevPlatformApiError>>;
|
|
68
74
|
|
|
69
75
|
/** Options for creating a frame (iframe or WebView). */
|
|
@@ -128,7 +134,9 @@ interface CoreClient {
|
|
|
128
134
|
getQuote(params: GetQuoteParams): Promise<Result<{
|
|
129
135
|
data: Quote;
|
|
130
136
|
}, GetQuoteError>>;
|
|
131
|
-
getPaymentMethods(): Promise<Result<
|
|
137
|
+
getPaymentMethods(): Promise<Result<{
|
|
138
|
+
data: ListPaymentMethodsResponse;
|
|
139
|
+
}, GetPaymentMethodsError>>;
|
|
132
140
|
listTransactions(params?: ListTransactionsParams): Promise<Result<{
|
|
133
141
|
data: Transaction[];
|
|
134
142
|
pageInfo: PaginationInfo;
|
package/dist/index.js
CHANGED
|
@@ -31,7 +31,7 @@ function createClientContext(options = {}) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
// src/api/fetch-wrapper.ts
|
|
34
|
-
import { err, ok } from "@moonpay/platform-protocol";
|
|
34
|
+
import { err, ok } from "@moonpay/platform-protocol/result";
|
|
35
35
|
async function apiFetch(ctx, path, options) {
|
|
36
36
|
const response = await ctx.fetch(path, options);
|
|
37
37
|
const data = await response.json();
|
|
@@ -77,10 +77,7 @@ async function getTransaction(ctx, id) {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
// src/api/identity.ts
|
|
80
|
-
import {
|
|
81
|
-
err as err2,
|
|
82
|
-
ok as ok2
|
|
83
|
-
} from "@moonpay/platform-protocol";
|
|
80
|
+
import { err as err2, ok as ok2 } from "@moonpay/platform-protocol/result";
|
|
84
81
|
async function createIdentity(ctx, body) {
|
|
85
82
|
const response = await ctx.fetch("/platform/v1/identities", {
|
|
86
83
|
method: "POST",
|
|
@@ -132,10 +129,7 @@ async function submitIdentityFiles(ctx, id, body) {
|
|
|
132
129
|
}
|
|
133
130
|
|
|
134
131
|
// src/api/payment-methods.ts
|
|
135
|
-
import {
|
|
136
|
-
err as err3,
|
|
137
|
-
ok as ok3
|
|
138
|
-
} from "@moonpay/platform-protocol";
|
|
132
|
+
import { err as err3, ok as ok3 } from "@moonpay/platform-protocol/result";
|
|
139
133
|
async function getPaymentMethods(ctx) {
|
|
140
134
|
return apiFetch(ctx, "/platform/v1/payment-methods");
|
|
141
135
|
}
|
|
@@ -181,7 +175,7 @@ function createClientCore(options) {
|
|
|
181
175
|
};
|
|
182
176
|
}
|
|
183
177
|
|
|
184
|
-
// ../../node_modules
|
|
178
|
+
// ../../node_modules/@noble/ciphers/esm/_assert.js
|
|
185
179
|
function isBytes(a) {
|
|
186
180
|
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
187
181
|
}
|
|
@@ -205,7 +199,7 @@ function aoutput(out, instance) {
|
|
|
205
199
|
}
|
|
206
200
|
}
|
|
207
201
|
|
|
208
|
-
// ../../node_modules
|
|
202
|
+
// ../../node_modules/@noble/ciphers/esm/utils.js
|
|
209
203
|
var u8 = (arr) => new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
210
204
|
var u32 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
211
205
|
var createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
@@ -314,7 +308,7 @@ function clean(...arrays) {
|
|
|
314
308
|
}
|
|
315
309
|
}
|
|
316
310
|
|
|
317
|
-
// ../../node_modules
|
|
311
|
+
// ../../node_modules/@noble/ciphers/esm/_polyval.js
|
|
318
312
|
var BLOCK_SIZE = 16;
|
|
319
313
|
var ZEROS16 = /* @__PURE__ */ new Uint8Array(16);
|
|
320
314
|
var ZEROS32 = u32(ZEROS16);
|
|
@@ -504,7 +498,7 @@ function wrapConstructorWithKey(hashCons) {
|
|
|
504
498
|
var ghash = wrapConstructorWithKey((key, expectedLength) => new GHASH(key, expectedLength));
|
|
505
499
|
var polyval = wrapConstructorWithKey((key, expectedLength) => new Polyval(key, expectedLength));
|
|
506
500
|
|
|
507
|
-
// ../../node_modules
|
|
501
|
+
// ../../node_modules/@noble/ciphers/esm/aes.js
|
|
508
502
|
var BLOCK_SIZE2 = 16;
|
|
509
503
|
var BLOCK_SIZE32 = 4;
|
|
510
504
|
var EMPTY_BLOCK = /* @__PURE__ */ new Uint8Array(BLOCK_SIZE2);
|
|
@@ -720,7 +714,7 @@ var gcm = /* @__PURE__ */ wrapCipher({ blockSize: 16, nonceLength: 12, tagLength
|
|
|
720
714
|
};
|
|
721
715
|
});
|
|
722
716
|
|
|
723
|
-
// ../../node_modules
|
|
717
|
+
// ../../node_modules/@noble/hashes/esm/_assert.js
|
|
724
718
|
function anumber(n) {
|
|
725
719
|
if (!Number.isSafeInteger(n) || n < 0)
|
|
726
720
|
throw new Error("positive integer expected, got " + n);
|
|
@@ -754,10 +748,10 @@ function aoutput2(out, instance) {
|
|
|
754
748
|
}
|
|
755
749
|
}
|
|
756
750
|
|
|
757
|
-
// ../../node_modules
|
|
751
|
+
// ../../node_modules/@noble/hashes/esm/crypto.js
|
|
758
752
|
var crypto = typeof globalThis === "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
|
|
759
753
|
|
|
760
|
-
// ../../node_modules
|
|
754
|
+
// ../../node_modules/@noble/hashes/esm/utils.js
|
|
761
755
|
var createView2 = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
762
756
|
var rotr = (word, shift) => word << 32 - shift | word >>> shift;
|
|
763
757
|
function utf8ToBytes2(str) {
|
|
@@ -795,7 +789,7 @@ function randomBytes(bytesLength = 32) {
|
|
|
795
789
|
throw new Error("crypto.getRandomValues must be defined");
|
|
796
790
|
}
|
|
797
791
|
|
|
798
|
-
// ../../node_modules
|
|
792
|
+
// ../../node_modules/@noble/hashes/esm/_md.js
|
|
799
793
|
function setBigUint642(view, byteOffset, value, isLE2) {
|
|
800
794
|
if (typeof view.setBigUint64 === "function")
|
|
801
795
|
return view.setBigUint64(byteOffset, value, isLE2);
|
|
@@ -897,7 +891,7 @@ var HashMD = class extends Hash {
|
|
|
897
891
|
}
|
|
898
892
|
};
|
|
899
893
|
|
|
900
|
-
// ../../node_modules
|
|
894
|
+
// ../../node_modules/@noble/curves/esm/abstract/utils.js
|
|
901
895
|
var _0n = /* @__PURE__ */ BigInt(0);
|
|
902
896
|
function isBytes3(a) {
|
|
903
897
|
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
@@ -1015,7 +1009,7 @@ function validateObject(object, validators, optValidators = {}) {
|
|
|
1015
1009
|
return object;
|
|
1016
1010
|
}
|
|
1017
1011
|
|
|
1018
|
-
// ../../node_modules
|
|
1012
|
+
// ../../node_modules/@noble/curves/esm/abstract/modular.js
|
|
1019
1013
|
var _0n2 = BigInt(0);
|
|
1020
1014
|
var _1n = BigInt(1);
|
|
1021
1015
|
function mod(a, b) {
|
|
@@ -1047,7 +1041,7 @@ function pow2(x, power, modulo) {
|
|
|
1047
1041
|
return res;
|
|
1048
1042
|
}
|
|
1049
1043
|
|
|
1050
|
-
// ../../node_modules
|
|
1044
|
+
// ../../node_modules/@noble/curves/esm/abstract/montgomery.js
|
|
1051
1045
|
var _0n3 = BigInt(0);
|
|
1052
1046
|
var _1n2 = BigInt(1);
|
|
1053
1047
|
function validateOpts(curve) {
|
|
@@ -1165,7 +1159,7 @@ function montgomery(curveDef) {
|
|
|
1165
1159
|
};
|
|
1166
1160
|
}
|
|
1167
1161
|
|
|
1168
|
-
// ../../node_modules
|
|
1162
|
+
// ../../node_modules/@noble/curves/esm/ed25519.js
|
|
1169
1163
|
var ED25519_P = BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");
|
|
1170
1164
|
var _0n4 = BigInt(0);
|
|
1171
1165
|
var _1n3 = BigInt(1);
|
|
@@ -1212,7 +1206,7 @@ var x25519 = /* @__PURE__ */ (() => montgomery({
|
|
|
1212
1206
|
randomBytes
|
|
1213
1207
|
}))();
|
|
1214
1208
|
|
|
1215
|
-
// ../../node_modules
|
|
1209
|
+
// ../../node_modules/@noble/hashes/esm/hmac.js
|
|
1216
1210
|
var HMAC = class extends Hash {
|
|
1217
1211
|
constructor(hash, _key) {
|
|
1218
1212
|
super();
|
|
@@ -1277,7 +1271,7 @@ var HMAC = class extends Hash {
|
|
|
1277
1271
|
var hmac = (hash, key, message) => new HMAC(hash, key).update(message).digest();
|
|
1278
1272
|
hmac.create = (hash, key) => new HMAC(hash, key);
|
|
1279
1273
|
|
|
1280
|
-
// ../../node_modules
|
|
1274
|
+
// ../../node_modules/@noble/hashes/esm/hkdf.js
|
|
1281
1275
|
function extract(hash, ikm, salt) {
|
|
1282
1276
|
ahash(hash);
|
|
1283
1277
|
if (salt === void 0)
|
|
@@ -1312,7 +1306,7 @@ function expand(hash, prk, info, length = 32) {
|
|
|
1312
1306
|
}
|
|
1313
1307
|
var hkdf = (hash, ikm, salt, info, length) => expand(hash, extract(hash, ikm, salt), info, length);
|
|
1314
1308
|
|
|
1315
|
-
// ../../node_modules
|
|
1309
|
+
// ../../node_modules/@noble/hashes/esm/sha256.js
|
|
1316
1310
|
var SHA256_K = /* @__PURE__ */ new Uint32Array([
|
|
1317
1311
|
1116352408,
|
|
1318
1312
|
1899447441,
|
|
@@ -1499,7 +1493,7 @@ function generateKeyPair() {
|
|
|
1499
1493
|
import {
|
|
1500
1494
|
HANDSHAKE_ACK_KIND,
|
|
1501
1495
|
HANDSHAKE_REQUEST_KIND
|
|
1502
|
-
} from "@moonpay/platform-protocol";
|
|
1496
|
+
} from "@moonpay/platform-protocol/protocol";
|
|
1503
1497
|
function createFrameOrchestrator(options) {
|
|
1504
1498
|
const { transport, channelId, url, container, hidden, handshakeTimeout = 15e3 } = options;
|
|
1505
1499
|
return new Promise((resolve, reject) => {
|