@funkit/api-base 1.8.3 → 1.9.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.
@@ -54,6 +54,10 @@ export declare function getCheckoutsByFunWalletAddress({ funWalletAddress, ...op
54
54
  export declare function getCheckoutsByRecipientAddress({ recipientAddress, ...options }: BaseApiRequest & {
55
55
  recipientAddress: Address;
56
56
  }): Promise<CheckoutHistoryItem[]>;
57
+ export interface GetCheckoutsByUserIdParams extends BaseApiRequest {
58
+ userId: string;
59
+ limit?: number;
60
+ }
57
61
  /**
58
62
  * Gets all checkouts associated with a funkit userId string
59
63
  * @param userId A userId string.
@@ -61,9 +65,7 @@ export declare function getCheckoutsByRecipientAddress({ recipientAddress, ...op
61
65
  * @param signal AbortSignal to cancel the request when no longer needed
62
66
  * @returns A list of checkout objects if exists. Otherwise, an empty array.
63
67
  */
64
- export declare function getCheckoutsByUserId({ userId, ...options }: BaseApiRequest & {
65
- userId: string;
66
- }): Promise<CheckoutHistoryItem[]>;
68
+ export declare function getCheckoutsByUserId({ userId, limit, ...options }: GetCheckoutsByUserIdParams): Promise<CheckoutHistoryItem[]>;
67
69
  export declare function getPaymasterDataForCheckoutSponsoredTransfer({ depositAddress, transferUserOp, ...options }: CheckoutTransferSponsorshipParams): Promise<CheckoutTransferSponsorshipResponse>;
68
70
  export declare function getRiskAssessmentForAddress({ address, ...options }: RiskAssessmentParams): Promise<RiskAssessmentResponse>;
69
71
  export declare function initializeCheckoutTokenTransferAddress({ apiKey, logger, signal, ...body }: CheckoutInitTokenTransferAddressParams): Promise<CheckoutInitTokenTransferResponse>;
@@ -1,6 +1,6 @@
1
1
  import type { DirectExecution, GetDirectExecutionByTxHashRequest, GetDirectExecutionsByUserIdRequest, PostDirectExecutionRequest } from './types';
2
2
  export declare function getDirectExecutionByTxHash({ txHash, apiKey, logger, signal, }: GetDirectExecutionByTxHashRequest): Promise<DirectExecution>;
3
- export declare function getDirectExecutionsByUserId({ userId, apiKey, logger, signal, }: GetDirectExecutionsByUserIdRequest): Promise<DirectExecution[]>;
3
+ export declare function getDirectExecutionsByUserId({ userId, apiKey, logger, limit, signal, }: GetDirectExecutionsByUserIdRequest): Promise<DirectExecution[]>;
4
4
  export declare function createDirectExecution({ txHash, userId, recipientAddr, fromChainId, fromTokenAddress, toChainId, toTokenAddress, fromAmountBaseUnit, toAmountBaseUnit, estTotalUsd, sourceOfFund, clientMetadata, apiKey, logger, signal, type, }: PostDirectExecutionRequest): Promise<{
5
5
  txHash: DirectExecution['txHash'];
6
6
  }>;
@@ -6,6 +6,7 @@ export interface GetDirectExecutionByTxHashRequest extends BaseApiRequest {
6
6
  }
7
7
  export interface GetDirectExecutionsByUserIdRequest extends BaseApiRequest {
8
8
  userId: string;
9
+ limit?: number;
9
10
  }
10
11
  export declare enum DirectExecutionType {
11
12
  TEST_EXECUTION = "TEST_EXECUTION",// For UT purposes only, should never show up in prod table
@@ -22,6 +23,15 @@ export declare enum RelayExecutionStatus {
22
23
  WAITING = "waiting",
23
24
  UNKNOWN = "unknown"
24
25
  }
26
+ export interface RelayExecutionRequestFeeData {
27
+ fees: Fee;
28
+ feesUsd: Fee;
29
+ }
30
+ export interface Fee {
31
+ gas: bigint;
32
+ fixed: bigint;
33
+ price: bigint;
34
+ }
25
35
  export interface DirectExecution {
26
36
  txHash: Hex;
27
37
  customerId: string;
@@ -38,8 +48,21 @@ export interface DirectExecution {
38
48
  sourceOfFund: string;
39
49
  clientMetadata: ApiCheckoutClientMetadata;
40
50
  createdTimeMs: number;
51
+ updatedTimeMs?: number;
41
52
  listenerInfo?: {
42
- status?: RelayExecutionStatus;
53
+ status: RelayExecutionStatus;
54
+ inTxHashes: string[];
55
+ txHashes: string[];
56
+ time: number;
57
+ originChainId: number;
58
+ destinationChainId: number;
59
+ relayExecutionRequestDetails?: {
60
+ id: Hex;
61
+ status: RelayExecutionStatus;
62
+ createdAt: Date;
63
+ updatedAt: Date;
64
+ data: RelayExecutionRequestFeeData;
65
+ };
43
66
  };
44
67
  }
45
68
  export interface PostDirectExecutionRequest extends BaseApiRequest, Omit<DirectExecution, 'customerId' | 'createdTimeMs'> {
@@ -9,7 +9,9 @@ export * from './fw-info';
9
9
  export * from './fw-operation';
10
10
  export * from './fw-paymaster';
11
11
  export * from './fw-user';
12
+ export * from './meld';
12
13
  export * from './mesh';
13
14
  export * from './moonpay';
15
+ export * from './organization';
14
16
  export * from './stripe';
15
17
  export * from './support';
@@ -0,0 +1,15 @@
1
+ import { type BaseApiRequest } from '../../consts';
2
+ import type { GetCryptoPurchaseLimitsParams, MeldCreateCryptoQuoteParams, MeldCreateCryptoQuoteResponse, MeldCreateCryptoWidgetParams, MeldCreateCryptoWidgetResponse, MeldDefaultFiatResponse, MeldFiatLimitResponse, MeldSupportedFiatResponse, SearchDefaultFiatParams } from './types';
3
+ export declare function getMeldSupportedFiat({ ...options }: BaseApiRequest): Promise<MeldSupportedFiatResponse>;
4
+ export declare function getMeldQuotes({ params, ...options }: BaseApiRequest & {
5
+ params: MeldCreateCryptoQuoteParams;
6
+ }): Promise<MeldCreateCryptoQuoteResponse>;
7
+ export declare function startMeldSession({ params, ...options }: BaseApiRequest & {
8
+ params: MeldCreateCryptoWidgetParams['sessionData'];
9
+ }): Promise<MeldCreateCryptoWidgetResponse>;
10
+ export declare function getMeldDefaultFiat({ params, ...options }: BaseApiRequest & {
11
+ params: SearchDefaultFiatParams;
12
+ }): Promise<MeldDefaultFiatResponse>;
13
+ export declare function getMeldFiatLimits({ params, ...options }: BaseApiRequest & {
14
+ params: GetCryptoPurchaseLimitsParams;
15
+ }): Promise<MeldFiatLimitResponse>;
@@ -0,0 +1,2 @@
1
+ export * from './endpoints';
2
+ export * from './types';
@@ -0,0 +1,330 @@
1
+ export declare enum MeldServiceProvider {
2
+ ALCHEMYPAY = "ALCHEMYPAY",
3
+ BANXA = "BANXA",
4
+ BILIRA = "BILIRA",
5
+ BINANCECONNECT = "BINANCECONNECT",
6
+ BLOCKCHAINDOTCOM = "BLOCKCHAINDOTCOM",
7
+ BTCDIRECT = "BTCDIRECT",
8
+ COINBASEPAY = "COINBASEPAY",
9
+ FONBNK = "FONBNK",
10
+ GUARDARIAN = "GUARDARIAN",
11
+ KOYWE = "KOYWE",
12
+ MESH = "MESH",
13
+ MESO = "MESO",
14
+ ONMETA = "ONMETA",
15
+ ONRAMPMONEY = "ONRAMPMONEY",
16
+ PAYBIS = "PAYBIS",
17
+ PAYPAL = "PAYPAL",
18
+ RAMP = "RAMP",
19
+ ROBINHOOD = "ROBINHOOD",
20
+ SARDINE = "SARDINE",
21
+ SHIFT4 = "SHIFT4",
22
+ SIMPLEX = "SIMPLEX",
23
+ SKRILLCRYPTO = "SKRILLCRYPTO",
24
+ STRIPE = "STRIPE",
25
+ TOPPER = "TOPPER",
26
+ TRANSAK = "TRANSAK",
27
+ TRANSFI = "TRANSFI",
28
+ UNLIMIT = "UNLIMIT",
29
+ YELLOWCARD = "YELLOWCARD"
30
+ }
31
+ export declare const MELD_PROVIDER_CATEGORIES: readonly ["BANK_LINKING", "CRYPTO_ONRAMP", "CRYPTO_OFFRAMP", "CRYPTO_TRANSFER", "FIAT_PAYMENTS"];
32
+ export type MeldFiatCurrency = {
33
+ /** fiat code. e.g. USD/EUR */
34
+ currencyCode: string;
35
+ /** fiat name. e.g. United State Dollar */
36
+ name: string;
37
+ /** image URL for the currency symbol provided by meld */
38
+ symbolImageUrl: string;
39
+ };
40
+ export type MeldDefaultFiatCurrency = {
41
+ /** Two-letter code (ISO 3166-1 alpha-2) for the Country. */
42
+ countryCode: string;
43
+ /** fiat code. e.g. USD/EUR */
44
+ defaultCurrencyCode: string;
45
+ /** The identifier for the Payment Method */
46
+ defaultPaymentMethods: MeldQuote['paymentMethodType'][];
47
+ };
48
+ export type MeldCreateCryptoQuoteParams = {
49
+ /**
50
+ * Two-letter country code (ISO 3166-1 alpha-2)
51
+ */
52
+ countryCode: string;
53
+ /**
54
+ * Meld generated unique identifier for your customer. This should be used to track customer activity.
55
+ */
56
+ customerId?: string;
57
+ /**
58
+ * The cryptocurrency the customer is buying (e.g. BTC, ETH).
59
+ */
60
+ destinationCurrencyCode: string;
61
+ /**
62
+ * Your unique identifier for your customer. If maintaining your own customer management system this can also be used for tracking customer activity.
63
+ */
64
+ externalCustomerId?: string;
65
+ /**
66
+ * Payment Method Type or SubType
67
+ */
68
+ paymentMethodType?: string;
69
+ /**
70
+ * An optional list of Strings representing the Service Providers for this Quote
71
+ */
72
+ serviceProviders?: MeldServiceProvider[];
73
+ /**
74
+ * The amount of source currency your customer wants tosend in this transaction (e.g., 50.05)
75
+ */
76
+ sourceAmount: `${number}`;
77
+ /**
78
+ * The fiat currency the user is buying crypto with (e.g. USD, EUR)
79
+ */
80
+ sourceCurrencyCode: string;
81
+ /**
82
+ * Subdivision is a optional parameter Only applicable if the country code is US or CA (e.g. US-CA).
83
+ */
84
+ subdivision?: string;
85
+ /**
86
+ * Your customer's wallet address
87
+ */
88
+ walletAddress?: `0x${string}`;
89
+ };
90
+ export type MeldQuote = {
91
+ /**
92
+ * Two-letter country code (ISO 3166-1 alpha-2)
93
+ */
94
+ countryCode: string;
95
+ /**
96
+ * A numerical score representing the expectation a Customer will convert
97
+ */
98
+ customerScore?: number;
99
+ /**
100
+ * Destination currency amount to be received for this quote
101
+ */
102
+ destinationAmount: number;
103
+ /**
104
+ * Code of currency being quoted: BTC, ETH, ...
105
+ */
106
+ destinationCurrencyCode: string;
107
+ /**
108
+ * The exchange rate at the time the request is sent
109
+ */
110
+ exchangeRate: number;
111
+ /**
112
+ * The fiat amount exchanged when buying or selling crypto, excluding fees
113
+ */
114
+ fiatAmountWithoutFees: number;
115
+ /**
116
+ * The name of the institution or broker used for this quote, if present
117
+ */
118
+ institutionName?: string | null;
119
+ /**
120
+ * LowKYC indicates if the quote amount is below the provider's low KYC threshold, meaning the user may not need to upload documents, which can increase conversion.
121
+ */
122
+ lowKyc?: boolean | null;
123
+ /**
124
+ * The network fee applied to a crypto transaction
125
+ */
126
+ networkFee?: number | null;
127
+ /**
128
+ * The fee amount charged by the partner to process your customer's purchase
129
+ */
130
+ partnerFee?: number | null;
131
+ /**
132
+ * Payment Method Type used for this quote
133
+ */
134
+ paymentMethodType: 'APPLE_PAY' | 'MASTERCARD' | 'SEPA' | 'VISA';
135
+ /**
136
+ * The service provider used for this transaction
137
+ */
138
+ serviceProvider: MeldServiceProvider;
139
+ /**
140
+ * Amount requested + fees
141
+ */
142
+ sourceAmount: number;
143
+ /**
144
+ * The fiat currency the user is buying crypto with (e.g. USD, EUR)
145
+ */
146
+ sourceCurrencyCode: string;
147
+ /**
148
+ * The total amount of fees that will be charged
149
+ */
150
+ totalFee?: number | null;
151
+ /**
152
+ * The fee amount charged by the service provider to process your customer's purchase
153
+ */
154
+ transactionFee?: number | null;
155
+ /**
156
+ * The type of crypto transaction
157
+ */
158
+ transactionType: 'CRYPTO_PURCHASE';
159
+ };
160
+ export type MeldCreateCryptoQuoteResponse = {
161
+ quotes: MeldQuote[];
162
+ };
163
+ export type MeldCreateCryptoWidgetParams = {
164
+ /**
165
+ * Meld generated unique identifier for your customer. This should be used to track customer activity.
166
+ */
167
+ customerId?: string;
168
+ /**
169
+ * Your unique identifier for your customer. If maintaining your own customer management system this can also be used for tracking customer activity.
170
+ */
171
+ externalCustomerId?: string;
172
+ /**
173
+ * Your reference Id for your widget session
174
+ */
175
+ externalSessionId?: string;
176
+ sessionData: {
177
+ /**
178
+ * Two-letter country code (ISO 3166-1 alpha-2)
179
+ */
180
+ countryCode: string;
181
+ /**
182
+ * The cryptocurrency the customer is buying (e.g. BTC, ETH).
183
+ */
184
+ destinationCurrencyCode: string;
185
+ /**
186
+ * If provided, the institution to bypass the institution selection screen in the service provider's widget. Currently this is only supported for MESH widget sessions.
187
+ */
188
+ institutionId?: string;
189
+ /**
190
+ * Where supported by the Service Provider, Meld can help you lock the cryptocurrency and/or wallet address fields within the widget.
191
+ */
192
+ lockFields?: ('destinationCurrencyCode' | 'walletAddress')[];
193
+ /**
194
+ * Payment Method Type or SubType
195
+ */
196
+ paymentMethodType?: string;
197
+ /**
198
+ * The url to redirect to following completion of the widget flow
199
+ */
200
+ redirectUrl?: string;
201
+ /**
202
+ * The service provider used for this transaction
203
+ */
204
+ serviceProvider: MeldServiceProvider;
205
+ /**
206
+ * The amount of source currency your customer wants to send in this transaction (e.g., 50.05)
207
+ */
208
+ sourceAmount: `${number}`;
209
+ /**
210
+ * The fiat currency the user is buying crypto with (e.g. USD, EUR)
211
+ */
212
+ sourceCurrencyCode: string;
213
+ /**
214
+ * Your customer's wallet address
215
+ */
216
+ walletAddress: `0x${string}`;
217
+ /**
218
+ * Your customer's wallet tag/destination tag/memo. This field is required for certain cryptocurrencies.
219
+ */
220
+ walletTag?: string;
221
+ };
222
+ sessionType: 'BUY';
223
+ /**
224
+ * For MESH only. Details about a previously authenticated crypto session or bank-linking connection.
225
+ * If provided, the widget will not require the customer to authenticate again as long as the authentication is still valid.
226
+ * The scope of these authentication bypass details are restricted to the same customer, service provider, and institution that were used in the original connection.
227
+ */
228
+ authenticationBypassDetails?: {
229
+ /**
230
+ * The widget type associated with the previously authenticated session/connection.
231
+ */
232
+ category: string;
233
+ /**
234
+ * The Meld id of the crypto session or bank-linking connection in which the customer has already authenticated with their institution.
235
+ * The auth tied to this session/connection will be used to bypass the authentication process for the current session, if it is still valid.
236
+ * This id may pertain to the initial session/connection in which the customer authenticated, or any subsequent session that used this prior authentication successfully.
237
+ */
238
+ previouslyAuthenticatedId: string;
239
+ };
240
+ };
241
+ export type MeldCreateCryptoWidgetResponse = {
242
+ /**
243
+ * Meld generated unique identifier for your customer. This should be used to track customer activity.
244
+ */
245
+ customerId?: string | null;
246
+ /**
247
+ * Your unique identifier for your customer. If maintaining your own customer management system this can also be used for tracking customer activity.
248
+ */
249
+ externalCustomerId?: string | null;
250
+ /**
251
+ * Your reference Id for your widget session
252
+ */
253
+ externalSessionId?: string | null;
254
+ /**
255
+ * Unique identifier for this session
256
+ */
257
+ id: string;
258
+ /**
259
+ * The session token
260
+ */
261
+ token: string;
262
+ /**
263
+ * The crypto widget URL
264
+ */
265
+ widgetUrl: string;
266
+ };
267
+ export interface MeldError extends Error {
268
+ /**
269
+ * A categorization of the error
270
+ */
271
+ code: string;
272
+ /**
273
+ * A user-friendly representation of the error code.
274
+ * This may change over time and is not safe for programmatic use.
275
+ */
276
+ errors?: string[] | null;
277
+ /**
278
+ * A developer-friendly representation of the error code.
279
+ * This may change over time and is not safe for programmatic use.
280
+ */
281
+ message: string;
282
+ /**
283
+ * The request Id
284
+ */
285
+ requestId: string;
286
+ /**
287
+ * The date and time when the request was made (ISO)
288
+ */
289
+ timestamp: string | null;
290
+ }
291
+ export interface MeldSupportedFiatResponse {
292
+ currencies: MeldFiatCurrency[];
293
+ /** Irrelevant */
294
+ preferred: string[];
295
+ }
296
+ export type SearchDefaultFiatParams = {
297
+ countries: string[];
298
+ categories?: (typeof MELD_PROVIDER_CATEGORIES)[number][];
299
+ };
300
+ export interface MeldDefaultFiatResponse {
301
+ currencies: MeldDefaultFiatCurrency[];
302
+ }
303
+ export interface GetCryptoPurchaseLimitsParams {
304
+ /**
305
+ * The two-letter country code (ISO 3166-1 alpha-2) to search for supported fiat currencies.
306
+ * A comma separated list of countries.
307
+ */
308
+ countries: string[];
309
+ /**
310
+ * The crypto currencies to search for limits
311
+ */
312
+ cryptoCurrencies: string[];
313
+ /**
314
+ * The fiat currencies to search for limits
315
+ */
316
+ fiatCurrencies: string[];
317
+ /**
318
+ * The categories to search for limits
319
+ */
320
+ categories?: (typeof MELD_PROVIDER_CATEGORIES)[number][];
321
+ }
322
+ export interface MeldFiatCurrencyLimit {
323
+ currencyCode: string;
324
+ defaultAmount: number | null;
325
+ minimumAmount: number;
326
+ maximumAmount: number;
327
+ }
328
+ export interface MeldFiatLimitResponse {
329
+ limits: MeldFiatCurrencyLimit[];
330
+ }
@@ -0,0 +1,4 @@
1
+ import type { GetOrganizationIdRequest } from './types';
2
+ export declare function getOrganizationIdByApiKey({ apiKey, }: GetOrganizationIdRequest): Promise<{
3
+ id: string;
4
+ }>;
@@ -0,0 +1,2 @@
1
+ export * from './endpoints';
2
+ export * from './types';
@@ -0,0 +1,3 @@
1
+ import type { BaseApiRequest } from '../../consts';
2
+ export interface GetOrganizationIdRequest extends BaseApiRequest {
3
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funkit/api-base",
3
- "version": "1.8.3",
3
+ "version": "1.9.0",
4
4
  "description": "Base API for Funkit",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -11,7 +11,7 @@
11
11
  "dependencies": {
12
12
  "@lifeomic/attempt": "^3.1.0",
13
13
  "big.js": "^6.2.1",
14
- "@funkit/utils": "1.0.14"
14
+ "@funkit/utils": "1.1.0"
15
15
  },
16
16
  "devDependencies": {
17
17
  "@types/big.js": "^6.2.2",