@meshconnect/web-link-sdk 2.1.0-rc.0 → 2.1.0-rc.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.
- package/index.cjs +1499 -0
- package/index.d.cts +289 -0
- package/index.d.ts +289 -3
- package/index.js +1433 -3
- package/package.json +10 -8
- package/Link.d.ts +0 -2
- package/Link.js +0 -420
- package/cjs/Link.js +0 -424
- package/cjs/index.js +0 -21
- package/cjs/utils/event-types.js +0 -31
- package/cjs/utils/popup.js +0 -39
- package/cjs/utils/sdk-specs.js +0 -8
- package/cjs/utils/style.js +0 -18
- package/cjs/utils/types.js +0 -2
- package/cjs/utils/version.js +0 -4
- package/cjs/utils/wagmiCoreConnectorsUtils.js +0 -425
- package/cjs/utils/wallet-browser-event-types.js +0 -17
- package/utils/event-types.d.ts +0 -152
- package/utils/event-types.js +0 -27
- package/utils/popup.d.ts +0 -3
- package/utils/popup.js +0 -34
- package/utils/sdk-specs.d.ts +0 -4
- package/utils/sdk-specs.js +0 -5
- package/utils/style.d.ts +0 -3
- package/utils/style.js +0 -13
- package/utils/types.d.ts +0 -134
- package/utils/types.js +0 -1
- package/utils/version.d.ts +0 -1
- package/utils/version.js +0 -1
- package/utils/wagmiCoreConnectorsUtils.d.ts +0 -11
- package/utils/wagmiCoreConnectorsUtils.js +0 -414
- package/utils/wallet-browser-event-types.d.ts +0 -59
- package/utils/wallet-browser-event-types.js +0 -13
package/cjs/Link.js
DELETED
@@ -1,424 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
3
|
-
__assign = Object.assign || function(t) {
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
5
|
-
s = arguments[i];
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
7
|
-
t[p] = s[p];
|
8
|
-
}
|
9
|
-
return t;
|
10
|
-
};
|
11
|
-
return __assign.apply(this, arguments);
|
12
|
-
};
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
20
|
-
});
|
21
|
-
};
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
26
|
-
function step(op) {
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
31
|
-
switch (op[0]) {
|
32
|
-
case 0: case 1: t = op; break;
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
36
|
-
default:
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
41
|
-
if (t[2]) _.ops.pop();
|
42
|
-
_.trys.pop(); continue;
|
43
|
-
}
|
44
|
-
op = body.call(thisArg, _);
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
47
|
-
}
|
48
|
-
};
|
49
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
50
|
-
exports.createLink = void 0;
|
51
|
-
var popup_1 = require("./utils/popup");
|
52
|
-
var event_types_1 = require("./utils/event-types");
|
53
|
-
var wallet_browser_event_types_1 = require("./utils/wallet-browser-event-types");
|
54
|
-
var sdk_specs_1 = require("./utils/sdk-specs");
|
55
|
-
var wagmiCoreConnectorsUtils_1 = require("./utils/wagmiCoreConnectorsUtils");
|
56
|
-
var currentOptions;
|
57
|
-
var possibleOrigins = new Set([
|
58
|
-
'https://web.meshconnect.com',
|
59
|
-
'https://web.getfront.com'
|
60
|
-
]);
|
61
|
-
var iframeElement = function () {
|
62
|
-
return document.getElementById(popup_1.iframeId);
|
63
|
-
};
|
64
|
-
function sendMessageToIframe(message) {
|
65
|
-
possibleOrigins.forEach(function (origin) {
|
66
|
-
var _a;
|
67
|
-
try {
|
68
|
-
(_a = iframeElement().contentWindow) === null || _a === void 0 ? void 0 : _a.postMessage(message, origin);
|
69
|
-
}
|
70
|
-
catch (e) {
|
71
|
-
console.error('Mesh SDK: Failed to deliver message to the iframe');
|
72
|
-
console.error(e);
|
73
|
-
}
|
74
|
-
});
|
75
|
-
}
|
76
|
-
function handleLinkEvent(event) {
|
77
|
-
return __awaiter(this, void 0, void 0, function () {
|
78
|
-
var _a, payload, payload, payload, payload, w, h, left, top_1, injectedConnectors;
|
79
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
80
|
-
return __generator(this, function (_o) {
|
81
|
-
switch (_o.label) {
|
82
|
-
case 0:
|
83
|
-
_a = event.data.type;
|
84
|
-
switch (_a) {
|
85
|
-
case 'brokerageAccountAccessToken': return [3 /*break*/, 1];
|
86
|
-
case 'delayedAuthentication': return [3 /*break*/, 2];
|
87
|
-
case 'transferFinished': return [3 /*break*/, 3];
|
88
|
-
case 'close': return [3 /*break*/, 4];
|
89
|
-
case 'done': return [3 /*break*/, 4];
|
90
|
-
case 'oauthLinkOpen': return [3 /*break*/, 5];
|
91
|
-
case 'loaded': return [3 /*break*/, 6];
|
92
|
-
}
|
93
|
-
return [3 /*break*/, 8];
|
94
|
-
case 1:
|
95
|
-
{
|
96
|
-
payload = {
|
97
|
-
accessToken: event.data.payload
|
98
|
-
};
|
99
|
-
(_b = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onEvent) === null || _b === void 0 ? void 0 : _b.call(currentOptions, {
|
100
|
-
type: 'integrationConnected',
|
101
|
-
payload: payload
|
102
|
-
});
|
103
|
-
(_c = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onIntegrationConnected) === null || _c === void 0 ? void 0 : _c.call(currentOptions, payload);
|
104
|
-
return [3 /*break*/, 9];
|
105
|
-
}
|
106
|
-
_o.label = 2;
|
107
|
-
case 2:
|
108
|
-
{
|
109
|
-
payload = {
|
110
|
-
delayedAuth: event.data.payload
|
111
|
-
};
|
112
|
-
(_d = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onEvent) === null || _d === void 0 ? void 0 : _d.call(currentOptions, {
|
113
|
-
type: 'integrationConnected',
|
114
|
-
payload: payload
|
115
|
-
});
|
116
|
-
(_e = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onIntegrationConnected) === null || _e === void 0 ? void 0 : _e.call(currentOptions, payload);
|
117
|
-
return [3 /*break*/, 9];
|
118
|
-
}
|
119
|
-
_o.label = 3;
|
120
|
-
case 3:
|
121
|
-
{
|
122
|
-
payload = event.data.payload;
|
123
|
-
(_f = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onEvent) === null || _f === void 0 ? void 0 : _f.call(currentOptions, {
|
124
|
-
type: 'transferCompleted',
|
125
|
-
payload: payload
|
126
|
-
});
|
127
|
-
(_g = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onTransferFinished) === null || _g === void 0 ? void 0 : _g.call(currentOptions, payload);
|
128
|
-
return [3 /*break*/, 9];
|
129
|
-
}
|
130
|
-
_o.label = 4;
|
131
|
-
case 4:
|
132
|
-
{
|
133
|
-
payload = (_h = event.data) === null || _h === void 0 ? void 0 : _h.payload;
|
134
|
-
(_j = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onExit) === null || _j === void 0 ? void 0 : _j.call(currentOptions, payload === null || payload === void 0 ? void 0 : payload.errorMessage, payload);
|
135
|
-
(0, popup_1.removePopup)();
|
136
|
-
return [3 /*break*/, 9];
|
137
|
-
}
|
138
|
-
_o.label = 5;
|
139
|
-
case 5:
|
140
|
-
{
|
141
|
-
if (event.data.link) {
|
142
|
-
w = 700;
|
143
|
-
h = 800;
|
144
|
-
left = screen.width / 2 - w / 2;
|
145
|
-
top_1 = screen.height / 2 - h / 2;
|
146
|
-
(_k = window
|
147
|
-
.open(event.data.link, '_blank', "popup,noopener,noreferrer,resizable,scrollbars,width=".concat(w, ",height=").concat(h, ",top=").concat(top_1, ",left=").concat(left))) === null || _k === void 0 ? void 0 : _k.focus();
|
148
|
-
}
|
149
|
-
return [3 /*break*/, 9];
|
150
|
-
}
|
151
|
-
_o.label = 6;
|
152
|
-
case 6:
|
153
|
-
sendMessageToIframe({
|
154
|
-
type: 'meshSDKSpecs',
|
155
|
-
payload: __assign({}, sdk_specs_1.sdkSpecs)
|
156
|
-
});
|
157
|
-
if (currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.accessTokens) {
|
158
|
-
sendMessageToIframe({
|
159
|
-
type: 'frontAccessTokens',
|
160
|
-
payload: currentOptions.accessTokens
|
161
|
-
});
|
162
|
-
}
|
163
|
-
if (currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.transferDestinationTokens) {
|
164
|
-
sendMessageToIframe({
|
165
|
-
type: 'frontTransferDestinationTokens',
|
166
|
-
payload: currentOptions.transferDestinationTokens
|
167
|
-
});
|
168
|
-
}
|
169
|
-
return [4 /*yield*/, (0, wagmiCoreConnectorsUtils_1.getWagmiCoreInjectedData)()];
|
170
|
-
case 7:
|
171
|
-
injectedConnectors = _o.sent();
|
172
|
-
if (injectedConnectors) {
|
173
|
-
sendMessageToIframe({
|
174
|
-
type: 'SDKinjectedWagmiConnectorsData',
|
175
|
-
payload: injectedConnectors
|
176
|
-
});
|
177
|
-
}
|
178
|
-
(_l = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onEvent) === null || _l === void 0 ? void 0 : _l.call(currentOptions, { type: 'pageLoaded' });
|
179
|
-
return [3 /*break*/, 9];
|
180
|
-
case 8:
|
181
|
-
{
|
182
|
-
if ((0, event_types_1.isLinkEventTypeKey)(event.data.type)) {
|
183
|
-
(_m = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onEvent) === null || _m === void 0 ? void 0 : _m.call(currentOptions, event.data);
|
184
|
-
}
|
185
|
-
return [3 /*break*/, 9];
|
186
|
-
}
|
187
|
-
_o.label = 9;
|
188
|
-
case 9: return [2 /*return*/];
|
189
|
-
}
|
190
|
-
});
|
191
|
-
});
|
192
|
-
}
|
193
|
-
function handleWalletBrowserEvent(event) {
|
194
|
-
return __awaiter(this, void 0, void 0, function () {
|
195
|
-
var _a, payload, result, error_1, payload, result, error_2, payload, result, error_3, payload, result, error_4, payload, result, error_5, payload, result, error_6;
|
196
|
-
return __generator(this, function (_b) {
|
197
|
-
switch (_b.label) {
|
198
|
-
case 0:
|
199
|
-
_a = event.data.type;
|
200
|
-
switch (_a) {
|
201
|
-
case 'walletBrowserInjectedWalletSelected': return [3 /*break*/, 1];
|
202
|
-
case 'walletBrowserChainSwitchRequest': return [3 /*break*/, 6];
|
203
|
-
case 'walletBrowserNativeTransferRequest': return [3 /*break*/, 11];
|
204
|
-
case 'walletBrowserNonNativeTransferRequest': return [3 /*break*/, 16];
|
205
|
-
case 'walletBrowserNativeSmartDeposit': return [3 /*break*/, 21];
|
206
|
-
case 'walletBrowserNonNativeSmartDeposit': return [3 /*break*/, 26];
|
207
|
-
case 'walletBrowserDisconnect': return [3 /*break*/, 31];
|
208
|
-
}
|
209
|
-
return [3 /*break*/, 32];
|
210
|
-
case 1:
|
211
|
-
payload = event.data.payload;
|
212
|
-
_b.label = 2;
|
213
|
-
case 2:
|
214
|
-
_b.trys.push([2, 4, , 5]);
|
215
|
-
return [4 /*yield*/, (0, wagmiCoreConnectorsUtils_1.connectToSpecificWallet)(payload.integrationName)];
|
216
|
-
case 3:
|
217
|
-
result = _b.sent();
|
218
|
-
if (result instanceof Error) {
|
219
|
-
throw result;
|
220
|
-
}
|
221
|
-
sendMessageToIframe({
|
222
|
-
type: 'SDKinjectedConnectionCompleted',
|
223
|
-
payload: {
|
224
|
-
accounts: result.accounts,
|
225
|
-
chainId: result.chainId,
|
226
|
-
signedTxHash: result.txSigned
|
227
|
-
}
|
228
|
-
});
|
229
|
-
return [3 /*break*/, 5];
|
230
|
-
case 4:
|
231
|
-
error_1 = _b.sent();
|
232
|
-
handleErrorAndSendMessage(error_1, 'SDKinjectedConnectionCompleted');
|
233
|
-
return [3 /*break*/, 5];
|
234
|
-
case 5: return [3 /*break*/, 32];
|
235
|
-
case 6:
|
236
|
-
payload = event.data.payload;
|
237
|
-
_b.label = 7;
|
238
|
-
case 7:
|
239
|
-
_b.trys.push([7, 9, , 10]);
|
240
|
-
return [4 /*yield*/, (0, wagmiCoreConnectorsUtils_1.switchChainFromSDK)(payload.chainId)];
|
241
|
-
case 8:
|
242
|
-
result = _b.sent();
|
243
|
-
if (result instanceof Error) {
|
244
|
-
throw result;
|
245
|
-
}
|
246
|
-
sendMessageToIframe({
|
247
|
-
type: 'SDKswitchChainCompleted',
|
248
|
-
payload: result
|
249
|
-
});
|
250
|
-
return [3 /*break*/, 10];
|
251
|
-
case 9:
|
252
|
-
error_2 = _b.sent();
|
253
|
-
handleErrorAndSendMessage(error_2, 'SDKswitchChainCompleted');
|
254
|
-
return [3 /*break*/, 10];
|
255
|
-
case 10: return [3 /*break*/, 32];
|
256
|
-
case 11:
|
257
|
-
payload = event.data.payload;
|
258
|
-
_b.label = 12;
|
259
|
-
case 12:
|
260
|
-
_b.trys.push([12, 14, , 15]);
|
261
|
-
return [4 /*yield*/, (0, wagmiCoreConnectorsUtils_1.sendTransactionFromSDK)(payload.toAddress, payload.amount, payload.decimalPlaces, payload.chainId, payload.account)];
|
262
|
-
case 13:
|
263
|
-
result = _b.sent();
|
264
|
-
if (result instanceof Error) {
|
265
|
-
throw result;
|
266
|
-
}
|
267
|
-
sendMessageToIframe({
|
268
|
-
type: 'SDKnativeTransferCompleted',
|
269
|
-
payload: result
|
270
|
-
});
|
271
|
-
return [3 /*break*/, 15];
|
272
|
-
case 14:
|
273
|
-
error_3 = _b.sent();
|
274
|
-
handleErrorAndSendMessage(error_3, 'SDKnativeTransferCompleted');
|
275
|
-
return [3 /*break*/, 15];
|
276
|
-
case 15: return [3 /*break*/, 32];
|
277
|
-
case 16:
|
278
|
-
payload = event.data.payload;
|
279
|
-
_b.label = 17;
|
280
|
-
case 17:
|
281
|
-
_b.trys.push([17, 19, , 20]);
|
282
|
-
return [4 /*yield*/, (0, wagmiCoreConnectorsUtils_1.sendNonNativeTransactionFromSDK)(payload.address, JSON.parse(payload.abi), payload.functionName, payload.args)];
|
283
|
-
case 18:
|
284
|
-
result = _b.sent();
|
285
|
-
if (result instanceof Error) {
|
286
|
-
throw result;
|
287
|
-
}
|
288
|
-
sendMessageToIframe({
|
289
|
-
type: 'SDKnonNativeTransferCompleted',
|
290
|
-
payload: result
|
291
|
-
});
|
292
|
-
return [3 /*break*/, 20];
|
293
|
-
case 19:
|
294
|
-
error_4 = _b.sent();
|
295
|
-
handleErrorAndSendMessage(error_4, 'SDKnonNativeTransferCompleted');
|
296
|
-
return [3 /*break*/, 20];
|
297
|
-
case 20: return [3 /*break*/, 32];
|
298
|
-
case 21:
|
299
|
-
payload = event.data.payload;
|
300
|
-
_b.label = 22;
|
301
|
-
case 22:
|
302
|
-
_b.trys.push([22, 24, , 25]);
|
303
|
-
return [4 /*yield*/, (0, wagmiCoreConnectorsUtils_1.sendNonNativeTransactionFromSDK)(payload.address, JSON.parse(payload.abi), payload.functionName, payload.args, payload.value)];
|
304
|
-
case 23:
|
305
|
-
result = _b.sent();
|
306
|
-
if (result instanceof Error) {
|
307
|
-
throw result;
|
308
|
-
}
|
309
|
-
sendMessageToIframe({
|
310
|
-
type: 'SDKnativeSmartDepositCompleted',
|
311
|
-
payload: {
|
312
|
-
txHash: result
|
313
|
-
}
|
314
|
-
});
|
315
|
-
return [3 /*break*/, 25];
|
316
|
-
case 24:
|
317
|
-
error_5 = _b.sent();
|
318
|
-
handleErrorAndSendMessage(error_5, 'SDKnativeSmartDepositCompleted');
|
319
|
-
return [3 /*break*/, 25];
|
320
|
-
case 25: return [3 /*break*/, 32];
|
321
|
-
case 26:
|
322
|
-
payload = event.data.payload;
|
323
|
-
_b.label = 27;
|
324
|
-
case 27:
|
325
|
-
_b.trys.push([27, 29, , 30]);
|
326
|
-
return [4 /*yield*/, (0, wagmiCoreConnectorsUtils_1.sendNonNativeTransactionFromSDK)(payload.address, JSON.parse(payload.abi), payload.functionName, payload.args)];
|
327
|
-
case 28:
|
328
|
-
result = _b.sent();
|
329
|
-
if (result) {
|
330
|
-
sendMessageToIframe({
|
331
|
-
type: 'SDKnonNativeSmartDepositCompleted',
|
332
|
-
payload: {
|
333
|
-
txHash: result
|
334
|
-
}
|
335
|
-
});
|
336
|
-
}
|
337
|
-
else {
|
338
|
-
throw new Error('Transfer failed');
|
339
|
-
}
|
340
|
-
return [3 /*break*/, 30];
|
341
|
-
case 29:
|
342
|
-
error_6 = _b.sent();
|
343
|
-
handleErrorAndSendMessage(error_6, 'SDKnonNativeSmartDepositCompleted');
|
344
|
-
return [3 /*break*/, 30];
|
345
|
-
case 30: return [3 /*break*/, 32];
|
346
|
-
case 31:
|
347
|
-
{
|
348
|
-
(0, wagmiCoreConnectorsUtils_1.disconnectAllAccounts)();
|
349
|
-
sendMessageToIframe({
|
350
|
-
type: 'SDKdisconnectSuccess'
|
351
|
-
});
|
352
|
-
return [3 /*break*/, 32];
|
353
|
-
}
|
354
|
-
_b.label = 32;
|
355
|
-
case 32: return [2 /*return*/];
|
356
|
-
}
|
357
|
-
});
|
358
|
-
});
|
359
|
-
}
|
360
|
-
function eventsListener(event) {
|
361
|
-
return __awaiter(this, void 0, void 0, function () {
|
362
|
-
return __generator(this, function (_a) {
|
363
|
-
switch (_a.label) {
|
364
|
-
case 0:
|
365
|
-
if (!(0, wallet_browser_event_types_1.isWalletBrowserEventTypeKey)(event.data.type)) return [3 /*break*/, 2];
|
366
|
-
return [4 /*yield*/, handleWalletBrowserEvent(event)];
|
367
|
-
case 1:
|
368
|
-
_a.sent();
|
369
|
-
return [3 /*break*/, 4];
|
370
|
-
case 2: return [4 /*yield*/, handleLinkEvent(event)];
|
371
|
-
case 3:
|
372
|
-
_a.sent();
|
373
|
-
_a.label = 4;
|
374
|
-
case 4: return [2 /*return*/];
|
375
|
-
}
|
376
|
-
});
|
377
|
-
});
|
378
|
-
}
|
379
|
-
function handleErrorAndSendMessage(error, messageType) {
|
380
|
-
var errorMessage = 'An unexpected error occurred';
|
381
|
-
if (error instanceof Error) {
|
382
|
-
errorMessage = error.message;
|
383
|
-
}
|
384
|
-
sendMessageToIframe({
|
385
|
-
type: messageType,
|
386
|
-
payload: {
|
387
|
-
error: errorMessage
|
388
|
-
}
|
389
|
-
});
|
390
|
-
}
|
391
|
-
var createLink = function (options) {
|
392
|
-
var openLink = function (linkToken) { return __awaiter(void 0, void 0, void 0, function () {
|
393
|
-
var linkUrl, iframeUrlObject;
|
394
|
-
var _a;
|
395
|
-
return __generator(this, function (_b) {
|
396
|
-
if (!linkToken) {
|
397
|
-
(_a = options === null || options === void 0 ? void 0 : options.onExit) === null || _a === void 0 ? void 0 : _a.call(options, 'Invalid link token!');
|
398
|
-
return [2 /*return*/];
|
399
|
-
}
|
400
|
-
currentOptions = options;
|
401
|
-
linkUrl = window.atob(linkToken);
|
402
|
-
iframeUrlObject = new URL(linkUrl);
|
403
|
-
if (iframeUrlObject.origin) {
|
404
|
-
possibleOrigins.add(iframeUrlObject.origin);
|
405
|
-
}
|
406
|
-
window.removeEventListener('message', eventsListener);
|
407
|
-
(0, popup_1.addPopup)(linkUrl);
|
408
|
-
window.addEventListener('message', eventsListener);
|
409
|
-
return [2 /*return*/];
|
410
|
-
});
|
411
|
-
}); };
|
412
|
-
var closeLink = function () {
|
413
|
-
var _a;
|
414
|
-
(0, popup_1.removePopup)();
|
415
|
-
window.removeEventListener('message', eventsListener);
|
416
|
-
(_a = options.onExit) === null || _a === void 0 ? void 0 : _a.call(options);
|
417
|
-
(0, wagmiCoreConnectorsUtils_1.disconnectAllAccounts)();
|
418
|
-
};
|
419
|
-
return {
|
420
|
-
openLink: openLink,
|
421
|
-
closeLink: closeLink
|
422
|
-
};
|
423
|
-
};
|
424
|
-
exports.createLink = createLink;
|
package/cjs/index.js
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
-
if (k2 === undefined) k2 = k;
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
-
}
|
8
|
-
Object.defineProperty(o, k2, desc);
|
9
|
-
}) : (function(o, m, k, k2) {
|
10
|
-
if (k2 === undefined) k2 = k;
|
11
|
-
o[k2] = m[k];
|
12
|
-
}));
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
-
};
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
-
exports.createLink = void 0;
|
18
|
-
__exportStar(require("./utils/types"), exports);
|
19
|
-
__exportStar(require("./utils/event-types"), exports);
|
20
|
-
var Link_1 = require("./Link");
|
21
|
-
Object.defineProperty(exports, "createLink", { enumerable: true, get: function () { return Link_1.createLink; } });
|
package/cjs/utils/event-types.js
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.isLinkEventTypeKey = void 0;
|
4
|
-
var LINK_EVENT_TYPE_KEYS = [
|
5
|
-
'integrationConnected',
|
6
|
-
'integrationConnectionError',
|
7
|
-
'integrationMfaRequired',
|
8
|
-
'integrationMfaEntered',
|
9
|
-
'integrationOAuthStarted',
|
10
|
-
'integrationAccountSelectionRequired',
|
11
|
-
'transferCompleted',
|
12
|
-
'integrationSelected',
|
13
|
-
'credentialsEntered',
|
14
|
-
'transferStarted',
|
15
|
-
'transferPreviewed',
|
16
|
-
'transferPreviewError',
|
17
|
-
'transferExecutionError',
|
18
|
-
'pageLoaded',
|
19
|
-
'transferAssetSelected',
|
20
|
-
'transferNetworkSelected',
|
21
|
-
'transferAmountEntered',
|
22
|
-
'transferMfaRequired',
|
23
|
-
'transferMfaEntered',
|
24
|
-
'transferKycRequired',
|
25
|
-
'done',
|
26
|
-
'close'
|
27
|
-
];
|
28
|
-
function isLinkEventTypeKey(key) {
|
29
|
-
return LINK_EVENT_TYPE_KEYS.includes(key);
|
30
|
-
}
|
31
|
-
exports.isLinkEventTypeKey = isLinkEventTypeKey;
|
package/cjs/utils/popup.js
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.addPopup = exports.removePopup = exports.iframeId = void 0;
|
4
|
-
var style_1 = require("./style");
|
5
|
-
var popupId = 'mesh-link-popup';
|
6
|
-
var backdropId = 'mesh-link-popup__backdrop';
|
7
|
-
var popupContentId = 'mesh-link-popup__popup-content';
|
8
|
-
var stylesId = 'mesh-link-popup__styles';
|
9
|
-
exports.iframeId = 'mesh-link-popup__iframe';
|
10
|
-
var getPopupHtml = function (link) { return "\n<div id=\"".concat(popupId, "\">\n <div id=\"").concat(backdropId, "\"></div>\n <div id=\"").concat(popupContentId, "\">\n <iframe id=\"").concat(exports.iframeId, "\" src=\"").concat(link, "\" allow=\"clipboard-read *; clipboard-write *\" />\n </div>\n</div>\n"); };
|
11
|
-
var getStyles = function (style) { return "\n<style id=\"".concat(stylesId, "\">\n body {\n position: fixed;\n left: 0;\n top: 0;\n bottom: 0;\n right: 0;\n overflow: hidden;\n }\n\n #").concat(popupId, " {\n all: unset;\n position: fixed;\n left: 0;\n top: 0;\n bottom: 0;\n right: 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n z-index: 10000;\n }\n\n #").concat(backdropId, " {\n position: absolute;\n left: 0;\n top: 0;\n bottom: 0;\n right: 0;\n z-index: 10000;\n background: black;\n opacity: ").concat((0, style_1.getNumber)(0.6, style === null || style === void 0 ? void 0 : style.io), ";\n }\n\n #").concat(popupContentId, " {\n position: absolute;\n height: 80%;\n max-height: 710px;\n min-height: 685px;\n margin: auto;\n z-index: 10001;\n width: 30%;\n max-width: 430px;\n min-width: 380px;\n display: flex;\n flex-direction: column;\n border-radius: ").concat((0, style_1.getNumber)(24, style === null || style === void 0 ? void 0 : style.ir), "px;\n background: white;\n flex-grow: 1;\n }\n\n #").concat(popupContentId, " iframe {\n border: none;\n width: 100%;\n flex-grow: 1;\n border-radius: ").concat((0, style_1.getNumber)(24, style === null || style === void 0 ? void 0 : style.ir), "px;\n }\n\n @media only screen and (max-width: 768px) {\n #").concat(popupContentId, " {\n height: 100vh;\n width: 100vw;\n max-width: 100%;\n min-width: 100%;\n max-height: 100%;\n min-height: 100%;\n border-radius: 0px;\n }\n\n #").concat(popupContentId, " iframe {\n border-radius: 0px;\n }\n }\n\n @media only screen and (max-height: 710px) {\n #").concat(popupContentId, " {\n max-height: 100%;\n min-height: 100%;\n }\n }\n</style>\n"); };
|
12
|
-
function removePopup() {
|
13
|
-
var _a, _b;
|
14
|
-
var existingPopup = window.document.getElementById(popupId);
|
15
|
-
(_a = existingPopup === null || existingPopup === void 0 ? void 0 : existingPopup.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(existingPopup);
|
16
|
-
var existingStyles = window.document.getElementById(stylesId);
|
17
|
-
(_b = existingStyles === null || existingStyles === void 0 ? void 0 : existingStyles.parentElement) === null || _b === void 0 ? void 0 : _b.removeChild(existingStyles);
|
18
|
-
}
|
19
|
-
exports.removePopup = removePopup;
|
20
|
-
function addPopup(iframeLink) {
|
21
|
-
var style = (0, style_1.getLinkStyle)(iframeLink);
|
22
|
-
removePopup();
|
23
|
-
var popup = getPopupHtml(iframeLink);
|
24
|
-
var stylesElement = htmlToElement(getStyles(style));
|
25
|
-
if (stylesElement) {
|
26
|
-
window.document.head.appendChild(stylesElement);
|
27
|
-
}
|
28
|
-
var popupElement = htmlToElement(popup);
|
29
|
-
if (popupElement) {
|
30
|
-
window.document.body.appendChild(popupElement);
|
31
|
-
}
|
32
|
-
}
|
33
|
-
exports.addPopup = addPopup;
|
34
|
-
function htmlToElement(html) {
|
35
|
-
var template = document.createElement('template');
|
36
|
-
html = html.trim();
|
37
|
-
template.innerHTML = html;
|
38
|
-
return template.content.firstChild;
|
39
|
-
}
|
package/cjs/utils/sdk-specs.js
DELETED
package/cjs/utils/style.js
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.getNumber = exports.getLinkStyle = void 0;
|
4
|
-
function getLinkStyle(url) {
|
5
|
-
try {
|
6
|
-
var params = new URLSearchParams(new URL(url).search);
|
7
|
-
var style = params.get('link_style');
|
8
|
-
return style && JSON.parse(window.atob(style));
|
9
|
-
}
|
10
|
-
catch (e) {
|
11
|
-
return undefined;
|
12
|
-
}
|
13
|
-
}
|
14
|
-
exports.getLinkStyle = getLinkStyle;
|
15
|
-
function getNumber(def, value) {
|
16
|
-
return value !== undefined ? value : def;
|
17
|
-
}
|
18
|
-
exports.getNumber = getNumber;
|
package/cjs/utils/types.js
DELETED
package/cjs/utils/version.js
DELETED