@nymphjs/tilmeld-client 1.0.0-beta.55 → 1.0.0-beta.57
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 +10 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/lib/Group.d.ts +36 -0
- package/lib/Group.js +1 -0
- package/lib/Group.js.map +1 -1
- package/lib/User.d.ts +80 -0
- package/lib/User.js +10 -6
- package/lib/User.js.map +1 -1
- package/lib/helpers.d.ts +27 -0
- package/lib/helpers.js +1 -0
- package/lib/helpers.js.map +1 -1
- package/lib/index.test.d.ts +1 -0
- package/lib/index.test.js +243 -0
- package/lib/index.test.js.map +1 -0
- package/package.json +8 -3
- package/src/User.ts +4 -4
- package/src/index.test.ts +319 -0
- package/tsconfig.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
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.57](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.56...v1.0.0-beta.57) (2024-06-12)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @nymphjs/tilmeld-client
|
|
9
|
+
|
|
10
|
+
# [1.0.0-beta.56](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.55...v1.0.0-beta.56) (2024-06-11)
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- allow connections where tokens are not renewed ([39071a5](https://github.com/sciactive/nymphjs/commit/39071a545644075190bd8213be25e0a0c46d2b5d))
|
|
15
|
+
|
|
6
16
|
# [1.0.0-beta.55](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.54...v1.0.0-beta.55) (2024-05-26)
|
|
7
17
|
|
|
8
18
|
**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={690:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const s=r(935);class n extends s.Entity{constructor(){super(),this.$data.enabled=!0,this.$data.abilities=[]}static async factory(e){return await super.factory(e)}static factorySync(){return super.factorySync()}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},962:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const s=r(935);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(){super(),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(){return super.factorySync()}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?[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.
|
|
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={690:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const s=r(935);class n extends s.Entity{constructor(){super(),this.$data.enabled=!0,this.$data.abilities=[]}static async factory(e){return await super.factory(e)}static factorySync(){return super.factorySync()}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},962:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const s=r(935);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(){super(),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(){return super.factorySync()}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?[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&&(delete this.nymph.headers["X-Xsrf-Token"],this.nymph.pubsub&&this.nymph.pubsub.authenticate(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.headers["X-Xsrf-Token"]=a.xsrfToken,this.nymph.pubsub&&this.nymph.pubsub.authenticate(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},584:(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.regFields.includes("email")&&(n.emailUsernames?s.email=t.username:s.email=t.email),n.regFields.includes("name")&&(s.nameFirst=t.nameFirst,s.nameLast=t.nameLast),n.regFields.includes("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.")}}},509: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(690),t);const i=a(r(690));t.Group=i.default,n(r(584),t),n(r(962),t);const o=a(r(962));t.User=o.default},935: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}(509)})()));
|
|
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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,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqB5E,IAAjB6E,EACH,OAAOA,EAAa5K,QAGrB,IAAIC,EAASwK,EAAyBE,GAAY,CAGjD3K,QAAS,CAAC,GAOX,OAHA6K,EAAoBF,GAAUR,KAAKlK,EAAOD,QAASC,EAAQA,EAAOD,QAAS0K,GAGpEzK,EAAOD,OACf,CCnB0B0K,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__935__) => {\nreturn ","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst client_1 = require(\"@nymphjs/client\");\nclass Group extends client_1.Entity {\n constructor() {\n super();\n this.$data.enabled = true;\n this.$data.abilities = [];\n }\n static async factory(guid) {\n return (await super.factory(guid));\n }\n static factorySync() {\n return super.factorySync();\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() {\n super();\n this.$data.enabled = true;\n this.$data.abilities = [];\n this.$data.groups = [];\n this.$data.inheritAbilities = true;\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() {\n return super.factorySync();\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', [\n ...(data ? [data] : []),\n ]);\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.regFields.includes('email')) {\n if (config.emailUsernames) {\n user.email = userDetails.username;\n }\n else {\n user.email = userDetails.email;\n }\n }\n if (config.regFields.includes('name')) {\n user.nameFirst = userDetails.nameFirst;\n user.nameLast = userDetails.nameLast;\n }\n if (config.regFields.includes('phone')) {\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__935__;","// 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__(509);\n"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE__935__","Object","defineProperty","value","client_1","Group","Entity","constructor","super","$data","enabled","abilities","guid","factorySync","$checkGroupname","$serverCall","$checkEmail","$getAvatar","$getChildren","$getDescendants","andSelf","$getLevel","$isDescendant","givenGroup","getPrimaryGroups","options","selectors","serverCallStatic","class","getSecondaryGroups","currentToken","User","init","nymph","store","registerCallbacks","loginCallbacks","logoutCallbacks","stores","has","storeVal","get","set","removeNymphResponseListener","on","response","handleToken","groups","inheritAbilities","factoryUsername","username","entity","getEntity","type","ilike","replace","s","$checkUsername","$checkPhone","$register","data","$nymph","Error","result","i","length","loggedin","$switchUser","$logout","$gatekeeper","ability","$changePassword","$revokeCurrentTokens","$hasTOTPSecret","$getNewTOTPSecret","$saveTOTPSecret","$removeTOTPSecret","current","returnObjectIfNotExist","currentUser","loginUser","user","sendRecovery","recover","getClientConfig","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","async","password","code","additionalData","needTOTP","message","e","userDetails","usernameVerified","password2","regFields","includes","emailUsernames","email","nameFirst","nameLast","phone","__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,OACzB,WAAAC,GACIC,QACAT,KAAKU,MAAMC,SAAU,EACrBX,KAAKU,MAAME,UAAY,EAC3B,CACA,oBAAalB,CAAQmB,GACjB,aAAcJ,MAAMf,QAAQmB,EAChC,CACA,kBAAOC,GACH,OAAOL,MAAMK,aACjB,CACA,qBAAMC,GACF,aAAaf,KAAKgB,YAAY,kBAAmB,IAAI,EACzD,CACA,iBAAMC,GACF,aAAajB,KAAKgB,YAAY,cAAe,IAAI,EACrD,CACA,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,EAAgBzJ,MAAQA,KAAKyJ,cAAiB,SAAST,EAAGrJ,GAC1D,IAAK,IAAI+J,KAAKV,EAAa,YAANU,GAAoBxJ,OAAOyJ,UAAUC,eAAeC,KAAKlK,EAAS+J,IAAIb,EAAgBlJ,EAASqJ,EAAGU,EAC3H,EACII,EAAmB9J,MAAQA,KAAK8J,iBAAoB,SAAUC,GAC9D,OAAQA,GAAOA,EAAIV,WAAcU,EAAM,CAAE,QAAWA,EACxD,EACA7J,OAAOC,eAAeR,EAAS,aAAc,CAAES,OAAO,IACtDT,EAAQqC,KAAOrC,EAAQW,WAAQ,EAC/BmJ,EAAa,EAAQ,KAAY9J,GACjC,MAAMqK,EAAUF,EAAgB,EAAQ,MACxCnK,EAAQW,MAAQ0J,EAAQC,QACxBR,EAAa,EAAQ,KAAc9J,GACnC8J,EAAa,EAAQ,KAAW9J,GAChC,MAAMuK,EAASJ,EAAgB,EAAQ,MACvCnK,EAAQqC,KAAOkI,EAAOD,O,UC1BtBrK,EAAOD,QAAUM,C,GCCbkK,EAA2B,CAAC,E,OAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqB3E,IAAjB4E,EACH,OAAOA,EAAa3K,QAGrB,IAAIC,EAASuK,EAAyBE,GAAY,CAGjD1K,QAAS,CAAC,GAOX,OAHA4K,EAAoBF,GAAUR,KAAKjK,EAAOD,QAASC,EAAQA,EAAOD,QAASyK,GAGpExK,EAAOD,OACf,CCnB0ByK,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__935__) => {\nreturn ","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst client_1 = require(\"@nymphjs/client\");\nclass Group extends client_1.Entity {\n constructor() {\n super();\n this.$data.enabled = true;\n this.$data.abilities = [];\n }\n static async factory(guid) {\n return (await super.factory(guid));\n }\n static factorySync() {\n return super.factorySync();\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}\n// The name of the server class\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() {\n super();\n this.$data.enabled = true;\n this.$data.abilities = [];\n this.$data.groups = [];\n this.$data.inheritAbilities = true;\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() {\n return super.factorySync();\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', [\n ...(data ? [data] : []),\n ]);\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 delete this.nymph.headers['X-Xsrf-Token'];\n if (this.nymph.pubsub) {\n this.nymph.pubsub.authenticate(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') // node\n : atob(base64); // browser\n const jwt = JSON.parse(json);\n this.nymph.headers['X-Xsrf-Token'] = jwt.xsrfToken;\n if (this.nymph.pubsub) {\n this.nymph.pubsub.authenticate(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 // @ts-ignore: The callback should always be the right type here.\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 // @ts-ignore: The callback should always be the right type here.\n const i = store[prop].indexOf(callback);\n if (i > -1) {\n // @ts-ignore: The callback should always be the right type here.\n store[prop].splice(i, 1);\n }\n return true;\n }\n}\nUser.stores = new WeakMap();\n// The name of the server class\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 // Create a new user.\n let user = User.factorySync();\n user.username = userDetails.username;\n const config = clientConfig || (await User.getClientConfig());\n if (config.regFields.includes('email')) {\n if (config.emailUsernames) {\n user.email = userDetails.username;\n }\n else {\n user.email = userDetails.email;\n }\n }\n if (config.regFields.includes('name')) {\n user.nameFirst = userDetails.nameFirst;\n user.nameLast = userDetails.nameLast;\n }\n if (config.regFields.includes('phone')) {\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__935__;","// 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__(509);\n"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE__935__","Object","defineProperty","value","client_1","Group","Entity","constructor","super","$data","enabled","abilities","guid","factorySync","$checkGroupname","$serverCall","$checkEmail","$getAvatar","$getChildren","$getDescendants","andSelf","$getLevel","$isDescendant","givenGroup","getPrimaryGroups","options","selectors","serverCallStatic","class","getSecondaryGroups","currentToken","User","init","nymph","store","registerCallbacks","loginCallbacks","logoutCallbacks","stores","has","storeVal","get","set","removeNymphResponseListener","on","response","handleToken","groups","inheritAbilities","factoryUsername","username","entity","getEntity","type","ilike","replace","s","$checkUsername","$checkPhone","$register","data","$nymph","Error","result","i","length","loggedin","$switchUser","$logout","$gatekeeper","ability","$changePassword","$revokeCurrentTokens","$hasTOTPSecret","$getNewTOTPSecret","$saveTOTPSecret","$removeTOTPSecret","current","returnObjectIfNotExist","currentUser","loginUser","user","sendRecovery","recover","getClientConfig","clientConfig","clientConfigPromise","then","config","undefined","token","switchToken","authCookiePattern","switchCookiePattern","headers","document","cookie","match","pubsub","authenticate","base64","split","json","atob","Buffer","from","toString","jwt","JSON","parse","xsrfToken","event","callback","prop","push","off","indexOf","splice","WeakMap","checkUsername","register","login","NeedTOTPError","async","password","code","additionalData","needTOTP","message","e","userDetails","usernameVerified","password2","regFields","includes","emailUsernames","email","nameFirst","nameLast","phone","__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/Group.d.ts
CHANGED
|
@@ -2,19 +2,55 @@ import { Entity, Options, Selector } from '@nymphjs/client';
|
|
|
2
2
|
import type User from './User';
|
|
3
3
|
import type { CurrentUserData } from './User';
|
|
4
4
|
export type GroupData = {
|
|
5
|
+
/**
|
|
6
|
+
* The group's groupname.
|
|
7
|
+
*/
|
|
5
8
|
groupname?: string;
|
|
9
|
+
/**
|
|
10
|
+
* The group's name.
|
|
11
|
+
*/
|
|
6
12
|
name?: string;
|
|
13
|
+
/**
|
|
14
|
+
* The group's avatar URL. (Use getAvatar() to support Gravatar.)
|
|
15
|
+
*/
|
|
7
16
|
avatar?: string;
|
|
17
|
+
/**
|
|
18
|
+
* The group's parent.
|
|
19
|
+
*/
|
|
8
20
|
parent?: Group & GroupData;
|
|
21
|
+
/**
|
|
22
|
+
* Whether the group can be used.
|
|
23
|
+
*/
|
|
9
24
|
enabled?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Whether this group is the default primary group for new users.
|
|
27
|
+
*/
|
|
10
28
|
defaultPrimary?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Whether this group is a default secondary group for new users.
|
|
31
|
+
*/
|
|
11
32
|
defaultSecondary?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Whether this group is a default secondary group for unverified users.
|
|
35
|
+
*/
|
|
12
36
|
unverifiedSecondary?: boolean;
|
|
13
37
|
};
|
|
14
38
|
export type CurrentGroupData = GroupData & {
|
|
39
|
+
/**
|
|
40
|
+
* The abilities granted to the group.
|
|
41
|
+
*/
|
|
15
42
|
abilities?: string[];
|
|
43
|
+
/**
|
|
44
|
+
* The group's email address.
|
|
45
|
+
*/
|
|
16
46
|
email?: string;
|
|
47
|
+
/**
|
|
48
|
+
* The group's telephone number.
|
|
49
|
+
*/
|
|
17
50
|
phone?: string;
|
|
51
|
+
/**
|
|
52
|
+
* If generatePrimary is on, this will be the user who generated this group.
|
|
53
|
+
*/
|
|
18
54
|
user?: (User & CurrentUserData) | null;
|
|
19
55
|
};
|
|
20
56
|
export type AdminGroupData = CurrentGroupData;
|
package/lib/Group.js
CHANGED
package/lib/Group.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Group.js","sourceRoot":"","sources":["../src/Group.ts"],"names":[],"mappings":";;AAAA,4CAA4D;AA8D5D,MAAqB,KAAM,SAAQ,eAAiB;IAIlD;QACE,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;QACzB,IAAI,CAAC,KAA0B,CAAC,SAAS,GAAG,EAAE,CAAC;IAClD,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAa;QAChC,OAAO,CAAC,MAAM,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAsB,CAAC;IAC1D,CAAC;IAED,MAAM,CAAC,WAAW;QAChB,OAAO,KAAK,CAAC,WAAW,EAAuB,CAAC;IAClD,CAAC;IAEM,KAAK,CAAC,eAAe;QAI1B,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,iBAAiB,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;IAC7D,CAAC;IAEM,KAAK,CAAC,WAAW;QACtB,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,aAAa,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;IACzD,CAAC;IAEM,KAAK,CAAC,UAAU;QACrB,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;IACxD,CAAC;IAEM,KAAK,CAAC,YAAY;QACvB,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,cAAc,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;IAC1D,CAAC;IAEM,KAAK,CAAC,eAAe,CAC1B,OAAO,GAA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IAEM,MAAM,CAAC,KAAK,CAAC,kBAAkB,CACpC,OAAiB,EACjB,SAAsB;QAEtB,OAAO,MAAM,IAAI,CAAC,gBAAgB,CAAC,oBAAoB,EAAE;YACvD,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE;YAC9B,SAAS;SACV,CAAC,CAAC;IACL,CAAC;;AAvED,+BAA+B;AACjB,WAAK,GAAG,OAAO,CAAC;kBAFX,KAAK"}
|
package/lib/User.d.ts
CHANGED
|
@@ -16,35 +16,115 @@ export type ClientConfig = {
|
|
|
16
16
|
unverifiedAccess: boolean;
|
|
17
17
|
};
|
|
18
18
|
export type UserData = {
|
|
19
|
+
/**
|
|
20
|
+
* The user's username.
|
|
21
|
+
*/
|
|
19
22
|
username?: string;
|
|
23
|
+
/**
|
|
24
|
+
* The user's first name.
|
|
25
|
+
*/
|
|
20
26
|
nameFirst?: string;
|
|
27
|
+
/**
|
|
28
|
+
* The user's middle name.
|
|
29
|
+
*/
|
|
21
30
|
nameMiddle?: string;
|
|
31
|
+
/**
|
|
32
|
+
* The user's last name.
|
|
33
|
+
*/
|
|
22
34
|
nameLast?: string;
|
|
35
|
+
/**
|
|
36
|
+
* The user's full name.
|
|
37
|
+
*/
|
|
23
38
|
name?: string;
|
|
39
|
+
/**
|
|
40
|
+
* The user's avatar URL. (Use $getAvatar() to support Gravatar.)
|
|
41
|
+
*/
|
|
24
42
|
avatar?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Whether the user can log in.
|
|
45
|
+
*/
|
|
25
46
|
enabled?: boolean;
|
|
26
47
|
};
|
|
27
48
|
export type CurrentUserData = UserData & {
|
|
49
|
+
/**
|
|
50
|
+
* The abilities granted to the user.
|
|
51
|
+
*/
|
|
28
52
|
abilities?: string[];
|
|
53
|
+
/**
|
|
54
|
+
* The user's email address.
|
|
55
|
+
*/
|
|
29
56
|
email?: string;
|
|
57
|
+
/**
|
|
58
|
+
* The user's telephone number.
|
|
59
|
+
*/
|
|
30
60
|
phone?: string;
|
|
61
|
+
/**
|
|
62
|
+
* The user's primary group.
|
|
63
|
+
*/
|
|
31
64
|
group?: Group & CurrentGroupData;
|
|
65
|
+
/**
|
|
66
|
+
* The user's secondary groups.
|
|
67
|
+
*/
|
|
32
68
|
groups?: (Group & CurrentGroupData)[];
|
|
69
|
+
/**
|
|
70
|
+
* Whether the user should inherit the abilities of his groups.
|
|
71
|
+
*/
|
|
33
72
|
inheritAbilities?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* If the user has changed their email address, this is the new one, awaiting
|
|
75
|
+
* verification.
|
|
76
|
+
*/
|
|
34
77
|
newEmailAddress?: string;
|
|
35
78
|
};
|
|
36
79
|
export type AdminUserData = CurrentUserData & {
|
|
80
|
+
/**
|
|
81
|
+
* The user's primary group.
|
|
82
|
+
*/
|
|
37
83
|
group?: Group & AdminGroupData;
|
|
84
|
+
/**
|
|
85
|
+
* The user's secondary groups.
|
|
86
|
+
*/
|
|
38
87
|
groups?: (Group & AdminGroupData)[];
|
|
88
|
+
/**
|
|
89
|
+
* A verification secret.
|
|
90
|
+
*/
|
|
39
91
|
secret?: string;
|
|
92
|
+
/**
|
|
93
|
+
* The timestamp of when the email address was last changed.
|
|
94
|
+
*/
|
|
40
95
|
emailChangeDate?: number;
|
|
96
|
+
/**
|
|
97
|
+
* An email change proceed secret.
|
|
98
|
+
*/
|
|
41
99
|
newEmailSecret?: string;
|
|
100
|
+
/**
|
|
101
|
+
* The new email address.
|
|
102
|
+
*/
|
|
42
103
|
newEmailAddress?: string;
|
|
104
|
+
/**
|
|
105
|
+
* An email change cancellation secret.
|
|
106
|
+
*/
|
|
43
107
|
cancelEmailSecret?: string;
|
|
108
|
+
/**
|
|
109
|
+
* The old email address.
|
|
110
|
+
*/
|
|
44
111
|
cancelEmailAddress?: string;
|
|
112
|
+
/**
|
|
113
|
+
* A recovery secret.
|
|
114
|
+
*/
|
|
45
115
|
recoverSecret?: string;
|
|
116
|
+
/**
|
|
117
|
+
* The timestamp of when the recovery secret was issued.
|
|
118
|
+
*/
|
|
46
119
|
recoverSecretDate?: number;
|
|
120
|
+
/**
|
|
121
|
+
* Used by admins to change a user's password. Not saved to the database.
|
|
122
|
+
*/
|
|
47
123
|
passwordTemp?: string;
|
|
124
|
+
/**
|
|
125
|
+
* If set, this timestamp is the cutoff point for JWT issue dates. Any token
|
|
126
|
+
* issued before this date will not authenticate the user.
|
|
127
|
+
*/
|
|
48
128
|
revokeTokenDate?: number;
|
|
49
129
|
};
|
|
50
130
|
type InstanceStore = {
|
package/lib/User.js
CHANGED
|
@@ -196,9 +196,9 @@ class User extends client_1.Entity {
|
|
|
196
196
|
if (currentToken !== token) {
|
|
197
197
|
if (token == null || token === '') {
|
|
198
198
|
if (currentToken != null) {
|
|
199
|
-
this.nymph.
|
|
199
|
+
delete this.nymph.headers['X-Xsrf-Token'];
|
|
200
200
|
if (this.nymph.pubsub) {
|
|
201
|
-
this.nymph.pubsub.
|
|
201
|
+
this.nymph.pubsub.authenticate(null);
|
|
202
202
|
}
|
|
203
203
|
currentToken = null;
|
|
204
204
|
}
|
|
@@ -207,12 +207,12 @@ class User extends client_1.Entity {
|
|
|
207
207
|
const base64Url = token.split('.')[1];
|
|
208
208
|
const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
|
|
209
209
|
const json = typeof atob === 'undefined'
|
|
210
|
-
? Buffer.from(base64, 'base64').toString('binary')
|
|
211
|
-
: atob(base64);
|
|
210
|
+
? Buffer.from(base64, 'base64').toString('binary') // node
|
|
211
|
+
: atob(base64); // browser
|
|
212
212
|
const jwt = JSON.parse(json);
|
|
213
|
-
this.nymph.
|
|
213
|
+
this.nymph.headers['X-Xsrf-Token'] = jwt.xsrfToken;
|
|
214
214
|
if (this.nymph.pubsub) {
|
|
215
|
-
this.nymph.pubsub.
|
|
215
|
+
this.nymph.pubsub.authenticate(token, switchToken);
|
|
216
216
|
}
|
|
217
217
|
currentToken = token;
|
|
218
218
|
}
|
|
@@ -227,6 +227,7 @@ class User extends client_1.Entity {
|
|
|
227
227
|
if (!(prop in store)) {
|
|
228
228
|
throw new Error('Invalid event type.');
|
|
229
229
|
}
|
|
230
|
+
// @ts-ignore: The callback should always be the right type here.
|
|
230
231
|
store[prop].push(callback);
|
|
231
232
|
return () => this.off(event, callback);
|
|
232
233
|
}
|
|
@@ -239,14 +240,17 @@ class User extends client_1.Entity {
|
|
|
239
240
|
if (!(prop in store)) {
|
|
240
241
|
return false;
|
|
241
242
|
}
|
|
243
|
+
// @ts-ignore: The callback should always be the right type here.
|
|
242
244
|
const i = store[prop].indexOf(callback);
|
|
243
245
|
if (i > -1) {
|
|
246
|
+
// @ts-ignore: The callback should always be the right type here.
|
|
244
247
|
store[prop].splice(i, 1);
|
|
245
248
|
}
|
|
246
249
|
return true;
|
|
247
250
|
}
|
|
248
251
|
}
|
|
249
252
|
User.stores = new WeakMap();
|
|
253
|
+
// The name of the server class
|
|
250
254
|
User.class = 'User';
|
|
251
255
|
exports.default = User;
|
|
252
256
|
//# sourceMappingURL=User.js.map
|
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,CAAC;YAC3B,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAExC,IAAI,QAAQ,EAAE,CAAC;gBACb,KAAK,GAAG,QAAQ,CAAC;YACnB,CAAC;QACH,CAAC;QA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AI,IAAI,KAAK,CAAC,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;QACzC,CAAC;QACD,iEAAiE;QACjE,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC3B,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACzC,CAAC;IAEM,MAAM,CAAC,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,CAAC;YAClB,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAC;QACJ,CAAC;QAED,MAAM,IAAI,GAAG,CAAC,KAAK,GAAG,WAAW,CAMxB,CAAC;QACV,IAAI,CAAC,CAAC,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;YACrB,OAAO,KAAK,CAAC;QACf,CAAC;QACD,iEAAiE;QACjE,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACxC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YACX,iEAAiE;YACjE,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC3B,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;;AAhZgB,WAAM,GAAG,IAAI,OAAO,EAAwB,CAAC;AAE9D,+BAA+B;AACjB,UAAK,GAAG,MAAM,CAAC;kBAJV,IAAI"}
|
package/lib/helpers.d.ts
CHANGED
|
@@ -1,14 +1,41 @@
|
|
|
1
1
|
import type UserClass from './User';
|
|
2
2
|
import type { ClientConfig, CurrentUserData } from './User';
|
|
3
3
|
export type RegistrationDetails = {
|
|
4
|
+
/**
|
|
5
|
+
* New user's username.
|
|
6
|
+
*/
|
|
4
7
|
username: string;
|
|
8
|
+
/**
|
|
9
|
+
* New user's password.
|
|
10
|
+
*/
|
|
5
11
|
password: string;
|
|
12
|
+
/**
|
|
13
|
+
* Repeat the password.
|
|
14
|
+
*/
|
|
6
15
|
password2: string;
|
|
16
|
+
/**
|
|
17
|
+
* Whether the username passed verification.
|
|
18
|
+
*/
|
|
7
19
|
usernameVerified: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The new user's email address.
|
|
22
|
+
*/
|
|
8
23
|
email?: string;
|
|
24
|
+
/**
|
|
25
|
+
* The new user's given name.
|
|
26
|
+
*/
|
|
9
27
|
nameFirst?: string;
|
|
28
|
+
/**
|
|
29
|
+
* The new user's surname.
|
|
30
|
+
*/
|
|
10
31
|
nameLast?: string;
|
|
32
|
+
/**
|
|
33
|
+
* The new user's phone number.
|
|
34
|
+
*/
|
|
11
35
|
phone?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Additional data to be included in the request.
|
|
38
|
+
*/
|
|
12
39
|
additionalData?: {
|
|
13
40
|
[k: string]: any;
|
|
14
41
|
};
|
package/lib/helpers.js
CHANGED
|
@@ -47,6 +47,7 @@ async function register(User, userDetails, clientConfig) {
|
|
|
47
47
|
if (userDetails.password === '') {
|
|
48
48
|
throw new Error('You need to enter a password');
|
|
49
49
|
}
|
|
50
|
+
// Create a new user.
|
|
50
51
|
let user = User.factorySync();
|
|
51
52
|
user.username = userDetails.username;
|
|
52
53
|
const config = clientConfig || (await User.getClientConfig());
|
package/lib/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";;;AA0CA,MAAa,aAAc,SAAQ,KAAK;CAAG;AAA3C,sCAA2C;AAEpC,KAAK,UAAU,KAAK,CACzB,IAAsB,EACtB,QAAgB,EAChB,QAAgB,EAChB,IAAa,EACb,cAAqC;IAErC,IAAI,QAAQ,KA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C;IACxB,CAAC;IAED,IAAI,CAAC;QACH,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAC5D,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACpC,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,CAAC,EAAE,OAAO,IAAI,oBAAoB,CAAC,CAAC;IACtD,CAAC;AACH,CAAC;AAtBD,sCAsBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const express_1 = __importDefault(require("express"));
|
|
7
|
+
const driver_sqlite3_1 = __importDefault(require("@nymphjs/driver-sqlite3"));
|
|
8
|
+
const nymph_1 = require("@nymphjs/nymph");
|
|
9
|
+
const client_node_1 = require("@nymphjs/client-node");
|
|
10
|
+
const tilmeld_1 = require("@nymphjs/tilmeld");
|
|
11
|
+
const server_1 = __importDefault(require("@nymphjs/server"));
|
|
12
|
+
const index_1 = require("./index");
|
|
13
|
+
describe('Tilmeld Client', () => {
|
|
14
|
+
let server = undefined;
|
|
15
|
+
afterEach(() => {
|
|
16
|
+
if (server) {
|
|
17
|
+
server.close(); // avoid jest open handle error
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
function createNymphTilmeldServer(config, clientConfig) {
|
|
21
|
+
const sqliteConfig = {
|
|
22
|
+
filename: ':memory:',
|
|
23
|
+
};
|
|
24
|
+
const tilmeld = new tilmeld_1.Tilmeld({
|
|
25
|
+
jwtSecret: 'supersecrettestingsecret',
|
|
26
|
+
allowRegistration: true,
|
|
27
|
+
verifyEmail: false,
|
|
28
|
+
emailUsernames: false,
|
|
29
|
+
...config,
|
|
30
|
+
});
|
|
31
|
+
const nymphServer = new nymph_1.Nymph({}, new driver_sqlite3_1.default(sqliteConfig), tilmeld);
|
|
32
|
+
const UserModel = nymphServer.addEntityClass(tilmeld_1.User);
|
|
33
|
+
const GroupModel = nymphServer.addEntityClass(tilmeld_1.Group);
|
|
34
|
+
const app = (0, express_1.default)();
|
|
35
|
+
app.use('/test', (0, server_1.default)(nymphServer));
|
|
36
|
+
server = app.listen(5084);
|
|
37
|
+
const nymph = new client_node_1.Nymph({
|
|
38
|
+
restUrl: 'http://localhost:5084/test/',
|
|
39
|
+
...(clientConfig ?? {}),
|
|
40
|
+
});
|
|
41
|
+
const User = nymph.addEntityClass(index_1.User);
|
|
42
|
+
User.init(nymph);
|
|
43
|
+
const Group = nymph.addEntityClass(index_1.Group);
|
|
44
|
+
return {
|
|
45
|
+
tilmeld,
|
|
46
|
+
nymphServer,
|
|
47
|
+
UserModel,
|
|
48
|
+
GroupModel,
|
|
49
|
+
app,
|
|
50
|
+
nymph,
|
|
51
|
+
User,
|
|
52
|
+
Group,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
async function createAdmin(User) {
|
|
56
|
+
const admin = User.factorySync();
|
|
57
|
+
admin.username = 'admin';
|
|
58
|
+
admin.email = 'root@localhost';
|
|
59
|
+
admin.nameFirst = 'Admin';
|
|
60
|
+
admin.nameLast = 'User';
|
|
61
|
+
const result = await admin.$register({
|
|
62
|
+
password: 'supersecretadminpassword',
|
|
63
|
+
});
|
|
64
|
+
return { result, admin };
|
|
65
|
+
}
|
|
66
|
+
async function createUser(User) {
|
|
67
|
+
const user = User.factorySync();
|
|
68
|
+
user.username = 'user';
|
|
69
|
+
user.email = 'user@localhost';
|
|
70
|
+
user.nameFirst = 'Some';
|
|
71
|
+
user.nameLast = 'User';
|
|
72
|
+
const result = await user.$register({
|
|
73
|
+
password: 'supersecretuserpassword',
|
|
74
|
+
});
|
|
75
|
+
return { result, user };
|
|
76
|
+
}
|
|
77
|
+
it('get client config', async () => {
|
|
78
|
+
const { User } = createNymphTilmeldServer();
|
|
79
|
+
const result = await User.getClientConfig();
|
|
80
|
+
expect(result).not.toBeNull();
|
|
81
|
+
expect(result.verifyEmail).toBeFalsy();
|
|
82
|
+
});
|
|
83
|
+
it('produce errors when register data is incorrect', async () => {
|
|
84
|
+
const { User } = createNymphTilmeldServer();
|
|
85
|
+
try {
|
|
86
|
+
const admin = User.factorySync();
|
|
87
|
+
let result = await admin.$register({
|
|
88
|
+
password: 'supersecretadminpassword',
|
|
89
|
+
});
|
|
90
|
+
expect(result.result).toBeFalsy();
|
|
91
|
+
expect(result.loggedin).toBeFalsy();
|
|
92
|
+
expect(result.message).toEqual('Please specify a username.');
|
|
93
|
+
expect(admin.guid).toBeNull();
|
|
94
|
+
admin.username = 'admin';
|
|
95
|
+
try {
|
|
96
|
+
expect((result = await admin.$register({
|
|
97
|
+
password: 'supersecretadminpassword',
|
|
98
|
+
}))).toThrow();
|
|
99
|
+
}
|
|
100
|
+
catch (e) {
|
|
101
|
+
expect(e.status).toEqual(400);
|
|
102
|
+
expect(e.message).toEqual('Please specify a valid email.');
|
|
103
|
+
}
|
|
104
|
+
admin.email = 'root@localhost';
|
|
105
|
+
try {
|
|
106
|
+
expect((result = await admin.$register({
|
|
107
|
+
password: 'supersecretadminpassword',
|
|
108
|
+
}))).toThrow();
|
|
109
|
+
}
|
|
110
|
+
catch (e) {
|
|
111
|
+
expect(e.status).toEqual(400);
|
|
112
|
+
expect(e.message).toEqual('Invalid User: "nameFirst" is required');
|
|
113
|
+
}
|
|
114
|
+
expect(admin.guid).toBeNull();
|
|
115
|
+
}
|
|
116
|
+
catch (e) {
|
|
117
|
+
console.error('Error creating admin: ', e);
|
|
118
|
+
throw e;
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
it('create admin user', async () => {
|
|
122
|
+
const { User } = createNymphTilmeldServer();
|
|
123
|
+
try {
|
|
124
|
+
const { result, admin } = await createAdmin(User);
|
|
125
|
+
expect(result.result).toBeTruthy();
|
|
126
|
+
expect(result.loggedin).toBeTruthy();
|
|
127
|
+
expect(result.message).toEqual("You're now registered and logged in!");
|
|
128
|
+
expect(admin.guid).not.toBeNull();
|
|
129
|
+
expect(typeof admin.guid).toEqual('string');
|
|
130
|
+
const permission = await admin.$gatekeeper('system/admin');
|
|
131
|
+
expect(permission).toBeTruthy();
|
|
132
|
+
}
|
|
133
|
+
catch (e) {
|
|
134
|
+
console.error('Error creating admin: ', e);
|
|
135
|
+
throw e;
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
it('logout', async () => {
|
|
139
|
+
const { User } = createNymphTilmeldServer();
|
|
140
|
+
try {
|
|
141
|
+
const { admin } = await createAdmin(User);
|
|
142
|
+
const user1 = await User.current();
|
|
143
|
+
expect(user1?.guid).toEqual(admin.guid);
|
|
144
|
+
expect((await admin.$logout()).result).toBeTruthy();
|
|
145
|
+
const user2 = await User.current();
|
|
146
|
+
expect(user2).toBeNull();
|
|
147
|
+
}
|
|
148
|
+
catch (e) {
|
|
149
|
+
console.error('Error running test: ', e);
|
|
150
|
+
throw e;
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
it('second user', async () => {
|
|
154
|
+
const { User } = createNymphTilmeldServer();
|
|
155
|
+
try {
|
|
156
|
+
const { admin } = await createAdmin(User);
|
|
157
|
+
expect((await admin.$logout()).result).toBeTruthy();
|
|
158
|
+
const { result, user } = await createUser(User);
|
|
159
|
+
expect(result.result).toBeTruthy();
|
|
160
|
+
expect(result.loggedin).toBeTruthy();
|
|
161
|
+
expect(result.message).toEqual("You're now registered and logged in!");
|
|
162
|
+
expect(user.guid).not.toBeNull();
|
|
163
|
+
expect(typeof user.guid).toEqual('string');
|
|
164
|
+
const permission = await user.$gatekeeper('system/admin');
|
|
165
|
+
expect(permission).toBeFalsy();
|
|
166
|
+
}
|
|
167
|
+
catch (e) {
|
|
168
|
+
console.error('Error running test: ', e);
|
|
169
|
+
throw e;
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
it("doesn't issue renewed token when not needed", async () => {
|
|
173
|
+
const { User, nymph } = createNymphTilmeldServer({
|
|
174
|
+
jwtExpire: 5,
|
|
175
|
+
jwtRenew: 0,
|
|
176
|
+
});
|
|
177
|
+
let responses = 0;
|
|
178
|
+
nymph.on('response', (response) => {
|
|
179
|
+
if (responses === 0) {
|
|
180
|
+
expect(response.headers.get('set-cookie')).toMatch(/^TILMELDAUTH=[^;]+; Max-Age=5; Domain=localhost; Path=\/; Expires=[^;]+; SameSite=Strict$/);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
expect(response.headers.has('set-cookie')).toBeFalsy();
|
|
184
|
+
}
|
|
185
|
+
responses++;
|
|
186
|
+
});
|
|
187
|
+
try {
|
|
188
|
+
const { admin } = await createAdmin(User);
|
|
189
|
+
expect(await admin.$gatekeeper()).toBeTruthy();
|
|
190
|
+
expect(responses).toEqual(2);
|
|
191
|
+
}
|
|
192
|
+
catch (e) {
|
|
193
|
+
console.error('Error running test: ', e);
|
|
194
|
+
throw e;
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
it('issues renewed token when needed', async () => {
|
|
198
|
+
const { User, nymph } = createNymphTilmeldServer({
|
|
199
|
+
jwtExpire: 5,
|
|
200
|
+
jwtRenew: 5,
|
|
201
|
+
});
|
|
202
|
+
let responses = 0;
|
|
203
|
+
nymph.on('response', (response) => {
|
|
204
|
+
expect(response.headers.get('set-cookie')).toMatch(/^TILMELDAUTH=[^;]+; Max-Age=5; Domain=localhost; Path=\/; Expires=[^;]+; SameSite=Strict$/);
|
|
205
|
+
responses++;
|
|
206
|
+
});
|
|
207
|
+
try {
|
|
208
|
+
const { admin } = await createAdmin(User);
|
|
209
|
+
expect(await admin.$gatekeeper()).toBeTruthy();
|
|
210
|
+
expect(responses).toEqual(2);
|
|
211
|
+
}
|
|
212
|
+
catch (e) {
|
|
213
|
+
console.error('Error running test: ', e);
|
|
214
|
+
throw e;
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
it("doesn't issue renewed token when requested", async () => {
|
|
218
|
+
const { User, nymph } = createNymphTilmeldServer({
|
|
219
|
+
jwtExpire: 5,
|
|
220
|
+
jwtRenew: 5,
|
|
221
|
+
}, { renewTokens: false });
|
|
222
|
+
let responses = 0;
|
|
223
|
+
nymph.on('response', (response) => {
|
|
224
|
+
if (responses === 0) {
|
|
225
|
+
expect(response.headers.get('set-cookie')).toMatch(/^TILMELDAUTH=[^;]+; Max-Age=5; Domain=localhost; Path=\/; Expires=[^;]+; SameSite=Strict$/);
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
expect(response.headers.has('set-cookie')).toBeFalsy();
|
|
229
|
+
}
|
|
230
|
+
responses++;
|
|
231
|
+
});
|
|
232
|
+
try {
|
|
233
|
+
const { admin } = await createAdmin(User);
|
|
234
|
+
expect(await admin.$gatekeeper()).toBeTruthy();
|
|
235
|
+
expect(responses).toEqual(2);
|
|
236
|
+
}
|
|
237
|
+
catch (e) {
|
|
238
|
+
console.error('Error running test: ', e);
|
|
239
|
+
throw e;
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
//# sourceMappingURL=index.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":";;;;;AACA,sDAA8B;AAC9B,6EAAoD;AACpD,0CAAsD;AACtD,sDAA6C;AAE7C,8CAK0B;AAC1B,6DAA2C;AAE3C,mCAKiB;AAEjB,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,IAAI,MAAM,GAAuB,SAAS,CAAC;IAE3C,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,MAAM,EAAE,CAAC;YACX,MAA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description": "Nymph.js - Tilmeld Client",
|
|
5
5
|
"browser": "dist/index.js",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -36,6 +36,11 @@
|
|
|
36
36
|
},
|
|
37
37
|
"license": "Apache-2.0",
|
|
38
38
|
"devDependencies": {
|
|
39
|
+
"@nymphjs/client-node": "^1.0.0-beta.57",
|
|
40
|
+
"@nymphjs/driver-sqlite3": "^1.0.0-beta.57",
|
|
41
|
+
"@nymphjs/nymph": "^1.0.0-beta.57",
|
|
42
|
+
"@nymphjs/server": "^1.0.0-beta.57",
|
|
43
|
+
"@nymphjs/tilmeld": "^1.0.0-beta.57",
|
|
39
44
|
"@tsconfig/recommended": "^1.0.3",
|
|
40
45
|
"@types/jest": "^29.5.12",
|
|
41
46
|
"jest": "^29.7.0",
|
|
@@ -46,7 +51,7 @@
|
|
|
46
51
|
"webpack-cli": "^5.1.4"
|
|
47
52
|
},
|
|
48
53
|
"dependencies": {
|
|
49
|
-
"@nymphjs/client": "^1.0.0-beta.
|
|
54
|
+
"@nymphjs/client": "^1.0.0-beta.57"
|
|
50
55
|
},
|
|
51
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "607f647fe16fb04c9b661bd872cc6cda53b0f530"
|
|
52
57
|
}
|
package/src/User.ts
CHANGED
|
@@ -458,9 +458,9 @@ export default class User extends Entity<UserData> {
|
|
|
458
458
|
if (currentToken !== token) {
|
|
459
459
|
if (token == null || token === '') {
|
|
460
460
|
if (currentToken != null) {
|
|
461
|
-
this.nymph.
|
|
461
|
+
delete this.nymph.headers['X-Xsrf-Token'];
|
|
462
462
|
if (this.nymph.pubsub) {
|
|
463
|
-
this.nymph.pubsub.
|
|
463
|
+
this.nymph.pubsub.authenticate(null);
|
|
464
464
|
}
|
|
465
465
|
currentToken = null;
|
|
466
466
|
}
|
|
@@ -472,9 +472,9 @@ export default class User extends Entity<UserData> {
|
|
|
472
472
|
? Buffer.from(base64, 'base64').toString('binary') // node
|
|
473
473
|
: atob(base64); // browser
|
|
474
474
|
const jwt = JSON.parse(json);
|
|
475
|
-
this.nymph.
|
|
475
|
+
this.nymph.headers['X-Xsrf-Token'] = jwt.xsrfToken;
|
|
476
476
|
if (this.nymph.pubsub) {
|
|
477
|
-
this.nymph.pubsub.
|
|
477
|
+
this.nymph.pubsub.authenticate(token, switchToken);
|
|
478
478
|
}
|
|
479
479
|
currentToken = token;
|
|
480
480
|
}
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import { type Server } from 'node:http';
|
|
2
|
+
import express from 'express';
|
|
3
|
+
import SQLite3Driver from '@nymphjs/driver-sqlite3';
|
|
4
|
+
import { Nymph as NymphServer } from '@nymphjs/nymph';
|
|
5
|
+
import { Nymph } from '@nymphjs/client-node';
|
|
6
|
+
import { type NymphOptions } from '@nymphjs/client';
|
|
7
|
+
import {
|
|
8
|
+
Tilmeld,
|
|
9
|
+
type Config as TilmeldConfig,
|
|
10
|
+
User as UserModelClass,
|
|
11
|
+
Group as GroupModelClass,
|
|
12
|
+
} from '@nymphjs/tilmeld';
|
|
13
|
+
import createServer from '@nymphjs/server';
|
|
14
|
+
|
|
15
|
+
import {
|
|
16
|
+
User as UserClass,
|
|
17
|
+
UserData,
|
|
18
|
+
Group as GroupClass,
|
|
19
|
+
CurrentUserData,
|
|
20
|
+
} from './index';
|
|
21
|
+
|
|
22
|
+
describe('Tilmeld Client', () => {
|
|
23
|
+
let server: Server | undefined = undefined;
|
|
24
|
+
|
|
25
|
+
afterEach(() => {
|
|
26
|
+
if (server) {
|
|
27
|
+
server.close(); // avoid jest open handle error
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
function createNymphTilmeldServer(
|
|
32
|
+
config?: Partial<TilmeldConfig>,
|
|
33
|
+
clientConfig?: Partial<NymphOptions>,
|
|
34
|
+
) {
|
|
35
|
+
const sqliteConfig = {
|
|
36
|
+
filename: ':memory:',
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const tilmeld = new Tilmeld({
|
|
40
|
+
jwtSecret: 'supersecrettestingsecret',
|
|
41
|
+
allowRegistration: true,
|
|
42
|
+
verifyEmail: false,
|
|
43
|
+
emailUsernames: false,
|
|
44
|
+
...config,
|
|
45
|
+
});
|
|
46
|
+
const nymphServer = new NymphServer(
|
|
47
|
+
{},
|
|
48
|
+
new SQLite3Driver(sqliteConfig),
|
|
49
|
+
tilmeld,
|
|
50
|
+
);
|
|
51
|
+
const UserModel = nymphServer.addEntityClass(UserModelClass);
|
|
52
|
+
const GroupModel = nymphServer.addEntityClass(GroupModelClass);
|
|
53
|
+
|
|
54
|
+
const app = express();
|
|
55
|
+
app.use('/test', createServer(nymphServer));
|
|
56
|
+
server = app.listen(5084);
|
|
57
|
+
|
|
58
|
+
const nymph = new Nymph({
|
|
59
|
+
restUrl: 'http://localhost:5084/test/',
|
|
60
|
+
...(clientConfig ?? {}),
|
|
61
|
+
});
|
|
62
|
+
const User = nymph.addEntityClass(UserClass);
|
|
63
|
+
User.init(nymph);
|
|
64
|
+
const Group = nymph.addEntityClass(GroupClass);
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
tilmeld,
|
|
68
|
+
nymphServer,
|
|
69
|
+
UserModel,
|
|
70
|
+
GroupModel,
|
|
71
|
+
app,
|
|
72
|
+
nymph,
|
|
73
|
+
User,
|
|
74
|
+
Group,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async function createAdmin(User: typeof UserClass) {
|
|
79
|
+
const admin = User.factorySync() as UserClass & UserData & CurrentUserData;
|
|
80
|
+
admin.username = 'admin';
|
|
81
|
+
admin.email = 'root@localhost';
|
|
82
|
+
admin.nameFirst = 'Admin';
|
|
83
|
+
admin.nameLast = 'User';
|
|
84
|
+
|
|
85
|
+
const result = await admin.$register({
|
|
86
|
+
password: 'supersecretadminpassword',
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
return { result, admin };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
async function createUser(User: typeof UserClass) {
|
|
93
|
+
const user = User.factorySync() as UserClass & UserData & CurrentUserData;
|
|
94
|
+
user.username = 'user';
|
|
95
|
+
user.email = 'user@localhost';
|
|
96
|
+
user.nameFirst = 'Some';
|
|
97
|
+
user.nameLast = 'User';
|
|
98
|
+
|
|
99
|
+
const result = await user.$register({
|
|
100
|
+
password: 'supersecretuserpassword',
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
return { result, user };
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
it('get client config', async () => {
|
|
107
|
+
const { User } = createNymphTilmeldServer();
|
|
108
|
+
|
|
109
|
+
const result = await User.getClientConfig();
|
|
110
|
+
|
|
111
|
+
expect(result).not.toBeNull();
|
|
112
|
+
expect(result.verifyEmail).toBeFalsy();
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('produce errors when register data is incorrect', async () => {
|
|
116
|
+
const { User } = createNymphTilmeldServer();
|
|
117
|
+
|
|
118
|
+
try {
|
|
119
|
+
const admin = User.factorySync() as UserClass &
|
|
120
|
+
UserData &
|
|
121
|
+
CurrentUserData;
|
|
122
|
+
|
|
123
|
+
let result = await admin.$register({
|
|
124
|
+
password: 'supersecretadminpassword',
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
expect(result.result).toBeFalsy();
|
|
128
|
+
expect(result.loggedin).toBeFalsy();
|
|
129
|
+
expect(result.message).toEqual('Please specify a username.');
|
|
130
|
+
expect(admin.guid).toBeNull();
|
|
131
|
+
|
|
132
|
+
admin.username = 'admin';
|
|
133
|
+
try {
|
|
134
|
+
expect(
|
|
135
|
+
(result = await admin.$register({
|
|
136
|
+
password: 'supersecretadminpassword',
|
|
137
|
+
})),
|
|
138
|
+
).toThrow();
|
|
139
|
+
} catch (e: any) {
|
|
140
|
+
expect(e.status).toEqual(400);
|
|
141
|
+
expect(e.message).toEqual('Please specify a valid email.');
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
admin.email = 'root@localhost';
|
|
145
|
+
try {
|
|
146
|
+
expect(
|
|
147
|
+
(result = await admin.$register({
|
|
148
|
+
password: 'supersecretadminpassword',
|
|
149
|
+
})),
|
|
150
|
+
).toThrow();
|
|
151
|
+
} catch (e: any) {
|
|
152
|
+
expect(e.status).toEqual(400);
|
|
153
|
+
expect(e.message).toEqual('Invalid User: "nameFirst" is required');
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
expect(admin.guid).toBeNull();
|
|
157
|
+
} catch (e: any) {
|
|
158
|
+
console.error('Error creating admin: ', e);
|
|
159
|
+
throw e;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it('create admin user', async () => {
|
|
164
|
+
const { User } = createNymphTilmeldServer();
|
|
165
|
+
|
|
166
|
+
try {
|
|
167
|
+
const { result, admin } = await createAdmin(User);
|
|
168
|
+
|
|
169
|
+
expect(result.result).toBeTruthy();
|
|
170
|
+
expect(result.loggedin).toBeTruthy();
|
|
171
|
+
expect(result.message).toEqual("You're now registered and logged in!");
|
|
172
|
+
|
|
173
|
+
expect(admin.guid).not.toBeNull();
|
|
174
|
+
expect(typeof admin.guid).toEqual('string');
|
|
175
|
+
|
|
176
|
+
const permission = await admin.$gatekeeper('system/admin');
|
|
177
|
+
|
|
178
|
+
expect(permission).toBeTruthy();
|
|
179
|
+
} catch (e: any) {
|
|
180
|
+
console.error('Error creating admin: ', e);
|
|
181
|
+
throw e;
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it('logout', async () => {
|
|
186
|
+
const { User } = createNymphTilmeldServer();
|
|
187
|
+
|
|
188
|
+
try {
|
|
189
|
+
const { admin } = await createAdmin(User);
|
|
190
|
+
|
|
191
|
+
const user1 = await User.current();
|
|
192
|
+
|
|
193
|
+
expect(user1?.guid).toEqual(admin.guid);
|
|
194
|
+
|
|
195
|
+
expect((await admin.$logout()).result).toBeTruthy();
|
|
196
|
+
|
|
197
|
+
const user2 = await User.current();
|
|
198
|
+
|
|
199
|
+
expect(user2).toBeNull();
|
|
200
|
+
} catch (e: any) {
|
|
201
|
+
console.error('Error running test: ', e);
|
|
202
|
+
throw e;
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it('second user', async () => {
|
|
207
|
+
const { User } = createNymphTilmeldServer();
|
|
208
|
+
|
|
209
|
+
try {
|
|
210
|
+
const { admin } = await createAdmin(User);
|
|
211
|
+
expect((await admin.$logout()).result).toBeTruthy();
|
|
212
|
+
|
|
213
|
+
const { result, user } = await createUser(User);
|
|
214
|
+
|
|
215
|
+
expect(result.result).toBeTruthy();
|
|
216
|
+
expect(result.loggedin).toBeTruthy();
|
|
217
|
+
expect(result.message).toEqual("You're now registered and logged in!");
|
|
218
|
+
|
|
219
|
+
expect(user.guid).not.toBeNull();
|
|
220
|
+
expect(typeof user.guid).toEqual('string');
|
|
221
|
+
|
|
222
|
+
const permission = await user.$gatekeeper('system/admin');
|
|
223
|
+
|
|
224
|
+
expect(permission).toBeFalsy();
|
|
225
|
+
} catch (e: any) {
|
|
226
|
+
console.error('Error running test: ', e);
|
|
227
|
+
throw e;
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
it("doesn't issue renewed token when not needed", async () => {
|
|
232
|
+
const { User, nymph } = createNymphTilmeldServer({
|
|
233
|
+
jwtExpire: 5,
|
|
234
|
+
jwtRenew: 0,
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
let responses = 0;
|
|
238
|
+
nymph.on('response', (response) => {
|
|
239
|
+
if (responses === 0) {
|
|
240
|
+
expect(response.headers.get('set-cookie')).toMatch(
|
|
241
|
+
/^TILMELDAUTH=[^;]+; Max-Age=5; Domain=localhost; Path=\/; Expires=[^;]+; SameSite=Strict$/,
|
|
242
|
+
);
|
|
243
|
+
} else {
|
|
244
|
+
expect(response.headers.has('set-cookie')).toBeFalsy();
|
|
245
|
+
}
|
|
246
|
+
responses++;
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
try {
|
|
250
|
+
const { admin } = await createAdmin(User);
|
|
251
|
+
|
|
252
|
+
expect(await admin.$gatekeeper()).toBeTruthy();
|
|
253
|
+
|
|
254
|
+
expect(responses).toEqual(2);
|
|
255
|
+
} catch (e: any) {
|
|
256
|
+
console.error('Error running test: ', e);
|
|
257
|
+
throw e;
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
it('issues renewed token when needed', async () => {
|
|
262
|
+
const { User, nymph } = createNymphTilmeldServer({
|
|
263
|
+
jwtExpire: 5,
|
|
264
|
+
jwtRenew: 5,
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
let responses = 0;
|
|
268
|
+
nymph.on('response', (response) => {
|
|
269
|
+
expect(response.headers.get('set-cookie')).toMatch(
|
|
270
|
+
/^TILMELDAUTH=[^;]+; Max-Age=5; Domain=localhost; Path=\/; Expires=[^;]+; SameSite=Strict$/,
|
|
271
|
+
);
|
|
272
|
+
responses++;
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
try {
|
|
276
|
+
const { admin } = await createAdmin(User);
|
|
277
|
+
|
|
278
|
+
expect(await admin.$gatekeeper()).toBeTruthy();
|
|
279
|
+
|
|
280
|
+
expect(responses).toEqual(2);
|
|
281
|
+
} catch (e: any) {
|
|
282
|
+
console.error('Error running test: ', e);
|
|
283
|
+
throw e;
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
it("doesn't issue renewed token when requested", async () => {
|
|
288
|
+
const { User, nymph } = createNymphTilmeldServer(
|
|
289
|
+
{
|
|
290
|
+
jwtExpire: 5,
|
|
291
|
+
jwtRenew: 5,
|
|
292
|
+
},
|
|
293
|
+
{ renewTokens: false },
|
|
294
|
+
);
|
|
295
|
+
|
|
296
|
+
let responses = 0;
|
|
297
|
+
nymph.on('response', (response) => {
|
|
298
|
+
if (responses === 0) {
|
|
299
|
+
expect(response.headers.get('set-cookie')).toMatch(
|
|
300
|
+
/^TILMELDAUTH=[^;]+; Max-Age=5; Domain=localhost; Path=\/; Expires=[^;]+; SameSite=Strict$/,
|
|
301
|
+
);
|
|
302
|
+
} else {
|
|
303
|
+
expect(response.headers.has('set-cookie')).toBeFalsy();
|
|
304
|
+
}
|
|
305
|
+
responses++;
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
try {
|
|
309
|
+
const { admin } = await createAdmin(User);
|
|
310
|
+
|
|
311
|
+
expect(await admin.$gatekeeper()).toBeTruthy();
|
|
312
|
+
|
|
313
|
+
expect(responses).toEqual(2);
|
|
314
|
+
} catch (e: any) {
|
|
315
|
+
console.error('Error running test: ', e);
|
|
316
|
+
throw e;
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
});
|