@meshconnect/web-link-sdk 2.1.0-rc.1 → 2.1.0-rc.3
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/Link.d.ts +2 -0
- package/Link.js +182 -0
- package/cjs/Link.js +186 -0
- package/cjs/index.js +21 -0
- package/cjs/utils/event-types.js +31 -0
- package/cjs/utils/popup.js +39 -0
- package/cjs/utils/sdk-specs.js +8 -0
- package/cjs/utils/style.js +18 -0
- package/cjs/utils/types.js +2 -0
- package/cjs/utils/version.js +4 -0
- package/index.d.ts +3 -289
- package/index.js +3 -1433
- package/package.json +12 -32
- package/utils/event-types.d.ts +152 -0
- package/utils/event-types.js +27 -0
- package/utils/popup.d.ts +3 -0
- package/utils/popup.js +34 -0
- package/utils/sdk-specs.d.ts +4 -0
- package/utils/sdk-specs.js +5 -0
- package/utils/style.d.ts +3 -0
- package/utils/style.js +13 -0
- package/utils/types.d.ts +103 -0
- package/utils/types.js +1 -0
- package/utils/version.d.ts +1 -0
- package/utils/version.js +1 -0
- package/index.cjs +0 -1499
- package/index.d.cts +0 -289
package/index.d.ts
CHANGED
@@ -1,289 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
type LinkEventType = IntegrationConnected | IntegrationConnectionError | TransferCompleted | IntegrationSelected | CredentialsEntered | TransferStarted | TransferPreviewed | TransferPreviewError | TransferExecutionError | PageLoaded | IntegrationMfaRequired | IntegrationMfaEntered | IntegrationOAuthStarted | IntegrationAccountSelectionRequired | TransferAssetSelected | TransferNetworkSelected | TransferAmountEntered | TransferMfaRequired | TransferMfaEntered | TransferKycRequired | DoneEvent | CloseEvent;
|
5
|
-
declare const LINK_EVENT_TYPE_KEYS: readonly ["integrationConnected", "integrationConnectionError", "integrationMfaRequired", "integrationMfaEntered", "integrationOAuthStarted", "integrationAccountSelectionRequired", "transferCompleted", "integrationSelected", "credentialsEntered", "transferStarted", "transferPreviewed", "transferPreviewError", "transferExecutionError", "pageLoaded", "transferAssetSelected", "transferNetworkSelected", "transferAmountEntered", "transferMfaRequired", "transferMfaEntered", "transferKycRequired", "done", "close"];
|
6
|
-
type LinkEventTypeKeys = (typeof LINK_EVENT_TYPE_KEYS)[number];
|
7
|
-
declare function isLinkEventTypeKey(key: string): key is LinkEventTypeKeys;
|
8
|
-
interface LinkEventBase {
|
9
|
-
type: LinkEventTypeKeys;
|
10
|
-
}
|
11
|
-
interface PageLoaded {
|
12
|
-
type: 'pageLoaded';
|
13
|
-
}
|
14
|
-
interface IntegrationConnected extends LinkEventBase {
|
15
|
-
type: 'integrationConnected';
|
16
|
-
payload: LinkPayload;
|
17
|
-
}
|
18
|
-
interface IntegrationConnectionError extends LinkEventBase {
|
19
|
-
type: 'integrationConnectionError';
|
20
|
-
payload: {
|
21
|
-
errorMessage: string;
|
22
|
-
};
|
23
|
-
}
|
24
|
-
interface TransferCompleted extends LinkEventBase {
|
25
|
-
type: 'transferCompleted';
|
26
|
-
payload: TransferFinishedPayload;
|
27
|
-
}
|
28
|
-
interface IntegrationSelected extends LinkEventBase {
|
29
|
-
type: 'integrationSelected';
|
30
|
-
payload: {
|
31
|
-
integrationType: string;
|
32
|
-
integrationName: string;
|
33
|
-
};
|
34
|
-
}
|
35
|
-
interface CredentialsEntered extends LinkEventBase {
|
36
|
-
type: 'credentialsEntered';
|
37
|
-
}
|
38
|
-
interface TransferStarted extends LinkEventBase {
|
39
|
-
type: 'transferStarted';
|
40
|
-
}
|
41
|
-
interface TransferPreviewed extends LinkEventBase {
|
42
|
-
type: 'transferPreviewed';
|
43
|
-
payload: {
|
44
|
-
amount: number;
|
45
|
-
symbol: string;
|
46
|
-
toAddress: string;
|
47
|
-
networkId: string;
|
48
|
-
previewId: string;
|
49
|
-
networkName?: string;
|
50
|
-
amountInFiat?: number;
|
51
|
-
estimatedNetworkGasFee?: {
|
52
|
-
fee?: number;
|
53
|
-
feeCurrency?: string;
|
54
|
-
feeInFiat?: number;
|
55
|
-
};
|
56
|
-
};
|
57
|
-
}
|
58
|
-
interface TransferPreviewError extends LinkEventBase {
|
59
|
-
type: 'transferPreviewError';
|
60
|
-
payload: {
|
61
|
-
errorMessage: string;
|
62
|
-
};
|
63
|
-
}
|
64
|
-
interface TransferExecutionError extends LinkEventBase {
|
65
|
-
type: 'transferExecutionError';
|
66
|
-
payload: {
|
67
|
-
errorMessage: string;
|
68
|
-
};
|
69
|
-
}
|
70
|
-
interface IntegrationMfaRequired extends LinkEventBase {
|
71
|
-
type: 'integrationMfaRequired';
|
72
|
-
}
|
73
|
-
interface IntegrationMfaEntered extends LinkEventBase {
|
74
|
-
type: 'integrationMfaEntered';
|
75
|
-
}
|
76
|
-
interface IntegrationOAuthStarted extends LinkEventBase {
|
77
|
-
type: 'integrationOAuthStarted';
|
78
|
-
}
|
79
|
-
interface IntegrationAccountSelectionRequired extends LinkEventBase {
|
80
|
-
type: 'integrationAccountSelectionRequired';
|
81
|
-
}
|
82
|
-
interface TransferAssetSelected extends LinkEventBase {
|
83
|
-
type: 'transferAssetSelected';
|
84
|
-
payload: {
|
85
|
-
symbol: string;
|
86
|
-
};
|
87
|
-
}
|
88
|
-
interface TransferNetworkSelected extends LinkEventBase {
|
89
|
-
type: 'transferNetworkSelected';
|
90
|
-
payload: {
|
91
|
-
id: string;
|
92
|
-
name: string;
|
93
|
-
};
|
94
|
-
}
|
95
|
-
interface TransferAmountEntered extends LinkEventBase {
|
96
|
-
type: 'transferAmountEntered';
|
97
|
-
}
|
98
|
-
interface TransferMfaRequired extends LinkEventBase {
|
99
|
-
type: 'transferMfaRequired';
|
100
|
-
}
|
101
|
-
interface TransferMfaEntered extends LinkEventBase {
|
102
|
-
type: 'transferMfaEntered';
|
103
|
-
}
|
104
|
-
interface TransferKycRequired extends LinkEventBase {
|
105
|
-
type: 'transferKycRequired';
|
106
|
-
}
|
107
|
-
interface DoneEvent extends LinkEventBase {
|
108
|
-
type: 'done';
|
109
|
-
payload: SessionSymmary;
|
110
|
-
}
|
111
|
-
interface CloseEvent extends LinkEventBase {
|
112
|
-
type: 'close';
|
113
|
-
payload: SessionSymmary;
|
114
|
-
}
|
115
|
-
interface SessionSymmary {
|
116
|
-
/**
|
117
|
-
* Current page of application. Possible values:
|
118
|
-
* `startPage`
|
119
|
-
* `integrationsCatalogPage`
|
120
|
-
* `integrationLoginPage`
|
121
|
-
* `integrationMfaPage`
|
122
|
-
* `integrationAccountSelectPage`
|
123
|
-
* `integrationConnectedPage`
|
124
|
-
* `errorPage`
|
125
|
-
* `transferKycPage`
|
126
|
-
* `transferHoldingSelectionPage`
|
127
|
-
* `transferNetworkSelectionPage`
|
128
|
-
* `transferAmountSelectionPage`
|
129
|
-
* `transferPreviewPage`
|
130
|
-
* `transferMfaPage`
|
131
|
-
* `transferFundingPage`
|
132
|
-
* `transferExecutedPage`
|
133
|
-
* `termsAndConditionPage`
|
134
|
-
*
|
135
|
-
* This list may change in future.
|
136
|
-
*/
|
137
|
-
page: string;
|
138
|
-
/** Selected integration */
|
139
|
-
selectedIntegration?: {
|
140
|
-
id?: string;
|
141
|
-
name?: string;
|
142
|
-
};
|
143
|
-
/** Transfer information */
|
144
|
-
transfer?: {
|
145
|
-
previewId?: string;
|
146
|
-
symbol?: string;
|
147
|
-
amount?: number;
|
148
|
-
amountInFiat?: number;
|
149
|
-
transactionId?: string;
|
150
|
-
networkId?: string;
|
151
|
-
};
|
152
|
-
errorMessage?: string;
|
153
|
-
}
|
154
|
-
|
155
|
-
type EventType = 'brokerageAccountAccessToken' | 'delayedAuthentication' | 'loaded' | 'oauthLinkOpen' | 'transferFinished';
|
156
|
-
interface Link {
|
157
|
-
/**
|
158
|
-
* A function that takes linkToken parameter from `/api/v1/linktoken` endpoint as an input, and opens the Link UI popup
|
159
|
-
*/
|
160
|
-
openLink: (linkToken: string) => Promise<void>;
|
161
|
-
/**
|
162
|
-
* A function to close Link UI popup
|
163
|
-
*/
|
164
|
-
closeLink: () => void;
|
165
|
-
}
|
166
|
-
interface AccountToken {
|
167
|
-
account: Account;
|
168
|
-
accessToken: string;
|
169
|
-
refreshToken?: string;
|
170
|
-
}
|
171
|
-
interface Account {
|
172
|
-
accountId: string;
|
173
|
-
accountName: string;
|
174
|
-
fund?: number;
|
175
|
-
cash?: number;
|
176
|
-
isReconnected?: boolean;
|
177
|
-
}
|
178
|
-
interface BrandInfo {
|
179
|
-
brokerLogo: string;
|
180
|
-
brokerPrimaryColor?: string;
|
181
|
-
}
|
182
|
-
interface LinkPayload {
|
183
|
-
accessToken?: AccessTokenPayload;
|
184
|
-
delayedAuth?: DelayedAuthPayload;
|
185
|
-
}
|
186
|
-
interface AccessTokenPayload {
|
187
|
-
accountTokens: AccountToken[];
|
188
|
-
brokerBrandInfo: BrandInfo;
|
189
|
-
expiresInSeconds?: number;
|
190
|
-
refreshTokenExpiresInSeconds?: number;
|
191
|
-
brokerType: BrokerType;
|
192
|
-
brokerName: string;
|
193
|
-
}
|
194
|
-
interface DelayedAuthPayload {
|
195
|
-
refreshTokenExpiresInSeconds?: number;
|
196
|
-
brokerType: BrokerType;
|
197
|
-
refreshToken: string;
|
198
|
-
brokerName: string;
|
199
|
-
brokerBrandInfo: BrandInfo;
|
200
|
-
}
|
201
|
-
interface TransferFinishedPayload {
|
202
|
-
status: 'success';
|
203
|
-
txId: string;
|
204
|
-
fromAddress: string;
|
205
|
-
toAddress: string;
|
206
|
-
symbol: string;
|
207
|
-
amount: number;
|
208
|
-
networkId: string;
|
209
|
-
}
|
210
|
-
interface IntegrationAccessToken {
|
211
|
-
accountId: string;
|
212
|
-
accountName: string;
|
213
|
-
accessToken: string;
|
214
|
-
brokerType: BrokerType;
|
215
|
-
brokerName: string;
|
216
|
-
}
|
217
|
-
interface WagmiInjectedConnectorData {
|
218
|
-
id: string;
|
219
|
-
name: string;
|
220
|
-
type: string;
|
221
|
-
icon?: string;
|
222
|
-
uid: string;
|
223
|
-
}
|
224
|
-
interface ConnectReturnTypeAndTxHash {
|
225
|
-
accounts: string[];
|
226
|
-
chainId: number;
|
227
|
-
txSigned: Hash;
|
228
|
-
}
|
229
|
-
interface IncomingConfig {
|
230
|
-
chains: Chain[];
|
231
|
-
transports: Record<number, string | string[]>;
|
232
|
-
}
|
233
|
-
interface AbiItem {
|
234
|
-
name: string;
|
235
|
-
type: string;
|
236
|
-
inputs: {
|
237
|
-
name: string;
|
238
|
-
type: string;
|
239
|
-
}[];
|
240
|
-
outputs?: {
|
241
|
-
name: string;
|
242
|
-
type: string;
|
243
|
-
}[];
|
244
|
-
stateMutability?: string;
|
245
|
-
}
|
246
|
-
type Abi = AbiItem[];
|
247
|
-
interface LinkOptions {
|
248
|
-
/**
|
249
|
-
* Client ID that can be obtained at https://dashboard.meshconnect.com/company/keys
|
250
|
-
*/
|
251
|
-
clientId: string;
|
252
|
-
/**
|
253
|
-
* A callback function that is called when an integration is successfully connected.
|
254
|
-
* It receives a payload of type `LinkPayload`.
|
255
|
-
*/
|
256
|
-
onIntegrationConnected: (payload: LinkPayload) => void;
|
257
|
-
/**
|
258
|
-
* (Optional) A callback function that is called when the Front iframe is closed.
|
259
|
-
*/
|
260
|
-
onExit?: (error?: string, summary?: SessionSymmary) => void;
|
261
|
-
/**
|
262
|
-
* (Optional) A callback function that is called when a transfer is finished.
|
263
|
-
* It receives a payload of type `TransferFinishedPayload`.
|
264
|
-
*/
|
265
|
-
onTransferFinished?: (payload: TransferFinishedPayload) => void;
|
266
|
-
/**
|
267
|
-
* (Optional) A callback function that is called when various events occur within the Front iframe.
|
268
|
-
* It receives an object with type `LinkEventTypeKeys` indicating the event, and an optional 'payload' containing additional data.
|
269
|
-
*/
|
270
|
-
onEvent?: (event: LinkEventType) => void;
|
271
|
-
/**
|
272
|
-
* (Optional) An array of integration access tokens.
|
273
|
-
* These access tokens are used to initialize crypto transfers flow at 'Select asset step'
|
274
|
-
*/
|
275
|
-
accessTokens?: IntegrationAccessToken[];
|
276
|
-
/**
|
277
|
-
* (Optional) An array of integration access tokens.
|
278
|
-
* Can be used to initialize the crypto transfers flow as an alternative to the target addresses.
|
279
|
-
*/
|
280
|
-
transferDestinationTokens?: IntegrationAccessToken[];
|
281
|
-
}
|
282
|
-
interface LinkStyle {
|
283
|
-
ir: number;
|
284
|
-
io: number;
|
285
|
-
}
|
286
|
-
|
287
|
-
declare const createLink: (options: LinkOptions) => Link;
|
288
|
-
|
289
|
-
export { type Abi, type AbiItem, type AccessTokenPayload, type Account, type AccountToken, type BrandInfo, type CloseEvent, type ConnectReturnTypeAndTxHash, type CredentialsEntered, type DelayedAuthPayload, type DoneEvent, type EventType, type IncomingConfig, type IntegrationAccessToken, type IntegrationAccountSelectionRequired, type IntegrationConnected, type IntegrationConnectionError, type IntegrationMfaEntered, type IntegrationMfaRequired, type IntegrationOAuthStarted, type IntegrationSelected, type Link, type LinkEventType, type LinkEventTypeKeys, type LinkOptions, type LinkPayload, type LinkStyle, type PageLoaded, type SessionSymmary, type TransferAmountEntered, type TransferAssetSelected, type TransferCompleted, type TransferExecutionError, type TransferFinishedPayload, type TransferKycRequired, type TransferMfaEntered, type TransferMfaRequired, type TransferNetworkSelected, type TransferPreviewError, type TransferPreviewed, type TransferStarted, type WagmiInjectedConnectorData, createLink, isLinkEventTypeKey };
|
1
|
+
export * from './utils/types';
|
2
|
+
export * from './utils/event-types';
|
3
|
+
export { createLink } from './Link';
|