@moonpay/platform-sdk-core 0.2.1 → 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.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
 
@@ -113,6 +136,24 @@ interface CoreClient {
113
136
  data: TransactionWithStages;
114
137
  }, GetTransactionsError>>;
115
138
  deletePaymentMethod(id: string): Promise<Result<void, DevPlatformApiError>>;
139
+ createIdentity(body: CreateIdentityRequestBody): Promise<Result<{
140
+ data: Identity | null;
141
+ }, CreateIdentityError>>;
142
+ getIdentity(id: string): Promise<Result<{
143
+ data: Identity;
144
+ }, GetIdentityError>>;
145
+ updateIdentity(id: string, body: UpdateIdentityRequestBody): Promise<Result<{
146
+ data: Identity;
147
+ }, UpdateIdentityError>>;
148
+ verifyIdentity(id: string): Promise<Result<{
149
+ data: IdentityVerificationResponse;
150
+ }, VerifyIdentityError>>;
151
+ getIdentityUploadUrl(id: string, body: IdentityFileUploadUrlRequestBody): Promise<Result<{
152
+ data: IdentityFileUploadUrl;
153
+ }, GetIdentityUploadUrlError>>;
154
+ submitIdentityFiles(id: string, body: SubmitIdentityFilesRequestBody): Promise<Result<{
155
+ data: Identity;
156
+ }, SubmitIdentityFilesError>>;
116
157
  }
117
158
  /**
118
159
  * Creates the platform-agnostic core client.
@@ -164,4 +205,4 @@ interface FrameHandle {
164
205
  */
165
206
  declare function createFrameOrchestrator(options: FrameOrchestratorOptions): Promise<FrameHandle>;
166
207
 
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 };
208
+ 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
 
@@ -113,6 +136,24 @@ interface CoreClient {
113
136
  data: TransactionWithStages;
114
137
  }, GetTransactionsError>>;
115
138
  deletePaymentMethod(id: string): Promise<Result<void, DevPlatformApiError>>;
139
+ createIdentity(body: CreateIdentityRequestBody): Promise<Result<{
140
+ data: Identity | null;
141
+ }, CreateIdentityError>>;
142
+ getIdentity(id: string): Promise<Result<{
143
+ data: Identity;
144
+ }, GetIdentityError>>;
145
+ updateIdentity(id: string, body: UpdateIdentityRequestBody): Promise<Result<{
146
+ data: Identity;
147
+ }, UpdateIdentityError>>;
148
+ verifyIdentity(id: string): Promise<Result<{
149
+ data: IdentityVerificationResponse;
150
+ }, VerifyIdentityError>>;
151
+ getIdentityUploadUrl(id: string, body: IdentityFileUploadUrlRequestBody): Promise<Result<{
152
+ data: IdentityFileUploadUrl;
153
+ }, GetIdentityUploadUrlError>>;
154
+ submitIdentityFiles(id: string, body: SubmitIdentityFilesRequestBody): Promise<Result<{
155
+ data: Identity;
156
+ }, SubmitIdentityFilesError>>;
116
157
  }
117
158
  /**
118
159
  * Creates the platform-agnostic core client.
@@ -164,4 +205,4 @@ interface FrameHandle {
164
205
  */
165
206
  declare function createFrameOrchestrator(options: FrameOrchestratorOptions): Promise<FrameHandle>;
166
207
 
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 };
208
+ 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
 
@@ -1537,13 +1598,19 @@ export {
1537
1598
  createClientContext,
1538
1599
  createClientCore,
1539
1600
  createFrameOrchestrator,
1601
+ createIdentity,
1540
1602
  decryptCredentials,
1541
1603
  deletePaymentMethod,
1542
1604
  generateKeyPair,
1605
+ getIdentity,
1606
+ getIdentityUploadUrl,
1543
1607
  getPaymentMethods,
1544
1608
  getQuote,
1545
1609
  getTransaction,
1546
- listTransactions
1610
+ listTransactions,
1611
+ submitIdentityFiles,
1612
+ updateIdentity,
1613
+ verifyIdentity
1547
1614
  };
1548
1615
  /*! Bundled license information:
1549
1616