Socket
Socket
Sign inDemoInstall

xumm-sdk

Package Overview
Dependencies
Maintainers
4
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xumm-sdk - npm Package Compare versions

Comparing version 1.6.0 to 1.6.1

2

dist/browser.min.js

@@ -1,1 +0,1 @@

require=function e(t,r,o){function n(s,a){if(!r[s]){if(!t[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=r[s]={exports:{}};t[s][0].call(l.exports,(function(e){return n(t[s][1][e]||e)}),l,l.exports,e,t,r,o)}return r[s].exports}for(var i="function"==typeof require&&require,s=0;s<o.length;s++)n(o[s]);return n}({1:[function(e,t,r){"use strict";var o=this&&this.__awaiter||function(e,t,r,o){return new(r||(r=Promise))((function(n,i){function s(e){try{u(o.next(e))}catch(e){i(e)}}function a(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((o=o.apply(e,t||[])).next())}))},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.Meta=void 0;const i=e("debug"),s=n(e("fetch-ponyfill")),{fetch:a,Request:u,Response:c,Headers:l}=s.default(),d=e("os-browserify"),h=e("./utils"),f=e("./index"),p=i.debug("xumm-sdk:meta");r.Meta=class{constructor(e,t){this.isBrowser=!1,this.jwtFlow=!1,this.injected=!1,this.endpoint="https://xumm.app",p("Constructed");const r=new RegExp("^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"),o={split:t.split(":"),uuidv4:""};if(3===o.split.length&&"xApp:OneTimeToken"===o.split.slice(0,2).join(":")?(o.uuidv4=o.split[2],this.jwtFlow=!0):o.split.length>1&&"RAWJWT"===o.split[0]?(this.jwtFlow=!0,this.jwt=o.split.slice(1).join(":")):o.uuidv4=t,!r.test(e)||!r.test(o.uuidv4)){if(!this.jwtFlow)throw new Error("Invalid API Key and/or API Secret. Use dotenv or constructor params.");if(!this.jwt)throw new Error("Invalid API Key and/or OTT (One Time Token). Provide OTT param (2nd param) or make sure `xAppToken` query param is present (Browser)")}return"undefined"!=typeof globalThis&&Object.keys(globalThis).indexOf("window")<0?p("Running in node"):(console.log("XUMM SDK: Running in browser"),this.isBrowser=!0),this.apiKey=e,this.apiSecret=o.uuidv4,this.jwtFlow&&!this.jwt&&(this.authPromise=new Promise((e=>{this.authPromiseResolve=e})),Promise.resolve().then((()=>this.authorize())).catch((e=>{p("Authorize error:",e.message),(null==this?void 0:this.invoker)&&this.invoker.caught(e),this.authPromiseResolve&&this.authPromiseResolve()}))),this}setEndpoint(e){return!!e.match(/^http/)&&(this.endpoint=e.trim(),!0)}authorize(){var e,t,r,n;return o(this,void 0,void 0,(function*(){let o;p("JWT Authorize",this.apiSecret),(null==this?void 0:this.invoker)&&this.invoker.constructor===f.XummSdkJwt&&(o=this.invoker._jwtStore(this,(e=>this.jwt=e)));const i=(null==o?void 0:o.get(this.apiSecret))||(yield this.call("authorize"));if(null===(t=null===(e=i)||void 0===e?void 0:e.error)||void 0===t?void 0:t.code)p("Could not resolve API Key & OTT to JWT (already fetched? Unauthorized?)"),(null==this?void 0:this.invoker)&&this.invoker.constructor===f.XummSdkJwt&&(null===(r=null==this?void 0:this.invoker)||void 0===r?void 0:r.fatalHandler)?this.invoker.fatalHandler(new Error(i.error.reference)):h.throwIfError(i);else{if(!(null===(n=i)||void 0===n?void 0:n.jwt))throw new Error("Unexpected response for xApp JWT authorize request");{const e=i;null==o||o.set(this.apiSecret,e)}}this.authPromiseResolve&&this.authPromiseResolve()}))}call(e,t="GET",r){var n;return o(this,void 0,void 0,(function*(){const o=t.toUpperCase();this.jwtFlow&&!(null==this?void 0:this.jwt)&&this.authPromise&&"authorize"!==e&&(yield this.authPromise);try{let t;void 0!==r&&("object"==typeof r&&null!==r&&(t=JSON.stringify(r)),"string"==typeof r&&(t=r));const n={"Content-Type":"application/json"};this.isBrowser||Object.assign(n,{"User-Agent":`xumm-sdk/node (${d.hostname()}) node-fetch`}),this.jwtFlow?"authorize"===e?Object.assign(n,{"x-api-key":this.apiKey,"x-api-ott":this.apiSecret}):Object.assign(n,{Authorization:"Bearer "+this.jwt}):Object.assign(n,{"x-api-key":this.apiKey,"x-api-secret":this.apiSecret});const i=["authorize","ping","curated-assets","rates","payload","userdata"],s=this.jwtFlow&&i.indexOf(e.split("/")[0])>-1?"jwt":"platform",u=yield a(this.endpoint+"/api/v1/"+s+"/"+e,{method:o,body:t,headers:n});return yield u.json()}catch(t){const r=new Error(`Unexpected response from XUMM API [${o}:${e}]`);throw r.stack=(null===(n=t)||void 0===n?void 0:n.stack)||void 0,r}}))}ping(){var e,t;return o(this,void 0,void 0,(function*(){const r=yield this.call("ping");if(h.throwIfError(r),void 0!==r.auth)return r.auth;if(void 0!==(null===(e=r)||void 0===e?void 0:e.ott_uuidv4))return{application:{uuidv4:r.app_uuidv4,name:r.app_name},jwtData:r};if(void 0!==(null===(t=r)||void 0===t?void 0:t.usertoken_uuidv4))return{application:{uuidv4:r.client_id,name:r.app_name},jwtData:r};throw new Error("Unexpected response for ping request")}))}getCuratedAssets(){return o(this,void 0,void 0,(function*(){return yield this.call("curated-assets")}))}getRates(e){return o(this,void 0,void 0,(function*(){return yield this.call("rates/"+e.trim().toUpperCase())}))}getKycStatus(e){return o(this,void 0,void 0,(function*(){if(e.trim().match(/^r/)){const t=yield this.call("kyc-status/"+e.trim());return(null==t?void 0:t.kycApproved)?"SUCCESSFUL":"NONE"}{const t=yield this.call("kyc-status","POST",{user_token:e});return(null==t?void 0:t.kycStatus)||"NONE"}}))}getTransaction(e){return o(this,void 0,void 0,(function*(){return yield this.call("xrpl-tx/"+e.trim())}))}verifyUserTokens(e){return o(this,void 0,void 0,(function*(){return(yield this.call("user-tokens","POST",{tokens:Array.isArray(e)?e:[e]})).tokens}))}_inject(e){if(this.injected)throw new Error("Cannot `_inject` twice");this.invoker=e}}},{"./index":"xumm-sdk","./utils":4,debug:7,"fetch-ponyfill":10,"os-browserify":12}],2:[function(e,t,r){"use strict";var o=this&&this.__awaiter||function(e,t,r,o){return new(r||(r=Promise))((function(n,i){function s(e){try{u(o.next(e))}catch(e){i(e)}}function a(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(r,"__esModule",{value:!0}),r.Payload=void 0;const n=e("debug"),i=e("websocket"),s=e("./utils"),a=n.debug("xumm-sdk:payload"),u=n.debug("xumm-sdk:payload:websocket");r.Payload=class{constructor(e){a("Constructed"),this.Meta=e}resolvePayload(e){var t,r,n;return o(this,void 0,void 0,(function*(){if("string"==typeof e)return yield this.get(e,!0);if(void 0!==(null===(t=e)||void 0===t?void 0:t.uuid))return yield this.get(e.uuid,!0);if(void 0!==(null===(n=null===(r=e)||void 0===r?void 0:r.meta)||void 0===n?void 0:n.uuid))return e;throw new Error("Could not resolve payload (not found)")}))}create(e,t=!1){var r;return o(this,void 0,void 0,(function*(){const o=void 0!==e.TransactionType&&void 0===e.txjson,n=yield this.Meta.call("payload","POST",o?{txjson:e}:e);t&&s.throwIfError(n);return void 0!==(null===(r=n)||void 0===r?void 0:r.next)?n:null}))}get(e,t=!1){var r,n;return o(this,void 0,void 0,(function*(){const o="string"==typeof e?e:null==e?void 0:e.uuid,i=yield this.Meta.call("payload/"+o,"GET");t&&s.throwIfError(i);return void 0!==(null===(n=null===(r=i)||void 0===r?void 0:r.meta)||void 0===n?void 0:n.uuid)?i:null}))}subscribe(e,t){var r,n;return o(this,void 0,void 0,(function*(){const a=new s.DeferredPromise,c=yield this.resolvePayload(e);if(c){const e="undefined",s=typeof(null===(r=globalThis)||void 0===r?void 0:r.MockedWebSocket)!==e&&typeof jest!==e?new(null===(n=globalThis)||void 0===n?void 0:n.MockedWebSocket)("ws://xumm.local"):new i.w3cwebsocket(this.Meta.endpoint.replace(/^http/,"ws")+"/sign/"+c.meta.uuid);return a.promise.then((()=>{s.close()})),s.onopen=()=>{u(`Payload ${c.meta.uuid}: Subscription active (WebSocket opened)`)},s.onmessage=e=>o(this,void 0,void 0,(function*(){const r=e.data;let n;try{n=JSON.parse(r.toString())}catch(e){u(`Payload ${c.meta.uuid}: Received message, unable to parse as JSON`,e)}if(n&&t&&void 0===n.devapp_fetched)try{const e=yield t({uuid:c.meta.uuid,data:n,resolve(e){return o(this,void 0,void 0,(function*(){yield a.resolve(e||void 0)}))},payload:c});void 0!==e&&a.resolve(e)}catch(e){u(`Payload ${c.meta.uuid}: Callback exception`,e)}})),s.onclose=e=>{u(`Payload ${c.meta.uuid}: Subscription ended (WebSocket closed)`)},{payload:c,resolve(e){a.resolve(e||void 0)},resolved:a.promise,websocket:s}}throw s.throwIfError(c),Error("Couldn't subscribe: couldn't fetch payload")}))}cancel(e,t=!1){var r,n,i;return o(this,void 0,void 0,(function*(){const o=yield this.resolvePayload(e),a=yield this.Meta.call("payload/"+(null===(r=null==o?void 0:o.meta)||void 0===r?void 0:r.uuid),"DELETE");t&&s.throwIfError(a);return void 0!==(null===(i=null===(n=a)||void 0===n?void 0:n.meta)||void 0===i?void 0:i.uuid)?a:null}))}createAndSubscribe(e,t){return o(this,void 0,void 0,(function*(){const r=yield this.create(e,!0);if(r){const e=yield this.subscribe(r,t);return Object.assign({created:r},e)}throw new Error("Error creating payload or subscribing to created payload")}))}}},{"./utils":4,debug:7,websocket:14}],3:[function(e,t,r){"use strict";var o=this&&this.__awaiter||function(e,t,r,o){return new(r||(r=Promise))((function(n,i){function s(e){try{u(o.next(e))}catch(e){i(e)}}function a(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(r,"__esModule",{value:!0}),r.Storage=void 0;const n=e("debug"),i=e("./utils"),s=n.debug("xumm-sdk:storage");r.Storage=class{constructor(e){s("Constructed"),this.Meta=e}get(){return o(this,void 0,void 0,(function*(){const e=yield this.Meta.call("app-storage","GET");return i.throwIfError(e),e.data}))}set(e){return o(this,void 0,void 0,(function*(){const t=yield this.Meta.call("app-storage","POST",e);return i.throwIfError(t),t.stored}))}delete(){return o(this,void 0,void 0,(function*(){const e=yield this.Meta.call("app-storage","DELETE");return i.throwIfError(e),e.stored}))}}},{"./utils":4,debug:7}],4:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.DeferredPromise=r.throwIfError=void 0,r.throwIfError=function(e){var t,r,o,n,i,s;if(void 0!==e.message)throw new Error(e.message);if(void 0===e.next&&void 0===(null===(r=null===(t=e)||void 0===t?void 0:t.meta)||void 0===r?void 0:r.uuid)&&void 0===(null===(n=null===(o=e)||void 0===o?void 0:o.application)||void 0===n?void 0:n.uuidv4)&&void 0!==(null===(s=null===(i=e)||void 0===i?void 0:i.error)||void 0===s?void 0:s.code)){const t=e.error;throw new Error(`Error code ${t.code}, see XUMM Dev Console, reference: ${t.reference}`)}};r.DeferredPromise=class{constructor(){this.resolveFn=e=>{},this.rejectFn=e=>{},this.promise=new Promise(((e,t)=>{this.resolveFn=e,this.rejectFn=t}))}resolve(e){return this.resolveFn(e),this.promise}reject(e){return this.rejectFn(e),this.promise}}},{}],5:[function(e,t,r){"use strict";var o=this&&this.__awaiter||function(e,t,r,o){return new(r||(r=Promise))((function(n,i){function s(e){try{u(o.next(e))}catch(e){i(e)}}function a(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(r,"__esModule",{value:!0}),r.xApp=void 0;const n=e("debug"),i=e("./xAppUserdata"),s=e("./utils"),a=n.debug("xumm-sdk:xapp");r.xApp=class{constructor(e){a("Constructed"),this.Meta=e,this.userdata=new i.xAppUserdata(this.Meta)}get(e){return o(this,void 0,void 0,(function*(){const t=yield this.Meta.call("xapp/ott/"+e,"GET");return s.throwIfError(t),t}))}event(e){return o(this,void 0,void 0,(function*(){const t=yield this.Meta.call("xapp/event","POST",e);return s.throwIfError(t),t}))}push(e){return o(this,void 0,void 0,(function*(){const t=yield this.Meta.call("xapp/push","POST",e);return s.throwIfError(t),t}))}}},{"./utils":4,"./xAppUserdata":6,debug:7}],6:[function(e,t,r){"use strict";var o=this&&this.__awaiter||function(e,t,r,o){return new(r||(r=Promise))((function(n,i){function s(e){try{u(o.next(e))}catch(e){i(e)}}function a(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(r,"__esModule",{value:!0}),r.xAppUserdata=void 0;const n=e("debug"),i=e("./utils"),s=n.debug("xumm-sdk:xapp:userdata");r.xAppUserdata=class{constructor(e){s("Constructed"),this.Meta=e}list(){return o(this,void 0,void 0,(function*(){const e=yield this.Meta.call("userdata","GET");return i.throwIfError(e),e.keys}))}get(e){var t;return o(this,void 0,void 0,(function*(){const r=Array.isArray(e)?e.join(","):e,o=yield this.Meta.call("userdata/"+r,"GET");return i.throwIfError(o),r.split(",").length>1?o.data:(null===(t=o.data)||void 0===t?void 0:t[r])||{}}))}delete(e){return o(this,void 0,void 0,(function*(){const t=yield this.Meta.call("userdata/"+e,"DELETE");return i.throwIfError(t),t.persisted}))}set(e,t){return o(this,void 0,void 0,(function*(){const r=yield this.Meta.call("userdata/"+e,"POST",t);return i.throwIfError(r),r.persisted}))}}},{"./utils":4,debug:7}],7:[function(e,t,r){(function(o){(function(){r.formatArgs=function(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;e.splice(1,0,r,"color: inherit");let o=0,n=0;e[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(o++,"%c"===e&&(n=o))})),e.splice(n,0,r)},r.save=function(e){try{e?r.storage.setItem("debug",e):r.storage.removeItem("debug")}catch(e){}},r.load=function(){let e;try{e=r.storage.getItem("debug")}catch(e){}!e&&void 0!==o&&"env"in o&&(e=o.env.DEBUG);return e},r.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},r.storage=function(){try{return localStorage}catch(e){}}(),r.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),r.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],r.log=console.debug||console.log||(()=>{}),t.exports=e("./common")(r);const{formatters:n}=t.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this)}).call(this,e("_process"))},{"./common":8,_process:13}],8:[function(e,t,r){t.exports=function(t){function r(e){let t,n=null;function i(...e){if(!i.enabled)return;const o=i,n=Number(new Date),s=n-(t||n);o.diff=s,o.prev=t,o.curr=n,t=n,e[0]=r.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((t,n)=>{if("%%"===t)return"%";a++;const i=r.formatters[n];if("function"==typeof i){const r=e[a];t=i.call(o,r),e.splice(a,1),a--}return t})),r.formatArgs.call(o,e);(o.log||r.log).apply(o,e)}return i.namespace=e,i.useColors=r.useColors(),i.color=r.selectColor(e),i.extend=o,i.destroy=r.destroy,Object.defineProperty(i,"enabled",{enumerable:!0,configurable:!1,get:()=>null===n?r.enabled(e):n,set:e=>{n=e}}),"function"==typeof r.init&&r.init(i),i}function o(e,t){const o=r(this.namespace+(void 0===t?":":t)+e);return o.log=this.log,o}function n(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return r.debug=r,r.default=r,r.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},r.disable=function(){const e=[...r.names.map(n),...r.skips.map(n).map((e=>"-"+e))].join(",");return r.enable(""),e},r.enable=function(e){let t;r.save(e),r.names=[],r.skips=[];const o=("string"==typeof e?e:"").split(/[\s,]+/),n=o.length;for(t=0;t<n;t++)o[t]&&("-"===(e=o[t].replace(/\*/g,".*?"))[0]?r.skips.push(new RegExp("^"+e.substr(1)+"$")):r.names.push(new RegExp("^"+e+"$")))},r.enabled=function(e){if("*"===e[e.length-1])return!0;let t,o;for(t=0,o=r.skips.length;t<o;t++)if(r.skips[t].test(e))return!1;for(t=0,o=r.names.length;t<o;t++)if(r.names[t].test(e))return!0;return!1},r.humanize=e("ms"),r.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(t).forEach((e=>{r[e]=t[e]})),r.names=[],r.skips=[],r.formatters={},r.selectColor=function(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t|=0;return r.colors[Math.abs(t)%r.colors.length]},r.enable(r.load()),r}},{ms:11}],9:[function(e,t,r){var o=function(){if("object"==typeof self&&self)return self;if("object"==typeof window&&window)return window;throw new Error("Unable to resolve global `this`")};t.exports=function(){if(this)return this;if("object"==typeof globalThis&&globalThis)return globalThis;try{Object.defineProperty(Object.prototype,"__global__",{get:function(){return this},configurable:!0})}catch(e){return o()}try{return __global__||o()}finally{delete Object.prototype.__global__}}()},{}],10:[function(e,t,r){(function(e){(function(){!function(e){"use strict";function o(o){var n=o&&o.Promise||e.Promise,i=o&&o.XMLHttpRequest||e.XMLHttpRequest;return function(){var o=Object.create(e,{fetch:{value:void 0,writable:!0}});return function(e,o){"object"==typeof r&&void 0!==t?o(r):"function"==typeof define&&define.amd?define(["exports"],o):o(e.WHATWGFetch={})}(this,(function(e){var t=void 0!==o&&o||"undefined"!=typeof self&&self||void 0!==t&&t,r="URLSearchParams"in t,s="Symbol"in t&&"iterator"in Symbol,a="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(e){return!1}}(),u="FormData"in t,c="ArrayBuffer"in t;if(c)var l=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],d=ArrayBuffer.isView||function(e){return e&&l.indexOf(Object.prototype.toString.call(e))>-1};function h(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function f(e){return"string"!=typeof e&&(e=String(e)),e}function p(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return s&&(t[Symbol.iterator]=function(){return t}),t}function v(e){this.map={},e instanceof v?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function y(e){if(e.bodyUsed)return n.reject(new TypeError("Already read"));e.bodyUsed=!0}function w(e){return new n((function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}}))}function m(e){var t=new FileReader,r=w(t);return t.readAsArrayBuffer(e),r}function g(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function b(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:a&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:u&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():c&&a&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=g(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):c&&(ArrayBuffer.prototype.isPrototypeOf(e)||d(e))?this._bodyArrayBuffer=g(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},a&&(this.blob=function(){var e=y(this);if(e)return e;if(this._bodyBlob)return n.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return n.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return n.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=y(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?n.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):n.resolve(this._bodyArrayBuffer))}return this.blob().then(m)}),this.text=function(){var e,t,r,o=y(this);if(o)return o;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=w(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return n.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),o=0;o<t.length;o++)r[o]=String.fromCharCode(t[o]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return n.resolve(this._bodyText)},u&&(this.formData=function(){return this.text().then(E)}),this.json=function(){return this.text().then(JSON.parse)},this}v.prototype.append=function(e,t){e=h(e),t=f(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},v.prototype.delete=function(e){delete this.map[h(e)]},v.prototype.get=function(e){return e=h(e),this.has(e)?this.map[e]:null},v.prototype.has=function(e){return this.map.hasOwnProperty(h(e))},v.prototype.set=function(e,t){this.map[h(e)]=f(t)},v.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},v.prototype.keys=function(){var e=[];return this.forEach((function(t,r){e.push(r)})),p(e)},v.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),p(e)},v.prototype.entries=function(){var e=[];return this.forEach((function(t,r){e.push([r,t])})),p(e)},s&&(v.prototype[Symbol.iterator]=v.prototype.entries);var C=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function T(e,t){if(!(this instanceof T))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var r,o,n=(t=t||{}).body;if(e instanceof T){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new v(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,n||null==e._bodyInit||(n=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new v(t.headers)),this.method=(r=t.method||this.method||"GET",o=r.toUpperCase(),C.indexOf(o)>-1?o:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&n)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(n),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==t.cache&&"no-cache"!==t.cache)){var i=/([?&])_=[^&]*/;if(i.test(this.url))this.url=this.url.replace(i,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function E(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var r=e.split("="),o=r.shift().replace(/\+/g," "),n=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(o),decodeURIComponent(n))}})),t}function x(e,t){if(!(this instanceof x))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"",this.headers=new v(t.headers),this.url=t.url||"",this._initBody(e)}T.prototype.clone=function(){return new T(this,{body:this._bodyInit})},b.call(T.prototype),b.call(x.prototype),x.prototype.clone=function(){return new x(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new v(this.headers),url:this.url})},x.error=function(){var e=new x(null,{status:0,statusText:""});return e.type="error",e};var _=[301,302,303,307,308];x.redirect=function(e,t){if(-1===_.indexOf(t))throw new RangeError("Invalid status code");return new x(null,{status:t,headers:{location:e}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function j(r,o){return new n((function(n,s){var u=new T(r,o);if(u.signal&&u.signal.aborted)return s(new e.DOMException("Aborted","AbortError"));var l=new i;function d(){l.abort()}l.onload=function(){var e,t,r={status:l.status,statusText:l.statusText,headers:(e=l.getAllResponseHeaders()||"",t=new v,e.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(e){return 0===e.indexOf("\n")?e.substr(1,e.length):e})).forEach((function(e){var r=e.split(":"),o=r.shift().trim();if(o){var n=r.join(":").trim();t.append(o,n)}})),t)};r.url="responseURL"in l?l.responseURL:r.headers.get("X-Request-URL");var o="response"in l?l.response:l.responseText;setTimeout((function(){n(new x(o,r))}),0)},l.onerror=function(){setTimeout((function(){s(new TypeError("Network request failed"))}),0)},l.ontimeout=function(){setTimeout((function(){s(new TypeError("Network request failed"))}),0)},l.onabort=function(){setTimeout((function(){s(new e.DOMException("Aborted","AbortError"))}),0)},l.open(u.method,function(e){try{return""===e&&t.location.href?t.location.href:e}catch(t){return e}}(u.url),!0),"include"===u.credentials?l.withCredentials=!0:"omit"===u.credentials&&(l.withCredentials=!1),"responseType"in l&&(a?l.responseType="blob":c&&u.headers.get("Content-Type")&&-1!==u.headers.get("Content-Type").indexOf("application/octet-stream")&&(l.responseType="arraybuffer")),!o||"object"!=typeof o.headers||o.headers instanceof v?u.headers.forEach((function(e,t){l.setRequestHeader(t,e)})):Object.getOwnPropertyNames(o.headers).forEach((function(e){l.setRequestHeader(e,f(o.headers[e]))})),u.signal&&(u.signal.addEventListener("abort",d),l.onreadystatechange=function(){4===l.readyState&&u.signal.removeEventListener("abort",d)}),l.send(void 0===u._bodyInit?null:u._bodyInit)}))}j.polyfill=!0,t.fetch||(t.fetch=j,t.Headers=v,t.Request=T,t.Response=x),e.Headers=v,e.Request=T,e.Response=x,e.fetch=j,Object.defineProperty(e,"__esModule",{value:!0})})),{fetch:o.fetch,Headers:o.Headers,Request:o.Request,Response:o.Response,DOMException:o.DOMException}}()}"function"==typeof define&&define.amd?define((function(){return o})):"object"==typeof r?t.exports=o:e.fetchPonyfill=o}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:void 0!==e?e:this)}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],11:[function(e,t,r){var o=1e3,n=60*o,i=60*n,s=24*i,a=7*s,u=365.25*s;function c(e,t,r,o){var n=t>=1.5*r;return Math.round(e/r)+" "+o+(n?"s":"")}t.exports=function(e,t){t=t||{};var r=typeof e;if("string"===r&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*u;case"weeks":case"week":case"w":return r*a;case"days":case"day":case"d":return r*s;case"hours":case"hour":case"hrs":case"hr":case"h":return r*i;case"minutes":case"minute":case"mins":case"min":case"m":return r*n;case"seconds":case"second":case"secs":case"sec":case"s":return r*o;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(e);if("number"===r&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=s)return c(e,t,s,"day");if(t>=i)return c(e,t,i,"hour");if(t>=n)return c(e,t,n,"minute");if(t>=o)return c(e,t,o,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=s)return Math.round(e/s)+"d";if(t>=i)return Math.round(e/i)+"h";if(t>=n)return Math.round(e/n)+"m";if(t>=o)return Math.round(e/o)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],12:[function(e,t,r){r.endianness=function(){return"LE"},r.hostname=function(){return"undefined"!=typeof location?location.hostname:""},r.loadavg=function(){return[]},r.uptime=function(){return 0},r.freemem=function(){return Number.MAX_VALUE},r.totalmem=function(){return Number.MAX_VALUE},r.cpus=function(){return[]},r.type=function(){return"Browser"},r.release=function(){return"undefined"!=typeof navigator?navigator.appVersion:""},r.networkInterfaces=r.getNetworkInterfaces=function(){return{}},r.arch=function(){return"javascript"},r.platform=function(){return"browser"},r.tmpdir=r.tmpDir=function(){return"/tmp"},r.EOL="\n",r.homedir=function(){return"/"}},{}],13:[function(e,t,r){var o,n,i=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function u(e){if(o===setTimeout)return setTimeout(e,0);if((o===s||!o)&&setTimeout)return o=setTimeout,setTimeout(e,0);try{return o(e,0)}catch(t){try{return o.call(null,e,0)}catch(t){return o.call(this,e,0)}}}!function(){try{o="function"==typeof setTimeout?setTimeout:s}catch(e){o=s}try{n="function"==typeof clearTimeout?clearTimeout:a}catch(e){n=a}}();var c,l=[],d=!1,h=-1;function f(){d&&c&&(d=!1,c.length?l=c.concat(l):h=-1,l.length&&p())}function p(){if(!d){var e=u(f);d=!0;for(var t=l.length;t;){for(c=l,l=[];++h<t;)c&&c[h].run();h=-1,t=l.length}c=null,d=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===a||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function v(e,t){this.fun=e,this.array=t}function y(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];l.push(new v(e,t)),1!==l.length||d||u(p)},v.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=y,i.addListener=y,i.once=y,i.off=y,i.removeListener=y,i.removeAllListeners=y,i.emit=y,i.prependListener=y,i.prependOnceListener=y,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},{}],14:[function(e,t,r){var o;if("object"==typeof globalThis)o=globalThis;else try{o=e("es5-ext/global")}catch(e){}finally{if(o||"undefined"==typeof window||(o=window),!o)throw new Error("Could not determine global this")}var n=o.WebSocket||o.MozWebSocket,i=e("./version");function s(e,t){return t?new n(e,t):new n(e)}n&&["CONNECTING","OPEN","CLOSING","CLOSED"].forEach((function(e){Object.defineProperty(s,e,{get:function(){return n[e]}})})),t.exports={w3cwebsocket:n?s:null,version:i}},{"./version":15,"es5-ext/global":9}],15:[function(e,t,r){t.exports=e("../package.json").version},{"../package.json":16}],16:[function(e,t,r){t.exports={name:"websocket",description:"Websocket Client & Server Library implementing the WebSocket protocol as specified in RFC 6455.",keywords:["websocket","websockets","socket","networking","comet","push","RFC-6455","realtime","server","client"],author:"Brian McKelvey <theturtle32@gmail.com> (https://github.com/theturtle32)",contributors:["Iñaki Baz Castillo <ibc@aliax.net> (http://dev.sipdoc.net)"],version:"1.0.34",repository:{type:"git",url:"https://github.com/theturtle32/WebSocket-Node.git"},homepage:"https://github.com/theturtle32/WebSocket-Node",engines:{node:">=4.0.0"},dependencies:{bufferutil:"^4.0.1",debug:"^2.2.0","es5-ext":"^0.10.50","typedarray-to-buffer":"^3.1.5","utf-8-validate":"^5.0.2",yaeti:"^0.0.6"},devDependencies:{"buffer-equal":"^1.0.0",gulp:"^4.0.2","gulp-jshint":"^2.0.4","jshint-stylish":"^2.2.1",jshint:"^2.0.0",tape:"^4.9.1"},config:{verbose:!1},scripts:{test:"tape test/unit/*.js",gulp:"gulp"},main:"index",directories:{lib:"./lib"},browser:"lib/browser.js",license:"Apache-2.0"}},{}],"xumm-sdk":[function(e,t,r){(function(t){(function(){"use strict";var o=this&&this.__awaiter||function(e,t,r,o){return new(r||(r=Promise))((function(n,i){function s(e){try{u(o.next(e))}catch(e){i(e)}}function a(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(r,"__esModule",{value:!0}),r.XummSdkJwt=r.XummSdk=void 0;const n=e("debug"),i=e("./Meta"),s=e("./Storage"),a=e("./Payload"),u=e("./xApp"),c=n.debug("xumm-sdk");class l{constructor(e,t){return c("Constructed"),this.Meta=new i.Meta(e||this.getEnv("XUMM_APIKEY"),t||this.getEnv("XUMM_APISECRET")),this.storage=new s.Storage(this.Meta),this.payload=new a.Payload(this.Meta),this.xApp=new u.xApp(this.Meta),this.Meta._inject(this),this}getEnv(e){let r="";try{r="undefined"!=typeof Deno&&Deno.env.get(e)||"",r=(null==t?void 0:t.env[e])||""}catch(e){}return r}ping(){return this.Meta.ping()}getCuratedAssets(){return this.Meta.getCuratedAssets()}getRates(e){return this.Meta.getRates(e)}getKycStatus(e){return this.Meta.getKycStatus(e)}getTransaction(e){return this.Meta.getTransaction(e)}verifyUserTokens(e){return this.Meta.verifyUserTokens(e)}verifyUserToken(e){return o(this,void 0,void 0,(function*(){const t=yield this.Meta.verifyUserTokens([e]);return Array.isArray(t)&&1===t.length?t[0]:null}))}setEndpoint(e){return this.Meta.setEndpoint(e)}caught(e){throw e}}r.XummSdk=l;r.XummSdkJwt=class extends l{constructor(e,t,r){var o,n,i,s,a,u,l,d;let h=String(t||"").trim().toLowerCase();const f=36!==e.length;if(!f&&void 0===t&&"undefined"!=typeof window&&void 0!==window.URLSearchParams){const e=new window.URLSearchParams((null===(o=null===window||void 0===window?void 0:window.location)||void 0===o?void 0:o.search)||"");for(const t of e.entries())"xAppToken"===t[0]&&(h=t[1].toLowerCase().trim());if(""===h&&"string"==typeof(null===(n=null===window||void 0===window?void 0:window.localStorage)||void 0===n?void 0:n.XummSdkJwt))try{const e=null===(s=null===(i=null===window||void 0===window?void 0:window.localStorage)||void 0===i?void 0:i.XummSdkJwt)||void 0===s?void 0:s.split(":"),t=JSON.parse(null===(a=null==e?void 0:e.slice(1))||void 0===a?void 0:a.join(":"));if(null==t?void 0:t.jwt){const r=JSON.parse(atob(null===(u=t.jwt.split("."))||void 0===u?void 0:u[1]));if(null==r?void 0:r.exp){const t=(null==r?void 0:r.exp)-Math.floor((new Date).getTime()/1e3);console.log("Restoring OTT "+(null==e?void 0:e[0])),t>3600?h=null==e?void 0:e[0]:console.log("Skip restore: not valid for one more hour")}}}catch(e){console.log("JWT Restore Error",e)}}super(e,f||""===h?"RAWJWT:"+e:"xApp:OneTimeToken:"+h),this.resolve=e=>{c("OTT data resolved",e)},this.reject=e=>{c("OTT data rejected",e.message)},this.ottResolved=f?Promise.resolve():new Promise(((e,t)=>{this.resolve=e,this.reject=t})),(null==r?void 0:r.fatalHandler)&&(this.fatalHandler=r.fatalHandler),this.store={get(e){var t;if(c("[JwtStore] » Builtin JWT store GET"),"undefined"!=typeof window&&void 0!==window.localStorage&&"string"==typeof window.localStorage.XummSdkJwt){const r=window.localStorage.XummSdkJwt.split(":");if(r[0]===e){c("Restoring OTT from localStorage:",e);try{return JSON.parse(r.slice(1).join(":"))}catch(e){c("Error restoring OTT Data (JWT) from localStorage",null===(t=e)||void 0===t?void 0:t.message)}}}},set(e,t){c("[JwtStore] » Builtin JWT store SET",e),"undefined"!=typeof window&&"undefined"!=typeof localStorage&&(window.localStorage.XummSdkJwt=e+":"+JSON.stringify(t))}},(null===(l=null==r?void 0:r.store)||void 0===l?void 0:l.get)&&(this.store.get=r.store.get),(null===(d=null==r?void 0:r.store)||void 0===d?void 0:d.set)&&(this.store.set=r.store.set),f?(this.reject(new Error("Not in OTT flow: in raw JWT (OAuth2-like) flow")),c("Using JWT (Raw, OAuth2) flow")):c("Using JWT (xApp) flow")}_jwtStore(e,t){if(e&&(null==e?void 0:e.constructor)===i.Meta)return{get:e=>{var t;return c("[JwtStore] Proxy GET"),null===(t=this.store)||void 0===t?void 0:t.get(e)},set:(e,r)=>{var o;return c("[JwtStore] Proxy SET"),this.resolve(r.ott),t(r.jwt),this.jwt=r.jwt,null===(o=this.store)||void 0===o?void 0:o.set(e,r)}};throw new Error("Invalid _jwtStore invoker")}getOttData(){return o(this,void 0,void 0,(function*(){const e=yield this.ottResolved;if(e)return e;throw new Error("Called getOttData on a non OTT-JWT flow")}))}getJwt(){return o(this,void 0,void 0,(function*(){return yield this.ottResolved,this.jwt}))}caught(e){this.reject(e)}}}).call(this)}).call(this,e("_process"))},{"./Meta":1,"./Payload":2,"./Storage":3,"./xApp":5,_process:13,debug:7}]},{},[]);
require=function e(t,r,o){function n(s,a){if(!r[s]){if(!t[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=r[s]={exports:{}};t[s][0].call(l.exports,(function(e){return n(t[s][1][e]||e)}),l,l.exports,e,t,r,o)}return r[s].exports}for(var i="function"==typeof require&&require,s=0;s<o.length;s++)n(o[s]);return n}({1:[function(e,t,r){"use strict";var o=this&&this.__awaiter||function(e,t,r,o){return new(r||(r=Promise))((function(n,i){function s(e){try{u(o.next(e))}catch(e){i(e)}}function a(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((o=o.apply(e,t||[])).next())}))},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.Meta=void 0;const i=e("debug"),s=n(e("fetch-ponyfill")),{fetch:a,Request:u,Response:c,Headers:l}=s.default(),d=e("os-browserify"),h=e("./utils"),f=e("./index"),p=i.debug("xumm-sdk:meta");r.Meta=class{constructor(e,t){this.isBrowser=!1,this.jwtFlow=!1,this.injected=!1,this.endpoint="https://xumm.app",p("Constructed");const r=new RegExp("^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"),o={split:t.split(":"),uuidv4:""};if(3===o.split.length&&"xApp:OneTimeToken"===o.split.slice(0,2).join(":")?(o.uuidv4=o.split[2],this.jwtFlow=!0):o.split.length>1&&"RAWJWT"===o.split[0]?(this.jwtFlow=!0,this.jwt=o.split.slice(1).join(":")):o.uuidv4=t,!r.test(e)||!r.test(o.uuidv4)){if(!this.jwtFlow)throw new Error("Invalid API Key and/or API Secret. Use dotenv or constructor params.");if(!this.jwt)throw new Error("Invalid API Key and/or OTT (One Time Token). Provide OTT param (2nd param) or make sure `xAppToken` query param is present (Browser)")}return"undefined"!=typeof globalThis&&Object.keys(globalThis).indexOf("window")<0?p("Running in node"):(console.log("XUMM SDK: Running in browser"),this.isBrowser=!0),this.apiKey=e,this.apiSecret=o.uuidv4,this.jwtFlow&&!this.jwt&&(this.authPromise=new Promise((e=>{this.authPromiseResolve=e})),Promise.resolve().then((()=>this.authorize())).catch((e=>{p("Authorize error:",e.message),(null==this?void 0:this.invoker)&&this.invoker.caught(e),this.authPromiseResolve&&this.authPromiseResolve()}))),this}setEndpoint(e){return!!e.match(/^http/)&&(this.endpoint=e.trim(),!0)}authorize(){var e,t,r,n;return o(this,void 0,void 0,(function*(){let o;p("JWT Authorize",this.apiSecret),(null==this?void 0:this.invoker)&&this.invoker.constructor===f.XummSdkJwt&&(o=this.invoker._jwtStore(this,(e=>this.jwt=e)));const i=(null==o?void 0:o.get(this.apiSecret))||(yield this.call("authorize"));if(null===(t=null===(e=i)||void 0===e?void 0:e.error)||void 0===t?void 0:t.code)p("Could not resolve API Key & OTT to JWT (already fetched? Unauthorized?)"),(null==this?void 0:this.invoker)&&this.invoker.constructor===f.XummSdkJwt&&(null===(r=null==this?void 0:this.invoker)||void 0===r?void 0:r.fatalHandler)?this.invoker.fatalHandler(new Error(i.error.reference)):h.throwIfError(i);else{if(!(null===(n=i)||void 0===n?void 0:n.jwt))throw new Error("Unexpected response for xApp JWT authorize request");{const e=i;null==o||o.set(this.apiSecret,e)}}this.authPromiseResolve&&this.authPromiseResolve()}))}call(e,t="GET",r){var n;return o(this,void 0,void 0,(function*(){const o=t.toUpperCase();this.jwtFlow&&!(null==this?void 0:this.jwt)&&this.authPromise&&"authorize"!==e&&(yield this.authPromise);try{let t;void 0!==r&&("object"==typeof r&&null!==r&&(t=JSON.stringify(r)),"string"==typeof r&&(t=r));const n={"Content-Type":"application/json"};this.isBrowser||Object.assign(n,{"User-Agent":`xumm-sdk/node (${d.hostname()}) node-fetch`}),this.jwtFlow?"authorize"===e?Object.assign(n,{"x-api-key":this.apiKey,"x-api-ott":this.apiSecret}):Object.assign(n,{Authorization:"Bearer "+this.jwt}):Object.assign(n,{"x-api-key":this.apiKey,"x-api-secret":this.apiSecret});const i=["authorize","ping","curated-assets","rates","payload","userdata"],s=this.jwtFlow&&i.indexOf(e.split("/")[0])>-1?"jwt":"platform",u=yield a(this.endpoint+"/api/v1/"+s+"/"+e,{method:o,body:t,headers:n});return yield u.json()}catch(t){const r=new Error(`Unexpected response from XUMM API [${o}:${e}]`);throw r.stack=(null===(n=t)||void 0===n?void 0:n.stack)||void 0,r}}))}ping(){var e,t;return o(this,void 0,void 0,(function*(){const r=yield this.call("ping");if(h.throwIfError(r),void 0!==r.auth)return r.auth;if(void 0!==(null===(e=r)||void 0===e?void 0:e.ott_uuidv4))return{application:{uuidv4:r.app_uuidv4,name:r.app_name},jwtData:r};if(void 0!==(null===(t=r)||void 0===t?void 0:t.usertoken_uuidv4))return{application:{uuidv4:r.client_id,name:r.app_name},jwtData:r};throw new Error("Unexpected response for ping request")}))}getCuratedAssets(){return o(this,void 0,void 0,(function*(){return yield this.call("curated-assets")}))}getRates(e){return o(this,void 0,void 0,(function*(){return yield this.call("rates/"+e.trim().toUpperCase())}))}getKycStatus(e){return o(this,void 0,void 0,(function*(){if(e.trim().match(/^r/)){const t=yield this.call("kyc-status/"+e.trim());return(null==t?void 0:t.kycApproved)?"SUCCESSFUL":"NONE"}{const t=yield this.call("kyc-status","POST",{user_token:e});return(null==t?void 0:t.kycStatus)||"NONE"}}))}getTransaction(e){return o(this,void 0,void 0,(function*(){return yield this.call("xrpl-tx/"+e.trim())}))}verifyUserTokens(e){return o(this,void 0,void 0,(function*(){return(yield this.call("user-tokens","POST",{tokens:Array.isArray(e)?e:[e]})).tokens}))}_inject(e){if(this.injected)throw new Error("Cannot `_inject` twice");this.invoker=e}}},{"./index":"xumm-sdk","./utils":4,debug:7,"fetch-ponyfill":10,"os-browserify":12}],2:[function(e,t,r){"use strict";var o=this&&this.__awaiter||function(e,t,r,o){return new(r||(r=Promise))((function(n,i){function s(e){try{u(o.next(e))}catch(e){i(e)}}function a(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(r,"__esModule",{value:!0}),r.Payload=void 0;const n=e("debug"),i=e("websocket"),s=e("./utils"),a=n.debug("xumm-sdk:payload"),u=n.debug("xumm-sdk:payload:websocket");r.Payload=class{constructor(e){a("Constructed"),this.Meta=e}resolvePayload(e){var t,r,n;return o(this,void 0,void 0,(function*(){if("string"==typeof e)return yield this.get(e,!0);if(void 0!==(null===(t=e)||void 0===t?void 0:t.uuid))return yield this.get(e.uuid,!0);if(void 0!==(null===(n=null===(r=e)||void 0===r?void 0:r.meta)||void 0===n?void 0:n.uuid))return e;throw new Error("Could not resolve payload (not found)")}))}create(e,t=!1){var r;return o(this,void 0,void 0,(function*(){const o=void 0!==e.TransactionType&&void 0===e.txjson,n=yield this.Meta.call("payload","POST",o?{txjson:e}:e);t&&s.throwIfError(n);return void 0!==(null===(r=n)||void 0===r?void 0:r.next)?n:null}))}get(e,t=!1){var r,n;return o(this,void 0,void 0,(function*(){const o="string"==typeof e?e:null==e?void 0:e.uuid,i=yield this.Meta.call("payload/"+o,"GET");t&&s.throwIfError(i);return void 0!==(null===(n=null===(r=i)||void 0===r?void 0:r.meta)||void 0===n?void 0:n.uuid)?i:null}))}subscribe(e,t){var r,n;return o(this,void 0,void 0,(function*(){const a=new s.DeferredPromise,c=yield this.resolvePayload(e);if(c){const e="undefined",s=typeof(null===(r=globalThis)||void 0===r?void 0:r.MockedWebSocket)!==e&&typeof jest!==e?new(null===(n=globalThis)||void 0===n?void 0:n.MockedWebSocket)("ws://xumm.local"):new i.w3cwebsocket(this.Meta.endpoint.replace(/^http/,"ws")+"/sign/"+c.meta.uuid);return a.promise.then((()=>{s.close()})),s.onopen=()=>{u(`Payload ${c.meta.uuid}: Subscription active (WebSocket opened)`)},s.onmessage=e=>o(this,void 0,void 0,(function*(){const r=e.data;let n;try{n=JSON.parse(r.toString())}catch(e){u(`Payload ${c.meta.uuid}: Received message, unable to parse as JSON`,e)}if(n&&t&&void 0===n.devapp_fetched)try{const e=yield t({uuid:c.meta.uuid,data:n,resolve(e){return o(this,void 0,void 0,(function*(){yield a.resolve(e||void 0)}))},payload:c});void 0!==e&&a.resolve(e)}catch(e){u(`Payload ${c.meta.uuid}: Callback exception`,e)}})),s.onclose=e=>{u(`Payload ${c.meta.uuid}: Subscription ended (WebSocket closed)`)},{payload:c,resolve(e){a.resolve(e||void 0)},resolved:a.promise,websocket:s}}throw s.throwIfError(c),Error("Couldn't subscribe: couldn't fetch payload")}))}cancel(e,t=!1){var r,n,i;return o(this,void 0,void 0,(function*(){const o=yield this.resolvePayload(e),a=yield this.Meta.call("payload/"+(null===(r=null==o?void 0:o.meta)||void 0===r?void 0:r.uuid),"DELETE");t&&s.throwIfError(a);return void 0!==(null===(i=null===(n=a)||void 0===n?void 0:n.meta)||void 0===i?void 0:i.uuid)?a:null}))}createAndSubscribe(e,t){return o(this,void 0,void 0,(function*(){const r=yield this.create(e,!0);if(r){const e=yield this.subscribe(r,t);return Object.assign({created:r},e)}throw new Error("Error creating payload or subscribing to created payload")}))}}},{"./utils":4,debug:7,websocket:14}],3:[function(e,t,r){"use strict";var o=this&&this.__awaiter||function(e,t,r,o){return new(r||(r=Promise))((function(n,i){function s(e){try{u(o.next(e))}catch(e){i(e)}}function a(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(r,"__esModule",{value:!0}),r.Storage=void 0;const n=e("debug"),i=e("./utils"),s=n.debug("xumm-sdk:storage");r.Storage=class{constructor(e){s("Constructed"),this.Meta=e}get(){return o(this,void 0,void 0,(function*(){const e=yield this.Meta.call("app-storage","GET");return i.throwIfError(e),e.data}))}set(e){return o(this,void 0,void 0,(function*(){const t=yield this.Meta.call("app-storage","POST",e);return i.throwIfError(t),t.stored}))}delete(){return o(this,void 0,void 0,(function*(){const e=yield this.Meta.call("app-storage","DELETE");return i.throwIfError(e),e.stored}))}}},{"./utils":4,debug:7}],4:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.DeferredPromise=r.throwIfError=void 0,r.throwIfError=function(e){var t,r,o,n,i,s;if(void 0!==e.message)throw new Error(e.message);if(void 0===e.next&&void 0===(null===(r=null===(t=e)||void 0===t?void 0:t.meta)||void 0===r?void 0:r.uuid)&&void 0===(null===(n=null===(o=e)||void 0===o?void 0:o.application)||void 0===n?void 0:n.uuidv4)&&void 0!==(null===(s=null===(i=e)||void 0===i?void 0:i.error)||void 0===s?void 0:s.code)){const t=e.error;throw new Error(`Error code ${t.code}, see XUMM Dev Console, reference: ${t.reference}`)}};r.DeferredPromise=class{constructor(){this.resolveFn=e=>{},this.rejectFn=e=>{},this.promise=new Promise(((e,t)=>{this.resolveFn=e,this.rejectFn=t}))}resolve(e){return this.resolveFn(e),this.promise}reject(e){return this.rejectFn(e),this.promise}}},{}],5:[function(e,t,r){"use strict";var o=this&&this.__awaiter||function(e,t,r,o){return new(r||(r=Promise))((function(n,i){function s(e){try{u(o.next(e))}catch(e){i(e)}}function a(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(r,"__esModule",{value:!0}),r.xApp=void 0;const n=e("debug"),i=e("./xAppUserdata"),s=e("./utils"),a=n.debug("xumm-sdk:xapp");r.xApp=class{constructor(e){a("Constructed"),this.Meta=e,this.userdata=new i.xAppUserdata(this.Meta)}get(e){return o(this,void 0,void 0,(function*(){const t=yield this.Meta.call("xapp/ott/"+e,"GET");return s.throwIfError(t),t}))}event(e){return o(this,void 0,void 0,(function*(){const t=yield this.Meta.call("xapp/event","POST",e);return s.throwIfError(t),t}))}push(e){return o(this,void 0,void 0,(function*(){const t=yield this.Meta.call("xapp/push","POST",e);return s.throwIfError(t),t}))}}},{"./utils":4,"./xAppUserdata":6,debug:7}],6:[function(e,t,r){"use strict";var o=this&&this.__awaiter||function(e,t,r,o){return new(r||(r=Promise))((function(n,i){function s(e){try{u(o.next(e))}catch(e){i(e)}}function a(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(r,"__esModule",{value:!0}),r.xAppUserdata=void 0;const n=e("debug"),i=e("./utils"),s=n.debug("xumm-sdk:xapp:userdata");r.xAppUserdata=class{constructor(e){s("Constructed"),this.Meta=e}list(){return o(this,void 0,void 0,(function*(){const e=yield this.Meta.call("userdata","GET");return i.throwIfError(e),e.keys}))}get(e){var t;return o(this,void 0,void 0,(function*(){const r=Array.isArray(e)?e.join(","):e,o=yield this.Meta.call("userdata/"+r,"GET");return i.throwIfError(o),r.split(",").length>1?o.data:(null===(t=o.data)||void 0===t?void 0:t[r])||{}}))}delete(e){return o(this,void 0,void 0,(function*(){const t=yield this.Meta.call("userdata/"+e,"DELETE");return i.throwIfError(t),t.persisted}))}set(e,t){return o(this,void 0,void 0,(function*(){const r=yield this.Meta.call("userdata/"+e,"POST",t);return i.throwIfError(r),r.persisted}))}}},{"./utils":4,debug:7}],7:[function(e,t,r){(function(o){(function(){r.formatArgs=function(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;e.splice(1,0,r,"color: inherit");let o=0,n=0;e[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(o++,"%c"===e&&(n=o))})),e.splice(n,0,r)},r.save=function(e){try{e?r.storage.setItem("debug",e):r.storage.removeItem("debug")}catch(e){}},r.load=function(){let e;try{e=r.storage.getItem("debug")}catch(e){}!e&&void 0!==o&&"env"in o&&(e=o.env.DEBUG);return e},r.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},r.storage=function(){try{return localStorage}catch(e){}}(),r.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),r.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],r.log=console.debug||console.log||(()=>{}),t.exports=e("./common")(r);const{formatters:n}=t.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this)}).call(this,e("_process"))},{"./common":8,_process:13}],8:[function(e,t,r){t.exports=function(t){function r(e){let t,n=null;function i(...e){if(!i.enabled)return;const o=i,n=Number(new Date),s=n-(t||n);o.diff=s,o.prev=t,o.curr=n,t=n,e[0]=r.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((t,n)=>{if("%%"===t)return"%";a++;const i=r.formatters[n];if("function"==typeof i){const r=e[a];t=i.call(o,r),e.splice(a,1),a--}return t})),r.formatArgs.call(o,e);(o.log||r.log).apply(o,e)}return i.namespace=e,i.useColors=r.useColors(),i.color=r.selectColor(e),i.extend=o,i.destroy=r.destroy,Object.defineProperty(i,"enabled",{enumerable:!0,configurable:!1,get:()=>null===n?r.enabled(e):n,set:e=>{n=e}}),"function"==typeof r.init&&r.init(i),i}function o(e,t){const o=r(this.namespace+(void 0===t?":":t)+e);return o.log=this.log,o}function n(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return r.debug=r,r.default=r,r.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},r.disable=function(){const e=[...r.names.map(n),...r.skips.map(n).map((e=>"-"+e))].join(",");return r.enable(""),e},r.enable=function(e){let t;r.save(e),r.names=[],r.skips=[];const o=("string"==typeof e?e:"").split(/[\s,]+/),n=o.length;for(t=0;t<n;t++)o[t]&&("-"===(e=o[t].replace(/\*/g,".*?"))[0]?r.skips.push(new RegExp("^"+e.substr(1)+"$")):r.names.push(new RegExp("^"+e+"$")))},r.enabled=function(e){if("*"===e[e.length-1])return!0;let t,o;for(t=0,o=r.skips.length;t<o;t++)if(r.skips[t].test(e))return!1;for(t=0,o=r.names.length;t<o;t++)if(r.names[t].test(e))return!0;return!1},r.humanize=e("ms"),r.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(t).forEach((e=>{r[e]=t[e]})),r.names=[],r.skips=[],r.formatters={},r.selectColor=function(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t|=0;return r.colors[Math.abs(t)%r.colors.length]},r.enable(r.load()),r}},{ms:11}],9:[function(e,t,r){var o=function(){if("object"==typeof self&&self)return self;if("object"==typeof window&&window)return window;throw new Error("Unable to resolve global `this`")};t.exports=function(){if(this)return this;if("object"==typeof globalThis&&globalThis)return globalThis;try{Object.defineProperty(Object.prototype,"__global__",{get:function(){return this},configurable:!0})}catch(e){return o()}try{return __global__||o()}finally{delete Object.prototype.__global__}}()},{}],10:[function(e,t,r){(function(e){(function(){!function(e){"use strict";function o(o){var n=o&&o.Promise||e.Promise,i=o&&o.XMLHttpRequest||e.XMLHttpRequest;return function(){var o=Object.create(e,{fetch:{value:void 0,writable:!0}});return function(e,o){"object"==typeof r&&void 0!==t?o(r):"function"==typeof define&&define.amd?define(["exports"],o):o(e.WHATWGFetch={})}(this,(function(e){var t=void 0!==o&&o||"undefined"!=typeof self&&self||void 0!==t&&t,r="URLSearchParams"in t,s="Symbol"in t&&"iterator"in Symbol,a="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(e){return!1}}(),u="FormData"in t,c="ArrayBuffer"in t;if(c)var l=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],d=ArrayBuffer.isView||function(e){return e&&l.indexOf(Object.prototype.toString.call(e))>-1};function h(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function f(e){return"string"!=typeof e&&(e=String(e)),e}function p(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return s&&(t[Symbol.iterator]=function(){return t}),t}function v(e){this.map={},e instanceof v?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function y(e){if(e.bodyUsed)return n.reject(new TypeError("Already read"));e.bodyUsed=!0}function w(e){return new n((function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}}))}function m(e){var t=new FileReader,r=w(t);return t.readAsArrayBuffer(e),r}function g(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function b(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:a&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:u&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():c&&a&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=g(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):c&&(ArrayBuffer.prototype.isPrototypeOf(e)||d(e))?this._bodyArrayBuffer=g(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},a&&(this.blob=function(){var e=y(this);if(e)return e;if(this._bodyBlob)return n.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return n.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return n.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=y(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?n.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):n.resolve(this._bodyArrayBuffer))}return this.blob().then(m)}),this.text=function(){var e,t,r,o=y(this);if(o)return o;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=w(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return n.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),o=0;o<t.length;o++)r[o]=String.fromCharCode(t[o]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return n.resolve(this._bodyText)},u&&(this.formData=function(){return this.text().then(E)}),this.json=function(){return this.text().then(JSON.parse)},this}v.prototype.append=function(e,t){e=h(e),t=f(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},v.prototype.delete=function(e){delete this.map[h(e)]},v.prototype.get=function(e){return e=h(e),this.has(e)?this.map[e]:null},v.prototype.has=function(e){return this.map.hasOwnProperty(h(e))},v.prototype.set=function(e,t){this.map[h(e)]=f(t)},v.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},v.prototype.keys=function(){var e=[];return this.forEach((function(t,r){e.push(r)})),p(e)},v.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),p(e)},v.prototype.entries=function(){var e=[];return this.forEach((function(t,r){e.push([r,t])})),p(e)},s&&(v.prototype[Symbol.iterator]=v.prototype.entries);var C=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function T(e,t){if(!(this instanceof T))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var r,o,n=(t=t||{}).body;if(e instanceof T){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new v(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,n||null==e._bodyInit||(n=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new v(t.headers)),this.method=(r=t.method||this.method||"GET",o=r.toUpperCase(),C.indexOf(o)>-1?o:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&n)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(n),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==t.cache&&"no-cache"!==t.cache)){var i=/([?&])_=[^&]*/;if(i.test(this.url))this.url=this.url.replace(i,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function E(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var r=e.split("="),o=r.shift().replace(/\+/g," "),n=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(o),decodeURIComponent(n))}})),t}function x(e,t){if(!(this instanceof x))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"",this.headers=new v(t.headers),this.url=t.url||"",this._initBody(e)}T.prototype.clone=function(){return new T(this,{body:this._bodyInit})},b.call(T.prototype),b.call(x.prototype),x.prototype.clone=function(){return new x(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new v(this.headers),url:this.url})},x.error=function(){var e=new x(null,{status:0,statusText:""});return e.type="error",e};var _=[301,302,303,307,308];x.redirect=function(e,t){if(-1===_.indexOf(t))throw new RangeError("Invalid status code");return new x(null,{status:t,headers:{location:e}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function j(r,o){return new n((function(n,s){var u=new T(r,o);if(u.signal&&u.signal.aborted)return s(new e.DOMException("Aborted","AbortError"));var l=new i;function d(){l.abort()}l.onload=function(){var e,t,r={status:l.status,statusText:l.statusText,headers:(e=l.getAllResponseHeaders()||"",t=new v,e.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(e){return 0===e.indexOf("\n")?e.substr(1,e.length):e})).forEach((function(e){var r=e.split(":"),o=r.shift().trim();if(o){var n=r.join(":").trim();t.append(o,n)}})),t)};r.url="responseURL"in l?l.responseURL:r.headers.get("X-Request-URL");var o="response"in l?l.response:l.responseText;setTimeout((function(){n(new x(o,r))}),0)},l.onerror=function(){setTimeout((function(){s(new TypeError("Network request failed"))}),0)},l.ontimeout=function(){setTimeout((function(){s(new TypeError("Network request failed"))}),0)},l.onabort=function(){setTimeout((function(){s(new e.DOMException("Aborted","AbortError"))}),0)},l.open(u.method,function(e){try{return""===e&&t.location.href?t.location.href:e}catch(t){return e}}(u.url),!0),"include"===u.credentials?l.withCredentials=!0:"omit"===u.credentials&&(l.withCredentials=!1),"responseType"in l&&(a?l.responseType="blob":c&&u.headers.get("Content-Type")&&-1!==u.headers.get("Content-Type").indexOf("application/octet-stream")&&(l.responseType="arraybuffer")),!o||"object"!=typeof o.headers||o.headers instanceof v?u.headers.forEach((function(e,t){l.setRequestHeader(t,e)})):Object.getOwnPropertyNames(o.headers).forEach((function(e){l.setRequestHeader(e,f(o.headers[e]))})),u.signal&&(u.signal.addEventListener("abort",d),l.onreadystatechange=function(){4===l.readyState&&u.signal.removeEventListener("abort",d)}),l.send(void 0===u._bodyInit?null:u._bodyInit)}))}j.polyfill=!0,t.fetch||(t.fetch=j,t.Headers=v,t.Request=T,t.Response=x),e.Headers=v,e.Request=T,e.Response=x,e.fetch=j,Object.defineProperty(e,"__esModule",{value:!0})})),{fetch:o.fetch,Headers:o.Headers,Request:o.Request,Response:o.Response,DOMException:o.DOMException}}()}"function"==typeof define&&define.amd?define((function(){return o})):"object"==typeof r?t.exports=o:e.fetchPonyfill=o}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:void 0!==e?e:this)}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],11:[function(e,t,r){var o=1e3,n=60*o,i=60*n,s=24*i,a=7*s,u=365.25*s;function c(e,t,r,o){var n=t>=1.5*r;return Math.round(e/r)+" "+o+(n?"s":"")}t.exports=function(e,t){t=t||{};var r=typeof e;if("string"===r&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*u;case"weeks":case"week":case"w":return r*a;case"days":case"day":case"d":return r*s;case"hours":case"hour":case"hrs":case"hr":case"h":return r*i;case"minutes":case"minute":case"mins":case"min":case"m":return r*n;case"seconds":case"second":case"secs":case"sec":case"s":return r*o;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(e);if("number"===r&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=s)return c(e,t,s,"day");if(t>=i)return c(e,t,i,"hour");if(t>=n)return c(e,t,n,"minute");if(t>=o)return c(e,t,o,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=s)return Math.round(e/s)+"d";if(t>=i)return Math.round(e/i)+"h";if(t>=n)return Math.round(e/n)+"m";if(t>=o)return Math.round(e/o)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],12:[function(e,t,r){r.endianness=function(){return"LE"},r.hostname=function(){return"undefined"!=typeof location?location.hostname:""},r.loadavg=function(){return[]},r.uptime=function(){return 0},r.freemem=function(){return Number.MAX_VALUE},r.totalmem=function(){return Number.MAX_VALUE},r.cpus=function(){return[]},r.type=function(){return"Browser"},r.release=function(){return"undefined"!=typeof navigator?navigator.appVersion:""},r.networkInterfaces=r.getNetworkInterfaces=function(){return{}},r.arch=function(){return"javascript"},r.platform=function(){return"browser"},r.tmpdir=r.tmpDir=function(){return"/tmp"},r.EOL="\n",r.homedir=function(){return"/"}},{}],13:[function(e,t,r){var o,n,i=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function u(e){if(o===setTimeout)return setTimeout(e,0);if((o===s||!o)&&setTimeout)return o=setTimeout,setTimeout(e,0);try{return o(e,0)}catch(t){try{return o.call(null,e,0)}catch(t){return o.call(this,e,0)}}}!function(){try{o="function"==typeof setTimeout?setTimeout:s}catch(e){o=s}try{n="function"==typeof clearTimeout?clearTimeout:a}catch(e){n=a}}();var c,l=[],d=!1,h=-1;function f(){d&&c&&(d=!1,c.length?l=c.concat(l):h=-1,l.length&&p())}function p(){if(!d){var e=u(f);d=!0;for(var t=l.length;t;){for(c=l,l=[];++h<t;)c&&c[h].run();h=-1,t=l.length}c=null,d=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===a||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function v(e,t){this.fun=e,this.array=t}function y(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];l.push(new v(e,t)),1!==l.length||d||u(p)},v.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=y,i.addListener=y,i.once=y,i.off=y,i.removeListener=y,i.removeAllListeners=y,i.emit=y,i.prependListener=y,i.prependOnceListener=y,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},{}],14:[function(e,t,r){var o;if("object"==typeof globalThis)o=globalThis;else try{o=e("es5-ext/global")}catch(e){}finally{if(o||"undefined"==typeof window||(o=window),!o)throw new Error("Could not determine global this")}var n=o.WebSocket||o.MozWebSocket,i=e("./version");function s(e,t){return t?new n(e,t):new n(e)}n&&["CONNECTING","OPEN","CLOSING","CLOSED"].forEach((function(e){Object.defineProperty(s,e,{get:function(){return n[e]}})})),t.exports={w3cwebsocket:n?s:null,version:i}},{"./version":15,"es5-ext/global":9}],15:[function(e,t,r){t.exports=e("../package.json").version},{"../package.json":16}],16:[function(e,t,r){t.exports={name:"websocket",description:"Websocket Client & Server Library implementing the WebSocket protocol as specified in RFC 6455.",keywords:["websocket","websockets","socket","networking","comet","push","RFC-6455","realtime","server","client"],author:"Brian McKelvey <theturtle32@gmail.com> (https://github.com/theturtle32)",contributors:["Iñaki Baz Castillo <ibc@aliax.net> (http://dev.sipdoc.net)"],version:"1.0.34",repository:{type:"git",url:"https://github.com/theturtle32/WebSocket-Node.git"},homepage:"https://github.com/theturtle32/WebSocket-Node",engines:{node:">=4.0.0"},dependencies:{bufferutil:"^4.0.1",debug:"^2.2.0","es5-ext":"^0.10.50","typedarray-to-buffer":"^3.1.5","utf-8-validate":"^5.0.2",yaeti:"^0.0.6"},devDependencies:{"buffer-equal":"^1.0.0",gulp:"^4.0.2","gulp-jshint":"^2.0.4","jshint-stylish":"^2.2.1",jshint:"^2.0.0",tape:"^4.9.1"},config:{verbose:!1},scripts:{test:"tape test/unit/*.js",gulp:"gulp"},main:"index",directories:{lib:"./lib"},browser:"lib/browser.js",license:"Apache-2.0"}},{}],"xumm-sdk":[function(e,t,r){(function(t){(function(){"use strict";var o=this&&this.__awaiter||function(e,t,r,o){return new(r||(r=Promise))((function(n,i){function s(e){try{u(o.next(e))}catch(e){i(e)}}function a(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(r,"__esModule",{value:!0}),r.XummSdkJwt=r.XummSdk=void 0;const n=e("debug"),i=e("./Meta"),s=e("./Storage"),a=e("./Payload"),u=e("./xApp"),c=n.debug("xumm-sdk");class l{constructor(e,t){return c("Constructed"),this.Meta=new i.Meta(e||this.getEnv("XUMM_APIKEY"),t||this.getEnv("XUMM_APISECRET")),this.storage=new s.Storage(this.Meta),this.payload=new a.Payload(this.Meta),this.xApp=new u.xApp(this.Meta),this.Meta._inject(this),this}getEnv(e){let r="";try{r="undefined"!=typeof Deno&&Deno.env.get(e)||"",r=(null==t?void 0:t.env[e])||""}catch(e){}return r}ping(){return this.Meta.ping()}getCuratedAssets(){return this.Meta.getCuratedAssets()}getRates(e){return this.Meta.getRates(e)}getKycStatus(e){return this.Meta.getKycStatus(e)}getTransaction(e){return this.Meta.getTransaction(e)}verifyUserTokens(e){return this.Meta.verifyUserTokens(e)}verifyUserToken(e){return o(this,void 0,void 0,(function*(){const t=yield this.Meta.verifyUserTokens([e]);return Array.isArray(t)&&1===t.length?t[0]:null}))}setEndpoint(e){return this.Meta.setEndpoint(e)}caught(e){throw e}}r.XummSdk=l;r.XummSdkJwt=class extends l{constructor(e,t,r){var o,n,i,s,a,u,l,d;let h=String(t||"").trim().toLowerCase();const f=36!==e.length;if(!f&&void 0===t&&"undefined"!=typeof window&&void 0!==window.URLSearchParams){const e=new window.URLSearchParams((null===(o=null===window||void 0===window?void 0:window.location)||void 0===o?void 0:o.search)||"");for(const t of e.entries())"xAppToken"===t[0]&&(h=t[1].toLowerCase().trim());if(""===h&&!(null==r?void 0:r.store)&&!(null==r?void 0:r.noAutoRetrieve)&&"string"==typeof(null===(n=null===window||void 0===window?void 0:window.localStorage)||void 0===n?void 0:n.XummSdkJwt))try{const e=null===(s=null===(i=null===window||void 0===window?void 0:window.localStorage)||void 0===i?void 0:i.XummSdkJwt)||void 0===s?void 0:s.split(":"),t=JSON.parse(null===(a=null==e?void 0:e.slice(1))||void 0===a?void 0:a.join(":"));if(null==t?void 0:t.jwt){const r=JSON.parse(atob(null===(u=t.jwt.split("."))||void 0===u?void 0:u[1]));if(null==r?void 0:r.exp){const t=(null==r?void 0:r.exp)-Math.floor((new Date).getTime()/1e3);console.log("Restoring OTT "+(null==e?void 0:e[0])),t>3600?h=null==e?void 0:e[0]:console.log("Skip restore: not valid for one more hour")}}}catch(e){console.log("JWT Restore Error",e)}}super(e,f||""===h?"RAWJWT:"+e:"xApp:OneTimeToken:"+h),this.resolve=e=>{c("OTT data resolved",e)},this.reject=e=>{c("OTT data rejected",e.message)},this.ottResolved=f?Promise.resolve():new Promise(((e,t)=>{this.resolve=e,this.reject=t})),(null==r?void 0:r.fatalHandler)&&(this.fatalHandler=r.fatalHandler),this.store={get(e){var t;if(c("[JwtStore] » Builtin JWT store GET"),"undefined"!=typeof window&&void 0!==window.localStorage&&"string"==typeof window.localStorage.XummSdkJwt){const r=window.localStorage.XummSdkJwt.split(":");if(r[0]===e){c("Restoring OTT from localStorage:",e);try{return JSON.parse(r.slice(1).join(":"))}catch(e){c("Error restoring OTT Data (JWT) from localStorage",null===(t=e)||void 0===t?void 0:t.message)}}}},set(e,t){c("[JwtStore] » Builtin JWT store SET",e),"undefined"!=typeof window&&"undefined"!=typeof localStorage&&(window.localStorage.XummSdkJwt=e+":"+JSON.stringify(t))}},(null===(l=null==r?void 0:r.store)||void 0===l?void 0:l.get)&&(this.store.get=r.store.get),(null===(d=null==r?void 0:r.store)||void 0===d?void 0:d.set)&&(this.store.set=r.store.set),f?(this.reject(new Error("Not in OTT flow: in raw JWT (OAuth2-like) flow")),c("Using JWT (Raw, OAuth2) flow")):c("Using JWT (xApp) flow")}_jwtStore(e,t){if(e&&(null==e?void 0:e.constructor)===i.Meta)return{get:e=>{var t;return c("[JwtStore] Proxy GET"),null===(t=this.store)||void 0===t?void 0:t.get(e)},set:(e,r)=>{var o;return c("[JwtStore] Proxy SET"),this.resolve(r.ott),t(r.jwt),this.jwt=r.jwt,null===(o=this.store)||void 0===o?void 0:o.set(e,r)}};throw new Error("Invalid _jwtStore invoker")}getOttData(){return o(this,void 0,void 0,(function*(){const e=yield this.ottResolved;if(e)return e;throw new Error("Called getOttData on a non OTT-JWT flow")}))}getJwt(){return o(this,void 0,void 0,(function*(){return yield this.ottResolved,this.jwt}))}caught(e){this.reject(e)}}}).call(this)}).call(this,e("_process"))},{"./Meta":1,"./Payload":2,"./Storage":3,"./xApp":5,_process:13,debug:7}]},{},[]);

@@ -34,2 +34,3 @@ import { Meta } from './Meta';

fatalHandler?: (error: Error) => void;
noAutoRetrieve?: boolean;
}

@@ -36,0 +37,0 @@ declare class XummSdkJwt extends XummSdk {

@@ -96,3 +96,3 @@ "use strict";

}
if (_ott === '') {
if (_ott === '' && !(options === null || options === void 0 ? void 0 : options.store) && !(options === null || options === void 0 ? void 0 : options.noAutoRetrieve)) {
// Check if we have something in history

@@ -99,0 +99,0 @@ if (typeof ((_b = window === null || window === void 0 ? void 0 : window.localStorage) === null || _b === void 0 ? void 0 : _b['XummSdkJwt']) === 'string') {

{
"name": "xumm-sdk",
"version": "1.6.0",
"version": "1.6.1",
"description": "Interact with the Xumm Developer API",

@@ -5,0 +5,0 @@ "main": "dist/src/index.js",

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc