UNPKG

@vechain/connex-wallet-buddy

Version:

to bridge connex sign request to wallet

2 lines 7.86 kB
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.ConnexWalletBuddy=n():e.ConnexWalletBuddy=n()}(self,(function(){return(()=>{"use strict";var e={35:(e,n,o)=>{o.r(n),o.d(n,{create:()=>y});var t=function(e,n,o){this.name=e,this.version=n,this.os=o,this.type="browser"},r=function(e,n,o,t){this.name=e,this.version=n,this.os=o,this.bot=t,this.type="bot-device"},i=function(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null},s=/(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,a=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FBAV\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["searchbot",/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/]],c=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]];function d(e){var n=function(e){return""!==e&&a.reduce((function(n,o){var t=o[0],r=o[1];if(n)return n;var i=r.exec(e);return!!i&&[t,i]}),!1)}(e);if(!n)return null;var o=n[0],d=n[1];if("searchbot"===o)return new i;var u=d[1]&&d[1].split(/[._]/).slice(0,3);u?u.length<3&&(u=function(){for(var e=0,n=0,o=arguments.length;n<o;n++)e+=arguments[n].length;var t=Array(e),r=0;for(n=0;n<o;n++)for(var i=arguments[n],s=0,a=i.length;s<a;s++,r++)t[r]=i[s];return t}(u,function(e){for(var n=[],o=0;o<e;o++)n.push("0");return n}(3-u.length))):u=[];var l=u.join("."),f=function(e){for(var n=0,o=c.length;n<o;n++){var t=c[n],r=t[0];if(t[1].exec(e))return r}return null}(e),h=s.exec(e);return h&&h[1]?new r(o,l,f,h[1]):new t(o,l,f)}const u="undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"===navigator.product?new function(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}:"undefined"!=typeof navigator?d(navigator.userAgent):"undefined"!=typeof process&&process.version?new function(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}(process.version.slice(1)):null;const l=(()=>{let e=null;return()=>(e||(e=document.createElement("iframe"),e.style.display="none",document.body.appendChild(e)),e)})();function f(e,n){if(navigator.msLaunchUri)return function(e){return new Promise(((n,o)=>{navigator.msLaunchUri(e,n,o)}))}(e);if(!u)return null;if("iOS"===u.os)return null;switch(u.name){case"chrome":case"edge-chromium":case"safari":return function(e,n){return l().contentWindow.location.href=e,function(e,n,o){return new Promise(((t,r)=>{let i;const s=setTimeout((()=>{e.removeEventListener(n,i),r()}),o);i=o=>{e.removeEventListener(n,i),clearTimeout(s),t(o)},e.addEventListener(n,i)}))}(window,"blur",n)}(e,n);default:return null}}function h(e){return n=this,o=void 0,r=function*(){try{const n=function(e){return f("connex:sign?src="+encodeURIComponent(e),1e3)}(e);if(n)return yield n,null}catch(e){}return function(e){const n=(()=>{switch(u&&u.os){case"iOS":case"android":return{};default:return{target:"sync|"+window.location.host,features:"width=360,height=640,resizable,scrollbars=yes,dependent,modal"}}})();return window.open(new URL("#/sign?src="+encodeURIComponent(e),"https://lite.sync.vecha.in/").href,n.target,n.features,!0)}(e)},new((t=void 0)||(t=Promise))((function(e,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(n){var o;n.done?e(n.value):(o=n.value,o instanceof t?o:new t((function(e){e(o)}))).then(s,a)}c((r=r.apply(n,o||[])).next())}));var n,o,t,r}var w=function(e,n,o,t){return new(o||(o=Promise))((function(r,i){function s(e){try{c(t.next(e))}catch(e){i(e)}}function a(e){try{c(t.throw(e))}catch(e){i(e)}}function c(e){var n;e.done?r(e.value):(n=e.value,n instanceof o?n:new o((function(e){e(n)}))).then(s,a)}c((t=t.apply(e,n||[])).next())}))};const p="https://tos.vecha.in:5678/";function v(e,n,o,t,r){return w(this,void 0,void 0,(function*(){let i=0;const s=Date.now()+o;for(;Date.now()<s&&!t.done;)try{const o=yield fetch(new URL(`${e}${n}?wait=1`,r).href),t=yield o.text();if(t)return t}catch(e){if(++i>2)throw new Error("failed fetch response");yield new Promise((e=>setTimeout(e,3e3)))}throw new Error("timeout")}))}function m(e,n,o,t,r,i,s){const a=o.onAccepted,c={type:e,gid:t,payload:{message:n,options:Object.assign(Object.assign({},o),{onAccepted:void 0})},nonce:r()},d=JSON.stringify(c),u=i(d),l={done:!1};return Promise.race([(()=>w(this,void 0,void 0,(function*(){try{const e=yield h(new URL(u,s).href);for(;!l.done;){if(e&&e.closed)throw new Error("wallet window closed");yield new Promise((e=>setTimeout(e,1e3)))}}finally{l.done=!0}})))(),(()=>w(this,void 0,void 0,(function*(){try{yield function(e,n,o,t){return w(this,void 0,void 0,(function*(){const r=new URL(e,t).href;for(let e=0;e<3&&!o.done;e++)try{return yield fetch(r,{method:"POST",body:n,headers:new Headers({"Content-Type":"application/json"})})}catch(e){yield new Promise((e=>setTimeout(e,2e3)))}throw new Error("failed to submit request")}))}(u,d,l,s),a&&(()=>{w(this,void 0,void 0,(function*(){try{yield v(u,".accepted",6e4,l,s),!l.done&&a&&a()}catch(e){console.warn(e)}}))})();const e=yield v(u,".resp",6e5,l,s),n=JSON.parse(e);if(n.error)throw new Error(n.error);return n.payload}finally{l.done=!0}})))()])}function y(e,n,o,t){return{signTx:(r,i)=>m("tx",r,i,e,n,o,t||p),signCert:(r,i)=>m("cert",r,i,e,n,o,t||p)}}const b=JSON.parse('{"u2":"@vechain/connex-wallet-buddy","i8":"0.1.0"}');console.log(`[${b.u2}] v${b.i8} loaded`)}},n={};function o(t){if(n[t])return n[t].exports;var r=n[t]={exports:{}};return e[t](r,r.exports,o),r.exports}return o.d=(e,n)=>{for(var t in n)o.o(n,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:n[t]})},o.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o(35)})()})); //# sourceMappingURL=bundle.min.js.map