@meshconnect/web-link-sdk 2.0.1 → 2.0.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/cjs/Link.js CHANGED
@@ -1,149 +1,165 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- 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;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.createLink = void 0;
40
- var popup_1 = require("./utils/popup");
41
- var event_types_1 = require("./utils/event-types");
42
- var currentOptions;
43
- var iframeUrlObject;
44
- var iframeElement = function () {
45
- return document.getElementById(popup_1.iframeId);
46
- };
47
- function eventsListener(event) {
48
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
49
- switch (event.data.type) {
50
- case 'brokerageAccountAccessToken': {
51
- var payload = {
52
- accessToken: event.data.payload
53
- };
54
- (_a = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onEvent) === null || _a === void 0 ? void 0 : _a.call(currentOptions, {
55
- type: 'integrationConnected',
56
- payload: payload
57
- });
58
- (_b = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onIntegrationConnected) === null || _b === void 0 ? void 0 : _b.call(currentOptions, payload);
59
- break;
60
- }
61
- case 'delayedAuthentication': {
62
- var payload = {
63
- delayedAuth: event.data.payload
64
- };
65
- (_c = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onEvent) === null || _c === void 0 ? void 0 : _c.call(currentOptions, {
66
- type: 'integrationConnected',
67
- payload: payload
68
- });
69
- (_d = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onIntegrationConnected) === null || _d === void 0 ? void 0 : _d.call(currentOptions, payload);
70
- break;
71
- }
72
- case 'transferFinished': {
73
- var payload = event.data.payload;
74
- (_e = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onEvent) === null || _e === void 0 ? void 0 : _e.call(currentOptions, {
75
- type: 'transferCompleted',
76
- payload: payload
77
- });
78
- (_f = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onTransferFinished) === null || _f === void 0 ? void 0 : _f.call(currentOptions, payload);
79
- break;
80
- }
81
- case 'close':
82
- case 'done': {
83
- var payload = (_g = event.data) === null || _g === void 0 ? void 0 : _g.payload;
84
- (_h = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onExit) === null || _h === void 0 ? void 0 : _h.call(currentOptions, payload.errorMessage, payload);
85
- (0, popup_1.removePopup)();
86
- break;
87
- }
88
- case 'oauthLinkOpen': {
89
- if (event.data.link) {
90
- var w = 700;
91
- var h = 800;
92
- var left = screen.width / 2 - w / 2;
93
- var top_1 = screen.height / 2 - h / 2;
94
- (_j = window
95
- .open(event.data.link, '_blank', "popup,noopener,noreferrer,resizable,scrollbars,width=".concat(w, ",height=").concat(h, ",top=").concat(top_1, ",left=").concat(left))) === null || _j === void 0 ? void 0 : _j.focus();
96
- }
97
- break;
98
- }
99
- case 'loaded': {
100
- if (currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.accessTokens) {
101
- (_k = iframeElement().contentWindow) === null || _k === void 0 ? void 0 : _k.postMessage({ type: 'frontAccessTokens', payload: currentOptions.accessTokens }, (iframeUrlObject === null || iframeUrlObject === void 0 ? void 0 : iframeUrlObject.origin) || 'https://web.meshconnect.com');
102
- }
103
- if (currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.transferDestinationTokens) {
104
- (_l = iframeElement().contentWindow) === null || _l === void 0 ? void 0 : _l.postMessage({
105
- type: 'frontTransferDestinationTokens',
106
- payload: currentOptions.transferDestinationTokens
107
- }, (iframeUrlObject === null || iframeUrlObject === void 0 ? void 0 : iframeUrlObject.origin) || 'https://web.meshconnect.com');
108
- }
109
- (_m = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onEvent) === null || _m === void 0 ? void 0 : _m.call(currentOptions, { type: 'pageLoaded' });
110
- break;
111
- }
112
- default: {
113
- if ((0, event_types_1.isLinkEventTypeKey)(event.data.type)) {
114
- (_o = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onEvent) === null || _o === void 0 ? void 0 : _o.call(currentOptions, event.data);
115
- }
116
- break;
117
- }
118
- }
119
- }
120
- var createLink = function (options) {
121
- var openLink = function (linkToken) { return __awaiter(void 0, void 0, void 0, function () {
122
- var linkUrl;
123
- var _a;
124
- return __generator(this, function (_b) {
125
- if (!linkToken) {
126
- (_a = options === null || options === void 0 ? void 0 : options.onExit) === null || _a === void 0 ? void 0 : _a.call(options, 'Invalid link token!');
127
- return [2 /*return*/];
128
- }
129
- currentOptions = options;
130
- linkUrl = window.atob(linkToken);
131
- iframeUrlObject = new URL(linkUrl);
132
- window.removeEventListener('message', eventsListener);
133
- (0, popup_1.addPopup)(linkUrl);
134
- window.addEventListener('message', eventsListener);
135
- return [2 /*return*/];
136
- });
137
- }); };
138
- var closeLink = function () {
139
- var _a;
140
- (0, popup_1.removePopup)();
141
- window.removeEventListener('message', eventsListener);
142
- (_a = options.onExit) === null || _a === void 0 ? void 0 : _a.call(options);
143
- };
144
- return {
145
- openLink: openLink,
146
- closeLink: closeLink
147
- };
148
- };
149
- exports.createLink = createLink;
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 sdk_specs_1 = require("./utils/sdk-specs");
54
+ var currentOptions;
55
+ var iframeUrlObject;
56
+ var iframeElement = function () {
57
+ return document.getElementById(popup_1.iframeId);
58
+ };
59
+ function eventsListener(event) {
60
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
61
+ switch (event.data.type) {
62
+ case 'brokerageAccountAccessToken': {
63
+ var payload = {
64
+ accessToken: event.data.payload
65
+ };
66
+ (_a = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onEvent) === null || _a === void 0 ? void 0 : _a.call(currentOptions, {
67
+ type: 'integrationConnected',
68
+ payload: payload
69
+ });
70
+ (_b = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onIntegrationConnected) === null || _b === void 0 ? void 0 : _b.call(currentOptions, payload);
71
+ break;
72
+ }
73
+ case 'delayedAuthentication': {
74
+ var payload = {
75
+ delayedAuth: event.data.payload
76
+ };
77
+ (_c = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onEvent) === null || _c === void 0 ? void 0 : _c.call(currentOptions, {
78
+ type: 'integrationConnected',
79
+ payload: payload
80
+ });
81
+ (_d = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onIntegrationConnected) === null || _d === void 0 ? void 0 : _d.call(currentOptions, payload);
82
+ break;
83
+ }
84
+ case 'transferFinished': {
85
+ var payload = event.data.payload;
86
+ (_e = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onEvent) === null || _e === void 0 ? void 0 : _e.call(currentOptions, {
87
+ type: 'transferCompleted',
88
+ payload: payload
89
+ });
90
+ (_f = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onTransferFinished) === null || _f === void 0 ? void 0 : _f.call(currentOptions, payload);
91
+ break;
92
+ }
93
+ case 'close':
94
+ case 'done': {
95
+ var payload = (_g = event.data) === null || _g === void 0 ? void 0 : _g.payload;
96
+ (_h = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onExit) === null || _h === void 0 ? void 0 : _h.call(currentOptions, payload === null || payload === void 0 ? void 0 : payload.errorMessage, payload);
97
+ (0, popup_1.removePopup)();
98
+ break;
99
+ }
100
+ case 'oauthLinkOpen': {
101
+ if (event.data.link) {
102
+ var w = 700;
103
+ var h = 800;
104
+ var left = screen.width / 2 - w / 2;
105
+ var top_1 = screen.height / 2 - h / 2;
106
+ (_j = window
107
+ .open(event.data.link, '_blank', "popup,noopener,noreferrer,resizable,scrollbars,width=".concat(w, ",height=").concat(h, ",top=").concat(top_1, ",left=").concat(left))) === null || _j === void 0 ? void 0 : _j.focus();
108
+ }
109
+ break;
110
+ }
111
+ case 'loaded': {
112
+ if (currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.accessTokens) {
113
+ (_k = iframeElement().contentWindow) === null || _k === void 0 ? void 0 : _k.postMessage({
114
+ type: 'meshSDKSpecs',
115
+ payload: __assign({}, sdk_specs_1.sdkSpecs)
116
+ }, (iframeUrlObject === null || iframeUrlObject === void 0 ? void 0 : iframeUrlObject.origin) || 'https://web.meshconnect.com');
117
+ (_l = iframeElement().contentWindow) === null || _l === void 0 ? void 0 : _l.postMessage({ type: 'frontAccessTokens', payload: currentOptions.accessTokens }, (iframeUrlObject === null || iframeUrlObject === void 0 ? void 0 : iframeUrlObject.origin) || 'https://web.meshconnect.com');
118
+ }
119
+ if (currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.transferDestinationTokens) {
120
+ (_m = iframeElement().contentWindow) === null || _m === void 0 ? void 0 : _m.postMessage({
121
+ type: 'frontTransferDestinationTokens',
122
+ payload: currentOptions.transferDestinationTokens
123
+ }, (iframeUrlObject === null || iframeUrlObject === void 0 ? void 0 : iframeUrlObject.origin) || 'https://web.meshconnect.com');
124
+ }
125
+ (_o = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onEvent) === null || _o === void 0 ? void 0 : _o.call(currentOptions, { type: 'pageLoaded' });
126
+ break;
127
+ }
128
+ default: {
129
+ if ((0, event_types_1.isLinkEventTypeKey)(event.data.type)) {
130
+ (_p = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onEvent) === null || _p === void 0 ? void 0 : _p.call(currentOptions, event.data);
131
+ }
132
+ break;
133
+ }
134
+ }
135
+ }
136
+ var createLink = function (options) {
137
+ var openLink = function (linkToken) { return __awaiter(void 0, void 0, void 0, function () {
138
+ var linkUrl;
139
+ var _a;
140
+ return __generator(this, function (_b) {
141
+ if (!linkToken) {
142
+ (_a = options === null || options === void 0 ? void 0 : options.onExit) === null || _a === void 0 ? void 0 : _a.call(options, 'Invalid link token!');
143
+ return [2 /*return*/];
144
+ }
145
+ currentOptions = options;
146
+ linkUrl = window.atob(linkToken);
147
+ iframeUrlObject = new URL(linkUrl);
148
+ window.removeEventListener('message', eventsListener);
149
+ (0, popup_1.addPopup)(linkUrl);
150
+ window.addEventListener('message', eventsListener);
151
+ return [2 /*return*/];
152
+ });
153
+ }); };
154
+ var closeLink = function () {
155
+ var _a;
156
+ (0, popup_1.removePopup)();
157
+ window.removeEventListener('message', eventsListener);
158
+ (_a = options.onExit) === null || _a === void 0 ? void 0 : _a.call(options);
159
+ };
160
+ return {
161
+ openLink: openLink,
162
+ closeLink: closeLink
163
+ };
164
+ };
165
+ exports.createLink = createLink;
package/cjs/index.js CHANGED
@@ -1,21 +1,21 @@
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; } });
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; } });
@@ -1,31 +1,31 @@
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;
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;
@@ -1,39 +1,39 @@
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
- }
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
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sdkSpecs = void 0;
4
+ var version_1 = require("./version");
5
+ exports.sdkSpecs = {
6
+ platform: 'web',
7
+ version: version_1.sdkVersion
8
+ };
@@ -1,18 +1,18 @@
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;
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;
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sdkVersion = void 0;
4
+ exports.sdkVersion = '2.0.3';
package/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from './utils/types';
2
- export * from './utils/event-types';
3
- export { createLink } from './Link';
1
+ export * from './utils/types';
2
+ export * from './utils/event-types';
3
+ export { createLink } from './Link';
package/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export * from './utils/types';
2
- export * from './utils/event-types';
3
- export { createLink } from './Link';
1
+ export * from './utils/types';
2
+ export * from './utils/event-types';
3
+ export { createLink } from './Link';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meshconnect/web-link-sdk",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "A client-side JS library for integrating with Mesh Connect",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/FrontFin/mesh-web-sdk.git",
@@ -14,13 +14,13 @@
14
14
  "eslint-plugin-prettier": "^3.4.0",
15
15
  "prettier": "^2.2.1",
16
16
  "typescript": "^4.6.4",
17
- "ts-jest": "^29.1.1",
18
- "jest": "^29.6.4",
19
- "@types/jest": "^29.5.4",
20
- "jest-environment-jsdom": "^29.6.4"
17
+ "ts-jest": "^29.1.2",
18
+ "jest": "^29.7.0",
19
+ "@types/jest": "^29.5.12",
20
+ "jest-environment-jsdom": "^29.7.0"
21
21
  },
22
22
  "dependencies": {
23
- "@meshconnect/node-api": "^2.0.1"
23
+ "@meshconnect/node-api": "^2.0.3"
24
24
  },
25
25
  "jest": {
26
26
  "preset": "ts-jest",