@nymphjs/tilmeld 1.0.0-beta.9 → 1.0.0-beta.90
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 +408 -0
- package/README.md +15 -2
- package/dist/AbleObject.d.ts +15 -0
- package/dist/AbleObject.js +18 -6
- package/dist/AbleObject.js.map +1 -1
- package/dist/Group.d.ts +140 -15
- package/dist/Group.js +466 -191
- package/dist/Group.js.map +1 -1
- package/dist/Group.test.js +83 -13
- package/dist/Group.test.js.map +1 -1
- package/dist/Tilmeld.d.ts +239 -12
- package/dist/Tilmeld.js +634 -254
- package/dist/Tilmeld.js.map +1 -1
- package/dist/Tilmeld.types.d.ts +2 -2
- package/dist/Tilmeld.types.js +1 -2
- package/dist/User.d.ts +365 -22
- package/dist/User.js +1265 -364
- package/dist/User.js.map +1 -1
- package/dist/User.test.js +132 -13
- package/dist/User.test.js.map +1 -1
- package/dist/conf/d.d.ts +287 -7
- package/dist/conf/d.js +1 -2
- package/dist/conf/defaults.d.ts +1 -1
- package/dist/conf/defaults.js +188 -141
- package/dist/conf/defaults.js.map +1 -1
- package/dist/conf/index.d.ts +2 -2
- package/dist/conf/index.js +2 -8
- package/dist/conf/index.js.map +1 -1
- package/dist/enforceTilmeld.d.ts +3 -0
- package/dist/enforceTilmeld.js +18 -0
- package/dist/enforceTilmeld.js.map +1 -0
- package/dist/errors/AccessControlError.d.ts +2 -1
- package/dist/errors/AccessControlError.js +3 -6
- package/dist/errors/AccessControlError.js.map +1 -1
- package/dist/errors/BadDataError.d.ts +2 -1
- package/dist/errors/BadDataError.js +3 -6
- package/dist/errors/BadDataError.js.map +1 -1
- package/dist/errors/BadEmailError.d.ts +2 -1
- package/dist/errors/BadEmailError.js +3 -6
- package/dist/errors/BadEmailError.js.map +1 -1
- package/dist/errors/BadUsernameError.d.ts +2 -1
- package/dist/errors/BadUsernameError.js +3 -6
- package/dist/errors/BadUsernameError.js.map +1 -1
- package/dist/errors/CouldNotChangeDefaultPrimaryGroupError.js +1 -5
- package/dist/errors/CouldNotChangeDefaultPrimaryGroupError.js.map +1 -1
- package/dist/errors/EmailChangeRateLimitExceededError.js +1 -5
- package/dist/errors/EmailChangeRateLimitExceededError.js.map +1 -1
- package/dist/errors/index.d.ts +6 -6
- package/dist/errors/index.js +6 -22
- package/dist/errors/index.js.map +1 -1
- package/dist/index.d.ts +11 -10
- package/dist/index.js +16 -35
- package/dist/index.js.map +1 -1
- package/dist/tilmeldJoiProps.js +13 -18
- package/dist/tilmeldJoiProps.js.map +1 -1
- package/jest.config.js +11 -2
- package/package.json +34 -31
- package/src/AbleObject.ts +2 -2
- package/src/Group.test.ts +104 -6
- package/src/Group.ts +478 -226
- package/src/Tilmeld.ts +418 -254
- package/src/Tilmeld.types.ts +2 -2
- package/src/User.test.ts +163 -6
- package/src/User.ts +1428 -444
- package/src/conf/d.ts +63 -17
- package/src/conf/defaults.ts +162 -109
- package/src/conf/index.ts +2 -2
- package/src/enforceTilmeld.ts +20 -0
- package/src/errors/AccessControlError.ts +4 -2
- package/src/errors/BadDataError.ts +4 -2
- package/src/errors/BadEmailError.ts +4 -2
- package/src/errors/BadUsernameError.ts +4 -2
- package/src/errors/index.ts +6 -6
- package/src/index.ts +12 -10
- package/src/tilmeldJoiProps.ts +11 -11
- package/src/type/locutus.d.ts +3 -0
- package/tsconfig.json +5 -3
- package/typedoc.json +4 -0
package/dist/conf/d.d.ts
CHANGED
|
@@ -1,55 +1,335 @@
|
|
|
1
|
-
import { EmailOptions, EmailConfig } from 'email-templates';
|
|
2
|
-
import type Tilmeld from '../Tilmeld';
|
|
3
|
-
import Group
|
|
4
|
-
import
|
|
1
|
+
import type { EmailOptions, EmailConfig } from 'email-templates';
|
|
2
|
+
import type Tilmeld from '../Tilmeld.js';
|
|
3
|
+
import type Group from '../Group.js';
|
|
4
|
+
import type { GroupData } from '../Group.js';
|
|
5
|
+
import type User from '../User.js';
|
|
6
|
+
import type { UserData } from '../User.js';
|
|
7
|
+
/**
|
|
8
|
+
* Tilmeld Config
|
|
9
|
+
*/
|
|
5
10
|
export interface Config {
|
|
11
|
+
/**
|
|
12
|
+
* The name of the app. Used in emails sent to users and as the TOTP issuer.
|
|
13
|
+
*/
|
|
6
14
|
appName: string;
|
|
15
|
+
/**
|
|
16
|
+
* The URL of the app. Used to define cookie domain, path, and security. Must
|
|
17
|
+
* be accessible to the Tilmeld client JS. (Note, cookies are not specific to
|
|
18
|
+
* individual ports, so tokens will be sent to any port running on this host.)
|
|
19
|
+
*/
|
|
7
20
|
appUrl: string;
|
|
21
|
+
/**
|
|
22
|
+
* The domain of the auth cookie.
|
|
23
|
+
*/
|
|
8
24
|
cookieDomain: string;
|
|
25
|
+
/**
|
|
26
|
+
* The path of the auth cookie.
|
|
27
|
+
*/
|
|
9
28
|
cookiePath: string;
|
|
29
|
+
/**
|
|
30
|
+
* The path (with leading slash and no trailing slash) where the setup utility
|
|
31
|
+
* is accessible. This is also used for email address verification.
|
|
32
|
+
*
|
|
33
|
+
* ***************************************************************************
|
|
34
|
+
* This portion of the app will **not** check for the XSRF token, so make sure
|
|
35
|
+
* your REST endpoint is **not** under this URL.
|
|
36
|
+
* ***************************************************************************
|
|
37
|
+
*/
|
|
10
38
|
setupPath: string;
|
|
39
|
+
/**
|
|
40
|
+
* Allow the creation of an admin user. When a user is created, if there are
|
|
41
|
+
* no other users in the system, they will be granted all abilities.
|
|
42
|
+
*/
|
|
11
43
|
createAdmin: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Instead of a "username", a user logs in and is referred to by their email
|
|
46
|
+
* address. Enabling this after many users have been created can be messy.
|
|
47
|
+
* Make sure they all have email addresses first.
|
|
48
|
+
*
|
|
49
|
+
* Email usernames cannot be enabled if domain support is.
|
|
50
|
+
*/
|
|
12
51
|
emailUsernames: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Enable domain support.
|
|
54
|
+
*
|
|
55
|
+
* If domain support is enabled, usernames can be either bare, meaning they
|
|
56
|
+
* belong to the root domain, or can include a domain part (username@domain),
|
|
57
|
+
* meaning they belong to that domain.
|
|
58
|
+
*
|
|
59
|
+
* It also enables domain admin abilities, meaning a domain admin has the
|
|
60
|
+
* ability to create and modify users on the domain
|
|
61
|
+
* ("tilmeld/domain/example.com/admin").
|
|
62
|
+
*
|
|
63
|
+
* Once a user is created, whether it has a domain part can't be changed.
|
|
64
|
+
* However, it can be moved to a different domain.
|
|
65
|
+
*
|
|
66
|
+
* Domain support cannot be enabled if email usernames is.
|
|
67
|
+
*/
|
|
68
|
+
domainSupport: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Allow users to register.
|
|
71
|
+
*/
|
|
13
72
|
allowRegistration: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Allow users to change their username.
|
|
75
|
+
*/
|
|
14
76
|
allowUsernameChange: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Whether frontend can search users. (Probably not a good idea if privacy is
|
|
79
|
+
* a concern.)
|
|
80
|
+
*/
|
|
15
81
|
enableUserSearch: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Whether frontend can search groups. (Probably not a good idea if privacy is
|
|
84
|
+
* a concern. Same risks as user search if generatePrimary is true.)
|
|
85
|
+
*/
|
|
16
86
|
enableGroupSearch: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* A list of UIDs that can be read from the client by anyone. (getUID)
|
|
89
|
+
*
|
|
90
|
+
* Note: If you'd like to limit the access to logged in users, give them an
|
|
91
|
+
* ability like "uid/get/nameofuid".
|
|
92
|
+
*/
|
|
17
93
|
clientReadableUIDs: string[];
|
|
94
|
+
/**
|
|
95
|
+
* A list of UIDs that can be created from the client by anyone. (newUID)
|
|
96
|
+
*
|
|
97
|
+
* Inclusion in this list implies inclusion in clientReadableUIDs.
|
|
98
|
+
*
|
|
99
|
+
* Note: If you'd like to limit the access to logged in users, give them an
|
|
100
|
+
* ability like "uid/new/nameofuid".
|
|
101
|
+
*/
|
|
18
102
|
clientEnabledUIDs: string[];
|
|
103
|
+
/**
|
|
104
|
+
* A list of UIDs that can be set from the client by anyone. (setUID,
|
|
105
|
+
* renameUID)
|
|
106
|
+
*
|
|
107
|
+
* Inclusion in this list implies inclusion in clientReadableUIDs and
|
|
108
|
+
* clientEnabledUIDs.
|
|
109
|
+
*
|
|
110
|
+
* Note: There is no way to run renameUID from the client.
|
|
111
|
+
*
|
|
112
|
+
* Note: If you'd like to limit the access to logged in users, give them an
|
|
113
|
+
* ability like "uid/set/nameofuid".
|
|
114
|
+
*/
|
|
19
115
|
clientSetabledUIDs: string[];
|
|
116
|
+
/**
|
|
117
|
+
* These will be the available fields for users. (Some fields, like username,
|
|
118
|
+
* can't be excluded.)
|
|
119
|
+
*/
|
|
20
120
|
userFields: string[];
|
|
121
|
+
/**
|
|
122
|
+
* These fields will be available for the user to fill in when they register.
|
|
123
|
+
*/
|
|
21
124
|
regFields: string[];
|
|
125
|
+
/**
|
|
126
|
+
* Verify users' email addresses upon registration/email change before
|
|
127
|
+
* allowing them to log in/change it.
|
|
128
|
+
*/
|
|
22
129
|
verifyEmail: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* After the user verifies their address, redirect them to this URL.
|
|
132
|
+
*/
|
|
23
133
|
verifyRedirect: string;
|
|
134
|
+
/**
|
|
135
|
+
* After the user verifies an address change, redirect them to this URL.
|
|
136
|
+
*/
|
|
24
137
|
verifyChangeRedirect: string;
|
|
138
|
+
/**
|
|
139
|
+
* After the user cancels an address change, redirect them to this URL.
|
|
140
|
+
*/
|
|
25
141
|
cancelChangeRedirect: string;
|
|
142
|
+
/**
|
|
143
|
+
* Unverified users will be able to log in, but will only have the "unverified
|
|
144
|
+
* users" secondary group(s) until they verify their email. If set to false,
|
|
145
|
+
* their account will instead be disabled until they verify.
|
|
146
|
+
*/
|
|
26
147
|
unverifiedAccess: boolean;
|
|
148
|
+
/**
|
|
149
|
+
* Don't let users change their email address more often than this. You can
|
|
150
|
+
* enter one value and one unit of time, such as "2 weeks". Leave blank to
|
|
151
|
+
* disable rate limiting.
|
|
152
|
+
*
|
|
153
|
+
* This also controls how long a user has to cancel an email address change
|
|
154
|
+
* from a link emailed to the old address.
|
|
155
|
+
*/
|
|
27
156
|
emailRateLimit: string;
|
|
157
|
+
/**
|
|
158
|
+
* Allow users to recover their username and/or password through their
|
|
159
|
+
* registered email.
|
|
160
|
+
*/
|
|
28
161
|
pwRecovery: boolean;
|
|
162
|
+
/**
|
|
163
|
+
* How long a recovery request is valid.
|
|
164
|
+
*/
|
|
29
165
|
pwRecoveryTimeLimit: string;
|
|
166
|
+
/**
|
|
167
|
+
* Method used to store passwords. Salt is more secure if the database is
|
|
168
|
+
* compromised. Plain: store the password in plaintext. Digest: store the
|
|
169
|
+
* password's digest (hash). Salt: store the password's digest using a
|
|
170
|
+
* complex, unique salt.
|
|
171
|
+
*
|
|
172
|
+
* Digests are SHA-256, so a salt probably isn't necessary, but who knows.
|
|
173
|
+
*
|
|
174
|
+
* Options are: "plain", "digest", "salt"
|
|
175
|
+
*/
|
|
30
176
|
pwMethod: 'plain' | 'digest' | 'salt';
|
|
177
|
+
/**
|
|
178
|
+
* Whether to create a new primary group for every user who registers. This
|
|
179
|
+
* can be useful for providing access to entities the user creates.
|
|
180
|
+
*
|
|
181
|
+
* In the case this is set, the default primary group, rather than being
|
|
182
|
+
* assigned to the user, is assigned as the parent of the generated group.
|
|
183
|
+
*/
|
|
31
184
|
generatePrimary: boolean;
|
|
185
|
+
/**
|
|
186
|
+
* The GUID of the group above the highest groups allowed to be assigned as
|
|
187
|
+
* primary groups. True means all groups, and false means no groups.
|
|
188
|
+
*/
|
|
32
189
|
highestPrimary: string | boolean;
|
|
190
|
+
/**
|
|
191
|
+
* The GUID of the group above the highest groups allowed to be assigned as
|
|
192
|
+
* secondary groups. True means all groups, and false means no groups.
|
|
193
|
+
*/
|
|
33
194
|
highestSecondary: string | boolean;
|
|
195
|
+
/**
|
|
196
|
+
* Only these characters can be used when creating usernames and groupnames.
|
|
197
|
+
* (Doesn't apply to emails as usernames.)
|
|
198
|
+
*/
|
|
34
199
|
validChars: string;
|
|
200
|
+
/**
|
|
201
|
+
* When a user enters an invalid name, this message will be displayed.
|
|
202
|
+
*/
|
|
35
203
|
validCharsNotice: string;
|
|
204
|
+
/**
|
|
205
|
+
* Usernames and groupnames must match this regular expression. (Doesn't apply
|
|
206
|
+
* to emails as usernames.) By default, this ensures that the name begins and
|
|
207
|
+
* ends with an alphanumeric. (To allow anything, use .* inside the slashes.)
|
|
208
|
+
*/
|
|
36
209
|
validRegex: RegExp;
|
|
210
|
+
/**
|
|
211
|
+
* When a user enters a name that doesn't match the regex, this message will
|
|
212
|
+
* be displayed.
|
|
213
|
+
*/
|
|
37
214
|
validRegexNotice: string;
|
|
215
|
+
/**
|
|
216
|
+
* Email addresses must match this regular expression. By default, this uses
|
|
217
|
+
* the regex from the W3C HTML email element validation:
|
|
218
|
+
*
|
|
219
|
+
* https://html.spec.whatwg.org/multipage/input.html#email-state-(type=email)
|
|
220
|
+
*/
|
|
38
221
|
validEmailRegex: RegExp;
|
|
222
|
+
/**
|
|
223
|
+
* When a user enters an email that doesn't match the regex, this message will
|
|
224
|
+
* be displayed.
|
|
225
|
+
*/
|
|
39
226
|
validEmailRegexNotice: string;
|
|
227
|
+
/**
|
|
228
|
+
* Domains must match this regular expression. By default, this uses a regex
|
|
229
|
+
* that should match most domains:
|
|
230
|
+
*
|
|
231
|
+
* https://stackoverflow.com/a/26987741
|
|
232
|
+
*/
|
|
233
|
+
validDomainRegex: RegExp;
|
|
234
|
+
/**
|
|
235
|
+
* When a user enters a domain that doesn't match the regex, this message will
|
|
236
|
+
* be displayed.
|
|
237
|
+
*/
|
|
238
|
+
validDomainRegexNotice: string;
|
|
239
|
+
/**
|
|
240
|
+
* The minimum length for usernames.
|
|
241
|
+
*/
|
|
242
|
+
minUsernameLength: number;
|
|
243
|
+
/**
|
|
244
|
+
* The maximum length for usernames. `Infinity` for unlimited.
|
|
245
|
+
*/
|
|
40
246
|
maxUsernameLength: number;
|
|
247
|
+
/**
|
|
248
|
+
* The secret used to sign the JWT.
|
|
249
|
+
*/
|
|
41
250
|
jwtSecret: string;
|
|
251
|
+
/**
|
|
252
|
+
* How long from current time, in seconds, the JWT token expires.
|
|
253
|
+
*/
|
|
42
254
|
jwtExpire: number;
|
|
255
|
+
/**
|
|
256
|
+
* How long from current time, in seconds, the JWT token for a user switch
|
|
257
|
+
* expires.
|
|
258
|
+
*/
|
|
259
|
+
jwtSwitchExpire: number;
|
|
260
|
+
/**
|
|
261
|
+
* How long, in seconds, before the JWT token expires to give the user a new
|
|
262
|
+
* one.
|
|
263
|
+
*/
|
|
43
264
|
jwtRenew: number;
|
|
44
|
-
|
|
265
|
+
/**
|
|
266
|
+
* Function to build the JWT for user sessions.
|
|
267
|
+
*/
|
|
268
|
+
jwtBuilder: (config: Config, user: User & UserData, switchToken?: boolean) => string;
|
|
269
|
+
/**
|
|
270
|
+
* Function to verify that a JWT was signed with the secret key, validate its
|
|
271
|
+
* data, validate the XSRF token, and extract the GUID and dates.
|
|
272
|
+
*
|
|
273
|
+
* If no XSRF token is supplied, ignore it.
|
|
274
|
+
*
|
|
275
|
+
* Return false if the JWT is not valid, or an object with GUID, issued date,
|
|
276
|
+
* and expire date otherwise.
|
|
277
|
+
*/
|
|
45
278
|
jwtExtract: (config: Config, token: string, xsrfToken?: string) => {
|
|
46
279
|
guid: string;
|
|
280
|
+
issued: Date;
|
|
47
281
|
expire: Date;
|
|
48
282
|
} | null;
|
|
283
|
+
/**
|
|
284
|
+
* The absolute path to the email template directory. Used by the default
|
|
285
|
+
* email sender.
|
|
286
|
+
*/
|
|
49
287
|
emailTemplateDir: string;
|
|
288
|
+
/**
|
|
289
|
+
* Configure an email object to prepare for sending.
|
|
290
|
+
*
|
|
291
|
+
* You can use this, for example, for DKIM signing.
|
|
292
|
+
*
|
|
293
|
+
* See: https://github.com/forwardemail/email-templates/blob/v8.0.9/README.md#Options
|
|
294
|
+
*/
|
|
50
295
|
configEmail: (tilmeld: Tilmeld, options: EmailOptions, user: User & UserData) => Promise<EmailConfig>;
|
|
296
|
+
/**
|
|
297
|
+
* Send an email to a user. Uses `email-templates` by default.
|
|
298
|
+
*
|
|
299
|
+
* Check out the `emails` directory to see the templates used.
|
|
300
|
+
*
|
|
301
|
+
* In addition to the specific `locals` for each template, there are
|
|
302
|
+
* additional locals added by the default email sender:
|
|
303
|
+
*
|
|
304
|
+
* - System Information
|
|
305
|
+
* - siteName
|
|
306
|
+
* - siteLink
|
|
307
|
+
* - Recipient Information
|
|
308
|
+
* - toUsername
|
|
309
|
+
* - toName
|
|
310
|
+
* - toFirstName
|
|
311
|
+
* - toLastName
|
|
312
|
+
* - toEmail
|
|
313
|
+
* - toPhone
|
|
314
|
+
* - Current User Information (Only available if a user is logged in.)
|
|
315
|
+
* - username
|
|
316
|
+
* - name
|
|
317
|
+
* - firstName
|
|
318
|
+
* - lastName
|
|
319
|
+
* - email
|
|
320
|
+
*/
|
|
51
321
|
sendEmail: (tilmeld: Tilmeld, options: EmailOptions, user: User & UserData) => Promise<boolean>;
|
|
322
|
+
/**
|
|
323
|
+
* The address you'd like to receive a notification of registered users, if
|
|
324
|
+
* any.
|
|
325
|
+
*/
|
|
52
326
|
userRegisteredRecipient: string | null;
|
|
53
|
-
|
|
54
|
-
|
|
327
|
+
/**
|
|
328
|
+
* The validator used to check groups before saving.
|
|
329
|
+
*/
|
|
330
|
+
validatorGroup: (tilmeld: Tilmeld, group: Group & GroupData) => void;
|
|
331
|
+
/**
|
|
332
|
+
* The validator used to check users before saving.
|
|
333
|
+
*/
|
|
334
|
+
validatorUser: (tilmeld: Tilmeld, user: User & UserData) => void;
|
|
55
335
|
}
|
package/dist/conf/d.js
CHANGED
package/dist/conf/defaults.d.ts
CHANGED