@vesselapi/client-sdk
Advanced tools
Comparing version 0.1.12 to 0.1.13
@@ -1,1 +0,1 @@ | ||
function t(){t=function(){return e};var e={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function s(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,n){return t[e]=n}}function l(t,e,n,r){var i=e&&e.prototype instanceof d?e:d,a=Object.create(i.prototype),u=new L(r||[]);return o(a,"_invoke",{value:x(t,n,u)}),a}function f(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var p={};function d(){}function h(){}function v(){}var y={};s(y,a,(function(){return this}));var w=Object.getPrototypeOf,g=w&&w(w(j([])));g&&g!==n&&r.call(g,a)&&(y=g);var m=v.prototype=d.prototype=Object.create(y);function b(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function _(t,e){function n(o,i,a,u){var c=f(t[o],t,i);if("throw"!==c.type){var s=c.arg,l=s.value;return l&&"object"==typeof l&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,a,u)}),(function(t){n("throw",t,a,u)})):e.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return n("throw",t,a,u)}))}u(c.arg)}var i;o(this,"_invoke",{value:function(t,r){function o(){return new e((function(e,o){n(t,r,e,o)}))}return i=i?i.then(o,o):o()}})}function x(t,e,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return T()}for(n.method=o,n.arg=i;;){var a=n.delegate;if(a){var u=k(a,n);if(u){if(u===p)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var c=f(t,e,n);if("normal"===c.type){if(r=n.done?"completed":"suspendedYield",c.arg===p)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r="completed",n.method="throw",n.arg=c.arg)}}}function k(t,e){var n=e.method,r=t.iterator[n];if(void 0===r)return e.delegate=null,"throw"===n&&t.iterator.return&&(e.method="return",e.arg=void 0,k(t,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),p;var o=f(r,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,p;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,p):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}function E(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function j(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:T}}function T(){return{value:void 0,done:!0}}return h.prototype=v,o(m,"constructor",{value:v,configurable:!0}),o(v,"constructor",{value:h,configurable:!0}),h.displayName=s(v,c,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,s(t,c,"GeneratorFunction")),t.prototype=Object.create(m),t},e.awrap=function(t){return{__await:t}},b(_.prototype),s(_.prototype,u,(function(){return this})),e.AsyncIterator=_,e.async=function(t,n,r,o,i){void 0===i&&(i=Promise);var a=new _(l(t,n,r,o),i);return e.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},b(m),s(m,c,"Generator"),s(m,a,(function(){return this})),s(m,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},e.values=j,L.prototype={constructor:L,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(O),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(n,r){return a.type="throw",a.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,p):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),p},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),O(n),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;O(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:j(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),p}},e}function e(t,e,n,r,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void n(t)}u.done?e(c):Promise.resolve(c).then(r,o)}function n(t){return function(){var n=this,r=arguments;return new Promise((function(o,i){var a=t.apply(n,r);function u(t){e(a,o,i,u,c,"next",t)}function c(t){e(a,o,i,u,c,"throw",t)}u(void 0)}))}}function r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,f(r.key),r)}}function o(t){return o=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},o(t)}function i(t,e){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},i(t,e)}function a(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function u(t,e,n){return u=a()?Reflect.construct.bind():function(t,e,n){var r=[null];r.push.apply(r,e);var o=new(Function.bind.apply(t,r));return n&&i(o,n.prototype),o},u.apply(null,arguments)}function c(t){var e="function"==typeof Map?new Map:void 0;return c=function(t){if(null===t||(n=t,-1===Function.toString.call(n).indexOf("[native code]")))return t;var n;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return u(t,arguments,o(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),i(r,t)},c(t)}function s(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function l(t){var e=a();return function(){var n,r=o(t);if(e){var i=o(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return s(t)}(this,n)}}function f(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}var p="__vessel-modal__",d="_vessel_close_connect_",h="_vessel_start_modal_flow_",v="_vessel_send_token_",y="_vessel_modal_ready_",w=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&i(t,e)}(u,c(Error));var e,n,o,a=l(u);function u(t,e){var n,r,o,i;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,u),n=a.call(this,t),r=s(n),i=void 0,(o=f(o="metadata"))in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i,n.metadata=null!=e?e:{},n}return e=u,n&&r(e.prototype,n),o&&r(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e}(),g=function(e){var r,o,i,a=e.onSuccess,u=e.onClose,c=e.onLoad,s=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{baseUrl:"https://api.vessel.dev"}).baseUrl;if("undefined"==typeof window||!window.document||!window.document.createElement)return{location:"server",open:(i=n(t().mark((function e(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),e)}))),function(){return i.apply(this,arguments)}),destroy:(o=n(t().mark((function e(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),e)}))),function(){return o.apply(this,arguments)})};window.__vessel__||(window.__vessel__={});var l,f,g,m=function(e){var r,o=e.prefixUrl,i=o.endsWith("/")?o.replace(/\/$/,""):o,a=function(){var e=n(t().mark((function e(n,r){var o,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("".concat(i).concat(n),{method:"POST",body:r.body?JSON.stringify(r.body):void 0,headers:{"content-type":"application/json","x-vessel-session-token":r.sessionToken}});case 2:return o=t.sent,t.next=5,o.json();case 5:if(!(a=t.sent).error){t.next=8;break}throw a.error;case 8:return t.abrupt("return",a.result);case 9:case"end":return t.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}();return{post:a,integrations:{find:(r=n(t().mark((function e(n,r){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",a(o.includes("api.vessel.dev")?"/integrations/find":"/api/integrations/find",{sessionToken:r.sessionToken,body:n}));case 1:case"end":return t.stop()}}),e)}))),function(t,e){return r.apply(this,arguments)})}}}({prefixUrl:s}),b=null!==(l=document.getElementById(p))&&void 0!==l?l:((f=document.createElement("iframe")).src="https://app.vessel.dev/modal/index.html",f.id=p,f.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n border: none;\n z-index: 99999; \n display: none;\n overflowX: hidden;\n overflowY: auto;\n ",document.body.appendChild(f),f);if(!window.__vessel__)throw new w("Invalid state: the vessel sdk was destroyed");null!==(r=window.__vessel__)&&void 0!==r&&r.callback&&window.removeEventListener("message",null===(g=window.__vessel__)||void 0===g?void 0:g.callback);window.__vessel__.callback=function(t){return function(e){var n=e.data;if(t){var r=n.messageType,o=n.sessionToken;switch(r){case d:t.style.display="none",null==u||u();break;case v:t.style.display="none",a(o);break;case y:null==c||c()}}}}(b),window.addEventListener("message",window.__vessel__.callback);var _,x;return{location:"client",open:(x=n(t().mark((function e(n){var r,o,i,a,u,c,l,f,p;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=n.integrationId,o=n.oauthAppId,i=n.authType,a=n.getSessionToken,b){t.next=4;break}return console.error("VesselError: Open called before modal loaded."),t.abrupt("return");case 4:if(!i||"oauth2"===i||!o){t.next=6;break}throw new w('If an oauthAppId is specified, the authType must be "oauth2"',{integrationId:r,oauthAppId:o,authType:i});case 6:return t.next=8,a();case 8:return u=t.sent,t.next=11,m.integrations.find({id:r},{sessionToken:u});case 11:if(c=t.sent,l=c.integration,f=i?l.auth.find((function(t){return t.type===i})):l.auth.find((function(t){return!0===t.default}))){t.next=18;break}if(!i){t.next=17;break}throw new w("The specified integration does not have an auth strategy for the given auth type",{integrationId:r,authType:i});case 17:throw new w("The specified integration does not have a default auth strategy",{integrationId:r});case 18:p=function(){return o||("oauth2"!==f.type?null:"v_oauthapp_".concat(r,"_default"))},b.style.display="block",e={messageType:h,payload:{integration:l,oauthAppId:p(),sessionToken:u,auth:f,baseUrl:s}},d=void 0,v=void 0,d=e.messageType,v=e.payload,null!=b&&b.contentWindow&&b.contentWindow.postMessage({payload:v,messageType:d},"*");case 21:case"end":return t.stop()}var e,d,v}),e)}))),function(t){return x.apply(this,arguments)}),destroy:(_=n(t().mark((function e(){var n;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:null==(n=document.getElementById(p))||n.remove(),delete window.__vessel__;case 3:case"end":return t.stop()}}),e)}))),function(){return _.apply(this,arguments)})}};export{w as VesselError,g as default}; | ||
function t(){t=function(){return e};var e={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function s(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,n){return t[e]=n}}function l(t,e,n,r){var i=e&&e.prototype instanceof h?e:h,a=Object.create(i.prototype),u=new L(r||[]);return o(a,"_invoke",{value:x(t,n,u)}),a}function f(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var p={};function h(){}function d(){}function v(){}var y={};s(y,a,(function(){return this}));var w=Object.getPrototypeOf,g=w&&w(w(j([])));g&&g!==n&&r.call(g,a)&&(y=g);var m=v.prototype=h.prototype=Object.create(y);function b(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function _(t,e){function n(o,i,a,u){var c=f(t[o],t,i);if("throw"!==c.type){var s=c.arg,l=s.value;return l&&"object"==typeof l&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,a,u)}),(function(t){n("throw",t,a,u)})):e.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return n("throw",t,a,u)}))}u(c.arg)}var i;o(this,"_invoke",{value:function(t,r){function o(){return new e((function(e,o){n(t,r,e,o)}))}return i=i?i.then(o,o):o()}})}function x(t,e,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return T()}for(n.method=o,n.arg=i;;){var a=n.delegate;if(a){var u=k(a,n);if(u){if(u===p)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var c=f(t,e,n);if("normal"===c.type){if(r=n.done?"completed":"suspendedYield",c.arg===p)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r="completed",n.method="throw",n.arg=c.arg)}}}function k(t,e){var n=e.method,r=t.iterator[n];if(void 0===r)return e.delegate=null,"throw"===n&&t.iterator.return&&(e.method="return",e.arg=void 0,k(t,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),p;var o=f(r,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,p;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,p):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}function E(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function j(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:T}}function T(){return{value:void 0,done:!0}}return d.prototype=v,o(m,"constructor",{value:v,configurable:!0}),o(v,"constructor",{value:d,configurable:!0}),d.displayName=s(v,c,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,s(t,c,"GeneratorFunction")),t.prototype=Object.create(m),t},e.awrap=function(t){return{__await:t}},b(_.prototype),s(_.prototype,u,(function(){return this})),e.AsyncIterator=_,e.async=function(t,n,r,o,i){void 0===i&&(i=Promise);var a=new _(l(t,n,r,o),i);return e.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},b(m),s(m,c,"Generator"),s(m,a,(function(){return this})),s(m,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},e.values=j,L.prototype={constructor:L,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(O),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(n,r){return a.type="throw",a.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,p):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),p},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),O(n),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;O(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:j(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),p}},e}function e(t,e,n,r,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void n(t)}u.done?e(c):Promise.resolve(c).then(r,o)}function n(t){return function(){var n=this,r=arguments;return new Promise((function(o,i){var a=t.apply(n,r);function u(t){e(a,o,i,u,c,"next",t)}function c(t){e(a,o,i,u,c,"throw",t)}u(void 0)}))}}function r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,f(r.key),r)}}function o(t){return o=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},o(t)}function i(t,e){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},i(t,e)}function a(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function u(t,e,n){return u=a()?Reflect.construct.bind():function(t,e,n){var r=[null];r.push.apply(r,e);var o=new(Function.bind.apply(t,r));return n&&i(o,n.prototype),o},u.apply(null,arguments)}function c(t){var e="function"==typeof Map?new Map:void 0;return c=function(t){if(null===t||(n=t,-1===Function.toString.call(n).indexOf("[native code]")))return t;var n;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return u(t,arguments,o(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),i(r,t)},c(t)}function s(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function l(t){var e=a();return function(){var n,r=o(t);if(e){var i=o(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return s(t)}(this,n)}}function f(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}var p="__vessel-modal__",h="_vessel_close_connect_",d="_vessel_start_modal_flow_",v="_vessel_send_token_",y="_vessel_modal_ready_",w=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&i(t,e)}(u,c(Error));var e,n,o,a=l(u);function u(t,e){var n,r,o,i;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,u),n=a.call(this,t),r=s(n),i=void 0,(o=f(o="metadata"))in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i,n.metadata=null!=e?e:{},n}return e=u,n&&r(e.prototype,n),o&&r(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e}(),g=function(e){var r,o,i,a=e.onSuccess,u=e.onClose,c=e.onLoad,s=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{baseUrl:"https://api.vessel.dev"}).baseUrl;if("undefined"==typeof window||!window.document||!window.document.createElement)return{location:"server",open:(i=n(t().mark((function e(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),e)}))),function(){return i.apply(this,arguments)}),destroy:(o=n(t().mark((function e(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),e)}))),function(){return o.apply(this,arguments)})};window.__vessel__||(window.__vessel__={});var l,f,g,m=function(e){var r,o=e.prefixUrl,i=o.endsWith("/")?o.replace(/\/$/,""):o,a=function(){var e=n(t().mark((function e(n,r){var o,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("".concat(i).concat(n),{method:"POST",body:r.body?JSON.stringify(r.body):void 0,headers:{"content-type":"application/json","x-vessel-session-token":r.sessionToken}});case 2:return o=t.sent,t.next=5,o.json();case 5:if(!(a=t.sent).error){t.next=8;break}throw a.error;case 8:return t.abrupt("return",a.result);case 9:case"end":return t.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}();return{post:a,integrations:{find:(r=n(t().mark((function e(n,r){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",a("/api/integrations/find",{sessionToken:r.sessionToken,body:n}));case 1:case"end":return t.stop()}}),e)}))),function(t,e){return r.apply(this,arguments)})}}}({prefixUrl:s}),b=null!==(l=document.getElementById(p))&&void 0!==l?l:((f=document.createElement("iframe")).src="https://app.vessel.dev/modal/index.html",f.id=p,f.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n border: none;\n z-index: 99999; \n display: none;\n overflowX: hidden;\n overflowY: auto;\n ",document.body.appendChild(f),f);if(!window.__vessel__)throw new w("Invalid state: the vessel sdk was destroyed");null!==(r=window.__vessel__)&&void 0!==r&&r.callback&&window.removeEventListener("message",null===(g=window.__vessel__)||void 0===g?void 0:g.callback);window.__vessel__.callback=function(t){return function(e){var n=e.data;if(t){var r=n.messageType,o=n.sessionToken;switch(r){case h:t.style.display="none",null==u||u();break;case v:t.style.display="none",a(o);break;case y:null==c||c()}}}}(b),window.addEventListener("message",window.__vessel__.callback);var _,x;return{location:"client",open:(x=n(t().mark((function e(n){var r,o,i,a,u,c,l,f,p;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=n.integrationId,o=n.oauthAppId,i=n.authType,a=n.getSessionToken,b){t.next=4;break}return console.error("VesselError: Open called before modal loaded."),t.abrupt("return");case 4:if(!i||"oauth2"===i||!o){t.next=6;break}throw new w('If an oauthAppId is specified, the authType must be "oauth2"',{integrationId:r,oauthAppId:o,authType:i});case 6:return t.next=8,a();case 8:return u=t.sent,t.next=11,m.integrations.find({id:r},{sessionToken:u});case 11:if(c=t.sent,l=c.integration,f=i?l.auth.find((function(t){return t.type===i})):l.auth.find((function(t){return!0===t.default}))){t.next=18;break}if(!i){t.next=17;break}throw new w("The specified integration does not have an auth strategy for the given auth type",{integrationId:r,authType:i});case 17:throw new w("The specified integration does not have a default auth strategy",{integrationId:r});case 18:p=function(){return o||("oauth2"!==f.type?null:"v_oauthapp_".concat(r,"_default"))},b.style.display="block",e={messageType:d,payload:{integration:l,oauthAppId:p(),sessionToken:u,auth:f,baseUrl:s}},h=void 0,v=void 0,h=e.messageType,v=e.payload,null!=b&&b.contentWindow&&b.contentWindow.postMessage({payload:v,messageType:h},"*");case 21:case"end":return t.stop()}var e,h,v}),e)}))),function(t){return x.apply(this,arguments)}),destroy:(_=n(t().mark((function e(){var n;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:null==(n=document.getElementById(p))||n.remove(),delete window.__vessel__;case 3:case"end":return t.stop()}}),e)}))),function(){return _.apply(this,arguments)})}};export{w as VesselError,g as default}; |
@@ -1,1 +0,1 @@ | ||
"use strict";function t(){t=function(){return e};var e={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function s(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,n){return t[e]=n}}function l(t,e,n,r){var i=e&&e.prototype instanceof d?e:d,a=Object.create(i.prototype),u=new j(r||[]);return o(a,"_invoke",{value:x(t,n,u)}),a}function f(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var p={};function d(){}function h(){}function v(){}var y={};s(y,a,(function(){return this}));var w=Object.getPrototypeOf,g=w&&w(w(L([])));g&&g!==n&&r.call(g,a)&&(y=g);var m=v.prototype=d.prototype=Object.create(y);function b(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function _(t,e){function n(o,i,a,u){var c=f(t[o],t,i);if("throw"!==c.type){var s=c.arg,l=s.value;return l&&"object"==typeof l&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,a,u)}),(function(t){n("throw",t,a,u)})):e.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return n("throw",t,a,u)}))}u(c.arg)}var i;o(this,"_invoke",{value:function(t,r){function o(){return new e((function(e,o){n(t,r,e,o)}))}return i=i?i.then(o,o):o()}})}function x(t,e,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return T()}for(n.method=o,n.arg=i;;){var a=n.delegate;if(a){var u=k(a,n);if(u){if(u===p)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var c=f(t,e,n);if("normal"===c.type){if(r=n.done?"completed":"suspendedYield",c.arg===p)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r="completed",n.method="throw",n.arg=c.arg)}}}function k(t,e){var n=e.method,r=t.iterator[n];if(void 0===r)return e.delegate=null,"throw"===n&&t.iterator.return&&(e.method="return",e.arg=void 0,k(t,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),p;var o=f(r,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,p;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,p):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}function E(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function L(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:T}}function T(){return{value:void 0,done:!0}}return h.prototype=v,o(m,"constructor",{value:v,configurable:!0}),o(v,"constructor",{value:h,configurable:!0}),h.displayName=s(v,c,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,s(t,c,"GeneratorFunction")),t.prototype=Object.create(m),t},e.awrap=function(t){return{__await:t}},b(_.prototype),s(_.prototype,u,(function(){return this})),e.AsyncIterator=_,e.async=function(t,n,r,o,i){void 0===i&&(i=Promise);var a=new _(l(t,n,r,o),i);return e.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},b(m),s(m,c,"Generator"),s(m,a,(function(){return this})),s(m,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},e.values=L,j.prototype={constructor:j,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(O),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(n,r){return a.type="throw",a.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,p):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),p},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),O(n),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;O(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:L(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),p}},e}function e(t,e,n,r,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void n(t)}u.done?e(c):Promise.resolve(c).then(r,o)}function n(t){return function(){var n=this,r=arguments;return new Promise((function(o,i){var a=t.apply(n,r);function u(t){e(a,o,i,u,c,"next",t)}function c(t){e(a,o,i,u,c,"throw",t)}u(void 0)}))}}function r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,f(r.key),r)}}function o(t){return o=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},o(t)}function i(t,e){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},i(t,e)}function a(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function u(t,e,n){return u=a()?Reflect.construct.bind():function(t,e,n){var r=[null];r.push.apply(r,e);var o=new(Function.bind.apply(t,r));return n&&i(o,n.prototype),o},u.apply(null,arguments)}function c(t){var e="function"==typeof Map?new Map:void 0;return c=function(t){if(null===t||(n=t,-1===Function.toString.call(n).indexOf("[native code]")))return t;var n;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return u(t,arguments,o(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),i(r,t)},c(t)}function s(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function l(t){var e=a();return function(){var n,r=o(t);if(e){var i=o(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return s(t)}(this,n)}}function f(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}Object.defineProperty(exports,"__esModule",{value:!0});var p="__vessel-modal__",d="_vessel_close_connect_",h="_vessel_start_modal_flow_",v="_vessel_send_token_",y="_vessel_modal_ready_",w=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&i(t,e)}(u,c(Error));var e,n,o,a=l(u);function u(t,e){var n,r,o,i;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,u),n=a.call(this,t),r=s(n),i=void 0,(o=f(o="metadata"))in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i,n.metadata=null!=e?e:{},n}return e=u,n&&r(e.prototype,n),o&&r(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e}();exports.VesselError=w,exports.default=function(e){var r,o,i,a=e.onSuccess,u=e.onClose,c=e.onLoad,s=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{baseUrl:"https://api.vessel.dev"}).baseUrl;if("undefined"==typeof window||!window.document||!window.document.createElement)return{location:"server",open:(i=n(t().mark((function e(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),e)}))),function(){return i.apply(this,arguments)}),destroy:(o=n(t().mark((function e(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),e)}))),function(){return o.apply(this,arguments)})};window.__vessel__||(window.__vessel__={});var l,f,g,m=function(e){var r,o=e.prefixUrl,i=o.endsWith("/")?o.replace(/\/$/,""):o,a=function(){var e=n(t().mark((function e(n,r){var o,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("".concat(i).concat(n),{method:"POST",body:r.body?JSON.stringify(r.body):void 0,headers:{"content-type":"application/json","x-vessel-session-token":r.sessionToken}});case 2:return o=t.sent,t.next=5,o.json();case 5:if(!(a=t.sent).error){t.next=8;break}throw a.error;case 8:return t.abrupt("return",a.result);case 9:case"end":return t.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}();return{post:a,integrations:{find:(r=n(t().mark((function e(n,r){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",a(o.includes("api.vessel.dev")?"/integrations/find":"/api/integrations/find",{sessionToken:r.sessionToken,body:n}));case 1:case"end":return t.stop()}}),e)}))),function(t,e){return r.apply(this,arguments)})}}}({prefixUrl:s}),b=null!==(l=document.getElementById(p))&&void 0!==l?l:((f=document.createElement("iframe")).src="https://app.vessel.dev/modal/index.html",f.id=p,f.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n border: none;\n z-index: 99999; \n display: none;\n overflowX: hidden;\n overflowY: auto;\n ",document.body.appendChild(f),f);if(!window.__vessel__)throw new w("Invalid state: the vessel sdk was destroyed");null!==(r=window.__vessel__)&&void 0!==r&&r.callback&&window.removeEventListener("message",null===(g=window.__vessel__)||void 0===g?void 0:g.callback);window.__vessel__.callback=function(t){return function(e){var n=e.data;if(t){var r=n.messageType,o=n.sessionToken;switch(r){case d:t.style.display="none",null==u||u();break;case v:t.style.display="none",a(o);break;case y:null==c||c()}}}}(b),window.addEventListener("message",window.__vessel__.callback);var _,x;return{location:"client",open:(x=n(t().mark((function e(n){var r,o,i,a,u,c,l,f,p;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=n.integrationId,o=n.oauthAppId,i=n.authType,a=n.getSessionToken,b){t.next=4;break}return console.error("VesselError: Open called before modal loaded."),t.abrupt("return");case 4:if(!i||"oauth2"===i||!o){t.next=6;break}throw new w('If an oauthAppId is specified, the authType must be "oauth2"',{integrationId:r,oauthAppId:o,authType:i});case 6:return t.next=8,a();case 8:return u=t.sent,t.next=11,m.integrations.find({id:r},{sessionToken:u});case 11:if(c=t.sent,l=c.integration,f=i?l.auth.find((function(t){return t.type===i})):l.auth.find((function(t){return!0===t.default}))){t.next=18;break}if(!i){t.next=17;break}throw new w("The specified integration does not have an auth strategy for the given auth type",{integrationId:r,authType:i});case 17:throw new w("The specified integration does not have a default auth strategy",{integrationId:r});case 18:p=function(){return o||("oauth2"!==f.type?null:"v_oauthapp_".concat(r,"_default"))},b.style.display="block",e={messageType:h,payload:{integration:l,oauthAppId:p(),sessionToken:u,auth:f,baseUrl:s}},d=void 0,v=void 0,d=e.messageType,v=e.payload,null!=b&&b.contentWindow&&b.contentWindow.postMessage({payload:v,messageType:d},"*");case 21:case"end":return t.stop()}var e,d,v}),e)}))),function(t){return x.apply(this,arguments)}),destroy:(_=n(t().mark((function e(){var n;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:null==(n=document.getElementById(p))||n.remove(),delete window.__vessel__;case 3:case"end":return t.stop()}}),e)}))),function(){return _.apply(this,arguments)})}}; | ||
"use strict";function t(){t=function(){return e};var e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var i=e&&e.prototype instanceof h?e:h,a=Object.create(i.prototype),u=new j(n||[]);return o(a,"_invoke",{value:x(t,r,u)}),a}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var p={};function h(){}function d(){}function v(){}var y={};s(y,a,(function(){return this}));var w=Object.getPrototypeOf,g=w&&w(w(L([])));g&&g!==r&&n.call(g,a)&&(y=g);var m=v.prototype=h.prototype=Object.create(y);function b(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function _(t,e){function r(o,i,a,u){var c=f(t[o],t,i);if("throw"!==c.type){var s=c.arg,l=s.value;return l&&"object"==typeof l&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,a,u)}),(function(t){r("throw",t,a,u)})):e.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return r("throw",t,a,u)}))}u(c.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function x(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return T()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var u=k(a,r);if(u){if(u===p)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=f(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===p)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function k(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,k(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),p;var o=f(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,p;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,p):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}function E(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function L(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:T}}function T(){return{value:void 0,done:!0}}return d.prototype=v,o(m,"constructor",{value:v,configurable:!0}),o(v,"constructor",{value:d,configurable:!0}),d.displayName=s(v,c,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,s(t,c,"GeneratorFunction")),t.prototype=Object.create(m),t},e.awrap=function(t){return{__await:t}},b(_.prototype),s(_.prototype,u,(function(){return this})),e.AsyncIterator=_,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new _(l(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},b(m),s(m,c,"Generator"),s(m,a,(function(){return this})),s(m,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=L,j.prototype={constructor:j,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(O),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),c=n.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,p):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),p},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),O(r),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;O(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:L(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},e}function e(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function r(t){return function(){var r=this,n=arguments;return new Promise((function(o,i){var a=t.apply(r,n);function u(t){e(a,o,i,u,c,"next",t)}function c(t){e(a,o,i,u,c,"throw",t)}u(void 0)}))}}function n(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,f(n.key),n)}}function o(t){return o=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},o(t)}function i(t,e){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},i(t,e)}function a(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function u(t,e,r){return u=a()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&i(o,r.prototype),o},u.apply(null,arguments)}function c(t){var e="function"==typeof Map?new Map:void 0;return c=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return u(t,arguments,o(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),i(n,t)},c(t)}function s(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function l(t){var e=a();return function(){var r,n=o(t);if(e){var i=o(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return s(t)}(this,r)}}function f(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}Object.defineProperty(exports,"__esModule",{value:!0});var p="__vessel-modal__",h="_vessel_close_connect_",d="_vessel_start_modal_flow_",v="_vessel_send_token_",y="_vessel_modal_ready_",w=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&i(t,e)}(u,c(Error));var e,r,o,a=l(u);function u(t,e){var r,n,o,i;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,u),r=a.call(this,t),n=s(r),i=void 0,(o=f(o="metadata"))in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i,r.metadata=null!=e?e:{},r}return e=u,r&&n(e.prototype,r),o&&n(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e}();exports.VesselError=w,exports.default=function(e){var n,o,i,a=e.onSuccess,u=e.onClose,c=e.onLoad,s=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{baseUrl:"https://api.vessel.dev"}).baseUrl;if("undefined"==typeof window||!window.document||!window.document.createElement)return{location:"server",open:(i=r(t().mark((function e(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),e)}))),function(){return i.apply(this,arguments)}),destroy:(o=r(t().mark((function e(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),e)}))),function(){return o.apply(this,arguments)})};window.__vessel__||(window.__vessel__={});var l,f,g,m=function(e){var n,o=e.prefixUrl,i=o.endsWith("/")?o.replace(/\/$/,""):o,a=function(){var e=r(t().mark((function e(r,n){var o,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("".concat(i).concat(r),{method:"POST",body:n.body?JSON.stringify(n.body):void 0,headers:{"content-type":"application/json","x-vessel-session-token":n.sessionToken}});case 2:return o=t.sent,t.next=5,o.json();case 5:if(!(a=t.sent).error){t.next=8;break}throw a.error;case 8:return t.abrupt("return",a.result);case 9:case"end":return t.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}();return{post:a,integrations:{find:(n=r(t().mark((function e(r,n){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",a("/api/integrations/find",{sessionToken:n.sessionToken,body:r}));case 1:case"end":return t.stop()}}),e)}))),function(t,e){return n.apply(this,arguments)})}}}({prefixUrl:s}),b=null!==(l=document.getElementById(p))&&void 0!==l?l:((f=document.createElement("iframe")).src="https://app.vessel.dev/modal/index.html",f.id=p,f.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n border: none;\n z-index: 99999; \n display: none;\n overflowX: hidden;\n overflowY: auto;\n ",document.body.appendChild(f),f);if(!window.__vessel__)throw new w("Invalid state: the vessel sdk was destroyed");null!==(n=window.__vessel__)&&void 0!==n&&n.callback&&window.removeEventListener("message",null===(g=window.__vessel__)||void 0===g?void 0:g.callback);window.__vessel__.callback=function(t){return function(e){var r=e.data;if(t){var n=r.messageType,o=r.sessionToken;switch(n){case h:t.style.display="none",null==u||u();break;case v:t.style.display="none",a(o);break;case y:null==c||c()}}}}(b),window.addEventListener("message",window.__vessel__.callback);var _,x;return{location:"client",open:(x=r(t().mark((function e(r){var n,o,i,a,u,c,l,f,p;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=r.integrationId,o=r.oauthAppId,i=r.authType,a=r.getSessionToken,b){t.next=4;break}return console.error("VesselError: Open called before modal loaded."),t.abrupt("return");case 4:if(!i||"oauth2"===i||!o){t.next=6;break}throw new w('If an oauthAppId is specified, the authType must be "oauth2"',{integrationId:n,oauthAppId:o,authType:i});case 6:return t.next=8,a();case 8:return u=t.sent,t.next=11,m.integrations.find({id:n},{sessionToken:u});case 11:if(c=t.sent,l=c.integration,f=i?l.auth.find((function(t){return t.type===i})):l.auth.find((function(t){return!0===t.default}))){t.next=18;break}if(!i){t.next=17;break}throw new w("The specified integration does not have an auth strategy for the given auth type",{integrationId:n,authType:i});case 17:throw new w("The specified integration does not have a default auth strategy",{integrationId:n});case 18:p=function(){return o||("oauth2"!==f.type?null:"v_oauthapp_".concat(n,"_default"))},b.style.display="block",e={messageType:d,payload:{integration:l,oauthAppId:p(),sessionToken:u,auth:f,baseUrl:s}},h=void 0,v=void 0,h=e.messageType,v=e.payload,null!=b&&b.contentWindow&&b.contentWindow.postMessage({payload:v,messageType:h},"*");case 21:case"end":return t.stop()}var e,h,v}),e)}))),function(t){return x.apply(this,arguments)}),destroy:(_=r(t().mark((function e(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:null==(r=document.getElementById(p))||r.remove(),delete window.__vessel__;case 3:case"end":return t.stop()}}),e)}))),function(){return _.apply(this,arguments)})}}; |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).VesselSDK={})}(this,(function(t){"use strict";function e(){e=function(){return t};var t={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function s(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,n){return t[e]=n}}function l(t,e,n,r){var i=e&&e.prototype instanceof d?e:d,a=Object.create(i.prototype),u=new j(r||[]);return o(a,"_invoke",{value:x(t,n,u)}),a}function f(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var p={};function d(){}function h(){}function v(){}var y={};s(y,a,(function(){return this}));var w=Object.getPrototypeOf,g=w&&w(w(L([])));g&&g!==n&&r.call(g,a)&&(y=g);var m=v.prototype=d.prototype=Object.create(y);function b(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function _(t,e){function n(o,i,a,u){var c=f(t[o],t,i);if("throw"!==c.type){var s=c.arg,l=s.value;return l&&"object"==typeof l&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,a,u)}),(function(t){n("throw",t,a,u)})):e.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return n("throw",t,a,u)}))}u(c.arg)}var i;o(this,"_invoke",{value:function(t,r){function o(){return new e((function(e,o){n(t,r,e,o)}))}return i=i?i.then(o,o):o()}})}function x(t,e,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return T()}for(n.method=o,n.arg=i;;){var a=n.delegate;if(a){var u=k(a,n);if(u){if(u===p)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var c=f(t,e,n);if("normal"===c.type){if(r=n.done?"completed":"suspendedYield",c.arg===p)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r="completed",n.method="throw",n.arg=c.arg)}}}function k(t,e){var n=e.method,r=t.iterator[n];if(void 0===r)return e.delegate=null,"throw"===n&&t.iterator.return&&(e.method="return",e.arg=void 0,k(t,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),p;var o=f(r,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,p;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,p):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}function E(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function L(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:T}}function T(){return{value:void 0,done:!0}}return h.prototype=v,o(m,"constructor",{value:v,configurable:!0}),o(v,"constructor",{value:h,configurable:!0}),h.displayName=s(v,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,s(t,c,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},b(_.prototype),s(_.prototype,u,(function(){return this})),t.AsyncIterator=_,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var a=new _(l(e,n,r,o),i);return t.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},b(m),s(m,c,"Generator"),s(m,a,(function(){return this})),s(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},t.values=L,j.prototype={constructor:j,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(O),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(n,r){return a.type="throw",a.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,p):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),p},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),O(n),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;O(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:L(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),p}},t}function n(t,e,n,r,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void n(t)}u.done?e(c):Promise.resolve(c).then(r,o)}function r(t){return function(){var e=this,r=arguments;return new Promise((function(o,i){var a=t.apply(e,r);function u(t){n(a,o,i,u,c,"next",t)}function c(t){n(a,o,i,u,c,"throw",t)}u(void 0)}))}}function o(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,p(r.key),r)}}function i(t){return i=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},i(t)}function a(t,e){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},a(t,e)}function u(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function c(t,e,n){return c=u()?Reflect.construct.bind():function(t,e,n){var r=[null];r.push.apply(r,e);var o=new(Function.bind.apply(t,r));return n&&a(o,n.prototype),o},c.apply(null,arguments)}function s(t){var e="function"==typeof Map?new Map:void 0;return s=function(t){if(null===t||(n=t,-1===Function.toString.call(n).indexOf("[native code]")))return t;var n;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return c(t,arguments,i(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),a(r,t)},s(t)}function l(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function f(t){var e=u();return function(){var n,r=i(t);if(e){var o=i(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return l(t)}(this,n)}}function p(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}var d="__vessel-modal__",h="_vessel_close_connect_",v="_vessel_start_modal_flow_",y="_vessel_send_token_",w="_vessel_modal_ready_",g=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&a(t,e)}(u,t);var e,n,r,i=f(u);function u(t,e){var n,r,o,a;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,u),n=i.call(this,t),r=l(n),a=void 0,(o=p(o="metadata"))in r?Object.defineProperty(r,o,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[o]=a,n.metadata=null!=e?e:{},n}return e=u,n&&o(e.prototype,n),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}(s(Error));t.VesselError=g,t.default=function(t){var n,o,i,a=t.onSuccess,u=t.onClose,c=t.onLoad,s=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{baseUrl:"https://api.vessel.dev"}).baseUrl;if("undefined"==typeof window||!window.document||!window.document.createElement)return{location:"server",open:(i=r(e().mark((function t(){return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),t)}))),function(){return i.apply(this,arguments)}),destroy:(o=r(e().mark((function t(){return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),t)}))),function(){return o.apply(this,arguments)})};window.__vessel__||(window.__vessel__={});var l,f,p,m=function(t){var n,o=t.prefixUrl,i=o.endsWith("/")?o.replace(/\/$/,""):o,a=function(){var t=r(e().mark((function t(n,r){var o,a;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("".concat(i).concat(n),{method:"POST",body:r.body?JSON.stringify(r.body):void 0,headers:{"content-type":"application/json","x-vessel-session-token":r.sessionToken}});case 2:return o=t.sent,t.next=5,o.json();case 5:if(!(a=t.sent).error){t.next=8;break}throw a.error;case 8:return t.abrupt("return",a.result);case 9:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}();return{post:a,integrations:{find:(n=r(e().mark((function t(n,r){return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",a(o.includes("api.vessel.dev")?"/integrations/find":"/api/integrations/find",{sessionToken:r.sessionToken,body:n}));case 1:case"end":return t.stop()}}),t)}))),function(t,e){return n.apply(this,arguments)})}}}({prefixUrl:s}),b=null!==(l=document.getElementById(d))&&void 0!==l?l:((f=document.createElement("iframe")).src="https://app.vessel.dev/modal/index.html",f.id=d,f.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n border: none;\n z-index: 99999; \n display: none;\n overflowX: hidden;\n overflowY: auto;\n ",document.body.appendChild(f),f);if(!window.__vessel__)throw new g("Invalid state: the vessel sdk was destroyed");null!==(n=window.__vessel__)&&void 0!==n&&n.callback&&window.removeEventListener("message",null===(p=window.__vessel__)||void 0===p?void 0:p.callback);window.__vessel__.callback=function(t){return function(e){var n=e.data;if(t){var r=n.messageType,o=n.sessionToken;switch(r){case h:t.style.display="none",null==u||u();break;case y:t.style.display="none",a(o);break;case w:null==c||c()}}}}(b),window.addEventListener("message",window.__vessel__.callback);var _,x;return{location:"client",open:(x=r(e().mark((function t(n){var r,o,i,a,u,c,l,f,p;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=n.integrationId,o=n.oauthAppId,i=n.authType,a=n.getSessionToken,b){t.next=4;break}return console.error("VesselError: Open called before modal loaded."),t.abrupt("return");case 4:if(!i||"oauth2"===i||!o){t.next=6;break}throw new g('If an oauthAppId is specified, the authType must be "oauth2"',{integrationId:r,oauthAppId:o,authType:i});case 6:return t.next=8,a();case 8:return u=t.sent,t.next=11,m.integrations.find({id:r},{sessionToken:u});case 11:if(c=t.sent,l=c.integration,f=i?l.auth.find((function(t){return t.type===i})):l.auth.find((function(t){return!0===t.default}))){t.next=18;break}if(!i){t.next=17;break}throw new g("The specified integration does not have an auth strategy for the given auth type",{integrationId:r,authType:i});case 17:throw new g("The specified integration does not have a default auth strategy",{integrationId:r});case 18:p=function(){return o||("oauth2"!==f.type?null:"v_oauthapp_".concat(r,"_default"))},b.style.display="block",e={messageType:v,payload:{integration:l,oauthAppId:p(),sessionToken:u,auth:f,baseUrl:s}},d=void 0,h=void 0,d=e.messageType,h=e.payload,null!=b&&b.contentWindow&&b.contentWindow.postMessage({payload:h,messageType:d},"*");case 21:case"end":return t.stop()}var e,d,h}),t)}))),function(t){return x.apply(this,arguments)}),destroy:(_=r(e().mark((function t(){var n;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:null==(n=document.getElementById(d))||n.remove(),delete window.__vessel__;case 3:case"end":return t.stop()}}),t)}))),function(){return _.apply(this,arguments)})}},Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).VesselSDK={})}(this,(function(t){"use strict";function e(){e=function(){return t};var t={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function s(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,n){return t[e]=n}}function l(t,e,n,r){var i=e&&e.prototype instanceof d?e:d,a=Object.create(i.prototype),u=new j(r||[]);return o(a,"_invoke",{value:x(t,n,u)}),a}function f(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var p={};function d(){}function h(){}function v(){}var y={};s(y,a,(function(){return this}));var w=Object.getPrototypeOf,g=w&&w(w(L([])));g&&g!==n&&r.call(g,a)&&(y=g);var m=v.prototype=d.prototype=Object.create(y);function b(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function _(t,e){function n(o,i,a,u){var c=f(t[o],t,i);if("throw"!==c.type){var s=c.arg,l=s.value;return l&&"object"==typeof l&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,a,u)}),(function(t){n("throw",t,a,u)})):e.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return n("throw",t,a,u)}))}u(c.arg)}var i;o(this,"_invoke",{value:function(t,r){function o(){return new e((function(e,o){n(t,r,e,o)}))}return i=i?i.then(o,o):o()}})}function x(t,e,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return T()}for(n.method=o,n.arg=i;;){var a=n.delegate;if(a){var u=k(a,n);if(u){if(u===p)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var c=f(t,e,n);if("normal"===c.type){if(r=n.done?"completed":"suspendedYield",c.arg===p)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r="completed",n.method="throw",n.arg=c.arg)}}}function k(t,e){var n=e.method,r=t.iterator[n];if(void 0===r)return e.delegate=null,"throw"===n&&t.iterator.return&&(e.method="return",e.arg=void 0,k(t,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),p;var o=f(r,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,p;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,p):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}function E(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function L(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:T}}function T(){return{value:void 0,done:!0}}return h.prototype=v,o(m,"constructor",{value:v,configurable:!0}),o(v,"constructor",{value:h,configurable:!0}),h.displayName=s(v,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,s(t,c,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},b(_.prototype),s(_.prototype,u,(function(){return this})),t.AsyncIterator=_,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var a=new _(l(e,n,r,o),i);return t.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},b(m),s(m,c,"Generator"),s(m,a,(function(){return this})),s(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},t.values=L,j.prototype={constructor:j,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(O),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(n,r){return a.type="throw",a.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,p):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),p},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),O(n),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;O(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:L(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),p}},t}function n(t,e,n,r,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void n(t)}u.done?e(c):Promise.resolve(c).then(r,o)}function r(t){return function(){var e=this,r=arguments;return new Promise((function(o,i){var a=t.apply(e,r);function u(t){n(a,o,i,u,c,"next",t)}function c(t){n(a,o,i,u,c,"throw",t)}u(void 0)}))}}function o(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,p(r.key),r)}}function i(t){return i=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},i(t)}function a(t,e){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},a(t,e)}function u(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function c(t,e,n){return c=u()?Reflect.construct.bind():function(t,e,n){var r=[null];r.push.apply(r,e);var o=new(Function.bind.apply(t,r));return n&&a(o,n.prototype),o},c.apply(null,arguments)}function s(t){var e="function"==typeof Map?new Map:void 0;return s=function(t){if(null===t||(n=t,-1===Function.toString.call(n).indexOf("[native code]")))return t;var n;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return c(t,arguments,i(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),a(r,t)},s(t)}function l(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function f(t){var e=u();return function(){var n,r=i(t);if(e){var o=i(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return l(t)}(this,n)}}function p(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}var d="__vessel-modal__",h="_vessel_close_connect_",v="_vessel_start_modal_flow_",y="_vessel_send_token_",w="_vessel_modal_ready_",g=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&a(t,e)}(u,t);var e,n,r,i=f(u);function u(t,e){var n,r,o,a;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,u),n=i.call(this,t),r=l(n),a=void 0,(o=p(o="metadata"))in r?Object.defineProperty(r,o,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[o]=a,n.metadata=null!=e?e:{},n}return e=u,n&&o(e.prototype,n),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}(s(Error));t.VesselError=g,t.default=function(t){var n,o,i,a=t.onSuccess,u=t.onClose,c=t.onLoad,s=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{baseUrl:"https://api.vessel.dev"}).baseUrl;if("undefined"==typeof window||!window.document||!window.document.createElement)return{location:"server",open:(i=r(e().mark((function t(){return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),t)}))),function(){return i.apply(this,arguments)}),destroy:(o=r(e().mark((function t(){return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),t)}))),function(){return o.apply(this,arguments)})};window.__vessel__||(window.__vessel__={});var l,f,p,m=function(t){var n,o=t.prefixUrl,i=o.endsWith("/")?o.replace(/\/$/,""):o,a=function(){var t=r(e().mark((function t(n,r){var o,a;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("".concat(i).concat(n),{method:"POST",body:r.body?JSON.stringify(r.body):void 0,headers:{"content-type":"application/json","x-vessel-session-token":r.sessionToken}});case 2:return o=t.sent,t.next=5,o.json();case 5:if(!(a=t.sent).error){t.next=8;break}throw a.error;case 8:return t.abrupt("return",a.result);case 9:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}();return{post:a,integrations:{find:(n=r(e().mark((function t(n,r){return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",a("/api/integrations/find",{sessionToken:r.sessionToken,body:n}));case 1:case"end":return t.stop()}}),t)}))),function(t,e){return n.apply(this,arguments)})}}}({prefixUrl:s}),b=null!==(l=document.getElementById(d))&&void 0!==l?l:((f=document.createElement("iframe")).src="https://app.vessel.dev/modal/index.html",f.id=d,f.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n border: none;\n z-index: 99999; \n display: none;\n overflowX: hidden;\n overflowY: auto;\n ",document.body.appendChild(f),f);if(!window.__vessel__)throw new g("Invalid state: the vessel sdk was destroyed");null!==(n=window.__vessel__)&&void 0!==n&&n.callback&&window.removeEventListener("message",null===(p=window.__vessel__)||void 0===p?void 0:p.callback);window.__vessel__.callback=function(t){return function(e){var n=e.data;if(t){var r=n.messageType,o=n.sessionToken;switch(r){case h:t.style.display="none",null==u||u();break;case y:t.style.display="none",a(o);break;case w:null==c||c()}}}}(b),window.addEventListener("message",window.__vessel__.callback);var _,x;return{location:"client",open:(x=r(e().mark((function t(n){var r,o,i,a,u,c,l,f,p;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=n.integrationId,o=n.oauthAppId,i=n.authType,a=n.getSessionToken,b){t.next=4;break}return console.error("VesselError: Open called before modal loaded."),t.abrupt("return");case 4:if(!i||"oauth2"===i||!o){t.next=6;break}throw new g('If an oauthAppId is specified, the authType must be "oauth2"',{integrationId:r,oauthAppId:o,authType:i});case 6:return t.next=8,a();case 8:return u=t.sent,t.next=11,m.integrations.find({id:r},{sessionToken:u});case 11:if(c=t.sent,l=c.integration,f=i?l.auth.find((function(t){return t.type===i})):l.auth.find((function(t){return!0===t.default}))){t.next=18;break}if(!i){t.next=17;break}throw new g("The specified integration does not have an auth strategy for the given auth type",{integrationId:r,authType:i});case 17:throw new g("The specified integration does not have a default auth strategy",{integrationId:r});case 18:p=function(){return o||("oauth2"!==f.type?null:"v_oauthapp_".concat(r,"_default"))},b.style.display="block",e={messageType:v,payload:{integration:l,oauthAppId:p(),sessionToken:u,auth:f,baseUrl:s}},d=void 0,h=void 0,d=e.messageType,h=e.payload,null!=b&&b.contentWindow&&b.contentWindow.postMessage({payload:h,messageType:d},"*");case 21:case"end":return t.stop()}var e,d,h}),t)}))),function(t){return x.apply(this,arguments)}),destroy:(_=r(e().mark((function t(){var n;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:null==(n=document.getElementById(d))||n.remove(),delete window.__vessel__;case 3:case"end":return t.stop()}}),t)}))),function(){return _.apply(this,arguments)})}},Object.defineProperty(t,"__esModule",{value:!0})})); |
{ | ||
"name": "@vesselapi/client-sdk", | ||
"version": "0.1.12", | ||
"version": "0.1.13", | ||
"description": "Vessel API Client SDK", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
51872
256