@funkit/api-base 1.4.2 → 1.5.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.
Files changed (35) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/index.js +507 -61
  3. package/dist/index.js.map +4 -4
  4. package/dist/src/consts/api.d.ts +1 -0
  5. package/dist/src/consts/customers.d.ts +4 -0
  6. package/dist/src/consts/index.d.ts +1 -0
  7. package/dist/src/consts/retry.d.ts +2 -2
  8. package/dist/src/services/assets/endpoints.d.ts +19 -5
  9. package/dist/src/services/assets/types.d.ts +23 -0
  10. package/dist/src/services/checkout/types.d.ts +4 -3
  11. package/dist/src/services/faucet/endpoints.d.ts +1 -1
  12. package/dist/src/services/fw-access/endpoints.d.ts +3 -0
  13. package/dist/src/services/fw-access/index.d.ts +2 -0
  14. package/dist/src/services/fw-access/types.d.ts +10 -0
  15. package/dist/src/services/fw-group/endpoints.d.ts +2 -0
  16. package/dist/src/services/fw-group/index.d.ts +2 -0
  17. package/dist/src/services/fw-group/types.d.ts +13 -0
  18. package/dist/src/services/fw-info/endpoints.d.ts +3 -0
  19. package/dist/src/services/fw-info/index.d.ts +2 -0
  20. package/dist/src/services/fw-info/types.d.ts +21 -0
  21. package/dist/src/services/fw-operation/endpoints.d.ts +11 -0
  22. package/dist/src/services/fw-operation/index.d.ts +2 -0
  23. package/dist/src/services/fw-operation/types.d.ts +149 -0
  24. package/dist/src/services/fw-paymaster/endpoints.d.ts +2 -0
  25. package/dist/src/services/fw-paymaster/index.d.ts +2 -0
  26. package/dist/src/services/fw-paymaster/types.d.ts +24 -0
  27. package/dist/src/services/fw-user/endpoints.d.ts +10 -0
  28. package/dist/src/services/fw-user/index.d.ts +2 -0
  29. package/dist/src/services/fw-user/types.d.ts +36 -0
  30. package/dist/src/services/index.d.ts +6 -0
  31. package/dist/src/services/mesh/endpoints.d.ts +35 -2
  32. package/dist/src/services/mesh/types.d.ts +16 -1
  33. package/dist/src/utils/error.d.ts +2 -1
  34. package/dist/src/utils/request.d.ts +3 -3
  35. package/package.json +2 -3
@@ -0,0 +1,149 @@
1
+ import type { Address, Hex } from 'viem';
2
+ export declare enum OperationStatus {
3
+ ALL = "",
4
+ PENDING_APPROVED = "PENDING_APPROVED",
5
+ APPROVED = "APPROVED",
6
+ PENDING = "PENDING",
7
+ OP_SUCCEED = "OP_SUCCEED",
8
+ OP_REVERTED = "OP_REVERTED",
9
+ SCHEDULED = "SCHEDULED"
10
+ }
11
+ export type OperationMetadata = {
12
+ opId?: Hex;
13
+ chainId: string;
14
+ opType: OperationType;
15
+ authType: AuthType;
16
+ groupId?: Hex;
17
+ message?: string;
18
+ walletAddr: Address;
19
+ status?: OperationStatus;
20
+ proposer: string;
21
+ proposedTime?: number;
22
+ executedBy?: string;
23
+ executedTime?: number;
24
+ relatedOpIds?: Hex[];
25
+ signatures?: Signature[];
26
+ txid?: string;
27
+ gasUsed?: string;
28
+ opFeeUSD?: string;
29
+ opFee?: string;
30
+ executedBlockNumber?: number;
31
+ executedBlockTimeStamp?: number;
32
+ };
33
+ export interface OperationData extends OperationMetadata {
34
+ userOp: UserOperation;
35
+ }
36
+ export declare enum AuthType {
37
+ ECDSA = 0,
38
+ MULTI_SIG = 1
39
+ }
40
+ export type Signature = {
41
+ userId: Hex;
42
+ signature: Hex;
43
+ signedTime: number;
44
+ };
45
+ export declare enum OperationType {
46
+ SINGLE_OPERATION = "SINGLE_OPERATION",
47
+ GROUP_OPERATION = "GROUP_OPERATION",
48
+ REJECTION = "REJECTION"
49
+ }
50
+ export type GroupInfo = {
51
+ threshold: number;
52
+ memberIds: Hex[];
53
+ };
54
+ export type UserOperation = {
55
+ sender: string;
56
+ nonce: bigint;
57
+ initCode?: string;
58
+ callData: string;
59
+ callGasLimit: bigint;
60
+ verificationGasLimit: bigint;
61
+ preVerificationGas?: bigint;
62
+ maxFeePerGas: bigint;
63
+ maxPriorityFeePerGas: bigint;
64
+ paymasterAndData?: string;
65
+ signature?: string;
66
+ };
67
+ export interface ExecutionReceipt {
68
+ userOpHash: string;
69
+ txId?: Hex;
70
+ gasUsed?: string;
71
+ opFeeUSD?: string;
72
+ opFee?: string;
73
+ }
74
+ export type EstimatedGas = {
75
+ preVerificationGas: bigint;
76
+ callGasLimit: bigint;
77
+ verificationGasLimit: bigint;
78
+ };
79
+ export interface CreateOpRequest {
80
+ op: OperationData;
81
+ apiKey: string;
82
+ }
83
+ export interface GetOpsOfWalletRequest {
84
+ walletAddr: Address;
85
+ chainId: string;
86
+ apiKey: string;
87
+ status?: OperationStatus;
88
+ }
89
+ export interface GetOpsRequest {
90
+ opIds: Hex[];
91
+ chainId: string;
92
+ apiKey: string;
93
+ }
94
+ export interface DeleteOpRequest {
95
+ opId: Hex;
96
+ chainId: string;
97
+ apiKey: string;
98
+ }
99
+ export interface SignOpRequest {
100
+ opId: Hex;
101
+ chainId: string;
102
+ signature: Hex;
103
+ signedBy: Address;
104
+ apiKey: string;
105
+ threshold?: number;
106
+ }
107
+ export type OpRequest<T> = {
108
+ input: T;
109
+ apiKey: string;
110
+ };
111
+ export type ExecuteOpInput = {
112
+ opId: Hex;
113
+ chainId: string;
114
+ executedBy: string;
115
+ entryPointAddress: Address;
116
+ signature: Hex;
117
+ userOp?: UserOperation;
118
+ groupInfo?: GroupInfo;
119
+ };
120
+ export type EstimateOpInput = {
121
+ opId?: Hex;
122
+ chainId: string;
123
+ entryPointAddress?: Address;
124
+ signature?: Hex;
125
+ userOp?: UserOperation;
126
+ };
127
+ export type ScheduleOpInput = {
128
+ opId: Hex;
129
+ chainId: string;
130
+ scheduledBy: string;
131
+ entryPointAddress: Address;
132
+ signature: Hex;
133
+ userOp?: UserOperation;
134
+ groupInfo?: GroupInfo;
135
+ };
136
+ export interface GetFullReceiptRequest {
137
+ opId: string;
138
+ chainId: string;
139
+ userOpHash: string;
140
+ apiKey: string;
141
+ }
142
+ export interface GetUserOpGasPriceRequest {
143
+ chainId: string;
144
+ apiKey: string;
145
+ }
146
+ export type UserOperationGasPrice = {
147
+ maxFeePerGas: bigint;
148
+ maxPriorityFeePerGas: bigint;
149
+ };
@@ -0,0 +1,2 @@
1
+ import type { AddPaymasterTransactionRequest } from './types';
2
+ export declare function addTransaction({ chainId, timestamp, txid, transaction, paymasterType, sponsorAddress, apiKey, }: AddPaymasterTransactionRequest): Promise<any>;
@@ -0,0 +1,2 @@
1
+ export * from './endpoints';
2
+ export * from './types';
@@ -0,0 +1,24 @@
1
+ import type { ExecutionReceipt } from '../fw-operation';
2
+ export interface PaymasterTransaction {
3
+ action: string;
4
+ amount: number;
5
+ from: string;
6
+ to: string;
7
+ token: string;
8
+ txid?: string;
9
+ }
10
+ export interface AddPaymasterTransactionRequest {
11
+ chainId: string;
12
+ timestamp: number;
13
+ txid: ExecutionReceipt['txId'] | string;
14
+ transaction: PaymasterTransaction;
15
+ paymasterType: PaymasterType;
16
+ sponsorAddress: string;
17
+ apiKey: string;
18
+ }
19
+ export declare enum PaymasterType {
20
+ BaseSponsor = "base",
21
+ GaslessSponsor = "gasless",
22
+ TokenSponsor = "token",
23
+ CheckoutSponsor = "checkout"
24
+ }
@@ -0,0 +1,10 @@
1
+ import { type Hex } from 'viem';
2
+ import type { AddUserToWalletRequest, CreateUserRequest, GetUserUniqueIdRequest, GetUserWalletIdentitiesRequest, GetUserWalletsByAddrRequest, Wallet } from './types';
3
+ export declare function createUser({ authId, addr, method, userUniqueId, apiKey, }: CreateUserRequest): Promise<void>;
4
+ export declare function getUserUniqueId({ authId, apiKey, }: GetUserUniqueIdRequest): Promise<string>;
5
+ export declare function getUserWalletsByAddr({ addr, apiKey, chainId, }: GetUserWalletsByAddrRequest): Promise<Wallet[]>;
6
+ export declare function addUserToWallet({ authId, chainId, walletAddr, userIds, apiKey, walletUniqueId, }: AddUserToWalletRequest): Promise<void>;
7
+ /**
8
+ * @returns userIds of the specified Wallet.
9
+ */
10
+ export declare function getUserWalletIdentities({ authId, chainId, walletAddr, apiKey, }: GetUserWalletIdentitiesRequest): Promise<Hex[]>;
@@ -0,0 +1,2 @@
1
+ export * from './endpoints';
2
+ export * from './types';
@@ -0,0 +1,36 @@
1
+ import type { Address, Hex } from 'viem';
2
+ export type Wallet = {
3
+ walletUniqueId?: string;
4
+ walletAddr: Address;
5
+ userIds: Hex[];
6
+ };
7
+ export interface CreateUserRequest {
8
+ authId: string;
9
+ addr: string;
10
+ method: string;
11
+ userUniqueId: string;
12
+ apiKey: string;
13
+ }
14
+ export interface GetUserUniqueIdRequest {
15
+ authId: string;
16
+ apiKey: string;
17
+ }
18
+ export interface GetUserWalletsByAddrRequest {
19
+ addr: string;
20
+ apiKey: string;
21
+ chainId?: string;
22
+ }
23
+ export interface AddUserToWalletRequest {
24
+ authId: string;
25
+ chainId: string;
26
+ walletAddr: Address;
27
+ userIds: Hex[];
28
+ apiKey: string;
29
+ walletUniqueId?: string;
30
+ }
31
+ export interface GetUserWalletIdentitiesRequest {
32
+ authId: string;
33
+ chainId: string;
34
+ walletAddr: Address;
35
+ apiKey: string;
36
+ }
@@ -1,6 +1,12 @@
1
1
  export * from './assets';
