@nymphjs/tilmeld-client 1.0.0-beta.7 → 1.0.0-beta.71

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,286 @@
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.71](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.70...v1.0.0-beta.71) (2024-09-20)
7
+
8
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
9
+
10
+ # [1.0.0-beta.70](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.69...v1.0.0-beta.70) (2024-09-20)
11
+
12
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
13
+
14
+ # [1.0.0-beta.69](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.68...v1.0.0-beta.69) (2024-09-19)
15
+
16
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
17
+
18
+ # [1.0.0-beta.68](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.67...v1.0.0-beta.68) (2024-09-19)
19
+
20
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
21
+
22
+ # [1.0.0-beta.67](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.66...v1.0.0-beta.67) (2024-09-03)
23
+
24
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
25
+
26
+ # [1.0.0-beta.66](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.65...v1.0.0-beta.66) (2024-08-06)
27
+
28
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
29
+
30
+ # [1.0.0-beta.65](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.64...v1.0.0-beta.65) (2024-08-05)
31
+
32
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
33
+
34
+ # [1.0.0-beta.64](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.63...v1.0.0-beta.64) (2024-08-04)
35
+
36
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
37
+
38
+ # [1.0.0-beta.63](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.62...v1.0.0-beta.63) (2024-06-18)
39
+
40
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
41
+
42
+ # [1.0.0-beta.62](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.61...v1.0.0-beta.62) (2024-06-15)
43
+
44
+ ### Bug Fixes
45
+
46
+ - update test with new error message ([05afe42](https://github.com/sciactive/nymphjs/commit/05afe42470d975278858edbe65ec1b29c1c43207))
47
+
48
+ # [1.0.0-beta.61](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.60...v1.0.0-beta.61) (2024-06-14)
49
+
50
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
51
+
52
+ # [1.0.0-beta.60](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.59...v1.0.0-beta.60) (2024-06-14)
53
+
54
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
55
+
56
+ # [1.0.0-beta.59](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.58...v1.0.0-beta.59) (2024-06-14)
57
+
58
+ ### Features
59
+
60
+ - add uniqueness constraint feature, refactor some types ([8133d32](https://github.com/sciactive/nymphjs/commit/8133d32b2c04907182dca2e9171b8217ed1b57e4))
61
+
62
+ # [1.0.0-beta.58](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.57...v1.0.0-beta.58) (2024-06-12)
63
+
64
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
65
+
66
+ # [1.0.0-beta.57](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.56...v1.0.0-beta.57) (2024-06-12)
67
+
68
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
69
+
70
+ # [1.0.0-beta.56](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.55...v1.0.0-beta.56) (2024-06-11)
71
+
72
+ ### Features
73
+
74
+ - allow connections where tokens are not renewed ([39071a5](https://github.com/sciactive/nymphjs/commit/39071a545644075190bd8213be25e0a0c46d2b5d))
75
+
76
+ # [1.0.0-beta.55](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.54...v1.0.0-beta.55) (2024-05-26)
77
+
78
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
79
+
80
+ # [1.0.0-beta.54](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.53...v1.0.0-beta.54) (2024-05-26)
81
+
82
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
83
+
84
+ # [1.0.0-beta.53](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.52...v1.0.0-beta.53) (2024-05-26)
85
+
86
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
87
+
88
+ # [1.0.0-beta.52](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.51...v1.0.0-beta.52) (2024-05-25)
89
+
90
+ ### Bug Fixes
91
+
92
+ - support setup app and users and groups when userFields is limited ([20e25a2](https://github.com/sciactive/nymphjs/commit/20e25a2bcc35f96b3146fd9d973e34083a85f854))
93
+
94
+ # [1.0.0-beta.51](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.50...v1.0.0-beta.51) (2024-04-12)
95
+
96
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
97
+
98
+ # [1.0.0-beta.50](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.49...v1.0.0-beta.50) (2024-04-08)
99
+
100
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
101
+
102
+ # [1.0.0-beta.49](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.48...v1.0.0-beta.49) (2024-03-04)
103
+
104
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
105
+
106
+ # [1.0.0-beta.48](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.47...v1.0.0-beta.48) (2023-11-10)
107
+
108
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
109
+
110
+ # [1.0.0-beta.47](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.46...v1.0.0-beta.47) (2023-11-10)
111
+
112
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
113
+
114
+ # [1.0.0-beta.46](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.45...v1.0.0-beta.46) (2023-08-29)
115
+
116
+ ### Features
117
+
118
+ - enable tilmeld admins to remove totp secret from users ([18455b3](https://github.com/sciactive/nymphjs/commit/18455b3edbbfa1188f8cf317438bbfa028ba8f47))
119
+
120
+ # [1.0.0-beta.45](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.44...v1.0.0-beta.45) (2023-07-17)
121
+
122
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
123
+
124
+ # [1.0.0-beta.44](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.43...v1.0.0-beta.44) (2023-07-13)
125
+
126
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
127
+
128
+ # [1.0.0-beta.43](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.42...v1.0.0-beta.43) (2023-07-12)
129
+
130
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
131
+
132
+ # [1.0.0-beta.42](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.41...v1.0.0-beta.42) (2023-07-12)
133
+
134
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
135
+
136
+ # [1.0.0-beta.41](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.40...v1.0.0-beta.41) (2023-07-12)
137
+
138
+ ### Features
139
+
140
+ - remove synchronous database queries ([b579fb2](https://github.com/sciactive/nymphjs/commit/b579fb2eacd96cdd1b386a62c5c00cdbb2438f6e))
141
+
142
+ # [1.0.0-beta.40](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.39...v1.0.0-beta.40) (2023-07-10)
143
+
144
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
145
+
146
+ # [1.0.0-beta.39](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.38...v1.0.0-beta.39) (2023-07-09)
147
+
148
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
149
+
150
+ # [1.0.0-beta.38](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.37...v1.0.0-beta.38) (2023-07-09)
151
+
152
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
153
+
154
+ # [1.0.0-beta.37](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.36...v1.0.0-beta.37) (2023-07-09)
155
+
156
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
157
+
158
+ # [1.0.0-beta.36](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.35...v1.0.0-beta.36) (2023-07-09)
159
+
160
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
161
+
162
+ # [1.0.0-beta.35](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.34...v1.0.0-beta.35) (2023-06-14)
163
+
164
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
165
+
166
+ # [1.0.0-beta.34](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.33...v1.0.0-beta.34) (2023-05-13)
167
+
168
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
169
+
170
+ # [1.0.0-beta.33](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.32...v1.0.0-beta.33) (2023-05-13)
171
+
172
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
173
+
174
+ # [1.0.0-beta.32](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.31...v1.0.0-beta.32) (2023-05-13)
175
+
176
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
177
+
178
+ # [1.0.0-beta.31](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.30...v1.0.0-beta.31) (2023-05-12)
179
+
180
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
181
+
182
+ # [1.0.0-beta.30](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.29...v1.0.0-beta.30) (2023-05-12)
183
+
184
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
185
+
186
+ # [1.0.0-beta.29](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.28...v1.0.0-beta.29) (2023-05-08)
187
+
188
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
189
+
190
+ # [1.0.0-beta.28](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.27...v1.0.0-beta.28) (2023-05-05)
191
+
192
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
193
+
194
+ # [1.0.0-beta.27](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.26...v1.0.0-beta.27) (2023-05-04)
195
+
196
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
197
+
198
+ # [1.0.0-beta.26](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.25...v1.0.0-beta.26) (2023-05-04)
199
+
200
+ ### Features
201
+
202
+ - update packages and migrate to mysql2 ([72ad611](https://github.com/sciactive/nymphjs/commit/72ad611bd2bf7bf85c3ba8a3486503d9b50c49d6))
203
+
204
+ # [1.0.0-beta.25](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.24...v1.0.0-beta.25) (2023-05-04)
205
+
206
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
207
+
208
+ # [1.0.0-beta.24](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.23...v1.0.0-beta.24) (2023-05-02)
209
+
210
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
211
+
212
+ # [1.0.0-beta.23](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.22...v1.0.0-beta.23) (2023-05-02)
213
+
214
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
215
+
216
+ # [1.0.0-beta.22](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.21...v1.0.0-beta.22) (2023-05-01)
217
+
218
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
219
+
220
+ # [1.0.0-beta.21](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.20...v1.0.0-beta.21) (2023-05-01)
221
+
222
+ ### Features
223
+
224
+ - add totp two factor authentication ([cc9f8ed](https://github.com/sciactive/nymphjs/commit/cc9f8edb183271fa7f51e4b182b876efb8fa0f8d))
225
+
226
+ # [1.0.0-beta.20](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.19...v1.0.0-beta.20) (2023-04-30)
227
+
228
+ ### Features
229
+
230
+ - let the user revoke all current auth tokens ([63af3b9](https://github.com/sciactive/nymphjs/commit/63af3b9a31c6c221ab40c2c8a69231675f4634a2))
231
+
232
+ # [1.0.0-beta.19](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.18...v1.0.0-beta.19) (2023-04-29)
233
+
234
+ ### Bug Fixes
235
+
236
+ - some type issues ([ee69d5d](https://github.com/sciactive/nymphjs/commit/ee69d5d73361dacda5745d697df18fafd47810bc))
237
+
238
+ # [1.0.0-beta.18](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.17...v1.0.0-beta.18) (2023-04-27)
239
+
240
+ ### Features
241
+
242
+ - add the ability to switch to a user without their password ([ca4466a](https://github.com/sciactive/nymphjs/commit/ca4466af1704d68905ac087350a8cf151c1072d9))
243
+
244
+ # [1.0.0-beta.17](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.16...v1.0.0-beta.17) (2023-04-24)
245
+
246
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
247
+
248
+ # [1.0.0-beta.16](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.15...v1.0.0-beta.16) (2023-03-31)
249
+
250
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
251
+
252
+ # [1.0.0-beta.15](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.14...v1.0.0-beta.15) (2023-03-23)
253
+
254
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
255
+
256
+ # [1.0.0-beta.14](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.13...v1.0.0-beta.14) (2023-03-17)
257
+
258
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
259
+
260
+ # [1.0.0-beta.13](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.12...v1.0.0-beta.13) (2023-03-16)
261
+
262
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
263
+
264
+ # [1.0.0-beta.12](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.11...v1.0.0-beta.12) (2023-03-04)
265
+
266
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
267
+
268
+ # [1.0.0-beta.11](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.10...v1.0.0-beta.11) (2023-02-27)
269
+
270
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
271
+
272
+ # [1.0.0-beta.10](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.9...v1.0.0-beta.10) (2023-01-19)
273
+
274
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
275
+
276
+ # [1.0.0-beta.9](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.8...v1.0.0-beta.9) (2023-01-09)
277
+
278
+ **Note:** Version bump only for package @nymphjs/tilmeld-client
279
+
280
+ # [1.0.0-beta.8](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.7...v1.0.0-beta.8) (2023-01-09)
281
+
282
+ ### Features
283
+
284
+ - make entities in nymph client instance specific too ([1029f06](https://github.com/sciactive/nymphjs/commit/1029f061a1ad193e4a8a2dab0186b9a4b517f646))
285
+
6
286
  # [1.0.0-beta.7](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.6...v1.0.0-beta.7) (2023-01-05)
7
287
 
8
288
  **Note:** Version bump only for package @nymphjs/tilmeld-client
package/README.md CHANGED
@@ -16,33 +16,24 @@ You can find UMD in `dist`, or TS source in `src`.
16
16
 
17
17
  The Tilmeld client contains the client versions of the `User` and `Group` entities. It also contains helpers, `login`, `register`, and `checkUsername`.
18
18
 
19
- Once you've initialized Nymph Client, set the User and Group classes on it.
19
+ Once you've initialized Nymph Client, set the User and Group classes on it. Then initialize the new User class with the Nymph instance. (This allows the class to set up authentication listeners.)
20
20
 
21
21
  ```ts
22
22
  import { Nymph } from '@nymphjs/client';
23
- import { User, Group } from '@nymphjs/tilmeld-client';
23
+ import {
24
+ User as UserClass,
25
+ Group as GroupClass,
26
+ } from '@nymphjs/tilmeld-client';
24
27
 
25
28
  const nymph = new Nymph({
26
29
  restUrl: 'https://yournymphrestserver/path/to/your/endpoint',
27
30
  });
28
- nymph.addEntityClass(User);
29
- nymph.addEntityClass(Group);
31
+ const User = nymph.addEntityClass(UserClass);
32
+ const Group = nymph.addEntityClass(GroupClass);
33
+ User.init(nymph);
30
34
  ```
31
35
 
32
- If you're running more than one instance of Nymph client, you can clone the classes and add those instead. This will keep event listeners and Tilmeld client config separated.
33
-
34
- ```ts
35
- import { Nymph } from '@nymphjs/client';
36
- import { User, Group } from '@nymphjs/tilmeld-client';
37
-
38
- const nymph = new Nymph({
39
- restUrl: 'https://yournymphrestserver/path/to/your/endpoint',
40
- });
41
- const UserClone = User.clone();
42
- nymph.addEntityClass(UserClone);
43
- const GroupClone = Group.clone();
44
- nymph.addEntityClass(GroupClone);
45
- ```
36
+ If you're running more than one instance of Nymph client, be sure to use the classes returned by `addEntityClass`, so as not to accidentally submit entities from one instances to another instance.
46
37
 
47
38
  # License
48
39
 
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 a extends s.Entity{static clone(){return class extends a{}}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])}}t.default=a,a.class="Group"},178:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const s=r(778);let a=null;class n extends s.Entity{static set nymph(e){this.nymphValue=e,this.removeNymphResponseListener&&this.removeNymphResponseListener(),this.removeNymphResponseListener=this.nymph.on("response",(e=>this.handleToken(e))),this.handleToken()}static get nymph(){return this.nymphValue}static clone(){class e extends n{}return e.registerCallbacks=[],e.loginCallbacks=[],e.logoutCallbacks=[],e}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=this.constructor,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){t.handleToken();for(let e=0;e<t.loginCallbacks.length;e++)t.loginCallbacks[e]&&t.loginCallbacks[e](this)}return r}async $logout(){const e=this.constructor,t=await this.$serverCall("$logout",[]);if(t.result){e.handleToken();for(let t=0;t<e.logoutCallbacks.length;t++)e.logoutCallbacks[t]&&e.logoutCallbacks[t](this)}return t}async $gatekeeper(e){return await this.$serverCall("$gatekeeper",[e],!0)}async $changePassword(e){return await this.$serverCall("$changePassword",[e])}static async current(e){const t=await this.serverCallStatic("current",[!1]);return null==t?e?this.factorySync():null:t}static async loginUser(e){const t=await this.serverCallStatic("loginUser",[e]);if(t.result){this.handleToken();for(let e=0;e<this.loginCallbacks.length;e++)this.loginCallbacks[e]&&this.loginCallbacks[e](t.user)}return t}static async sendRecovery(e){return await this.serverCallStatic("sendRecovery",[e])}static async recover(e){return await this.serverCallStatic("recover",[e])}static async getClientConfig(){return this.clientConfig?this.clientConfig:(this.clientConfigPromise||(this.clientConfigPromise=this.serverCallStatic("getClientConfig",[]).then((e=>(this.clientConfig=e,this.clientConfigPromise=void 0,e)))),await this.clientConfigPromise)}static handleToken(e){let t=null;const r=/(?:(?:^|.*;\s*)TILMELDAUTH\s*=\s*([^;]*).*$)|^.*$/;if(e&&e.headers.has("X-TILMELDAUTH"))t=e.headers.get("X-TILMELDAUTH");else{if("undefined"==typeof document||!document.cookie.match(r))return;t=document.cookie.replace(r,"$1")}if(a!==t)if(null==t||""===t)null!=a&&(this.nymph.setXsrfToken(null),this.nymph.pubsub&&this.nymph.pubsub.setToken(null),a=null);else{const e=t.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),r="undefined"==typeof atob?Buffer.from(e,"base64").toString("binary"):atob(e),s=JSON.parse(r);this.nymph.setXsrfToken(s.xsrfToken),this.nymph.pubsub&&this.nymph.pubsub.setToken(t),a=t}}static on(e,t){const r=e+"Callbacks";if(!(r in this))throw new Error("Invalid event type.");return this[r].push(t),()=>this.off(e,t)}static off(e,t){const r=e+"Callbacks";if(!(r in this))return!1;const s=this[r].indexOf(t);return s>-1&&this[r].splice(s,1),!0}}t.default=n,n.class="User",n.registerCallbacks=[],n.loginCallbacks=[],n.logoutCallbacks=[]},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:a,...n}=await e.loginUser({username:t,password:r,...s?{additionalData:s}:{}});if(!a)throw new Error(n.message);return n}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 a=r||await e.getClientConfig();a.emailUsernames?s.email=t.username:-1!==a.regFields.indexOf("email")&&(s.email=t.email),-1!==a.regFields.indexOf("name")&&(s.nameFirst=t.nameFirst,s.nameLast=t.nameLast),-1!==a.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 a=Object.getOwnPropertyDescriptor(t,r);a&&!("get"in a?!t.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,a)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),a=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||s(t,e,r)},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.User=t.Group=void 0,a(r(848),t);const i=n(r(848));t.Group=i.default,a(r(13),t),a(r(178),t);const o=n(r(178));t.User=o.default},778:t=>{t.exports=e}},r={};return function e(s){var a=r[s];if(void 0!==a)return a.exports;var n=r[s]={exports:{}};return t[s].call(n.exports,n,n.exports,e),n.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={690:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const s=r(935);class n extends s.Entity{static async factoryGroupname(e){const t=new this;if(null!=e){const t=await this.nymph.getEntity({class:this},{type:"&",ilike:["groupname",e.replace(/([\\%_])/g,(e=>`\\${e}`))]});if(null!=t)return t}return t}constructor(){super(),this.$data.enabled=!0,this.$data.abilities=[]}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()}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}constructor(){super(),this.$data.enabled=!0,this.$data.abilities=[],this.$data.groups=[],this.$data.inheritAbilities=!0}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,mBAAXC,QAAyBA,OAAOC,IAC9CD,OAAO,CAAC,mBAAoBJ,GACF,iBAAZC,QACdA,QAAQ,2BAA6BD,EAAQG,QAAQ,oBAErDJ,EAAK,2BAA6BC,EAAQD,EAAK,oBARjD,CASGO,MAAOC,G,wCCRVC,OAAOC,eAAeR,EAAS,aAAc,CAAES,OAAO,IACtD,MAAMC,EAAW,EAAQ,KACzB,MAAMC,UAAcD,EAASE,OACzB,eAGI,OAFA,cAAyBD,IAI7BE,YAAYC,GACRC,MAAMD,GACM,MAARA,IACAT,KAAKW,MAAMC,SAAU,EACrBZ,KAAKW,MAAME,UAAY,IAG/B,qBAAqBJ,GACjB,aAAcC,MAAMhB,QAAQe,GAEhC,mBAAmBA,GACf,OAAOC,MAAMI,YAAYL,GAE7B,wBACI,aAAaT,KAAKe,YAAY,kBAAmB,IAAI,GAEzD,oBACI,aAAaf,KAAKe,YAAY,c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BE,GAAY,CAGjD1I,QAAS,IAOV,OAHA4I,EAAoBF,GAAUR,KAAKjI,EAAOD,QAASC,EAAQA,EAAOD,QAASyI,GAGpExI,EAAOD,QClBWyI,CAAoB,M","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 static clone() {\n class GroupClone extends Group {\n }\n return GroupClone;\n }\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}\nexports.default = Group;\nGroup.class = '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 set nymph(value) {\n this.nymphValue = value;\n if (this.removeNymphResponseListener) {\n this.removeNymphResponseListener();\n }\n this.removeNymphResponseListener = this.nymph.on('response', (response) => this.handleToken(response));\n this.handleToken();\n }\n static get nymph() {\n return this.nymphValue;\n }\n static clone() {\n class UserClone extends User {\n }\n UserClone.registerCallbacks = [];\n UserClone.loginCallbacks = [];\n UserClone.logoutCallbacks = [];\n return UserClone;\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 UserClass = this.constructor;\n const response = await this.$serverCall('$register', [data]);\n if (response.result) {\n for (let i = 0; i < UserClass.registerCallbacks.length; i++) {\n UserClass.registerCallbacks[i] && UserClass.registerCallbacks[i](this);\n }\n }\n if (response.loggedin) {\n UserClass.handleToken();\n for (let i = 0; i < UserClass.loginCallbacks.length; i++) {\n UserClass.loginCallbacks[i] && UserClass.loginCallbacks[i](this);\n }\n }\n return response;\n }\n async $logout() {\n const UserClass = this.constructor;\n const response = await this.$serverCall('$logout', []);\n if (response.result) {\n UserClass.handleToken();\n for (let i = 0; i < UserClass.logoutCallbacks.length; i++) {\n UserClass.logoutCallbacks[i] && UserClass.logoutCallbacks[i](this);\n }\n }\n return response;\n }\n async $gatekeeper(ability) {\n return await this.$serverCall('$gatekeeper', [ability], true);\n }\n async $changePassword(data) {\n return await this.$serverCall('$changePassword', [data]);\n }\n static async current(returnObjectIfNotExist) {\n const currentUser = await this.serverCallStatic('current', [false]);\n if (currentUser == null) {\n return returnObjectIfNotExist ? this.factorySync() : null;\n }\n return currentUser;\n }\n static async loginUser(data) {\n const response = await this.serverCallStatic('loginUser', [data]);\n if (response.result) {\n this.handleToken();\n for (let i = 0; i < this.loginCallbacks.length; i++) {\n this.loginCallbacks[i] && this.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 if (this.clientConfig) {\n return this.clientConfig;\n }\n if (!this.clientConfigPromise) {\n this.clientConfigPromise = this.serverCallStatic('getClientConfig', []).then((config) => {\n this.clientConfig = config;\n this.clientConfigPromise = undefined;\n return config;\n });\n }\n return await this.clientConfigPromise;\n }\n static handleToken(response) {\n let token = null;\n const authCookiePattern = /(?:(?:^|.*;\\s*)TILMELDAUTH\\s*=\\s*([^;]*).*$)|^.*$/;\n if (response && response.headers.has('X-TILMELDAUTH')) {\n token = response.headers.get('X-TILMELDAUTH');\n }\n else if (typeof document !== 'undefined' &&\n document.cookie.match(authCookiePattern)) {\n token = document.cookie.replace(authCookiePattern, '$1');\n }\n else {\n return;\n }\n if (currentToken !== token) {\n if (token == null || token === '') {\n if (currentToken != null) {\n this.nymph.setXsrfToken(null);\n if (this.nymph.pubsub) {\n this.nymph.pubsub.setToken(null);\n }\n currentToken = null;\n }\n }\n else {\n const base64Url = token.split('.')[1];\n const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');\n const json = typeof atob === 'undefined'\n ? Buffer.from(base64, 'base64').toString('binary')\n : atob(base64);\n const jwt = JSON.parse(json);\n this.nymph.setXsrfToken(jwt.xsrfToken);\n if (this.nymph.pubsub) {\n this.nymph.pubsub.setToken(token);\n }\n currentToken = token;\n }\n }\n }\n static on(event, callback) {\n const prop = (event + 'Callbacks');\n if (!(prop in this)) {\n throw new Error('Invalid event type.');\n }\n this[prop].push(callback);\n return () => this.off(event, callback);\n }\n static off(event, callback) {\n const prop = (event + 'Callbacks');\n if (!(prop in this)) {\n return false;\n }\n const i = this[prop].indexOf(callback);\n if (i > -1) {\n this[prop].splice(i, 1);\n }\n return true;\n }\n}\nexports.default = User;\nUser.class = 'User';\nUser.registerCallbacks = [];\nUser.loginCallbacks = [];\nUser.logoutCallbacks = [];\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","factorySync","$serverCall","andSelf","givenGroup","options","selectors","serverCallStatic","class","currentToken","User","nymphValue","removeNymphResponseListener","nymph","on","response","handleToken","UserClone","registerCallbacks","loginCallbacks","logoutCallbacks","groups","inheritAbilities","username","entity","getEntity","type","ilike","replace","s","data","UserClass","result","i","length","loggedin","ability","returnObjectIfNotExist","currentUser","user","clientConfig","clientConfigPromise","then","config","undefined","token","authCookiePattern","headers","has","get","document","cookie","match","setXsrfToken","pubsub","setToken","base64","split","json","atob","Buffer","from","toString","jwt","JSON","parse","xsrfToken","event","callback","prop","Error","push","off","indexOf","splice","checkUsername","register","login","async","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,OACzB,6BAAaC,CAAiBC,GAC1B,MAAMC,EAAS,IAAIV,KACnB,GAAiB,MAAbS,EAAmB,CACnB,MAAMC,QAAeV,KAAKW,MAAMC,UAAU,CACtCC,MAAOb,MACR,CACCc,KAAM,IACNC,MAAO,CAAC,YAAaN,EAAUO,QAAQ,aAAcC,GAAM,KAAKA,SAEpE,GAAc,MAAVP,EACA,OAAOA,CAEf,CACA,OAAOA,CACX,CACA,WAAAQ,GACIC,QACAnB,KAAKoB,MAAMC,SAAU,EACrBrB,KAAKoB,MAAME,UAAY,EAC3B,CACA,qBAAMC,GACF,aAAavB,KAAKwB,YAAY,kBAAmB,IAAI,EACzD,CACA,iBAAMC,GACF,aAAazB,KAAKwB,YAAY,cAAe,IAAI,EACrD,CACA,gBAAME,GACF,a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nK,EAASgK,IAAIb,EAAgBnJ,EAASsJ,EAAGU,EAC3H,EACII,EAAmB/J,MAAQA,KAAK+J,iBAAoB,SAAUC,GAC9D,OAAQA,GAAOA,EAAIV,WAAcU,EAAM,CAAE,QAAWA,EACxD,EACA9J,OAAOC,eAAeR,EAAS,aAAc,CAAES,OAAO,IACtDT,EAAQ4C,KAAO5C,EAAQW,WAAQ,EAC/BoJ,EAAa,EAAQ,KAAY/J,GACjC,MAAMsK,EAAUF,EAAgB,EAAQ,MACxCpK,EAAQW,MAAQ2J,EAAQC,QACxBR,EAAa,EAAQ,KAAc/J,GACnC+J,EAAa,EAAQ,KAAW/J,GAChC,MAAMwK,EAASJ,EAAgB,EAAQ,MACvCpK,EAAQ4C,KAAO4H,EAAOD,O,UC1BtBtK,EAAOD,QAAUM,C,GCCbmK,EAA2B,CAAC,E,OAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqB3E,IAAjB4E,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 static async factoryGroupname(groupname) {\n const entity = new this();\n if (groupname != null) {\n const entity = await this.nymph.getEntity({\n class: this,\n }, {\n type: '&',\n ilike: ['groupname', groupname.replace(/([\\\\%_])/g, (s) => `\\\\${s}`)],\n });\n if (entity != null) {\n return entity;\n }\n }\n return entity;\n }\n constructor() {\n super();\n this.$data.enabled = true;\n this.$data.abilities = [];\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 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 constructor() {\n super();\n this.$data.enabled = true;\n this.$data.abilities = [];\n this.$data.groups = [];\n this.$data.inheritAbilities = true;\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","factoryGroupname","groupname","entity","nymph","getEntity","class","type","ilike","replace","s","constructor","super","$data","enabled","abilities","$checkGroupname","$serverCall","$checkEmail","$getAvatar","$getChildren","$getDescendants","andSelf","$getLevel","$isDescendant","givenGroup","getPrimaryGroups","options","selectors","serverCallStatic","getSecondaryGroups","currentToken","User","init","store","registerCallbacks","loginCallbacks","logoutCallbacks","stores","has","storeVal","get","set","removeNymphResponseListener","on","response","handleToken","factoryUsername","username","groups","inheritAbilities","$checkUsername","$checkPhone","$register","data","$nymph","Error","result","i","length","loggedin","$switchUser","$logout","$gatekeeper","ability","$changePassword","$revokeCurrentTokens","$hasTOTPSecret","$getNewTOTPSecret","$saveTOTPSecret","$removeTOTPSecret","current","returnObjectIfNotExist","currentUser","factorySync","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,28 +2,62 @@ 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;
21
57
  export default class Group extends Entity<GroupData> {
22
58
  static class: string;
23
- static clone(): typeof Group;
24
- constructor(guid?: string);
25
- static factory(guid?: string): Promise<Group & GroupData>;
26
- static factorySync(guid?: string): Group & GroupData;
59
+ static factoryGroupname(groupname?: string): Promise<Group & GroupData>;
60
+ constructor();
27
61
  $checkGroupname(): Promise<{
28
62
  result: boolean;
29
63
  message: string;
package/lib/Group.js CHANGED
@@ -2,23 +2,25 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const client_1 = require("@nymphjs/client");
4
4
  class Group extends client_1.Entity {
5
- static clone() {
6
- class GroupClone extends Group {
5
+ static async factoryGroupname(groupname) {
6
+ const entity = new this();
7
+ if (groupname != null) {
8
+ const entity = await this.nymph.getEntity({
9
+ class: this,
10
+ }, {
11
+ type: '&',
12
+ ilike: ['groupname', groupname.replace(/([\\%_])/g, (s) => `\\${s}`)],
13
+ });
14
+ if (entity != null) {
15
+ return entity;
16
+ }
7
17
  }
8
- return GroupClone;
18
+ return entity;
9
19
  }
10
- constructor(guid) {
11
- super(guid);
12
- if (guid == null) {
13
- this.$data.enabled = true;
14
- this.$data.abilities = [];
15
- }
16
- }
17
- static async factory(guid) {
18
- return (await super.factory(guid));
19
- }
20
- static factorySync(guid) {
21
- return super.factorySync(guid);
20
+ constructor() {
21
+ super();
22
+ this.$data.enabled = true;
23
+ this.$data.abilities = [];
22
24
  }
23
25
  async $checkGroupname() {
24
26
  return await this.$serverCall('$checkGroupname', [], true);
@@ -54,6 +56,7 @@ class Group extends client_1.Entity {
54
56
  ]);
55
57
  }
56
58
  }
57
- exports.default = Group;
59
+ // The name of the server class
58
60
  Group.class = 'Group';
61
+ exports.default = Group;
59
62
  //# sourceMappingURL=Group.js.map