@amedia/user 0.7.2 → 0.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +6 -17
- package/dist/index.js +7 -2
- package/dist/lib/authentication.d.ts +17 -0
- package/dist/lib/authentication.js +74 -0
- package/dist/lib/authorization.d.ts +14 -0
- package/dist/lib/authorization.js +51 -0
- package/dist/{cache/engines/indexeddb.d.ts → lib/cache/db.d.ts} +2 -3
- package/dist/lib/cache/db.js +13 -0
- package/dist/lib/cache/global.d.ts +9 -0
- package/dist/lib/cache/global.js +16 -0
- package/dist/lib/cache/types.d.ts +5 -0
- package/dist/lib/cache/types.js +2 -0
- package/dist/lib/queue.d.ts +5 -0
- package/dist/lib/queue.js +17 -0
- package/dist/lib/tools.d.ts +1 -0
- package/dist/lib/tools.js +2 -0
- package/dist/lib/user.d.ts +2 -0
- package/dist/lib/user.js +3 -0
- package/dist/services/cache.d.ts +9 -0
- package/dist/services/cache.js +34 -0
- package/dist/services/jupiter.d.ts +4 -4
- package/dist/services/jupiter.js +72 -0
- package/dist/services/pluto.d.ts +10 -6
- package/dist/services/pluto.js +40 -0
- package/package.json +1 -1
- package/src/actions/authorization.ts +2 -2
- package/src/actions/preferences.spec.ts +2 -14
- package/src/actions/preferences.ts +26 -54
- package/src/cache/index.spec.ts +2 -2
- package/src/clients/europa.spec.ts +51 -19
- package/src/clients/europa.ts +70 -53
- package/src/clients/jupiter.spec.ts +26 -0
- package/src/clients/jupiter.ts +3 -2
- package/src/clients/mercury.spec.ts +5 -7
- package/src/clients/mercury.ts +4 -2
- package/src/clients/pluto.spec.ts +0 -2
- package/src/eventHandlers/activation.ts +2 -2
- package/src/index-authentcation.spec.ts +2 -1
- package/src/index-subscription.spec.ts +20 -13
- package/src/index.ts +58 -34
- package/src/types.ts +1 -0
- package/src/utils/getOrUpdate.spec.ts +168 -0
- package/src/utils/getOrUpdate.ts +27 -3
- package/dist/actions/authentication.d.ts +0 -4
- package/dist/actions/authorization.d.ts +0 -3
- package/dist/actions/preferences.d.ts +0 -9
- package/dist/actions/preferences.spec.d.ts +0 -1
- package/dist/actions/userData.d.ts +0 -2
- package/dist/cache/engines/global.d.ts +0 -21
- package/dist/cache/engines/global.spec.d.ts +0 -1
- package/dist/cache/index.d.ts +0 -11
- package/dist/cache/index.spec.d.ts +0 -4
- package/dist/cache/types.d.ts +0 -11
- package/dist/clients/europa.d.ts +0 -12
- package/dist/clients/europa.spec.d.ts +0 -1
- package/dist/clients/jupiter.d.ts +0 -30
- package/dist/clients/jupiter.spec.d.ts +0 -1
- package/dist/clients/mercury.d.ts +0 -18
- package/dist/clients/mercury.spec.d.ts +0 -4
- package/dist/clients/nebula.d.ts +0 -2
- package/dist/clients/nebula.spec.d.ts +0 -1
- package/dist/clients/pluto.d.ts +0 -3
- package/dist/clients/pluto.spec.d.ts +0 -1
- package/dist/eventHandlers/activation.d.ts +0 -15
- package/dist/eventHandlers/authentication.d.ts +0 -17
- package/dist/eventHandlers/userAttributes.d.ts +0 -14
- package/dist/index-authentcation.spec.d.ts +0 -4
- package/dist/index-subscription.spec.d.ts +0 -4
- package/dist/index-userdata.spec.d.ts +0 -4
- package/dist/index.js.LICENSE.txt +0 -14
- package/dist/index.js.gz +0 -0
- package/dist/lib/cookie.d.ts +0 -5
- package/dist/lib/rpc.d.ts +0 -6
- package/dist/services/europa.d.ts +0 -12
- package/dist/services/europa.spec.d.ts +0 -1
- package/dist/services/jupiter.spec.d.ts +0 -1
- package/dist/services/mercury.d.ts +0 -18
- package/dist/services/mercury.spec.d.ts +0 -4
- package/dist/services/nebula.d.ts +0 -22
- package/dist/services/nebula.spec.d.ts +0 -1
- package/dist/services/pluto.spec.d.ts +0 -1
- package/dist/store/index.d.ts +0 -13
- package/dist/store/index.spec.d.ts +0 -1
- package/dist/store/store.d.ts +0 -13
- package/dist/store/store.spec.d.ts +0 -1
- package/dist/types.d.ts +0 -24
- package/dist/utils/customEventWrapper.d.ts +0 -17
- package/dist/utils/deepEquals.d.ts +0 -4
- package/dist/utils/getOrUpdate.d.ts +0 -6
- package/dist/utils/log.d.ts +0 -26
- package/dist/utils/queue.d.ts +0 -12
- package/dist/utils/url.d.ts +0 -3
- package/dist/utils/url.spec.d.ts +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
import '
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export declare const subscribeToUserAttributes: <T extends (keyof UserAttributes)[]>(attributes: T, onUserUpdated: (attributes: Pick<UserAttributes, T[number]>) => void, onStateUpdated?: ((attributes: State) => void) | undefined) => void;
|
|
8
|
-
/**
|
|
9
|
-
* This will, if necessary, trigger a redirect to www.aid.no and return
|
|
10
|
-
* to the requestedUrl if supplied or the current url before redirecting away if not.
|
|
11
|
-
* @param requestedUrl
|
|
12
|
-
*/
|
|
13
|
-
export declare const goToLoginPage: (requestedUrl?: string | undefined) => void;
|
|
14
|
-
export declare const logout: () => Promise<void>;
|
|
15
|
-
export declare const tryActivateSubscriptionAccess: (access: string) => Promise<{
|
|
16
|
-
hasAccess: boolean;
|
|
17
|
-
}>;
|
|
1
|
+
import { AuthorizationEvents } from './lib/authorization';
|
|
2
|
+
import { AuthenticationEvents } from './lib/authentication';
|
|
3
|
+
export declare const AmediaUserEvents: {
|
|
4
|
+
authentication: typeof AuthenticationEvents;
|
|
5
|
+
authorization: typeof AuthorizationEvents;
|
|
6
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.user=t():e.user=t()}(this,(function(){return(()=>{var e={651:(e,t,r)=>{var n,o,i;void 0===(o="function"==typeof(n=i=function(){function e(){for(var e=0,t={};e<arguments.length;e++){var r=arguments[e];for(var n in r)t[n]=r[n]}return t}function t(e){return e.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}return function r(n){function o(){}function i(t,r,i){if("undefined"!=typeof document){"number"==typeof(i=e({path:"/"},o.defaults,i)).expires&&(i.expires=new Date(1*new Date+864e5*i.expires)),i.expires=i.expires?i.expires.toUTCString():"";try{var a=JSON.stringify(r);/^[\{\[]/.test(a)&&(r=a)}catch(e){}r=n.write?n.write(r,t):encodeURIComponent(String(r)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),t=encodeURIComponent(String(t)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape);var c="";for(var u in i)i[u]&&(c+="; "+u,!0!==i[u]&&(c+="="+i[u].split(";")[0]));return document.cookie=t+"="+r+c}}function a(e,r){if("undefined"!=typeof document){for(var o={},i=document.cookie?document.cookie.split("; "):[],a=0;a<i.length;a++){var c=i[a].split("="),u=c.slice(1).join("=");r||'"'!==u.charAt(0)||(u=u.slice(1,-1));try{var s=t(c[0]);if(u=(n.read||n)(u,s)||t(u),r)try{u=JSON.parse(u)}catch(e){}if(o[s]=u,e===s)break}catch(e){}}return e?o[e]:o}}return o.set=i,o.get=function(e){return a(e,!1)},o.getJSON=function(e){return a(e,!0)},o.remove=function(t,r){i(t,"",e(r,{expires:-1}))},o.defaults={},o.withConverter=r,o}((function(){}))})?n.call(t,r,t,e):n)||(e.exports=o),e.exports=i()},466:(e,t,r)=>{e.exports=function e(t,r,n){function o(a,c){if(!r[a]){if(!t[a]){if(i)return i(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var s=r[a]={exports:{}};t[a][0].call(s.exports,(function(e){return o(t[a][1][e]||e)}),s,s.exports,e,t,r,n)}return r[a].exports}for(var i=void 0,a=0;a<n.length;a++)o(n[a]);return o}({1:[function(e,t,n){(function(e){"use strict";var r,n,o=e.MutationObserver||e.WebKitMutationObserver;if(o){var i=0,a=new o(f),c=e.document.createTextNode("");a.observe(c,{characterData:!0}),r=function(){c.data=i=++i%2}}else if(e.setImmediate||void 0===e.MessageChannel)r="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script");t.onreadystatechange=function(){f(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},e.document.documentElement.appendChild(t)}:function(){setTimeout(f,0)};else{var u=new e.MessageChannel;u.port1.onmessage=f,r=function(){u.port2.postMessage(0)}}var s=[];function f(){var e,t;n=!0;for(var r=s.length;r;){for(t=s,s=[],e=-1;++e<r;)t[e]();r=s.length}n=!1}t.exports=function(e){1!==s.push(e)||n||r()}}).call(this,void 0!==r.g?r.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(e,t,r){"use strict";var n=e(1);function o(){}var i={},a=["REJECTED"],c=["FULFILLED"],u=["PENDING"];function s(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=u,this.queue=[],this.outcome=void 0,e!==o&&v(this,e)}function f(e,t,r){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof r&&(this.onRejected=r,this.callRejected=this.otherCallRejected)}function l(e,t,r){n((function(){var n;try{n=t(r)}catch(t){return i.reject(e,t)}n===e?i.reject(e,new TypeError("Cannot resolve promise with itself")):i.resolve(e,n)}))}function d(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function v(e,t){var r=!1;function n(t){r||(r=!0,i.reject(e,t))}function o(t){r||(r=!0,i.resolve(e,t))}var a=h((function(){t(o,n)}));"error"===a.status&&n(a.value)}function h(e,t){var r={};try{r.value=e(t),r.status="success"}catch(e){r.status="error",r.value=e}return r}t.exports=s,s.prototype.catch=function(e){return this.then(null,e)},s.prototype.then=function(e,t){if("function"!=typeof e&&this.state===c||"function"!=typeof t&&this.state===a)return this;var r=new this.constructor(o);return this.state!==u?l(r,this.state===c?e:t,this.outcome):this.queue.push(new f(r,e,t)),r},f.prototype.callFulfilled=function(e){i.resolve(this.promise,e)},f.prototype.otherCallFulfilled=function(e){l(this.promise,this.onFulfilled,e)},f.prototype.callRejected=function(e){i.reject(this.promise,e)},f.prototype.otherCallRejected=function(e){l(this.promise,this.onRejected,e)},i.resolve=function(e,t){var r=h(d,t);if("error"===r.status)return i.reject(e,r.value);var n=r.value;if(n)v(e,n);else{e.state=c,e.outcome=t;for(var o=-1,a=e.queue.length;++o<a;)e.queue[o].callFulfilled(t)}return e},i.reject=function(e,t){e.state=a,e.outcome=t;for(var r=-1,n=e.queue.length;++r<n;)e.queue[r].callRejected(t);return e},s.resolve=function(e){return e instanceof this?e:i.resolve(new this(o),e)},s.reject=function(e){var t=new this(o);return i.reject(t,e)},s.all=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var r=e.length,n=!1;if(!r)return this.resolve([]);for(var a=new Array(r),c=0,u=-1,s=new this(o);++u<r;)f(e[u],u);return s;function f(e,o){t.resolve(e).then((function(e){a[o]=e,++c!==r||n||(n=!0,i.resolve(s,a))}),(function(e){n||(n=!0,i.reject(s,e))}))}},s.race=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var r,n=e.length,a=!1;if(!n)return this.resolve([]);for(var c=-1,u=new this(o);++c<n;)r=e[c],t.resolve(r).then((function(e){a||(a=!0,i.resolve(u,e))}),(function(e){a||(a=!0,i.reject(u,e))}));return u}},{1:1}],3:[function(e,t,n){(function(t){"use strict";"function"!=typeof t.Promise&&(t.Promise=e(2))}).call(this,void 0!==r.g?r.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{2:2}],4:[function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};var o=function(){try{if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof webkitIndexedDB)return webkitIndexedDB;if("undefined"!=typeof mozIndexedDB)return mozIndexedDB;if("undefined"!=typeof OIndexedDB)return OIndexedDB;if("undefined"!=typeof msIndexedDB)return msIndexedDB}catch(e){return}}();function i(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(o){if("TypeError"!==o.name)throw o;for(var r=new("undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder),n=0;n<e.length;n+=1)r.append(e[n]);return r.getBlob(t.type)}}"undefined"==typeof Promise&&e(3);var a=Promise;function c(e,t){t&&e.then((function(e){t(null,e)}),(function(e){t(e)}))}function u(e,t,r){"function"==typeof t&&e.then(t),"function"==typeof r&&e.catch(r)}function s(e){return"string"!=typeof e&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function f(){if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}var l="local-forage-detect-blob-support",d=void 0,v={},h=Object.prototype.toString,p="readonly",y="readwrite";function g(e){for(var t=e.length,r=new ArrayBuffer(t),n=new Uint8Array(r),o=0;o<t;o++)n[o]=e.charCodeAt(o);return r}function m(e){return"boolean"==typeof d?a.resolve(d):function(e){return new a((function(t){var r=e.transaction(l,y),n=i([""]);r.objectStore(l).put(n,"key"),r.onabort=function(e){e.preventDefault(),e.stopPropagation(),t(!1)},r.oncomplete=function(){var e=navigator.userAgent.match(/Chrome\/(\d+)/),r=navigator.userAgent.match(/Edge\//);t(r||!e||parseInt(e[1],10)>=43)}})).catch((function(){return!1}))}(e).then((function(e){return d=e}))}function b(e){var t=v[e.name],r={};r.promise=new a((function(e,t){r.resolve=e,r.reject=t})),t.deferredOperations.push(r),t.dbReady?t.dbReady=t.dbReady.then((function(){return r.promise})):t.dbReady=r.promise}function E(e){var t=v[e.name].deferredOperations.pop();if(t)return t.resolve(),t.promise}function _(e,t){var r=v[e.name].deferredOperations.pop();if(r)return r.reject(t),r.promise}function w(e,t){return new a((function(r,n){if(v[e.name]=v[e.name]||{forages:[],db:null,dbReady:null,deferredOperations:[]},e.db){if(!t)return r(e.db);b(e),e.db.close()}var i=[e.name];t&&i.push(e.version);var a=o.open.apply(o,i);t&&(a.onupgradeneeded=function(t){var r=a.result;try{r.createObjectStore(e.storeName),t.oldVersion<=1&&r.createObjectStore(l)}catch(r){if("ConstraintError"!==r.name)throw r;console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),a.onerror=function(e){e.preventDefault(),n(a.error)},a.onsuccess=function(){r(a.result),E(e)}}))}function S(e){return w(e,!1)}function R(e){return w(e,!0)}function I(e,t){if(!e.db)return!0;var r=!e.db.objectStoreNames.contains(e.storeName),n=e.version<e.db.version,o=e.version>e.db.version;if(n&&(e.version!==t&&console.warn('The database "'+e.name+"\" can't be downgraded from version "+e.db.version+" to version "+e.version+"."),e.version=e.db.version),o||r){if(r){var i=e.db.version+1;i>e.version&&(e.version=i)}return!0}return!1}function O(e){return i([g(atob(e.data))],{type:e.type})}function C(e){return e&&e.__local_forage_encoded_blob}function T(e){var t=this,r=t._initReady().then((function(){var e=v[t._dbInfo.name];if(e&&e.dbReady)return e.dbReady}));return u(r,e,e),r}function N(e,t,r,n){void 0===n&&(n=1);try{var o=e.db.transaction(e.storeName,t);r(null,o)}catch(o){if(n>0&&(!e.db||"InvalidStateError"===o.name||"NotFoundError"===o.name))return a.resolve().then((function(){if(!e.db||"NotFoundError"===o.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),R(e)})).then((function(){return function(e){b(e);for(var t=v[e.name],r=t.forages,n=0;n<r.length;n++){var o=r[n];o._dbInfo.db&&(o._dbInfo.db.close(),o._dbInfo.db=null)}return e.db=null,S(e).then((function(t){return e.db=t,I(e)?R(e):t})).then((function(n){e.db=t.db=n;for(var o=0;o<r.length;o++)r[o]._dbInfo.db=n})).catch((function(t){throw _(e,t),t}))}(e).then((function(){N(e,t,r,n-1)}))})).catch(r);r(o)}}var A={_driver:"asyncStorage",_initStorage:function(e){var t=this,r={db:null};if(e)for(var n in e)r[n]=e[n];var o=v[r.name];o||(o={forages:[],db:null,dbReady:null,deferredOperations:[]},v[r.name]=o),o.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=T);var i=[];function c(){return a.resolve()}for(var u=0;u<o.forages.length;u++){var s=o.forages[u];s!==t&&i.push(s._initReady().catch(c))}var f=o.forages.slice(0);return a.all(i).then((function(){return r.db=o.db,S(r)})).then((function(e){return r.db=e,I(r,t._defaultConfig.version)?R(r):e})).then((function(e){r.db=o.db=e,t._dbInfo=r;for(var n=0;n<f.length;n++){var i=f[n];i!==t&&(i._dbInfo.db=r.db,i._dbInfo.version=r.version)}}))},_support:function(){try{if(!o||!o.open)return!1;var e="undefined"!=typeof openDatabase&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),t="function"==typeof fetch&&-1!==fetch.toString().indexOf("[native code");return(!e||t)&&"undefined"!=typeof indexedDB&&"undefined"!=typeof IDBKeyRange}catch(e){return!1}}(),iterate:function(e,t){var r=this,n=new a((function(t,n){r.ready().then((function(){N(r._dbInfo,p,(function(o,i){if(o)return n(o);try{var a=i.objectStore(r._dbInfo.storeName).openCursor(),c=1;a.onsuccess=function(){var r=a.result;if(r){var n=r.value;C(n)&&(n=O(n));var o=e(n,r.key,c++);void 0!==o?t(o):r.continue()}else t()},a.onerror=function(){n(a.error)}}catch(e){n(e)}}))})).catch(n)}));return c(n,t),n},getItem:function(e,t){var r=this;e=s(e);var n=new a((function(t,n){r.ready().then((function(){N(r._dbInfo,p,(function(o,i){if(o)return n(o);try{var a=i.objectStore(r._dbInfo.storeName).get(e);a.onsuccess=function(){var e=a.result;void 0===e&&(e=null),C(e)&&(e=O(e)),t(e)},a.onerror=function(){n(a.error)}}catch(e){n(e)}}))})).catch(n)}));return c(n,t),n},setItem:function(e,t,r){var n=this;e=s(e);var o=new a((function(r,o){var i;n.ready().then((function(){return i=n._dbInfo,"[object Blob]"===h.call(t)?m(i.db).then((function(e){return e?t:(r=t,new a((function(e,t){var n=new FileReader;n.onerror=t,n.onloadend=function(t){var n=btoa(t.target.result||"");e({__local_forage_encoded_blob:!0,data:n,type:r.type})},n.readAsBinaryString(r)})));var r})):t})).then((function(t){N(n._dbInfo,y,(function(i,a){if(i)return o(i);try{var c=a.objectStore(n._dbInfo.storeName);null===t&&(t=void 0);var u=c.put(t,e);a.oncomplete=function(){void 0===t&&(t=null),r(t)},a.onabort=a.onerror=function(){var e=u.error?u.error:u.transaction.error;o(e)}}catch(e){o(e)}}))})).catch(o)}));return c(o,r),o},removeItem:function(e,t){var r=this;e=s(e);var n=new a((function(t,n){r.ready().then((function(){N(r._dbInfo,y,(function(o,i){if(o)return n(o);try{var a=i.objectStore(r._dbInfo.storeName).delete(e);i.oncomplete=function(){t()},i.onerror=function(){n(a.error)},i.onabort=function(){var e=a.error?a.error:a.transaction.error;n(e)}}catch(e){n(e)}}))})).catch(n)}));return c(n,t),n},clear:function(e){var t=this,r=new a((function(e,r){t.ready().then((function(){N(t._dbInfo,y,(function(n,o){if(n)return r(n);try{var i=o.objectStore(t._dbInfo.storeName).clear();o.oncomplete=function(){e()},o.onabort=o.onerror=function(){var e=i.error?i.error:i.transaction.error;r(e)}}catch(e){r(e)}}))})).catch(r)}));return c(r,e),r},length:function(e){var t=this,r=new a((function(e,r){t.ready().then((function(){N(t._dbInfo,p,(function(n,o){if(n)return r(n);try{var i=o.objectStore(t._dbInfo.storeName).count();i.onsuccess=function(){e(i.result)},i.onerror=function(){r(i.error)}}catch(e){r(e)}}))})).catch(r)}));return c(r,e),r},key:function(e,t){var r=this,n=new a((function(t,n){e<0?t(null):r.ready().then((function(){N(r._dbInfo,p,(function(o,i){if(o)return n(o);try{var a=i.objectStore(r._dbInfo.storeName),c=!1,u=a.openKeyCursor();u.onsuccess=function(){var r=u.result;r?0===e||c?t(r.key):(c=!0,r.advance(e)):t(null)},u.onerror=function(){n(u.error)}}catch(e){n(e)}}))})).catch(n)}));return c(n,t),n},keys:function(e){var t=this,r=new a((function(e,r){t.ready().then((function(){N(t._dbInfo,p,(function(n,o){if(n)return r(n);try{var i=o.objectStore(t._dbInfo.storeName).openKeyCursor(),a=[];i.onsuccess=function(){var t=i.result;t?(a.push(t.key),t.continue()):e(a)},i.onerror=function(){r(i.error)}}catch(e){r(e)}}))})).catch(r)}));return c(r,e),r},dropInstance:function(e,t){t=f.apply(this,arguments);var r=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName);var n,i=this;if(e.name){var u=e.name===r.name&&i._dbInfo.db?a.resolve(i._dbInfo.db):S(e).then((function(t){var r=v[e.name],n=r.forages;r.db=t;for(var o=0;o<n.length;o++)n[o]._dbInfo.db=t;return t}));n=e.storeName?u.then((function(t){if(t.objectStoreNames.contains(e.storeName)){var r=t.version+1;b(e);var n=v[e.name],i=n.forages;t.close();for(var c=0;c<i.length;c++){var u=i[c];u._dbInfo.db=null,u._dbInfo.version=r}return new a((function(t,n){var i=o.open(e.name,r);i.onerror=function(e){i.result.close(),n(e)},i.onupgradeneeded=function(){i.result.deleteObjectStore(e.storeName)},i.onsuccess=function(){var e=i.result;e.close(),t(e)}})).then((function(e){n.db=e;for(var t=0;t<i.length;t++){var r=i[t];r._dbInfo.db=e,E(r._dbInfo)}})).catch((function(t){throw(_(e,t)||a.resolve()).catch((function(){})),t}))}})):u.then((function(t){b(e);var r=v[e.name],n=r.forages;t.close();for(var i=0;i<n.length;i++)n[i]._dbInfo.db=null;return new a((function(t,r){var n=o.deleteDatabase(e.name);n.onerror=n.onblocked=function(e){var t=n.result;t&&t.close(),r(e)},n.onsuccess=function(){var e=n.result;e&&e.close(),t(e)}})).then((function(e){r.db=e;for(var t=0;t<n.length;t++)E(n[t]._dbInfo)})).catch((function(t){throw(_(e,t)||a.resolve()).catch((function(){})),t}))}))}else n=a.reject("Invalid arguments");return c(n,t),n}};var j="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",P=/^~~local_forage_type~([^~]+)~/,U="__lfsc__:",x=U.length,L="arbf",k="blob",F="si08",D="ui08",M="uic8",B="si16",V="si32",$="ur16",Y="ui32",K="fl32",G="fl64",z=x+L.length,q=Object.prototype.toString;function W(e){var t,r,n,o,i,a=.75*e.length,c=e.length,u=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);var s=new ArrayBuffer(a),f=new Uint8Array(s);for(t=0;t<c;t+=4)r=j.indexOf(e[t]),n=j.indexOf(e[t+1]),o=j.indexOf(e[t+2]),i=j.indexOf(e[t+3]),f[u++]=r<<2|n>>4,f[u++]=(15&n)<<4|o>>2,f[u++]=(3&o)<<6|63&i;return s}function H(e){var t,r=new Uint8Array(e),n="";for(t=0;t<r.length;t+=3)n+=j[r[t]>>2],n+=j[(3&r[t])<<4|r[t+1]>>4],n+=j[(15&r[t+1])<<2|r[t+2]>>6],n+=j[63&r[t+2]];return r.length%3==2?n=n.substring(0,n.length-1)+"=":r.length%3==1&&(n=n.substring(0,n.length-2)+"=="),n}var J={serialize:function(e,t){var r="";if(e&&(r=q.call(e)),e&&("[object ArrayBuffer]"===r||e.buffer&&"[object ArrayBuffer]"===q.call(e.buffer))){var n,o=U;e instanceof ArrayBuffer?(n=e,o+=L):(n=e.buffer,"[object Int8Array]"===r?o+=F:"[object Uint8Array]"===r?o+=D:"[object Uint8ClampedArray]"===r?o+=M:"[object Int16Array]"===r?o+=B:"[object Uint16Array]"===r?o+=$:"[object Int32Array]"===r?o+=V:"[object Uint32Array]"===r?o+=Y:"[object Float32Array]"===r?o+=K:"[object Float64Array]"===r?o+=G:t(new Error("Failed to get type for BinaryArray"))),t(o+H(n))}else if("[object Blob]"===r){var i=new FileReader;i.onload=function(){var r="~~local_forage_type~"+e.type+"~"+H(this.result);t("__lfsc__:blob"+r)},i.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(r){console.error("Couldn't convert value into a JSON string: ",e),t(null,r)}},deserialize:function(e){if(e.substring(0,x)!==U)return JSON.parse(e);var t,r=e.substring(z),n=e.substring(x,z);if(n===k&&P.test(r)){var o=r.match(P);t=o[1],r=r.substring(o[0].length)}var a=W(r);switch(n){case L:return a;case k:return i([a],{type:t});case F:return new Int8Array(a);case D:return new Uint8Array(a);case M:return new Uint8ClampedArray(a);case B:return new Int16Array(a);case $:return new Uint16Array(a);case V:return new Int32Array(a);case Y:return new Uint32Array(a);case K:return new Float32Array(a);case G:return new Float64Array(a);default:throw new Error("Unkown type: "+n)}},stringToBuffer:W,bufferToString:H};function Q(e,t,r,n){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],r,n)}function X(e,t,r,n,o,i){e.executeSql(r,n,o,(function(e,a){a.code===a.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],(function(e,c){c.rows.length?i(e,a):Q(e,t,(function(){e.executeSql(r,n,o,i)}),i)}),i):i(e,a)}),i)}function Z(e,t,r,n){var o=this;e=s(e);var i=new a((function(i,a){o.ready().then((function(){void 0===t&&(t=null);var c=t,u=o._dbInfo;u.serializer.serialize(t,(function(t,s){s?a(s):u.db.transaction((function(r){X(r,u,"INSERT OR REPLACE INTO "+u.storeName+" (key, value) VALUES (?, ?)",[e,t],(function(){i(c)}),(function(e,t){a(t)}))}),(function(t){if(t.code===t.QUOTA_ERR){if(n>0)return void i(Z.apply(o,[e,c,r,n-1]));a(t)}}))}))})).catch(a)}));return c(i,r),i}function ee(e){return new a((function(t,r){e.transaction((function(n){n.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],(function(r,n){for(var o=[],i=0;i<n.rows.length;i++)o.push(n.rows.item(i).name);t({db:e,storeNames:o})}),(function(e,t){r(t)}))}),(function(e){r(e)}))}))}var te={_driver:"webSQLStorage",_initStorage:function(e){var t=this,r={db:null};if(e)for(var n in e)r[n]="string"!=typeof e[n]?e[n].toString():e[n];var o=new a((function(e,n){try{r.db=openDatabase(r.name,String(r.version),r.description,r.size)}catch(e){return n(e)}r.db.transaction((function(o){Q(o,r,(function(){t._dbInfo=r,e()}),(function(e,t){n(t)}))}),n)}));return r.serializer=J,o},_support:"function"==typeof openDatabase,iterate:function(e,t){var r=this,n=new a((function(t,n){r.ready().then((function(){var o=r._dbInfo;o.db.transaction((function(r){X(r,o,"SELECT * FROM "+o.storeName,[],(function(r,n){for(var i=n.rows,a=i.length,c=0;c<a;c++){var u=i.item(c),s=u.value;if(s&&(s=o.serializer.deserialize(s)),void 0!==(s=e(s,u.key,c+1)))return void t(s)}t()}),(function(e,t){n(t)}))}))})).catch(n)}));return c(n,t),n},getItem:function(e,t){var r=this;e=s(e);var n=new a((function(t,n){r.ready().then((function(){var o=r._dbInfo;o.db.transaction((function(r){X(r,o,"SELECT * FROM "+o.storeName+" WHERE key = ? LIMIT 1",[e],(function(e,r){var n=r.rows.length?r.rows.item(0).value:null;n&&(n=o.serializer.deserialize(n)),t(n)}),(function(e,t){n(t)}))}))})).catch(n)}));return c(n,t),n},setItem:function(e,t,r){return Z.apply(this,[e,t,r,1])},removeItem:function(e,t){var r=this;e=s(e);var n=new a((function(t,n){r.ready().then((function(){var o=r._dbInfo;o.db.transaction((function(r){X(r,o,"DELETE FROM "+o.storeName+" WHERE key = ?",[e],(function(){t()}),(function(e,t){n(t)}))}))})).catch(n)}));return c(n,t),n},clear:function(e){var t=this,r=new a((function(e,r){t.ready().then((function(){var n=t._dbInfo;n.db.transaction((function(t){X(t,n,"DELETE FROM "+n.storeName,[],(function(){e()}),(function(e,t){r(t)}))}))})).catch(r)}));return c(r,e),r},length:function(e){var t=this,r=new a((function(e,r){t.ready().then((function(){var n=t._dbInfo;n.db.transaction((function(t){X(t,n,"SELECT COUNT(key) as c FROM "+n.storeName,[],(function(t,r){var n=r.rows.item(0).c;e(n)}),(function(e,t){r(t)}))}))})).catch(r)}));return c(r,e),r},key:function(e,t){var r=this,n=new a((function(t,n){r.ready().then((function(){var o=r._dbInfo;o.db.transaction((function(r){X(r,o,"SELECT key FROM "+o.storeName+" WHERE id = ? LIMIT 1",[e+1],(function(e,r){var n=r.rows.length?r.rows.item(0).key:null;t(n)}),(function(e,t){n(t)}))}))})).catch(n)}));return c(n,t),n},keys:function(e){var t=this,r=new a((function(e,r){t.ready().then((function(){var n=t._dbInfo;n.db.transaction((function(t){X(t,n,"SELECT key FROM "+n.storeName,[],(function(t,r){for(var n=[],o=0;o<r.rows.length;o++)n.push(r.rows.item(o).key);e(n)}),(function(e,t){r(t)}))}))})).catch(r)}));return c(r,e),r},dropInstance:function(e,t){t=f.apply(this,arguments);var r=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName);var n,o=this;return c(n=e.name?new a((function(t){var n;n=e.name===r.name?o._dbInfo.db:openDatabase(e.name,"","",0),e.storeName?t({db:n,storeNames:[e.storeName]}):t(ee(n))})).then((function(e){return new a((function(t,r){e.db.transaction((function(n){function o(e){return new a((function(t,r){n.executeSql("DROP TABLE IF EXISTS "+e,[],(function(){t()}),(function(e,t){r(t)}))}))}for(var i=[],c=0,u=e.storeNames.length;c<u;c++)i.push(o(e.storeNames[c]));a.all(i).then((function(){t()})).catch((function(e){r(e)}))}),(function(e){r(e)}))}))})):a.reject("Invalid arguments"),t),n}};function re(e,t){var r=e.name+"/";return e.storeName!==t.storeName&&(r+=e.storeName+"/"),r}function ne(){return!function(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch(e){return!0}}()||localStorage.length>0}var oe={_driver:"localStorageWrapper",_initStorage:function(e){var t={};if(e)for(var r in e)t[r]=e[r];return t.keyPrefix=re(e,this._defaultConfig),ne()?(this._dbInfo=t,t.serializer=J,a.resolve()):a.reject()},_support:function(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}(),iterate:function(e,t){var r=this,n=r.ready().then((function(){for(var t=r._dbInfo,n=t.keyPrefix,o=n.length,i=localStorage.length,a=1,c=0;c<i;c++){var u=localStorage.key(c);if(0===u.indexOf(n)){var s=localStorage.getItem(u);if(s&&(s=t.serializer.deserialize(s)),void 0!==(s=e(s,u.substring(o),a++)))return s}}}));return c(n,t),n},getItem:function(e,t){var r=this;e=s(e);var n=r.ready().then((function(){var t=r._dbInfo,n=localStorage.getItem(t.keyPrefix+e);return n&&(n=t.serializer.deserialize(n)),n}));return c(n,t),n},setItem:function(e,t,r){var n=this;e=s(e);var o=n.ready().then((function(){void 0===t&&(t=null);var r=t;return new a((function(o,i){var a=n._dbInfo;a.serializer.serialize(t,(function(t,n){if(n)i(n);else try{localStorage.setItem(a.keyPrefix+e,t),o(r)}catch(e){"QuotaExceededError"!==e.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==e.name||i(e),i(e)}}))}))}));return c(o,r),o},removeItem:function(e,t){var r=this;e=s(e);var n=r.ready().then((function(){var t=r._dbInfo;localStorage.removeItem(t.keyPrefix+e)}));return c(n,t),n},clear:function(e){var t=this,r=t.ready().then((function(){for(var e=t._dbInfo.keyPrefix,r=localStorage.length-1;r>=0;r--){var n=localStorage.key(r);0===n.indexOf(e)&&localStorage.removeItem(n)}}));return c(r,e),r},length:function(e){var t=this.keys().then((function(e){return e.length}));return c(t,e),t},key:function(e,t){var r=this,n=r.ready().then((function(){var t,n=r._dbInfo;try{t=localStorage.key(e)}catch(e){t=null}return t&&(t=t.substring(n.keyPrefix.length)),t}));return c(n,t),n},keys:function(e){var t=this,r=t.ready().then((function(){for(var e=t._dbInfo,r=localStorage.length,n=[],o=0;o<r;o++){var i=localStorage.key(o);0===i.indexOf(e.keyPrefix)&&n.push(i.substring(e.keyPrefix.length))}return n}));return c(r,e),r},dropInstance:function(e,t){if(t=f.apply(this,arguments),!(e="function"!=typeof e&&e||{}).name){var r=this.config();e.name=e.name||r.name,e.storeName=e.storeName||r.storeName}var n,o=this;return c(n=e.name?new a((function(t){e.storeName?t(re(e,o._defaultConfig)):t(e.name+"/")})).then((function(e){for(var t=localStorage.length-1;t>=0;t--){var r=localStorage.key(t);0===r.indexOf(e)&&localStorage.removeItem(r)}})):a.reject("Invalid arguments"),t),n}},ie=function(e,t){for(var r=e.length,n=0;n<r;){if((o=e[n])===(i=t)||"number"==typeof o&&"number"==typeof i&&isNaN(o)&&isNaN(i))return!0;n++}var o,i;return!1},ae=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},ce={},ue={},se={INDEXEDDB:A,WEBSQL:te,LOCALSTORAGE:oe},fe=[se.INDEXEDDB._driver,se.WEBSQL._driver,se.LOCALSTORAGE._driver],le=["dropInstance"],de=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(le),ve={description:"",driver:fe.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function he(e,t){e[t]=function(){var r=arguments;return e.ready().then((function(){return e[t].apply(e,r)}))}}function pe(){for(var e=1;e<arguments.length;e++){var t=arguments[e];if(t)for(var r in t)t.hasOwnProperty(r)&&(ae(t[r])?arguments[0][r]=t[r].slice():arguments[0][r]=t[r])}return arguments[0]}var ye=new(function(){function e(t){for(var r in function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),se)if(se.hasOwnProperty(r)){var n=se[r],o=n._driver;this[r]=o,ce[o]||this.defineDriver(n)}this._defaultConfig=pe({},ve),this._config=pe({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch((function(){}))}return e.prototype.config=function(e){if("object"===(void 0===e?"undefined":n(e))){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var t in e){if("storeName"===t&&(e[t]=e[t].replace(/\W/g,"_")),"version"===t&&"number"!=typeof e[t])return new Error("Database version must be a number.");this._config[t]=e[t]}return!("driver"in e)||!e.driver||this.setDriver(this._config.driver)}return"string"==typeof e?this._config[e]:this._config},e.prototype.defineDriver=function(e,t,r){var n=new a((function(t,r){try{var n=e._driver,o=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!e._driver)return void r(o);for(var i=de.concat("_initStorage"),u=0,s=i.length;u<s;u++){var f=i[u];if((!ie(le,f)||e[f])&&"function"!=typeof e[f])return void r(o)}!function(){for(var t=function(e){return function(){var t=new Error("Method "+e+" is not implemented by the current driver"),r=a.reject(t);return c(r,arguments[arguments.length-1]),r}},r=0,n=le.length;r<n;r++){var o=le[r];e[o]||(e[o]=t(o))}}();var l=function(r){ce[n]&&console.info("Redefining LocalForage driver: "+n),ce[n]=e,ue[n]=r,t()};"_support"in e?e._support&&"function"==typeof e._support?e._support().then(l,r):l(!!e._support):l(!0)}catch(e){r(e)}}));return u(n,t,r),n},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(e,t,r){var n=ce[e]?a.resolve(ce[e]):a.reject(new Error("Driver not found."));return u(n,t,r),n},e.prototype.getSerializer=function(e){var t=a.resolve(J);return u(t,e),t},e.prototype.ready=function(e){var t=this,r=t._driverSet.then((function(){return null===t._ready&&(t._ready=t._initDriver()),t._ready}));return u(r,e,e),r},e.prototype.setDriver=function(e,t,r){var n=this;ae(e)||(e=[e]);var o=this._getSupportedDrivers(e);function i(){n._config.driver=n.driver()}function c(e){return n._extend(e),i(),n._ready=n._initStorage(n._config),n._ready}var s=null!==this._driverSet?this._driverSet.catch((function(){return a.resolve()})):a.resolve();return this._driverSet=s.then((function(){var e=o[0];return n._dbInfo=null,n._ready=null,n.getDriver(e).then((function(e){n._driver=e._driver,i(),n._wrapLibraryMethodsWithReady(),n._initDriver=function(e){return function(){var t=0;return function r(){for(;t<e.length;){var o=e[t];return t++,n._dbInfo=null,n._ready=null,n.getDriver(o).then(c).catch(r)}i();var u=new Error("No available storage method found.");return n._driverSet=a.reject(u),n._driverSet}()}}(o)}))})).catch((function(){i();var e=new Error("No available storage method found.");return n._driverSet=a.reject(e),n._driverSet})),u(this._driverSet,t,r),this._driverSet},e.prototype.supports=function(e){return!!ue[e]},e.prototype._extend=function(e){pe(this,e)},e.prototype._getSupportedDrivers=function(e){for(var t=[],r=0,n=e.length;r<n;r++){var o=e[r];this.supports(o)&&t.push(o)}return t},e.prototype._wrapLibraryMethodsWithReady=function(){for(var e=0,t=de.length;e<t;e++)he(this,de[e])},e.prototype.createInstance=function(t){return new e(t)},e}());t.exports=ye},{3:3}]},{},[4])(4)},390:e=>{var t=function(e){"use strict";var t,r=Object.prototype,n=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function s(e,t,r,n){var o=t&&t.prototype instanceof y?t:y,i=Object.create(o.prototype),a=new T(n||[]);return i._invoke=function(e,t,r){var n=l;return function(o,i){if(n===v)throw new Error("Generator is already running");if(n===h){if("throw"===o)throw i;return A()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=I(a,r);if(c){if(c===p)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===l)throw n=h,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=v;var u=f(e,t,r);if("normal"===u.type){if(n=r.done?h:d,u.arg===p)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n=h,r.method="throw",r.arg=u.arg)}}}(e,r,a),i}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var l="suspendedStart",d="suspendedYield",v="executing",h="completed",p={};function y(){}function g(){}function m(){}var b={};b[i]=function(){return this};var E=Object.getPrototypeOf,_=E&&E(E(N([])));_&&_!==r&&n.call(_,i)&&(b=_);var w=m.prototype=y.prototype=Object.create(b);function S(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function R(e,t){function r(o,i,a,c){var u=f(e[o],e,i);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,a,c)}),(function(e){r("throw",e,a,c)})):t.resolve(l).then((function(e){s.value=e,a(s)}),(function(e){return r("throw",e,a,c)}))}c(u.arg)}var o;this._invoke=function(e,n){function i(){return new t((function(t,o){r(e,n,t,o)}))}return o=o?o.then(i,i):i()}}function I(e,r){var n=e.iterator[r.method];if(n===t){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=t,I(e,r),"throw"===r.method))return p;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return p}var o=f(n,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,p;var i=o.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,p):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,p)}function O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function C(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function N(e){if(e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}return{next:A}}function A(){return{value:t,done:!0}}return g.prototype=w.constructor=m,m.constructor=g,g.displayName=u(m,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,u(e,c,"GeneratorFunction")),e.prototype=Object.create(w),e},e.awrap=function(e){return{__await:e}},S(R.prototype),R.prototype[a]=function(){return this},e.AsyncIterator=R,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new R(s(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},S(w),u(w,c,"Generator"),w[i]=function(){return this},w.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=N,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(C),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),s=n.call(a,"finallyLoc");if(u&&s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(e,t){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"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,p):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),p},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),C(r),p}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;C(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:N(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),p}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}},896:function(e,t,r){"use strict";var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},o=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,o=e.length;r<n;r++,o++)e[o]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.AsyncContract=void 0;var i=r(174),a=r(589);t.AsyncContract=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=e.length-1,c=e.slice(0,r),u=e[r];return{enforce:function(e){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];if(t.length<c.length){var s="Expected "+c.length+" arguments but only received "+t.length,f=a.FAILURE.ARGUMENT_INCORRECT(s);throw new i.ValidationError(f)}for(var l=0;l<c.length;l++)c[l].check(t[l]);var d=e.apply(void 0,o([],n(t)));if(!(d instanceof Promise))throw s="Expected function to return a promise, but instead got "+d,f=a.FAILURE.RETURN_INCORRECT(s),new i.ValidationError(f);return d.then(u.check)}}}}},308:function(e,t,r){"use strict";var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},o=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,o=e.length;r<n;r++,o++)e[o]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.Contract=void 0;var i=r(174),a=r(589);t.Contract=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=e.length-1,c=e.slice(0,r),u=e[r];return{enforce:function(e){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];if(t.length<c.length){var s="Expected "+c.length+" arguments but only received "+t.length,f=a.FAILURE.ARGUMENT_INCORRECT(s);throw new i.ValidationError(f)}for(var l=0;l<c.length;l++)c[l].check(t[l]);return u.check(e.apply(void 0,o([],n(t))))}}}}},965:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.checked=t.check=void 0;var n=r(174),o=r(589),i=new WeakMap;function a(e,t,r){var n=i.get(e),o=n&&n.get(t);if(o)return o;for(var a=[],c=0;c<r;c++)a.push(c);return a}t.check=function(e,t,r){var n=i.get(e)||new Map;i.set(e,n);var o=n.get(t)||[];n.set(t,o),o.push(r)},t.checked=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(0===e.length)throw new Error("No runtype provided to `@checked`. Please remove the decorator.");return function(t,r,i){var c=i.value,u=(t.name||t.constructor.name+".prototype")+("string"==typeof r?'["'+r+'"]':"["+String(r)+"]"),s=a(t,r,e.length);if(s.length!==e.length)throw new Error("Number of `@checked` runtypes and @check parameters not matched.");if(s.length>c.length)throw new Error("Number of `@checked` runtypes exceeds actual parameter length.");i.value=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return e.forEach((function(e,r){var i=s[r],a=e.validate(t[i]);if(!a.success){var c=u+", argument #"+i+": "+a.message,f=o.FAILURE.ARGUMENT_INCORRECT(c);throw new n.ValidationError(f)}})),c.apply(this,t)}}}},174:function(e,t){"use strict";var r,n=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.ValidationError=void 0;var o=function(e){function t(r){var n=e.call(this,r.message)||this;return n.name="ValidationError",n.code=r.code,void 0!==r.details&&(n.details=r.details),Object.setPrototypeOf(n,t.prototype),n}return n(t,e),t}(Error);t.ValidationError=o},61:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.InstanceOf=t.Null=t.Undefined=t.Literal=void 0,o(r(350),t),o(r(205),t),o(r(308),t),o(r(896),t),o(r(339),t),o(r(174),t),o(r(615),t),o(r(551),t),o(r(362),t);var i=r(620);Object.defineProperty(t,"Literal",{enumerable:!0,get:function(){return i.Literal}}),Object.defineProperty(t,"Undefined",{enumerable:!0,get:function(){return i.Undefined}}),Object.defineProperty(t,"Null",{enumerable:!0,get:function(){return i.Null}}),o(r(643),t),o(r(422),t),o(r(172),t),o(r(856),t),o(r(59),t),o(r(669),t),o(r(941),t),o(r(489),t),o(r(745),t),o(r(219),t),o(r(617),t),o(r(979),t),o(r(548),t);var a=r(937);Object.defineProperty(t,"InstanceOf",{enumerable:!0,get:function(){return a.InstanceOf}}),o(r(813),t),o(r(277),t),o(r(550),t),o(r(965),t)},339:function(e,t){"use strict";var r=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a};Object.defineProperty(t,"__esModule",{value:!0}),t.match=void 0,t.match=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){var o,i;try{for(var a=r(e),c=a.next();!c.done;c=a.next()){var u=n(c.value,2),s=u[0],f=u[1];if(s.guard(t))return f(t)}}catch(e){o={error:e}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(o)throw o.error}}throw new Error("No alternatives were matched")}}},350:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},205:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Failcode=void 0,t.Failcode={TYPE_INCORRECT:"TYPE_INCORRECT",VALUE_INCORRECT:"VALUE_INCORRECT",KEY_INCORRECT:"KEY_INCORRECT",CONTENT_INCORRECT:"CONTENT_INCORRECT",ARGUMENT_INCORRECT:"ARGUMENT_INCORRECT",RETURN_INCORRECT:"RETURN_INCORRECT",CONSTRAINT_FAILED:"CONSTRAINT_FAILED",PROPERTY_MISSING:"PROPERTY_MISSING",PROPERTY_PRESENT:"PROPERTY_PRESENT",NOTHING_EXPECTED:"NOTHING_EXPECTED"}},705:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.innerValidate=t.create=void 0;var n=r(61),o=r(268),i=r(174),a=r(589);t.create=function(e,t){return t.check=r,t.assert=r,t._innerValidate=function(r,n){return n.has(r,t)?a.SUCCESS(r):e(r,n)},t.validate=function(e){return t._innerValidate(e,(r=new WeakMap,n=function(e,t){if(null!==e&&"object"==typeof e){var n=r.get(e);r.set(e,n?n.set(t,!0):(new WeakMap).set(t,!0))}},{has:function(e,t){var o=r.get(e),i=o&&o.get(t)||!1;return n(e,t),i}}));var r,n},t.guard=function(e){return t.validate(e).success},t.Or=function(e){return n.Union(t,e)},t.And=function(e){return n.Intersect(t,e)},t.optional=function(){return n.Optional(t)},t.nullable=function(){return n.Union(t,n.Null)},t.withConstraint=function(e,r){return n.Constraint(t,e,r)},t.withGuard=function(e,r){return n.Constraint(t,e,r)},t.withBrand=function(e){return n.Brand(e,t)},t.reflect=t,t.toString=function(){return"Runtype<"+o.default(t)+">"},t;function r(e){var r=t.validate(e);if(r.success)return r.value;throw new i.ValidationError(r)}},t.innerValidate=function(e,t,r){return e._innerValidate(t,r)}},268:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(e,t){return function(o){var i=function(t){return e?"("+t+")":t};if(t.has(o))return i("CIRCULAR "+o.tag);t.add(o);try{switch(o.tag){case"unknown":case"never":case"void":case"boolean":case"number":case"bigint":case"string":case"symbol":case"function":return o.tag;case"literal":var a=o.value;return"string"==typeof a?'"'+a+'"':String(a);case"array":return""+n(o)+r(!0,t)(o.element)+"[]";case"dictionary":return"{ [_: "+o.key+"]: "+r(!1,t)(o.value)+" }";case"record":var c=Object.keys(o.fields);return c.length?"{ "+c.map((function(e){return""+n(o)+e+(a=e,c=(i=o).isPartial,u=i.fields,(c||void 0!==a&&"optional"===u[a].tag?"?":"")+": ")+("optional"===o.fields[e].tag?r(!1,t)(o.fields[e].underlying):r(!1,t)(o.fields[e]))+";";var i,a,c,u})).join(" ")+" }":"{}";case"tuple":return"["+o.components.map(r(!1,t)).join(", ")+"]";case"union":return i(""+o.alternatives.map(r(!0,t)).join(" | "));case"intersect":return i(""+o.intersectees.map(r(!0,t)).join(" & "));case"optional":return r(e,t)(o.underlying)+" | undefined";case"constraint":return o.name||r(e,t)(o.underlying);case"instanceof":return o.ctor.name;case"brand":return r(e,t)(o.entity)}}finally{t.delete(o)}throw Error("impossible")}};function n(e){return e.isReadonly?"readonly ":""}t.default=r(!1,new Set)},669:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Array=void 0;var n=r(705),o=r(589);function i(e,t){var r,a={tag:"array",isReadonly:t,element:e};return(r=n.create((function(t,r){if(!Array.isArray(t))return o.FAILURE.TYPE_INCORRECT(a,t);var i=o.enumerableKeysOf(t),c=i.map((function(o){return n.innerValidate(e,t[o],r)})),u=i.reduce((function(e,t){var r=c[t];return r.success||(e[t]=r.details||r.message),e}),[]);return 0!==o.enumerableKeysOf(u).length?o.FAILURE.CONTENT_INCORRECT(a,u):o.SUCCESS(t)}),a)).asReadonly=function(){return i(r.element,!0)},r}t.Array=function(e){return i(e,!1)}},172:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BigInt=void 0;var n=r(705),o=r(589),i={tag:"bigint"};t.BigInt=n.create((function(e){return"bigint"==typeof e?o.SUCCESS(e):o.FAILURE.TYPE_INCORRECT(i,e)}),i)},643:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Boolean=void 0;var n=r(705),o=r(589),i={tag:"boolean"};t.Boolean=n.create((function(e){return"boolean"==typeof e?o.SUCCESS(e):o.FAILURE.TYPE_INCORRECT(i,e)}),i)},550:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Brand=void 0;var n=r(705);t.Brand=function(e,t){var r={tag:"brand",brand:e,entity:t};return n.create((function(e){return t.validate(e)}),r)}},277:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Guard=t.Constraint=void 0;var n=r(705),o=r(589),i=r(615);t.Constraint=function(e,t,r){var i=r&&r.name,a=r&&r.args,c={tag:"constraint",underlying:e,constraint:t,name:i,args:a};return n.create((function(r){var n=e.validate(r);if(!n.success)return n;var i=t(n.value);return"string"==typeof i?o.FAILURE.CONSTRAINT_FAILED(c,i):i?o.SUCCESS(n.value):o.FAILURE.CONSTRAINT_FAILED(c)}),c)},t.Guard=function(e,t){return i.Unknown.withGuard(e,t)}},745:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Dictionary=void 0;var n=r(705),o=r(856),i=r(277),a=r(268),c=r(589),u=i.Constraint(o.String,(function(e){return!isNaN(+e)}),{name:"number"});t.Dictionary=function(e,t){var i=void 0===t||"string"===t?o.String:"number"===t?u:t,s=a.default(i),f={tag:"dictionary",key:s,value:e};return n.create((function(t,o){if(null==t||"object"!=typeof t)return c.FAILURE.TYPE_INCORRECT(f,t);if(Object.getPrototypeOf(t)!==Object.prototype&&(!Array.isArray(t)||"string"===s))return c.FAILURE.TYPE_INCORRECT(f,t);var a=/^(?:NaN|-?\d+(?:\.\d+)?)$/u,u=c.enumerableKeysOf(t),l=u.reduce((function(u,s){var l="string"==typeof s&&a.test(s),d=l?r.g.Number(s):s;return(l?i.guard(d)||i.guard(s):i.guard(d))?u[s]=n.innerValidate(e,t[s],o):u[s]=c.FAILURE.KEY_INCORRECT(f,i.reflect,d),u}),{}),d=u.reduce((function(e,t){var r=l[t];return r.success||(e[t]=r.details||r.message),e}),{});return 0!==c.enumerableKeysOf(d).length?c.FAILURE.CONTENT_INCORRECT(f,d):c.SUCCESS(t)}),f)}},548:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Function=void 0;var n=r(705),o=r(589),i={tag:"function"};t.Function=n.create((function(e){return"function"==typeof e?o.SUCCESS(e):o.FAILURE.TYPE_INCORRECT(i,e)}),i)},937:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InstanceOf=void 0;var n=r(705),o=r(589);t.InstanceOf=function(e){var t={tag:"instanceof",ctor:e};return n.create((function(r){return r instanceof e?o.SUCCESS(r):o.FAILURE.TYPE_INCORRECT(t,r)}),t)}},617:function(e,t,r){"use strict";var n=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0}),t.Intersect=void 0;var o=r(705),i=r(589);t.Intersect=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r={tag:"intersect",intersectees:e};return o.create((function(t,r){var a,c;try{for(var u=n(e),s=u.next();!s.done;s=u.next()){var f=s.value,l=o.innerValidate(f,t,r);if(!l.success)return l}}catch(e){a={error:e}}finally{try{s&&!s.done&&(c=u.return)&&c.call(u)}finally{if(a)throw a.error}}return i.SUCCESS(t)}),r)}},813:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Lazy=void 0;var n=r(705);t.Lazy=function(e){var t,r={get tag(){return o().tag}};function o(){if(!t)for(var n in t=e())"tag"!==n&&(r[n]=t[n]);return t}return n.create((function(e){return o().validate(e)}),r)}},620:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Null=t.Undefined=t.Literal=void 0;var n=r(705),o=r(589);function i(e){return Array.isArray(e)?String(e.map(String)):"bigint"==typeof e?String(e)+"n":String(e)}function a(e){var t={tag:"literal",value:e};return n.create((function(t){return t===e?o.SUCCESS(t):o.FAILURE.VALUE_INCORRECT("literal","`"+i(e)+"`","`"+i(t)+"`")}),t)}t.Literal=a,t.Undefined=a(void 0),t.Null=a(null)},551:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Never=void 0;var n=r(705),o=r(589);t.Never=n.create(o.FAILURE.NOTHING_EXPECTED,{tag:"never"})},422:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Number=void 0;var n=r(705),o=r(589),i={tag:"number"};t.Number=n.create((function(e){return"number"==typeof e?o.SUCCESS(e):o.FAILURE.TYPE_INCORRECT(i,e)}),i)},979:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Optional=void 0;var n=r(705),o=r(589);t.Optional=function(e){var t={tag:"optional",underlying:e};return n.create((function(t){return void 0===t?o.SUCCESS(t):e.validate(t)}),t)}},489:function(e,t,r){"use strict";var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},o=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,o=e.length;r<n;r++,o++)e[o]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.Partial=t.Record=t.InternalRecord=void 0;var i=r(705),a=r(589);function c(e,t,r){var u,s={tag:"record",isPartial:t,isReadonly:r,fields:e};return(u=i.create((function(r,c){if(null==r)return a.FAILURE.TYPE_INCORRECT(s,r);var u=a.enumerableKeysOf(e);if(0!==u.length&&"object"!=typeof r)return a.FAILURE.TYPE_INCORRECT(s,r);var f=o([],n(new Set(o(o([],n(u)),n(a.enumerableKeysOf(r)))))),l=f.reduce((function(n,o){var u=a.hasKey(o,e),s=a.hasKey(o,r);if(u){var f=e[o],l=t||"optional"===f.reflect.tag;if(s){var d=r[o];n[o]=l&&void 0===d?a.SUCCESS(d):i.innerValidate(f,d,c)}else n[o]=l?a.SUCCESS(void 0):a.FAILURE.PROPERTY_MISSING(f.reflect)}else{if(!s)throw new Error("impossible");d=r[o],n[o]=a.SUCCESS(d)}return n}),{}),d=f.reduce((function(e,t){var r=l[t];return r.success||(e[t]=r.details||r.message),e}),{});return 0!==a.enumerableKeysOf(d).length?a.FAILURE.CONTENT_INCORRECT(s,d):a.SUCCESS(r)}),s)).asPartial=function(){return c(u.fields,!0,u.isReadonly)},u.asReadonly=function(){return c(u.fields,u.isPartial,!0)},u.pick=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r={};return e.forEach((function(e){r[e]=u.fields[e]})),c(r,u.isPartial,u.isReadonly)},u.omit=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r={};return a.enumerableKeysOf(u.fields).forEach((function(t){e.includes(t)||(r[t]=u.fields[t])})),c(r,u.isPartial,u.isReadonly)},u}t.InternalRecord=c,t.Record=function(e){return c(e,!1,!1)},t.Partial=function(e){return c(e,!0,!1)}},856:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.String=void 0;var n=r(705),o=r(589),i={tag:"string"};t.String=n.create((function(e){return"string"==typeof e?o.SUCCESS(e):o.FAILURE.TYPE_INCORRECT(i,e)}),i)},59:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Symbol=void 0;var n=r(705),o=r(589),i={tag:"symbol"};t.Symbol=n.create((function(e){return"symbol"==typeof e?o.SUCCESS(e):o.FAILURE.TYPE_INCORRECT(i,e)}),Object.assign((function(e){var t={tag:"symbol",key:e};return n.create((function(n){if("symbol"!=typeof n)return o.FAILURE.TYPE_INCORRECT(t,n);var i=r.g.Symbol.keyFor(n);return i!==e?o.FAILURE.VALUE_INCORRECT("symbol key",a(e),a(i)):o.SUCCESS(n)}),t)}),i));var a=function(e){return void 0===e?"undefined":'"'+e+'"'}},941:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tuple=void 0;var n=r(705),o=r(589);t.Tuple=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r={tag:"tuple",components:e};return n.create((function(t,i){if(!Array.isArray(t))return o.FAILURE.TYPE_INCORRECT(r,t);if(t.length!==e.length)return o.FAILURE.CONSTRAINT_FAILED(r,"Expected length "+e.length+", but was "+t.length);var a=o.enumerableKeysOf(t),c=a.map((function(r){return n.innerValidate(e[r],t[r],i)})),u=a.reduce((function(e,t){var r=c[t];return r.success||(e[t]=r.details||r.message),e}),[]);return 0!==o.enumerableKeysOf(u).length?o.FAILURE.CONTENT_INCORRECT(r,u):o.SUCCESS(t)}),r)}},219:function(e,t,r){"use strict";var n=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0}),t.Union=void 0;var o=r(705),i=r(589);t.Union=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return function(r){for(var n=0;n<e.length;n++)if(e[n].guard(r))return t[n](r)}},a={tag:"union",alternatives:e,match:r};return o.create((function(t,r){var c,u,s,f,l,d,v,h;if("object"!=typeof t||null===t){try{for(var p=n(e),y=p.next();!y.done;y=p.next()){var g=y.value;if(o.innerValidate(g,t,r).success)return i.SUCCESS(t)}}catch(e){c={error:e}}finally{try{y&&!y.done&&(u=p.return)&&u.call(p)}finally{if(c)throw c.error}}return i.FAILURE.TYPE_INCORRECT(a,t)}var m={};try{for(var b=n(e),E=b.next();!E.done;E=b.next())if("record"===(g=E.value).reflect.tag){var _=function(e){var t=g.reflect.fields[e];"literal"===t.tag&&(m[e]?m[e].every((function(e){return e!==t.value}))&&m[e].push(t.value):m[e]=[t.value])};for(var w in g.reflect.fields)_(w)}}catch(e){s={error:e}}finally{try{E&&!E.done&&(f=b.return)&&f.call(b)}finally{if(s)throw s.error}}for(var w in m)if(m[w].length===e.length)try{for(var S=(l=void 0,n(e)),R=S.next();!R.done;R=S.next())if("record"===(g=R.value).reflect.tag){var I=g.reflect.fields[w];if("literal"===I.tag&&i.hasKey(w,t)&&t[w]===I.value)return o.innerValidate(g,t,r)}}catch(e){l={error:e}}finally{try{R&&!R.done&&(d=S.return)&&d.call(S)}finally{if(l)throw l.error}}try{for(var O=n(e),C=O.next();!C.done;C=O.next()){var T=C.value;if(o.innerValidate(T,t,r).success)return i.SUCCESS(t)}}catch(e){v={error:e}}finally{try{C&&!C.done&&(h=O.return)&&h.call(O)}finally{if(v)throw v.error}}return i.FAILURE.TYPE_INCORRECT(a,t)}),a)}},615:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Unknown=void 0;var n=r(705),o=r(589);t.Unknown=n.create((function(e){return o.SUCCESS(e)}),{tag:"unknown"})},362:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Void=void 0;var n=r(615);t.Void=n.Unknown},589:function(e,t,r){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.FAILURE=t.SUCCESS=t.enumerableKeysOf=t.typeOf=t.hasKey=void 0;var o=r(205),i=r(268);t.hasKey=function(e,t){return"object"==typeof t&&null!==t&&e in t},t.typeOf=function(e){return"object"==typeof e?null===e?"null":Array.isArray(e)?"array":"Object"===e.constructor.name?"object":e.constructor.name:typeof e},t.enumerableKeysOf=function(e){return"object"==typeof e&&null!==e?Reflect.ownKeys(e).filter((function(t){var r,n;return null===(n=null===(r=e.propertyIsEnumerable)||void 0===r?void 0:r.call(e,t))||void 0===n||n})):[]},t.SUCCESS=function(e){return{success:!0,value:e}},t.FAILURE=Object.assign((function(e,t,r){return n({success:!1,code:e,message:t},r?{details:r}:{})}),{TYPE_INCORRECT:function(e,r){var n="Expected "+i.default(e)+", but was "+t.typeOf(r);return t.FAILURE(o.Failcode.TYPE_INCORRECT,n)},VALUE_INCORRECT:function(e,r,n){return t.FAILURE(o.Failcode.VALUE_INCORRECT,"Expected "+e+" "+String(r)+", but was "+String(n))},KEY_INCORRECT:function(e,r,n){return t.FAILURE(o.Failcode.KEY_INCORRECT,"Expected "+i.default(e)+" key to be "+i.default(r)+", but was "+t.typeOf(n))},CONTENT_INCORRECT:function(e,r){var n="Expected "+i.default(e)+", but was incompatible";return t.FAILURE(o.Failcode.CONTENT_INCORRECT,n,r)},ARGUMENT_INCORRECT:function(e){return t.FAILURE(o.Failcode.ARGUMENT_INCORRECT,e)},RETURN_INCORRECT:function(e){return t.FAILURE(o.Failcode.RETURN_INCORRECT,e)},CONSTRAINT_FAILED:function(e,r){var n=r?": "+r:"";return t.FAILURE(o.Failcode.CONSTRAINT_FAILED,"Failed constraint check for "+i.default(e)+n)},PROPERTY_MISSING:function(e){var r="Expected "+i.default(e)+", but was missing";return t.FAILURE(o.Failcode.PROPERTY_MISSING,r)},PROPERTY_PRESENT:function(e){var r="Expected nothing, but was "+t.typeOf(e);return t.FAILURE(o.Failcode.PROPERTY_PRESENT,r)},NOTHING_EXPECTED:function(e){var r="Expected nothing, but was "+t.typeOf(e);return t.FAILURE(o.Failcode.NOTHING_EXPECTED,r)}})}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,r),i.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{"use strict";r.r(n),r.d(n,{goToLoginPage:()=>Ee,logout:()=>_e,subscribeToUserAttributes:()=>be,tryActivateSubscriptionAccess:()=>we}),r(390);var e=r(466),t=r(651);let o;const i="undefined"==typeof self?window:self,a="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||void 0!==i.msCrypto&&"function"==typeof i.msCrypto.getRandomValues&&i.msCrypto.getRandomValues.bind(i.msCrypto);if(a){const e=new Uint8Array(16);o=function(){return a(e),e}}else{const e=new Array(16);o=function(){for(let t,r=0;r<16;r+=1)0==(3&r)&&(t=4294967296*Math.random()),e[r]=t>>>((3&r)<<3)&255;return e}}const c=[];for(let e=0;e<256;++e)c[e]=(e+256).toString(16).substr(1);function u(){const e=o();return e[6]=15&e[6]|64,e[8]=63&e[8]|128,function(e,t){let r=0;const n=c;return[n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]]].join("")}(e)}e.config({name:"aid:userdata"});const s=self.location.hostname.replace(/(.*\.)([^.]+\.\w+$)/,"$2");function f(r){return t.set("amedia:visitid",r,{expires:new Date(Date.now()+18e5),domain:s,sameSite:"strict"}),e.setItem("visitid",r).then((()=>r))}function l(){const e=Date.now();return f(`${u()}|${e}`)}function d(){return function(){const r=t.get("amedia:visitid");return r?Promise.resolve(r):e.getItem("visitid")}().then((e=>e||l())).then((e=>{const[t,r]=e.split("|");return!t||r&&Date.now()-18e5>r?l():f(`${t}|${Date.now()}`)})).catch((e=>console.error(e)))}"undefined"!=typeof window&&["mousedown","keydown","mousemove","focus","scroll","resize","seshat-video-active","touchmove","deviceorientation"].forEach((e=>window.addEventListener(e,function(e){let t=!1;return(...r)=>{t||(e.apply(this,r),t=!0,setTimeout((()=>{t=!1}),400))}}(d))));const v=()=>window.location.hostname,h=()=>v().replace(/\.[^.]+\.api\.no/,"");var p=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{u(n.next(e))}catch(e){i(e)}}function c(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,c)}u((n=n.apply(e,t||[])).next())}))};const y=(e,t,r)=>{!function(e,t){const r=new FormData;Object.keys(t).forEach((e=>r.append(e,t[e]))),fetch(e,{method:"POST",body:r,headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"}}).then((e=>{if(!e.ok)throw new Error(`Error, status: ${e.status}, text: ${e.statusText}`)}))}(`//www.aid.no/api/mercury/v1/log/${e}`,Object.assign(Object.assign({},r),{message:t,url:window.location.href,domain:window.location.host}))},g=(e,t)=>y("error",e,t);class m extends Error{}const b={debug:console.debug,info:console.info,warn:console.warn,error:console.error};var E=r(61);const _={},w=(e,t)=>{_[e]||(_[e]=[]),_[e].push(t)},S=e=>{const t=_[e];return t?(delete _[e],t):[]},R=e=>{var t;return(null===(t=_[e])||void 0===t?void 0:t.length)||0},I=()=>{const e="undefined"!=typeof window?window:r.g;return e.amediaUserCache||(e.amediaUserCache={})},O={get:e=>{const t=I()[e];return Promise.resolve(t)},set:(e,t,r)=>(I()[e]={key:e,data:t,expires:r},Promise.resolve()),remove:e=>(delete I()[e],Promise.resolve()),clear:()=>(("undefined"!=typeof window?window:r.g).amediaUserCache={},Promise.resolve())};const C=()=>O,T=e=>C().remove(e),N=(e,t)=>{return r=void 0,n=void 0,i=function*(){const r=yield C().get(e);if(!r)return Promise.resolve();if(Date.now()>r.expires)return T(e),Promise.resolve();try{return t.check(r.data)}catch(t){return t instanceof E.ValidationError?b.error("Failed validating data",{data:r.data,error:t.details}):b.error("Unknown error",t),T(e),Promise.resolve()}},new((o=void 0)||(o=Promise))((function(e,t){function a(e){try{u(i.next(e))}catch(e){t(e)}}function c(e){try{u(i.throw(e))}catch(e){t(e)}}function u(t){var r;t.done?e(t.value):(r=t.value,r instanceof o?r:new o((function(e){e(r)}))).then(a,c)}u((i=i.apply(r,n||[])).next())}));var r,n,o,i},A=(e,t,r)=>C().set(e,t,Date.now()+r);function j(e,t,r){return new Promise(((n,o)=>{w(e,{resolve:n,reject:o}),R(e)>1||N(e,t).then((t=>{t?S(e).forEach((e=>{e.resolve(t)})):r().then((t=>{A(e,t.data,t.ttl),S(e).forEach((e=>{e.resolve(t.data)}))})).catch((()=>{S(e).forEach((e=>{e.reject()}))}))}))}))}const P={},U={},x=(e,t)=>{P[e]=Object.assign(Object.assign({},P[e]),t),(e=>{var t;null===(t=U[e])||void 0===t||t.forEach((t=>t(P[e])))})(e)},L=(e,t)=>{U[e]||(U[e]=[]),U[e].push(t)};var k=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{u(n.next(e))}catch(e){i(e)}}function c(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,c)}u((n=n.apply(e,t||[])).next())}))};const F=(0,E.Record)({user_name:E.String,tracking_key:E.String}),D=e=>({name:e.user_name,trackingKey:e.tracking_key}),M=()=>fetch("/api/pluto/v1/sessions/current").then((e=>e.ok?(x("state",{isLoggedIn:!0}),e.json()):403===e.status?(x("state",{isLoggedIn:!1}),{}):(b.error(`Unknown error (${e.status}: ${e.statusText}) when fetching current session`,{response:e}),Promise.reject()))).then((e=>{try{return{ttl:1e4,data:F.check(e)}}catch(e){throw b.error("Invalid schema",e),e}})),B=e=>k(void 0,void 0,void 0,(function*(){return fetch(`/api/pluto/v1/sessions/current?publication_domain=${e}`,{method:"DELETE"}).then((e=>{if(!e.ok){if(403===e.status)return;throw new Error(`Error, could not perform deleteRequest. Status: ${e.status} Text: ${e.statusText}`)}x("state",{isLoggedIn:!1})}))}));let V;const $=self||window,Y="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||void 0!==$.msCrypto&&"function"==typeof $.msCrypto.getRandomValues&&$.msCrypto.getRandomValues.bind($.msCrypto);if(Y){const e=new Uint8Array(16);V=function(){return Y(e),e}}else{const e=new Array(16);V=function(){for(let t,r=0;r<16;r+=1)0==(3&r)&&(t=4294967296*Math.random()),e[r]=t>>>((3&r)<<3)&255;return e}}const K=[];for(let e=0;e<256;++e)K[e]=(e+256).toString(16).substr(1);function G(e,t){return(...r)=>{const{resolve:n,reject:o,promise:i}=function(){let e,t,r=!1;return{promise:new Promise(((n,o)=>{e=e=>{r||n(e),r=!0},t=e=>{r||o(e),r=!0}})),resolve:e,reject:t}}(),a=function(){const e=V();return e[6]=15&e[6]|64,e[8]=63&e[8]|128,function(e,t){let r=0;const n=K;return[n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]]].join("")}(e)}(),c=new CustomEvent(`amedia-rpc-event:${e}:${t}`,{detail:{eventId:a,args:r}});if(self.dispatchEvent(c),self.amediaNativeBridge){const n=JSON.stringify(r);self.amediaNativeBridge.callNativeMethod(e,t,n,a)}return self.addEventListener(`amedia-rpc-event:${e}:${t}:${a}`,(e=>{e.detail||n();const{error:t,result:r}=e.detail;return t?o(t):n(r)})),i}}class z{constructor({version:e,component:t,methods:r=[]}){this.component=t,this.version=e,this.queue=[],r.forEach((e=>this.addMethod(e))),this.boundLiveHandler=this.liveHandler.bind(this),self.addEventListener(`amedia-rpc-event:${t}:live`,this.boundLiveHandler),setTimeout((()=>self.dispatchEvent(new CustomEvent(`amedia-rpc-event:${t}:ready`))),0)}liveHandler(e){const[t,r]=e.detail.version.split(".").map((e=>parseInt(e,10))),[n,o]=this.version.split(".").map((e=>parseInt(e,10)));if(t!==n)throw new Error(`${this.component} version mismatch. Server version: ${t}. Client version: ${n}`);r<o&&console.warn(`${this.component} server version is on an earlier minor version (${r}) than the client (${o})`);const i=this.queue.slice(0);delete this.queue,i.forEach((e=>e())),self.removeEventListener(`amedia-rpc-event:${this.component}:live`,this.boundLiveHandler)}addMethod(e){if(this[e])throw new Error(`${e} already exists on the RPC interface.`);this[e]=(...t)=>{if(this.queue){let r,n;const o=new Promise(((e,t)=>{r=e,n=t}));return this.queue.push((()=>this[e](...t).then(r).catch(n))),o}return this[e]=G(this.component,e),this[e](...t)}}}let q;const W=(e,t)=>{const r=t.substring(e.length,t.length);return"{"===r.substring(0,1)?JSON.parse(r):"%7B"===r.substring(0,3)?JSON.parse(decodeURIComponent(r)):"undefined"!==r?""===r||"null"===r?null:r:void 0};function H(e){!function(e,t,r=Date.now(),n="/",o=!1){const i=new Date;let a=`${e}=`;t&&""!==t||(r=-1),a+=(e=>e&&""!==e?e instanceof Object?encodeURIComponent(JSON.stringify(e)):"number"==typeof e?e.toString(10):e:"")(t),a+=((e,t)=>t?t instanceof Date?`; expires=${t.toUTCString()}`:(e.setTime(e.getTime()+24*t*60*60*1e3),`; expires=${e.toUTCString()}`):"")(i,r),a+=`; path=${n}`,o&&(a+="; secure"),document.cookie=a,r&&-1!==r&&null===(e=>{const t=`${e}=`,r=document.cookie.split(";");for(let e=r.length-1;e>=0;e-=1){const n=r[e].trim();if(0===n.indexOf(t))return W(t,n)}return null})(e)&&(document.cookie=a.replace(/; expires=[^;]*/,""))}(e)}const J=()=>{return e=void 0,t=void 0,n=function*(){return Promise.all([B(h()),C().clear()]).then((()=>{(q||(q=new z({version:"1.0.0",component:"userdata-session",methods:["userAuthenticated"]}),q)).userAuthenticated(!1),H("VSTOKEN"),H("aid.session"),H("aid_invitation_code"),H("aid-reload-article"),H("VSTOKEN2")})).catch((e=>{b.error("Failure while logging out",e)}))},new((r=void 0)||(r=Promise))((function(o,i){function a(e){try{u(n.next(e))}catch(e){i(e)}}function c(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,c)}u((n=n.apply(e,t||[])).next())}));var e,t,r,n},Q=()=>k(void 0,void 0,void 0,(function*(){return j("getCurrentSession",F,M).then(D)})),X=(0,E.Record)({id:E.Number,domain:E.String}),Z=(0,E.Record)({status:(0,E.Literal)("success"),access:(0,E.Union)((0,E.Literal)("granted"),(0,E.Literal)("denied")),publication:X,access_features:(0,E.Array)(E.String)}),ee=((0,E.Record)({status:(0,E.Literal)("success"),cookie:E.String,access_features:(0,E.Array)(E.String)}),(0,E.Record)({status:(0,E.Literal)("success"),vstoken_cookie:E.String,uuid:E.String,access_features:(0,E.Array)(E.String)}),e=>{try{return(e=>p(void 0,void 0,void 0,(function*(){return fetch(`/api/mercury/v2/access/activate?publication_wwwdomain=${h()}&access_feature=${e}`,{method:"post"}).then((e=>p(void 0,void 0,void 0,(function*(){let t;try{t=yield e.json()}catch(e){g("Body does not contain parsable json",e)}if(!e.ok){if(401===e.status&&"user_deactivated"===(null==t?void 0:t.status))throw new m;return!1}return"success"===(null==t?void 0:t.status)&&"granted"===(null==t?void 0:t.access)}))))})))(e)}catch(e){if(e instanceof m)return J(),Promise.resolve(!1);throw e}});var te=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{u(n.next(e))}catch(e){i(e)}}function c(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,c)}u((n=n.apply(e,t||[])).next())}))};const re=(0,E.Record)({namespaces:(0,E.Partial)({})}),ne=(e,t={ignoreCache:!1})=>te(void 0,void 0,void 0,(function*(){if(!t.ignoreCache){const t=yield N("europa",re);if(t&&t.namespaces[e])return t.namespaces[e]}return(r=`/api/europa/v1/me/${e}`,n="GET",fetch(r,{method:n&&n,body:o&&JSON.stringify(o),headers:{"Content-Type":"application/json",Accept:"application/json"}})).then((t=>t.ok?t.json():(b.error(`Could not get namespace: ${e}, status: ${t.status}, statusText: ${t.statusText}`,t),{}))).then((t=>{const r=re.check(t);return((e,t)=>{te(void 0,void 0,void 0,(function*(){const r=yield N("europa",re),n=r?Object.assign(Object.assign({},r),{namespaces:Object.assign(Object.assign({},r.namespaces),{[e]:t})}):{namespaces:{[e]:t}};return A("europa",n,Date.now()+3e5)}))})(e,r.namespaces[e]),r.namespaces[e]||{}})).catch((t=>(b.error(`Could not get namespace: ${e}. Error:${t}`),{})));var r,n,o}));const oe="privacy_preferences_queue",ie="privacyPreferences",ae=(0,E.Record)({allowResearchUsage:E.Boolean,connectWithSurveys:E.Boolean,personalizedAds:E.Boolean,personalizedContent:E.Boolean}),ce=e=>"true"===e||!0===e,ue=(0,E.Dictionary)(E.Unknown,E.String).And((0,E.Partial)({ad_segments:E.String,ad_segments_user:E.String,age:E.Number,age_user:E.Number,birth_year:E.String,birth_year_user:E.String,gender:E.String,gender_user:E.String,grunnkrets:E.String,grunnkrets_user:E.String,postcode:E.String,postcode_user:E.String,shared_account:E.Boolean,shared_account_user:E.Boolean,user_grouping_number:E.String,user_grouping_number_user:E.String})),se=e=>({extraData:e}),fe={name:Q,trackingKey:Q,access:()=>{return e=h(),t=["newspaper"],j("checkForAccess",Z,(()=>fetch(`/api/jupiter/v1/check_access_for_paper/${e}/?require=any&access_features=${t.join(",")}`).then((e=>{if(!e.ok)throw new Error(`Request not ok (${e.status}: ${e.statusText}).`);return e.json()})).then((e=>{try{return{ttl:1e4,data:Z.check(e)}}catch(e){throw b.error("Invalid schema",e),e}})))).then((e=>({access:e.access_features})));var e,t},extraData:()=>function(){let e=t.get("amedia:fpbid");return e||(e=u(),t.set("amedia:fpbid",e,{expires:3650,domain:s,sameSite:"strict"})),Promise.resolve(e)}().then((e=>{var t;return((e,t,r)=>j("getNebulaInfo",ue,(()=>((e,t,r)=>{const n=new URL("https://services.gcloud.api.no/api/nebula/v1/info");return n.searchParams.set("domain",e),n.searchParams.set("browser_id",t),r&&n.searchParams.set("user_key",r),fetch(n.toString()).then((e=>e.json())).then((e=>{try{return{ttl:18e6,data:ue.check(e)}}catch(e){throw b.error("Invalid schema",e),e}}))})(e,t,r))).then(se))(window.location.hostname,e,null===(t=P["userAttributes"])||void 0===t?void 0:t.trackingKey)})),privacyPreferences:()=>{return e=void 0,t=void 0,n=function*(){return new Promise(((e,t)=>{w(oe,{resolve:e,reject:t}),R(oe)>1||N(ie,ae).then((e=>{if(e)return void S(oe).forEach((t=>{t.resolve({privacyPreferences:e})}));const t="privacy_preferences";ne(t).then((e=>{const t={allowResearchUsage:ce(e.allow_research_usage),connectWithSurveys:ce(e.connect_with_surveys),personalizedAds:ce(e.personalized_ads),personalizedContent:ce(e.personalized_content)};A(ie,t,3e5),S(oe).forEach((e=>{e.resolve({privacyPreferences:t})}))})).catch((e=>{b.error(`Could not fetch data for namespace: ${t}`,e),S(oe).forEach((e=>{e.reject()}))}))}))}))},new((r=void 0)||(r=Promise))((function(o,i){function a(e){try{u(n.next(e))}catch(e){i(e)}}function c(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,c)}u((n=n.apply(e,t||[])).next())}));var e,t,r,n}};let le;var de;"undefined"!=typeof window&&(de=window,le=de);const ve=(e,t)=>{le?le.addEventListener(e,(e=>{e.stopImmediatePropagation(),t.apply(window,[e])})):b.error("No root element to bind event to!")},he=(e,t)=>{le?le.addEventListener(e,(e=>{t.apply(window,[e])})):b.error("No root element to bind event to!")},pe=e=>{le?le.dispatchEvent(e):b.error("No root element to dispatch event on!")};var ye,ge;!function(e){e.REQUEST_USER_ATTRIBUTES="amedia-user.request-user-attributes",e.ON_ATTRIBUTES_UPDATED="amedia-user.on-user-attributes-updated",e.ON_STATE_UPDATED="amedia-user.on-state-updated"}(ye||(ye={})),L("userAttributes",(e=>{pe(new CustomEvent(ye.ON_ATTRIBUTES_UPDATED,{detail:e}))})),L("state",(e=>{pe(new CustomEvent(ye.ON_STATE_UPDATED,{detail:e}))})),ve(ye.REQUEST_USER_ATTRIBUTES,(e=>{(e=>{const t=[];for(e.forEach((e=>{const r=fe[e];r?t.includes(r)||t.push(r):b.warn("Unknown attribute was requested")}));t.length>0;){const e=t.pop();e&&e().then((e=>x("userAttributes",e))).catch((t=>{b.error("Call rejected",e,t)}))}})(e.detail)})),function(e){e.REQUEST_ACTIVATION="amedia-user.activation.request-activation",e.ON_ACTIVATION_COMPLETE="amedia-user.activation.on-activation-complete"}(ge||(ge={})),ve(ge.REQUEST_ACTIVATION,(e=>{ee(e.detail.accessFeature).then((e=>{pe(new CustomEvent(ge.ON_ACTIVATION_COMPLETE,{detail:{hasAccess:e}}))}))}));const me=(e,t)=>{if(e===t)return!0;if("object"!=typeof e||"object"!=typeof t||null===e||null===t)return!1;const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(const o of r){if(!n.includes(o))return!1;if("function"==typeof e[o]||"function"==typeof t[o]){if(e[o].toString()!==t[o].toString())return!1}else if(!me(e[o],t[o]))return!1}return!0},be=(e,t,r)=>{if(!e||0===e.length)throw new Error("You must subscribe to at least one attribute");let n;he(ye.ON_ATTRIBUTES_UPDATED,(r=>{const o=r.detail,i=e.reduce(((e,t)=>(void 0!==o[t]&&(e[t]=o[t]),e)),{});me(n,i)||(t(i),n=i)})),r&&he(ye.ON_STATE_UPDATED,(e=>{r(e.detail)})),pe(new CustomEvent(ye.REQUEST_USER_ATTRIBUTES,{detail:e}))},Ee=e=>(e=>{const t=(()=>{const e=/^bed-([^.]+)\.api\.no$/.exec(v()),t=/\.([^.]+)\.api\.no/.exec(v());return e?e[1]:t?t[1]:null})(),r=new URL(`https://aid.no${t&&`.${t}.api.no`}/aid/logg_inn/`);r.searchParams.set("requestedUrl",e||window.location.href),window.location.href=r.href})(e||window.location.href),_e=()=>J(),we=e=>new Promise((t=>{he(ge.ON_ACTIVATION_COMPLETE,(e=>t(e.detail))),pe(new CustomEvent(ge.REQUEST_ACTIVATION,{detail:{accessFeature:e}}))}))})(),n})()}));
|
|
1
|
+
import { AuthorizationEvents } from './lib/authorization';
|
|
2
|
+
import { AuthenticationEvents } from './lib/authentication';
|
|
3
|
+
export const AmediaUserEvents = {
|
|
4
|
+
authentication: AuthenticationEvents,
|
|
5
|
+
authorization: AuthorizationEvents,
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLG1CQUFtQixFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDMUQsT0FBTyxFQUFFLG9CQUFvQixFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFFNUQsTUFBTSxDQUFDLE1BQU0sZ0JBQWdCLEdBQUc7SUFDOUIsY0FBYyxFQUFFLG9CQUFvQjtJQUNwQyxhQUFhLEVBQUUsbUJBQW1CO0NBQ25DLENBQUMifQ==
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare enum AuthenticationEvents {
|
|
2
|
+
REQUEST_LOGIN = "amedia_user.authentication.request_login",
|
|
3
|
+
REQUEST_LOGOUT = "amedia_user.authentication.request_logout",
|
|
4
|
+
REQUEST_AUTH_STATE = "amedia_user.authentication.request_auth_state",
|
|
5
|
+
ON_AUTH_STATE_UPDATED = "amedia_user.authentication.on_auth_state_updated"
|
|
6
|
+
}
|
|
7
|
+
declare global {
|
|
8
|
+
interface WindowEventMap {
|
|
9
|
+
[AuthenticationEvents.REQUEST_LOGIN]: CustomEvent<{
|
|
10
|
+
requestedUrl?: string;
|
|
11
|
+
}>;
|
|
12
|
+
[AuthenticationEvents.REQUEST_LOGOUT]: CustomEvent<void>;
|
|
13
|
+
[AuthenticationEvents.ON_AUTH_STATE_UPDATED]: CustomEvent<{
|
|
14
|
+
isLoggedIn: boolean;
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import global from './cache/global';
|
|
11
|
+
import cache from '../services/cache';
|
|
12
|
+
import { getCurrentSession, SessionSchema } from '../services/pluto';
|
|
13
|
+
const EXPIRES_OFFSET = 10000; // 10 seconds
|
|
14
|
+
export var AuthenticationEvents;
|
|
15
|
+
(function (AuthenticationEvents) {
|
|
16
|
+
AuthenticationEvents["REQUEST_LOGIN"] = "amedia_user.authentication.request_login";
|
|
17
|
+
AuthenticationEvents["REQUEST_LOGOUT"] = "amedia_user.authentication.request_logout";
|
|
18
|
+
AuthenticationEvents["REQUEST_AUTH_STATE"] = "amedia_user.authentication.request_auth_state";
|
|
19
|
+
AuthenticationEvents["ON_AUTH_STATE_UPDATED"] = "amedia_user.authentication.on_auth_state_updated";
|
|
20
|
+
})(AuthenticationEvents || (AuthenticationEvents = {}));
|
|
21
|
+
const login = (requestedUrl) => {
|
|
22
|
+
// TODO Need to get environment smarts from incentive embed
|
|
23
|
+
window.location.href = `https://aid.no/logg_inn/?requestedUrl=${requestedUrl || window.location.href}`;
|
|
24
|
+
};
|
|
25
|
+
const logout = () => {
|
|
26
|
+
// TODO Perform logout
|
|
27
|
+
};
|
|
28
|
+
let isFetchingSession = false;
|
|
29
|
+
const IS_LOGGED_IN_CACHE_KEY = 'is_logged_in';
|
|
30
|
+
const getSession = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
+
if (isFetchingSession) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
isFetchingSession = true;
|
|
35
|
+
// Try the cache first
|
|
36
|
+
const cacheResponse = yield cache.get(IS_LOGGED_IN_CACHE_KEY, SessionSchema);
|
|
37
|
+
if (cacheResponse) {
|
|
38
|
+
isFetchingSession = false;
|
|
39
|
+
return cacheResponse;
|
|
40
|
+
}
|
|
41
|
+
// Actually perform a request against backend for the session
|
|
42
|
+
const session = yield getCurrentSession();
|
|
43
|
+
cache.set(IS_LOGGED_IN_CACHE_KEY, session, Date.now() + EXPIRES_OFFSET);
|
|
44
|
+
isFetchingSession = false;
|
|
45
|
+
return session;
|
|
46
|
+
});
|
|
47
|
+
(window || global).addEventListener(AuthenticationEvents.REQUEST_LOGIN, (evt) => {
|
|
48
|
+
if (!window) {
|
|
49
|
+
throw new Error('Cannot perform login in node-context yet!');
|
|
50
|
+
}
|
|
51
|
+
login(evt.detail.requestedUrl || window.location.href);
|
|
52
|
+
});
|
|
53
|
+
(window || global).addEventListener(AuthenticationEvents.REQUEST_LOGOUT, () => {
|
|
54
|
+
if (!window) {
|
|
55
|
+
throw new Error('Cannot perform login in node-context yet!');
|
|
56
|
+
}
|
|
57
|
+
logout();
|
|
58
|
+
});
|
|
59
|
+
(window || global).addEventListener(AuthenticationEvents.REQUEST_AUTH_STATE, () => {
|
|
60
|
+
if (!window) {
|
|
61
|
+
throw new Error('Cannot perform auth-state in node-context yet!');
|
|
62
|
+
}
|
|
63
|
+
getSession().then((session) => {
|
|
64
|
+
// Supports not getting a response. We're probably working on it already and will emit
|
|
65
|
+
// events on window / global when complete.
|
|
66
|
+
if (!session) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
(window || global).dispatchEvent(new CustomEvent(AuthenticationEvents.ON_AUTH_STATE_UPDATED, {
|
|
70
|
+
detail: session,
|
|
71
|
+
}));
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXV0aGVudGljYXRpb24uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbGliL2F1dGhlbnRpY2F0aW9uLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7OztBQUFBLE9BQU8sTUFBTSxNQUFNLGdCQUFnQixDQUFDO0FBQ3BDLE9BQU8sS0FBSyxNQUFNLG1CQUFtQixDQUFDO0FBQ3RDLE9BQU8sRUFBRSxpQkFBaUIsRUFBVyxhQUFhLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQztBQUU5RSxNQUFNLGNBQWMsR0FBRyxLQUFLLENBQUMsQ0FBQyxhQUFhO0FBRTNDLE1BQU0sQ0FBTixJQUFZLG9CQUtYO0FBTEQsV0FBWSxvQkFBb0I7SUFDOUIsa0ZBQTBELENBQUE7SUFDMUQsb0ZBQTRELENBQUE7SUFDNUQsNEZBQW9FLENBQUE7SUFDcEUsa0dBQTBFLENBQUE7QUFDNUUsQ0FBQyxFQUxXLG9CQUFvQixLQUFwQixvQkFBb0IsUUFLL0I7QUFjRCxNQUFNLEtBQUssR0FBRyxDQUFDLFlBQW9CLEVBQUUsRUFBRTtJQUNyQywyREFBMkQ7SUFDM0QsTUFBTSxDQUFDLFFBQVEsQ0FBQyxJQUFJLEdBQUcseUNBQ3JCLFlBQVksSUFBSSxNQUFNLENBQUMsUUFBUSxDQUFDLElBQ2xDLEVBQUUsQ0FBQztBQUNMLENBQUMsQ0FBQztBQUVGLE1BQU0sTUFBTSxHQUFHLEdBQUcsRUFBRTtJQUNsQixzQkFBc0I7QUFDeEIsQ0FBQyxDQUFDO0FBRUYsSUFBSSxpQkFBaUIsR0FBRyxLQUFLLENBQUM7QUFDOUIsTUFBTSxzQkFBc0IsR0FBRyxjQUFjLENBQUM7QUFDOUMsTUFBTSxVQUFVLEdBQUcsR0FBa0MsRUFBRTtJQUNyRCxJQUFJLGlCQUFpQixFQUFFO1FBQ3JCLE9BQU8sSUFBSSxDQUFDO0tBQ2I7SUFDRCxpQkFBaUIsR0FBRyxJQUFJLENBQUM7SUFFekIsc0JBQXNCO0lBQ3RCLE1BQU0sYUFBYSxHQUFHLE1BQU0sS0FBSyxDQUFDLEdBQUcsQ0FBQyxzQkFBc0IsRUFBRSxhQUFhLENBQUMsQ0FBQztJQUM3RSxJQUFJLGFBQWEsRUFBRTtRQUNqQixpQkFBaUIsR0FBRyxLQUFLLENBQUM7UUFDMUIsT0FBTyxhQUFhLENBQUM7S0FDdEI7SUFFRCw2REFBNkQ7SUFDN0QsTUFBTSxPQUFPLEdBQUcsTUFBTSxpQkFBaUIsRUFBRSxDQUFDO0lBQzFDLEtBQUssQ0FBQyxHQUFHLENBQUMsc0JBQXNCLEVBQUUsT0FBTyxFQUFFLElBQUksQ0FBQyxHQUFHLEVBQUUsR0FBRyxjQUFjLENBQUMsQ0FBQztJQUN4RSxpQkFBaUIsR0FBRyxLQUFLLENBQUM7SUFDMUIsT0FBTyxPQUFPLENBQUM7QUFDakIsQ0FBQyxDQUFBLENBQUM7QUFFRixDQUFDLE1BQU0sSUFBSSxNQUFNLENBQUMsQ0FBQyxnQkFBZ0IsQ0FDakMsb0JBQW9CLENBQUMsYUFBYSxFQUNsQyxDQUFDLEdBQUcsRUFBRSxFQUFFO0lBQ04sSUFBSSxDQUFDLE1BQU0sRUFBRTtRQUNYLE1BQU0sSUFBSSxLQUFLLENBQUMsMkNBQTJDLENBQUMsQ0FBQztLQUM5RDtJQUNELEtBQUssQ0FBQyxHQUFHLENBQUMsTUFBTSxDQUFDLFlBQVksSUFBSSxNQUFNLENBQUMsUUFBUSxDQUFDLElBQUksQ0FBQyxDQUFDO0FBQ3pELENBQUMsQ0FDRixDQUFDO0FBRUYsQ0FBQyxNQUFNLElBQUksTUFBTSxDQUFDLENBQUMsZ0JBQWdCLENBQUMsb0JBQW9CLENBQUMsY0FBYyxFQUFFLEdBQUcsRUFBRTtJQUM1RSxJQUFJLENBQUMsTUFBTSxFQUFFO1FBQ1gsTUFBTSxJQUFJLEtBQUssQ0FBQywyQ0FBMkMsQ0FBQyxDQUFDO0tBQzlEO0lBQ0QsTUFBTSxFQUFFLENBQUM7QUFDWCxDQUFDLENBQUMsQ0FBQztBQUVILENBQUMsTUFBTSxJQUFJLE1BQU0sQ0FBQyxDQUFDLGdCQUFnQixDQUNqQyxvQkFBb0IsQ0FBQyxrQkFBa0IsRUFDdkMsR0FBRyxFQUFFO0lBQ0gsSUFBSSxDQUFDLE1BQU0sRUFBRTtRQUNYLE1BQU0sSUFBSSxLQUFLLENBQUMsZ0RBQWdELENBQUMsQ0FBQztLQUNuRTtJQUNELFVBQVUsRUFBRSxDQUFDLElBQUksQ0FBQyxDQUFDLE9BQU8sRUFBRSxFQUFFO1FBQzVCLHNGQUFzRjtRQUN0RiwyQ0FBMkM7UUFDM0MsSUFBSSxDQUFDLE9BQU8sRUFBRTtZQUNaLE9BQU87U0FDUjtRQUNELENBQUMsTUFBTSxJQUFJLE1BQU0sQ0FBQyxDQUFDLGFBQWEsQ0FDOUIsSUFBSSxXQUFXLENBQUMsb0JBQW9CLENBQUMscUJBQXFCLEVBQUU7WUFDMUQsTUFBTSxFQUFFLE9BQU87U0FDaEIsQ0FBQyxDQUNILENBQUM7SUFDSixDQUFDLENBQUMsQ0FBQztBQUNMLENBQUMsQ0FDRixDQUFDIn0=
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AccessFeatures, CheckAccessForPaper } from '../services/jupiter';
|
|
2
|
+
export declare enum AuthorizationEvents {
|
|
3
|
+
REQUEST_PUBLICATION_ACCESS_STATE_CHECK = "amedia_user.authorization.request_publication_access_state_check",
|
|
4
|
+
ON_PUBLICATION_ACCESS_STATE_UPDATED = "amedia_user.authorization.on_publication_access_state_updated"
|
|
5
|
+
}
|
|
6
|
+
declare global {
|
|
7
|
+
interface WindowEventMap {
|
|
8
|
+
[AuthorizationEvents.REQUEST_PUBLICATION_ACCESS_STATE_CHECK]: CustomEvent<{
|
|
9
|
+
publicationDomain: string;
|
|
10
|
+
accessFeatures: AccessFeatures;
|
|
11
|
+
}>;
|
|
12
|
+
[AuthorizationEvents.ON_PUBLICATION_ACCESS_STATE_UPDATED]: CustomEvent<CheckAccessForPaper>;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { CheckAccessForPaperSchema, checkForAccess, } from '../services/jupiter';
|
|
11
|
+
import cache from '../services/cache';
|
|
12
|
+
const EXPIRES_OFFSET = 10000; // 10 seconds
|
|
13
|
+
const CHECK_FOR_ACCESS_CACHE_KEY = 'check_for_access_to_publication';
|
|
14
|
+
let isCheckingForAccess = false;
|
|
15
|
+
export var AuthorizationEvents;
|
|
16
|
+
(function (AuthorizationEvents) {
|
|
17
|
+
AuthorizationEvents["REQUEST_PUBLICATION_ACCESS_STATE_CHECK"] = "amedia_user.authorization.request_publication_access_state_check";
|
|
18
|
+
AuthorizationEvents["ON_PUBLICATION_ACCESS_STATE_UPDATED"] = "amedia_user.authorization.on_publication_access_state_updated";
|
|
19
|
+
})(AuthorizationEvents || (AuthorizationEvents = {}));
|
|
20
|
+
const checkForAccessToPublication = (publicationDomain, accessFeatures) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
+
if (isCheckingForAccess) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
isCheckingForAccess = true;
|
|
25
|
+
// Try the cache first
|
|
26
|
+
const cacheResponse = yield cache.get(CHECK_FOR_ACCESS_CACHE_KEY, CheckAccessForPaperSchema);
|
|
27
|
+
if (cacheResponse) {
|
|
28
|
+
isCheckingForAccess = false;
|
|
29
|
+
return cacheResponse;
|
|
30
|
+
}
|
|
31
|
+
// Actually perform a request against backend for the accessState
|
|
32
|
+
const accessState = yield checkForAccess(publicationDomain, accessFeatures);
|
|
33
|
+
cache.set(CHECK_FOR_ACCESS_CACHE_KEY, accessState, Date.now() + EXPIRES_OFFSET);
|
|
34
|
+
isCheckingForAccess = false;
|
|
35
|
+
return accessState;
|
|
36
|
+
});
|
|
37
|
+
(window || global).addEventListener(AuthorizationEvents.REQUEST_PUBLICATION_ACCESS_STATE_CHECK, (evt) => {
|
|
38
|
+
// Since this lib might me loaded multiple times, we need to prevent all other processing of this event.
|
|
39
|
+
evt.stopImmediatePropagation();
|
|
40
|
+
checkForAccessToPublication(evt.detail.publicationDomain, evt.detail.accessFeatures).then((accessState) => {
|
|
41
|
+
// Supports not getting a response. We're probably working on it already and will emit
|
|
42
|
+
// events on window / global when complete.
|
|
43
|
+
if (!accessState) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
(window || global).dispatchEvent(new CustomEvent(AuthorizationEvents.ON_PUBLICATION_ACCESS_STATE_UPDATED, {
|
|
47
|
+
detail: accessState,
|
|
48
|
+
}));
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXV0aG9yaXphdGlvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9saWIvYXV0aG9yaXphdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7QUFBQSxPQUFPLEVBR0wseUJBQXlCLEVBQ3pCLGNBQWMsR0FDZixNQUFNLHFCQUFxQixDQUFDO0FBQzdCLE9BQU8sS0FBSyxNQUFNLG1CQUFtQixDQUFDO0FBRXRDLE1BQU0sY0FBYyxHQUFHLEtBQUssQ0FBQyxDQUFDLGFBQWE7QUFDM0MsTUFBTSwwQkFBMEIsR0FBRyxpQ0FBaUMsQ0FBQztBQUNyRSxJQUFJLG1CQUFtQixHQUFZLEtBQUssQ0FBQztBQUV6QyxNQUFNLENBQU4sSUFBWSxtQkFHWDtBQUhELFdBQVksbUJBQW1CO0lBQzdCLGtJQUEyRyxDQUFBO0lBQzNHLDRIQUFxRyxDQUFBO0FBQ3ZHLENBQUMsRUFIVyxtQkFBbUIsS0FBbkIsbUJBQW1CLFFBRzlCO0FBWUQsTUFBTSwyQkFBMkIsR0FBRyxDQUNsQyxpQkFBeUIsRUFDekIsY0FBOEIsRUFDTyxFQUFFO0lBQ3ZDLElBQUksbUJBQW1CLEVBQUU7UUFDdkIsT0FBTyxJQUFJLENBQUM7S0FDYjtJQUNELG1CQUFtQixHQUFHLElBQUksQ0FBQztJQUUzQixzQkFBc0I7SUFDdEIsTUFBTSxhQUFhLEdBQUcsTUFBTSxLQUFLLENBQUMsR0FBRyxDQUNuQywwQkFBMEIsRUFDMUIseUJBQXlCLENBQzFCLENBQUM7SUFDRixJQUFJLGFBQWEsRUFBRTtRQUNqQixtQkFBbUIsR0FBRyxLQUFLLENBQUM7UUFDNUIsT0FBTyxhQUFhLENBQUM7S0FDdEI7SUFFRCxpRUFBaUU7SUFDakUsTUFBTSxXQUFXLEdBQUcsTUFBTSxjQUFjLENBQUMsaUJBQWlCLEVBQUUsY0FBYyxDQUFDLENBQUM7SUFDNUUsS0FBSyxDQUFDLEdBQUcsQ0FDUCwwQkFBMEIsRUFDMUIsV0FBVyxFQUNYLElBQUksQ0FBQyxHQUFHLEVBQUUsR0FBRyxjQUFjLENBQzVCLENBQUM7SUFFRixtQkFBbUIsR0FBRyxLQUFLLENBQUM7SUFFNUIsT0FBTyxXQUFXLENBQUM7QUFDckIsQ0FBQyxDQUFBLENBQUM7QUFFRixDQUFDLE1BQU0sSUFBSSxNQUFNLENBQUMsQ0FBQyxnQkFBZ0IsQ0FDakMsbUJBQW1CLENBQUMsc0NBQXNDLEVBQzFELENBQUMsR0FBRyxFQUFFLEVBQUU7SUFDTix3R0FBd0c7SUFDeEcsR0FBRyxDQUFDLHdCQUF3QixFQUFFLENBQUM7SUFDL0IsMkJBQTJCLENBQ3pCLEdBQUcsQ0FBQyxNQUFNLENBQUMsaUJBQWlCLEVBQzVCLEdBQUcsQ0FBQyxNQUFNLENBQUMsY0FBYyxDQUMxQixDQUFDLElBQUksQ0FBQyxDQUFDLFdBQVcsRUFBRSxFQUFFO1FBQ3JCLHNGQUFzRjtRQUN0RiwyQ0FBMkM7UUFDM0MsSUFBSSxDQUFDLFdBQVcsRUFBRTtZQUNoQixPQUFPO1NBQ1I7UUFDRCxDQUFDLE1BQU0sSUFBSSxNQUFNLENBQUMsQ0FBQyxhQUFhLENBQzlCLElBQUksV0FBVyxDQUNiLG1CQUFtQixDQUFDLG1DQUFtQyxFQUN2RDtZQUNFLE1BQU0sRUFBRSxXQUFXO1NBQ3BCLENBQ0YsQ0FDRixDQUFDO0lBQ0osQ0FBQyxDQUFDLENBQUM7QUFDTCxDQUFDLENBQ0YsQ0FBQyJ9
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const get: (key: string) => Promise<
|
|
1
|
+
import { Engine } from './types';
|
|
2
|
+
export declare const get: (key: string) => Promise<unknown>;
|
|
3
3
|
export declare const set: (key: string, data: unknown, expires: number) => Promise<void>;
|
|
4
4
|
export declare const remove: (key: string) => Promise<void>;
|
|
5
|
-
export declare const clear: () => Promise<void>;
|
|
6
5
|
declare const _default: Engine;
|
|
7
6
|
export default _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Dexie from 'dexie';
|
|
2
|
+
const db = new Dexie('amedia-user-cache');
|
|
3
|
+
db.version(1).stores({
|
|
4
|
+
cache: 'key,data,expires',
|
|
5
|
+
});
|
|
6
|
+
const cache = db.table('cache');
|
|
7
|
+
export const get = (key) => cache.get(key);
|
|
8
|
+
export const set = (key, data, expires) => cache.add({ key, data, expires }).then(() => {
|
|
9
|
+
// Void return as per contract. Should do some error logging first I guess
|
|
10
|
+
});
|
|
11
|
+
export const remove = (key) => cache.delete(key);
|
|
12
|
+
export default { get, set, remove };
|
|
13
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvbGliL2NhY2hlL2RiLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxNQUFNLE9BQU8sQ0FBQztBQUcxQixNQUFNLEVBQUUsR0FBRyxJQUFJLEtBQUssQ0FBQyxtQkFBbUIsQ0FBQyxDQUFDO0FBQzFDLEVBQUUsQ0FBQyxPQUFPLENBQUMsQ0FBQyxDQUFDLENBQUMsTUFBTSxDQUFDO0lBQ25CLEtBQUssRUFBRSxrQkFBa0I7Q0FDMUIsQ0FBQyxDQUFDO0FBQ0gsTUFBTSxLQUFLLEdBQUcsRUFBRSxDQUFDLEtBQUssQ0FBQyxPQUFPLENBQUMsQ0FBQztBQUVoQyxNQUFNLENBQUMsTUFBTSxHQUFHLEdBQUcsQ0FBQyxHQUFXLEVBQW9CLEVBQUUsQ0FBQyxLQUFLLENBQUMsR0FBRyxDQUFDLEdBQUcsQ0FBQyxDQUFDO0FBQ3JFLE1BQU0sQ0FBQyxNQUFNLEdBQUcsR0FBRyxDQUNqQixHQUFXLEVBQ1gsSUFBYSxFQUNiLE9BQWUsRUFDQSxFQUFFLENBQ2pCLEtBQUssQ0FBQyxHQUFHLENBQUMsRUFBRSxHQUFHLEVBQUUsSUFBSSxFQUFFLE9BQU8sRUFBRSxDQUFDLENBQUMsSUFBSSxDQUFDLEdBQUcsRUFBRTtJQUMxQywwRUFBMEU7QUFDNUUsQ0FBQyxDQUFDLENBQUM7QUFDTCxNQUFNLENBQUMsTUFBTSxNQUFNLEdBQUcsQ0FBQyxHQUFXLEVBQWlCLEVBQUUsQ0FBQyxLQUFLLENBQUMsTUFBTSxDQUFDLEdBQUcsQ0FBQyxDQUFDO0FBRXhFLGVBQWUsRUFBRSxHQUFHLEVBQUUsR0FBRyxFQUFFLE1BQU0sRUFBWSxDQUFDIn0=
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const get: (key: string) => Promise<unknown>;
|
|
2
|
+
export declare const set: (key: string, data: unknown, expires: number) => Promise<void>;
|
|
3
|
+
export declare const remove: (key: string) => Promise<void>;
|
|
4
|
+
declare const _default: {
|
|
5
|
+
get: (key: string) => Promise<unknown>;
|
|
6
|
+
set: (key: string, data: unknown, expires: number) => Promise<void>;
|
|
7
|
+
remove: (key: string) => Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// eslint-disable-next-line no-multi-assign
|
|
2
|
+
const cache = ((window || global)['amedia-user-cache'] = {});
|
|
3
|
+
export const get = (key) => {
|
|
4
|
+
const data = cache[key];
|
|
5
|
+
return Promise.resolve(data);
|
|
6
|
+
};
|
|
7
|
+
export const set = (key, data, expires) => {
|
|
8
|
+
cache[key] = { key, data, expires };
|
|
9
|
+
return Promise.resolve();
|
|
10
|
+
};
|
|
11
|
+
export const remove = (key) => {
|
|
12
|
+
delete cache[key];
|
|
13
|
+
return Promise.resolve();
|
|
14
|
+
};
|
|
15
|
+
export default { get, set, remove };
|
|
16
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2xvYmFsLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2xpYi9jYWNoZS9nbG9iYWwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsMkNBQTJDO0FBQzNDLE1BQU0sS0FBSyxHQUFHLENBQUMsQ0FBQyxNQUFNLElBQUksTUFBTSxDQUFDLENBQUMsbUJBQW1CLENBQUMsR0FBRyxFQUFFLENBQUMsQ0FBQztBQUU3RCxNQUFNLENBQUMsTUFBTSxHQUFHLEdBQUcsQ0FBQyxHQUFXLEVBQW9CLEVBQUU7SUFDbkQsTUFBTSxJQUFJLEdBQUcsS0FBSyxDQUFDLEdBQUcsQ0FBQyxDQUFDO0lBQ3hCLE9BQU8sT0FBTyxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQztBQUMvQixDQUFDLENBQUM7QUFFRixNQUFNLENBQUMsTUFBTSxHQUFHLEdBQUcsQ0FDakIsR0FBVyxFQUNYLElBQWEsRUFDYixPQUFlLEVBQ0EsRUFBRTtJQUNqQixLQUFLLENBQUMsR0FBRyxDQUFDLEdBQUcsRUFBRSxHQUFHLEVBQUUsSUFBSSxFQUFFLE9BQU8sRUFBRSxDQUFDO0lBQ3BDLE9BQU8sT0FBTyxDQUFDLE9BQU8sRUFBRSxDQUFDO0FBQzNCLENBQUMsQ0FBQztBQUVGLE1BQU0sQ0FBQyxNQUFNLE1BQU0sR0FBRyxDQUFDLEdBQVcsRUFBaUIsRUFBRTtJQUNuRCxPQUFPLEtBQUssQ0FBQyxHQUFHLENBQUMsQ0FBQztJQUNsQixPQUFPLE9BQU8sQ0FBQyxPQUFPLEVBQUUsQ0FBQztBQUMzQixDQUFDLENBQUM7QUFFRixlQUFlLEVBQUUsR0FBRyxFQUFFLEdBQUcsRUFBRSxNQUFNLEVBQUUsQ0FBQyJ9
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const queue = {};
|
|
2
|
+
const add = (key, data) => {
|
|
3
|
+
if (!queue[key]) {
|
|
4
|
+
queue[key] = [];
|
|
5
|
+
}
|
|
6
|
+
queue[key].push(data);
|
|
7
|
+
};
|
|
8
|
+
const getAll = (key) => {
|
|
9
|
+
const keyQueue = queue[key];
|
|
10
|
+
if (!keyQueue) {
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
delete queue[key];
|
|
14
|
+
return keyQueue;
|
|
15
|
+
};
|
|
16
|
+
export default { add, getAll };
|
|
17
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicXVldWUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbGliL3F1ZXVlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE1BQU0sS0FBSyxHQUFpQyxFQUFFLENBQUM7QUFFL0MsTUFBTSxHQUFHLEdBQUcsQ0FBQyxHQUFXLEVBQUUsSUFBYSxFQUFRLEVBQUU7SUFDL0MsSUFBSSxDQUFDLEtBQUssQ0FBQyxHQUFHLENBQUMsRUFBRTtRQUNmLEtBQUssQ0FBQyxHQUFHLENBQUMsR0FBRyxFQUFFLENBQUM7S0FDakI7SUFDRCxLQUFLLENBQUMsR0FBRyxDQUFDLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFDO0FBQ3hCLENBQUMsQ0FBQztBQUVGLE1BQU0sTUFBTSxHQUFHLENBQUMsR0FBVyxFQUFFLEVBQUU7SUFDN0IsTUFBTSxRQUFRLEdBQUcsS0FBSyxDQUFDLEdBQUcsQ0FBQyxDQUFDO0lBQzVCLElBQUksQ0FBQyxRQUFRLEVBQUU7UUFDYixPQUFPLEVBQUUsQ0FBQztLQUNYO0lBQ0QsT0FBTyxLQUFLLENBQUMsR0FBRyxDQUFDLENBQUM7SUFDbEIsT0FBTyxRQUFRLENBQUM7QUFDbEIsQ0FBQyxDQUFDO0FBRUYsZUFBZSxFQUFFLEdBQUcsRUFBRSxNQUFNLEVBQUUsQ0FBQyJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getCurrentUrl: {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export const getCurrentUrl = {};
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidG9vbHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbGliL3Rvb2xzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE1BQU0sQ0FBQyxNQUFNLGFBQWEsR0FBRyxFQUFFLENBQUMifQ==
|
package/dist/lib/user.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export const login = () => { };
|
|
2
|
+
export const logout = () => { };
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXNlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9saWIvdXNlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxNQUFNLENBQUMsTUFBTSxLQUFLLEdBQUcsR0FBRyxFQUFFLEdBQUUsQ0FBQyxDQUFDO0FBRTlCLE1BQU0sQ0FBQyxNQUFNLE1BQU0sR0FBRyxHQUFHLEVBQUUsR0FBRSxDQUFDLENBQUMifQ==
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Record, Static } from 'runtypes';
|
|
2
|
+
import { Engine } from '../lib/cache/types';
|
|
3
|
+
export declare const setCacheEngine: (engine: Engine) => void;
|
|
4
|
+
declare const _default: {
|
|
5
|
+
get: <T extends Record<any, any>>(key: string, validator: T) => Promise<void | Static<T>>;
|
|
6
|
+
set: (key: string, value: unknown, expires: number) => Promise<void>;
|
|
7
|
+
remove: (key: string) => Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import globalCache from '../lib/cache/global';
|
|
11
|
+
let cacheEngine;
|
|
12
|
+
export const setCacheEngine = (engine) => {
|
|
13
|
+
cacheEngine = engine;
|
|
14
|
+
};
|
|
15
|
+
const getCacheEngine = () => cacheEngine || globalCache;
|
|
16
|
+
const get = (key, validator) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
const data = yield getCacheEngine().get(key);
|
|
18
|
+
if (!data) {
|
|
19
|
+
return Promise.resolve();
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
const typedData = validator.check(data);
|
|
23
|
+
return typedData;
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
console.error('Failed validating data', { data, error });
|
|
27
|
+
getCacheEngine().remove(key);
|
|
28
|
+
return Promise.resolve();
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const set = (key, value, expires) => getCacheEngine().set(key, value, expires);
|
|
32
|
+
const remove = (key) => getCacheEngine().remove(key);
|
|
33
|
+
export default { get, set, remove };
|
|
34
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2FjaGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvc2VydmljZXMvY2FjaGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7O0FBQ0EsT0FBTyxXQUFXLE1BQU0scUJBQXFCLENBQUM7QUFHOUMsSUFBSSxXQUFtQixDQUFDO0FBRXhCLE1BQU0sQ0FBQyxNQUFNLGNBQWMsR0FBRyxDQUFDLE1BQWMsRUFBRSxFQUFFO0lBQy9DLFdBQVcsR0FBRyxNQUFNLENBQUM7QUFDdkIsQ0FBQyxDQUFDO0FBRUYsTUFBTSxjQUFjLEdBQUcsR0FBVyxFQUFFLENBQUMsV0FBVyxJQUFJLFdBQVcsQ0FBQztBQUVoRSxNQUFNLEdBQUcsR0FBRyxDQUNWLEdBQVcsRUFDWCxTQUFZLEVBQ2UsRUFBRTtJQUM3QixNQUFNLElBQUksR0FBRyxNQUFNLGNBQWMsRUFBRSxDQUFDLEdBQUcsQ0FBQyxHQUFHLENBQUMsQ0FBQztJQUM3QyxJQUFJLENBQUMsSUFBSSxFQUFFO1FBQ1QsT0FBTyxPQUFPLENBQUMsT0FBTyxFQUFFLENBQUM7S0FDMUI7SUFDRCxJQUFJO1FBQ0YsTUFBTSxTQUFTLEdBQUcsU0FBUyxDQUFDLEtBQUssQ0FBQyxJQUFJLENBQUMsQ0FBQztRQUN4QyxPQUFPLFNBQWMsQ0FBQztLQUN2QjtJQUFDLE9BQU8sS0FBSyxFQUFFO1FBQ2QsT0FBTyxDQUFDLEtBQUssQ0FBQyx3QkFBd0IsRUFBRSxFQUFFLElBQUksRUFBRSxLQUFLLEVBQUUsQ0FBQyxDQUFDO1FBQ3pELGNBQWMsRUFBRSxDQUFDLE1BQU0sQ0FBQyxHQUFHLENBQUMsQ0FBQztRQUM3QixPQUFPLE9BQU8sQ0FBQyxPQUFPLEVBQUUsQ0FBQztLQUMxQjtBQUNILENBQUMsQ0FBQSxDQUFDO0FBRUYsTUFBTSxHQUFHLEdBQUcsQ0FBQyxHQUFXLEVBQUUsS0FBYyxFQUFFLE9BQWUsRUFBRSxFQUFFLENBQzNELGNBQWMsRUFBRSxDQUFDLEdBQUcsQ0FBQyxHQUFHLEVBQUUsS0FBSyxFQUFFLE9BQU8sQ0FBQyxDQUFDO0FBRTVDLE1BQU0sTUFBTSxHQUFHLENBQUMsR0FBVyxFQUFpQixFQUFFLENBQUMsY0FBYyxFQUFFLENBQUMsTUFBTSxDQUFDLEdBQUcsQ0FBQyxDQUFDO0FBRTVFLGVBQWUsRUFBRSxHQUFHLEVBQUUsR0FBRyxFQUFFLE1BQU0sRUFBRSxDQUFDIn0=
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Array, Literal, Record, Static, String,
|
|
1
|
+
import { Array, Literal, Record, Static, String, Union } from 'runtypes';
|
|
2
2
|
export declare type AccessFeatures = string[];
|
|
3
3
|
export declare const CheckAccessForPaperSchema: Record<{
|
|
4
4
|
status: Literal<"success">;
|
|
5
5
|
access: Union<[Literal<"granted">, Literal<"denied">]>;
|
|
6
6
|
publication: Record<{
|
|
7
|
-
id:
|
|
7
|
+
id: String;
|
|
8
8
|
domain: String;
|
|
9
9
|
}, false>;
|
|
10
10
|
access_features: Array<String, false>;
|
|
@@ -15,14 +15,14 @@ declare const GetVstokenSchema: Record<{
|
|
|
15
15
|
cookie: String;
|
|
16
16
|
access_features: Array<String, false>;
|
|
17
17
|
}, false>;
|
|
18
|
-
|
|
18
|
+
declare type GetVstoken = Static<typeof GetVstokenSchema>;
|
|
19
19
|
declare const GetNonUserAccessSchema: Record<{
|
|
20
20
|
status: Literal<"success">;
|
|
21
21
|
vstoken_cookie: String;
|
|
22
22
|
uuid: String;
|
|
23
23
|
access_features: Array<String, false>;
|
|
24
24
|
}, false>;
|
|
25
|
-
|
|
25
|
+
declare type GetNonUserAccess = Static<typeof GetNonUserAccessSchema>;
|
|
26
26
|
export declare const checkForAccess: (publicationDomain: string, accessFeatures: AccessFeatures) => Promise<CheckAccessForPaper>;
|
|
27
27
|
export declare const getVstoken: (publicationDomain: string) => Promise<GetVstoken>;
|
|
28
28
|
export declare const getNonUserAccess: (publicationDomain: string) => Promise<GetNonUserAccess>;
|