2
2
  export * from './checkout';
3
3
  export * from './faucet';
4
+ export * from './fw-access';
5
+ export * from './fw-group';
6
+ export * from './fw-info';
7
+ export * from './fw-operation';
8
+ export * from './fw-paymaster';
9
+ export * from './fw-user';
4
10
  export * from './mesh';
5
11
  export * from './moonpay';
6
12
  export * from './stripe';
@@ -1,10 +1,11 @@
1
- import type { GetCryptocurrencyHoldingsRequest, GetLinkTokenRequest, GetLinkTokenResponse, GetTransferIntegrationsRequest, GetTransferIntegrationsResponse, MeshExecuteTransferRequest, MeshExecuteTransferResponse, PreviewTransferRequest, PreviewTransferResponse } from './types';
1
+ import type { GetCryptocurrencyHoldingsRequest, GetCryptocurrencyHoldingsRequestProxy, GetCryptocurrencyHoldingsResponse, GetLinkTokenRequest, GetLinkTokenResponse, GetTransferIntegrationsRequest, GetTransferIntegrationsResponse, MeshExecuteTransferRequest, MeshExecuteTransferRequestProxy, MeshExecuteTransferResponse, PreviewTransferRequest, PreviewTransferRequestProxy, PreviewTransferResponse } from './types';
2
2
  /**
3
3
  * @param authToken The authentication token to send the asset from.
4
4
  * @param type The type of the integration to send the asset from.
5
5
  * @return https://docs.meshconnect.com/api-reference/portfolio/get-holdings
6
6
  */
