@waves.exchange/provider-web 1.1.1 → 1.1.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/README.md CHANGED
@@ -12,7 +12,8 @@
12
12
  <a id="overview"></a>
13
13
  ## Overview
14
14
 
15
- ProviderWeb developed by Waves.Exchange implements a Signature Provider for [Signer](https://github.com/wavesplatform/signer) protocol library. Signer enables easy deploy dApps based on Waves blockchain. User's private key and SEED phrase are encrypted and stored in Waves.Exchange, so your web app does not have access to them.
15
+ ProviderWeb developed by Waves.Exchange implements a Signature Provider for [Signer](https://github.com/wavesplatform/signer) protocol library. Signer enables easy deploy dApps based on Waves blockchain. Users' encrypted private keys and SEED phrase are stored in waves.exchange domain of the local browser storage. Waves.Exchange and other apps do not have access to the local data as they are stored encrypted.
16
+
16
17
 
17
18
  > For now, signing is implemented for all types of transactions except exchange transactions.
18
19
 
@@ -18,13 +18,19 @@ var __spreadValues = (a, b) => {
18
18
  return a;
19
19
  };
20
20
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
+ var __publicField = (obj, key, value) => {
22
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
23
+ return value;
24
+ };
21
25
  Object.defineProperty(exports, "__esModule", { value: true });
22
26
  exports[Symbol.toStringTag] = "Module";
23
27
  var wavesBrowserBus = require("@waves/waves-browser-bus");
24
28
  var typedTsEvents = require("typed-ts-events");
25
29
  class Queue {
26
30
  constructor(maxLength) {
27
- this._actions = [];
31
+ __publicField(this, "_actions", []);
32
+ __publicField(this, "_maxLength");
33
+ __publicField(this, "_active");
28
34
  this._maxLength = maxLength;
29
35
  }
30
36
  get length() {
@@ -74,23 +80,18 @@ class Queue {
74
80
  }
75
81
  }
76
82
  const createError = (error) => {
77
- const commonError = {
78
- code: 0,
79
- message: (error == null ? void 0 : error.message) || error
80
- };
81
- switch (error == null ? void 0 : error.message) {
82
- case "SecurityError: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.":
83
- return __spreadProps(__spreadValues({}, commonError), {
84
- message: "Local storage is not available! It is possible that the Browser is in incognito mode!"
85
- });
86
- default:
87
- return commonError;
83
+ if (error && error.message === "SecurityError: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.") {
84
+ return __spreadProps(__spreadValues({}, error), {
85
+ message: "Local storage is not available! It is possible that the Browser is in incognito mode!"
86
+ });
88
87
  }
88
+ return error;
89
89
  };
90
90
  class Transport {
91
91
  constructor(queueLength) {
92
- this._events = [];
93
- this._toRunEvents = [];
92
+ __publicField(this, "_queue");
93
+ __publicField(this, "_events", []);
94
+ __publicField(this, "_toRunEvents", []);
94
95
  this._queue = new Queue(queueLength);
95
96
  }
96
97
  dropConnection() {
@@ -146,6 +147,9 @@ class Transport {
146
147
  const _TransportIframe = class extends Transport {
147
148
  constructor(url, queueLength) {
148
149
  super(queueLength);
150
+ __publicField(this, "_url");
151
+ __publicField(this, "_iframe");
152
+ __publicField(this, "_bus");
149
153
  this._url = url;
150
154
  this._initIframe();
151
155
  }
@@ -341,7 +345,7 @@ const _TransportIframe = class extends Transport {
341
345
  }
342
346
  };
343
347
  let TransportIframe = _TransportIframe;
344
- TransportIframe._timer = null;
348
+ __publicField(TransportIframe, "_timer", null);
345
349
  function isBrave() {
346
350
  var _a;
347
351
  return !!((_a = navigator.brave) == null ? void 0 : _a.isBrave);
@@ -354,8 +358,10 @@ function isSafari() {
354
358
  }
355
359
  class ProviderWeb {
356
360
  constructor(clientUrl, logs) {
357
- this.user = null;
358
- this.emitter = new typedTsEvents.EventEmitter();
361
+ __publicField(this, "user", null);
362
+ __publicField(this, "_transport");
363
+ __publicField(this, "_clientUrl");
364
+ __publicField(this, "emitter", new typedTsEvents.EventEmitter());
359
365
  this._clientUrl = (clientUrl || "https://waves.exchange/signer/") + `?${ProviderWeb._getCacheClean()}`;
360
366
  this._transport = new TransportIframe(this._clientUrl, 3);
361
367
  if (logs === true) {
@@ -17,11 +17,17 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __publicField = (obj, key, value) => {
21
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
22
+ return value;
23
+ };
20
24
  import { WindowAdapter, Bus, config } from "@waves/waves-browser-bus";
21
25
  import { EventEmitter } from "typed-ts-events";
22
26
  class Queue {
23
27
  constructor(maxLength) {
24
- this._actions = [];
28
+ __publicField(this, "_actions", []);
29
+ __publicField(this, "_maxLength");
30
+ __publicField(this, "_active");
25
31
  this._maxLength = maxLength;
26
32
  }
27
33
  get length() {
@@ -71,23 +77,18 @@ class Queue {
71
77
  }
72
78
  }
73
79
  const createError = (error) => {
74
- const commonError = {
75
- code: 0,
76
- message: (error == null ? void 0 : error.message) || error
77
- };
78
- switch (error == null ? void 0 : error.message) {
79
- case "SecurityError: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.":
80
- return __spreadProps(__spreadValues({}, commonError), {
81
- message: "Local storage is not available! It is possible that the Browser is in incognito mode!"
82
- });
83
- default:
84
- return commonError;
80
+ if (error && error.message === "SecurityError: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.") {
81
+ return __spreadProps(__spreadValues({}, error), {
82
+ message: "Local storage is not available! It is possible that the Browser is in incognito mode!"
83
+ });
85
84
  }
85
+ return error;
86
86
  };
87
87
  class Transport {
88
88
  constructor(queueLength) {
89
- this._events = [];
90
- this._toRunEvents = [];
89
+ __publicField(this, "_queue");
90
+ __publicField(this, "_events", []);
91
+ __publicField(this, "_toRunEvents", []);
91
92
  this._queue = new Queue(queueLength);
92
93
  }
93
94
  dropConnection() {
@@ -143,6 +144,9 @@ class Transport {
143
144
  const _TransportIframe = class extends Transport {
144
145
  constructor(url, queueLength) {
145
146
  super(queueLength);
147
+ __publicField(this, "_url");
148
+ __publicField(this, "_iframe");
149
+ __publicField(this, "_bus");
146
150
  this._url = url;
147
151
  this._initIframe();
148
152
  }
@@ -338,7 +342,7 @@ const _TransportIframe = class extends Transport {
338
342
  }
339
343
  };
340
344
  let TransportIframe = _TransportIframe;
341
- TransportIframe._timer = null;
345
+ __publicField(TransportIframe, "_timer", null);
342
346
  function isBrave() {
343
347
  var _a;
344
348
  return !!((_a = navigator.brave) == null ? void 0 : _a.isBrave);
@@ -351,8 +355,10 @@ function isSafari() {
351
355
  }
352
356
  class ProviderWeb {
353
357
  constructor(clientUrl, logs) {
354
- this.user = null;
355
- this.emitter = new EventEmitter();
358
+ __publicField(this, "user", null);
359
+ __publicField(this, "_transport");
360
+ __publicField(this, "_clientUrl");
361
+ __publicField(this, "emitter", new EventEmitter());
356
362
  this._clientUrl = (clientUrl || "https://waves.exchange/signer/") + `?${ProviderWeb._getCacheClean()}`;
357
363
  this._transport = new TransportIframe(this._clientUrl, 3);
358
364
  if (logs === true) {
@@ -1 +1 @@
1
- var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,n)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,__spreadValues=(e,t)=>{for(var n in t||(t={}))__hasOwnProp.call(t,n)&&__defNormalProp(e,n,t[n]);if(__getOwnPropSymbols)for(var n of __getOwnPropSymbols(t))__propIsEnum.call(t,n)&&__defNormalProp(e,n,t[n]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t));!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).providerWeb={})}(this,(function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n={},r={},o={},i={};Object.defineProperty(i,"__esModule",{value:!0}),i.keys=function(e){return Object.keys(e)};var s=Math.floor(Date.now()*Math.random()),a=0;i.uniqueId=function(e){return e+"-"+s+"-"+a++},i.toArray=function(e){return Array.isArray(e)?e:[e]},i.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){return e.reduce((function(e,t){return t(e)}),t)}};var c,u,l,h={},d={};c=d,Object.defineProperty(c,"__esModule",{value:!0}),u=c.config||(c.config={}),(l=u.console||(u.console={})).LOG_LEVEL={PRODUCTION:0,ERRORS:1,VERBOSE:2},l.logLevel=l.LOG_LEVEL.PRODUCTION,l.methodsData={log:{save:!1,logLevel:l.LOG_LEVEL.VERBOSE},info:{save:!1,logLevel:l.LOG_LEVEL.VERBOSE},warn:{save:!1,logLevel:l.LOG_LEVEL.VERBOSE},error:{save:!0,logLevel:l.LOG_LEVEL.ERRORS}};var p=t&&t.__assign||function(){return(p=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};Object.defineProperty(h,"__esModule",{value:!0});var f=d,_=i,v=("undefined"!=typeof self?self:t).console,y=Object.create(null);function g(e){y[e]||(y[e]=[])}function m(e,t){y[e].push(t)}h.console=p({},_.keys(f.config.console.methodsData).reduce((function(e,t){return e[t]=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];f.config.console.logLevel<f.config.console.methodsData[t].logLevel?f.config.console.methodsData[t].save&&(g(t),m(t,e)):v[t].apply(v,e)},e}),Object.create(null)),{getSavedMessages:function(e){return y[e]||[]}});var w={};Object.defineProperty(w,"__esModule",{value:!0});var E=function(){function e(e){this.size=0,this.hash=Object.create(null),e&&e.forEach(this.add,this)}return e.prototype.add=function(e){return this.hash[e]=!0,this.size=Object.keys(this.hash).length,this},e.prototype.has=function(e){return e in this.hash},e.prototype.toArray=function(){return Object.keys(this.hash)},e}();w.UniqPrimitiveCollection=E,function(e){function t(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}Object.defineProperty(e,"__esModule",{value:!0}),t(i),t(h),t(w)}(o),function(e){Object.defineProperty(e,"__esModule",{value:!0});var t,n,r=o;(t=e.EventType||(e.EventType={}))[t.Event=0]="Event",t[t.Action=1]="Action",t[t.Response=2]="Response",(n=e.ResponseStatus||(e.ResponseStatus={}))[n.Success=0]="Success",n[n.Error=1]="Error";var i=function(){function e(e,t){var n=this;this.id=r.uniqueId("bus"),this._timeout=t||5e3,this._adapter=e,this._adapter.addListener((function(e){return n._onMessage(e)})),this._eventHandlers=Object.create(null),this._activeRequestHash=Object.create(null),this._requestHandlers=Object.create(null),r.console.info('Create Bus with id "'+this.id+'"')}return e.prototype.dispatchEvent=function(t,n){return this._adapter.send(e._createEvent(t,n)),r.console.info('Dispatch event "'+t+'"',n),this},e.prototype.request=function(e,t,n){var o=this;return new Promise((function(i,s){var a,c=r.uniqueId(o.id+"-action"),u=n||o._timeout;-1!==(n||o._timeout)&&(a=setTimeout((function(){delete o._activeRequestHash[c];var t=new Error('Timeout error for request with name "'+e+'" and timeout '+u+"!");r.console.error(t),s(t)}),u));var l=function(){a&&clearTimeout(a)};o._activeRequestHash[c]={reject:function(t){l(),r.console.error('Error request with name "'+e+'"',t),s(t)},resolve:function(t){l(),r.console.info('Request with name "'+e+'" success resolved!',t),i(t)}},o._adapter.send({id:c,type:1,name:e,data:t}),r.console.info('Request with name "'+e+'"',t)}))},e.prototype.on=function(e,t,n){return this._addEventHandler(e,t,n,!1)},e.prototype.once=function(e,t,n){return this._addEventHandler(e,t,n,!0)},e.prototype.off=function(e,t){var n=this;return e?this._eventHandlers[e]?t?(this._eventHandlers[e]=this._eventHandlers[e].filter((function(e){return e.handler!==t})),this._eventHandlers[e].length||delete this._eventHandlers[e],this):(this._eventHandlers[e].slice().forEach((function(t){n.off(e,t.handler)})),this):this:(Object.keys(this._eventHandlers).forEach((function(e){return n.off(e,t)})),this)},e.prototype.registerRequestHandler=function(e,t){if(this._requestHandlers[e])throw new Error("Duplicate request handler!");return this._requestHandlers[e]=t,this},e.prototype.unregisterHandler=function(e){return this._requestHandlers[e]&&delete this._requestHandlers[e],this},e.prototype.changeAdapter=function(t){var n=this,r=new e(t,this._timeout);return Object.keys(this._eventHandlers).forEach((function(e){n._eventHandlers[e].forEach((function(t){t.once?r.once(e,t.handler,t.context):r.on(e,t.handler,t.context)}))})),Object.keys(this._requestHandlers).forEach((function(e){r.registerRequestHandler(e,n._requestHandlers[e])})),r},e.prototype.destroy=function(){r.console.info("Destroy Bus"),this.off(),this._adapter.destroy()},e.prototype._addEventHandler=function(e,t,n,r){return this._eventHandlers[e]||(this._eventHandlers[e]=[]),this._eventHandlers[e].push({handler:t,once:r,context:n}),this},e.prototype._onMessage=function(e){switch(e.type){case 0:r.console.info('Has event with name "'+String(e.name)+'"',e.data),this._fireEvent(String(e.name),e.data);break;case 1:r.console.info('Start action with id "'+e.id+'" and name "'+String(e.name)+'"',e.data),this._createResponse(e);break;case 2:r.console.info('Start response with name "'+e.id+'" and status "'+e.status+'"',e.content),this._fireEndAction(e)}},e.prototype._createResponse=function(t){var n=this,o=function(e){r.console.error(e),n._adapter.send({id:t.id,type:2,status:1,content:String(e)})};if(this._requestHandlers[String(t.name)])try{var i=this._requestHandlers[String(t.name)](t.data);e._isPromise(i)?i.then((function(e){n._adapter.send({id:t.id,type:2,status:0,content:e})}),o):this._adapter.send({id:t.id,type:2,status:0,content:i})}catch(S){o(S)}else o(new Error('Has no handler for "'+String(t.name)+'" action!'))},e.prototype._fireEndAction=function(e){if(this._activeRequestHash[e.id]){switch(e.status){case 1:this._activeRequestHash[e.id].reject(e.content);break;case 0:this._activeRequestHash[e.id].resolve(e.content)}delete this._activeRequestHash[e.id]}},e.prototype._fireEvent=function(e,t){this._eventHandlers[e]&&(this._eventHandlers[e]=this._eventHandlers[e].slice().filter((function(e){try{e.handler.call(e.context,t)}catch(S){r.console.warn(S)}return!e.once})),this._eventHandlers[e].length||delete this._eventHandlers[e])},e._createEvent=function(e,t){return{type:0,name:e,data:t}},e._isPromise=function(e){return e&&e.then&&"function"==typeof e.then},e}();e.Bus=i}(r);var b={};Object.defineProperty(b,"__esModule",{value:!0});var O=function(){};b.Adapter=O;var P,S,L={},j={},x={exports:{}};x.exports=(P={660:(e,t)=>{t.__esModule=!0,t.EventEmitter=void 0;var n=function(){function e(e){this._events=Object.create(null),this.catchHandler=e||function(){}}return e.prototype.hasListeners=function(e){return!(!this._events[e]||!this._events[e].length)},e.prototype.getActiveEvents=function(){var e=this;return Object.keys(this._events).filter((function(t){return e.hasListeners(t)}))},e.prototype.trigger=function(e,t){var n=this;this._events[e]&&(this._events[e].slice().forEach((function(r){try{r.handler.call(r.context,t)}catch(o){n.catchHandler(o)}r.once&&n.off(e,r.handler)})),this._events[e].length||delete this._events[e])},e.prototype.on=function(e,t,n){this._on(e,t,n,!1)},e.prototype.once=function(e,t,n){this._on(e,t,n,!0)},e.prototype.off=function(e,t){var n=this,r="string"==typeof e?e:null,o="function"==typeof t?t:"function"==typeof e?e:null;if(r)if(o){if(r in this._events){var i=this._events[r].map((function(e){return e.handler})).indexOf(o);this._events[r].splice(i,1)}}else delete this._events[r];else Object.keys(this._events).forEach((function(e){n.off(e,o)}))},e.prototype._on=function(e,t,n,r){this._events[e]||(this._events[e]=[]),this._events[e].push({handler:t,context:n,once:r})},e}();t.EventEmitter=n},607:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};t.__esModule=!0;var i=n(660);o(n(660),t),t.default=i.EventEmitter}},S={},function e(t){if(S[t])return S[t].exports;var n=S[t]={exports:{}};return P[t].call(n.exports,n,n.exports,e),n.exports}(607)),function(e){var n,r=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0});var o=function(e){function t(n,r){var o=e.call(this)||this;return o.win=n,o.type=r,o.handler=function(e){o.trigger("message",e)},r===t.PROTOCOL_TYPES.LISTEN&&o.win.addEventListener("message",o.handler,!1),o}var n;return r(t,e),t.prototype.dispatch=function(e){return this.win.postMessage(e,"*"),this},t.prototype.destroy=function(){this.type===t.PROTOCOL_TYPES.LISTEN&&this.win.removeEventListener("message",this.handler,!1),this.win=t._fakeWin},t._fakeWin={postMessage:n=function(){return null},addEventListener:n,removeEventListener:n},t}(x.exports.EventEmitter);e.WindowProtocol=o,(o=e.WindowProtocol||(e.WindowProtocol={})).PROTOCOL_TYPES={LISTEN:"listen",DISPATCH:"dispatch"},e.WindowProtocol=o}(j);var I,C=t&&t.__extends||(I=function(e,t){return(I=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}I(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),H=t&&t.__assign||function(){return(H=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};Object.defineProperty(L,"__esModule",{value:!0});var R=n,q=j,T=i,A={origins:[],availableChanelId:[]},W=function(e){function t(n,r,o){var i=e.call(this)||this;return i.id=R.uniqueId("wa"),i.callbacks=[],i.options=t.prepareOptions(o),i.listen=n,i.dispatch=r,i.listen.forEach((function(e){return e.on("message",i.onMessage,i)})),i}return C(t,e),t.prototype.addListener=function(e){return this.callbacks.push(e),R.console.info("WindowAdapter: Add iframe message listener"),this},t.prototype.send=function(e){var t=H({},e,{chanelId:this.options.chanelId});return this.dispatch.forEach((function(e){return e.dispatch(t)})),R.console.info("WindowAdapter: Send message",t),this},t.prototype.destroy=function(){this.listen.forEach((function(e){return e.destroy()})),this.dispatch.forEach((function(e){return e.destroy()})),R.console.info("WindowAdapter: Destroy")},t.prototype.onMessage=function(e){this.accessEvent(e)&&this.callbacks.forEach((function(t){try{t(e.data)}catch(S){R.console.warn("WindowAdapter: Unhandled exception!",S)}}))},t.prototype.accessEvent=function(e){if("object"!=typeof e.data||null==e.data.type)return R.console.info("WindowAdapter: Block event. Wrong event format!",e.data),!1;if(!this.options.origins.has("*")&&!this.options.origins.has(e.origin))return R.console.info('SimpleWindowAdapter: Block event by origin "'+e.origin+'"'),!1;if(!this.options.availableChanelId.size)return!0;var t=!(!e.data.chanelId||!this.options.availableChanelId.has(e.data.chanelId));return t||R.console.info('SimpleWindowAdapter: Block event by chanel id "'+e.data.chanelId+'"'),t},t.createSimpleWindowAdapter=function(e,n){var r=this,o=this.getContentOrigin(e),i=this.prepareOptions(n),s=[];o&&i.origins.add(o);var a=new q.WindowProtocol(window,q.WindowProtocol.PROTOCOL_TYPES.LISTEN),c=function(e){s.push(e)};return a.on("message",c),this.getIframeContent(e).then((function(e){var n=new q.WindowProtocol(e.win,q.WindowProtocol.PROTOCOL_TYPES.DISPATCH),o=new t([a],[n],r.unPrepareOptions(i));return s.forEach((function(e){o.onMessage(e)})),a.off("message",c),o}))},t.prepareOptions=function(e){void 0===e&&(e=A);var t=function(e,t){return T.pipe(R.toArray,(n=t,function(e){return e.reduce((function(e,t){return e.add(t)}),n)}))(e);var n},n=t(e.origins||[],new R.UniqPrimitiveCollection([window.location.origin])),r=t(e.availableChanelId||[],new R.UniqPrimitiveCollection);return H({},e,{origins:n,availableChanelId:r})},t.unPrepareOptions=function(e){return{origins:e.origins.toArray(),availableChanelId:e.availableChanelId.toArray(),chanelId:e.chanelId}},t.getIframeContent=function(e){return e?e instanceof HTMLIFrameElement?e.contentWindow?Promise.resolve({win:e.contentWindow}):new Promise((function(t,n){e.addEventListener("load",(function(){return t({win:e.contentWindow})}),!1),e.addEventListener("error",n,!1)})):Promise.resolve({win:e}):Promise.resolve({win:window.opener||window.parent})},t.getContentOrigin=function(e){if(!e)try{return new URL(document.referrer).origin}catch(S){return null}if(!(e instanceof HTMLIFrameElement))try{return window.top.origin}catch(S){return null}try{return new URL(e.src).origin||null}catch(S){return null}},t}(b.Adapter);L.WindowAdapter=W,function(e){function t(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}Object.defineProperty(e,"__esModule",{value:!0}),t(r),t(b),t(L),t(j),t(d),t(o)}(n);class k{constructor(e){this._actions=[],this._maxLength=e}get length(){return this._actions.length+(null==this._active?0:1)}push(e){if(this._actions.length>=this._maxLength)throw new Error("Cant't push action! Queue is full!");return new Promise(((t,n)=>{const r=()=>{this._active=void 0;const e=this._actions.map((e=>e.action)).indexOf(o);-1!==e&&this._actions.splice(e,1),this.run()},o=()=>e().then((e=>{r(),t(e)}),(e=>{r(),n(e)}));this._actions.push({action:o,reject:n}),1===this.length&&this.run()}))}clear(e){const t="string"==typeof(e=e||new Error("Rejection with clear queue!"))?new Error(e):e;this._actions.splice(0,this._actions.length).forEach((e=>e.reject(t))),this._active=void 0}canPush(){return this._actions.length<this._maxLength}run(){const e=this._actions.shift();null!=e&&(this._active=e.action())}}const M=e=>{const t={code:0,message:(null==e?void 0:e.message)||e};switch(null==e?void 0:e.message){case"SecurityError: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.":return __spreadProps(__spreadValues({},t),{message:"Local storage is not available! It is possible that the Browser is in incognito mode!"});default:return t}};const D=class extends class{constructor(e){this._events=[],this._toRunEvents=[],this._queue=new k(e)}dropConnection(){this._queue.clear(new Error("User rejection!")),this._events.forEach((e=>this._toRunEvents.push(e))),this._dropTransportConnect()}sendEvent(e){this._events.push(e),this._toRunEvents.push(e)}dialog(e){return this._runBeforeShow(),this._getBus().then((t=>{const n=this._wrapAction((()=>e(t)));return this._runEvents(t),this._queue.canPush()?this._queue.push(n).then((e=>(this._runAfterShow(),e))).catch((e=>(this._runAfterShow(),Promise.reject(M(e))))):Promise.reject(new Error("Queue is full!"))}))}_runBeforeShow(){0===this._queue.length&&this._beforeShow()}_runAfterShow(){0===this._queue.length&&this._afterShow()}_runEvents(e){this._toRunEvents.splice(0,this._events.length).forEach((t=>t(e)))}_wrapAction(e){return this._toRunEvents?()=>{const t=e();return t.catch((()=>{this._events.forEach((e=>this._toRunEvents.push(e)))})),t}:e}}{constructor(e,t){super(t),this._url=e,this._initIframe()}get(){return this._iframe||this._initIframe(),this._iframe}_dropTransportConnect(){null!=this._iframe&&(document.body.removeChild(this._iframe),this._initIframe()),this._bus&&(this._bus.destroy(),this._bus=void 0)}_getBus(){return this._bus?Promise.resolve(this._bus):n.WindowAdapter.createSimpleWindowAdapter(this._iframe).then((e=>new Promise((t=>{this._bus=new n.Bus(e,-1),this._bus.once("ready",(()=>{t(this._bus)}))}))))}_beforeShow(){this._showIframe()}_afterShow(){this._hideIframe()}_initIframe(){this._iframe=this._createIframe(),this._addIframeToDom(this._iframe),this._listenFetchURLError(this._iframe),this._hideIframe()}_addIframeToDom(e){null!=document.body?document.body.appendChild(e):document.addEventListener("DOMContentLoaded",(()=>{document.body.appendChild(e)}))}_createIframe(){const e=document.createElement("iframe");return e.style.transition="opacity .2s",e.style.position="absolute",e.style.opacity="0",e.style.width="100%",e.style.height="100%",e.style.left="0",e.style.top="0",e.style.border="none",e.style.position="fixed",e}_showIframe(){this._applyStyle({width:"100%",height:"100%",left:"0",top:"0",border:"none",position:"fixed",display:"block",opacity:"0",zIndex:"99999999"}),null!=D._timer&&clearTimeout(D._timer),D._timer=setTimeout((()=>{this._applyStyle({opacity:"1"})}),0)}_hideIframe(){this._applyStyle({opacity:"0"}),null!=D._timer&&clearTimeout(D._timer),D._timer=setTimeout((()=>{this._applyStyle({width:"10px",height:"10px",left:"-100px",top:"-100px",position:"absolute",opacity:"0",zIndex:"0",display:"none"})}),200)}_applyStyle(e){Object.entries(e).forEach((([e,t])=>{null!=t&&this._iframe&&(this._iframe.style[e]=t)}))}_renderErrorPage(e,t,n){e.parentElement&&(e.parentElement.style.height="100%"),Object.assign(e.style,{position:"relative",boxSizing:"border-box",width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center",margin:"0px"});const r=document.createElement("div");Object.assign(r.style,{position:"fixed",zIndex:"-1",height:"100%",width:"100%",overflow:"hidden",backgroundColor:"#000",opacity:"0.6"});const o=document.createElement("div");Object.assign(o.style,{position:"fixed",display:"flex",justifyContent:"center",alignItems:"center",flexDirection:"column",margin:"0",backgroundColor:"#292F3C",width:"520px",borderRadius:"6px",padding:"40px",boxSizing:"border-box"});const i=document.createElement("div");i.textContent=n,Object.assign(i.style,{fontSize:"15px",lineHeight:"20px",color:"#fff",marginBottom:"40px",fontFamily:"Roboto, sans-serif"});const s=document.createElement("button");s.textContent="OK",s.addEventListener("click",(()=>t())),Object.assign(s.style,{width:"100%",fontSize:"15px",lineHeight:"48px",padding:" 0 40px",color:"#fff",backgroundColor:"#5A81EA",outline:"none",border:"none",cursor:"pointer",fontFamily:"Roboto, sans-serif",borderRadius:"4px"}),o.appendChild(i),o.appendChild(s),e.appendChild(r),e.appendChild(o)}_listenFetchURLError(e){fetch(this._url).catch((()=>{e.addEventListener("load",(()=>{e.contentDocument&&(this._renderErrorPage(e.contentDocument.body,(()=>this.dropConnection()),"The request could not be processed. To resume your further work, disable the installed plugins."),this._showIframe())}))}))}};let B=D;B._timer=null;class U{constructor(e,t){this.user=null,this.emitter=new x.exports.EventEmitter,this._clientUrl=(e||"https://waves.exchange/signer/")+`?${U._getCacheClean()}`,this._transport=new B(this._clientUrl,3),!0===t&&(n.config.console.logLevel=n.config.console.LOG_LEVEL.VERBOSE)}static _getCacheClean(){return String(Date.now()%6e4)}on(e,t){return this.emitter.on(e,t),this}once(e,t){return this.emitter.once(e,t),this}off(e,t){return this.emitter.once(e,t),this}connect(e){return Promise.resolve(this._transport.sendEvent((t=>t.dispatchEvent("connect",e))))}logout(){return this.user=null,Promise.resolve(this._transport.dropConnection())}login(){var e;if(this.user)return Promise.resolve(this.user);const t=this._transport.get();if(function(){const e=navigator.userAgent.toLowerCase(),t=e.includes("safari")&&!e.includes("chrome");return null!=navigator.platform&&/iPad|iPhone|iPod/.test(navigator.platform)||t}()||function(){var e;return!!(null==(e=navigator.brave)?void 0:e.isBrave)}()){if(!(null==(e=t.contentWindow)?void 0:e.open(this._clientUrl)))throw new Error("Window was blocked")}return t.src=this._clientUrl,this._transport.dialog((e=>e.request("login").then((e=>(this.user=e,e))).catch((e=>(this._transport.dropConnection(),Promise.reject(M(e)))))))}signMessage(e){return this.login().then((()=>this._transport.dialog((t=>t.request("sign-message",e)))))}signTypedData(e){return this.login().then((()=>this._transport.dialog((t=>t.request("sign-typed-data",e)))))}sign(e){return this.login().then((()=>this._transport.dialog((t=>t.request("sign",e)))))}}e.ProviderWeb=U,Object.defineProperty(e,"__esModule",{value:!0}),e[Symbol.toStringTag]="Module"}));
1
+ var ht=Object.defineProperty,dt=Object.defineProperties;var ft=Object.getOwnPropertyDescriptors;var U=Object.getOwnPropertySymbols;var pt=Object.prototype.hasOwnProperty,_t=Object.prototype.propertyIsEnumerable;var k=(_,u,p)=>u in _?ht(_,u,{enumerable:!0,configurable:!0,writable:!0,value:p}):_[u]=p,V=(_,u)=>{for(var p in u||(u={}))pt.call(u,p)&&k(_,p,u[p]);if(U)for(var p of U(u))_t.call(u,p)&&k(_,p,u[p]);return _},z=(_,u)=>dt(_,ft(u));var v=(_,u,p)=>(k(_,typeof u!="symbol"?u+"":u,p),p);(function(_,u){typeof exports=="object"&&typeof module!="undefined"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(_=typeof globalThis!="undefined"?globalThis:_||self,u(_.providerWeb={}))})(this,function(_){"use strict";var u=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},p={},M={},C={},m={};Object.defineProperty(m,"__esModule",{value:!0});function F(o){return Object.keys(o)}m.keys=F;var G=Math.floor(Date.now()*Math.random()),N=0;function $(o){return o+"-"+G+"-"+N++}m.uniqueId=$;function Y(o){return Array.isArray(o)?o:[o]}m.toArray=Y;function Q(){for(var o=[],t=0;t<arguments.length;t++)o[t]=arguments[t];return function(n){return o.reduce(function(r,e){return e(r)},n)}}m.pipe=Q;var j={},x={};(function(o){Object.defineProperty(o,"__esModule",{value:!0}),function(t){(function(n){n.LOG_LEVEL={PRODUCTION:0,ERRORS:1,VERBOSE:2},n.logLevel=n.LOG_LEVEL.PRODUCTION,n.methodsData={log:{save:!1,logLevel:n.LOG_LEVEL.VERBOSE},info:{save:!1,logLevel:n.LOG_LEVEL.VERBOSE},warn:{save:!1,logLevel:n.LOG_LEVEL.VERBOSE},error:{save:!0,logLevel:n.LOG_LEVEL.ERRORS}}})(t.console||(t.console={}))}(o.config||(o.config={}))})(x);var A=u&&u.__assign||function(){return A=Object.assign||function(o){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(o[e]=t[e])}return o},A.apply(this,arguments)};Object.defineProperty(j,"__esModule",{value:!0});var b=x,K=m,B=function(o){return o.console}(typeof self!="undefined"?self:u),O=Object.create(null);function J(o){O[o]||(O[o]=[])}function X(o,t){O[o].push(t)}function Z(){return K.keys(b.config.console.methodsData).reduce(function(o,t){return o[t]=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];b.config.console.logLevel<b.config.console.methodsData[t].logLevel?b.config.console.methodsData[t].save&&(J(t),X(t,n)):B[t].apply(B,n)},o},Object.create(null))}j.console=A({},Z(),{getSavedMessages:function(o){return O[o]||[]}});var H={};Object.defineProperty(H,"__esModule",{value:!0});var tt=function(){function o(t){this.size=0,this.hash=Object.create(null),t&&t.forEach(this.add,this)}return o.prototype.add=function(t){return this.hash[t]=!0,this.size=Object.keys(this.hash).length,this},o.prototype.has=function(t){return t in this.hash},o.prototype.toArray=function(){return Object.keys(this.hash)},o}();H.UniqPrimitiveCollection=tt,function(o){function t(n){for(var r in n)o.hasOwnProperty(r)||(o[r]=n[r])}Object.defineProperty(o,"__esModule",{value:!0}),t(m),t(j),t(H)}(C),function(o){Object.defineProperty(o,"__esModule",{value:!0});var t=C;(function(r){r[r.Event=0]="Event",r[r.Action=1]="Action",r[r.Response=2]="Response"})(o.EventType||(o.EventType={})),function(r){r[r.Success=0]="Success",r[r.Error=1]="Error"}(o.ResponseStatus||(o.ResponseStatus={}));var n=function(){function r(e,i){var s=this;this.id=t.uniqueId("bus"),this._timeout=i||5e3,this._adapter=e,this._adapter.addListener(function(a){return s._onMessage(a)}),this._eventHandlers=Object.create(null),this._activeRequestHash=Object.create(null),this._requestHandlers=Object.create(null),t.console.info('Create Bus with id "'+this.id+'"')}return r.prototype.dispatchEvent=function(e,i){return this._adapter.send(r._createEvent(e,i)),t.console.info('Dispatch event "'+e+'"',i),this},r.prototype.request=function(e,i,s){var a=this;return new Promise(function(c,l){var h=t.uniqueId(a.id+"-action"),d=s||a._timeout,f;(s||a._timeout)!==-1&&(f=setTimeout(function(){delete a._activeRequestHash[h];var y=new Error('Timeout error for request with name "'+e+'" and timeout '+d+"!");t.console.error(y),l(y)},d));var g=function(){f&&clearTimeout(f)};a._activeRequestHash[h]={reject:function(y){g(),t.console.error('Error request with name "'+e+'"',y),l(y)},resolve:function(y){g(),t.console.info('Request with name "'+e+'" success resolved!',y),c(y)}},a._adapter.send({id:h,type:1,name:e,data:i}),t.console.info('Request with name "'+e+'"',i)})},r.prototype.on=function(e,i,s){return this._addEventHandler(e,i,s,!1)},r.prototype.once=function(e,i,s){return this._addEventHandler(e,i,s,!0)},r.prototype.off=function(e,i){var s=this;return e?this._eventHandlers[e]?i?(this._eventHandlers[e]=this._eventHandlers[e].filter(function(a){return a.handler!==i}),this._eventHandlers[e].length||delete this._eventHandlers[e],this):(this._eventHandlers[e].slice().forEach(function(a){s.off(e,a.handler)}),this):this:(Object.keys(this._eventHandlers).forEach(function(a){return s.off(a,i)}),this)},r.prototype.registerRequestHandler=function(e,i){if(this._requestHandlers[e])throw new Error("Duplicate request handler!");return this._requestHandlers[e]=i,this},r.prototype.unregisterHandler=function(e){return this._requestHandlers[e]&&delete this._requestHandlers[e],this},r.prototype.changeAdapter=function(e){var i=this,s=new r(e,this._timeout);return Object.keys(this._eventHandlers).forEach(function(a){i._eventHandlers[a].forEach(function(c){c.once?s.once(a,c.handler,c.context):s.on(a,c.handler,c.context)})}),Object.keys(this._requestHandlers).forEach(function(a){s.registerRequestHandler(a,i._requestHandlers[a])}),s},r.prototype.destroy=function(){t.console.info("Destroy Bus"),this.off(),this._adapter.destroy()},r.prototype._addEventHandler=function(e,i,s,a){return this._eventHandlers[e]||(this._eventHandlers[e]=[]),this._eventHandlers[e].push({handler:i,once:a,context:s}),this},r.prototype._onMessage=function(e){switch(e.type){case 0:t.console.info('Has event with name "'+String(e.name)+'"',e.data),this._fireEvent(String(e.name),e.data);break;case 1:t.console.info('Start action with id "'+e.id+'" and name "'+String(e.name)+'"',e.data),this._createResponse(e);break;case 2:t.console.info('Start response with name "'+e.id+'" and status "'+e.status+'"',e.content),this._fireEndAction(e);break}},r.prototype._createResponse=function(e){var i=this,s=function(c){t.console.error(c),i._adapter.send({id:e.id,type:2,status:1,content:String(c)})};if(!this._requestHandlers[String(e.name)]){s(new Error('Has no handler for "'+String(e.name)+'" action!'));return}try{var a=this._requestHandlers[String(e.name)](e.data);r._isPromise(a)?a.then(function(c){i._adapter.send({id:e.id,type:2,status:0,content:c})},s):this._adapter.send({id:e.id,type:2,status:0,content:a})}catch(c){s(c)}},r.prototype._fireEndAction=function(e){if(this._activeRequestHash[e.id]){switch(e.status){case 1:this._activeRequestHash[e.id].reject(e.content);break;case 0:this._activeRequestHash[e.id].resolve(e.content);break}delete this._activeRequestHash[e.id]}},r.prototype._fireEvent=function(e,i){!this._eventHandlers[e]||(this._eventHandlers[e]=this._eventHandlers[e].slice().filter(function(s){try{s.handler.call(s.context,i)}catch(a){t.console.warn(a)}return!s.once}),this._eventHandlers[e].length||delete this._eventHandlers[e])},r._createEvent=function(e,i){return{type:0,name:e,data:i}},r._isPromise=function(e){return e&&e.then&&typeof e.then=="function"},r}();o.Bus=n}(M);var P={};Object.defineProperty(P,"__esModule",{value:!0});var et=function(){function o(){}return o}();P.Adapter=et;var I={},q={},R={exports:{}};(function(o,t){(function(n,r){o.exports=r()})(u,function(){return(()=>{var n={660:(e,i)=>{i.__esModule=!0,i.EventEmitter=void 0;var s=function(){function a(c){this._events=Object.create(null),this.catchHandler=c||function(){}}return a.prototype.hasListeners=function(c){return!(!this._events[c]||!this._events[c].length)},a.prototype.getActiveEvents=function(){var c=this;return Object.keys(this._events).filter(function(l){return c.hasListeners(l)})},a.prototype.trigger=function(c,l){var h=this;this._events[c]&&(this._events[c].slice().forEach(function(d){try{d.handler.call(d.context,l)}catch(f){h.catchHandler(f)}d.once&&h.off(c,d.handler)}),this._events[c].length||delete this._events[c])},a.prototype.on=function(c,l,h){this._on(c,l,h,!1)},a.prototype.once=function(c,l,h){this._on(c,l,h,!0)},a.prototype.off=function(c,l){var h=this,d=typeof c=="string"?c:null,f=typeof l=="function"?l:typeof c=="function"?c:null;if(d)if(f){if(d in this._events){var g=this._events[d].map(function(y){return y.handler}).indexOf(f);this._events[d].splice(g,1)}}else delete this._events[d];else Object.keys(this._events).forEach(function(y){h.off(y,f)})},a.prototype._on=function(c,l,h,d){this._events[c]||(this._events[c]=[]),this._events[c].push({handler:l,context:h,once:d})},a}();i.EventEmitter=s},607:function(e,i,s){var a=this&&this.__createBinding||(Object.create?function(h,d,f,g){g===void 0&&(g=f),Object.defineProperty(h,g,{enumerable:!0,get:function(){return d[f]}})}:function(h,d,f,g){g===void 0&&(g=f),h[g]=d[f]}),c=this&&this.__exportStar||function(h,d){for(var f in h)f==="default"||Object.prototype.hasOwnProperty.call(d,f)||a(d,h,f)};i.__esModule=!0;var l=s(660);c(s(660),i),i.default=l.EventEmitter}},r={};return function e(i){if(r[i])return r[i].exports;var s=r[i]={exports:{}};return n[i].call(s.exports,s,s.exports,e),s.exports}(607)})()})})(R),function(o){var t=u&&u.__extends||function(){var e=function(i,s){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,c){a.__proto__=c}||function(a,c){for(var l in c)c.hasOwnProperty(l)&&(a[l]=c[l])},e(i,s)};return function(i,s){e(i,s);function a(){this.constructor=i}i.prototype=s===null?Object.create(s):(a.prototype=s.prototype,new a)}}();Object.defineProperty(o,"__esModule",{value:!0});var n=R.exports,r=function(e){t(i,e);function i(s,a){var c=e.call(this)||this;return c.win=s,c.type=a,c.handler=function(l){c.trigger("message",l)},a===i.PROTOCOL_TYPES.LISTEN&&c.win.addEventListener("message",c.handler,!1),c}return i.prototype.dispatch=function(s){return this.win.postMessage(s,"*"),this},i.prototype.destroy=function(){this.type===i.PROTOCOL_TYPES.LISTEN&&this.win.removeEventListener("message",this.handler,!1),this.win=i._fakeWin},i._fakeWin=function(){var s=function(){return null};return{postMessage:s,addEventListener:s,removeEventListener:s}}(),i}(n.EventEmitter);o.WindowProtocol=r,function(e){e.PROTOCOL_TYPES={LISTEN:"listen",DISPATCH:"dispatch"}}(r=o.WindowProtocol||(o.WindowProtocol={})),o.WindowProtocol=r}(q);var nt=u&&u.__extends||function(){var o=function(t,n){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,e){r.__proto__=e}||function(r,e){for(var i in e)e.hasOwnProperty(i)&&(r[i]=e[i])},o(t,n)};return function(t,n){o(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),S=u&&u.__assign||function(){return S=Object.assign||function(o){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(o[e]=t[e])}return o},S.apply(this,arguments)};Object.defineProperty(I,"__esModule",{value:!0});var rt=P,w=p,L=q,it=m,ot={origins:[],availableChanelId:[]},st=function(o){nt(t,o);function t(n,r,e){var i=o.call(this)||this;return i.id=w.uniqueId("wa"),i.callbacks=[],i.options=t.prepareOptions(e),i.listen=n,i.dispatch=r,i.listen.forEach(function(s){return s.on("message",i.onMessage,i)}),i}return t.prototype.addListener=function(n){return this.callbacks.push(n),w.console.info("WindowAdapter: Add iframe message listener"),this},t.prototype.send=function(n){var r=S({},n,{chanelId:this.options.chanelId});return this.dispatch.forEach(function(e){return e.dispatch(r)}),w.console.info("WindowAdapter: Send message",r),this},t.prototype.destroy=function(){this.listen.forEach(function(n){return n.destroy()}),this.dispatch.forEach(function(n){return n.destroy()}),w.console.info("WindowAdapter: Destroy")},t.prototype.onMessage=function(n){this.accessEvent(n)&&this.callbacks.forEach(function(r){try{r(n.data)}catch(e){w.console.warn("WindowAdapter: Unhandled exception!",e)}})},t.prototype.accessEvent=function(n){if(typeof n.data!="object"||n.data.type==null)return w.console.info("WindowAdapter: Block event. Wrong event format!",n.data),!1;if(!this.options.origins.has("*")&&!this.options.origins.has(n.origin))return w.console.info('SimpleWindowAdapter: Block event by origin "'+n.origin+'"'),!1;if(!this.options.availableChanelId.size)return!0;var r=!!(n.data.chanelId&&this.options.availableChanelId.has(n.data.chanelId));return r||w.console.info('SimpleWindowAdapter: Block event by chanel id "'+n.data.chanelId+'"'),r},t.createSimpleWindowAdapter=function(n,r){var e=this,i=this.getContentOrigin(n),s=this.prepareOptions(r),a=[];i&&s.origins.add(i);var c=new L.WindowProtocol(window,L.WindowProtocol.PROTOCOL_TYPES.LISTEN),l=function(h){a.push(h)};return c.on("message",l),this.getIframeContent(n).then(function(h){var d=new L.WindowProtocol(h.win,L.WindowProtocol.PROTOCOL_TYPES.DISPATCH),f=new t([c],[d],e.unPrepareOptions(s));return a.forEach(function(g){f.onMessage(g)}),c.off("message",l),f})},t.prepareOptions=function(n){n===void 0&&(n=ot);var r=function(a){return function(c){return c.reduce(function(l,h){return l.add(h)},a)}},e=function(a,c){return it.pipe(w.toArray,r(c))(a)},i=e(n.origins||[],new w.UniqPrimitiveCollection([window.location.origin])),s=e(n.availableChanelId||[],new w.UniqPrimitiveCollection);return S({},n,{origins:i,availableChanelId:s})},t.unPrepareOptions=function(n){return{origins:n.origins.toArray(),availableChanelId:n.availableChanelId.toArray(),chanelId:n.chanelId}},t.getIframeContent=function(n){return n?n instanceof HTMLIFrameElement?n.contentWindow?Promise.resolve({win:n.contentWindow}):new Promise(function(r,e){n.addEventListener("load",function(){return r({win:n.contentWindow})},!1),n.addEventListener("error",e,!1)}):Promise.resolve({win:n}):Promise.resolve({win:window.opener||window.parent})},t.getContentOrigin=function(n){if(!n)try{return new URL(document.referrer).origin}catch{return null}if(!(n instanceof HTMLIFrameElement))try{return window.top.origin}catch{return null}try{return new URL(n.src).origin||null}catch{return null}},t}(rt.Adapter);I.WindowAdapter=st,function(o){function t(n){for(var r in n)o.hasOwnProperty(r)||(o[r]=n[r])}Object.defineProperty(o,"__esModule",{value:!0}),t(M),t(P),t(I),t(q),t(x),t(C)}(p);class at{constructor(t){v(this,"_actions",[]);v(this,"_maxLength");v(this,"_active");this._maxLength=t}get length(){return this._actions.length+(this._active==null?0:1)}push(t){if(this._actions.length>=this._maxLength)throw new Error("Cant't push action! Queue is full!");return new Promise((n,r)=>{const e=()=>{this._active=void 0;const s=this._actions.map(a=>a.action).indexOf(i);s!==-1&&this._actions.splice(s,1),this.run()},i=()=>t().then(s=>{e(),n(s)},s=>{e(),r(s)});this._actions.push({action:i,reject:r}),this.length===1&&this.run()})}clear(t){t=t||new Error("Rejection with clear queue!");const n=typeof t=="string"?new Error(t):t;this._actions.splice(0,this._actions.length).forEach(r=>r.reject(n)),this._active=void 0}canPush(){return this._actions.length<this._maxLength}run(){const t=this._actions.shift();t!=null&&(this._active=t.action())}}const D=o=>o&&o.message==="SecurityError: Failed to read the 'localStorage' property from 'Window': Access is denied for this document."?z(V({},o),{message:"Local storage is not available! It is possible that the Browser is in incognito mode!"}):o;class ct{constructor(t){v(this,"_queue");v(this,"_events",[]);v(this,"_toRunEvents",[]);this._queue=new at(t)}dropConnection(){this._queue.clear(new Error("User rejection!")),this._events.forEach(t=>this._toRunEvents.push(t)),this._dropTransportConnect()}sendEvent(t){this._events.push(t),this._toRunEvents.push(t)}dialog(t){return this._runBeforeShow(),this._getBus().then(n=>{const r=this._wrapAction(()=>t(n));return this._runEvents(n),this._queue.canPush()?this._queue.push(r).then(e=>(this._runAfterShow(),e)).catch(e=>(this._runAfterShow(),Promise.reject(D(e)))):Promise.reject(new Error("Queue is full!"))})}_runBeforeShow(){this._queue.length===0&&this._beforeShow()}_runAfterShow(){this._queue.length===0&&this._afterShow()}_runEvents(t){this._toRunEvents.splice(0,this._events.length).forEach(n=>n(t))}_wrapAction(t){return this._toRunEvents?()=>{const n=t();return n.catch(()=>{this._events.forEach(r=>this._toRunEvents.push(r))}),n}:t}}const E=class extends ct{constructor(t,n){super(n);v(this,"_url");v(this,"_iframe");v(this,"_bus");this._url=t,this._initIframe()}get(){return this._iframe||this._initIframe(),this._iframe}_dropTransportConnect(){this._iframe!=null&&(document.body.removeChild(this._iframe),this._initIframe()),this._bus&&(this._bus.destroy(),this._bus=void 0)}_getBus(){return this._bus?Promise.resolve(this._bus):p.WindowAdapter.createSimpleWindowAdapter(this._iframe).then(t=>new Promise(n=>{this._bus=new p.Bus(t,-1),this._bus.once("ready",()=>{n(this._bus)})}))}_beforeShow(){this._showIframe()}_afterShow(){this._hideIframe()}_initIframe(){this._iframe=this._createIframe(),this._addIframeToDom(this._iframe),this._listenFetchURLError(this._iframe),this._hideIframe()}_addIframeToDom(t){document.body!=null?document.body.appendChild(t):document.addEventListener("DOMContentLoaded",()=>{document.body.appendChild(t)})}_createIframe(){const t=document.createElement("iframe");return t.style.transition="opacity .2s",t.style.position="absolute",t.style.opacity="0",t.style.width="100%",t.style.height="100%",t.style.left="0",t.style.top="0",t.style.border="none",t.style.position="fixed",t}_showIframe(){const t={width:"100%",height:"100%",left:"0",top:"0",border:"none",position:"fixed",display:"block",opacity:"0",zIndex:"99999999"};this._applyStyle(t),E._timer!=null&&clearTimeout(E._timer),E._timer=setTimeout(()=>{this._applyStyle({opacity:"1"})},0)}_hideIframe(){const t={opacity:"0"};this._applyStyle(t),E._timer!=null&&clearTimeout(E._timer),E._timer=setTimeout(()=>{this._applyStyle({width:"10px",height:"10px",left:"-100px",top:"-100px",position:"absolute",opacity:"0",zIndex:"0",display:"none"})},200)}_applyStyle(t){Object.entries(t).forEach(([n,r])=>{r!=null&&this._iframe&&(this._iframe.style[n]=r)})}_renderErrorPage(t,n,r){t.parentElement&&(t.parentElement.style.height="100%"),Object.assign(t.style,{position:"relative",boxSizing:"border-box",width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center",margin:"0px"});const e=document.createElement("div");Object.assign(e.style,{position:"fixed",zIndex:"-1",height:"100%",width:"100%",overflow:"hidden",backgroundColor:"#000",opacity:"0.6"});const i=document.createElement("div");Object.assign(i.style,{position:"fixed",display:"flex",justifyContent:"center",alignItems:"center",flexDirection:"column",margin:"0",backgroundColor:"#292F3C",width:"520px",borderRadius:"6px",padding:"40px",boxSizing:"border-box"});const s=document.createElement("div");s.textContent=r,Object.assign(s.style,{fontSize:"15px",lineHeight:"20px",color:"#fff",marginBottom:"40px",fontFamily:"Roboto, sans-serif"});const a=document.createElement("button");a.textContent="OK",a.addEventListener("click",()=>n()),Object.assign(a.style,{width:"100%",fontSize:"15px",lineHeight:"48px",padding:" 0 40px",color:"#fff",backgroundColor:"#5A81EA",outline:"none",border:"none",cursor:"pointer",fontFamily:"Roboto, sans-serif",borderRadius:"4px"}),i.appendChild(s),i.appendChild(a),t.appendChild(e),t.appendChild(i)}_listenFetchURLError(t){fetch(this._url).catch(()=>{t.addEventListener("load",()=>{!t.contentDocument||(this._renderErrorPage(t.contentDocument.body,()=>this.dropConnection(),"The request could not be processed. To resume your further work, disable the installed plugins."),this._showIframe())})})}};let T=E;v(T,"_timer",null);function ut(){var o;return!!((o=navigator.brave)==null?void 0:o.isBrave)}function lt(){const o=navigator.userAgent.toLowerCase(),t=o.includes("safari")&&!o.includes("chrome");return navigator.platform!=null&&/iPad|iPhone|iPod/.test(navigator.platform)||t}class W{constructor(t,n){v(this,"user",null);v(this,"_transport");v(this,"_clientUrl");v(this,"emitter",new R.exports.EventEmitter);this._clientUrl=(t||"https://waves.exchange/signer/")+`?${W._getCacheClean()}`,this._transport=new T(this._clientUrl,3),n===!0&&(p.config.console.logLevel=p.config.console.LOG_LEVEL.VERBOSE)}static _getCacheClean(){return String(Date.now()%(1e3*60))}on(t,n){return this.emitter.on(t,n),this}once(t,n){return this.emitter.once(t,n),this}off(t,n){return this.emitter.once(t,n),this}connect(t){return Promise.resolve(this._transport.sendEvent(n=>n.dispatchEvent("connect",t)))}logout(){return this.user=null,Promise.resolve(this._transport.dropConnection())}login(){var n;if(this.user)return Promise.resolve(this.user);const t=this._transport.get();if((lt()||ut())&&!((n=t.contentWindow)==null?void 0:n.open(this._clientUrl)))throw new Error("Window was blocked");return t.src=this._clientUrl,this._transport.dialog(r=>r.request("login").then(e=>(this.user=e,e)).catch(e=>(this._transport.dropConnection(),Promise.reject(D(e)))))}signMessage(t){return this.login().then(()=>this._transport.dialog(n=>n.request("sign-message",t)))}signTypedData(t){return this.login().then(()=>this._transport.dialog(n=>n.request("sign-typed-data",t)))}sign(t){return this.login().then(()=>this._transport.dialog(n=>n.request("sign",t)))}}_.ProviderWeb=W,Object.defineProperty(_,"__esModule",{value:!0}),_[Symbol.toStringTag]="Module"});
@@ -1,4 +1 @@
1
- export declare const createError: (error: Error) => {
2
- code: number;
3
- message: string | Error;
4
- };
1
+ export declare const createError: (error: Error) => Error;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@waves.exchange/provider-web",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -15,10 +15,10 @@
15
15
  ],
16
16
  "repository": {
17
17
  "type": "git",
18
- "url": "https://github.com/waves-exchange/provider-web.git"
18
+ "url": "https://github.com/waves-exchange/signer-providers.git"
19
19
  },
20
20
  "bugs": {
21
- "url": "https://github.com/waves-exchange/provider-web/issues",
21
+ "url": "https://github.com/waves-exchange/signer-providers/issues",
22
22
  "email": "support@waves.exchange"
23
23
  },
24
24
  "homepage": "https://waves.exchange",