@nymphjs/tilmeld-client 1.0.0-beta.20 → 1.0.0-beta.21

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,12 @@
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.21](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.20...v1.0.0-beta.21) (2023-05-01)
7
+
8
+ ### Features
9
+
10
+ - add totp two factor authentication ([cc9f8ed](https://github.com/sciactive/nymphjs/commit/cc9f8edb183271fa7f51e4b182b876efb8fa0f8d))
11
+
6
12
  # [1.0.0-beta.20](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.19...v1.0.0-beta.20) (2023-04-30)
7
13
 
8
14
  ### Features
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 $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])}async $revokeCurrentTokens(e){return await this.$serverCall("$revokeCurrentTokens",[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)})()));
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])}async $revokeCurrentTokens(e){return await this.$serverCall("$revokeCurrentTokens",[e])}async $hasTOTPSecret(){return await this.$serverCall("$hasTOTPSecret",[],!0)}async $getNewTOTPSecret(){return await this.$serverCall("$getNewTOTPSecret",[],!0)}async $saveTOTPSecret(e){return await this.$serverCall("$saveTOTPSecret",[e])}async $removeTOTPSecret(e){return await this.$serverCall("$removeTOTPSecret",[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=t.NeedTOTPError=void 0;class r extends Error{}t.NeedTOTPError=r,t.login=async function(e,t,s,n,a){if(""===t)throw new Error("You need to enter a username.");if(""===s)throw new Error("You need to enter a password");try{const{result:i,needTOTP:o,...l}=await e.loginUser({username:t,password:s,code:n,...a?{additionalData:a}:{}});if(!i){if(o)throw new r(l.message);throw new Error(l.message)}return l}catch(e){if(e instanceof r)throw 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,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D,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 async $revokeCurrentTokens(data) {\n return await this.$serverCall('$revokeCurrentTokens', [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":""}
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,CACA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AAES,OAAO,IACtDT,EAAQ8B,KAAO9B,EAAQW,WAAQ,EAC/B4H,EAAa,EAAQ,KAAYvI,GACjC,MAAM8I,EAAUF,EAAgB,EAAQ,MACxC5I,EAAQW,MAAQmI,EAAQC,QACxBR,EAAa,EAAQ,IAAcvI,GACnCuI,EAAa,EAAQ,KAAWvI,GAChC,MAAMgJ,EAASJ,EAAgB,EAAQ,MACvC5I,EAAQ8B,KAAOkH,EAAOD,O,UC1BtB9I,EAAOD,QAAUM,C,GCCb2I,EAA2B,CAAC,E,OAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqB9E,IAAjB+E,EACH,OAAOA,EAAapJ,QAGrB,IAAIC,EAASgJ,EAAyBE,GAAY,CAGjDnJ,QAAS,CAAC,GAOX,OAHAqJ,EAAoBF,GAAUR,KAAK1I,EAAOD,QAASC,EAAQA,EAAOD,QAASkJ,GAGpEjJ,EAAOD,OACf,CCnB0BkJ,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 async $revokeCurrentTokens(data) {\n return await this.$serverCall('$revokeCurrentTokens', [data]);\n }\n async $hasTOTPSecret() {\n return await this.$serverCall('$hasTOTPSecret', [], true);\n }\n async $getNewTOTPSecret() {\n return await this.$serverCall('$getNewTOTPSecret', [], true);\n }\n async $saveTOTPSecret(data) {\n return await this.$serverCall('$saveTOTPSecret', [data]);\n }\n async $removeTOTPSecret(data) {\n return await this.$serverCall('$removeTOTPSecret', [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 = exports.NeedTOTPError = void 0;\nclass NeedTOTPError extends Error {\n}\nexports.NeedTOTPError = NeedTOTPError;\nasync function login(User, username, password, code, 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, needTOTP, ...response } = await User.loginUser({\n username,\n password,\n code,\n ...(additionalData ? { additionalData } : {}),\n });\n if (!result) {\n if (needTOTP) {\n throw new NeedTOTPError(response.message);\n }\n throw new Error(response.message);\n }\n return response;\n }\n catch (e) {\n if (e instanceof NeedTOTPError) {\n throw e;\n }\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","NeedTOTPError","password","code","additionalData","needTOTP","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
@@ -113,17 +113,40 @@ export default class User extends Entity<UserData> {
113
113
  result: boolean;
114
114
  message: string;
115
115
  }>;
116
+ $hasTOTPSecret(): Promise<boolean>;
117
+ $getNewTOTPSecret(): Promise<{
118
+ uri: string;
119
+ qrcode: string;
120
+ secret: string;
121
+ }>;
122
+ $saveTOTPSecret(data: {
123
+ password: string;
124
+ secret: string;
125
+ code: string;
126
+ }): Promise<{
127
+ result: boolean;
128
+ message: string;
129
+ }>;
130
+ $removeTOTPSecret(data: {
131
+ password: string;
132
+ code: string;
133
+ }): Promise<{
134
+ result: boolean;
135
+ message: string;
136
+ }>;
116
137
  static current(returnObjectIfNotExist: true): Promise<User & CurrentUserData>;
117
138
  static current(returnObjectIfNotExist?: false): Promise<(User & CurrentUserData) | null>;
118
139
  static loginUser(data: {
119
140
  username: string;
120
141
  password: string;
142
+ code?: string;
121
143
  additionalData?: {
122
144
  [k: string]: any;
123
145
  };
124
146
  }): Promise<{
125
147
  result: boolean;
126
148
  message: string;
149
+ needTOTP?: true;
127
150
  user?: User & CurrentUserData;
128
151
  }>;
129
152
  static sendRecovery(data: {
package/lib/User.js CHANGED
@@ -120,6 +120,18 @@ class User extends client_1.Entity {
120
120
  async $revokeCurrentTokens(data) {
121
121
  return await this.$serverCall('$revokeCurrentTokens', [data]);
122
122
  }
123
+ async $hasTOTPSecret() {
124
+ return await this.$serverCall('$hasTOTPSecret', [], true);
125
+ }
126
+ async $getNewTOTPSecret() {
127
+ return await this.$serverCall('$getNewTOTPSecret', [], true);
128
+ }
129
+ async $saveTOTPSecret(data) {
130
+ return await this.$serverCall('$saveTOTPSecret', [data]);
131
+ }
132
+ async $removeTOTPSecret(data) {
133
+ return await this.$serverCall('$removeTOTPSecret', [data]);
134
+ }
123
135
  static async current(returnObjectIfNotExist) {
124
136
  const currentUser = await this.serverCallStatic('current', [false]);
125
137
  if (currentUser == null) {
package/lib/User.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"User.js","sourceRoot":"","sources":["../src/User.ts"],"names":[],"mappings":";;AAAA,4CAAgD;AAyIhD,IAAI,YAAY,GAAkB,IAAI,CAAC;AAWvC,MAAqB,IAAK,SAAQ,eAAgB;IAMzC,MAAM,CAAC,IAAI,CAAC,KAAY;QAC7B,IAAI,KAAK,GAAkB;YACzB,iBAAiB,EAAE,EAAE;YACrB,cAAc,EAAE,EAAE;YAClB,eAAe,EAAE,EAAE;SACpB,CAAC;QAEF,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;YAC1B,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAExC,IAAI,QAAQ,EAAE;gBACZ,KAAK,GAAG,QAAQ,CAAC;aAClB;SACF;Q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C,GAAG,CACf,KAAQ,EACR,QAMS;QAET,MAAM,KAAK,GAAG,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;;AAhZgB,WAAM,GAAG,IAAI,OAAO,EAAwB,CAAC;AAGhD,UAAK,GAAG,MAAM,CAAC;kBAJV,IAAI"}
package/lib/helpers.d.ts CHANGED
@@ -13,7 +13,9 @@ export type RegistrationDetails = {
13
13
  [k: string]: any;
14
14
  };
15
15
  };
16
- export declare function login(User: typeof UserClass, username: string, password: string, additionalData?: {
16
+ export declare class NeedTOTPError extends Error {
17
+ }
18
+ export declare function login(User: typeof UserClass, username: string, password: string, code?: string, additionalData?: {
17
19
  [k: string]: any;
18
20
  }): Promise<{
19
21
  message: string;
package/lib/helpers.js CHANGED
@@ -1,7 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkUsername = exports.register = exports.login = void 0;
4
- async function login(User, username, password, additionalData) {
3
+ exports.checkUsername = exports.register = exports.login = exports.NeedTOTPError = void 0;
4
+ class NeedTOTPError extends Error {
5
+ }
6
+ exports.NeedTOTPError = NeedTOTPError;
7
+ async function login(User, username, password, code, additionalData) {
5
8
  if (username === '') {
6
9
  throw new Error('You need to enter a username.');
7
10
  }
@@ -9,17 +12,24 @@ async function login(User, username, password, additionalData) {
9
12
  throw new Error('You need to enter a password');
10
13
  }
11
14
  try {
12
- const { result, ...response } = await User.loginUser({
15
+ const { result, needTOTP, ...response } = await User.loginUser({
13
16
  username,
14
17
  password,
18
+ code,
15
19
  ...(additionalData ? { additionalData } : {}),
16
20
  });
17
21
  if (!result) {
22
+ if (needTOTP) {
23
+ throw new NeedTOTPError(response.message);
24
+ }
18
25
  throw new Error(response.message);
19
26
  }
20
27
  return response;
21
28
  }
22
29
  catch (e) {
30
+ if (e instanceof NeedTOTPError) {
31
+ throw e;
32
+ }
23
33
  throw new Error(e?.message ?? 'An error occurred.');
24
34
  }
25
35
  }
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";;;AA0CO,KAAK,UAAU,KAAK,CACzB,IAAsB,EACtB,QAAgB,EAChB,QAAgB,EAChB,cAAqC;IAErC,IAAI,QAAQ,KAAK,EAAE,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;KAClD;IACD,IAAI,QAAQ,KAAK,EAAE,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;KACjD;IAED,IAAI;QACF,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC;YACnD,QAAQ;YACR,QAAQ;YACR,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC9C,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;SACnC;QACD,OAAO,QAAQ,CAAC;KACjB;IAAC,OAAO,CAAM,EAAE;QACf,MAAM,IAAI,KAAK,CAAC,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CAAC,CAAC,EAAE,OAAO,IAAI,oBAAoB,CAAC,CAAC;KACrD;AACH,CAAC;AAtBD,sCAsBC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nymphjs/tilmeld-client",
3
- "version": "1.0.0-beta.20",
3
+ "version": "1.0.0-beta.21",
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.20"
49
+ "@nymphjs/client": "^1.0.0-beta.21"
50
50
  },
51
- "gitHead": "d6422bc2317b0955d28a7eaa61929aa6194a1578"
51
+ "gitHead": "a1149a055d645ce8191845978d5cbdeaa1afddaa"
52
52
  }
package/src/User.ts CHANGED
@@ -326,6 +326,33 @@ export default class User extends Entity<UserData> {
326
326
  return await this.$serverCall('$revokeCurrentTokens', [data]);
327
327
  }
328
328
 
329
+ public async $hasTOTPSecret(): Promise<boolean> {
330
+ return await this.$serverCall('$hasTOTPSecret', [], true);
331
+ }
332
+
333
+ public async $getNewTOTPSecret(): Promise<{
334
+ uri: string;
335
+ qrcode: string;
336
+ secret: string;
337
+ }> {
338
+ return await this.$serverCall('$getNewTOTPSecret', [], true);
339
+ }
340
+
341
+ public async $saveTOTPSecret(data: {
342
+ password: string;
343
+ secret: string;
344
+ code: string;
345
+ }): Promise<{ result: boolean; message: string }> {
346
+ return await this.$serverCall('$saveTOTPSecret', [data]);
347
+ }
348
+
349
+ public async $removeTOTPSecret(data: {
350
+ password: string;
351
+ code: string;
352
+ }): Promise<{ result: boolean; message: string }> {
353
+ return await this.$serverCall('$removeTOTPSecret', [data]);
354
+ }
355
+
329
356
  public static async current(
330
357
  returnObjectIfNotExist: true
331
358
  ): Promise<User & CurrentUserData>;
@@ -345,10 +372,12 @@ export default class User extends Entity<UserData> {
345
372
  public static async loginUser(data: {
346
373
  username: string;
347
374
  password: string;
375
+ code?: string;
348
376
  additionalData?: { [k: string]: any };
349
377
  }): Promise<{
350
378
  result: boolean;
351
379
  message: string;
380
+ needTOTP?: true;
352
381
  user?: User & CurrentUserData;
353
382
  }> {
354
383
  const store = User.stores.get(this.nymph);
package/src/helpers.ts CHANGED
@@ -40,10 +40,13 @@ export type RegistrationDetails = {
40
40
  additionalData?: { [k: string]: any };
41
41
  };
42
42
 
43
+ export class NeedTOTPError extends Error {}
44
+
43
45
  export async function login(
44
46
  User: typeof UserClass,
45
47
  username: string,
46
48
  password: string,
49
+ code?: string,
47
50
  additionalData?: { [k: string]: any }
48
51
  ) {
49
52
  if (username === '') {
@@ -54,16 +57,24 @@ export async function login(
54
57
  }
55
58
 
56
59
  try {
57
- const { result, ...response } = await User.loginUser({
60
+ const { result, needTOTP, ...response } = await User.loginUser({
58
61
  username,
59
62
  password,
63
+ code,
60
64
  ...(additionalData ? { additionalData } : {}),
61
65
  });
62
66
  if (!result) {
67
+ if (needTOTP) {
68
+ throw new NeedTOTPError(response.message);
69
+ }
70
+
63
71
  throw new Error(response.message);
64
72
  }
65
73
  return response;
66
74
  } catch (e: any) {
75
+ if (e instanceof NeedTOTPError) {
76
+ throw e;
77
+ }
67
78
  throw new Error(e?.message ?? 'An error occurred.');
68
79
  }
69
80
  }