@amedia/user 0.4.0 → 0.4.2

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.
Files changed (49) hide show
  1. package/dist/actions/authentication.d.ts +1 -1
  2. package/dist/actions/authorization.d.ts +2 -2
  3. package/dist/cache/engines/global.d.ts +15 -0
  4. package/dist/cache/engines/global.spec.d.ts +1 -0
  5. package/dist/cache/engines/indexeddb.d.ts +1 -0
  6. package/dist/cache/index.d.ts +1 -0
  7. package/dist/cache/index.spec.d.ts +4 -0
  8. package/dist/cache/types.d.ts +1 -0
  9. package/dist/eventHandlers/authentication.d.ts +5 -3
  10. package/dist/eventHandlers/userAttributes.d.ts +5 -3
  11. package/dist/index-authentcation.spec.d.ts +4 -0
  12. package/dist/index-userdata.spec.d.ts +4 -0
  13. package/dist/index.d.ts +6 -3
  14. package/dist/index.js +1 -1
  15. package/dist/lib/cookie.d.ts +5 -0
  16. package/dist/lib/rpc.d.ts +1 -0
  17. package/dist/services/jupiter.spec.d.ts +1 -0
  18. package/dist/services/mercury.spec.d.ts +4 -0
  19. package/dist/services/pluto.d.ts +2 -2
  20. package/dist/services/pluto.spec.d.ts +1 -0
  21. package/dist/types.d.ts +6 -3
  22. package/dist/utils/log.d.ts +7 -0
  23. package/dist/utils/queue.d.ts +9 -2
  24. package/dist/utils/url.d.ts +3 -0
  25. package/dist/utils/url.spec.d.ts +1 -0
  26. package/package.json +1 -3
  27. package/src/actions/authorization.ts +43 -37
  28. package/src/{lib/dataOrganizer.ts → actions/userData.ts} +3 -1
  29. package/src/eventHandlers/userAttributes.ts +8 -7
  30. package/src/index-userdata.spec.ts +19 -40
  31. package/src/index.ts +19 -15
  32. package/src/types.ts +9 -3
  33. package/src/utils/queue.ts +19 -4
  34. package/src/utils/url.spec.ts +33 -0
  35. package/src/utils/url.ts +22 -0
  36. package/tsconfig.json +2 -0
  37. package/webpack.config.js +1 -1
  38. package/.babelrc +0 -3
  39. package/dist/lib/authentication.d.ts +0 -20
  40. package/dist/lib/authorization.d.ts +0 -15
  41. package/dist/lib/cache/db.d.ts +0 -6
  42. package/dist/lib/cache/global.d.ts +0 -9
  43. package/dist/lib/cache/types.d.ts +0 -5
  44. package/dist/lib/eventHandler.d.ts +0 -3
  45. package/dist/lib/queue.d.ts +0 -5
  46. package/dist/lib/types.d.ts +0 -7
  47. package/dist/lib/userAttributes.d.ts +0 -12
  48. package/dist/services/cache.d.ts +0 -9
  49. /package/dist/{lib/dataOrganizer.d.ts → actions/userData.d.ts} +0 -0
@@ -1,4 +1,4 @@
1
1
  import { Session } from '../services/pluto';
2
2
  export declare const login: (requestedUrl: string) => void;
3
- export declare const logout: () => void;
3
+ export declare const logout: () => Promise<void>;
4
4
  export declare const getSession: () => Promise<Session | null>;
@@ -1,3 +1,3 @@
1
- import { AccessFeatures, CheckAccessForPaper } from '../services/jupiter';
2
- export declare const checkForAccessToPublication: (publicationDomain: string, accessFeatures: AccessFeatures) => Promise<CheckAccessForPaper | null>;
1
+ import { UserAttributes } from '../types';
2
+ export declare const getAccess: () => Promise<Pick<UserAttributes, 'access'>>;
3
3
  export declare const activate: () => Promise<unknown>;
@@ -1,6 +1,21 @@
1
1
  import { CacheEntry, Engine } from '../types';
2
+ declare global {
3
+ interface Window {
4
+ amediaUserCache?: {
5
+ [index: string]: CacheEntry;
6
+ };
7
+ }
8
+ namespace NodeJS {
9
+ interface Global {
10
+ amediaUserCache?: {
11
+ [index: string]: CacheEntry;
12
+ };
13
+ }
14
+ }
15
+ }
2
16
  export declare const get: (key: string) => Promise<CacheEntry>;
3
17
  export declare const set: (key: string, data: unknown, expires: number) => Promise<void>;
4
18
  export declare const remove: (key: string) => Promise<void>;
19
+ export declare const clear: () => Promise<void>;
5
20
  declare const _default: Engine;
6
21
  export default _default;
@@ -0,0 +1 @@
1
+ export {};
@@ -2,5 +2,6 @@ import { CacheEntry, Engine } from '../types';
2
2
  export declare const get: (key: string) => Promise<CacheEntry>;
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>;
5
6
  declare const _default: Engine;
6
7
  export default _default;
@@ -5,5 +5,6 @@ declare const _default: {
5
5
  get: <T extends Record<any, any>>(key: string, validator: T) => Promise<void | Static<T>>;
6
6
  set: (key: string, value: unknown, expires: number) => Promise<void>;
7
7
  remove: (key: string) => Promise<void>;
8
+ clear: () => Promise<void>;
8
9
  };
9
10
  export default _default;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @jest-environment jsdom
3
+ */
4
+ export {};
@@ -7,4 +7,5 @@ export declare type Engine = {
7
7
  get: (key: string) => Promise<CacheEntry | null>;
8
8
  set: (key: string, data: unknown, expires: number) => Promise<void>;
9
9
  remove: (key: string) => Promise<void>;
10
+ clear: () => Promise<void>;
10
11
  };
@@ -1,15 +1,17 @@
1
1
  export declare enum AuthenticationEvents {
2
2
  REQUEST_LOGIN = "amedia-user.authentication.request-login",
3
- REQUEST_LOGOUT = "amedia-user.authentication.request-logout"
3
+ REQUEST_LOGOUT = "amedia-user.authentication.request-logout",
4
+ ON_LOGGED_OUT = "amedia-user.authentication.on-logged-out"
4
5
  }
5
6
  declare global {
6
7
  interface WindowEventMap {
7
8
  [AuthenticationEvents.REQUEST_LOGIN]: CustomEvent<{
8
- requestedUrl?: string;
9
+ requestedUrl: string;
9
10
  }>;
10
11
  [AuthenticationEvents.REQUEST_LOGOUT]: CustomEvent<{
11
- requestedUrl?: string;
12
+ onLoggedOut: () => void;
12
13
  }>;
14
+ [AuthenticationEvents.ON_LOGGED_OUT]: CustomEvent;
13
15
  }
14
16
  }
15
17
  export declare const listenForAuthenticationRequests: () => void;
@@ -1,12 +1,14 @@
1
- import { UserAttributes } from '../types';
1
+ import { State, UserAttributes } from '../types';
2
2
  export declare enum AmediaUserEvents {
3
3
  REQUEST_USER_ATTRIBUTES = "amedia-user.request-user-attributes",
4
- ON_USER_ATTRIBUTES_UPDATED = "amedia-user.on-user-attributes-updated"
4
+ ON_ATTRIBUTES_UPDATED = "amedia-user.on-user-attributes-updated",
5
+ ON_STATE_UPDATED = "amedia-user.on-state-updated"
5
6
  }
6
7
  declare global {
7
8
  interface WindowEventMap {
8
9
  [AmediaUserEvents.REQUEST_USER_ATTRIBUTES]: CustomEvent<Array<keyof UserAttributes>>;
9
- [AmediaUserEvents.ON_USER_ATTRIBUTES_UPDATED]: CustomEvent<UserAttributes>;
10
+ [AmediaUserEvents.ON_ATTRIBUTES_UPDATED]: CustomEvent<UserAttributes>;
11
+ [AmediaUserEvents.ON_STATE_UPDATED]: CustomEvent<State>;
10
12
  }
11
13
  }
12
14
  export declare const listenForUserAttributeRequests: () => void;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @jest-environment jsdom
3
+ */
4
+ export {};
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @jest-environment jsdom
3
+ */
4
+ export {};
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { UserAttributes } from './types';
1
+ import 'regenerator-runtime/runtime';
2
+ import { State, UserAttributes } from './types';
2
3
  /**
3
4
  * Enables you to subscribe to the user attributes you care about and
4
5
  * get notified when something changes
@@ -10,12 +11,14 @@ import { UserAttributes } from './types';
10
11
  * @todo or resubscribe with different attributes.
11
12
  * @param attributes
12
13
  * @param onUserUpdated
14
+ * @param onStateUpdated
13
15
  */
14
- export declare const subscribeToUserUpdates: <T extends (keyof UserAttributes)[]>(attributes: T, onUserUpdated: (attributes: Pick<UserAttributes, "isLoggedIn" | T[number]>) => void) => void;
16
+ export declare const subscribeToUserUpdates: <T extends (keyof UserAttributes)[]>(attributes: T, onUserUpdated: (attributes: Pick<UserAttributes, T[number]>) => void, onStateUpdated?: ((attributes: State) => void) | undefined) => void;
15
17
  /**
16
18
  * This will, if necessary, trigger a redirect to www.aid.no and return
17
19
  * to the requestedUrl if supplied or the current url before redirecting away if not.
18
20
  * @param requestedUrl
19
21
  */
