@nymphjs/tilmeld 1.0.0-beta.14 → 1.0.0-beta.140

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.
Files changed (105) hide show
  1. package/CHANGELOG.md +668 -0
  2. package/README.md +21 -5
  3. package/dist/AbleObject.d.ts +20 -2
  4. package/dist/AbleObject.js +25 -13
  5. package/dist/AbleObject.js.map +1 -1
  6. package/dist/Group.d.ts +190 -27
  7. package/dist/Group.js +827 -440
  8. package/dist/Group.js.map +1 -1
  9. package/dist/Group.testArtifacts.d.ts +3 -0
  10. package/dist/Group.testArtifacts.js +120 -0
  11. package/dist/Group.testArtifacts.js.map +1 -0
  12. package/dist/Tilmeld.d.ts +275 -14
  13. package/dist/Tilmeld.js +789 -310
  14. package/dist/Tilmeld.js.map +1 -1
  15. package/dist/Tilmeld.types.d.ts +9 -9
  16. package/dist/Tilmeld.types.js +1 -2
  17. package/dist/User.d.ts +410 -41
  18. package/dist/User.js +2042 -1057
  19. package/dist/User.js.map +1 -1
  20. package/dist/User.testArtifacts.d.ts +3 -0
  21. package/dist/User.testArtifacts.js +175 -0
  22. package/dist/User.testArtifacts.js.map +1 -0
  23. package/dist/conf/defaults.d.ts +1 -1
  24. package/dist/conf/defaults.js +215 -141
  25. package/dist/conf/defaults.js.map +1 -1
  26. package/dist/conf/index.d.ts +361 -2
  27. package/dist/conf/index.js +2 -8
  28. package/dist/conf/index.js.map +1 -1
  29. package/dist/decorators/index.d.ts +2 -0
  30. package/dist/decorators/index.js +3 -0
  31. package/dist/decorators/index.js.map +1 -0
  32. package/dist/decorators/requireAbility.d.ts +10 -0
  33. package/dist/decorators/requireAbility.js +21 -0
  34. package/dist/decorators/requireAbility.js.map +1 -0
  35. package/dist/decorators/requireAuthentication.d.ts +8 -0
  36. package/dist/decorators/requireAuthentication.js +16 -0
  37. package/dist/decorators/requireAuthentication.js.map +1 -0
  38. package/dist/enforceTilmeld.d.ts +3 -0
  39. package/dist/enforceTilmeld.js +18 -0
  40. package/dist/enforceTilmeld.js.map +1 -0
  41. package/dist/errors/AccessControlError.d.ts +2 -1
  42. package/dist/errors/AccessControlError.js +3 -6
  43. package/dist/errors/AccessControlError.js.map +1 -1
  44. package/dist/errors/BadDataError.d.ts +2 -1
  45. package/dist/errors/BadDataError.js +3 -6
  46. package/dist/errors/BadDataError.js.map +1 -1
  47. package/dist/errors/BadEmailError.d.ts +2 -1
  48. package/dist/errors/BadEmailError.js +3 -6
  49. package/dist/errors/BadEmailError.js.map +1 -1
  50. package/dist/errors/BadUsernameError.d.ts +2 -1
  51. package/dist/errors/BadUsernameError.js +3 -6
  52. package/dist/errors/BadUsernameError.js.map +1 -1
  53. package/dist/errors/CouldNotChangeDefaultPrimaryGroupError.js +1 -5
  54. package/dist/errors/CouldNotChangeDefaultPrimaryGroupError.js.map +1 -1
  55. package/dist/errors/EmailChangeRateLimitExceededError.js +1 -5
  56. package/dist/errors/EmailChangeRateLimitExceededError.js.map +1 -1
  57. package/dist/errors/index.d.ts +6 -6
  58. package/dist/errors/index.js +6 -22
  59. package/dist/errors/index.js.map +1 -1
  60. package/dist/index.d.ts +10 -14
  61. package/dist/index.js +11 -35
  62. package/dist/index.js.map +1 -1
  63. package/dist/testArtifacts.d.ts +26 -0
  64. package/dist/testArtifacts.js +1346 -0
  65. package/dist/testArtifacts.js.map +1 -0
  66. package/dist/tilmeldJoiProps.d.ts +4 -5
  67. package/dist/tilmeldJoiProps.js +13 -18
  68. package/dist/tilmeldJoiProps.js.map +1 -1
  69. package/jest.config.js +31 -5
  70. package/package.json +49 -36
  71. package/src/AbleObject.ts +17 -11
  72. package/src/Group.testArtifacts.ts +159 -0
  73. package/src/Group.ts +712 -299
  74. package/src/Tilmeld.ts +666 -344
  75. package/src/Tilmeld.types.ts +9 -9
  76. package/src/User.testArtifacts.ts +226 -0
  77. package/src/User.ts +1984 -879
  78. package/src/conf/defaults.ts +205 -109
  79. package/src/conf/index.ts +381 -2
  80. package/src/decorators/index.ts +2 -0
  81. package/src/decorators/requireAbility.ts +26 -0
  82. package/src/decorators/requireAuthentication.ts +19 -0
  83. package/src/enforceTilmeld.ts +20 -0
  84. package/src/errors/AccessControlError.ts +4 -2
  85. package/src/errors/BadDataError.ts +4 -2
  86. package/src/errors/BadEmailError.ts +4 -2
  87. package/src/errors/BadUsernameError.ts +4 -2
  88. package/src/errors/index.ts +6 -6
  89. package/src/index.ts +11 -14
  90. package/src/testArtifacts.ts +2148 -0
  91. package/src/tilmeldJoiProps.ts +9 -24
  92. package/tsconfig.json +6 -3
  93. package/typedoc.json +4 -0
  94. package/dist/Group.test.d.ts +0 -1
  95. package/dist/Group.test.js +0 -48
  96. package/dist/Group.test.js.map +0 -1
  97. package/dist/User.test.d.ts +0 -1
  98. package/dist/User.test.js +0 -51
  99. package/dist/User.test.js.map +0 -1
  100. package/dist/conf/d.d.ts +0 -55
  101. package/dist/conf/d.js +0 -3
  102. package/dist/conf/d.js.map +0 -1
  103. package/src/Group.test.ts +0 -58
  104. package/src/User.test.ts +0 -61
  105. package/src/conf/d.ts +0 -303