7
- export declare function meshGetCryptocurrencyHoldings({ authToken, type, apiKey, }: GetCryptocurrencyHoldingsRequest): Promise<any>;
7
+ export declare function meshGetCryptocurrencyHoldings({ authToken, type, apiKey, }: GetCryptocurrencyHoldingsRequest): Promise<GetCryptocurrencyHoldingsResponse>;
8
+ export declare function meshGetCryptocurrencyHoldingsProxy({ apiKey, ...props }: GetCryptocurrencyHoldingsRequestProxy): Promise<GetCryptocurrencyHoldingsResponse>;
8
9
  /**
9
10
  * @return https://docs.meshconnect.com/api-reference/managed-transfers/get-integrations
10
11
  */
@@ -34,6 +35,7 @@ export declare function meshGetLinkToken({ userId, integrationId, restrictMultip
34
35
  * @returns https://docs.meshconnect.com/api-reference/managed-transfers/preview-transfer
35
36
  */
36
37
  export declare function meshPreviewTransfer({ fromAuthToken, fromType, toAuthToken, toType, networkId, symbol, toAddress, amount, amountInFiat, fiatCurrency, apiKey, }: PreviewTransferRequest): Promise<PreviewTransferResponse>;
38
+ export declare function meshPreviewTransferProxy({ apiKey, ...props }: PreviewTransferRequestProxy): Promise<PreviewTransferResponse>;
37
39
  /**
38
40
  *
39
41
  * @param fromAuthToken The authentication token to send the asset from.
@@ -43,3 +45,34 @@ export declare function meshPreviewTransfer({ fromAuthToken, fromType, toAuthTok
43
45
  * @returns https://docs.meshconnect.com/api-reference/managed-transfers/execute-transfer
44
46
  */
45
47
  export declare function meshExecuteTransfer({ fromAuthToken, fromType, previewId, mfaCode, apiKey, }: MeshExecuteTransferRequest): Promise<MeshExecuteTransferResponse>;
48
+ export declare function meshExecuteTransferProxy({ apiKey, ...props }: MeshExecuteTransferRequestProxy): Promise<MeshExecuteTransferResponse>;
49
+ interface SaveTokensToMeshProxyRequestBody {
50
+ deviceId?: string | null;
51
+ brokerType: string;
52
+ accessToken: string;
53
+ refreshToken: string | null;
54
+ accessTokenExpiresIn: number;
55
+ accessTokenExpiresAt: string;
56
+ refreshTokenExpiresAt?: string | null;
57
+ apiKey: string;
58
+ }
59
+ interface SaveTokensToMeshProxyResponseBody {
60
+ id: number;
61
+ createdAt: Date;
62
+ updatedAt: Date;
63
+ deviceId: string;
64
+ integrationId: string;
65
+ accessToken: string;
66
+ accessTokenExpiresAt: Date | null;
67
+ accessTokenExpiresIn: number | null;
68
+ refreshToken: string | null;
69
+ refreshTokenExpiresAt: Date | null;
70
+ }
71
+ export declare function saveTokensToMeshProxy({ apiKey, ...props }: SaveTokensToMeshProxyRequestBody): Promise<SaveTokensToMeshProxyResponseBody>;
72
+ interface RemoveTokensFromMeshProxyRequestBody {
73
+ deviceId: string;
74
+ brokerType: string;
75
+ apiKey: string;
76
+ }
77
+ export declare function removeTokensFromMeshProxy({ apiKey, ...props }: RemoveTokensFromMeshProxyRequestBody): Promise<void>;
78
+ export {};
@@ -3,6 +3,10 @@ export interface GetCryptocurrencyHoldingsRequest {
3
3
  type: string;
4
4
  apiKey: string;
5
5
  }
6
+ export interface GetCryptocurrencyHoldingsRequestProxy extends Omit<GetCryptocurrencyHoldingsRequest, 'authToken' | 'type'> {
7
+ deviceId: string;
8
+ brokerType: string;
9
+ }
6
10
  export interface GetTransferIntegrationsRequest {
7
11
  apiKey: string;
8
12
  }
@@ -27,7 +31,7 @@ export interface GetLinkTokenRequest {
27
31
  userId: string;
28
32
  integrationId?: string | null;
29
33
  restrictMultipleAccounts?: boolean;
30
- transferOptions?: any | null;
34
+ transferOptions?: Record<string, unknown> | null;
31
35
  apiKey: string;
32
36
  }
33
37
  export interface GetLinkTokenResponse {
@@ -46,6 +50,10 @@ export interface PreviewTransferRequest {
46
50
  amountInFiat?: string | null;
47
51
  fiatCurrency?: string | null;
48
52
  }
53
+ export interface PreviewTransferRequestProxy extends Omit<PreviewTransferRequest, 'fromAuthToken' | 'fromType'> {
54
+ deviceId: string;
55
+ brokerType: string;
56
+ }
49
57
  export interface MeshExecuteTransferRequest {
50
58
  apiKey: string;
51
59
  fromAuthToken: string;
@@ -53,6 +61,10 @@ export interface MeshExecuteTransferRequest {
53
61
  previewId: string;
54
62
  mfaCode?: string | null;
55
63
  }
64
+ export interface MeshExecuteTransferRequestProxy extends Omit<MeshExecuteTransferRequest, 'fromAuthToken' | 'fromType'> {
65
+ deviceId: string;
66
+ brokerType: string;
67
+ }
56
68
  export declare enum MeshExecuteTransferStatus {
57
69
  succeeded = "succeeded",
58
70
  failed = "failed",
@@ -89,6 +101,9 @@ export interface MeshCryptoCurrencyPosition {
89
101
  export interface GetCryptocurrencyHoldingsResponse {
90
102
  cryptocurrencyPositions: MeshCryptoCurrencyPosition[];
91
103
  }
104
+ export interface MeshProxyUnauthorizedResponse {
105
+ error: string;
106
+ }
92
107
  export interface PreviewTransferResponse {
93
108
  /** The status of the operation. */
94
109
  status: 'succeeded' | 'failed' | 'requiresFunding';
@@ -1 +1,2 @@
1
- export declare const errorAbortHandler: (err: any, context: any) => void;
1
+ import type { AttemptContext } from '@lifeomic/attempt';
2
+ export declare const errorAbortHandler: (err: Error, context: AttemptContext) => void;
@@ -1,8 +1,8 @@
1
1
  import type { BaseRequest } from '../consts/request';
2
2
  import { type BaseResponse } from '../consts/retry';
3
3
  import type { DeleteRequest, GetRequest, PostRequest, PutRequest } from './../consts/request';
4
- export declare const sendRequest: ({ uri, method, apiKey, body, retryOptions, signal, }: BaseRequest) => Promise<BaseResponse>;
5
- export declare function sendGetRequest({ uri, apiKey, retryOptions, signal, }: GetRequest): Promise<BaseResponse>;
6
- export declare function sendPostRequest({ uri, body, apiKey, retryOptions, signal, }: PostRequest): Promise<BaseResponse>;
4
+ export declare function sendRequest<T = BaseResponse>({ uri, method, apiKey, body, retryOptions, signal, }: BaseRequest): Promise<T>;
5
+ export declare function sendGetRequest<T = BaseResponse>({ uri, apiKey, retryOptions, signal, }: GetRequest): Promise<T>;
6
+ export declare function sendPostRequest<T = BaseResponse>({ uri, body, apiKey, retryOptions, signal, }: PostRequest): Promise<T>;
7
7
  export declare function sendDeleteRequest({ uri, apiKey, retryOptions, signal, }: DeleteRequest): Promise<void>;
8
8
  export declare function sendPutRequest({ uri, body, apiKey, retryOptions, signal, }: PutRequest): Promise<BaseResponse>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funkit/api-base",
3
- "version": "1.4.2",
3
+ "version": "1.5.1",
4
4
  "description": "Base API for Funkit",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -11,11 +11,10 @@
11
11
  "dependencies": {
12
12
  "@lifeomic/attempt": "^3.1.0",
13
13
  "big.js": "^6.2.1",
14
- "@funkit/utils": "1.0.3"
14
+ "@funkit/utils": "1.0.4"
15
15
  },
16
16
  "devDependencies": {
17
17
  "@types/big.js": "^6.2.2",
18
- "ts-node": "^10.9.1",
19
18
  "typescript": "^5.4.3",
20
19
  "vitest": "^2.0.5"
21
20
  },