@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.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _moonpay_platform_protocol from '@moonpay/platform-protocol';
2
- import { Result, DevPlatformApiError, GetQuoteParams, GetQuoteError, TransactionWithStages, GetTransactionsError, Transaction, PaginationInfo, ListPaymentMethodsResponse, GetPaymentMethodsError, ProtocolMessage, Quote, DecryptedCredentials } from '@moonpay/platform-protocol';
2
+ import { Result, DevPlatformApiError, GetQuoteParams, GetQuoteError, TransactionWithStages, GetTransactionsError, Transaction, PaginationInfo, CreateIdentityRequestBody, Identity, CreateIdentityError, GetIdentityError, IdentityFileUploadUrlRequestBody, IdentityFileUploadUrl, GetIdentityUploadUrlError, SubmitIdentityFilesRequestBody, SubmitIdentityFilesError, UpdateIdentityRequestBody, UpdateIdentityError, IdentityVerificationResponse, VerifyIdentityError, ListPaymentMethodsResponse, GetPaymentMethodsError, ProtocolMessage, Quote, DecryptedCredentials } from '@moonpay/platform-protocol';
3
3
 
4
4
  /** Internal state container for authenticated API access. */
5
5
  interface ClientContext {
@@ -40,6 +40,29 @@ interface GetTransactionApiResponse {
40
40
  }
41
41
  declare function getTransaction(ctx: ClientContext, id: string): Promise<Result<GetTransactionApiResponse, GetTransactionsError>>;
42
42
 
43
+ /** The API wraps each identity response in a `{ data: ... }` envelope. */
44
+ interface IdentityEnvelope {
45
+ data: Identity;
46
+ }
47
+ interface VerificationEnvelope {
48
+ data: IdentityVerificationResponse;
49
+ }
50
+ interface UploadUrlEnvelope {
51
+ data: IdentityFileUploadUrl;
52
+ }
53
+ /**
54
+ * Create an identity. Returns the created identity, or `null` when the
55
+ * customer has no outstanding requirements (the API returns 204).
56
+ */
57
+ declare function createIdentity(ctx: ClientContext, body: CreateIdentityRequestBody): Promise<Result<{
58
+ data: Identity | null;
59
+ }, CreateIdentityError>>;
60
+ declare function getIdentity(ctx: ClientContext, id: string): Promise<Result<IdentityEnvelope, GetIdentityError>>;
61
+ declare function updateIdentity(ctx: ClientContext, id: string, body: UpdateIdentityRequestBody): Promise<Result<IdentityEnvelope, UpdateIdentityError>>;
62
+ declare function verifyIdentity(ctx: ClientContext, id: string): Promise<Result<VerificationEnvelope, VerifyIdentityError>>;
63
+ declare function getIdentityUploadUrl(ctx: ClientContext, id: string, body: IdentityFileUploadUrlRequestBody): Promise<Result<UploadUrlEnvelope, GetIdentityUploadUrlError>>;
64
+ declare function submitIdentityFiles(ctx: ClientContext, id: string, body: SubmitIdentityFilesRequestBody): Promise<Result<IdentityEnvelope, SubmitIdentityFilesError>>;
65
+
43
66
  declare function getPaymentMethods(ctx: ClientContext): Promise<Result<ListPaymentMethodsResponse, GetPaymentMethodsError>>;
44
67
  declare function deletePaymentMethod(ctx: ClientContext, paymentMethodId: string): Promise<Result<void, DevPlatformApiError>>;
45
68
 
@@ -70,6 +93,7 @@ interface FrameTransport {
70
93
 
71
94
  declare const FRAME_PATHS: {
72
95
  readonly connect: "/platform/v1/connect";
96
+ readonly auth: "/platform/v1/auth";
73
97
  readonly checkConnection: "/platform/v1/check-connection";
74
98
  readonly applePay: "/platform/v1/apple-pay";
75
99
  readonly googlePay: "/platform/v1/google-pay";
@@ -113,6 +137,24 @@ interface CoreClient {
113
137
  data: TransactionWithStages;
114
138
  }, GetTransactionsError>>;
115
139
  deletePaymentMethod(id: string): Promise<Result<void, DevPlatformApiError>>;
140
+ createIdentity(body: CreateIdentityRequestBody): Promise<Result<{
141
+ data: Identity | null;
142
+ }, CreateIdentityError>>;
143
+ getIdentity(id: string): Promise<Result<{
144
+ data: Identity;
145
+ }, GetIdentityError>>;
146
+ updateIdentity(id: string, body: UpdateIdentityRequestBody): Promise<Result<{
147
+ data: Identity;
148
+ }, UpdateIdentityError>>;
149
+ verifyIdentity(id: string): Promise<Result<{
150
+ data: IdentityVerificationResponse;
151
+ }, VerifyIdentityError>>;
152
+ getIdentityUploadUrl(id: string, body: IdentityFileUploadUrlRequestBody): Promise<Result<{
153
+ data: IdentityFileUploadUrl;
154
+ }, GetIdentityUploadUrlError>>;
155
+ submitIdentityFiles(id: string, body: SubmitIdentityFilesRequestBody): Promise<Result<{
156
+ data: Identity;
157
+ }, SubmitIdentityFilesError>>;
116
158
  }
117
159
  /**
118
160
  * Creates the platform-agnostic core client.
@@ -164,4 +206,4 @@ interface FrameHandle {
164
206
  */
165
207
  declare function createFrameOrchestrator(options: FrameOrchestratorOptions): Promise<FrameHandle>;
166
208
 
167
- export { type ClientContext, type ClientContextOptions, type CoreClient, type CoreClientOptions, FRAME_PATHS, type FrameHandle, type FrameOptions, type FrameOrchestratorOptions, type FrameTransport, type KeyPair, type ListTransactionsParams, type UrlBuilderOptions, apiFetch, buildFrameUrl, createClientContext, createClientCore, createFrameOrchestrator, decryptCredentials, deletePaymentMethod, generateKeyPair, getPaymentMethods, getQuote, getTransaction, listTransactions };
209
+ export { type ClientContext, type ClientContextOptions, type CoreClient, type CoreClientOptions, FRAME_PATHS, type FrameHandle, type FrameOptions, type FrameOrchestratorOptions, type FrameTransport, type KeyPair, type ListTransactionsParams, type UrlBuilderOptions, apiFetch, buildFrameUrl, createClientContext, createClientCore, createFrameOrchestrator, createIdentity, decryptCredentials, deletePaymentMethod, generateKeyPair, getIdentity, getIdentityUploadUrl, getPaymentMethods, getQuote, getTransaction, listTransactions, submitIdentityFiles, updateIdentity, verifyIdentity };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _moonpay_platform_protocol from '@moonpay/platform-protocol';
2
- import { Result, DevPlatformApiError, GetQuoteParams, GetQuoteError, TransactionWithStages, GetTransactionsError, Transaction, PaginationInfo, ListPaymentMethodsResponse, GetPaymentMethodsError, ProtocolMessage, Quote, DecryptedCredentials } from '@moonpay/platform-protocol';
2
+ import { Result, DevPlatformApiError, GetQuoteParams, GetQuoteError, TransactionWithStages, GetTransactionsError, Transaction, PaginationInfo, CreateIdentityRequestBody, Identity, CreateIdentityError, GetIdentityError, IdentityFileUploadUrlRequestBody, IdentityFileUploadUrl, GetIdentityUploadUrlError, SubmitIdentityFilesRequestBody, SubmitIdentityFilesError, UpdateIdentityRequestBody, UpdateIdentityError, IdentityVerificationResponse, VerifyIdentityError, ListPaymentMethodsResponse, GetPaymentMethodsError, ProtocolMessage, Quote, DecryptedCredentials } from '@moonpay/platform-protocol';
3
3
 
4
4
  /** Internal state container for authenticated API access. */
5
5
  interface ClientContext {
@@ -40,6 +40,29 @@ interface GetTransactionApiResponse {
40
40
  }
41
41
  declare function getTransaction(ctx: ClientContext, id: string): Promise<Result<GetTransactionApiResponse, GetTransactionsError>>;
42
42
 
43
+ /** The API wraps each identity response in a `{ data: ... }` envelope. */
44
+ interface IdentityEnvelope {
45
+ data: Identity;
46
+ }
47
+ interface VerificationEnvelope {
48
+ data: IdentityVerificationResponse;
49
+ }
50
+ interface UploadUrlEnvelope {
51
+ data: IdentityFileUploadUrl;
52
+ }
53
+ /**
54
+ * Create an identity. Returns the created identity, or `null` when the
55
+ * customer has no outstanding requirements (the API returns 204).
56
+ */
57
+ declare function createIdentity(ctx: ClientContext, body: CreateIdentityRequestBody): Promise<Result<{
58
+ data: Identity | null;
59
+ }, CreateIdentityError>>;
60
+ declare function getIdentity(ctx: ClientContext, id: string): Promise<Result<IdentityEnvelope, GetIdentityError>>;
61
+ declare function updateIdentity(ctx: ClientContext, id: string, body: UpdateIdentityRequestBody): Promise<Result<IdentityEnvelope, UpdateIdentityError>>;
62
+ declare function verifyIdentity(ctx: ClientContext, id: string): Promise<Result<VerificationEnvelope, VerifyIdentityError>>;
63
+ declare function getIdentityUploadUrl(ctx: ClientContext, id: string, body: IdentityFileUploadUrlRequestBody): Promise<Result<UploadUrlEnvelope, GetIdentityUploadUrlError>>;
64
+ declare function submitIdentityFiles(ctx: ClientContext, id: string, body: SubmitIdentityFilesRequestBody): Promise<Result<IdentityEnvelope, SubmitIdentityFilesError>>;
65
+
43
66
  declare function getPaymentMethods(ctx: ClientContext): Promise<Result<ListPaymentMethodsResponse, GetPaymentMethodsError>>;
44
67
  declare function deletePaymentMethod(ctx: ClientContext, paymentMethodId: string): Promise<Result<void, DevPlatformApiError>>;
45
68
 
@@ -70,6 +93,7 @@ interface FrameTransport {
70
93
 
71
94
  declare const FRAME_PATHS: {
72
95
  readonly connect: "/platform/v1/connect";
96
+ readonly auth: "/platform/v1/auth";
73
97
  readonly checkConnection: "/platform/v1/check-connection";
74
98
  readonly applePay: "/platform/v1/apple-pay";
75
99
  readonly googlePay: "/platform/v1/google-pay";
@@ -113,6 +137,24 @@ interface CoreClient {
113
137
  data: TransactionWithStages;
114
138
  }, GetTransactionsError>>;
115
139
  deletePaymentMethod(id: string): Promise<Result<void, DevPlatformApiError>>;
140
+ createIdentity(body: CreateIdentityRequestBody): Promise<Result<{
141
+ data: Identity | null;
142
+ }, CreateIdentityError>>;
143
+ getIdentity(id: string): Promise<Result<{
144
+ data: Identity;
145
+ }, GetIdentityError>>;
146
+ updateIdentity(id: string, body: UpdateIdentityRequestBody): Promise<Result<{
147
+ data: Identity;
148
+ }, UpdateIdentityError>>;
149
+ verifyIdentity(id: string): Promise<Result<{
150
+ data: IdentityVerificationResponse;
151
+ }, VerifyIdentityError>>;
152
+ getIdentityUploadUrl(id: string, body: IdentityFileUploadUrlRequestBody): Promise<Result<{
153
+ data: IdentityFileUploadUrl;
154
+ }, GetIdentityUploadUrlError>>;
155
+ submitIdentityFiles(id: string, body: SubmitIdentityFilesRequestBody): Promise<Result<{
156
+ data: Identity;
157
+ }, SubmitIdentityFilesError>>;
116
158
  }
117
159
  /**
118
160
  * Creates the platform-agnostic core client.
@@ -164,4 +206,4 @@ interface FrameHandle {
164
206
  */
165
207
  declare function createFrameOrchestrator(options: FrameOrchestratorOptions): Promise<FrameHandle>;
166
208
 
167
- export { type ClientContext, type ClientContextOptions, type CoreClient, type CoreClientOptions, FRAME_PATHS, type FrameHandle, type FrameOptions, type FrameOrchestratorOptions, type FrameTransport, type KeyPair, type ListTransactionsParams, type UrlBuilderOptions, apiFetch, buildFrameUrl, createClientContext, createClientCore, createFrameOrchestrator, decryptCredentials, deletePaymentMethod, generateKeyPair, getPaymentMethods, getQuote, getTransaction, listTransactions };
209
+ export { type ClientContext, type ClientContextOptions, type CoreClient, type CoreClientOptions, FRAME_PATHS, type FrameHandle, type FrameOptions, type FrameOrchestratorOptions, type FrameTransport, type KeyPair, type ListTransactionsParams, type UrlBuilderOptions, apiFetch, buildFrameUrl, createClientContext, createClientCore, createFrameOrchestrator, createIdentity, decryptCredentials, deletePaymentMethod, generateKeyPair, getIdentity, getIdentityUploadUrl, getPaymentMethods, getQuote, getTransaction, listTransactions, submitIdentityFiles, updateIdentity, verifyIdentity };
package/dist/index.js CHANGED
@@ -76,11 +76,66 @@ async function getTransaction(ctx, id) {
76
76
  );
77
77
  }
78
78
 
79
- // src/api/payment-methods.ts
79
+ // src/api/identity.ts
80
80
  import {
81
81
  err as err2,
82
82
  ok as ok2
83
83
  } from "@moonpay/platform-protocol";
84
+ async function createIdentity(ctx, body) {
85
+ const response = await ctx.fetch("/platform/v1/identities", {
86
+ method: "POST",
87
+ body: JSON.stringify(body)
88
+ });
89
+ if (response.status === 204) {
90
+ return ok2({ data: null });
91
+ }
92
+ const parsed = await response.json().catch(() => ({}));
93
+ if (!response.ok) {
94
+ const error = parsed;
95
+ return err2({
96
+ code: error.code ?? "unknown_error",
97
+ message: error.message ?? "Failed to create identity",
98
+ errors: error.errors
99
+ });
100
+ }
101
+ return ok2(parsed);
102
+ }
103
+ async function getIdentity(ctx, id) {
104
+ return apiFetch(ctx, `/platform/v1/identities/${encodeURIComponent(id)}`);
105
+ }
106
+ async function updateIdentity(ctx, id, body) {
107
+ return apiFetch(ctx, `/platform/v1/identities/${encodeURIComponent(id)}`, {
108
+ method: "PATCH",
109
+ body: JSON.stringify(body)
110
+ });
111
+ }
112
+ async function verifyIdentity(ctx, id) {
113
+ return apiFetch(
114
+ ctx,
115
+ `/platform/v1/identities/${encodeURIComponent(id)}/verifications`,
116
+ { method: "POST" }
117
+ );
118
+ }
119
+ async function getIdentityUploadUrl(ctx, id, body) {
120
+ return apiFetch(
121
+ ctx,
122
+ `/platform/v1/identities/${encodeURIComponent(id)}/files/upload-url`,
123
+ { method: "POST", body: JSON.stringify(body) }
124
+ );
125
+ }
126
+ async function submitIdentityFiles(ctx, id, body) {
127
+ return apiFetch(
128
+ ctx,
129
+ `/platform/v1/identities/${encodeURIComponent(id)}/files`,
130
+ { method: "POST", body: JSON.stringify(body) }
131
+ );
132
+ }
133
+
134
+ // src/api/payment-methods.ts
135
+ import {
136
+ err as err3,
137
+ ok as ok3
138
+ } from "@moonpay/platform-protocol";
84
139
  async function getPaymentMethods(ctx) {
85
140
  return apiFetch(ctx, "/platform/v1/payment-methods");
86
141
  }
@@ -91,12 +146,12 @@ async function deletePaymentMethod(ctx, paymentMethodId) {
91
146
  );
92
147
  if (!response.ok) {
93
148
  const data = await response.json().catch(() => ({}));
94
- return err2({
149
+ return err3({
95
150
  code: data.code ?? "unknown_error",
96
151
  message: data.message ?? "Failed to delete payment method"
97
152
  });
98
153
  }
99
- return ok2(void 0);
154
+ return ok3(void 0);
100
155
  }
101
156
 
102
157
  // src/client.ts
@@ -116,7 +171,13 @@ function createClientCore(options) {
116
171
  getPaymentMethods: () => getPaymentMethods(ctx),
117
172
  listTransactions: (params) => listTransactions(ctx, params),
118
173
  getTransaction: (id) => getTransaction(ctx, id),
119
- deletePaymentMethod: (id) => deletePaymentMethod(ctx, id)
174
+ deletePaymentMethod: (id) => deletePaymentMethod(ctx, id),
175
+ createIdentity: (body) => createIdentity(ctx, body),
176
+ getIdentity: (id) => getIdentity(ctx, id),
177
+ updateIdentity: (id, body) => updateIdentity(ctx, id, body),
178
+ verifyIdentity: (id) => verifyIdentity(ctx, id),
179
+ getIdentityUploadUrl: (id, body) => getIdentityUploadUrl(ctx, id, body),
180
+ submitIdentityFiles: (id, body) => submitIdentityFiles(ctx, id, body)
120
181
  };
121
182
  }
122
183
 
@@ -1496,6 +1557,7 @@ function createFrameOrchestrator(options) {
1496
1557
  // src/frames/url-builder.ts
1497
1558
  var FRAME_PATHS = {
1498
1559
  connect: "/platform/v1/connect",
1560
+ auth: "/platform/v1/auth",
1499
1561
  checkConnection: "/platform/v1/check-connection",
1500
1562
  applePay: "/platform/v1/apple-pay",
1501
1563
  googlePay: "/platform/v1/google-pay",
@@ -1536,13 +1598,19 @@ export {
1536
1598
  createClientContext,
1537
1599
  createClientCore,
1538
1600
  createFrameOrchestrator,
1601
+ createIdentity,
1539
1602
  decryptCredentials,
1540
1603
  deletePaymentMethod,
1541
1604
  generateKeyPair,
1605
+ getIdentity,
1606
+ getIdentityUploadUrl,
1542
1607
  getPaymentMethods,
1543
1608
  getQuote,
1544
1609
  getTransaction,
1545
- listTransactions
1610
+ listTransactions,
1611
+ submitIdentityFiles,
1612
+ updateIdentity,
1613
+ verifyIdentity
1546
1614
  };
1547
1615
  /*! Bundled license information:
1548
1616