@moonpay/platform-sdk-web 0.3.0 → 1.0.2

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,7 +1,34 @@
1
- import * as _moonpay_platform_protocol from '@moonpay/platform-protocol';
2
- import { Result, Connection, GetConnectionError, ConnectEvent, ConnectError, AuthEvent, SetupAuthError, ListPaymentMethodsResponse, GetPaymentMethodsError, GetQuoteParams, Quote, GetQuoteError, Transaction, PaginationInfo, GetTransactionsError, TransactionWithStages, WidgetEvent, SetupWidgetError, ApplePayEvent, SetupApplePayError, GooglePayEvent, SetupGooglePayError, ResetConnectionError, BuyEvent, SetupBuyError, BuyButtonEvent, SetupBuyButtonError, ChallengeEvent, SetupChallengeError, AddCardEvent, SetupAddCardError, CreateIdentityRequestBody, Identity, CreateIdentityError, GetIdentityError, UpdateIdentityRequestBody, UpdateIdentityError, IdentityVerificationResponse, VerifyIdentityError, IdentityFileUploadUrlRequestBody, IdentityFileUploadUrl, GetIdentityUploadUrlError, SubmitIdentityFilesRequestBody, SubmitIdentityFilesError, ProtocolMessage } from '@moonpay/platform-protocol';
3
- export { AddCardEvent, ApplePayEvent, AuthEvent, BuyButtonEvent, BuyEvent, CardResponse, ChallengeCancellation, ChallengeCompleteResult, ChallengeEvent, ConnectEvent, Connection, ConnectionStatus, GetQuoteParams, GooglePayEvent, PaymentMethodConfig, PaymentMethodType, Quote, Result, StoredCardPaymentMethod, StoredPaymentMethod, Transaction, TransactionWithStages, WidgetEvent } from '@moonpay/platform-protocol';
1
+ import { ListPaymentMethodsResponse, GetQuoteParams, Quote, Transaction, PaginationInfo, TransactionWithStages } from '@moonpay/platform-protocol/api';
2
+ export { GetQuoteParams, ListPaymentMethodsResponse, PaginationInfo, PaymentMethodConfig, PaymentMethodType, Quote, StoredCardPaymentMethod, StoredPaymentMethod, Transaction, TransactionWithStages } from '@moonpay/platform-protocol/api';
3
+ export { CardResponse } from '@moonpay/platform-protocol/frames/add-card';
4
+ export { Cancellation as ChallengeCancellation, CompleteResult as ChallengeCompleteResult } from '@moonpay/platform-protocol/frames/challenge';
5
+ import { Connection } from '@moonpay/platform-protocol/models/connection';
6
+ export { Connection, ConnectionStatus } from '@moonpay/platform-protocol/models/connection';
7
+ import { Result } from '@moonpay/platform-protocol/result';
8
+ export { Result } from '@moonpay/platform-protocol/result';
9
+ import * as AddCardSdk from '@moonpay/platform-protocol/sdks/add-card';
10
+ export { Event as AddCardEvent, SetupError as SetupAddCardError } from '@moonpay/platform-protocol/sdks/add-card';
11
+ import * as ApplePaySdk from '@moonpay/platform-protocol/sdks/apple-pay';
12
+ export { Event as ApplePayEvent, SetupError as SetupApplePayError } from '@moonpay/platform-protocol/sdks/apple-pay';
13
+ import * as AuthSdk from '@moonpay/platform-protocol/sdks/auth';
14
+ export { Event as AuthEvent, SetupError as SetupAuthError } from '@moonpay/platform-protocol/sdks/auth';
15
+ import * as BuySdk from '@moonpay/platform-protocol/sdks/buy';
16
+ export { Event as BuyEvent, SetupError as SetupBuyError } from '@moonpay/platform-protocol/sdks/buy';
17
+ import * as BuyButtonSdk from '@moonpay/platform-protocol/sdks/buy-button';
18
+ export { Event as BuyButtonEvent, SetupError as SetupBuyButtonError } from '@moonpay/platform-protocol/sdks/buy-button';
19
+ import * as ChallengeSdk from '@moonpay/platform-protocol/sdks/challenge';
20
+ export { Event as ChallengeEvent, SetupError as SetupChallengeError } from '@moonpay/platform-protocol/sdks/challenge';
21
+ import * as ConnectSdk from '@moonpay/platform-protocol/sdks/connect';
22
+ export { Event as ConnectEvent } from '@moonpay/platform-protocol/sdks/connect';
23
+ import * as GooglePaySdk from '@moonpay/platform-protocol/sdks/google-pay';
24
+ export { Event as GooglePayEvent, SetupError as SetupGooglePayError } from '@moonpay/platform-protocol/sdks/google-pay';
25
+ import * as WidgetSdk from '@moonpay/platform-protocol/sdks/widget';
26
+ export { SetupError as SetupWidgetError, Event as WidgetEvent } from '@moonpay/platform-protocol/sdks/widget';
27
+ import { GetPaymentMethodsError, GetQuoteError, GetTransactionsError, DevPlatformApiError, CreateIdentityError, GetIdentityError, UpdateIdentityError, VerifyIdentityError, GetIdentityUploadUrlError, SubmitIdentityFilesError } from '@moonpay/platform-protocol/api/errors';
28
+ import { CreateIdentityRequestBody, Identity, UpdateIdentityRequestBody, IdentityVerificationResponse, IdentityFileUploadUrlRequestBody, IdentityFileUploadUrl, SubmitIdentityFilesRequestBody } from '@moonpay/platform-protocol/api/identity';
29
+ import { ResetConnectionError } from '@moonpay/platform-protocol/sdks/reset';
4
30
  import { ListTransactionsParams, FrameTransport, FrameOptions } from '@moonpay/platform-sdk-core';