20
- export declare const requestLogin: (requestedUrl?: string | undefined) => void;
22
+ export declare const login: (requestedUrl?: string | undefined) => void;
23
+ export declare const logout: (onLoggedOut: () => void) => void;
21
24
  export declare const activate: () => Promise<unknown>;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- !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={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",u=o.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=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 I(n||[]);return i._invoke=function(e,t,r){var n=f;return function(o,i){if(n===v)throw new Error("Generator is already running");if(n===h){if("throw"===o)throw i;return U()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var u=C(a,r);if(u){if(u===p)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===f)throw n=h,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=v;var c=l(e,t,r);if("normal"===c.type){if(n=r.done?h:d,c.arg===p)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n=h,r.method="throw",r.arg=c.arg)}}}(e,r,a),i}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var f="suspendedStart",d="suspendedYield",v="executing",h="completed",p={};function y(){}function E(){}function g(){}var m={};m[i]=function(){return this};var R=Object.getPrototypeOf,O=R&&R(R(N([])));O&&O!==r&&n.call(O,i)&&(m=O);var _=g.prototype=y.prototype=Object.create(m);function b(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function T(e,t){function r(o,i,a,u){var c=l(e[o],e,i);if("throw"!==c.type){var s=c.arg,f=s.value;return f&&"object"==typeof f&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,a,u)}),(function(e){r("throw",e,a,u)})):t.resolve(f).then((function(e){s.value=e,a(s)}),(function(e){return r("throw",e,a,u)}))}u(c.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 C(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,C(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=l(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 w(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 S(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(w,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:U}}function U(){return{value:t,done:!0}}return E.prototype=_.constructor=g,g.constructor=E,E.displayName=c(g,u,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===E||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,g):(e.__proto__=g,c(e,u,"GeneratorFunction")),e.prototype=Object.create(_),e},e.awrap=function(e){return{__await:e}},b(T.prototype),T.prototype[a]=function(){return this},e.AsyncIterator=T,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new T(s(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},b(_),c(_,u,"Generator"),_[i]=function(){return this},_.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,I.prototype={constructor:I,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(S),!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 u.type="throw",u.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],u=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var c=n.call(a,"catchLoc"),s=n.call(a,"finallyLoc");if(c&&s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(c){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),S(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;S(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,u=e.slice(0,r),c=e[r];return{enforce:function(e){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];if(t.length<u.length){var s="Expected "+u.length+" arguments but only received "+t.length,l=a.FAILURE.ARGUMENT_INCORRECT(s);throw new i.ValidationError(l)}for(var f=0;f<u.length;f++)u[f].check(t[f]);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,l=a.FAILURE.RETURN_INCORRECT(s),new i.ValidationError(l);return d.then(c.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,u=e.slice(0,r),c=e[r];return{enforce:function(e){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];if(t.length<u.length){var s="Expected "+u.length+" arguments but only received "+t.length,l=a.FAILURE.ARGUMENT_INCORRECT(s);throw new i.ValidationError(l)}for(var f=0;f<u.length;f++)u[f].check(t[f]);return c.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=[],u=0;u<r;u++)a.push(u);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 u=i.value,c=(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>u.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 u=c+", argument #"+i+": "+a.message,l=o.FAILURE.ARGUMENT_INCORRECT(u);throw new n.ValidationError(l)}})),u.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),u=a.next();!u.done;u=a.next()){var c=n(u.value,2),s=c[0],l=c[1];if(s.guard(t))return l(t)}}catch(e){o={error:e}}finally{try{u&&!u.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 u=Object.keys(o.fields);return u.length?"{ "+u.map((function(e){return""+n(o)+e+(a=e,u=(i=o).isPartial,c=i.fields,(u||void 0!==a&&"optional"===c[a].tag?"?":"")+": ")+("optional"===o.fields[e].tag?r(!1,t)(o.fields[e].underlying):r(!1,t)(o.fields[e]))+";";var i,a,u,c})).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),u=i.map((function(o){return n.innerValidate(e,t[o],r)})),c=i.reduce((function(e,t){var r=u[t];return r.success||(e[t]=r.details||r.message),e}),[]);return 0!==o.enumerableKeysOf(c).length?o.FAILURE.CONTENT_INCORRECT(a,c):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,u={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(u,i):i?o.SUCCESS(n.value):o.FAILURE.CONSTRAINT_FAILED(u)}),u)},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),u=r(589),c=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?c:t,s=a.default(i),l={tag:"dictionary",key:s,value:e};return n.create((function(t,o){if(null==t||"object"!=typeof t)return u.FAILURE.TYPE_INCORRECT(l,t);if(Object.getPrototypeOf(t)!==Object.prototype&&(!Array.isArray(t)||"string"===s))return u.FAILURE.TYPE_INCORRECT(l,t);var a=/^(?:NaN|-?\d+(?:\.\d+)?)$/u,c=u.enumerableKeysOf(t),f=c.reduce((function(c,s){var f="string"==typeof s&&a.test(s),d=f?r.g.Number(s):s;return(f?i.guard(d)||i.guard(s):i.guard(d))?c[s]=n.innerValidate(e,t[s],o):c[s]=u.FAILURE.KEY_INCORRECT(l,i.reflect,d),c}),{}),d=c.reduce((function(e,t){var r=f[t];return r.success||(e[t]=r.details||r.message),e}),{});return 0!==u.enumerableKeysOf(d).length?u.FAILURE.CONTENT_INCORRECT(l,d):u.SUCCESS(t)}),l)}},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,u;try{for(var c=n(e),s=c.next();!s.done;s=c.next()){var l=s.value,f=o.innerValidate(l,t,r);if(!f.success)return f}}catch(e){a={error:e}}finally{try{s&&!s.done&&(u=c.return)&&u.call(c)}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 u(e,t,r){var c,s={tag:"record",isPartial:t,isReadonly:r,fields:e};return(c=i.create((function(r,u){if(null==r)return a.FAILURE.TYPE_INCORRECT(s,r);var c=a.enumerableKeysOf(e);if(0!==c.length&&"object"!=typeof r)return a.FAILURE.TYPE_INCORRECT(s,r);var l=o([],n(new Set(o(o([],n(c)),n(a.enumerableKeysOf(r)))))),f=l.reduce((function(n,o){var c=a.hasKey(o,e),s=a.hasKey(o,r);if(c){var l=e[o],f=t||"optional"===l.reflect.tag;if(s){var d=r[o];n[o]=f&&void 0===d?a.SUCCESS(d):i.innerValidate(l,d,u)}else n[o]=f?a.SUCCESS(void 0):a.FAILURE.PROPERTY_MISSING(l.reflect)}else{if(!s)throw new Error("impossible");d=r[o],n[o]=a.SUCCESS(d)}return n}),{}),d=l.reduce((function(e,t){var r=f[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 u(c.fields,!0,c.isReadonly)},c.asReadonly=function(){return u(c.fields,c.isPartial,!0)},c.pick=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r={};return e.forEach((function(e){r[e]=c.fields[e]})),u(r,c.isPartial,c.isReadonly)},c.omit=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r={};return a.enumerableKeysOf(c.fields).forEach((function(t){e.includes(t)||(r[t]=c.fields[t])})),u(r,c.isPartial,c.isReadonly)},c}t.InternalRecord=u,t.Record=function(e){return u(e,!1,!1)},t.Partial=function(e){return u(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),u=a.map((function(r){return n.innerValidate(e[r],t[r],i)})),c=a.reduce((function(e,t){var r=u[t];return r.success||(e[t]=r.details||r.message),e}),[]);return 0!==o.enumerableKeysOf(c).length?o.FAILURE.CONTENT_INCORRECT(r,c):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 u,c,s,l,f,d,v,h;if("object"!=typeof t||null===t){try{for(var p=n(e),y=p.next();!y.done;y=p.next()){var E=y.value;if(o.innerValidate(E,t,r).success)return i.SUCCESS(t)}}catch(e){u={error:e}}finally{try{y&&!y.done&&(c=p.return)&&c.call(p)}finally{if(u)throw u.error}}return i.FAILURE.TYPE_INCORRECT(a,t)}var g={};try{for(var m=n(e),R=m.next();!R.done;R=m.next())if("record"===(E=R.value).reflect.tag){var O=function(e){var t=E.reflect.fields[e];"literal"===t.tag&&(g[e]?g[e].every((function(e){return e!==t.value}))&&g[e].push(t.value):g[e]=[t.value])};for(var _ in E.reflect.fields)O(_)}}catch(e){s={error:e}}finally{try{R&&!R.done&&(l=m.return)&&l.call(m)}finally{if(s)throw s.error}}for(var _ in g)if(g[_].length===e.length)try{for(var b=(f=void 0,n(e)),T=b.next();!T.done;T=b.next())if("record"===(E=T.value).reflect.tag){var C=E.reflect.fields[_];if("literal"===C.tag&&i.hasKey(_,t)&&t[_]===C.value)return o.innerValidate(E,t,r)}}catch(e){f={error:e}}finally{try{T&&!T.done&&(d=b.return)&&d.call(b)}finally{if(f)throw f.error}}try{for(var w=n(e),S=w.next();!S.done;S=w.next()){var I=S.value;if(o.innerValidate(I,t,r).success)return i.SUCCESS(t)}}catch(e){v={error:e}}finally{try{S&&!S.done&&(h=w.return)&&h.call(w)}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,{activate:()=>J,login:()=>H,logout:()=>X,subscribeToUserUpdates:()=>Q}),r(390);const e={debug:console.debug,info:console.info,warn:console.warn,error:console.error};var t,o;"undefined"!=typeof window&&(o=window,t=o);var i=function(r,n){t?t.addEventListener(r,(function(e){e.stopImmediatePropagation(),n.apply(window,[e])})):e.error("No root element to bind event to!")},a=function(r,n){t?t.addEventListener(r,(function(e){n.apply(window,[e])})):e.error("No root element to bind event to!")},u=function(r){t?t.dispatchEvent(r):e.error("No root element to dispatch event on!")},c=r(61);function s(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,o)}function l(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function a(e){s(i,n,o,a,u,"next",e)}function u(e){s(i,n,o,a,u,"throw",e)}a(void 0)}))}}var f=(0,c.Record)({user_name:c.String,tracking_key:c.String}),d=(0,c.Record)({name:c.String,trackingKey:c.String}),v=function(){var t=l(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",fetch("/api/pluto/v1/sessions/current").then((function(e){if(!e.ok)throw new Error("Request not ok (".concat(e.status,": ").concat(e.statusText,")."));return e.json()})).then((function(t){try{return{name:(r=f.check(t)).user_name,trackingKey:r.tracking_key}}catch(t){throw e.error("Invalid schema",t),t}var r})));case 1:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),h=function(){var e=l(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",fetch("/api/pluto/v1/sessions/current?publication_domain=".concat(t),{method:"DELETE"}).then((function(e){if(!e.ok)throw new Error("Error, could not perform deleteRequest. Status: ".concat(e.status," Text: ").concat(e.statusText))})));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),p=function(){var e="undefined"!=typeof window?window:r.g;return e.amediaUserCache||(e.amediaUserCache={})};const y={get:function(e){var t=p()[e];return Promise.resolve(t)},set:function(e,t,r){return p()[e]={key:e,data:t,expires:r},Promise.resolve()},remove:function(e){return delete p()[e],Promise.resolve()}};function E(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,o)}var g=function(){return y},m=function(e){return g().remove(e)};const R={get:function(){var t,r=(t=regeneratorRuntime.mark((function t(r,n){var o,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,g().get(r);case 2:if(o=t.sent){t.next=5;break}return t.abrupt("return",Promise.resolve());case 5:if(!(Date.now()>o.expires)){t.next=8;break}return m(r),t.abrupt("return",Promise.resolve());case 8:return t.prev=8,i=n.check(o.data),t.abrupt("return",i);case 13:return t.prev=13,t.t0=t.catch(8),t.t0 instanceof c.ValidationError?e.error("Failed validating data",{data:o.data,error:t.t0.details}):e.error("Unknown error",t.t0),m(r),t.abrupt("return",Promise.resolve());case 18:case"end":return t.stop()}}),t,null,[[8,13]])})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(e){E(i,n,o,a,u,"next",e)}function u(e){E(i,n,o,a,u,"throw",e)}a(void 0)}))});return function(e,t){return r.apply(this,arguments)}}(),set:function(e,t,r){return g().set(e,t,r)},remove:m,clear:function(){return g().clear()}};let O;const _=self||window,b="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||void 0!==_.msCrypto&&"function"==typeof _.msCrypto.getRandomValues&&_.msCrypto.getRandomValues.bind(_.msCrypto);if(b){const e=new Uint8Array(16);O=function(){return b(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 T=[];for(let e=0;e<256;++e)T[e]=(e+256).toString(16).substr(1);function C(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=O();return e[6]=15&e[6]|64,e[8]=63&e[8]|128,function(e,t){let r=0;const n=T;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)}(),u=new CustomEvent(`amedia-rpc-event:${e}:${t}`,{detail:{eventId:a,args:r}});if(self.dispatchEvent(u),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 w{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]=C(this.component,e),this[e](...t)}}}var S,I=function(e,t){var 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},N=function(e){for(var t="".concat(e,"="),r=document.cookie.split(";"),n=r.length-1;n>=0;n-=1){var o=r[n].trim();if(0===o.indexOf(t))return I(t,o)}return null},U=function(e,t){return t?t instanceof Date?"; expires=".concat(t.toUTCString()):(e.setTime(e.getTime()+24*t*60*60*1e3),"; expires=".concat(e.toUTCString())):""},P=function(e){return e&&""!==e?e instanceof Object?encodeURIComponent(JSON.stringify(e)):"number"==typeof e?e.toString(10):e:""};function L(e){!function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Date.now(),n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"/",o=arguments.length>4&&void 0!==arguments[4]&&arguments[4],i=new Date,a="".concat(e,"=");t&&""!==t||(r=-1),a+=P(t),a+=U(i,r),a+="; path=".concat(n),o&&(a+="; secure"),document.cookie=a,r&&-1!==r&&null===N(e)&&(document.cookie=a.replace(/; expires=[^;]*/,""))}(e)}function A(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,o)}function j(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function a(e){A(i,n,o,a,u,"next",e)}function u(e){A(i,n,o,a,u,"throw",e)}a(void 0)}))}}var x,F=function(){var e=j(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Promise.all([h(window.location.host),R.clear()]).then((function(){(S||((S=new w({version:"1.0.0",component:"userdata-session"})).addMethod("userAuthenticated"),S)).userAuthenticated(!1),L("VSTOKEN"),L("aid.session"),L("aid_invitation_code"),L("aid-reload-article"),L("VSTOKEN2")})));case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),k=!1,M="is_logged_in",V=function(){var e=j(regeneratorRuntime.mark((function e(){var t,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!k){e.next=2;break}return e.abrupt("return",null);case 2:return k=!0,e.next=5,R.get(M,d);case 5:if(!(t=e.sent)){e.next=9;break}return k=!1,e.abrupt("return",t);case 9:return e.next=11,v();case 11:return r=e.sent,R.set(M,r,Date.now()+1e4),k=!1,e.abrupt("return",r);case 15:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();!function(e){e.REQUEST_LOGIN="amedia-user.authentication.request-login",e.REQUEST_LOGOUT="amedia-user.authentication.request-logout",e.ON_LOGGED_OUT="amedia-user.authentication.on-logged-out"}(x||(x={})),i(x.REQUEST_LOGIN,(function(e){var t,r;t=e.detail.requestedUrl,(r=new URL("https://aid.no/logg_inn/")).searchParams.set("requestedUrl",t||window.location.href),window.location.href=r.href})),i(x.REQUEST_LOGOUT,(function(){F().finally((function(){u(new CustomEvent(x.ON_LOGGED_OUT))}))}));var G,Y={name:V,trackingKey:V};function D(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function K(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?D(Object(r),!0).forEach((function(t){B(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):D(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function B(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}!function(e){e.REQUEST_USER_ATTRIBUTES="amedia-user.request-user-attributes",e.ON_USER_ATTRIBUTES_UPDATED="amedia-user.on-user-attributes-updated"}(G||(G={})),i(G.REQUEST_USER_ATTRIBUTES,(function(t){!function(t,r){var n=[];for(t.forEach((function(t){var r=Y[t];r?n.includes(r)||n.push(r):e.warn("Unknown attribute was requested")}));n.length>0;){var o=n.pop();o&&o().then((function(e){r(e)}))}}(t.detail,(function(e){u(new CustomEvent(G.ON_USER_ATTRIBUTES_UPDATED,{detail:K(K({},e),{},{isLoggedIn:!(null==e||!e.name)})}))}))}));var $,q=(0,c.Record)({id:c.Number,domain:c.String});(0,c.Record)({status:(0,c.Literal)("success"),access:(0,c.Union)((0,c.Literal)("granted"),(0,c.Literal)("denied")),publication:q,access_features:(0,c.Array)(c.String)}),(0,c.Record)({status:(0,c.Literal)("success"),cookie:c.String,access_features:(0,c.Array)(c.String)}),(0,c.Record)({status:(0,c.Literal)("success"),vstoken_cookie:c.String,uuid:c.String,access_features:(0,c.Array)(c.String)}),function(e){e.REQUEST_ACTIVATION="amedia-user.activation.request-activation",e.ON_ACTIVATION_COMPLETE="amedia-user.activation.on-activation-complete"}($||($={})),i($.REQUEST_ACTIVATION,(function(){new Promise((function(e){setTimeout((function(){e({status:"success"})}),1e3)})).then((function(e){u(new CustomEvent($.ON_ACTIVATION_COMPLETE,{detail:e}))}))}));var Q=function(t,r){a(G.ON_USER_ATTRIBUTES_UPDATED,(function(n){var o=n.detail;if(o){var i={};void 0!==o.isLoggedIn&&(i.isLoggedIn=o.isLoggedIn),t.forEach((function(e){void 0!==o[e]&&(i[e]=o[e])})),r(i)}else e.warn("Nå attributes received",o)})),u(new CustomEvent(G.REQUEST_USER_ATTRIBUTES,{detail:t}))},H=function(e){return u(new CustomEvent(x.REQUEST_LOGIN,{detail:{requestedUrl:e||window.location.href}}))},X=function(e){a(x.ON_LOGGED_OUT,e),u(new CustomEvent(x.REQUEST_LOGOUT))},J=function(){return new Promise((function(e){a($.ON_ACTIVATION_COMPLETE,e),u(new CustomEvent($.REQUEST_ACTIVATION))}))}})(),n})()}));
1
+ !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={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",u=o.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function s(e,t,r,n){var o=t&&t.prototype instanceof p?t:p,i=Object.create(o.prototype),a=new N(n||[]);return i._invoke=function(e,t,r){var n=f;return function(o,i){if(n===v)throw new Error("Generator is already running");if(n===h){if("throw"===o)throw i;return U()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var u=b(a,r);if(u){if(u===y)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===f)throw n=h,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=v;var c=l(e,t,r);if("normal"===c.type){if(n=r.done?h:d,c.arg===y)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n=h,r.method="throw",r.arg=c.arg)}}}(e,r,a),i}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var f="suspendedStart",d="suspendedYield",v="executing",h="completed",y={};function p(){}function E(){}function g(){}var m={};m[i]=function(){return this};var _=Object.getPrototypeOf,R=_&&_(_(I([])));R&&R!==r&&n.call(R,i)&&(m=R);var O=g.prototype=p.prototype=Object.create(m);function T(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function C(e,t){function r(o,i,a,u){var c=l(e[o],e,i);if("throw"!==c.type){var s=c.arg,f=s.value;return f&&"object"==typeof f&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,a,u)}),(function(e){r("throw",e,a,u)})):t.resolve(f).then((function(e){s.value=e,a(s)}),(function(e){return r("throw",e,a,u)}))}u(c.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 b(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,b(e,r),"throw"===r.method))return y;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return y}var o=l(n,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,y;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,y):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function w(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 S(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function N(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(w,this),this.reset(!0)}function I(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:U}}function U(){return{value:t,done:!0}}return E.prototype=O.constructor=g,g.constructor=E,E.displayName=c(g,u,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===E||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,g):(e.__proto__=g,c(e,u,"GeneratorFunction")),e.prototype=Object.create(O),e},e.awrap=function(e){return{__await:e}},T(C.prototype),C.prototype[a]=function(){return this},e.AsyncIterator=C,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new C(s(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},T(O),c(O,u,"Generator"),O[i]=function(){return this},O.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=I,N.prototype={constructor:N,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(S),!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 u.type="throw",u.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],u=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var c=n.call(a,"catchLoc"),s=n.call(a,"finallyLoc");if(c&&s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(c){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,y):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),y},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),S(r),y}},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;S(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),y}},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,u=e.slice(0,r),c=e[r];return{enforce:function(e){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];if(t.length<u.length){var s="Expected "+u.length+" arguments but only received "+t.length,l=a.FAILURE.ARGUMENT_INCORRECT(s);throw new i.ValidationError(l)}for(var f=0;f<u.length;f++)u[f].check(t[f]);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,l=a.FAILURE.RETURN_INCORRECT(s),new i.ValidationError(l);return d.then(c.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,u=e.slice(0,r),c=e[r];return{enforce:function(e){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];if(t.length<u.length){var s="Expected "+u.length+" arguments but only received "+t.length,l=a.FAILURE.ARGUMENT_INCORRECT(s);throw new i.ValidationError(l)}for(var f=0;f<u.length;f++)u[f].check(t[f]);return c.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=[],u=0;u<r;u++)a.push(u);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 u=i.value,c=(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>u.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 u=c+", argument #"+i+": "+a.message,l=o.FAILURE.ARGUMENT_INCORRECT(u);throw new n.ValidationError(l)}})),u.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),u=a.next();!u.done;u=a.next()){var c=n(u.value,2),s=c[0],l=c[1];if(s.guard(t))return l(t)}}catch(e){o={error:e}}finally{try{u&&!u.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 u=Object.keys(o.fields);return u.length?"{ "+u.map((function(e){return""+n(o)+e+(a=e,u=(i=o).isPartial,c=i.fields,(u||void 0!==a&&"optional"===c[a].tag?"?":"")+": ")+("optional"===o.fields[e].tag?r(!1,t)(o.fields[e].underlying):r(!1,t)(o.fields[e]))+";";var i,a,u,c})).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),u=i.map((function(o){return n.innerValidate(e,t[o],r)})),c=i.reduce((function(e,t){var r=u[t];return r.success||(e[t]=r.details||r.message),e}),[]);return 0!==o.enumerableKeysOf(c).length?o.FAILURE.CONTENT_INCORRECT(a,c):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,u={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(u,i):i?o.SUCCESS(n.value):o.FAILURE.CONSTRAINT_FAILED(u)}),u)},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),u=r(589),c=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?c:t,s=a.default(i),l={tag:"dictionary",key:s,value:e};return n.create((function(t,o){if(null==t||"object"!=typeof t)return u.FAILURE.TYPE_INCORRECT(l,t);if(Object.getPrototypeOf(t)!==Object.prototype&&(!Array.isArray(t)||"string"===s))return u.FAILURE.TYPE_INCORRECT(l,t);var a=/^(?:NaN|-?\d+(?:\.\d+)?)$/u,c=u.enumerableKeysOf(t),f=c.reduce((function(c,s){var f="string"==typeof s&&a.test(s),d=f?r.g.Number(s):s;return(f?i.guard(d)||i.guard(s):i.guard(d))?c[s]=n.innerValidate(e,t[s],o):c[s]=u.FAILURE.KEY_INCORRECT(l,i.reflect,d),c}),{}),d=c.reduce((function(e,t){var r=f[t];return r.success||(e[t]=r.details||r.message),e}),{});return 0!==u.enumerableKeysOf(d).length?u.FAILURE.CONTENT_INCORRECT(l,d):u.SUCCESS(t)}),l)}},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,u;try{for(var c=n(e),s=c.next();!s.done;s=c.next()){var l=s.value,f=o.innerValidate(l,t,r);if(!f.success)return f}}catch(e){a={error:e}}finally{try{s&&!s.done&&(u=c.return)&&u.call(c)}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 u(e,t,r){var c,s={tag:"record",isPartial:t,isReadonly:r,fields:e};return(c=i.create((function(r,u){if(null==r)return a.FAILURE.TYPE_INCORRECT(s,r);var c=a.enumerableKeysOf(e);if(0!==c.length&&"object"!=typeof r)return a.FAILURE.TYPE_INCORRECT(s,r);var l=o([],n(new Set(o(o([],n(c)),n(a.enumerableKeysOf(r)))))),f=l.reduce((function(n,o){var c=a.hasKey(o,e),s=a.hasKey(o,r);if(c){var l=e[o],f=t||"optional"===l.reflect.tag;if(s){var d=r[o];n[o]=f&&void 0===d?a.SUCCESS(d):i.innerValidate(l,d,u)}else n[o]=f?a.SUCCESS(void 0):a.FAILURE.PROPERTY_MISSING(l.reflect)}else{if(!s)throw new Error("impossible");d=r[o],n[o]=a.SUCCESS(d)}return n}),{}),d=l.reduce((function(e,t){var r=f[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 u(c.fields,!0,c.isReadonly)},c.asReadonly=function(){return u(c.fields,c.isPartial,!0)},c.pick=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r={};return e.forEach((function(e){r[e]=c.fields[e]})),u(r,c.isPartial,c.isReadonly)},c.omit=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r={};return a.enumerableKeysOf(c.fields).forEach((function(t){e.includes(t)||(r[t]=c.fields[t])})),u(r,c.isPartial,c.isReadonly)},c}t.InternalRecord=u,t.Record=function(e){return u(e,!1,!1)},t.Partial=function(e){return u(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),u=a.map((function(r){return n.innerValidate(e[r],t[r],i)})),c=a.reduce((function(e,t){var r=u[t];return r.success||(e[t]=r.details||r.message),e}),[]);return 0!==o.enumerableKeysOf(c).length?o.FAILURE.CONTENT_INCORRECT(r,c):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 u,c,s,l,f,d,v,h;if("object"!=typeof t||null===t){try{for(var y=n(e),p=y.next();!p.done;p=y.next()){var E=p.value;if(o.innerValidate(E,t,r).success)return i.SUCCESS(t)}}catch(e){u={error:e}}finally{try{p&&!p.done&&(c=y.return)&&c.call(y)}finally{if(u)throw u.error}}return i.FAILURE.TYPE_INCORRECT(a,t)}var g={};try{for(var m=n(e),_=m.next();!_.done;_=m.next())if("record"===(E=_.value).reflect.tag){var R=function(e){var t=E.reflect.fields[e];"literal"===t.tag&&(g[e]?g[e].every((function(e){return e!==t.value}))&&g[e].push(t.value):g[e]=[t.value])};for(var O in E.reflect.fields)R(O)}}catch(e){s={error:e}}finally{try{_&&!_.done&&(l=m.return)&&l.call(m)}finally{if(s)throw s.error}}for(var O in g)if(g[O].length===e.length)try{for(var T=(f=void 0,n(e)),C=T.next();!C.done;C=T.next())if("record"===(E=C.value).reflect.tag){var b=E.reflect.fields[O];if("literal"===b.tag&&i.hasKey(O,t)&&t[O]===b.value)return o.innerValidate(E,t,r)}}catch(e){f={error:e}}finally{try{C&&!C.done&&(d=T.return)&&d.call(T)}finally{if(f)throw f.error}}try{for(var w=n(e),S=w.next();!S.done;S=w.next()){var N=S.value;if(o.innerValidate(N,t,r).success)return i.SUCCESS(t)}}catch(e){v={error:e}}finally{try{S&&!S.done&&(h=w.return)&&h.call(w)}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,{activate:()=>B,login:()=>$,logout:()=>K,subscribeToUserUpdates:()=>D}),r(390);const e={debug:console.debug,info:console.info,warn:console.warn,error:console.error};let t;var o;"undefined"!=typeof window&&(o=window,t=o);const i=(r,n)=>{t?t.addEventListener(r,(e=>{e.stopImmediatePropagation(),n.apply(window,[e])})):e.error("No root element to bind event to!")},a=(r,n)=>{t?t.addEventListener(r,(e=>{n.apply(window,[e])})):e.error("No root element to bind event to!")},u=r=>{t?t.dispatchEvent(r):e.error("No root element to dispatch event on!")};var c=r(61),s=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{c(n.next(e))}catch(e){i(e)}}function u(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,u)}c((n=n.apply(e,t||[])).next())}))};const l=(0,c.Record)({user_name:c.String,tracking_key:c.String}),f=(0,c.Record)({name:c.String,trackingKey:c.String}),d=()=>{const e="undefined"!=typeof window?window:r.g;return e.amediaUserCache||(e.amediaUserCache={})},v={get:e=>{const t=d()[e];return Promise.resolve(t)},set:(e,t,r)=>(d()[e]={key:e,data:t,expires:r},Promise.resolve()),remove:e=>(delete d()[e],Promise.resolve())};const h=()=>v,y=e=>h().remove(e),p=(t,r)=>{return n=void 0,o=void 0,a=function*(){const n=yield h().get(t);if(!n)return Promise.resolve();if(Date.now()>n.expires)return y(t),Promise.resolve();try{return r.check(n.data)}catch(r){return r instanceof c.ValidationError?e.error("Failed validating data",{data:n.data,error:r.details}):e.error("Unknown error",r),y(t),Promise.resolve()}},new((i=void 0)||(i=Promise))((function(e,t){function r(e){try{c(a.next(e))}catch(e){t(e)}}function u(e){try{c(a.throw(e))}catch(e){t(e)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof i?n:new i((function(e){e(n)}))).then(r,u)}c((a=a.apply(n,o||[])).next())}));var n,o,i,a},E=(e,t,r)=>h().set(e,t,r);let g;const m=self||window,_="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||void 0!==m.msCrypto&&"function"==typeof m.msCrypto.getRandomValues&&m.msCrypto.getRandomValues.bind(m.msCrypto);if(_){const e=new Uint8Array(16);g=function(){return _(e),e}}else{const e=new Array(16);g=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 R=[];for(let e=0;e<256;++e)R[e]=(e+256).toString(16).substr(1);function O(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=g();return e[6]=15&e[6]|64,e[8]=63&e[8]|128,function(e,t){let r=0;const n=R;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)}(),u=new CustomEvent(`amedia-rpc-event:${e}:${t}`,{detail:{eventId:a,args:r}});if(self.dispatchEvent(u),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 T{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]=O(this.component,e),this[e](...t)}}}let C;const b=(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 w(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 b(t,n)}return null})(e)&&(document.cookie=a.replace(/; expires=[^;]*/,""))}(e)}var S=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{c(n.next(e))}catch(e){i(e)}}function u(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,u)}c((n=n.apply(e,t||[])).next())}))};let N=!1;const I="is_logged_in",U=()=>S(void 0,void 0,void 0,(function*(){if(N)return null;N=!0;const t=yield p(I,f);if(t)return N=!1,t;const r=yield s(void 0,void 0,void 0,(function*(){return fetch("/api/pluto/v1/sessions/current").then((e=>{if(!e.ok)throw new Error(`Request not ok (${e.status}: ${e.statusText}).`);return e.json()})).then((t=>{try{return{name:(r=l.check(t)).user_name,trackingKey:r.tracking_key}}catch(t){throw e.error("Invalid schema",t),t}var r}))}));return E(I,r,Date.now()+1e4),N=!1,r}));var P;!function(e){e.REQUEST_LOGIN="amedia-user.authentication.request-login",e.REQUEST_LOGOUT="amedia-user.authentication.request-logout",e.ON_LOGGED_OUT="amedia-user.authentication.on-logged-out"}(P||(P={})),i(P.REQUEST_LOGIN,(e=>{(e=>{const t=new URL("https://aid.no/logg_inn/");t.searchParams.set("requestedUrl",e||window.location.href),window.location.href=t.href})(e.detail.requestedUrl)})),i(P.REQUEST_LOGOUT,(()=>{S(void 0,void 0,void 0,(function*(){return Promise.all([(e=window.location.host,s(void 0,void 0,void 0,(function*(){return fetch(`/api/pluto/v1/sessions/current?publication_domain=${e}`,{method:"DELETE"}).then((e=>{if(!e.ok)throw new Error(`Error, could not perform deleteRequest. Status: ${e.status} Text: ${e.statusText}`)}))}))),h().clear()]).then((()=>{(C||(C=new T({version:"1.0.0",component:"userdata-session"}),C.addMethod("userAuthenticated"),C)).userAuthenticated(!1),w("VSTOKEN"),w("aid.session"),w("aid_invitation_code"),w("aid-reload-article"),w("VSTOKEN2")}));var e})).finally((()=>{u(new CustomEvent(P.ON_LOGGED_OUT))}))}));const A=(0,c.Record)({id:c.Number,domain:c.String}),L=(0,c.Record)({status:(0,c.Literal)("success"),access:(0,c.Union)((0,c.Literal)("granted"),(0,c.Literal)("denied")),publication:A,access_features:(0,c.Array)(c.String)}),j=((0,c.Record)({status:(0,c.Literal)("success"),cookie:c.String,access_features:(0,c.Array)(c.String)}),(0,c.Record)({status:(0,c.Literal)("success"),vstoken_cookie:c.String,uuid:c.String,access_features:(0,c.Array)(c.String)}),{}),x=e=>{const t=j[e];return t?(delete j[e],t):[]};const F="authorization.getAccess",k="authorization.getAccess",M=(0,c.Record)({access:(0,c.Array)(c.String)}),V={name:U,trackingKey:U,access:()=>{return t=void 0,r=void 0,o=function*(){return new Promise(((t,r)=>{var n,o;o={resolve:t,reject:r},j[n=k]||(j[n]=[]),j[n].push(o),(e=>{var t;return(null===(t=j[e])||void 0===t?void 0:t.length)||0})(k)>1||p(F,M).then((t=>{var r,n;t?x(k).forEach((e=>{e.resolve(t)})):(r=window.location.hostname.replace(/\.[^.]+\.api\.no/,""),n=["newspaper"],fetch(`/api/jupiter/v1/check_access_for_paper/${r}/?require=any&access_features=${n.join(",")}`).then((e=>{if(!e.ok)throw new Error(`Request not ok (${e.status}: ${e.statusText}).`);return e.json()})).then((t=>{try{return L.check(t)}catch(t){throw e.error("Invalid schema",t),t}}))).then((e=>{E(F,e.access_features,Date.now()+1e4),x(k).forEach((t=>{t.resolve({access:e.access_features})}))})).catch((t=>{e.error("Could not get access",t),x(k).forEach((e=>{e.reject()}))}))}))}))},new((n=void 0)||(n=Promise))((function(e,i){function a(e){try{c(o.next(e))}catch(e){i(e)}}function u(e){try{c(o.throw(e))}catch(e){i(e)}}function c(t){var r;t.done?e(t.value):(r=t.value,r instanceof n?r:new n((function(e){e(r)}))).then(a,u)}c((o=o.apply(t,r||[])).next())}));var t,r,n,o}};var G,Y;!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"}(G||(G={})),i(G.REQUEST_USER_ATTRIBUTES,(t=>{((t,r)=>{const n=[];for(t.forEach((t=>{const r=V[t];r?n.includes(r)||n.push(r):e.warn("Unknown attribute was requested")}));n.length>0;){const e=n.pop();e&&e().then((e=>{r(e)}))}})(t.detail,(e=>{u(new CustomEvent(G.ON_ATTRIBUTES_UPDATED,{detail:e}))}))})),function(e){e.REQUEST_ACTIVATION="amedia-user.activation.request-activation",e.ON_ACTIVATION_COMPLETE="amedia-user.activation.on-activation-complete"}(Y||(Y={})),i(Y.REQUEST_ACTIVATION,(()=>{new Promise((e=>{setTimeout((()=>{e({status:"success"})}),1e3)})).then((e=>{u(new CustomEvent(Y.ON_ACTIVATION_COMPLETE,{detail:e}))}))}));const D=(t,r,n)=>{if(!t||0===t.length)throw new Error("You must subscribe to at least one attribute");a(G.ON_ATTRIBUTES_UPDATED,(n=>{const o=n.detail;if(!o)return void e.warn("Nå attributes received",o);const i=t.reduce(((e,t)=>(void 0!==o[t]&&(e[t]=o[t]),e)),{});r(i)})),n&&a(G.ON_STATE_UPDATED,(e=>{n(e.detail)})),u(new CustomEvent(G.REQUEST_USER_ATTRIBUTES,{detail:t}))},$=e=>u(new CustomEvent(P.REQUEST_LOGIN,{detail:{requestedUrl:e||window.location.href}})),K=e=>{a(P.ON_LOGGED_OUT,e),u(new CustomEvent(P.REQUEST_LOGOUT))},B=()=>new Promise((e=>{a(Y.ON_ACTIVATION_COMPLETE,e),u(new CustomEvent(Y.REQUEST_ACTIVATION))}))})(),n})()}));
@@ -0,0 +1,5 @@
1
+ export declare const getCookie: (name: string) => string | {
2
+ [index: string]: unknown;
3
+ } | null | undefined;
4
+ export declare function setCookie(name: string, value?: unknown, validTimeInDateOrDays?: Date | number, path?: string, secure?: boolean): string;
5
+ export declare function removeCookie(name: any): void;
@@ -0,0 +1 @@
1
+ export declare const getRPCClient: () => any;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @jest-environment jsdom
3
+ */
4
+ export {};
@@ -1,8 +1,8 @@
1
1
  import { Record, Static, String } from 'runtypes';
2
- export declare const Session: Record<{
2
+ export declare const InternalSessionSchema: Record<{
3
3
  name: String;
4
4
  trackingKey: String;
5
5
  }, false>;
6
- export declare type Session = Static<typeof Session>;
6
+ export declare type Session = Static<typeof InternalSessionSchema>;
7
7
  export declare const getCurrentSession: () => Promise<Session>;
8
8
  export declare const removeSession: (domain: string) => Promise<void>;
@@ -0,0 +1 @@
1
+ export {};
package/dist/types.d.ts CHANGED
@@ -1,11 +1,14 @@
1
1
  export declare type UserAttributes = {
2
- isLoggedIn: boolean;
3
2
  name?: string;
4
3
  email?: string;
5
4
  phone?: string;
6
5
  trackingKey?: string;
7
- extraData: [];
8
- access: string[];
6
+ extraData?: [];
7
+ access?: string[];
8
+ };
9
+ export declare type State = {
10
+ isLoggedIn: boolean;
11
+ emergencyMode?: string[];
9
12
  };
10
13
  export declare type AnonymousAttributes = {
11
14
  age: number;
@@ -1,3 +1,10 @@
1
+ export declare type Logger = {
2
+ debug: (message: string | any, ...extra: any[]) => void;
3
+ info: (message: string | any, ...extra: any[]) => void;
4
+ warn: (message: string | any, ...extra: any[]) => void;
5
+ error: (message: string | any, ...extra: any[]) => void;
6
+ };
7
+ export declare const setLogger: (engine: Logger) => void;
1
8
  declare const _default: {
2
9
  debug: {
3
10
  (...data: any[]): void;
@@ -1,5 +1,12 @@
1
1
  declare const _default: {
2
- add: (key: string, data: unknown) => void;
3
- getAll: (key: string) => unknown[];
2
+ add: (key: string, promiseCallbacks: {
3
+ resolve: (PromiseLike: any) => void;
4
+ reject: (reason?: any) => void;
5
+ }) => void;
6
+ getAll: (key: string) => {
7
+ resolve: (PromiseLike: any) => void;
8
+ reject: (reason?: any) => void;
9
+ }[];
10
+ peekQueueSize: (key: string) => number;
4
11
  };
5
12
  export default _default;
@@ -0,0 +1,3 @@
1
+ export declare const setCurrentHostname: (hostname: string) => void;
2
+ export declare const getCurrentEnvironment: () => string | null;
3
+ export declare const getCurrentPublicationDomain: () => string;
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amedia/user",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "Client lib for working with aID user and associated data",
5
5
  "repository": "https://github.com/amedia/amedia-user-js",
6
6
  "author": "Amedia Utvikling (ID og data)",
@@ -26,8 +26,6 @@
26
26
  "@types/dexie": "1.3.1",
27
27
  "@types/jest": "^26.0.23",
28
28
  "@typescript-eslint/eslint-plugin": "4.22.0",
29
- "babel-eslint": "10.1.0",
30
- "babel-loader": "8.2.2",
31
29
  "eslint": "7.24.0",
32
30
  "eslint-config-airbnb-typescript": "12.3.1",
33
31
  "eslint-config-prettier": "8.2.0",
@@ -1,46 +1,52 @@
1
- import {
2
- AccessFeatures,
3
- CheckAccessForPaper,
4
- CheckAccessForPaperSchema,
5
- checkForAccess,
6
- } from '../services/jupiter';
1
+ import { Record, Array, String } from 'runtypes';
2
+ import { checkForAccess } from '../services/jupiter';
7
3
  import cache from '../cache';
4
+ import queue from '../utils/queue';
5
+ import log from '../utils/log';
6
+ import { getCurrentPublicationDomain } from '../utils/url';
7
+ import { UserAttributes } from '../types';
8
8
 
9
9
  const EXPIRES_OFFSET = 10000; // 10 seconds
10
- const CHECK_FOR_ACCESS_CACHE_KEY = 'check_for_access_to_publication';
10
+ const GET_ACCESS_CACHE_KEY = 'authorization.getAccess';
11
+ const GET_ACCESS_QUEUE_KEY = 'authorization.getAccess';
11
12
 
12
- let isCheckingForAccess: boolean = false;
13
- export const checkForAccessToPublication = async (
14
- publicationDomain: string,
15
- accessFeatures: AccessFeatures
16
- ): Promise<CheckAccessForPaper | null> => {
17
- if (isCheckingForAccess) {
18
- return null;
19
- }
20
- isCheckingForAccess = true;
13
+ const AccessSchema = Record({
14
+ access: Array(String),
15
+ });
21
16
 
22
- // Try the cache first
23
- const cacheResponse = await cache.get(
24
- CHECK_FOR_ACCESS_CACHE_KEY,
25
- CheckAccessForPaperSchema
26
- );
27
- if (cacheResponse) {
28
- isCheckingForAccess = false;
29
- return cacheResponse;
30
- }
17
+ export const getAccess = async (): Promise<Pick<UserAttributes, 'access'>> =>
18
+ new Promise((resolve, reject) => {
19
+ queue.add(GET_ACCESS_QUEUE_KEY, { resolve, reject });
20
+ if (queue.peekQueueSize(GET_ACCESS_QUEUE_KEY) > 1) {
21
+ return;
22
+ }
31
23
 
32
- // Actually perform a request against backend for the accessState
33
- const accessState = await checkForAccess(publicationDomain, accessFeatures);
34
- cache.set(
35
- CHECK_FOR_ACCESS_CACHE_KEY,
36
- accessState,
37
- Date.now() + EXPIRES_OFFSET
38
- );
39
-
40
- isCheckingForAccess = false;
41
-
42
- return accessState;
43
- };
24
+ cache.get(GET_ACCESS_CACHE_KEY, AccessSchema).then((cacheResponse) => {
25
+ if (cacheResponse) {
26
+ queue.getAll(GET_ACCESS_QUEUE_KEY).forEach((promise) => {
27
+ promise.resolve(cacheResponse);
28
+ });
29
+ return;
30
+ }
31
+ checkForAccess(getCurrentPublicationDomain(), ['newspaper'])
32
+ .then((accessState) => {
33
+ cache.set(
34
+ GET_ACCESS_CACHE_KEY,
35
+ accessState.access_features,
36
+ Date.now() + EXPIRES_OFFSET
37
+ );
38
+ queue.getAll(GET_ACCESS_QUEUE_KEY).forEach((promise) => {
39
+ promise.resolve({ access: accessState.access_features });
40
+ });
41
+ })
42
+ .catch((error) => {
43
+ log.error('Could not get access', error);
44
+ queue.getAll(GET_ACCESS_QUEUE_KEY).forEach((promise) => {
45
+ promise.reject();
46
+ });
47
+ });
48
+ });
49
+ });
44
50
 
45
51
  // TODO This is just mock implementation
46
52
  export const activate = () =>
@@ -1,6 +1,7 @@
1
1
  import log from '../utils/log';
2
2
  import { UserAttributes } from '../types';
3
- import { getSession } from '../actions/authentication';
3
+ import { getSession } from './authentication';
4
+ import { getAccess } from './authorization';
4
5
 
5
6
  // TODO We may want actions to tell us what they can deliver and not have this "organizer" (wohoo-bad-name) tell the actions..
6
7
  const dataServiceMap: {
@@ -9,6 +10,7 @@ const dataServiceMap: {
9
10
  } = {
10
11
  name: getSession,
11
12
  trackingKey: getSession,
13
+ access: getAccess,
12
14
  };
13
15
 
14
16
  export const fetchDataBasedOnAttributes = (
@@ -1,10 +1,11 @@
1
- import { fetchDataBasedOnAttributes } from '../lib/dataOrganizer';
1
+ import { fetchDataBasedOnAttributes } from '../actions/userData';
2
2
  import { dispatch, listenWithExclusivity } from '../utils/customEventWrapper';
3
- import { UserAttributes } from '../types';
3
+ import { State, UserAttributes } from '../types';
4
4
 
5
5
  export enum AmediaUserEvents {
6
6
  REQUEST_USER_ATTRIBUTES = 'amedia-user.request-user-attributes',
7
- ON_USER_ATTRIBUTES_UPDATED = 'amedia-user.on-user-attributes-updated',
7
+ ON_ATTRIBUTES_UPDATED = 'amedia-user.on-user-attributes-updated',
8
+ ON_STATE_UPDATED = 'amedia-user.on-state-updated',
8
9
  }
9
10
 
10
11
  declare global {
@@ -12,7 +13,8 @@ declare global {
12
13
  [AmediaUserEvents.REQUEST_USER_ATTRIBUTES]: CustomEvent<
13
14
  Array<keyof UserAttributes>
14
15
  >;
15
- [AmediaUserEvents.ON_USER_ATTRIBUTES_UPDATED]: CustomEvent<UserAttributes>;
16
+ [AmediaUserEvents.ON_ATTRIBUTES_UPDATED]: CustomEvent<UserAttributes>;
17
+ [AmediaUserEvents.ON_STATE_UPDATED]: CustomEvent<State>;
16
18
  }
17
19
  }
18
20
 
@@ -20,9 +22,8 @@ export const listenForUserAttributeRequests = () => {
20
22
  listenWithExclusivity(AmediaUserEvents.REQUEST_USER_ATTRIBUTES, (evt) => {
21
23
  fetchDataBasedOnAttributes(evt.detail, (attributes) => {
22
24
  dispatch(
23
- new CustomEvent(AmediaUserEvents.ON_USER_ATTRIBUTES_UPDATED, {
24
- // TODO Fix hacky isLoggedIn
25
- detail: { ...attributes, isLoggedIn: !!attributes?.name },
25
+ new CustomEvent(AmediaUserEvents.ON_ATTRIBUTES_UPDATED, {
26
+ detail: attributes,
26
27
  })
27
28
  );
28
29
  });
@@ -3,7 +3,7 @@
3
3
  */
4
4
 
5
5
  import { subscribeToUserUpdates } from './index';
6
- import * as dataOrganizer from './lib/dataOrganizer';
6
+ import * as userData from './actions/userData';
7
7
  import { setRootElement } from './utils/customEventWrapper';
8
8
  import { listenForUserAttributeRequests } from './eventHandlers/userAttributes';
9
9
 
@@ -22,7 +22,7 @@ beforeEach(() => {
22
22
  describe('Public endpoint - userdata', () => {
23
23
  it('should alert about user data', () => {
24
24
  jest
25
- .spyOn(dataOrganizer, 'fetchDataBasedOnAttributes')
25
+ .spyOn(userData, 'fetchDataBasedOnAttributes')
26
26
  .mockImplementation((_, callback: Function) => {
27
27
  callback({
28
28
  name: 'Donald Duck',
@@ -34,13 +34,12 @@ describe('Public endpoint - userdata', () => {
34
34
 
35
35
  expect(onUserUpdate).toHaveBeenCalledWith({
36
36
  name: 'Donald Duck',
37
- isLoggedIn: true,
38
37
  });
39
38
  });
40
39
 
41
40
  it('should alert when others also ask about data', () => {
42
41
  jest
43
- .spyOn(dataOrganizer, 'fetchDataBasedOnAttributes')
42
+ .spyOn(userData, 'fetchDataBasedOnAttributes')
44
43
  .mockImplementationOnce((_, callback: Function) => {
45
44
  callback({
46
45
  name: undefined,
@@ -59,25 +58,20 @@ describe('Public endpoint - userdata', () => {
59
58
  subscribeToUserUpdates(['name'], secondOnUserUpdate);
60
59
 
61
60
  expect(firstOnUserUpdate).toHaveBeenCalledTimes(2);
62
- expect(firstOnUserUpdate).nthCalledWith(1, {
63
- name: undefined,
64
- isLoggedIn: false,
65
- });
61
+ expect(firstOnUserUpdate).nthCalledWith(1, {});
66
62
  expect(firstOnUserUpdate).nthCalledWith(2, {
67
63
  name: 'Donald Duck',
68
- isLoggedIn: true,
69
64
  });
70
65
 
71
66
  expect(secondOnUserUpdate).toHaveBeenCalledTimes(1);
72
67
  expect(secondOnUserUpdate).toHaveBeenCalledWith({
73
68
  name: 'Donald Duck',
74
- isLoggedIn: true,
75
69
  });
76
70
  });
77
71
 
78
72
  it('should not return more data that requested (except for login status)', () => {
79
73
  jest
80
- .spyOn(dataOrganizer, 'fetchDataBasedOnAttributes')
74
+ .spyOn(userData, 'fetchDataBasedOnAttributes')
81
75
  .mockImplementationOnce((_, callback: Function) => {
82
76
  callback({
83
77
  name: 'Donald Duck',
@@ -90,13 +84,12 @@ describe('Public endpoint - userdata', () => {
90
84
 
91
85
  expect(onUserUpdate).toHaveBeenCalledWith({
92
86
  name: 'Donald Duck',
93
- isLoggedIn: true,
94
87
  });
95
88
  });
96
89
 
97
90
  it('should support returning multiple requested attributes', () => {
98
91
  jest
99
- .spyOn(dataOrganizer, 'fetchDataBasedOnAttributes')
92
+ .spyOn(userData, 'fetchDataBasedOnAttributes')
100
93
 
101
94
  .mockImplementationOnce((_, callback: Function) => {
102
95
  callback({
@@ -111,13 +104,12 @@ describe('Public endpoint - userdata', () => {
111
104
  expect(onUserUpdate).toHaveBeenCalledWith({
112
105
  name: 'Donald Duck',
113
106
  email: 'donald.duck@andeby.no',
114
- isLoggedIn: true,
115
107
  });
116
108
  });
117
109
 
118
- it('should support no attributes, returning only logged in state', () => {
110
+ it('should require at least one attribute', () => {
119
111
  jest
120
- .spyOn(dataOrganizer, 'fetchDataBasedOnAttributes')
112
+ .spyOn(userData, 'fetchDataBasedOnAttributes')
121
113
  .mockImplementationOnce((_, callback: Function) => {
122
114
  callback({
123
115
  name: 'Donald Duck',
@@ -126,16 +118,14 @@ describe('Public endpoint - userdata', () => {
126
118
  });
127
119
 
128
120
  const onUserUpdate = jest.fn();
129
- subscribeToUserUpdates([], onUserUpdate);
130
-
131
- expect(onUserUpdate).toHaveBeenCalledWith({
132
- isLoggedIn: true,
133
- });
121
+ expect(() => subscribeToUserUpdates([], onUserUpdate)).toThrowError(
122
+ new Error('You must subscribe to at least one attribute')
123
+ );
134
124
  });
135
125
 
136
126
  it('should support requesting different attributes', () => {
137
127
  jest
138
- .spyOn(dataOrganizer, 'fetchDataBasedOnAttributes')
128
+ .spyOn(userData, 'fetchDataBasedOnAttributes')
139
129
  .mockImplementation((_, callback: Function) => {
140
130
  callback({
141
131
  name: 'Donald Duck',
@@ -144,34 +134,23 @@ describe('Public endpoint - userdata', () => {
144
134
  });
145
135
 
146
136
  const firstOnUserUpdate = jest.fn();
147
- subscribeToUserUpdates([], firstOnUserUpdate);
137
+ subscribeToUserUpdates(['name', 'email'], firstOnUserUpdate);
148
138
 
149
139
  const secondOnUserUpdate = jest.fn();
150
- subscribeToUserUpdates(['name', 'email'], secondOnUserUpdate);
151
-
152
- const thirdOnUserUpdate = jest.fn();
153
- subscribeToUserUpdates(['email'], thirdOnUserUpdate);
154
-
155
- expect(firstOnUserUpdate).toHaveBeenCalledTimes(3);
156
- expect(firstOnUserUpdate).nthCalledWith(1, { isLoggedIn: true });
157
- expect(firstOnUserUpdate).nthCalledWith(2, { isLoggedIn: true });
158
- expect(firstOnUserUpdate).nthCalledWith(3, { isLoggedIn: true });
140
+ subscribeToUserUpdates(['email'], secondOnUserUpdate);
159
141
 
160
- expect(secondOnUserUpdate).toHaveBeenCalledTimes(2);
161
- expect(secondOnUserUpdate).nthCalledWith(1, {
142
+ expect(firstOnUserUpdate).toHaveBeenCalledTimes(2);
143
+ expect(firstOnUserUpdate).nthCalledWith(1, {
162
144
  name: 'Donald Duck',
163
145
  email: 'donald.duck@andeby.no',
164
- isLoggedIn: true,
165
146
  });
166
- expect(secondOnUserUpdate).nthCalledWith(2, {
147
+ expect(firstOnUserUpdate).nthCalledWith(2, {
167
148
  name: 'Donald Duck',
168
149
  email: 'donald.duck@andeby.no',
169
- isLoggedIn: true,
170
150
  });
171
151
 
172
- expect(thirdOnUserUpdate).toHaveBeenCalledTimes(1);
173
- expect(thirdOnUserUpdate).nthCalledWith(1, {
174
- isLoggedIn: true,
152
+ expect(secondOnUserUpdate).toHaveBeenCalledTimes(1);
153
+ expect(secondOnUserUpdate).nthCalledWith(1, {
175
154
  email: 'donald.duck@andeby.no',
176
155
  });
177
156
  });
package/src/index.ts CHANGED
@@ -3,7 +3,7 @@ import { AuthenticationEvents } from './eventHandlers/authentication';
3
3
  import { AmediaUserEvents } from './eventHandlers/userAttributes';
4
4
  import { ActivationEvents } from './eventHandlers/activation';
5
5
  import { dispatch, listenForAllEvents } from './utils/customEventWrapper';
6
- import { UserAttributes } from './types';
6
+ import { State, UserAttributes } from './types';
7
7
  import log from './utils/log';
8
8
 
9
9
  /**
@@ -17,15 +17,20 @@ import log from './utils/log';
17
17
  * @todo or resubscribe with different attributes.
18
18
  * @param attributes
19
19
  * @param onUserUpdated
20
+ * @param onStateUpdated
20
21
  */
21
22
  export const subscribeToUserUpdates = <T extends Array<keyof UserAttributes>>(
22
23
  attributes: T,
23
24
  onUserUpdated: (
24
25
  // This type ensures you will have the requested attributes _and_ isLoggedIn
25
- attributes: Pick<UserAttributes, T[number] | 'isLoggedIn'>
26
- ) => void
26
+ attributes: Pick<UserAttributes, T[number]>
27
+ ) => void,
28
+ onStateUpdated?: (attributes: State) => void
27
29
  ) => {
28
- listenForAllEvents(AmediaUserEvents.ON_USER_ATTRIBUTES_UPDATED, (evt) => {
30
+ if (!attributes || attributes.length === 0) {
31
+ throw new Error('You must subscribe to at least one attribute');
32
+ }
33
+ listenForAllEvents(AmediaUserEvents.ON_ATTRIBUTES_UPDATED, (evt) => {
29
34
  const userAttributes = evt.detail;
30
35
 
31
36
  if (!userAttributes) {
@@ -33,24 +38,23 @@ export const subscribeToUserUpdates = <T extends Array<keyof UserAttributes>>(
33
38
  return;
34
39
  }
35
40
 
36
- // @ts-ignore
37
- const responseAttributes: Pick<
38
- UserAttributes,
39
- T[number] | 'isLoggedIn'
40
- > = {};
41
- if (userAttributes.isLoggedIn !== undefined) {
42
- responseAttributes.isLoggedIn = userAttributes.isLoggedIn;
43
- }
44
- attributes.forEach((attribute) => {
41
+ const responseAttributes = attributes.reduce((map, attribute) => {
45
42
  if (userAttributes[attribute] !== undefined) {
46
- responseAttributes[attribute] = userAttributes[attribute];
43
+ // eslint-disable-next-line no-param-reassign
44
+ map[attribute] = userAttributes[attribute];
47
45
  }
48
- });
46
+ return map;
47
+ }, {} as Pick<UserAttributes, T[number]>);
49
48
 
50
49
  // TODO: Perhaps cache the previous response and check against that to avoid
51
50
  // TODO: unnecessary calls to onUserUpdated. The README already pretends that we do this ;)
52
51
  onUserUpdated(responseAttributes);
53
52
  });
53
+ if (onStateUpdated) {
54
+ listenForAllEvents(AmediaUserEvents.ON_STATE_UPDATED, (evt) => {
55
+ onStateUpdated(evt.detail);
56
+ });
57
+ }
54
58
  dispatch(
55
59
  new CustomEvent(AmediaUserEvents.REQUEST_USER_ATTRIBUTES, {
56
60
  detail: attributes,
package/src/types.ts CHANGED
@@ -1,11 +1,17 @@
1
+ import global from './cache/engines/global';
2
+
1
3
  export type UserAttributes = {
2
- isLoggedIn: boolean;
3
4
  name?: string;
4
5
  email?: string;
5
6
  phone?: string;
6
7
  trackingKey?: string;
7
- extraData: [];
8
- access: string[];
8
+ extraData?: [];
9
+ access?: string[];
10
+ };
11
+
12
+ export type State = {
13
+ isLoggedIn: boolean;
14
+ emergencyMode?: string[];
9
15
  };
10
16
 
11
17
  export type AnonymousAttributes = {
@@ -1,10 +1,23 @@
1
- const queue: { [key: string]: Promise<unknown>[] } = {};
1
+ import { Function } from 'runtypes';
2
2
 
3
- const add = (key: string, data: Promise<unknown>): void => {
3
+ const queue: {
4
+ [key: string]: {
5
+ resolve: (PromiseLike) => void;
6
+ reject: (reason?) => void;
7
+ }[];
8
+ } = {};
9
+
10
+ const add = (
11
+ key: string,
12
+ promiseCallbacks: {
13
+ resolve: (PromiseLike) => void;
14
+ reject: (reason?) => void;
15
+ }
16
+ ): void => {
4
17
  if (!queue[key]) {
5
18
  queue[key] = [];
6
19
  }
7
- queue[key].push(data);
20
+ queue[key].push(promiseCallbacks);
8
21
  };
9
22
 
10
23
  const getAll = (key: string) => {
@@ -16,4 +29,6 @@ const getAll = (key: string) => {
16
29
  return keyQueue;
17
30
  };
18
31
 
19
- export default { add, getAll };
32
+ const peekQueueSize = (key: string): number => queue[key]?.length || 0;
33
+
34
+ export default { add, getAll, peekQueueSize };
@@ -0,0 +1,33 @@
1
+ import {
2
+ getCurrentEnvironment,
3
+ getCurrentPublicationDomain,
4
+ setCurrentHostname,
5
+ } from './url';
6
+
7
+ describe('URL utils', () => {
8
+ it('should get proper publication domain', () => {
9
+ const domains = [
10
+ 'www.telen.no.localhost.api.no',
11
+ 'www.telen.no.snap5.api.no',
12
+ 'www.telen.no',
13
+ ];
14
+ expect.assertions(domains.length);
15
+ domains.forEach((domain) => {
16
+ setCurrentHostname(domain);
17
+ expect(getCurrentPublicationDomain()).toEqual('www.telen.no');
18
+ });
19
+ });
20
+
21
+ it('should get current environment', () => {
22
+ const domains = {
23
+ 'www.telen.no.localhost.api.no': 'localhost',
24
+ 'www.telen.no.snap5.api.no': 'snap5',
25
+ 'www.telen.no': null,
26
+ };
27
+ expect.assertions(Object.keys(domains).length);
28
+ Object.entries(domains).forEach(([domain, expectedEnvironment]) => {
29
+ setCurrentHostname(domain);
30
+ expect(getCurrentEnvironment()).toEqual(expectedEnvironment);
31
+ });
32
+ });
33
+ });
@@ -0,0 +1,22 @@
1
+ let overriddenHostname: string;
2
+ export const setCurrentHostname = (hostname: string) => {
3
+ overriddenHostname = hostname;
4
+ };
5
+
6
+ const getCurrentHostname = (): string =>
7
+ overriddenHostname || window.location.hostname;
8
+
9
+ export const getCurrentEnvironment = () => {
10
+ const matchBed = /^bed-([^.]+)\.api\.no$/.exec(getCurrentHostname());
11
+ const match = /\.([^.]+)\.api\.no/.exec(getCurrentHostname());
12
+ if (matchBed) {
13
+ return matchBed[1];
14
+ }
15
+ if (match) {
16
+ return match[1];
17
+ }
18
+ return null;
19
+ };
20
+
21
+ export const getCurrentPublicationDomain = () =>
22
+ getCurrentHostname().replace(/\.[^.]+\.api\.no/, '');
package/tsconfig.json CHANGED
@@ -4,11 +4,13 @@
4
4
  "rootDir": "./src",
5
5
  "outDir": "./dist/",
6
6
  //"noImplicitAny": true,
7
+ "declaration": true,
7
8
  "typeRoots": [
8
9
  "./node_modules/@types"
9
10
  ],
10
11
  "lib": [
11
12
  "DOM"
12
13
  ],
14
+ "module": "ES2020"
13
15
  }
14
16
  }
package/webpack.config.js CHANGED
@@ -6,7 +6,7 @@ module.exports = {
6
6
  rules: [
7
7
  {
8
8
  test: /\.tsx?$/,
9
- use: 'babel-loader',
9
+ use: [/*'babel-loader',*/ 'ts-loader'],
10
10
  exclude: /node_modules/,
11
11
  },
12
12
  {
package/.babelrc DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "presets": ["@babel/typescript", ["@babel/env", {"modules": false}]]
3
- }
@@ -1,20 +0,0 @@
1
- import { Session } from '../services/pluto';
2
- export declare enum AuthenticationEvents {
3
- REQUEST_LOGIN = "amedia_user.authentication.request_login",
4
- REQUEST_LOGOUT = "amedia_user.authentication.request_logout",
5
- REQUEST_AUTH_STATE = "amedia_user.authentication.request_auth_state",
6
- ON_AUTH_STATE_UPDATED = "amedia_user.authentication.on_auth_state_updated"
7
- }
8
- declare global {
9
- interface WindowEventMap {
10
- [AuthenticationEvents.REQUEST_LOGIN]: CustomEvent<{
11
- requestedUrl?: string;
12
- }>;
13
- [AuthenticationEvents.REQUEST_LOGOUT]: CustomEvent<{
14
- requestedUrl?: string;
15
- }>;
16
- [AuthenticationEvents.REQUEST_AUTH_STATE]: CustomEvent<Session>;
17
- [AuthenticationEvents.ON_AUTH_STATE_UPDATED]: CustomEvent<Session>;
18
- }
19
- }
20
- export declare const listenForAuthenticationRequests: () => void;
@@ -1,15 +0,0 @@
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
- }
15
- export declare const listenForAuthorizationRequests: () => void;
@@ -1,6 +0,0 @@
1
- import { Engine } from './types';
2
- export declare const get: (key: string) => Promise<unknown>;
3
- export declare const set: (key: string, data: unknown, expires: number) => Promise<void>;
4
- export declare const remove: (key: string) => Promise<void>;
5
- declare const _default: Engine;
6
- export default _default;
@@ -1,9 +0,0 @@
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;
@@ -1,5 +0,0 @@
1
- export declare type Engine = {
2
- get: (key: string) => Promise<unknown>;
3
- set: (key: string, data: unknown, expires: number) => Promise<void>;
4
- remove: (key: string) => Promise<void>;
5
- };
@@ -1,3 +0,0 @@
1
- export declare const setRootElement: (element: any) => void;
2
- export declare const listen: <T extends keyof WindowEventMap>(type: T, listener: (this: Window, ev: WindowEventMap[T]) => void) => void;
3
- export declare const dispatch: <T extends Event>(event: T) => void;
@@ -1,5 +0,0 @@
1
- declare const _default: {
2
- add: (key: string, data: unknown) => void;
3
- getAll: (key: string) => unknown[];
4
- };
5
- export default _default;
@@ -1,7 +0,0 @@
1
- export declare type UserAttributes = {
2
- isLoggedIn?: boolean;
3
- name?: string;
4
- email?: string;
5
- phone?: string;
6
- trackingKey?: string;
7
- };
@@ -1,12 +0,0 @@
1
- import { UserAttributes } from './types';
2
- export declare enum AmediaUserEvents {
3
- REQUEST_USER_ATTRIBUTES = "amedia-user.request-user-attributes",
4
- ON_USER_ATTRIBUTES_UPDATED = "amedia-user.on-user-attributes-updated"
5
- }
6
- declare global {
7
- interface WindowEventMap {
8
- [AmediaUserEvents.REQUEST_USER_ATTRIBUTES]: CustomEvent<Array<keyof UserAttributes>>;
9
- [AmediaUserEvents.ON_USER_ATTRIBUTES_UPDATED]: CustomEvent<UserAttributes>;
10
- }
11
- }
12
- export declare const listenForUserAttributeRequests: () => void;
@@ -1,9 +0,0 @@
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;