@meshconnect/web-link-sdk 3.3.0 → 3.3.2

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.js CHANGED
@@ -55,6 +55,7 @@ var currentOptions;
55
55
  var targetOrigin;
56
56
  var linkTokenOrigin;
57
57
  var currentIframeId = iframeId;
58
+ var bridgeParent = null;
58
59
  var iframeElement = function () {
59
60
  return document.getElementById(currentIframeId);
60
61
  };
@@ -118,6 +119,7 @@ function handleLinkEvent(event) {
118
119
  case 'done': {
119
120
  payload = (_g = event.data) === null || _g === void 0 ? void 0 : _g.payload;
120
121
  (_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);
122
+ bridgeParent === null || bridgeParent === void 0 ? void 0 : bridgeParent.destroy();
121
123
  removePopup();
122
124
  break;
123
125
  }
@@ -481,13 +483,18 @@ function handleErrorAndSendMessage(error, messageType) {
481
483
  }
482
484
  export var createLink = function (options) {
483
485
  var openLink = function (linkToken, customIframeId) {
484
- var _a;
486
+ var _a, _b;
485
487
  if (!linkToken) {
486
488
  (_a = options === null || options === void 0 ? void 0 : options.onExit) === null || _a === void 0 ? void 0 : _a.call(options, 'Invalid link token!');
487
489
  return;
488
490
  }
489
491
  currentOptions = options;
490
492
  var linkUrl = window.atob(linkToken);
493
+ var isProtocolValid = linkUrl.startsWith('http://') || linkUrl.startsWith('https://');
494
+ if (!isProtocolValid) {
495
+ (_b = options === null || options === void 0 ? void 0 : options.onExit) === null || _b === void 0 ? void 0 : _b.call(options, 'Invalid link token!');
496
+ return;
497
+ }
491
498
  linkUrl = addLanguage(linkUrl, currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.language);
492
499
  linkTokenOrigin = new URL(linkUrl).origin;
493
500
  window.removeEventListener('message', eventsListener);
@@ -510,11 +517,12 @@ export var createLink = function (options) {
510
517
  targetOrigin = window.location.origin;
511
518
  var iframe = iframeElement();
512
519
  if (iframe) {
513
- new BridgeParent(iframe);
520
+ bridgeParent = new BridgeParent(iframe);
514
521
  }
515
522
  };
516
523
  var closeLink = function () {
517
524
  var _a;
525
+ bridgeParent === null || bridgeParent === void 0 ? void 0 : bridgeParent.destroy();
518
526
  removePopup();
519
527
  window.removeEventListener('message', eventsListener);
520
528
  (_a = options.onExit) === null || _a === void 0 ? void 0 : _a.call(options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meshconnect/web-link-sdk",
3
- "version": "3.3.0",
3
+ "version": "3.3.2",
4
4
  "description": "A client-side JS library for integrating with Mesh Connect",
5
5
  "exports": "./index.js",
6
6
  "license": "MIT",
@@ -24,7 +24,7 @@
24
24
  "dependencies": {
25
25
  "@meshconnect/node-api": "^2.0.23",
26
26
  "@meshconnect/solana-web3.js": "^1.0.4",
27
- "@meshconnect/uwc-bridge-parent": "^0.0.2",
27
+ "@meshconnect/uwc-bridge-parent": "0.0.3",
28
28
  "bs58": "^5.0.0",
29
29
  "buffer": "^6.0.3",
30
30
  "ethers": "^6.11.1"
@@ -1 +1 @@
1
- export declare const sdkVersion = "3.3.0";
1
+ export declare const sdkVersion = "3.3.2";
package/utils/version.js CHANGED
@@ -1 +1 @@
1
- export var sdkVersion = '3.3.0';
1
+ export var sdkVersion = '3.3.2';