31
+ import { ProtocolMessage } from '@moonpay/platform-protocol/protocol';
5
32
 
6
33
  interface CreateClientOptions {
7
34
  /** Session token from your server (via createSession). */
@@ -27,7 +54,7 @@ interface ConnectOptions {
27
54
  appearance?: 'light' | 'dark';
28
55
  };
29
56
  /** Callback for connect lifecycle events. */
30
- onEvent?: (event: ConnectEvent) => void;
57
+ onEvent?: (event: ConnectSdk.Event) => void;
31
58
  }
32
59
  interface ConnectFrame {
33
60
  dispose(): void;
@@ -38,7 +65,7 @@ interface SetupWidgetOptions {
38
65
  /** DOM element to render the widget into. */
39
66
  container: HTMLElement;
40
67
  /** Callback for widget lifecycle events. */
41
- onEvent?: (event: WidgetEvent) => void;
68
+ onEvent?: (event: WidgetSdk.Event) => void;
42
69
  }
43
70
  interface WidgetFrame {
44
71
  dispose(): void;
@@ -49,7 +76,7 @@ interface SetupApplePayOptions {
49
76
  /** DOM element to render the Apple Pay button into. */
50
77
  container: HTMLElement;
51
78
  /** Callback for Apple Pay lifecycle events. */
52
- onEvent?: (event: ApplePayEvent) => void;
79
+ onEvent?: (event: ApplePaySdk.Event) => void;
53
80
  }
54
81
  interface ApplePayFrame {
55
82
  /** Update the quote (e.g., after expiry). */
@@ -64,7 +91,7 @@ interface SetupGooglePayOptions {
64
91
  /** Partner-assigned identifier for this transaction attempt. */
65
92
  externalTransactionId?: string;
66
93
  /** Callback for Google Pay lifecycle events. */
67
- onEvent?: (event: GooglePayEvent) => void;
94
+ onEvent?: (event: GooglePaySdk.Event) => void;
68
95
  }
69
96
  interface GooglePayFrame {
70
97
  /** Update the quote (e.g., after expiry). */
@@ -79,7 +106,7 @@ interface SetupBuyOptions {
79
106
  /** Partner-assigned identifier for this transaction attempt. */
80
107
  externalTransactionId?: string;
81
108
  /** Callback for buy frame lifecycle events. */
82
- onEvent?: (event: BuyEvent) => void;
109
+ onEvent?: (event: BuySdk.Event) => void;
83
110
  }
84
111
  interface BuyFrame {
85
112
  /** Update the quote (e.g., after expiry). */
@@ -92,7 +119,7 @@ interface SetupBuyButtonOptions {
92
119
  /** DOM element to render the buy button into. */
93
120
  container: HTMLElement;
94
121
  /** Callback for buy-button frame lifecycle events. */
95
- onEvent?: (event: BuyButtonEvent) => void;
122
+ onEvent?: (event: BuyButtonSdk.Event) => void;
96
123
  }
97
124
  interface BuyButtonFrame {
98
125
  /** Update the quote (e.g., after expiry). */
@@ -100,12 +127,12 @@ interface BuyButtonFrame {
100
127
  dispose(): void;
101
128
  }
102
129
  interface SetupChallengeOptions {
103
- /** Full challenge URL received from the buy or buy-button frame's `challenge` event. */
130
+ /** Full challenge URL received from a frame's `challenge` event (buy, buy-button, Apple Pay, or Google Pay). */
104
131
  url: string;
105
132
  /** DOM element to render the challenge frame into. */
106
133
  container: HTMLElement;
107
134
  /** Callback for challenge frame lifecycle events. */
108
- onEvent?: (event: ChallengeEvent) => void;
135
+ onEvent?: (event: ChallengeSdk.Event) => void;
109
136
  }
110
137
  interface ChallengeFrame {
111
138
  dispose(): void;
@@ -114,7 +141,7 @@ interface SetupAddCardOptions {
114
141
  /** DOM element to render the add-card frame into. */
115
142
  container: HTMLElement;
116
143
  /** Callback for add-card frame lifecycle events. */
117
- onEvent?: (event: AddCardEvent) => void;
144
+ onEvent?: (event: AddCardSdk.Event) => void;
118
145
  }
119
146
  interface AddCardFrame {
120
147
  dispose(): void;
@@ -123,7 +150,7 @@ interface SetupAuthOptions {
123
150
  /** DOM element to render the auth frame into. */
124
151
  container: HTMLElement;
125
152
  /** Callback for auth frame lifecycle events. */
126
- onEvent?: (event: AuthEvent) => void;
153
+ onEvent?: (event: AuthSdk.Event) => void;
127
154
  }
128
155
  interface AuthFrame {
129
156
  dispose(): void;
@@ -140,8 +167,8 @@ interface Client {
140
167
  * surfaces `termsAcceptanceRequired` (legal can't be skipped) but won't
141
168
  * resolve to `pending` / `failed` due to KYC alone.
142
169
  */
143
- getConnection(options?: GetConnectionOptions): Promise<Result<Connection, GetConnectionError>>;
144
- connect(options: ConnectOptions): Promise<Result<ConnectFrame, ConnectError>>;
170
+ getConnection(options?: GetConnectionOptions): Promise<Result<Connection, ConnectSdk.GetConnectionError>>;
171
+ connect(options: ConnectOptions): Promise<Result<ConnectFrame, ConnectSdk.ConnectError>>;
145
172
  /**
146
173
  * Launch the auth frame — the lighter-weight counterpart to `connect()`
147
174
  * for headless / Identity-API partners. Requires a `clientToken` to be
@@ -150,8 +177,10 @@ interface Client {
150
177
  * Call `getConnection()` first; if its status is `connectionRequired`,
151
178
  * call `setupAuth()` to drive the customer through email/OTP.
152
179
  */
153
- setupAuth(options: SetupAuthOptions): Promise<Result<AuthFrame, SetupAuthError>>;
154
- getPaymentMethods(): Promise<Result<ListPaymentMethodsResponse, GetPaymentMethodsError>>;
180
+ setupAuth(options: SetupAuthOptions): Promise<Result<AuthFrame, AuthSdk.SetupError>>;
181
+ getPaymentMethods(): Promise<Result<{
182
+ data: ListPaymentMethodsResponse;
183
+ }, GetPaymentMethodsError>>;
155
184
  getQuote(params: GetQuoteParams): Promise<Result<{
156
185
  data: Quote;
157
186
  }, GetQuoteError>>;
@@ -162,10 +191,10 @@ interface Client {
162
191
  getTransaction(id: string): Promise<Result<{
163
192
  data: TransactionWithStages;
164
193
  }, GetTransactionsError>>;
165
- setupWidget(options: SetupWidgetOptions): Promise<Result<WidgetFrame, SetupWidgetError>>;
166
- setupApplePay(options: SetupApplePayOptions): Promise<Result<ApplePayFrame, SetupApplePayError>>;
167
- setupGooglePay(options: SetupGooglePayOptions): Promise<Result<GooglePayFrame, SetupGooglePayError>>;
168
- deletePaymentMethod(id: string): Promise<Result<void, _moonpay_platform_protocol.DevPlatformApiError>>;
194
+ setupWidget(options: SetupWidgetOptions): Promise<Result<WidgetFrame, WidgetSdk.SetupError>>;
195
+ setupApplePay(options: SetupApplePayOptions): Promise<Result<ApplePayFrame, ApplePaySdk.SetupError>>;
196
+ setupGooglePay(options: SetupGooglePayOptions): Promise<Result<GooglePayFrame, GooglePaySdk.SetupError>>;
197
+ deletePaymentMethod(id: string): Promise<Result<void, DevPlatformApiError>>;
169
198
  /**
170
199
  * Clears the customer's MoonPay connection for this partner by running the
171
200
  * reset frame. Resolves when the reset completes or times out (5s).
@@ -173,10 +202,10 @@ interface Client {
173
202
  * can be captured before disposal since the session token is baked in).
174
203
  */
175
204
  resetConnection(): Promise<Result<void, ResetConnectionError>>;
176
- setupBuy(options: SetupBuyOptions): Promise<Result<BuyFrame, SetupBuyError>>;
177
- setupBuyButton(options: SetupBuyButtonOptions): Promise<Result<BuyButtonFrame, SetupBuyButtonError>>;
178
- setupChallenge(options: SetupChallengeOptions): Promise<Result<ChallengeFrame, SetupChallengeError>>;
179
- setupAddCard(options: SetupAddCardOptions): Promise<Result<AddCardFrame, SetupAddCardError>>;
205
+ setupBuy(options: SetupBuyOptions): Promise<Result<BuyFrame, BuySdk.SetupError>>;
206
+ setupBuyButton(options: SetupBuyButtonOptions): Promise<Result<BuyButtonFrame, BuyButtonSdk.SetupError>>;
207
+ setupChallenge(options: SetupChallengeOptions): Promise<Result<ChallengeFrame, ChallengeSdk.SetupError>>;
208
+ setupAddCard(options: SetupAddCardOptions): Promise<Result<AddCardFrame, AddCardSdk.SetupError>>;
180
209
  /**
181
210
  * Create an identity for the customer bound to the credential. The API
182
211
  * returns `data: null` (HTTP 204) when the customer has no outstanding
package/dist/index.d.ts CHANGED
@@ -1,7 +1,34 @@
1
- import * as _moonpay_platform_protocol from '@moonpay/platform-protocol';
2
- import { Result, Connection, GetConnectionError, ConnectEvent, ConnectError, AuthEvent, SetupAuthError, ListPaymentMethodsResponse, GetPaymentMethodsError, GetQuoteParams, Quote, GetQuoteError, Transaction, PaginationInfo, GetTransactionsError, TransactionWithStages, WidgetEvent, SetupWidgetError, ApplePayEvent, SetupApplePayError, GooglePayEvent, SetupGooglePayError, ResetConnectionError, BuyEvent, SetupBuyError, BuyButtonEvent, SetupBuyButtonError, ChallengeEvent, SetupChallengeError, AddCardEvent, SetupAddCardError, CreateIdentityRequestBody, Identity, CreateIdentityError, GetIdentityError, UpdateIdentityRequestBody, UpdateIdentityError, IdentityVerificationResponse, VerifyIdentityError, IdentityFileUploadUrlRequestBody, IdentityFileUploadUrl, GetIdentityUploadUrlError, SubmitIdentityFilesRequestBody, SubmitIdentityFilesError, ProtocolMessage } from '@moonpay/platform-protocol';
3
- export { AddCardEvent, ApplePayEvent, AuthEvent, BuyButtonEvent, BuyEvent, CardResponse, ChallengeCancellation, ChallengeCompleteResult, ChallengeEvent, ConnectEvent, Connection, ConnectionStatus, GetQuoteParams, GooglePayEvent, PaymentMethodConfig, PaymentMethodType, Quote, Result, StoredCardPaymentMethod, StoredPaymentMethod, Transaction, TransactionWithStages, WidgetEvent } from '@moonpay/platform-protocol';
1
+ import { ListPaymentMethodsResponse, GetQuoteParams, Quote, Transaction, PaginationInfo, TransactionWithStages } from '@moonpay/platform-protocol/api';
2
+ export { GetQuoteParams, ListPaymentMethodsResponse, PaginationInfo, PaymentMethodConfig, PaymentMethodType, Quote, StoredCardPaymentMethod, StoredPaymentMethod, Transaction, TransactionWithStages } from '@moonpay/platform-protocol/api';
3
+ export { CardResponse } from '@moonpay/platform-protocol/frames/add-card';
4
+ export { Cancellation as ChallengeCancellation, CompleteResult as ChallengeCompleteResult } from '@moonpay/platform-protocol/frames/challenge';
5
+ import { Connection } from '@moonpay/platform-protocol/models/connection';
6
+ export { Connection, ConnectionStatus } from '@moonpay/platform-protocol/models/connection';
7
+ import { Result } from '@moonpay/platform-protocol/result';
8
+ export { Result } from '@moonpay/platform-protocol/result';
9
+ import * as AddCardSdk from '@moonpay/platform-protocol/sdks/add-card';
10
+ export { Event as AddCardEvent, SetupError as SetupAddCardError } from '@moonpay/platform-protocol/sdks/add-card';
11
+ import * as ApplePaySdk from '@moonpay/platform-protocol/sdks/apple-pay';
12
+ export { Event as ApplePayEvent, SetupError as SetupApplePayError } from '@moonpay/platform-protocol/sdks/apple-pay';
13
+ import * as AuthSdk from '@moonpay/platform-protocol/sdks/auth';
14
+ export { Event as AuthEvent, SetupError as SetupAuthError } from '@moonpay/platform-protocol/sdks/auth';
15
+ import * as BuySdk from '@moonpay/platform-protocol/sdks/buy';
16
+ export { Event as BuyEvent, SetupError as SetupBuyError } from '@moonpay/platform-protocol/sdks/buy';
17
+ import * as BuyButtonSdk from '@moonpay/platform-protocol/sdks/buy-button';
18
+ export { Event as BuyButtonEvent, SetupError as SetupBuyButtonError } from '@moonpay/platform-protocol/sdks/buy-button';
19
+ import * as ChallengeSdk from '@moonpay/platform-protocol/sdks/challenge';
20
+ export { Event as ChallengeEvent, SetupError as SetupChallengeError } from '@moonpay/platform-protocol/sdks/challenge';
21
+ import * as ConnectSdk from '@moonpay/platform-protocol/sdks/connect';
22
+ export { Event as ConnectEvent } from '@moonpay/platform-protocol/sdks/connect';
23
+ import * as GooglePaySdk from '@moonpay/platform-protocol/sdks/google-pay';
24
+ export { Event as GooglePayEvent, SetupError as SetupGooglePayError } from '@moonpay/platform-protocol/sdks/google-pay';
25
+ import * as WidgetSdk from '@moonpay/platform-protocol/sdks/widget';
26
+ export { SetupError as SetupWidgetError, Event as WidgetEvent } from '@moonpay/platform-protocol/sdks/widget';
27
+ import { GetPaymentMethodsError, GetQuoteError, GetTransactionsError, DevPlatformApiError, CreateIdentityError, GetIdentityError, UpdateIdentityError, VerifyIdentityError, GetIdentityUploadUrlError, SubmitIdentityFilesError } from '@moonpay/platform-protocol/api/errors';
28
+ import { CreateIdentityRequestBody, Identity, UpdateIdentityRequestBody, IdentityVerificationResponse, IdentityFileUploadUrlRequestBody, IdentityFileUploadUrl, SubmitIdentityFilesRequestBody } from '@moonpay/platform-protocol/api/identity';
29
+ import { ResetConnectionError } from '@moonpay/platform-protocol/sdks/reset';
4
30
  import { ListTransactionsParams, FrameTransport, FrameOptions } from '@moonpay/platform-sdk-core';
31
+ import { ProtocolMessage } from '@moonpay/platform-protocol/protocol';
5
32
 
6
33
  interface CreateClientOptions {
7
34
  /** Session token from your server (via createSession). */
@@ -27,7 +54,7 @@ interface ConnectOptions {
27
54
  appearance?: 'light' | 'dark';
28
55
  };
29
56
  /** Callback for connect lifecycle events. */
30
- onEvent?: (event: ConnectEvent) => void;
57
+ onEvent?: (event: ConnectSdk.Event) => void;
31
58
  }
32
59
  interface ConnectFrame {
33
60
  dispose(): void;
@@ -38,7 +65,7 @@ interface SetupWidgetOptions {
38
65
  /** DOM element to render the widget into. */
39
66
  container: HTMLElement;
40
67
  /** Callback for widget lifecycle events. */
41
- onEvent?: (event: WidgetEvent) => void;
68
+ onEvent?: (event: WidgetSdk.Event) => void;
42
69
  }
43
70
  interface WidgetFrame {
44
71
  dispose(): void;
@@ -49,7 +76,7 @@ interface SetupApplePayOptions {
49
76
  /** DOM element to render the Apple Pay button into. */
50
77
  container: HTMLElement;
51
78
  /** Callback for Apple Pay lifecycle events. */
52
- onEvent?: (event: ApplePayEvent) => void;
79
+ onEvent?: (event: ApplePaySdk.Event) => void;
53
80
  }
54
81
  interface ApplePayFrame {
55
82
  /** Update the quote (e.g., after expiry). */
@@ -64,7 +91,7 @@ interface SetupGooglePayOptions {
64
91
  /** Partner-assigned identifier for this transaction attempt. */
65
92
  externalTransactionId?: string;
66
93
  /** Callback for Google Pay lifecycle events. */
67
- onEvent?: (event: GooglePayEvent) => void;
94
+ onEvent?: (event: GooglePaySdk.Event) => void;
68
95
  }
69
96
  interface GooglePayFrame {
70
97
  /** Update the quote (e.g., after expiry). */
@@ -79,7 +106,7 @@ interface SetupBuyOptions {
79
106
  /** Partner-assigned identifier for this transaction attempt. */
80
107
  externalTransactionId?: string;
81
108
  /** Callback for buy frame lifecycle events. */
82
- onEvent?: (event: BuyEvent) => void;
109
+ onEvent?: (event: BuySdk.Event) => void;
83
110
  }
84
111
  interface BuyFrame {
85
112
  /** Update the quote (e.g., after expiry). */
@@ -92,7 +119,7 @@ interface SetupBuyButtonOptions {
92
119
  /** DOM element to render the buy button into. */
93
120
  container: HTMLElement;
94
121
  /** Callback for buy-button frame lifecycle events. */
95
- onEvent?: (event: BuyButtonEvent) => void;
122
+ onEvent?: (event: BuyButtonSdk.Event) => void;
96
123
  }
97
124
  interface BuyButtonFrame {
98
125
  /** Update the quote (e.g., after expiry). */
@@ -100,12 +127,12 @@ interface BuyButtonFrame {
100
127
  dispose(): void;
101
128
  }
102
129
  interface SetupChallengeOptions {
103
- /** Full challenge URL received from the buy or buy-button frame's `challenge` event. */
130
+ /** Full challenge URL received from a frame's `challenge` event (buy, buy-button, Apple Pay, or Google Pay). */
104
131
  url: string;
105
132
  /** DOM element to render the challenge frame into. */
106
133
  container: HTMLElement;
107
134
  /** Callback for challenge frame lifecycle events. */
108
- onEvent?: (event: ChallengeEvent) => void;
135
+ onEvent?: (event: ChallengeSdk.Event) => void;
109
136
  }
110
137
  interface ChallengeFrame {
111
138
  dispose(): void;
@@ -114,7 +141,7 @@ interface SetupAddCardOptions {
114
141
  /** DOM element to render the add-card frame into. */
115
142
  container: HTMLElement;
116
143
  /** Callback for add-card frame lifecycle events. */
117
- onEvent?: (event: AddCardEvent) => void;
144
+ onEvent?: (event: AddCardSdk.Event) => void;
118
145
  }
119
146
  interface AddCardFrame {
120
147
  dispose(): void;
@@ -123,7 +150,7 @@ interface SetupAuthOptions {
123
150
  /** DOM element to render the auth frame into. */
124
151
  container: HTMLElement;
125
152
  /** Callback for auth frame lifecycle events. */
126
- onEvent?: (event: AuthEvent) => void;
153
+ onEvent?: (event: AuthSdk.Event) => void;
127
154
  }
128
155
  interface AuthFrame {
129
156
  dispose(): void;
@@ -140,8 +167,8 @@ interface Client {
140
167
  * surfaces `termsAcceptanceRequired` (legal can't be skipped) but won't
141
168
  * resolve to `pending` / `failed` due to KYC alone.
142
169
  */
143
- getConnection(options?: GetConnectionOptions): Promise<Result<Connection, GetConnectionError>>;
144
- connect(options: ConnectOptions): Promise<Result<ConnectFrame, ConnectError>>;
170
+ getConnection(options?: GetConnectionOptions): Promise<Result<Connection, ConnectSdk.GetConnectionError>>;
171
+ connect(options: ConnectOptions): Promise<Result<ConnectFrame, ConnectSdk.ConnectError>>;
145
172
  /**
146
173
  * Launch the auth frame — the lighter-weight counterpart to `connect()`
147
174
  * for headless / Identity-API partners. Requires a `clientToken` to be
@@ -150,8 +177,10 @@ interface Client {
150
177
  * Call `getConnection()` first; if its status is `connectionRequired`,
151
178
  * call `setupAuth()` to drive the customer through email/OTP.
152
179
  */
153
- setupAuth(options: SetupAuthOptions): Promise<Result<AuthFrame, SetupAuthError>>;
154
- getPaymentMethods(): Promise<Result<ListPaymentMethodsResponse, GetPaymentMethodsError>>;
180
+ setupAuth(options: SetupAuthOptions): Promise<Result<AuthFrame, AuthSdk.SetupError>>;
181
+ getPaymentMethods(): Promise<Result<{
182
+ data: ListPaymentMethodsResponse;
183
+ }, GetPaymentMethodsError>>;
155
184
  getQuote(params: GetQuoteParams): Promise<Result<{
156
185
  data: Quote;
157
186
  }, GetQuoteError>>;
@@ -162,10 +191,10 @@ interface Client {
162
191
  getTransaction(id: string): Promise<Result<{
163
192
  data: TransactionWithStages;
164
193
  }, GetTransactionsError>>;
165
- setupWidget(options: SetupWidgetOptions): Promise<Result<WidgetFrame, SetupWidgetError>>;
166
- setupApplePay(options: SetupApplePayOptions): Promise<Result<ApplePayFrame, SetupApplePayError>>;
167
- setupGooglePay(options: SetupGooglePayOptions): Promise<Result<GooglePayFrame, SetupGooglePayError>>;
168
- deletePaymentMethod(id: string): Promise<Result<void, _moonpay_platform_protocol.DevPlatformApiError>>;
194
+ setupWidget(options: SetupWidgetOptions): Promise<Result<WidgetFrame, WidgetSdk.SetupError>>;
195
+ setupApplePay(options: SetupApplePayOptions): Promise<Result<ApplePayFrame, ApplePaySdk.SetupError>>;
196
+ setupGooglePay(options: SetupGooglePayOptions): Promise<Result<GooglePayFrame, GooglePaySdk.SetupError>>;
197
+ deletePaymentMethod(id: string): Promise<Result<void, DevPlatformApiError>>;
169
198
  /**
170
199
  * Clears the customer's MoonPay connection for this partner by running the
171
200
  * reset frame. Resolves when the reset completes or times out (5s).
@@ -173,10 +202,10 @@ interface Client {
173
202
  * can be captured before disposal since the session token is baked in).
174
203
  */
175
204
  resetConnection(): Promise<Result<void, ResetConnectionError>>;
176
- setupBuy(options: SetupBuyOptions): Promise<Result<BuyFrame, SetupBuyError>>;
177
- setupBuyButton(options: SetupBuyButtonOptions): Promise<Result<BuyButtonFrame, SetupBuyButtonError>>;
178
- setupChallenge(options: SetupChallengeOptions): Promise<Result<ChallengeFrame, SetupChallengeError>>;
179
- setupAddCard(options: SetupAddCardOptions): Promise<Result<AddCardFrame, SetupAddCardError>>;
205
+ setupBuy(options: SetupBuyOptions): Promise<Result<BuyFrame, BuySdk.SetupError>>;
206
+ setupBuyButton(options: SetupBuyButtonOptions): Promise<Result<BuyButtonFrame, BuyButtonSdk.SetupError>>;
207
+ setupChallenge(options: SetupChallengeOptions): Promise<Result<ChallengeFrame, ChallengeSdk.SetupError>>;
208
+ setupAddCard(options: SetupAddCardOptions): Promise<Result<AddCardFrame, AddCardSdk.SetupError>>;
180
209
  /**
181
210
  * Create an identity for the customer bound to the credential. The API
182
211
  * returns `data: null` (HTTP 204) when the customer has no outstanding
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
+ // src/index.ts
2
+ import { ConnectionStatus as ConnectionStatus2 } from "@moonpay/platform-protocol/models/connection";
3
+
1
4
  // src/client.ts
2
- import {
3
- ConnectionStatus,
4
- err,
5
- ok
6
- } from "@moonpay/platform-protocol";
5
+ import { ConnectionStatus } from "@moonpay/platform-protocol/models/connection";
6
+ import { err, ok } from "@moonpay/platform-protocol/result";
7
7
  import {
8
8
  buildFrameUrl,
9
9
  createClientCore,
@@ -380,6 +380,12 @@ function createClient(options) {
380
380
  payload: msg.payload
381
381
  });
382
382
  break;
383
+ case "challenge":
384
+ opts.onEvent?.({
385
+ kind: "challenge",
386
+ payload: msg.payload
387
+ });
388
+ break;
383
389
  case "error": {
384
390
  const payload = msg.payload;
385
391
  if (payload.code === "quoteExpired") {
@@ -656,10 +662,16 @@ function createClient(options) {
656
662
  opts.onEvent?.({ kind: "ready" });
657
663
  break;
658
664
  case "complete":
659
- opts.onEvent?.({ kind: "complete", payload: msg.payload });
665
+ opts.onEvent?.({
666
+ kind: "complete",
667
+ payload: msg.payload
668
+ });
660
669
  break;
661
670
  case "cancelled":
662
- opts.onEvent?.({ kind: "cancelled", payload: msg.payload });
671
+ opts.onEvent?.({
672
+ kind: "cancelled",
673
+ payload: msg.payload
674
+ });
663
675
  break;
664
676
  case "error":
665
677
  opts.onEvent?.({
@@ -694,8 +706,14 @@ function createClient(options) {
694
706
  });
695
707
  handle.onMessage((msg) => {
696
708
  switch (msg.kind) {
709
+ case "ready":
710
+ opts.onEvent?.({ kind: "ready" });
711
+ break;
697
712
  case "complete":
698
- opts.onEvent?.({ kind: "complete", payload: msg.payload });
713
+ opts.onEvent?.({
714
+ kind: "complete",
715
+ payload: msg.payload
716
+ });
699
717
  break;
700
718
  case "error":
701
719
  opts.onEvent?.({
@@ -739,6 +757,7 @@ function createClient(options) {
739
757
  };
740
758
  }
741
759
  export {
760
+ ConnectionStatus2 as ConnectionStatus,
742
761
  IframeTransport,
743
762
  createClient
744
763
  };