@@ -1,3 +1,362 @@
1
- export { Config } from './d';
2
- import defaults from './defaults';
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 { User } from '../User.js';
5
+ /**
6
+ * Tilmeld Config
7
+ */
8
+ export interface Config {
9
+ /**
10
+ * The name of the app. Used in emails sent to users and as the TOTP issuer.
11
+ */
12
+ appName: string;
13
+ /**
14
+ * The URL of the app. Used to define cookie domain, path, and security. Must
15
+ * be accessible to the Tilmeld client JS. (Note, cookies are not specific to
16
+ * individual ports, so tokens will be sent to any port running on this host.)
17
+ */
18
+ appUrl: string;
19
+ /**
20
+ * The domain of the auth cookie.
21
+ */
22
+ cookieDomain: string;
23
+ /**
24
+ * The path of the auth cookie.
25
+ */
26
+ cookiePath: string;
27
+ /**
28
+ * The path (with leading slash and no trailing slash) where the setup utility
29
+ * is accessible. This is also used for email address verification.
30
+ *
31
+ * ***************************************************************************
32
+ * This portion of the app will **not** check for the XSRF token, so make sure
33
+ * your REST endpoint is **not** under this URL.
34
+ * ***************************************************************************
35
+ */
36
+ setupPath: string;
37
+ /**
38
+ * Allow the creation of an admin user. When a user is created, if there are
39
+ * no other users in the system, they will be granted all abilities.
40
+ */
41
+ createAdmin: boolean;
42
+ /**
43
+ * Instead of a "username", a user logs in and is referred to by their email
44
+ * address. Enabling this after many users have been created can be messy.
45
+ * Make sure they all have email addresses first.
46
+ *
47
+ * Email usernames cannot be enabled if domain support is.
48
+ */
49
+ emailUsernames: boolean;
50
+ /**
51
+ * Enable domain support.
52
+ *
53
+ * If domain support is enabled, usernames can be either bare, meaning they
54
+ * belong to the root domain, or can include a domain part (username@domain),
55
+ * meaning they belong to that domain.
56
+ *
57
+ * It also enables domain admin abilities, meaning a domain admin has the
58
+ * ability to create and modify users on the domain
59
+ * ("tilmeld/domain/example.com/admin").
60
+ *
61
+ * Once a user is created, whether it has a domain part can't be changed.
62
+ * However, it can be moved to a different domain.
63
+ *
64
+ * Domain support cannot be enabled if email usernames is.
65
+ */
66
+ domainSupport: boolean;
67
+ /**
68
+ * Allow users to register.
69
+ */
70
+ allowRegistration: boolean;
71
+ /**
72
+ * Allow users to change their username.
73
+ */
74
+ allowUsernameChange: boolean;
75
+ /**
76
+ * Whether frontend can search users. (Probably not a good idea if privacy is
77
+ * a concern.)
78
+ */
79
+ enableUserSearch: boolean;
80
+ /**
81
+ * Whether frontend can search groups. (Probably not a good idea if privacy is
82
+ * a concern. Same risks as user search if generatePrimary is true.)
83
+ */
84
+ enableGroupSearch: boolean;
85
+ /**
86
+ * A list of UIDs that can be read from the client by anyone. (getUID)
87
+ *
88
+ * Note: If you'd like to limit the access to logged in users, give them an
89
+ * ability like "uid/get/nameofuid".
90
+ */
91
+ clientReadableUIDs: string[];
92
+ /**
93
+ * A list of UIDs that can be created from the client by anyone. (newUID)
94
+ *
95
+ * Inclusion in this list implies inclusion in clientReadableUIDs.
96
+ *
97
+ * Note: If you'd like to limit the access to logged in users, give them an
98
+ * ability like "uid/new/nameofuid".
99
+ */
100
+ clientEnabledUIDs: string[];
101
+ /**
102
+ * A list of UIDs that can be set from the client by anyone. (setUID,
103
+ * renameUID)
104
+ *
105
+ * Inclusion in this list implies inclusion in clientReadableUIDs and
106
+ * clientEnabledUIDs.
107
+ *
108
+ * Note: There is no way to run renameUID from the client.
109
+ *
110
+ * Note: If you'd like to limit the access to logged in users, give them an
111
+ * ability like "uid/set/nameofuid".
112
+ */
113
+ clientSetabledUIDs: string[];
114
+ /**
115
+ * These will be the available fields for users. (Some fields, like username,
116
+ * can't be excluded.)
117
+ */
118
+ userFields: string[];
119
+ /**
120
+ * These fields will be available for the user to fill in when they register.
121
+ */
122
+ regFields: string[];
123
+ /**
124
+ * Verify users' email addresses upon registration/email change before
125
+ * allowing them to log in/change it.
126
+ */
127
+ verifyEmail: boolean;
128
+ /**
129
+ * After the user verifies their address, redirect them to this URL.
130
+ */
131
+ verifyRedirect: string;
132
+ /**
133
+ * After the user verifies an address change, redirect them to this URL.
134
+ */
135
+ verifyChangeRedirect: string;
136
+ /**
137
+ * After the user cancels an address change, redirect them to this URL.
138
+ */
139
+ cancelChangeRedirect: string;
140
+ /**
141
+ * Unverified users will be able to log in, but will only have the "unverified
142
+ * users" secondary group(s) until they verify their email. If set to false,
143
+ * their account will instead be disabled until they verify.
144
+ */
145
+ unverifiedAccess: boolean;
146
+ /**
147
+ * Don't let users change their email address more often than this. You can
148
+ * enter one value and one unit of time, such as "2 weeks". Leave blank to
149
+ * disable rate limiting.
150
+ *
151
+ * This also controls how long a user has to cancel an email address change
152
+ * from a link emailed to the old address.
153
+ */
154
+ emailRateLimit: string;
155
+ /**
156
+ * Allow users to recover their username and/or password through their
157
+ * registered email.
158
+ */
159
+ pwRecovery: boolean;
160
+ /**
161
+ * How long a recovery request is valid.
162
+ */
163
+ pwRecoveryTimeLimit: string;
164
+ /**
165
+ * Method used to store passwords. Salt is the most secure if the database is
166
+ * compromised.
167
+ *
168
+ * - Plain: Store the password in plain text. A very bad idea.
169
+ * - Digest: Store the password's digest (hash) using SHA-256. The minimum
170
+ * level of security, but not enough for modern apps.
171
+ * - Salt: Store the password's digest with a complex, unique salt using
172
+ * the scrypt algorithm. Modern, secure password storage.
173
+ *
174
+ * Really the only reason to use anything other than "salt" is if you need
175
+ * logins to be so incredibly fast you can't even perceive a delay. So, not in
176
+ * a web app.
177
+ *
178
+ * Options are: "plain", "digest", "salt"
179
+ */
180
+ pwMethod: 'plain' | 'digest' | 'salt';
181
+ /**
182
+ * Whether to create a new primary group for every user who registers. This
183
+ * can be useful for providing access to entities the user creates.
184
+ *
185
+ * In the case this is set, the default primary group, rather than being
186
+ * assigned to the user, is assigned as the parent of the generated group.
187
+ */
188
+ generatePrimary: boolean;
189
+ /**
190
+ * The GUID of the group above the highest groups allowed to be assigned as
191
+ * primary groups. True means all groups, and false means no groups.
192
+ */
193
+ highestPrimary: string | boolean;
194
+ /**
195
+ * The GUID of the group above the highest groups allowed to be assigned as
196
+ * secondary groups. True means all groups, and false means no groups.
197
+ */
198
+ highestSecondary: string | boolean;
199
+ /**
200
+ * Only these characters can be used when creating usernames and groupnames.
201
+ * (Doesn't apply to emails as usernames.)
202
+ */
203
+ validChars: string;
204
+ /**
205
+ * When a user enters an invalid name, this message will be displayed.
206
+ */
207
+ validCharsNotice: string;
208
+ /**
209
+ * Usernames and groupnames must match this regular expression. (Doesn't apply
210
+ * to emails as usernames.) By default, this ensures that the name begins and
211
+ * ends with an alphanumeric. (To allow anything, use .* inside the slashes.)
212
+ */
213
+ validRegex: RegExp;
214
+ /**
215
+ * When a user enters a name that doesn't match the regex, this message will
216
+ * be displayed.
217
+ */
218
+ validRegexNotice: string;
219
+ /**
220
+ * Email addresses must match this regular expression. By default, this uses
221
+ * the regex from the W3C HTML email element validation:
222
+ *
223
+ * https://html.spec.whatwg.org/multipage/input.html#email-state-(type=email)
224
+ */
225
+ validEmailRegex: RegExp;
226
+ /**
227
+ * When a user enters an email that doesn't match the regex, this message will
228
+ * be displayed.
229
+ */
230
+ validEmailRegexNotice: string;
231
+ /**
232
+ * Domains must match this regular expression. By default, this uses a regex
233
+ * that should match most domains:
234
+ *
235
+ * https://stackoverflow.com/a/26987741
236
+ */
237
+ validDomainRegex: RegExp;
238
+ /**
239
+ * When a user enters a domain that doesn't match the regex, this message will
240
+ * be displayed.
241
+ */
242
+ validDomainRegexNotice: string;
243
+ /**
244
+ * The minimum length for usernames.
245
+ */
246
+ minUsernameLength: number;
247
+ /**
248
+ * The maximum length for usernames. `Infinity` for unlimited.
249
+ */
250
+ maxUsernameLength: number;
251
+ /**
252
+ * The secret used to sign the JWT.
253
+ */
254
+ jwtSecret: string;
255
+ /**
256
+ * How long from current time, in seconds, the JWT token expires.
257
+ */
258
+ jwtExpire: number;
259
+ /**
260
+ * How long from current time, in seconds, the JWT token for a user switch
261
+ * expires.
262
+ */
263
+ jwtSwitchExpire: number;
264
+ /**
265
+ * How long, in seconds, before the JWT token expires to give the user a new
266
+ * one.
267
+ */
268
+ jwtRenew: number;
269
+ /**
270
+ * Function to build the JWT for user sessions.
271
+ */
272
+ jwtBuilder: (config: Config, user: User, switchToken?: boolean, switchForUser?: User) => string;
273
+ /**
274
+ * Function to verify that a JWT was signed with the secret key, validate its
275
+ * data, validate the XSRF token, and extract the GUID and dates.
276
+ *
277
+ * If no XSRF token is supplied, ignore it.
278
+ *
279
+ * Return false if the JWT is not valid, or an object with GUID, issued date,
280
+ * and expire date otherwise.
281
+ */
282
+ jwtExtract: (config: Config, token: string, xsrfToken?: string) => {
283
+ sub: string;
284
+ guid: string;
285
+ issued: Date;
286
+ expire: Date;
287
+ switch?: true;
288
+ } | null;
289
+ /**
290
+ * The absolute path to the email template directory. Used by the default
291
+ * email sender.
292
+ */
293
+ emailTemplateDir: string;
294
+ /**
295
+ * Configure an email object to prepare for sending.
296
+ *
297
+ * You can use this, for example, for DKIM signing.
298
+ *
299
+ * See: https://github.com/forwardemail/email-templates/blob/v8.0.9/README.md#Options
300
+ */
301
+ configEmail: (tilmeld: Tilmeld, options: EmailOptions, user: User) => Promise<EmailConfig>;
302
+ /**
303
+ * Send an email to a user. Uses `email-templates` by default.
304
+ *
305
+ * Check out the `emails` directory to see the templates used.
306
+ *
307
+ * In addition to the specific `locals` for each template, there are
308
+ * additional locals added by the default email sender:
309
+ *
310
+ * - System Information
311
+ * - siteName
312
+ * - siteLink
313
+ * - Recipient Information
314
+ * - toUsername
315
+ * - toName
316
+ * - toFirstName
317
+ * - toLastName
318
+ * - toEmail
319
+ * - toPhone
320
+ * - Current User Information (Only available if a user is logged in.)
321
+ * - username
322
+ * - name
323
+ * - firstName
324
+ * - lastName
325
+ * - email
326
+ */
327
+ sendEmail: (tilmeld: Tilmeld, options: EmailOptions, user: User) => Promise<boolean>;
328
+ /**
329
+ * The address you'd like to receive a notification of registered users, if
330
+ * any.
331
+ */
332
+ userRegisteredRecipient: string | null;
333
+ /**
334
+ * A function to run on a failed login attempt.
335
+ *
336
+ * If the username the client attempted doesn't exist, user will be null.
337
+ *
338
+ * This defaults to a promise that resolves after 3-5 seconds. This rate
339
+ * limits failed login attempts.
340
+ *
341
+ * Please note that the data comes from the client, so the types have not been
342
+ * verified. For example, username might be an array or a number.
343
+ */
344
+ failedLoginAttempt: (user: User | null, data: {
345
+ username: string;
346
+ password: string;
347
+ code?: string;
348
+ additionalData?: {
349
+ [k: string]: any;
350
+ };
351
+ }) => Promise<void>;
352
+ /**
353
+ * The validator used to check groups before saving.
354
+ */
355
+ validatorGroup: (tilmeld: Tilmeld, group: Group) => void;
356
+ /**
357
+ * The validator used to check users before saving.
358
+ */
359
+ validatorUser: (tilmeld: Tilmeld, user: User) => void;
360
+ }
361
+ import defaults from './defaults.js';
3
362
  export { defaults as ConfigDefaults };
