@nymphjs/tilmeld-client 1.0.0-beta.17 → 1.0.0-beta.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,18 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.0.0-beta.19](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.18...v1.0.0-beta.19) (2023-04-29)
7
+
8
+ ### Bug Fixes
9
+
10
+ - some type issues ([ee69d5d](https://github.com/sciactive/nymphjs/commit/ee69d5d73361dacda5745d697df18fafd47810bc))
11
+
12
+ # [1.0.0-beta.18](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.17...v1.0.0-beta.18) (2023-04-27)
13
+
14
+ ### Features
15
+
16
+ - add the ability to switch to a user without their password ([ca4466a](https://github.com/sciactive/nymphjs/commit/ca4466af1704d68905ac087350a8cf151c1072d9))
17
+
6
18
  # [1.0.0-beta.17](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.16...v1.0.0-beta.17) (2023-04-24)
7
19
 
8
20
  **Note:** Version bump only for package @nymphjs/tilmeld-client
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@nymphjs/client")):"function"==typeof define&&define.amd?define(["@nymphjs/client"],t):"object"==typeof exports?exports["@nymphjs/tilmeld-client"]=t(require("@nymphjs/client")):e["@nymphjs/tilmeld-client"]=t(e["@nymphjs/client"])}(this,(e=>(()=>{"use strict";var t={848:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const s=r(778);class n extends s.Entity{constructor(e){super(e),null==e&&(this.$data.enabled=!0,this.$data.abilities=[])}static async factory(e){return await super.factory(e)}static factorySync(e){return super.factorySync(e)}async $checkGroupname(){return await this.$serverCall("$checkGroupname",[],!0)}async $checkEmail(){return await this.$serverCall("$checkEmail",[],!0)}async $getAvatar(){return await this.$serverCall("$getAvatar",[],!0)}async $getChildren(){return await this.$serverCall("$getChildren",[],!0)}async $getDescendants(e=!1){return await this.$serverCall("$getDescendants",[e],!0)}async $getLevel(){return await this.$serverCall("$getLevel",[],!0)}async $isDescendant(e){return await this.$serverCall("$isDescendant",[e],!0)}static async getPrimaryGroups(e,t){return await this.serverCallStatic("getPrimaryGroups",[{options:e,class:this.class},t])}static async getSecondaryGroups(e,t){return await this.serverCallStatic("getSecondaryGroups",[{options:e,class:this.class},t])}}n.class="Group",t.default=n},178:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const s=r(778);let n=null;class a extends s.Entity{static init(e){let t={registerCallbacks:[],loginCallbacks:[],logoutCallbacks:[]};if(a.stores.has(e)){const r=a.stores.get(e);r&&(t=r)}a.stores.set(e,t),t.removeNymphResponseListener&&t.removeNymphResponseListener(),t.removeNymphResponseListener=e.on("response",(e=>this.handleToken(e))),this.handleToken()}constructor(e){super(e),null==e&&(this.$data.enabled=!0,this.$data.abilities=[],this.$data.groups=[],this.$data.inheritAbilities=!0)}static async factory(e){return await super.factory(e)}static async factoryUsername(e){const t=new this;if(null!=e){const t=await this.nymph.getEntity({class:this},{type:"&",ilike:["username",e.replace(/([\\%_])/g,(e=>`\\${e}`))]});if(null!=t)return t}return t}static factorySync(e){return super.factorySync(e)}async $checkUsername(){return await this.$serverCall("$checkUsername",[],!0)}async $checkEmail(){return await this.$serverCall("$checkEmail",[],!0)}async $checkPhone(){return await this.$serverCall("$checkPhone",[],!0)}async $getAvatar(){return await this.$serverCall("$getAvatar",[],!0)}async $register(e){const t=a.stores.get(this.$nymph);if(null==t)throw new Error("This user class was never initialized with an instance of Nymph");const r=await this.$serverCall("$register",[e]);if(r.result)for(let e=0;e<t.registerCallbacks.length;e++)t.registerCallbacks[e]&&t.registerCallbacks[e](this);if(r.loggedin){this.constructor.handleToken();for(let e=0;e<t.loginCallbacks.length;e++)t.loginCallbacks[e]&&t.loginCallbacks[e](this)}return r}async $logout(){const e=a.stores.get(this.$nymph);if(null==e)throw new Error("This user class was never initialized with an instance of Nymph");const t=await this.$serverCall("$logout",[]);if(t.result){this.constructor.handleToken();for(let t=0;t<e.logoutCallbacks.length;t++)e.logoutCallbacks[t]&&e.logoutCallbacks[t](this)}return t}async $gatekeeper(e){return await this.$serverCall("$gatekeeper",[e],!0)}async $changePassword(e){return await this.$serverCall("$changePassword",[e])}static async current(e){const t=await this.serverCallStatic("current",[!1]);return null==t?e?this.factorySync():null:t}static async loginUser(e){const t=a.stores.get(this.nymph);if(null==t)throw new Error("This user class was never initialized with an instance of Nymph");const r=await this.serverCallStatic("loginUser",[e]);if(r.result){this.handleToken();for(let e=0;e<t.loginCallbacks.length;e++)t.loginCallbacks[e]&&t.loginCallbacks[e](r.user)}return r}static async sendRecovery(e){return await this.serverCallStatic("sendRecovery",[e])}static async recover(e){return await this.serverCallStatic("recover",[e])}static async getClientConfig(){const e=a.stores.get(this.nymph);if(null==e)throw new Error("This user class was never initialized with an instance of Nymph");return e.clientConfig?e.clientConfig:(e.clientConfigPromise||(e.clientConfigPromise=this.serverCallStatic("getClientConfig",[]).then((t=>(e.clientConfig=t,e.clientConfigPromise=void 0,t)))),await e.clientConfigPromise)}static handleToken(e){let t=null;const r=/(?:(?:^|.*;\s*)TILMELDAUTH\s*=\s*([^;]*).*$)|^.*$/;if(e&&e.headers.has("X-TILMELDAUTH"))t=e.headers.get("X-TILMELDAUTH");else{if("undefined"==typeof document||!document.cookie.match(r))return;t=document.cookie.replace(r,"$1")}if(n!==t)if(null==t||""===t)null!=n&&(this.nymph.setXsrfToken(null),this.nymph.pubsub&&this.nymph.pubsub.setToken(null),n=null);else{const e=t.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),r="undefined"==typeof atob?Buffer.from(e,"base64").toString("binary"):atob(e),s=JSON.parse(r);this.nymph.setXsrfToken(s.xsrfToken),this.nymph.pubsub&&this.nymph.pubsub.setToken(t),n=t}}static on(e,t){const r=a.stores.get(this.nymph);if(null==r)throw new Error("This user class was never initialized with an instance of Nymph");const s=e+"Callbacks";if(!(s in r))throw new Error("Invalid event type.");return r[s].push(t),()=>this.off(e,t)}static off(e,t){const r=a.stores.get(this.nymph);if(null==r)throw new Error("This user class was never initialized with an instance of Nymph");const s=e+"Callbacks";if(!(s in r))return!1;const n=r[s].indexOf(t);return n>-1&&r[s].splice(n,1),!0}}a.stores=new WeakMap,a.class="User",t.default=a},13:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.checkUsername=t.register=t.login=void 0,t.login=async function(e,t,r,s){if(""===t)throw new Error("You need to enter a username.");if(""===r)throw new Error("You need to enter a password");try{const{result:n,...a}=await e.loginUser({username:t,password:r,...s?{additionalData:s}:{}});if(!n)throw new Error(a.message);return a}catch(e){throw new Error(e?.message??"An error occurred.")}},t.register=async function(e,t,r){if(""===t.username)throw new Error("You need to enter a username.");if(!t.usernameVerified)throw new Error("The username you entered is not valid.");if(t.password!==t.password2)throw new Error("Your passwords do not match.");if(""===t.password)throw new Error("You need to enter a password");let s=e.factorySync();s.username=t.username;const n=r||await e.getClientConfig();n.emailUsernames?s.email=t.username:-1!==n.regFields.indexOf("email")&&(s.email=t.email),-1!==n.regFields.indexOf("name")&&(s.nameFirst=t.nameFirst,s.nameLast=t.nameLast),-1!==n.regFields.indexOf("phone")&&(s.phone=t.phone);try{const{result:e,...r}=await s.$register({password:t.password,...t.additionalData?{additionalData:t.additionalData}:{}});if(!e)throw new Error(r.message);return{...r,user:s}}catch(e){throw new Error(e?.message??"An error occurred.")}},t.checkUsername=async function(e,t,r){let s=e.factorySync();s.username=t,(r||await e.getClientConfig()).emailUsernames&&(s.email=t);try{const{result:e,...t}=await s.$checkUsername();if(!e)throw new Error(t.message);return t}catch(e){throw new Error(e?.message??"An error occurred.")}}},568:function(e,t,r){var s=this&&this.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,n)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),n=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||s(t,e,r)},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.User=t.Group=void 0,n(r(848),t);const i=a(r(848));t.Group=i.default,n(r(13),t),n(r(178),t);const o=a(r(178));t.User=o.default},778:t=>{t.exports=e}},r={};return function e(s){var n=r[s];if(void 0!==n)return n.exports;var a=r[s]={exports:{}};return t[s].call(a.exports,a,a.exports,e),a.exports}(568)})()));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@nymphjs/client")):"function"==typeof define&&define.amd?define(["@nymphjs/client"],t):"object"==typeof exports?exports["@nymphjs/tilmeld-client"]=t(require("@nymphjs/client")):e["@nymphjs/tilmeld-client"]=t(e["@nymphjs/client"])}(this,(e=>(()=>{"use strict";var t={848:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const s=r(778);class n extends s.Entity{constructor(e){super(e),null==e&&(this.$data.enabled=!0,this.$data.abilities=[])}static async factory(e){return await super.factory(e)}static factorySync(e){return super.factorySync(e)}async $checkGroupname(){return await this.$serverCall("$checkGroupname",[],!0)}async $checkEmail(){return await this.$serverCall("$checkEmail",[],!0)}async $getAvatar(){return await this.$serverCall("$getAvatar",[],!0)}async $getChildren(){return await this.$serverCall("$getChildren",[],!0)}async $getDescendants(e=!1){return await this.$serverCall("$getDescendants",[e],!0)}async $getLevel(){return await this.$serverCall("$getLevel",[],!0)}async $isDescendant(e){return await this.$serverCall("$isDescendant",[e],!0)}static async getPrimaryGroups(e,t){return await this.serverCallStatic("getPrimaryGroups",[{options:e,class:this.class},t])}static async getSecondaryGroups(e,t){return await this.serverCallStatic("getSecondaryGroups",[{options:e,class:this.class},t])}}n.class="Group",t.default=n},178:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const s=r(778);let n=null;class a extends s.Entity{static init(e){let t={registerCallbacks:[],loginCallbacks:[],logoutCallbacks:[]};if(a.stores.has(e)){const r=a.stores.get(e);r&&(t=r)}a.stores.set(e,t),t.removeNymphResponseListener&&t.removeNymphResponseListener(),t.removeNymphResponseListener=e.on("response",(e=>this.handleToken(e))),this.handleToken()}constructor(e){super(e),null==e&&(this.$data.enabled=!0,this.$data.abilities=[],this.$data.groups=[],this.$data.inheritAbilities=!0)}static async factory(e){return await super.factory(e)}static async factoryUsername(e){const t=new this;if(null!=e){const t=await this.nymph.getEntity({class:this},{type:"&",ilike:["username",e.replace(/([\\%_])/g,(e=>`\\${e}`))]});if(null!=t)return t}return t}static factorySync(e){return super.factorySync(e)}async $checkUsername(){return await this.$serverCall("$checkUsername",[],!0)}async $checkEmail(){return await this.$serverCall("$checkEmail",[],!0)}async $checkPhone(){return await this.$serverCall("$checkPhone",[],!0)}async $getAvatar(){return await this.$serverCall("$getAvatar",[],!0)}async $register(e){const t=a.stores.get(this.$nymph);if(null==t)throw new Error("This user class was never initialized with an instance of Nymph");const r=await this.$serverCall("$register",[e]);if(r.result)for(let e=0;e<t.registerCallbacks.length;e++)t.registerCallbacks[e]&&t.registerCallbacks[e](this);if(r.loggedin){this.constructor.handleToken();for(let e=0;e<t.loginCallbacks.length;e++)t.loginCallbacks[e]&&t.loginCallbacks[e](this)}return r}async $switchUser(e){const t=a.stores.get(this.$nymph);if(null==t)throw new Error("This user class was never initialized with an instance of Nymph");const r=await this.$serverCall("$switchUser",[e]);if(r.result){this.constructor.handleToken();for(let e=0;e<t.loginCallbacks.length;e++)t.loginCallbacks[e]&&t.loginCallbacks[e](this)}return r}async $logout(){const e=a.stores.get(this.$nymph);if(null==e)throw new Error("This user class was never initialized with an instance of Nymph");const t=await this.$serverCall("$logout",[]);if(t.result){this.constructor.handleToken();for(let t=0;t<e.logoutCallbacks.length;t++)e.logoutCallbacks[t]&&e.logoutCallbacks[t](this)}return t}async $gatekeeper(e){return await this.$serverCall("$gatekeeper",[e],!0)}async $changePassword(e){return await this.$serverCall("$changePassword",[e])}static async current(e){const t=await this.serverCallStatic("current",[!1]);return null==t?e?this.factorySync():null:t}static async loginUser(e){const t=a.stores.get(this.nymph);if(null==t)throw new Error("This user class was never initialized with an instance of Nymph");const r=await this.serverCallStatic("loginUser",[e]);if(r.result){this.handleToken();for(let e=0;e<t.loginCallbacks.length;e++)t.loginCallbacks[e]&&t.loginCallbacks[e](r.user)}return r}static async sendRecovery(e){return await this.serverCallStatic("sendRecovery",[e])}static async recover(e){return await this.serverCallStatic("recover",[e])}static async getClientConfig(){const e=a.stores.get(this.nymph);if(null==e)throw new Error("This user class was never initialized with an instance of Nymph");return e.clientConfig?e.clientConfig:(e.clientConfigPromise||(e.clientConfigPromise=this.serverCallStatic("getClientConfig",[]).then((t=>(e.clientConfig=t,e.clientConfigPromise=void 0,t)))),await e.clientConfigPromise)}static handleToken(e){let t=null,r=null;const s=/(?:(?:^|.*;\s*)TILMELDAUTH\s*=\s*([^;]*).*$)|^.*$/,a=/(?:(?:^|.*;\s*)TILMELDSWITCH\s*=\s*([^;]*).*$)|^.*$/;if(e&&e.headers.has("X-TILMELDAUTH"))t=e.headers.get("X-TILMELDAUTH"),r=e.headers.get("X-TILMELDSWITCH");else{if("undefined"==typeof document||!document.cookie.match(s))return;t=document.cookie.replace(s,"$1"),r=document.cookie.replace(a,"$1")}if(n!==t)if(null==t||""===t)null!=n&&(this.nymph.setXsrfToken(null),this.nymph.pubsub&&this.nymph.pubsub.setToken(null),n=null);else{const e=t.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),s="undefined"==typeof atob?Buffer.from(e,"base64").toString("binary"):atob(e),a=JSON.parse(s);this.nymph.setXsrfToken(a.xsrfToken),this.nymph.pubsub&&this.nymph.pubsub.setToken(t,r),n=t}}static on(e,t){const r=a.stores.get(this.nymph);if(null==r)throw new Error("This user class was never initialized with an instance of Nymph");const s=e+"Callbacks";if(!(s in r))throw new Error("Invalid event type.");return r[s].push(t),()=>this.off(e,t)}static off(e,t){const r=a.stores.get(this.nymph);if(null==r)throw new Error("This user class was never initialized with an instance of Nymph");const s=e+"Callbacks";if(!(s in r))return!1;const n=r[s].indexOf(t);return n>-1&&r[s].splice(n,1),!0}}a.stores=new WeakMap,a.class="User",t.default=a},13:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.checkUsername=t.register=t.login=void 0,t.login=async function(e,t,r,s){if(""===t)throw new Error("You need to enter a username.");if(""===r)throw new Error("You need to enter a password");try{const{result:n,...a}=await e.loginUser({username:t,password:r,...s?{additionalData:s}:{}});if(!n)throw new Error(a.message);return a}catch(e){throw new Error(e?.message??"An error occurred.")}},t.register=async function(e,t,r){if(""===t.username)throw new Error("You need to enter a username.");if(!t.usernameVerified)throw new Error("The username you entered is not valid.");if(t.password!==t.password2)throw new Error("Your passwords do not match.");if(""===t.password)throw new Error("You need to enter a password");let s=e.factorySync();s.username=t.username;const n=r||await e.getClientConfig();n.emailUsernames?s.email=t.username:-1!==n.regFields.indexOf("email")&&(s.email=t.email),-1!==n.regFields.indexOf("name")&&(s.nameFirst=t.nameFirst,s.nameLast=t.nameLast),-1!==n.regFields.indexOf("phone")&&(s.phone=t.phone);try{const{result:e,...r}=await s.$register({password:t.password,...t.additionalData?{additionalData:t.additionalData}:{}});if(!e)throw new Error(r.message);return{...r,user:s}}catch(e){throw new Error(e?.message??"An error occurred.")}},t.checkUsername=async function(e,t,r){let s=e.factorySync();s.username=t,(r||await e.getClientConfig()).emailUsernames&&(s.email=t);try{const{result:e,...t}=await s.$checkUsername();if(!e)throw new Error(t.message);return t}catch(e){throw new Error(e?.message??"An error occurred.")}}},568:function(e,t,r){var s=this&&this.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,n)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),n=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||s(t,e,r)},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.User=t.Group=void 0,n(r(848),t);const i=a(r(848));t.Group=i.default,n(r(13),t),n(r(178),t);const o=a(r(178));t.User=o.default},778:t=>{t.exports=e}},r={};return function e(s){var n=r[s];if(void 0!==n)return n.exports;var a=r[s]={exports:{}};return t[s].call(a.exports,a,a.exports,e),a.exports}(568)})()));
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,EAAQG,QAAQ,oBACR,mBAAXC,QAAyBA,OAAOC,IAC9CD,OAAO,CAAC,mBAAoBJ,GACF,iBAAZC,QACdA,QAAQ,2BAA6BD,EAAQG,QAAQ,oBAErDJ,EAAK,2BAA6BC,EAAQD,EAAK,mBAChD,CATD,CASGO,MAAOC,G,wCCRVC,OAAOC,eAAeR,EAAS,aAAc,CAAES,OAAO,IACtD,MAAMC,EAAW,EAAQ,KACzB,MAAMC,UAAcD,EAASE,OACzBC,YAAYC,GACRC,MAAMD,GACM,MAARA,IACAT,KAAKW,MAAMC,SAAU,EACrBZ,KAAKW,MAAME,UAAY,GAE/B,CACAC,qBAAqBL,GACjB,aAAcC,MAAMhB,QAAQe,EAChC,CACAK,mBAAmBL,GACf,OAAOC,MAAMK,YAAYN,EAC7B,CACAO,wBACI,aAAahB,KAAKiB,YAAY,kBAAmB,IAAI,EACzD,CACAD,oBACI,aAAahB,KAAKiB,YAAY,cAAe,IAAI,EACrD,CACAD,mBACI,aAAahB,KAAKiB,YAAY,aAAc,IAAI,EAC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EAAgB7H,MAAQA,KAAK6H,cAAiB,SAAST,EAAGzH,GAC1D,IAAK,IAAImI,KAAKV,EAAa,YAANU,GAAoB5H,OAAO6H,UAAUC,eAAeC,KAAKtI,EAASmI,IAAIb,EAAgBtH,EAASyH,EAAGU,EAC3H,EACII,EAAmBlI,MAAQA,KAAKkI,iBAAoB,SAAUC,GAC9D,OAAQA,GAAOA,EAAIV,WAAcU,EAAM,CAAE,QAAWA,EACxD,EACAjI,OAAOC,eAAeR,EAAS,aAAc,CAAES,OAAO,IACtDT,EAAQ8B,KAAO9B,EAAQW,WAAQ,EAC/BuH,EAAa,EAAQ,KAAYlI,GACjC,MAAMyI,EAAUF,EAAgB,EAAQ,MACxCvI,EAAQW,MAAQ8H,EAAQC,QACxBR,EAAa,EAAQ,IAAclI,GACnCkI,EAAa,EAAQ,KAAWlI,GAChC,MAAM2I,EAASJ,EAAgB,EAAQ,MACvCvI,EAAQ8B,KAAO6G,EAAOD,O,UC1BtBzI,EAAOD,QAAUM,C,GCCbsI,EAA2B,CAAC,E,OAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBzE,IAAjB0E,EACH,OAAOA,EAAa/I,QAGrB,IAAIC,EAAS2I,EAAyBE,GAAY,CAGjD9I,QAAS,CAAC,GAOX,OAHAgJ,EAAoBF,GAAUR,KAAKrI,EAAOD,QAASC,EAAQA,EAAOD,QAAS6I,GAGpE5I,EAAOD,OACf,CCnB0B6I,CAAoB,I","sources":["webpack://@nymphjs/tilmeld-client/webpack/universalModuleDefinition","webpack://@nymphjs/tilmeld-client/./lib/Group.js","webpack://@nymphjs/tilmeld-client/./lib/User.js","webpack://@nymphjs/tilmeld-client/./lib/helpers.js","webpack://@nymphjs/tilmeld-client/./lib/index.js","webpack://@nymphjs/tilmeld-client/external umd \"@nymphjs/client\"","webpack://@nymphjs/tilmeld-client/webpack/bootstrap","webpack://@nymphjs/tilmeld-client/webpack/startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"@nymphjs/client\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"@nymphjs/client\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"@nymphjs/tilmeld-client\"] = factory(require(\"@nymphjs/client\"));\n\telse\n\t\troot[\"@nymphjs/tilmeld-client\"] = factory(root[\"@nymphjs/client\"]);\n})(this, (__WEBPACK_EXTERNAL_MODULE__778__) => {\nreturn ","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst client_1 = require(\"@nymphjs/client\");\nclass Group extends client_1.Entity {\n constructor(guid) {\n super(guid);\n if (guid == null) {\n this.$data.enabled = true;\n this.$data.abilities = [];\n }\n }\n static async factory(guid) {\n return (await super.factory(guid));\n }\n static factorySync(guid) {\n return super.factorySync(guid);\n }\n async $checkGroupname() {\n return await this.$serverCall('$checkGroupname', [], true);\n }\n async $checkEmail() {\n return await this.$serverCall('$checkEmail', [], true);\n }\n async $getAvatar() {\n return await this.$serverCall('$getAvatar', [], true);\n }\n async $getChildren() {\n return await this.$serverCall('$getChildren', [], true);\n }\n async $getDescendants(andSelf = false) {\n return await this.$serverCall('$getDescendants', [andSelf], true);\n }\n async $getLevel() {\n return await this.$serverCall('$getLevel', [], true);\n }\n async $isDescendant(givenGroup) {\n return await this.$serverCall('$isDescendant', [givenGroup], true);\n }\n static async getPrimaryGroups(options, selectors) {\n return await this.serverCallStatic('getPrimaryGroups', [\n { options, class: this.class },\n selectors,\n ]);\n }\n static async getSecondaryGroups(options, selectors) {\n return await this.serverCallStatic('getSecondaryGroups', [\n { options, class: this.class },\n selectors,\n ]);\n }\n}\nGroup.class = 'Group';\nexports.default = Group;\n//# sourceMappingURL=Group.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst client_1 = require(\"@nymphjs/client\");\nlet currentToken = null;\nclass User extends client_1.Entity {\n static init(nymph) {\n let store = {\n registerCallbacks: [],\n loginCallbacks: [],\n logoutCallbacks: [],\n };\n if (User.stores.has(nymph)) {\n const storeVal = User.stores.get(nymph);\n if (storeVal) {\n store = storeVal;\n }\n }\n User.stores.set(nymph, store);\n if (store.removeNymphResponseListener) {\n store.removeNymphResponseListener();\n }\n store.removeNymphResponseListener = nymph.on('response', (response) => this.handleToken(response));\n this.handleToken();\n }\n constructor(guid) {\n super(guid);\n if (guid == null) {\n this.$data.enabled = true;\n this.$data.abilities = [];\n this.$data.groups = [];\n this.$data.inheritAbilities = true;\n }\n }\n static async factory(guid) {\n return (await super.factory(guid));\n }\n static async factoryUsername(username) {\n const entity = new this();\n if (username != null) {\n const entity = await this.nymph.getEntity({\n class: this,\n }, {\n type: '&',\n ilike: ['username', username.replace(/([\\\\%_])/g, (s) => `\\\\${s}`)],\n });\n if (entity != null) {\n return entity;\n }\n }\n return entity;\n }\n static factorySync(guid) {\n return super.factorySync(guid);\n }\n async $checkUsername() {\n return await this.$serverCall('$checkUsername', [], true);\n }\n async $checkEmail() {\n return await this.$serverCall('$checkEmail', [], true);\n }\n async $checkPhone() {\n return await this.$serverCall('$checkPhone', [], true);\n }\n async $getAvatar() {\n return await this.$serverCall('$getAvatar', [], true);\n }\n async $register(data) {\n const store = User.stores.get(this.$nymph);\n if (store == null) {\n throw new Error('This user class was never initialized with an instance of Nymph');\n }\n const response = await this.$serverCall('$register', [data]);\n if (response.result) {\n for (let i = 0; i < store.registerCallbacks.length; i++) {\n store.registerCallbacks[i] && store.registerCallbacks[i](this);\n }\n }\n if (response.loggedin) {\n this.constructor.handleToken();\n for (let i = 0; i < store.loginCallbacks.length; i++) {\n store.loginCallbacks[i] && store.loginCallbacks[i](this);\n }\n }\n return response;\n }\n async $logout() {\n const store = User.stores.get(this.$nymph);\n if (store == null) {\n throw new Error('This user class was never initialized with an instance of Nymph');\n }\n const response = await this.$serverCall('$logout', []);\n if (response.result) {\n this.constructor.handleToken();\n for (let i = 0; i < store.logoutCallbacks.length; i++) {\n store.logoutCallbacks[i] && store.logoutCallbacks[i](this);\n }\n }\n return response;\n }\n async $gatekeeper(ability) {\n return await this.$serverCall('$gatekeeper', [ability], true);\n }\n async $changePassword(data) {\n return await this.$serverCall('$changePassword', [data]);\n }\n static async current(returnObjectIfNotExist) {\n const currentUser = await this.serverCallStatic('current', [false]);\n if (currentUser == null) {\n return returnObjectIfNotExist ? this.factorySync() : null;\n }\n return currentUser;\n }\n static async loginUser(data) {\n const store = User.stores.get(this.nymph);\n if (store == null) {\n throw new Error('This user class was never initialized with an instance of Nymph');\n }\n const response = await this.serverCallStatic('loginUser', [data]);\n if (response.result) {\n this.handleToken();\n for (let i = 0; i < store.loginCallbacks.length; i++) {\n store.loginCallbacks[i] && store.loginCallbacks[i](response.user);\n }\n }\n return response;\n }\n static async sendRecovery(data) {\n return await this.serverCallStatic('sendRecovery', [data]);\n }\n static async recover(data) {\n return await this.serverCallStatic('recover', [data]);\n }\n static async getClientConfig() {\n const store = User.stores.get(this.nymph);\n if (store == null) {\n throw new Error('This user class was never initialized with an instance of Nymph');\n }\n if (store.clientConfig) {\n return store.clientConfig;\n }\n if (!store.clientConfigPromise) {\n store.clientConfigPromise = this.serverCallStatic('getClientConfig', []).then((config) => {\n store.clientConfig = config;\n store.clientConfigPromise = undefined;\n return config;\n });\n }\n return await store.clientConfigPromise;\n }\n static handleToken(response) {\n let token = null;\n const authCookiePattern = /(?:(?:^|.*;\\s*)TILMELDAUTH\\s*=\\s*([^;]*).*$)|^.*$/;\n if (response && response.headers.has('X-TILMELDAUTH')) {\n token = response.headers.get('X-TILMELDAUTH');\n }\n else if (typeof document !== 'undefined' &&\n document.cookie.match(authCookiePattern)) {\n token = document.cookie.replace(authCookiePattern, '$1');\n }\n else {\n return;\n }\n if (currentToken !== token) {\n if (token == null || token === '') {\n if (currentToken != null) {\n this.nymph.setXsrfToken(null);\n if (this.nymph.pubsub) {\n this.nymph.pubsub.setToken(null);\n }\n currentToken = null;\n }\n }\n else {\n const base64Url = token.split('.')[1];\n const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');\n const json = typeof atob === 'undefined'\n ? Buffer.from(base64, 'base64').toString('binary')\n : atob(base64);\n const jwt = JSON.parse(json);\n this.nymph.setXsrfToken(jwt.xsrfToken);\n if (this.nymph.pubsub) {\n this.nymph.pubsub.setToken(token);\n }\n currentToken = token;\n }\n }\n }\n static on(event, callback) {\n const store = User.stores.get(this.nymph);\n if (store == null) {\n throw new Error('This user class was never initialized with an instance of Nymph');\n }\n const prop = (event + 'Callbacks');\n if (!(prop in store)) {\n throw new Error('Invalid event type.');\n }\n store[prop].push(callback);\n return () => this.off(event, callback);\n }\n static off(event, callback) {\n const store = User.stores.get(this.nymph);\n if (store == null) {\n throw new Error('This user class was never initialized with an instance of Nymph');\n }\n const prop = (event + 'Callbacks');\n if (!(prop in store)) {\n return false;\n }\n const i = store[prop].indexOf(callback);\n if (i > -1) {\n store[prop].splice(i, 1);\n }\n return true;\n }\n}\nUser.stores = new WeakMap();\nUser.class = 'User';\nexports.default = User;\n//# sourceMappingURL=User.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.checkUsername = exports.register = exports.login = void 0;\nasync function login(User, username, password, additionalData) {\n if (username === '') {\n throw new Error('You need to enter a username.');\n }\n if (password === '') {\n throw new Error('You need to enter a password');\n }\n try {\n const { result, ...response } = await User.loginUser({\n username,\n password,\n ...(additionalData ? { additionalData } : {}),\n });\n if (!result) {\n throw new Error(response.message);\n }\n return response;\n }\n catch (e) {\n throw new Error(e?.message ?? 'An error occurred.');\n }\n}\nexports.login = login;\nasync function register(User, userDetails, clientConfig) {\n if (userDetails.username === '') {\n throw new Error('You need to enter a username.');\n }\n if (!userDetails.usernameVerified) {\n throw new Error('The username you entered is not valid.');\n }\n if (userDetails.password !== userDetails.password2) {\n throw new Error('Your passwords do not match.');\n }\n if (userDetails.password === '') {\n throw new Error('You need to enter a password');\n }\n let user = User.factorySync();\n user.username = userDetails.username;\n const config = clientConfig || (await User.getClientConfig());\n if (config.emailUsernames) {\n user.email = userDetails.username;\n }\n else if (config.regFields.indexOf('email') !== -1) {\n user.email = userDetails.email;\n }\n if (config.regFields.indexOf('name') !== -1) {\n user.nameFirst = userDetails.nameFirst;\n user.nameLast = userDetails.nameLast;\n }\n if (config.regFields.indexOf('phone') !== -1) {\n user.phone = userDetails.phone;\n }\n try {\n const { result, ...response } = await user.$register({\n password: userDetails.password,\n ...(userDetails.additionalData\n ? { additionalData: userDetails.additionalData }\n : {}),\n });\n if (!result) {\n throw new Error(response.message);\n }\n return { ...response, user };\n }\n catch (e) {\n throw new Error(e?.message ?? 'An error occurred.');\n }\n}\nexports.register = register;\nasync function checkUsername(User, username, clientConfig) {\n let user = User.factorySync();\n user.username = username;\n const config = clientConfig || (await User.getClientConfig());\n if (config.emailUsernames) {\n user.email = username;\n }\n try {\n const { result, ...response } = await user.$checkUsername();\n if (!result) {\n throw new Error(response.message);\n }\n return response;\n }\n catch (e) {\n throw new Error(e?.message ?? 'An error occurred.');\n }\n}\nexports.checkUsername = checkUsername;\n//# sourceMappingURL=helpers.js.map","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.User = exports.Group = void 0;\n__exportStar(require(\"./Group\"), exports);\nconst Group_1 = __importDefault(require(\"./Group\"));\nexports.Group = Group_1.default;\n__exportStar(require(\"./helpers\"), exports);\n__exportStar(require(\"./User\"), exports);\nconst User_1 = __importDefault(require(\"./User\"));\nexports.User = User_1.default;\n//# sourceMappingURL=index.js.map","module.exports = __WEBPACK_EXTERNAL_MODULE__778__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(568);\n"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE__778__","Object","defineProperty","value","client_1","Group","Entity","constructor","guid","super","$data","enabled","abilities","static","factorySync","async","$serverCall","andSelf","givenGroup","options","selectors","serverCallStatic","class","currentToken","User","nymph","store","registerCallbacks","loginCallbacks","logoutCallbacks","stores","has","storeVal","get","set","removeNymphResponseListener","on","response","handleToken","groups","inheritAbilities","username","entity","getEntity","type","ilike","replace","s","data","$nymph","Error","result","i","length","loggedin","ability","returnObjectIfNotExist","currentUser","user","clientConfig","clientConfigPromise","then","config","undefined","token","authCookiePattern","headers","document","cookie","match","setXsrfToken","pubsub","setToken","base64","split","json","atob","Buffer","from","toString","jwt","JSON","parse","xsrfToken","event","callback","prop","push","off","indexOf","splice","WeakMap","checkUsername","register","login","password","additionalData","loginUser","message","e","userDetails","usernameVerified","password2","getClientConfig","emailUsernames","email","regFields","nameFirst","nameLast","phone","$register","$checkUsername","__createBinding","create","o","m","k","k2","desc","getOwnPropertyDescriptor","__esModule","writable","configurable","enumerable","__exportStar","p","prototype","hasOwnProperty","call","__importDefault","mod","Group_1","default","User_1","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","__webpack_modules__"],"sourceRoot":""}
1
+ {"version":3,"file":"index.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,EAAQG,QAAQ,oBACR,mBAAXC,QAAyBA,OAAOC,IAC9CD,OAAO,CAAC,mBAAoBJ,GACF,iBAAZC,QACdA,QAAQ,2BAA6BD,EAAQG,QAAQ,oBAErDJ,EAAK,2BAA6BC,EAAQD,EAAK,mBAChD,CATD,CASGO,MAAOC,G,wCCRVC,OAAOC,eAAeR,EAAS,aAAc,CAAES,OAAO,IACtD,MAAMC,EAAW,EAAQ,KACzB,MAAMC,UAAcD,EAASE,OACzBC,YAAYC,GACRC,MAAMD,GACM,MAARA,IACAT,KAAKW,MAAMC,SAAU,EACrBZ,KAAKW,MAAME,UAAY,GAE/B,CACAC,qBAAqBL,GACjB,aAAcC,MAAMhB,QAAQe,EAChC,CACAK,mBAAmBL,GACf,OAAOC,MAAMK,YAAYN,EAC7B,CACAO,wBACI,aAAahB,KAAKiB,YAAY,kBAAmB,IAAI,EACzD,CACAD,oBACI,aAAahB,KAAKiB,YAAY,cAAe,IAAI,EACrD,CACAD,mBACI,aAAahB,KAAKiB,YAAY,aAAc,IAAI,EACpD,CACAD,qBACI,aAAahB,KAAKiB,YAAY,eAAgB,IAAI,EACtD,CACAD,sBAAsBE,GAAU,GAC5B,aAAalB,KAAKiB,YAAY,kBAAmB,CAACC,IAAU,EAChE,CACAF,kBACI,aAAahB,KAAKiB,YAAY,YAAa,IAAI,EACnD,CACAD,oBAAoBG,GAChB,aAAanB,KAAKiB,YAAY,gBAAiB,CAACE,IAAa,EACjE,CACAL,8BAA8BM,EAASC,GACnC,aAAarB,KAAKsB,i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AAOoF,EAAEC,EAAI,IAE5DrH,OAAOC,eAAekH,EAAGG,EAAIC,EAChC,EAAI,SAAUJ,EAAGC,EAAGC,EAAGC,QACTxD,IAAPwD,IAAkBA,EAAKD,GAC3BF,EAAEG,GAAMF,EAAEC,EACb,GACGQ,EAAgB/H,MAAQA,KAAK+H,cAAiB,SAAST,EAAG3H,GAC1D,IAAK,IAAIqI,KAAKV,EAAa,YAANU,GAAoB9H,OAAO+H,UAAUC,eAAeC,KAAKxI,EAASqI,IAAIb,EAAgBxH,EAAS2H,EAAGU,EAC3H,EACII,EAAmBpI,MAAQA,KAAKoI,iBAAoB,SAAUC,GAC9D,OAAQA,GAAOA,EAAIV,WAAcU,EAAM,CAAE,QAAWA,EACxD,EACAnI,OAAOC,eAAeR,EAAS,aAAc,CAAES,OAAO,IACtDT,EAAQ8B,KAAO9B,EAAQW,WAAQ,EAC/ByH,EAAa,EAAQ,KAAYpI,GACjC,MAAM2I,EAAUF,EAAgB,EAAQ,MACxCzI,EAAQW,MAAQgI,EAAQC,QACxBR,EAAa,EAAQ,IAAcpI,GACnCoI,EAAa,EAAQ,KAAWpI,GAChC,MAAM6I,EAASJ,EAAgB,EAAQ,MACvCzI,EAAQ8B,KAAO+G,EAAOD,O,UC1BtB3I,EAAOD,QAAUM,C,GCCbwI,EAA2B,CAAC,E,OAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqB3E,IAAjB4E,EACH,OAAOA,EAAajJ,QAGrB,IAAIC,EAAS6I,EAAyBE,GAAY,CAGjDhJ,QAAS,CAAC,GAOX,OAHAkJ,EAAoBF,GAAUR,KAAKvI,EAAOD,QAASC,EAAQA,EAAOD,QAAS+I,GAGpE9I,EAAOD,OACf,CCnB0B+I,CAAoB,I","sources":["webpack://@nymphjs/tilmeld-client/webpack/universalModuleDefinition","webpack://@nymphjs/tilmeld-client/./lib/Group.js","webpack://@nymphjs/tilmeld-client/./lib/User.js","webpack://@nymphjs/tilmeld-client/./lib/helpers.js","webpack://@nymphjs/tilmeld-client/./lib/index.js","webpack://@nymphjs/tilmeld-client/external umd \"@nymphjs/client\"","webpack://@nymphjs/tilmeld-client/webpack/bootstrap","webpack://@nymphjs/tilmeld-client/webpack/startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"@nymphjs/client\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"@nymphjs/client\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"@nymphjs/tilmeld-client\"] = factory(require(\"@nymphjs/client\"));\n\telse\n\t\troot[\"@nymphjs/tilmeld-client\"] = factory(root[\"@nymphjs/client\"]);\n})(this, (__WEBPACK_EXTERNAL_MODULE__778__) => {\nreturn ","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst client_1 = require(\"@nymphjs/client\");\nclass Group extends client_1.Entity {\n constructor(guid) {\n super(guid);\n if (guid == null) {\n this.$data.enabled = true;\n this.$data.abilities = [];\n }\n }\n static async factory(guid) {\n return (await super.factory(guid));\n }\n static factorySync(guid) {\n return super.factorySync(guid);\n }\n async $checkGroupname() {\n return await this.$serverCall('$checkGroupname', [], true);\n }\n async $checkEmail() {\n return await this.$serverCall('$checkEmail', [], true);\n }\n async $getAvatar() {\n return await this.$serverCall('$getAvatar', [], true);\n }\n async $getChildren() {\n return await this.$serverCall('$getChildren', [], true);\n }\n async $getDescendants(andSelf = false) {\n return await this.$serverCall('$getDescendants', [andSelf], true);\n }\n async $getLevel() {\n return await this.$serverCall('$getLevel', [], true);\n }\n async $isDescendant(givenGroup) {\n return await this.$serverCall('$isDescendant', [givenGroup], true);\n }\n static async getPrimaryGroups(options, selectors) {\n return await this.serverCallStatic('getPrimaryGroups', [\n { options, class: this.class },\n selectors,\n ]);\n }\n static async getSecondaryGroups(options, selectors) {\n return await this.serverCallStatic('getSecondaryGroups', [\n { options, class: this.class },\n selectors,\n ]);\n }\n}\nGroup.class = 'Group';\nexports.default = Group;\n//# sourceMappingURL=Group.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst client_1 = require(\"@nymphjs/client\");\nlet currentToken = null;\nclass User extends client_1.Entity {\n static init(nymph) {\n let store = {\n registerCallbacks: [],\n loginCallbacks: [],\n logoutCallbacks: [],\n };\n if (User.stores.has(nymph)) {\n const storeVal = User.stores.get(nymph);\n if (storeVal) {\n store = storeVal;\n }\n }\n User.stores.set(nymph, store);\n if (store.removeNymphResponseListener) {\n store.removeNymphResponseListener();\n }\n store.removeNymphResponseListener = nymph.on('response', (response) => this.handleToken(response));\n this.handleToken();\n }\n constructor(guid) {\n super(guid);\n if (guid == null) {\n this.$data.enabled = true;\n this.$data.abilities = [];\n this.$data.groups = [];\n this.$data.inheritAbilities = true;\n }\n }\n static async factory(guid) {\n return (await super.factory(guid));\n }\n static async factoryUsername(username) {\n const entity = new this();\n if (username != null) {\n const entity = await this.nymph.getEntity({\n class: this,\n }, {\n type: '&',\n ilike: ['username', username.replace(/([\\\\%_])/g, (s) => `\\\\${s}`)],\n });\n if (entity != null) {\n return entity;\n }\n }\n return entity;\n }\n static factorySync(guid) {\n return super.factorySync(guid);\n }\n async $checkUsername() {\n return await this.$serverCall('$checkUsername', [], true);\n }\n async $checkEmail() {\n return await this.$serverCall('$checkEmail', [], true);\n }\n async $checkPhone() {\n return await this.$serverCall('$checkPhone', [], true);\n }\n async $getAvatar() {\n return await this.$serverCall('$getAvatar', [], true);\n }\n async $register(data) {\n const store = User.stores.get(this.$nymph);\n if (store == null) {\n throw new Error('This user class was never initialized with an instance of Nymph');\n }\n const response = await this.$serverCall('$register', [data]);\n if (response.result) {\n for (let i = 0; i < store.registerCallbacks.length; i++) {\n store.registerCallbacks[i] && store.registerCallbacks[i](this);\n }\n }\n if (response.loggedin) {\n this.constructor.handleToken();\n for (let i = 0; i < store.loginCallbacks.length; i++) {\n store.loginCallbacks[i] && store.loginCallbacks[i](this);\n }\n }\n return response;\n }\n async $switchUser(data) {\n const store = User.stores.get(this.$nymph);\n if (store == null) {\n throw new Error('This user class was never initialized with an instance of Nymph');\n }\n const response = await this.$serverCall('$switchUser', [data]);\n if (response.result) {\n this.constructor.handleToken();\n for (let i = 0; i < store.loginCallbacks.length; i++) {\n store.loginCallbacks[i] && store.loginCallbacks[i](this);\n }\n }\n return response;\n }\n async $logout() {\n const store = User.stores.get(this.$nymph);\n if (store == null) {\n throw new Error('This user class was never initialized with an instance of Nymph');\n }\n const response = await this.$serverCall('$logout', []);\n if (response.result) {\n this.constructor.handleToken();\n for (let i = 0; i < store.logoutCallbacks.length; i++) {\n store.logoutCallbacks[i] && store.logoutCallbacks[i](this);\n }\n }\n return response;\n }\n async $gatekeeper(ability) {\n return await this.$serverCall('$gatekeeper', [ability], true);\n }\n async $changePassword(data) {\n return await this.$serverCall('$changePassword', [data]);\n }\n static async current(returnObjectIfNotExist) {\n const currentUser = await this.serverCallStatic('current', [false]);\n if (currentUser == null) {\n return returnObjectIfNotExist ? this.factorySync() : null;\n }\n return currentUser;\n }\n static async loginUser(data) {\n const store = User.stores.get(this.nymph);\n if (store == null) {\n throw new Error('This user class was never initialized with an instance of Nymph');\n }\n const response = await this.serverCallStatic('loginUser', [data]);\n if (response.result) {\n this.handleToken();\n for (let i = 0; i < store.loginCallbacks.length; i++) {\n store.loginCallbacks[i] && store.loginCallbacks[i](response.user);\n }\n }\n return response;\n }\n static async sendRecovery(data) {\n return await this.serverCallStatic('sendRecovery', [data]);\n }\n static async recover(data) {\n return await this.serverCallStatic('recover', [data]);\n }\n static async getClientConfig() {\n const store = User.stores.get(this.nymph);\n if (store == null) {\n throw new Error('This user class was never initialized with an instance of Nymph');\n }\n if (store.clientConfig) {\n return store.clientConfig;\n }\n if (!store.clientConfigPromise) {\n store.clientConfigPromise = this.serverCallStatic('getClientConfig', []).then((config) => {\n store.clientConfig = config;\n store.clientConfigPromise = undefined;\n return config;\n });\n }\n return await store.clientConfigPromise;\n }\n static handleToken(response) {\n let token = null;\n let switchToken = null;\n const authCookiePattern = /(?:(?:^|.*;\\s*)TILMELDAUTH\\s*=\\s*([^;]*).*$)|^.*$/;\n const switchCookiePattern = /(?:(?:^|.*;\\s*)TILMELDSWITCH\\s*=\\s*([^;]*).*$)|^.*$/;\n if (response && response.headers.has('X-TILMELDAUTH')) {\n token = response.headers.get('X-TILMELDAUTH');\n switchToken = response.headers.get('X-TILMELDSWITCH');\n }\n else if (typeof document !== 'undefined' &&\n document.cookie.match(authCookiePattern)) {\n token = document.cookie.replace(authCookiePattern, '$1');\n switchToken = document.cookie.replace(switchCookiePattern, '$1');\n }\n else {\n return;\n }\n if (currentToken !== token) {\n if (token == null || token === '') {\n if (currentToken != null) {\n this.nymph.setXsrfToken(null);\n if (this.nymph.pubsub) {\n this.nymph.pubsub.setToken(null);\n }\n currentToken = null;\n }\n }\n else {\n const base64Url = token.split('.')[1];\n const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');\n const json = typeof atob === 'undefined'\n ? Buffer.from(base64, 'base64').toString('binary')\n : atob(base64);\n const jwt = JSON.parse(json);\n this.nymph.setXsrfToken(jwt.xsrfToken);\n if (this.nymph.pubsub) {\n this.nymph.pubsub.setToken(token, switchToken);\n }\n currentToken = token;\n }\n }\n }\n static on(event, callback) {\n const store = User.stores.get(this.nymph);\n if (store == null) {\n throw new Error('This user class was never initialized with an instance of Nymph');\n }\n const prop = (event + 'Callbacks');\n if (!(prop in store)) {\n throw new Error('Invalid event type.');\n }\n store[prop].push(callback);\n return () => this.off(event, callback);\n }\n static off(event, callback) {\n const store = User.stores.get(this.nymph);\n if (store == null) {\n throw new Error('This user class was never initialized with an instance of Nymph');\n }\n const prop = (event + 'Callbacks');\n if (!(prop in store)) {\n return false;\n }\n const i = store[prop].indexOf(callback);\n if (i > -1) {\n store[prop].splice(i, 1);\n }\n return true;\n }\n}\nUser.stores = new WeakMap();\nUser.class = 'User';\nexports.default = User;\n//# sourceMappingURL=User.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.checkUsername = exports.register = exports.login = void 0;\nasync function login(User, username, password, additionalData) {\n if (username === '') {\n throw new Error('You need to enter a username.');\n }\n if (password === '') {\n throw new Error('You need to enter a password');\n }\n try {\n const { result, ...response } = await User.loginUser({\n username,\n password,\n ...(additionalData ? { additionalData } : {}),\n });\n if (!result) {\n throw new Error(response.message);\n }\n return response;\n }\n catch (e) {\n throw new Error(e?.message ?? 'An error occurred.');\n }\n}\nexports.login = login;\nasync function register(User, userDetails, clientConfig) {\n if (userDetails.username === '') {\n throw new Error('You need to enter a username.');\n }\n if (!userDetails.usernameVerified) {\n throw new Error('The username you entered is not valid.');\n }\n if (userDetails.password !== userDetails.password2) {\n throw new Error('Your passwords do not match.');\n }\n if (userDetails.password === '') {\n throw new Error('You need to enter a password');\n }\n let user = User.factorySync();\n user.username = userDetails.username;\n const config = clientConfig || (await User.getClientConfig());\n if (config.emailUsernames) {\n user.email = userDetails.username;\n }\n else if (config.regFields.indexOf('email') !== -1) {\n user.email = userDetails.email;\n }\n if (config.regFields.indexOf('name') !== -1) {\n user.nameFirst = userDetails.nameFirst;\n user.nameLast = userDetails.nameLast;\n }\n if (config.regFields.indexOf('phone') !== -1) {\n user.phone = userDetails.phone;\n }\n try {\n const { result, ...response } = await user.$register({\n password: userDetails.password,\n ...(userDetails.additionalData\n ? { additionalData: userDetails.additionalData }\n : {}),\n });\n if (!result) {\n throw new Error(response.message);\n }\n return { ...response, user };\n }\n catch (e) {\n throw new Error(e?.message ?? 'An error occurred.');\n }\n}\nexports.register = register;\nasync function checkUsername(User, username, clientConfig) {\n let user = User.factorySync();\n user.username = username;\n const config = clientConfig || (await User.getClientConfig());\n if (config.emailUsernames) {\n user.email = username;\n }\n try {\n const { result, ...response } = await user.$checkUsername();\n if (!result) {\n throw new Error(response.message);\n }\n return response;\n }\n catch (e) {\n throw new Error(e?.message ?? 'An error occurred.');\n }\n}\nexports.checkUsername = checkUsername;\n//# sourceMappingURL=helpers.js.map","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.User = exports.Group = void 0;\n__exportStar(require(\"./Group\"), exports);\nconst Group_1 = __importDefault(require(\"./Group\"));\nexports.Group = Group_1.default;\n__exportStar(require(\"./helpers\"), exports);\n__exportStar(require(\"./User\"), exports);\nconst User_1 = __importDefault(require(\"./User\"));\nexports.User = User_1.default;\n//# sourceMappingURL=index.js.map","module.exports = __WEBPACK_EXTERNAL_MODULE__778__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(568);\n"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE__778__","Object","defineProperty","value","client_1","Group","Entity","constructor","guid","super","$data","enabled","abilities","static","factorySync","async","$serverCall","andSelf","givenGroup","options","selectors","serverCallStatic","class","currentToken","User","nymph","store","registerCallbacks","loginCallbacks","logoutCallbacks","stores","has","storeVal","get","set","removeNymphResponseListener","on","response","handleToken","groups","inheritAbilities","username","entity","getEntity","type","ilike","replace","s","data","$nymph","Error","result","i","length","loggedin","ability","returnObjectIfNotExist","currentUser","user","clientConfig","clientConfigPromise","then","config","undefined","token","switchToken","authCookiePattern","switchCookiePattern","headers","document","cookie","match","setXsrfToken","pubsub","setToken","base64","split","json","atob","Buffer","from","toString","jwt","JSON","parse","xsrfToken","event","callback","prop","push","off","indexOf","splice","WeakMap","checkUsername","register","login","password","additionalData","loginUser","message","e","userDetails","usernameVerified","password2","getClientConfig","emailUsernames","email","regFields","nameFirst","nameLast","phone","$register","$checkUsername","__createBinding","create","o","m","k","k2","desc","getOwnPropertyDescriptor","__esModule","writable","configurable","enumerable","__exportStar","p","prototype","hasOwnProperty","call","__importDefault","mod","Group_1","default","User_1","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","__webpack_modules__"],"sourceRoot":""}
package/lib/User.d.ts CHANGED
@@ -31,6 +31,7 @@ export type CurrentUserData = UserData & {
31
31
  group?: Group & CurrentGroupData;
32
32
  groups?: (Group & CurrentGroupData)[];
33
33
  inheritAbilities?: boolean;
34
+ newEmailAddress?: string;
34
35
  };
35
36
  export type AdminUserData = CurrentUserData & {
36
37
  group?: Group & AdminGroupData;
@@ -84,6 +85,14 @@ export default class User extends Entity<UserData> {
84
85
  loggedin: boolean;
85
86
  message: string;
86
87
  }>;
88
+ $switchUser(data?: {
89
+ additionalData?: {
90
+ [k: string]: any;
91
+ };
92
+ }): Promise<{
93
+ result: boolean;
94
+ message: string;
95
+ }>;
87
96
  $logout(): Promise<{
88
97
  result: boolean;
89
98
  message: string;
package/lib/User.js CHANGED
@@ -83,6 +83,20 @@ class User extends client_1.Entity {
83
83
  }
84
84
  return response;
85
85
  }
86
+ async $switchUser(data) {
87
+ const store = User.stores.get(this.$nymph);
88
+ if (store == null) {
89
+ throw new Error('This user class was never initialized with an instance of Nymph');
90
+ }
91
+ const response = await this.$serverCall('$switchUser', [data]);
92
+ if (response.result) {
93
+ this.constructor.handleToken();
94
+ for (let i = 0; i < store.loginCallbacks.length; i++) {
95
+ store.loginCallbacks[i] && store.loginCallbacks[i](this);
96
+ }
97
+ }
98
+ return response;
99
+ }
86
100
  async $logout() {
87
101
  const store = User.stores.get(this.$nymph);
88
102
  if (store == null) {
@@ -149,13 +163,17 @@ class User extends client_1.Entity {
149
163
  }
150
164
  static handleToken(response) {
151
165
  let token = null;
166
+ let switchToken = null;
152
167
  const authCookiePattern = /(?:(?:^|.*;\s*)TILMELDAUTH\s*=\s*([^;]*).*$)|^.*$/;
168
+ const switchCookiePattern = /(?:(?:^|.*;\s*)TILMELDSWITCH\s*=\s*([^;]*).*$)|^.*$/;
153
169
  if (response && response.headers.has('X-TILMELDAUTH')) {
154
170
  token = response.headers.get('X-TILMELDAUTH');
171
+ switchToken = response.headers.get('X-TILMELDSWITCH');
155
172
  }
156
173
  else if (typeof document !== 'undefined' &&
157
174
  document.cookie.match(authCookiePattern)) {
158
175
  token = document.cookie.replace(authCookiePattern, '$1');
176
+ switchToken = document.cookie.replace(switchCookiePattern, '$1');
159
177
  }
160
178
  else {
161
179
  return;
@@ -179,7 +197,7 @@ class User extends client_1.Entity {
179
197
  const jwt = JSON.parse(json);
180
198
  this.nymph.setXsrfToken(jwt.xsrfToken);
181
199
  if (this.nymph.pubsub) {
182
- this.nymph.pubsub.setToken(token);
200
+ this.nymph.pubsub.setToken(token, switchToken);
183
201
  }
184
202
  currentToken = token;
185
203
  }
package/lib/User.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"User.js","sourceRoot":"","sources":["../src/User.ts"],"names":[],"mappings":";;AAAA,4CAAgD;AA+Hh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,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC1C,IAAI,KAAK,IAAI,IAAI,EAAE;YACjB,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAC;SACH;QAED,MAAM,IAAI,GAAG,CAAC,KAAK,GAAG,WAAW,CAMxB,CAAC;QACV,IAAI,CAAC,CAAC,IAAI,IAAI,KAAK,CAAC,EAAE;YACpB,OAAO,KAAK,CAAC;SACd;QAED,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACxC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE;YAEV,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SAC1B;QACD,OAAO,IAAI,CAAC;IACd,CAAC;;AA5WgB,WAAM,GAAG,IAAI,OAAO,EAAwB,CAAC;AAGhD,UAAK,GAAG,MAAM,CAAC;kBAJV,IAAI"}
package/lib/helpers.d.ts CHANGED
@@ -34,6 +34,7 @@ export declare function login(User: typeof UserClass, username: string, password
34
34
  user?: (UserClass & import("./User").UserData & any) | null | undefined;
35
35
  })[] | undefined;
36
36
  inheritAbilities?: boolean | undefined;
37
+ newEmailAddress?: string | undefined;
37
38
  }) | undefined;
38
39
  }>;
39
40
  export declare function register(User: typeof UserClass, userDetails: RegistrationDetails, clientConfig?: ClientConfig): Promise<{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nymphjs/tilmeld-client",
3
- "version": "1.0.0-beta.17",
3
+ "version": "1.0.0-beta.19",
4
4
  "description": "NymphJS - Tilmeld Client",
5
5
  "browser": "dist/index.js",
6
6
  "main": "lib/index.js",
@@ -46,7 +46,7 @@
46
46
  "webpack-cli": "^5.0.2"
47
47
  },
48
48
  "dependencies": {
49
- "@nymphjs/client": "^1.0.0-beta.17"
49
+ "@nymphjs/client": "^1.0.0-beta.19"
50
50
  },
51
- "gitHead": "5cb62a425927116ac34340210235ccb50d190ff3"
51
+ "gitHead": "753e9db945a8847f5664495c79fc4e717fd49303"
52
52
  }
package/src/User.ts CHANGED
@@ -76,6 +76,11 @@ export type CurrentUserData = UserData & {
76
76
  * Whether the user should inherit the abilities of his groups.
77
77
  */
78
78
  inheritAbilities?: boolean;
79
+ /**
80
+ * If the user has changed their email address, this is the new one, awaiting
81
+ * verification.
82
+ */
83
+ newEmailAddress?: string;
79
84
  };
80
85
 
81
86
  export type AdminUserData = CurrentUserData & {
@@ -257,6 +262,29 @@ export default class User extends Entity<UserData> {
257
262
  return response;
258
263
  }
259
264
 
265
+ public async $switchUser(data?: {
266
+ additionalData?: { [k: string]: any };
267
+ }): Promise<{
268
+ result: boolean;
269
+ message: string;
270
+ }> {
271
+ const store = User.stores.get(this.$nymph);
272
+ if (store == null) {
273
+ throw new Error(
274
+ 'This user class was never initialized with an instance of Nymph'
275
+ );
276
+ }
277
+
278
+ const response = await this.$serverCall('$switchUser', [data]);
279
+ if (response.result) {
280
+ (this.constructor as typeof User).handleToken();
281
+ for (let i = 0; i < store.loginCallbacks.length; i++) {
282
+ store.loginCallbacks[i] && store.loginCallbacks[i](this);
283
+ }
284
+ }
285
+ return response;
286
+ }
287
+
260
288
  public async $logout(): Promise<{ result: boolean; message: string }> {
261
289
  const store = User.stores.get(this.$nymph);
262
290
  if (store == null) {
@@ -369,15 +397,20 @@ export default class User extends Entity<UserData> {
369
397
 
370
398
  private static handleToken(response?: Response) {
371
399
  let token: string | null = null;
400
+ let switchToken: string | null = null;
372
401
  const authCookiePattern =
373
402
  /(?:(?:^|.*;\s*)TILMELDAUTH\s*=\s*([^;]*).*$)|^.*$/;
403
+ const switchCookiePattern =
404
+ /(?:(?:^|.*;\s*)TILMELDSWITCH\s*=\s*([^;]*).*$)|^.*$/;
374
405
  if (response && response.headers.has('X-TILMELDAUTH')) {
375
406
  token = response.headers.get('X-TILMELDAUTH');
407
+ switchToken = response.headers.get('X-TILMELDSWITCH');
376
408
  } else if (
377
409
  typeof document !== 'undefined' &&
378
410
  document.cookie.match(authCookiePattern)
379
411
  ) {
380
412
  token = document.cookie.replace(authCookiePattern, '$1');
413
+ switchToken = document.cookie.replace(switchCookiePattern, '$1');
381
414
  } else {
382
415
  return;
383
416
  }
@@ -400,7 +433,7 @@ export default class User extends Entity<UserData> {
400
433
  const jwt = JSON.parse(json);
401
434
  this.nymph.setXsrfToken(jwt.xsrfToken);
402
435
  if (this.nymph.pubsub) {
403
- this.nymph.pubsub.setToken(token);
436
+ this.nymph.pubsub.setToken(token, switchToken);
404
437
  }
405
438
  currentToken = token;
406
439
  }