@nymphjs/tilmeld 1.0.0-beta.13 → 1.0.0-beta.131

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 +604 -0
  2. package/README.md +21 -5
  3. package/dist/AbleObject.d.ts +15 -0
  4. package/dist/AbleObject.js +18 -6
  5. package/dist/AbleObject.js.map +1 -1
  6. package/dist/Group.d.ts +183 -19
  7. package/dist/Group.js +814 -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 +241 -12
  13. package/dist/Tilmeld.js +725 -286
  14. package/dist/Tilmeld.js.map +1 -1
  15. package/dist/Tilmeld.types.d.ts +5 -5
  16. package/dist/Tilmeld.types.js +1 -2
  17. package/dist/User.d.ts +396 -26
  18. package/dist/User.js +1955 -1058
  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 +196 -141
  25. package/dist/conf/defaults.js.map +1 -1
  26. package/dist/conf/index.d.ts +355 -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 +12 -10
  61. package/dist/index.js +17 -35
  62. package/dist/index.js.map +1 -1
  63. package/dist/testArtifacts.d.ts +23 -0
  64. package/dist/testArtifacts.js +1317 -0
  65. package/dist/testArtifacts.js.map +1 -0
  66. package/dist/tilmeldJoiProps.d.ts +3 -3
  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 +2 -2
  72. package/src/Group.testArtifacts.ts +159 -0
  73. package/src/Group.ts +647 -241
  74. package/src/Tilmeld.ts +550 -315
  75. package/src/Tilmeld.types.ts +5 -5
  76. package/src/User.testArtifacts.ts +226 -0
  77. package/src/User.ts +1657 -637
  78. package/src/conf/defaults.ts +172 -109
  79. package/src/conf/index.ts +370 -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 +13 -10
  90. package/src/testArtifacts.ts +2098 -0
  91. package/src/tilmeldJoiProps.ts +8 -23
  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,356 @@
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 { GroupData } from '../Group.js';
5
+ import type User from '../User.js';
6
+ import type { UserData } from '../User.js';
7
+ /**
8
+ * Tilmeld Config
9
+ */
10
+ export interface Config {
11
+ /**
12
+ * The name of the app. Used in emails sent to users and as the TOTP issuer.
13
+ */
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
+ */
20
+ appUrl: string;
21
+ /**
22
+ * The domain of the auth cookie.
23
+ */
24
+ cookieDomain: string;
25
+ /**
26
+ * The path of the auth cookie.
27
+ */
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
+ */
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
+ */
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
+ */
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
+ */
72
+ allowRegistration: boolean;
73
+ /**
74
+ * Allow users to change their username.
75
+ */
76
+ allowUsernameChange: boolean;
77
+ /**
78
+ * Whether frontend can search users. (Probably not a good idea if privacy is
79
+ * a concern.)
80
+ */
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
+ */
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
+ */
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
+ */
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
+ */
115
+ clientSetabledUIDs: string[];
116
+ /**
117
+ * These will be the available fields for users. (Some fields, like username,
118
+ * can't be excluded.)
119
+ */
120
+ userFields: string[];
121
+ /**
122
+ * These fields will be available for the user to fill in when they register.
123
+ */
124
+ regFields: string[];
125
+ /**
126
+ * Verify users' email addresses upon registration/email change before
127
+ * allowing them to log in/change it.
128
+ */
129
+ verifyEmail: boolean;
130
+ /**
131
+ * After the user verifies their address, redirect them to this URL.
132
+ */
133
+ verifyRedirect: string;
134
+ /**
135
+ * After the user verifies an address change, redirect them to this URL.
136
+ */
137
+ verifyChangeRedirect: string;
138
+ /**
139
+ * After the user cancels an address change, redirect them to this URL.
140
+ */
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
+ */
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
+ */
156
+ emailRateLimit: string;
157
+ /**
158
+ * Allow users to recover their username and/or password through their
159
+ * registered email.
160
+ */
161
+ pwRecovery: boolean;
162
+ /**
163
+ * How long a recovery request is valid.
164
+ */
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
+ */
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
+ */
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
+ */
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
+ */
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
+ */
199
+ validChars: string;
200
+ /**
201
+ * When a user enters an invalid name, this message will be displayed.
202
+ */
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
+ */
209
+ validRegex: RegExp;
210
+ /**
211
+ * When a user enters a name that doesn't match the regex, this message will
212
+ * be displayed.
213
+ */
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
+ */
221
+ validEmailRegex: RegExp;
222
+ /**
223
+ * When a user enters an email that doesn't match the regex, this message will
224
+ * be displayed.
225
+ */
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
+ */
246
+ maxUsernameLength: number;
247
+ /**
248
+ * The secret used to sign the JWT.
249
+ */
250
+ jwtSecret: string;
251
+ /**
252
+ * How long from current time, in seconds, the JWT token expires.
253
+ */
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
+ */
264
+ jwtRenew: number;
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
+ */
278
+ jwtExtract: (config: Config, token: string, xsrfToken?: string) => {
279
+ guid: string;
280
+ issued: Date;
281
+ expire: Date;
282
+ } | null;
283
+ /**
284
+ * The absolute path to the email template directory. Used by the default
285
+ * email sender.
286
+ */
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
+ */
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
+ */
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
+ */
326
+ userRegisteredRecipient: string | null;
327
+ /**
328
+ * A function to run on a failed login attempt.
329
+ *
330
+ * If the username the client attempted doesn't exist, user will be null.
331
+ *
332
+ * This defaults to a promise that resolves after 3-5 seconds. This rate
333
+ * limits failed login attempts.
334
+ *
335
+ * Please note that the data comes from the client, so the types have not been
336
+ * verified. For example, username might be an array or a number.
337
+ */
338
+ failedLoginAttempt: (user: (User & UserData) | null, data: {
339
+ username: string;
340
+ password: string;
341
+ code?: string;
342
+ additionalData?: {
343
+ [k: string]: any;
344
+ };
345
+ }) => Promise<void>;
346
+ /**
347
+ * The validator used to check groups before saving.
348
+ */
349
+ validatorGroup: (tilmeld: Tilmeld, group: Group & GroupData) => void;
350
+ /**
351
+ * The validator used to check users before saving.
352
+ */
353
+ validatorUser: (tilmeld: Tilmeld, user: User & UserData) => void;
354
+ }
355
+ import defaults from './defaults.js';
3
356
  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":"AAkXA,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"}
@@ -1,6 +1,6 @@
1
- export * from './AccessControlError';
2
- export * from './BadDataError';
3
- export * from './BadEmailError';
4
- export * from './BadUsernameError';
5
- export * from './CouldNotChangeDefaultPrimaryGroupError';
6
- export * from './EmailChangeRateLimitExceededError';
1
+ export * from './AccessControlError.js';
2
+ export * from './BadDataError.js';
3
+ export * from './BadEmailError.js';
4
+ export * from './BadUsernameError.js';
5
+ export * from './CouldNotChangeDefaultPrimaryGroupError.js';
6
+ export * from './EmailChangeRateLimitExceededError.js';