@@ -1,9 +1,3 @@
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
- exports.ConfigDefaults = void 0;
7
- const defaults_1 = __importDefault(require("./defaults"));
8
- exports.ConfigDefaults = defaults_1.default;
1
+ import defaults from './defaults.js';
2
+ export { defaults as ConfigDefaults };
9
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/conf/index.ts"],"names":[],"mappings":";;;;;;AAEA,0DAAkC;AACb,yBADd,kBAAQ,CACoB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/conf/index.ts"],"names":[],"mappings":"AA6XA,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,QAAQ,IAAI,cAAc,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './requireAbility.js';
2
+ export * from './requireAuthentication.js';
@@ -0,0 +1,3 @@
1
+ export * from './requireAbility.js';
2
+ export * from './requireAuthentication.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { Entity } from '@nymphjs/nymph';
2
+ /**
3
+ * A decorator that checks for an ability before running the method.
4
+ *
5
+ * If the logged in user does not have the given ability, the decorator will
6
+ * cause the method to throw a 403 Forbidden HttpError.
7
+ *
8
+ * @param ability The ability to check for.
9
+ */
10
+ export declare function requireAbility(ability: string): (target: (...args: any[]) => any, _context: ClassMethodDecoratorContext) => (this: Entity, ...args: unknown[]) => any;
@@ -0,0 +1,21 @@
1
+ import { HttpError } from '@nymphjs/nymph';
2
+ /**
3
+ * A decorator that checks for an ability before running the method.
4
+ *
5
+ * If the logged in user does not have the given ability, the decorator will
6
+ * cause the method to throw a 403 Forbidden HttpError.
7
+ *
8
+ * @param ability The ability to check for.
9
+ */
10
+ export function requireAbility(ability) {
11
+ return function (target, _context) {
12
+ return function (...args) {
13
+ if (this.$nymph.tilmeld == null ||
14
+ !this.$nymph.tilmeld.gatekeeper(ability)) {
15
+ throw new HttpError('Forbidden', 403);
16
+ }
17
+ return target.apply(this, args);
18
+ };
19
+ };
20
+ }
21
+ //# sourceMappingURL=requireAbility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requireAbility.js","sourceRoot":"","sources":["../../src/decorators/requireAbility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEnD;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAAC,OAAe;IAC5C,OAAO,UACL,MAA+B,EAC/B,QAAqC;QAErC,OAAO,UAAwB,GAAG,IAAe;YAC/C,IACE,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,IAAI;gBAC3B,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,EACxC,CAAC;gBACD,MAAM,IAAI,SAAS,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;YACxC,CAAC;YACD,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAClC,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { Entity } from '@nymphjs/nymph';
2
+ /**
3
+ * A decorator that checks for authentication before running the method.
4
+ *
5
+ * If the user is not logged in, the decorator will cause the method to throw a
6
+ * 403 Forbidden HttpError.
7
+ */
8
+ export declare function requireAuthentication(target: (...args: any[]) => any, _context: ClassMethodDecoratorContext): (this: Entity, ...args: unknown[]) => any;
@@ -0,0 +1,16 @@
1
+ import { HttpError } from '@nymphjs/nymph';
2
+ /**
3
+ * A decorator that checks for authentication before running the method.
4
+ *
5
+ * If the user is not logged in, the decorator will cause the method to throw a
6
+ * 403 Forbidden HttpError.
7
+ */
8
+ export function requireAuthentication(target, _context) {
9
+ return function (...args) {
10
+ if (this.$nymph.tilmeld == null || !this.$nymph.tilmeld.gatekeeper()) {
11
+ throw new HttpError('Forbidden', 403);
12
+ }
13
+ return target.apply(this, args);
14
+ };
15
+ }
16
+ //# sourceMappingURL=requireAuthentication.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requireAuthentication.js","sourceRoot":"","sources":["../../src/decorators/requireAuthentication.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEnD;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CACnC,MAA+B,EAC/B,QAAqC;IAErC,OAAO,UAAwB,GAAG,IAAe;QAC/C,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;YACrE,MAAM,IAAI,SAAS,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;QACxC,CAAC;QACD,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Entity, EntityConstructor, Nymph } from '@nymphjs/nymph';
2
+ import Tilmeld from './Tilmeld.js';
3
+ export declare function enforceTilmeld(object: Nymph | Entity | EntityConstructor): Tilmeld;
@@ -0,0 +1,18 @@
1
+ import { Entity, Nymph } from '@nymphjs/nymph';
2
+ export function enforceTilmeld(object) {
3
+ let tilmeld;
4
+ if (object instanceof Entity) {
5
+ tilmeld = object.$nymph.tilmeld;
6
+ }
7
+ else if (object instanceof Nymph) {
8
+ tilmeld = object.tilmeld;
9
+ }
10
+ else {
11
+ tilmeld = object.nymph.tilmeld;
12
+ }
13
+ if (tilmeld == null) {
14
+ throw new Error('Tilmeld was not configured on this Nymph instance!');
15
+ }
16
+ return tilmeld;
17
+ }
18
+ //# sourceMappingURL=enforceTilmeld.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enforceTilmeld.js","sourceRoot":"","sources":["../src/enforceTilmeld.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAqB,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAIlE,MAAM,UAAU,cAAc,CAAC,MAA0C;IACvE,IAAI,OAA4B,CAAC;IACjC,IAAI,MAAM,YAAY,MAAM,EAAE,CAAC;QAC7B,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,OAA8B,CAAC;IACzD,CAAC;SAAM,IAAI,MAAM,YAAY,KAAK,EAAE,CAAC;QACnC,OAAO,GAAG,MAAM,CAAC,OAA8B,CAAC;IAClD,CAAC;SAAM,CAAC;QACN,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,OAA8B,CAAC;IACxD,CAAC;IAED,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IACxE,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -1,3 +1,4 @@
1
- export declare class AccessControlError extends Error {
1
+ import { HttpError } from '@nymphjs/nymph';
2
+ export declare class AccessControlError extends HttpError {
2
3
  constructor(message: string);
3
4
  }
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AccessControlError = void 0;
4
- class AccessControlError extends Error {
1
+ import { HttpError } from '@nymphjs/nymph';
2
+ export class AccessControlError extends HttpError {
5
3
  constructor(message) {
6
- super(message);
4
+ super(message, 403);
7
5
  this.name = 'AccessControlError';
8
6
  }
9
7
  }
10
- exports.AccessControlError = AccessControlError;
11
8
  //# sourceMappingURL=AccessControlError.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AccessControlError.js","sourceRoot":"","sources":["../../src/errors/AccessControlError.ts"],"names":[],"mappings":";;;AAAA,MAAa,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AALD,gDAKC"}
1
+ {"version":3,"file":"AccessControlError.js","sourceRoot":"","sources":["../../src/errors/AccessControlError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,OAAO,kBAAmB,SAAQ,SAAS;IAC/C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF"}
@@ -1,3 +1,4 @@
1
- export declare class BadDataError extends Error {
1
+ import { HttpError } from '@nymphjs/nymph';
2
+ export declare class BadDataError extends HttpError {
2
3
  constructor(message: string);
3
4
  }
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BadDataError = void 0;
4
- class BadDataError extends Error {
1
+ import { HttpError } from '@nymphjs/nymph';
2
+ export class BadDataError extends HttpError {
5
3
  constructor(message) {
6
- super(message);
4
+ super(message, 400);
7
5
  this.name = 'BadDataError';
8
6
  }
9
7
  }
10
- exports.BadDataError = BadDataError;
11
8
  //# sourceMappingURL=BadDataError.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BadDataError.js","sourceRoot":"","sources":["../../src/errors/BadDataError.ts"],"names":[],"mappings":";;;AAAA,MAAa,YAAa,SAAQ,KAAK;IACrC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AALD,oCAKC"}
1
+ {"version":3,"file":"BadDataError.js","sourceRoot":"","sources":["../../src/errors/BadDataError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,OAAO,YAAa,SAAQ,SAAS;IACzC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF"}
@@ -1,3 +1,4 @@
1
- export declare class BadEmailError extends Error {
1
+ import { HttpError } from '@nymphjs/nymph';
2
+ export declare class BadEmailError extends HttpError {
2
3
  constructor(message: string);
3
4
  }
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BadEmailError = void 0;
4
- class BadEmailError extends Error {
1
+ import { HttpError } from '@nymphjs/nymph';
2
+ export class BadEmailError extends HttpError {
5
3
  constructor(message) {
6
- super(message);
4
+ super(message, 400);
7
5
  this.name = 'BadEmailError';
8
6
  }
9
7
  }
10
- exports.BadEmailError = BadEmailError;
11
8
  //# sourceMappingURL=BadEmailError.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BadEmailError.js","sourceRoot":"","sources":["../../src/errors/BadEmailError.ts"],"names":[],"mappings":";;;AAAA,MAAa,aAAc,SAAQ,KAAK;IACtC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AALD,sCAKC"}
1
+ {"version":3,"file":"BadEmailError.js","sourceRoot":"","sources":["../../src/errors/BadEmailError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,OAAO,aAAc,SAAQ,SAAS;IAC1C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF"}
@@ -1,3 +1,4 @@
1
- export declare class BadUsernameError extends Error {
1
+ import { HttpError } from '@nymphjs/nymph';
2
+ export declare class BadUsernameError extends HttpError {
2
3
  constructor(message: string);
3
4
  }
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BadUsernameError = void 0;
4
- class BadUsernameError extends Error {
1
+ import { HttpError } from '@nymphjs/nymph';
2
+ export class BadUsernameError extends HttpError {
5
3
  constructor(message) {
6
- super(message);
4
+ super(message, 400);
7
5
  this.name = 'BadUsernameError';
8
6
  }
9
7
  }
10
- exports.BadUsernameError = BadUsernameError;
11
8
  //# sourceMappingURL=BadUsernameError.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BadUsernameError.js","sourceRoot":"","sources":["../../src/errors/BadUsernameError.ts"],"names":[],"mappings":";;;AAAA,MAAa,gBAAiB,SAAQ,KAAK;IACzC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF;AALD,4CAKC"}
1
+ {"version":3,"file":"BadUsernameError.js","sourceRoot":"","sources":["../../src/errors/BadUsernameError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,OAAO,gBAAiB,SAAQ,SAAS;IAC7C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF"}
@@ -1,11 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CouldNotChangeDefaultPrimaryGroupError = void 0;
4
- class CouldNotChangeDefaultPrimaryGroupError extends Error {
1
+ export class CouldNotChangeDefaultPrimaryGroupError extends Error {
5
2
  constructor(message) {
6
3
  super(message);
7
4
  this.name = 'CouldNotChangeDefaultPrimaryGroupError';
8
5
  }
9
6
  }
10
- exports.CouldNotChangeDefaultPrimaryGroupError = CouldNotChangeDefaultPrimaryGroupError;
11
7
  //# sourceMappingURL=CouldNotChangeDefaultPrimaryGroupError.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CouldNotChangeDefaultPrimaryGroupError.js","sourceRoot":"","sources":["../../src/errors/CouldNotChangeDefaultPrimaryGroupError.ts"],"names":[],"mappings":";;;AAAA,MAAa,sCAAuC,SAAQ,KAAK;IAC/D,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,wCAAwC,CAAC;IACvD,CAAC;CACF;AALD,wFAKC"}
1
+ {"version":3,"file":"CouldNotChangeDefaultPrimaryGroupError.js","sourceRoot":"","sources":["../../src/errors/CouldNotChangeDefaultPrimaryGroupError.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,sCAAuC,SAAQ,KAAK;IAC/D,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,wCAAwC,CAAC;IACvD,CAAC;CACF"}
@@ -1,11 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EmailChangeRateLimitExceededError = void 0;
4
- class EmailChangeRateLimitExceededError extends Error {
1
+ export class EmailChangeRateLimitExceededError extends Error {
5
2
  constructor(message) {
6
3
  super(message);
7
4
  this.name = 'EmailChangeRateLimitExceededError';
8
5
  }
9
6
  }
10
- exports.EmailChangeRateLimitExceededError = EmailChangeRateLimitExceededError;
11
7
  //# sourceMappingURL=EmailChangeRateLimitExceededError.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EmailChangeRateLimitExceededError.js","sourceRoot":"","sources":["../../src/errors/EmailChangeRateLimitExceededError.ts"],"names":[],"mappings":";;;AAAA,MAAa,iCAAkC,SAAQ,KAAK;IAC1D,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,mCAAmC,CAAC;IAClD,CAAC;CACF;AALD,8EAKC"}
1
+ {"version":3,"file":"EmailChangeRateLimitExceededError.js","sourceRoot":"","sources":["../../src/errors/EmailChangeRateLimitExceededError.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,iCAAkC,SAAQ,KAAK;IAC1D,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,mCAAmC,CAAC;IAClD,CAAC;CACF"}