@plinthjs/auth 0.1.0
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/LICENSE +21 -0
- package/README.md +115 -0
- package/dist/index.cjs +885 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +698 -0
- package/dist/index.d.ts +698 -0
- package/dist/index.js +852 -0
- package/dist/index.js.map +1 -0
- package/package.json +63 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,885 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var crypto = require('crypto');
|
|
4
|
+
var http = require('@plinthjs/http');
|
|
5
|
+
var session = require('@plinthjs/session');
|
|
6
|
+
|
|
7
|
+
// src/email-verification.ts
|
|
8
|
+
|
|
9
|
+
// src/events.ts
|
|
10
|
+
var Attempting = class {
|
|
11
|
+
constructor(guard, credentials, remember = false) {
|
|
12
|
+
this.guard = guard;
|
|
13
|
+
this.credentials = credentials;
|
|
14
|
+
this.remember = remember;
|
|
15
|
+
}
|
|
16
|
+
guard;
|
|
17
|
+
credentials;
|
|
18
|
+
remember;
|
|
19
|
+
};
|
|
20
|
+
var Validated = class {
|
|
21
|
+
constructor(guard, user) {
|
|
22
|
+
this.guard = guard;
|
|
23
|
+
this.user = user;
|
|
24
|
+
}
|
|
25
|
+
guard;
|
|
26
|
+
user;
|
|
27
|
+
};
|
|
28
|
+
var Login = class {
|
|
29
|
+
constructor(guard, user, remember) {
|
|
30
|
+
this.guard = guard;
|
|
31
|
+
this.user = user;
|
|
32
|
+
this.remember = remember;
|
|
33
|
+
}
|
|
34
|
+
guard;
|
|
35
|
+
user;
|
|
36
|
+
remember;
|
|
37
|
+
};
|
|
38
|
+
var Authenticated = class {
|
|
39
|
+
constructor(guard, user) {
|
|
40
|
+
this.guard = guard;
|
|
41
|
+
this.user = user;
|
|
42
|
+
}
|
|
43
|
+
guard;
|
|
44
|
+
user;
|
|
45
|
+
};
|
|
46
|
+
var Failed = class {
|
|
47
|
+
constructor(guard, user, credentials) {
|
|
48
|
+
this.guard = guard;
|
|
49
|
+
this.user = user;
|
|
50
|
+
this.credentials = credentials;
|
|
51
|
+
}
|
|
52
|
+
guard;
|
|
53
|
+
user;
|
|
54
|
+
credentials;
|
|
55
|
+
};
|
|
56
|
+
var Logout = class {
|
|
57
|
+
constructor(guard, user) {
|
|
58
|
+
this.guard = guard;
|
|
59
|
+
this.user = user;
|
|
60
|
+
}
|
|
61
|
+
guard;
|
|
62
|
+
user;
|
|
63
|
+
};
|
|
64
|
+
var CurrentDeviceLogout = class {
|
|
65
|
+
constructor(guard, user) {
|
|
66
|
+
this.guard = guard;
|
|
67
|
+
this.user = user;
|
|
68
|
+
}
|
|
69
|
+
guard;
|
|
70
|
+
user;
|
|
71
|
+
};
|
|
72
|
+
var OtherDeviceLogout = class {
|
|
73
|
+
constructor(guard, user) {
|
|
74
|
+
this.guard = guard;
|
|
75
|
+
this.user = user;
|
|
76
|
+
}
|
|
77
|
+
guard;
|
|
78
|
+
user;
|
|
79
|
+
};
|
|
80
|
+
var Registered = class {
|
|
81
|
+
constructor(user) {
|
|
82
|
+
this.user = user;
|
|
83
|
+
}
|
|
84
|
+
user;
|
|
85
|
+
};
|
|
86
|
+
var Verified = class {
|
|
87
|
+
constructor(user) {
|
|
88
|
+
this.user = user;
|
|
89
|
+
}
|
|
90
|
+
user;
|
|
91
|
+
};
|
|
92
|
+
var PasswordReset = class {
|
|
93
|
+
constructor(user) {
|
|
94
|
+
this.user = user;
|
|
95
|
+
}
|
|
96
|
+
user;
|
|
97
|
+
};
|
|
98
|
+
var Lockout = class {
|
|
99
|
+
constructor(credentials) {
|
|
100
|
+
this.credentials = credentials;
|
|
101
|
+
}
|
|
102
|
+
credentials;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// src/email-verification.ts
|
|
106
|
+
var EmailVerifier = class {
|
|
107
|
+
secret;
|
|
108
|
+
expireMinutes;
|
|
109
|
+
now;
|
|
110
|
+
events;
|
|
111
|
+
constructor(options) {
|
|
112
|
+
this.secret = options.secret;
|
|
113
|
+
this.expireMinutes = options.expireMinutes ?? 60;
|
|
114
|
+
this.now = options.now ?? (() => /* @__PURE__ */ new Date());
|
|
115
|
+
this.events = options.events;
|
|
116
|
+
}
|
|
117
|
+
/** A stable hash of the user's email — proves the link was issued for this exact address. */
|
|
118
|
+
hashFor(user) {
|
|
119
|
+
return crypto.createHash("sha256").update(user.getEmailForVerification()).digest("hex");
|
|
120
|
+
}
|
|
121
|
+
/** Build a signed, expiring verification payload for `user` (embed it in the verification URL). */
|
|
122
|
+
sign(user) {
|
|
123
|
+
const expires = this.now().getTime() + this.expireMinutes * 6e4;
|
|
124
|
+
return { expires, signature: this.signature(user, expires) };
|
|
125
|
+
}
|
|
126
|
+
/** Whether `payload` is a valid, unexpired signature for `user`'s current email. */
|
|
127
|
+
isValid(user, payload) {
|
|
128
|
+
if (this.now().getTime() > payload.expires) return false;
|
|
129
|
+
return safeEqual(this.signature(user, payload.expires), payload.signature);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Verify a payload and mark the user verified. Returns `false` on a bad or expired signature;
|
|
133
|
+
* idempotent — an already-verified user returns `true` without re-marking.
|
|
134
|
+
*/
|
|
135
|
+
async verify(user, payload) {
|
|
136
|
+
if (!this.isValid(user, payload)) return false;
|
|
137
|
+
if (!user.hasVerifiedEmail()) {
|
|
138
|
+
await user.markEmailAsVerified();
|
|
139
|
+
this.events?.dispatch(new Verified(user));
|
|
140
|
+
}
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
/** The HMAC binding the user id, email hash, and expiry. */
|
|
144
|
+
signature(user, expires) {
|
|
145
|
+
const data = `${String(user.getAuthIdentifier())}.${this.hashFor(user)}.${String(expires)}`;
|
|
146
|
+
return crypto.createHmac("sha256", this.secret).update(data).digest("hex");
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
function safeEqual(a, b) {
|
|
150
|
+
const bufferA = Buffer.from(a);
|
|
151
|
+
const bufferB = Buffer.from(b);
|
|
152
|
+
if (bufferA.length !== bufferB.length) return false;
|
|
153
|
+
return crypto.timingSafeEqual(bufferA, bufferB);
|
|
154
|
+
}
|
|
155
|
+
var SESSION_KEY = "auth.id";
|
|
156
|
+
var TOKEN_KEY = "api_token";
|
|
157
|
+
var PASSWORD_HASH_SESSION_KEY = "auth.password_hash";
|
|
158
|
+
var DEFAULT_REMEMBER_DURATION = 576e3;
|
|
159
|
+
var SessionGuard = class {
|
|
160
|
+
constructor(provider, session, key = SESSION_KEY, options = {}) {
|
|
161
|
+
this.provider = provider;
|
|
162
|
+
this.session = session;
|
|
163
|
+
this.key = key;
|
|
164
|
+
this.name = options.name ?? "web";
|
|
165
|
+
this.request = options.request;
|
|
166
|
+
this.events = options.events;
|
|
167
|
+
}
|
|
168
|
+
provider;
|
|
169
|
+
session;
|
|
170
|
+
key;
|
|
171
|
+
cachedUser = null;
|
|
172
|
+
resolved = false;
|
|
173
|
+
lastAttempted = null;
|
|
174
|
+
viaRememberFlag = false;
|
|
175
|
+
rememberDuration = DEFAULT_REMEMBER_DURATION;
|
|
176
|
+
request;
|
|
177
|
+
name;
|
|
178
|
+
events;
|
|
179
|
+
async user() {
|
|
180
|
+
if (this.resolved) return this.cachedUser;
|
|
181
|
+
const id = this.session.get(this.key);
|
|
182
|
+
this.cachedUser = id === null ? null : await this.provider.retrieveById(id);
|
|
183
|
+
this.resolved = true;
|
|
184
|
+
return this.cachedUser;
|
|
185
|
+
}
|
|
186
|
+
async check() {
|
|
187
|
+
return await this.user() !== null;
|
|
188
|
+
}
|
|
189
|
+
async guest() {
|
|
190
|
+
return !await this.check();
|
|
191
|
+
}
|
|
192
|
+
async id() {
|
|
193
|
+
const user = await this.user();
|
|
194
|
+
return user === null ? null : user.getAuthIdentifier();
|
|
195
|
+
}
|
|
196
|
+
async validate(credentials) {
|
|
197
|
+
const user = await this.provider.retrieveByCredentials(credentials);
|
|
198
|
+
this.lastAttempted = user;
|
|
199
|
+
if (user === null) return false;
|
|
200
|
+
return this.hasValidCredentials(user, credentials);
|
|
201
|
+
}
|
|
202
|
+
async attempt(credentials) {
|
|
203
|
+
return this.attemptWhen(credentials);
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Attempt to authenticate with additional callbacks — the Laravel `attemptWhen`. The callbacks
|
|
207
|
+
* run after the credentials validate, receiving the user and this guard; every one must return
|
|
208
|
+
* `true` (a falsy result fails the attempt without logging the user in).
|
|
209
|
+
*/
|
|
210
|
+
async attemptWhen(credentials, callbacks = []) {
|
|
211
|
+
this.events?.dispatch(new Attempting(this.name, credentials));
|
|
212
|
+
const user = await this.provider.retrieveByCredentials(credentials);
|
|
213
|
+
this.lastAttempted = user;
|
|
214
|
+
if (user !== null && await this.hasValidCredentials(user, credentials) && await this.shouldLogin(callbacks, user)) {
|
|
215
|
+
await this.provider.rehashPasswordIfRequired?.(user, credentials);
|
|
216
|
+
this.login(user);
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
this.events?.dispatch(new Failed(this.name, user, credentials));
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
async once(credentials) {
|
|
223
|
+
this.events?.dispatch(new Attempting(this.name, credentials));
|
|
224
|
+
const user = await this.provider.retrieveByCredentials(credentials);
|
|
225
|
+
this.lastAttempted = user;
|
|
226
|
+
if (user !== null && await this.hasValidCredentials(user, credentials)) {
|
|
227
|
+
this.setUser(user);
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
login(user) {
|
|
233
|
+
this.updateSession(user);
|
|
234
|
+
this.events?.dispatch(new Login(this.name, user, false));
|
|
235
|
+
this.setUser(user);
|
|
236
|
+
}
|
|
237
|
+
async loginUsingId(id) {
|
|
238
|
+
const user = await this.provider.retrieveById(id);
|
|
239
|
+
if (user !== null) this.login(user);
|
|
240
|
+
return user;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Log the current user out, cycling the remember token so every recaller dies — the Laravel
|
|
244
|
+
* `logout`. The session keys are cleared synchronously; the returned promise resolves once the
|
|
245
|
+
* token has been cycled through the provider and the `Logout` event dispatched.
|
|
246
|
+
*/
|
|
247
|
+
logout() {
|
|
248
|
+
return this.performLogout(true);
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Log the current user out on this device only — the Laravel `logoutCurrentDevice`. Unlike
|
|
252
|
+
* {@link SessionGuard.logout} the remember token is *not* cycled, so other remembered devices
|
|
253
|
+
* stay logged in. Dispatches `CurrentDeviceLogout`.
|
|
254
|
+
*/
|
|
255
|
+
logoutCurrentDevice() {
|
|
256
|
+
return this.performLogout(false);
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Invalidate the user's sessions on every other device — the Laravel `logoutOtherDevices`.
|
|
260
|
+
* Validates `password` against the current user (throwing when it does not match), then:
|
|
261
|
+
*
|
|
262
|
+
* - force re-hashes the password through {@link UserProvider.rehashPasswordIfRequired} (when the
|
|
263
|
+
* provider supports it) and refreshes this session's stored password hash, so any session
|
|
264
|
+
* checked by `authenticateSession` whose stored hash is now stale is logged out — the same
|
|
265
|
+
* session-password-hash mechanism Laravel's `AuthenticateSession` middleware uses; and
|
|
266
|
+
* - cycles the remember token, killing every previously issued recaller cookie.
|
|
267
|
+
*
|
|
268
|
+
* Returns the fresh recaller value for *this* device (the Laravel `queueRecallerCookie`
|
|
269
|
+
* re-issue), or `null` when nobody is authenticated.
|
|
270
|
+
*/
|
|
271
|
+
async logoutOtherDevices(password) {
|
|
272
|
+
const user = await this.user();
|
|
273
|
+
if (user === null) return null;
|
|
274
|
+
if (!await this.provider.validateCredentials(user, { password })) {
|
|
275
|
+
throw new Error("The given password does not match the current password.");
|
|
276
|
+
}
|
|
277
|
+
await this.provider.rehashPasswordIfRequired?.(user, { password }, true);
|
|
278
|
+
this.session.put(PASSWORD_HASH_SESSION_KEY, user.getAuthPassword());
|
|
279
|
+
const recaller = await this.remember(user);
|
|
280
|
+
this.events?.dispatch(new OtherDeviceLogout(this.name, user));
|
|
281
|
+
return recaller;
|
|
282
|
+
}
|
|
283
|
+
setUser(user) {
|
|
284
|
+
this.cachedUser = user;
|
|
285
|
+
this.resolved = true;
|
|
286
|
+
this.events?.dispatch(new Authenticated(this.name, user));
|
|
287
|
+
}
|
|
288
|
+
/** Set the current request (used by the HTTP Basic helpers). The `setRequest` equivalent. */
|
|
289
|
+
setRequest(request) {
|
|
290
|
+
this.request = request;
|
|
291
|
+
return this;
|
|
292
|
+
}
|
|
293
|
+
/** The last user a credential attempt resolved, or `null`. The `getLastAttempted` equivalent. */
|
|
294
|
+
getLastAttempted() {
|
|
295
|
+
return this.lastAttempted;
|
|
296
|
+
}
|
|
297
|
+
/** Whether the current user was authenticated via a remember-me recaller. The `viaRemember` equivalent. */
|
|
298
|
+
viaRemember() {
|
|
299
|
+
return this.viaRememberFlag;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Set how long (in minutes) issued recaller cookies should live — the `setRememberDuration`
|
|
303
|
+
* equivalent. The guard does not write cookies itself; read it back via
|
|
304
|
+
* {@link SessionGuard.getRememberDuration} when turning a recaller value into a cookie.
|
|
305
|
+
*/
|
|
306
|
+
setRememberDuration(minutes) {
|
|
307
|
+
this.rememberDuration = minutes;
|
|
308
|
+
return this;
|
|
309
|
+
}
|
|
310
|
+
/** The "remember me" cookie lifetime in minutes. The `getRememberDuration` equivalent. */
|
|
311
|
+
getRememberDuration() {
|
|
312
|
+
return this.rememberDuration;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Attempt HTTP Basic authentication, logging the user in for the session — the Laravel `basic`.
|
|
316
|
+
* Resolves to `undefined` when already authenticated or when the `Authorization: Basic` header
|
|
317
|
+
* validates; otherwise resolves to a `401` challenge response (`WWW-Authenticate: Basic`).
|
|
318
|
+
* Requires the request (constructor option or {@link SessionGuard.setRequest}).
|
|
319
|
+
*/
|
|
320
|
+
async basic(field = "email") {
|
|
321
|
+
if (await this.check()) return void 0;
|
|
322
|
+
const credentials = this.basicCredentialsFromRequest(field);
|
|
323
|
+
if (credentials !== null && await this.attempt(credentials)) return void 0;
|
|
324
|
+
return failedBasicResponse();
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Perform a stateless HTTP Basic attempt (no session persistence) — the Laravel `onceBasic`.
|
|
328
|
+
* Resolves to `undefined` on success, or the `401` challenge response on failure.
|
|
329
|
+
*/
|
|
330
|
+
async onceBasic(field = "email") {
|
|
331
|
+
const credentials = this.basicCredentialsFromRequest(field);
|
|
332
|
+
if (credentials !== null && await this.once(credentials)) return void 0;
|
|
333
|
+
return failedBasicResponse();
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Issue a fresh remember-me token for `user`, persist it through the provider, and return the
|
|
337
|
+
* recaller value (`id|token`) to store in a long-lived cookie. The Laravel "remember me" persist.
|
|
338
|
+
*/
|
|
339
|
+
async remember(user) {
|
|
340
|
+
const token = crypto.randomBytes(20).toString("hex");
|
|
341
|
+
await this.provider.updateRememberToken(user, token);
|
|
342
|
+
return recallerValue(user.getAuthIdentifier(), token);
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Authenticate from a recaller cookie value (`id|token`), logging the user in for the session on a
|
|
346
|
+
* constant-time token match (the Laravel `viaRemember` path). Returns the user, or `null`.
|
|
347
|
+
*/
|
|
348
|
+
async loginUsingRecaller(value) {
|
|
349
|
+
const recaller = parseRecaller(value);
|
|
350
|
+
if (recaller === null) return null;
|
|
351
|
+
const user = await this.provider.retrieveByToken(recaller.id, recaller.token);
|
|
352
|
+
if (user !== null) {
|
|
353
|
+
this.viaRememberFlag = true;
|
|
354
|
+
this.updateSession(user);
|
|
355
|
+
this.events?.dispatch(new Login(this.name, user, true));
|
|
356
|
+
this.setUser(user);
|
|
357
|
+
}
|
|
358
|
+
return user;
|
|
359
|
+
}
|
|
360
|
+
/** Persist the user's id and current password hash into the session. */
|
|
361
|
+
updateSession(user) {
|
|
362
|
+
this.session.put(this.key, user.getAuthIdentifier());
|
|
363
|
+
this.session.put(PASSWORD_HASH_SESSION_KEY, user.getAuthPassword());
|
|
364
|
+
}
|
|
365
|
+
/** Whether `credentials` validate against `user`, dispatching `Validated` when they do. */
|
|
366
|
+
async hasValidCredentials(user, credentials) {
|
|
367
|
+
const valid = await this.provider.validateCredentials(user, credentials);
|
|
368
|
+
if (valid) this.events?.dispatch(new Validated(this.name, user));
|
|
369
|
+
return valid;
|
|
370
|
+
}
|
|
371
|
+
/** Run the `attemptWhen` callbacks; every one must return `true` for the login to proceed. */
|
|
372
|
+
async shouldLogin(callbacks, user) {
|
|
373
|
+
const list = typeof callbacks === "function" ? [callbacks] : callbacks;
|
|
374
|
+
for (const callback of list) {
|
|
375
|
+
if (!await callback(user, this)) return false;
|
|
376
|
+
}
|
|
377
|
+
return true;
|
|
378
|
+
}
|
|
379
|
+
/** Clear the session synchronously, then finish teardown (token cycling + event) async. */
|
|
380
|
+
performLogout(cycleToken) {
|
|
381
|
+
const known = this.resolved ? this.cachedUser : null;
|
|
382
|
+
const id = this.session.get(this.key);
|
|
383
|
+
this.session.forget(this.key);
|
|
384
|
+
this.session.forget(PASSWORD_HASH_SESSION_KEY);
|
|
385
|
+
this.cachedUser = null;
|
|
386
|
+
this.resolved = true;
|
|
387
|
+
this.viaRememberFlag = false;
|
|
388
|
+
return this.finishLogout(known, id, cycleToken);
|
|
389
|
+
}
|
|
390
|
+
/** Resolve the user that was logged out, cycle their remember token, and dispatch the event. */
|
|
391
|
+
async finishLogout(known, id, cycleToken) {
|
|
392
|
+
const user = known ?? (id === null ? null : await this.provider.retrieveById(id));
|
|
393
|
+
if (user === null) return;
|
|
394
|
+
if (cycleToken && hasRememberToken(user)) {
|
|
395
|
+
await this.provider.updateRememberToken(user, crypto.randomBytes(20).toString("hex"));
|
|
396
|
+
}
|
|
397
|
+
this.events?.dispatch(
|
|
398
|
+
cycleToken ? new Logout(this.name, user) : new CurrentDeviceLogout(this.name, user)
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
/** Parse `Authorization: Basic …` from the request into `{ [field], password }`, or `null`. */
|
|
402
|
+
basicCredentialsFromRequest(field) {
|
|
403
|
+
if (this.request === void 0) return null;
|
|
404
|
+
const header = this.request.header("authorization");
|
|
405
|
+
if (!header?.toLowerCase().startsWith("basic ")) return null;
|
|
406
|
+
const decoded = Buffer.from(header.slice(6).trim(), "base64").toString("utf8");
|
|
407
|
+
const separator = decoded.indexOf(":");
|
|
408
|
+
if (separator === -1) return null;
|
|
409
|
+
return { [field]: decoded.slice(0, separator), password: decoded.slice(separator + 1) };
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
function failedBasicResponse() {
|
|
413
|
+
return http.Response.make("Invalid Basic credentials.", 401).withHeaders({
|
|
414
|
+
"WWW-Authenticate": "Basic"
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
function hasRememberToken(user) {
|
|
418
|
+
if (!("getRememberToken" in user)) return false;
|
|
419
|
+
const token = user.getRememberToken();
|
|
420
|
+
return typeof token === "string" && token.length > 0;
|
|
421
|
+
}
|
|
422
|
+
function recallerValue(id, token) {
|
|
423
|
+
return `${String(id)}|${token}`;
|
|
424
|
+
}
|
|
425
|
+
function parseRecaller(value) {
|
|
426
|
+
const separator = value.indexOf("|");
|
|
427
|
+
if (separator <= 0) return null;
|
|
428
|
+
const token = value.slice(separator + 1);
|
|
429
|
+
if (token.length === 0) return null;
|
|
430
|
+
return { id: value.slice(0, separator), token };
|
|
431
|
+
}
|
|
432
|
+
var TokenGuard = class {
|
|
433
|
+
constructor(provider, request, inputKey = TOKEN_KEY, options = {}) {
|
|
434
|
+
this.provider = provider;
|
|
435
|
+
this.request = request;
|
|
436
|
+
this.inputKey = inputKey;
|
|
437
|
+
this.name = options.name ?? "api";
|
|
438
|
+
this.events = options.events;
|
|
439
|
+
}
|
|
440
|
+
provider;
|
|
441
|
+
request;
|
|
442
|
+
inputKey;
|
|
443
|
+
cachedUser = null;
|
|
444
|
+
resolved = false;
|
|
445
|
+
name;
|
|
446
|
+
events;
|
|
447
|
+
async user() {
|
|
448
|
+
if (this.resolved) return this.cachedUser;
|
|
449
|
+
const token = this.tokenForRequest();
|
|
450
|
+
this.cachedUser = token === void 0 ? null : await this.provider.retrieveByCredentials({ [this.inputKey]: token });
|
|
451
|
+
this.resolved = true;
|
|
452
|
+
if (this.cachedUser !== null) {
|
|
453
|
+
this.events?.dispatch(new Authenticated(this.name, this.cachedUser));
|
|
454
|
+
}
|
|
455
|
+
return this.cachedUser;
|
|
456
|
+
}
|
|
457
|
+
async check() {
|
|
458
|
+
return await this.user() !== null;
|
|
459
|
+
}
|
|
460
|
+
async guest() {
|
|
461
|
+
return !await this.check();
|
|
462
|
+
}
|
|
463
|
+
async id() {
|
|
464
|
+
const user = await this.user();
|
|
465
|
+
return user === null ? null : user.getAuthIdentifier();
|
|
466
|
+
}
|
|
467
|
+
async validate(credentials) {
|
|
468
|
+
const user = await this.provider.retrieveByCredentials(credentials);
|
|
469
|
+
if (user === null) return false;
|
|
470
|
+
return this.provider.validateCredentials(user, credentials);
|
|
471
|
+
}
|
|
472
|
+
setUser(user) {
|
|
473
|
+
this.cachedUser = user;
|
|
474
|
+
this.resolved = true;
|
|
475
|
+
this.events?.dispatch(new Authenticated(this.name, user));
|
|
476
|
+
}
|
|
477
|
+
/** Read the API token from the bearer header, then the query string, then the input bag. */
|
|
478
|
+
tokenForRequest() {
|
|
479
|
+
const bearer = this.request.bearerToken();
|
|
480
|
+
if (bearer !== void 0) return bearer;
|
|
481
|
+
const query = this.request.query(this.inputKey);
|
|
482
|
+
if (typeof query === "string" && query.length > 0) return query;
|
|
483
|
+
const input = this.request.input(this.inputKey);
|
|
484
|
+
return typeof input === "string" && input.length > 0 ? input : void 0;
|
|
485
|
+
}
|
|
486
|
+
};
|
|
487
|
+
var RequestGuard = class {
|
|
488
|
+
constructor(callback, request, provider) {
|
|
489
|
+
this.callback = callback;
|
|
490
|
+
this.provider = provider;
|
|
491
|
+
this.request = request;
|
|
492
|
+
}
|
|
493
|
+
callback;
|
|
494
|
+
provider;
|
|
495
|
+
cachedUser = null;
|
|
496
|
+
resolved = false;
|
|
497
|
+
request;
|
|
498
|
+
async user() {
|
|
499
|
+
if (this.resolved) return this.cachedUser;
|
|
500
|
+
this.cachedUser = this.request === void 0 ? null : await this.callback(this.request, this.provider) ?? null;
|
|
501
|
+
this.resolved = true;
|
|
502
|
+
return this.cachedUser;
|
|
503
|
+
}
|
|
504
|
+
async check() {
|
|
505
|
+
return await this.user() !== null;
|
|
506
|
+
}
|
|
507
|
+
async guest() {
|
|
508
|
+
return !await this.check();
|
|
509
|
+
}
|
|
510
|
+
async id() {
|
|
511
|
+
const user = await this.user();
|
|
512
|
+
return user === null ? null : user.getAuthIdentifier();
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Whether the callback resolves a user for `credentials['request']` — the Laravel
|
|
516
|
+
* `RequestGuard::validate`, which runs the resolver against the given request.
|
|
517
|
+
*/
|
|
518
|
+
async validate(credentials) {
|
|
519
|
+
const request = credentials["request"];
|
|
520
|
+
if (!(request instanceof http.Request)) return false;
|
|
521
|
+
return (await this.callback(request, this.provider) ?? null) !== null;
|
|
522
|
+
}
|
|
523
|
+
setUser(user) {
|
|
524
|
+
this.cachedUser = user;
|
|
525
|
+
this.resolved = true;
|
|
526
|
+
}
|
|
527
|
+
/** Swap the request and reset the cached user. The `setRequest` equivalent. */
|
|
528
|
+
setRequest(request) {
|
|
529
|
+
this.request = request;
|
|
530
|
+
this.cachedUser = null;
|
|
531
|
+
this.resolved = false;
|
|
532
|
+
return this;
|
|
533
|
+
}
|
|
534
|
+
};
|
|
535
|
+
|
|
536
|
+
// src/manager.ts
|
|
537
|
+
var AuthManager = class {
|
|
538
|
+
constructor(defaultGuard = "web") {
|
|
539
|
+
this.defaultGuard = defaultGuard;
|
|
540
|
+
}
|
|
541
|
+
defaultGuard;
|
|
542
|
+
guards = /* @__PURE__ */ new Map();
|
|
543
|
+
/** Register a guard factory under `name`. The `Auth::extend()` equivalent. */
|
|
544
|
+
extend(name, factory) {
|
|
545
|
+
this.guards.set(name, factory);
|
|
546
|
+
return this;
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* Register a closure-driven guard under `name` — the `Auth::viaRequest()` equivalent. The
|
|
550
|
+
* callback receives the request (and `provider`, when given) and returns the authenticated user
|
|
551
|
+
* or `null`; the manager builds a {@link RequestGuard} around it on every resolve.
|
|
552
|
+
*/
|
|
553
|
+
viaRequest(name, callback, provider) {
|
|
554
|
+
return this.extend(name, (request) => new RequestGuard(callback, request, provider));
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* Resolve a guard by name (or the default), forwarding `request` to the factory so
|
|
558
|
+
* request-scoped guards (e.g. {@link AuthManager.viaRequest}) can read it. Throws if the guard is
|
|
559
|
+
* not registered.
|
|
560
|
+
*/
|
|
561
|
+
guard(name, request) {
|
|
562
|
+
const resolved = name ?? this.defaultGuard;
|
|
563
|
+
const factory = this.guards.get(resolved);
|
|
564
|
+
if (factory === void 0) {
|
|
565
|
+
throw new Error(`Auth guard [${resolved}] is not defined.`);
|
|
566
|
+
}
|
|
567
|
+
return factory(request);
|
|
568
|
+
}
|
|
569
|
+
/** Change the default guard name. The `Auth::shouldUse()` equivalent. */
|
|
570
|
+
setDefaultGuard(name) {
|
|
571
|
+
this.defaultGuard = name;
|
|
572
|
+
return this;
|
|
573
|
+
}
|
|
574
|
+
/** The current default guard name. */
|
|
575
|
+
getDefaultGuard() {
|
|
576
|
+
return this.defaultGuard;
|
|
577
|
+
}
|
|
578
|
+
};
|
|
579
|
+
var USER_ATTRIBUTE = "mason.user";
|
|
580
|
+
var PASSWORD_CONFIRMED_AT_SESSION_KEY = "auth.password_confirmed_at";
|
|
581
|
+
var DEFAULT_PASSWORD_TIMEOUT_SECONDS = 10800;
|
|
582
|
+
var AuthenticationError = class extends http.HttpException {
|
|
583
|
+
constructor(message = "Unauthenticated.") {
|
|
584
|
+
super(401, message);
|
|
585
|
+
this.name = "AuthenticationError";
|
|
586
|
+
}
|
|
587
|
+
};
|
|
588
|
+
function getUser(req) {
|
|
589
|
+
return req.attribute(USER_ATTRIBUTE);
|
|
590
|
+
}
|
|
591
|
+
function authenticateSession(provider) {
|
|
592
|
+
return async (req, next) => {
|
|
593
|
+
const session = requireSession(req);
|
|
594
|
+
const guard = new SessionGuard(provider, session);
|
|
595
|
+
const user = await guard.user();
|
|
596
|
+
if (user === null) throw new AuthenticationError();
|
|
597
|
+
const storedHash = session.get(PASSWORD_HASH_SESSION_KEY);
|
|
598
|
+
if (storedHash !== null && storedHash !== user.getAuthPassword()) {
|
|
599
|
+
await guard.logoutCurrentDevice();
|
|
600
|
+
throw new AuthenticationError();
|
|
601
|
+
}
|
|
602
|
+
if (storedHash === null) session.put(PASSWORD_HASH_SESSION_KEY, user.getAuthPassword());
|
|
603
|
+
return next(req.withAttribute(USER_ATTRIBUTE, user));
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
function authenticateToken(provider, inputKey) {
|
|
607
|
+
return async (req, next) => {
|
|
608
|
+
const guard = inputKey === void 0 ? new TokenGuard(provider, req) : new TokenGuard(provider, req, inputKey);
|
|
609
|
+
const user = await guard.user();
|
|
610
|
+
if (user === null) throw new AuthenticationError();
|
|
611
|
+
return next(req.withAttribute(USER_ATTRIBUTE, user));
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
function redirectIfAuthenticated(provider, redirectTo = "/home") {
|
|
615
|
+
return async (req, next) => {
|
|
616
|
+
const session$1 = session.getSession(req);
|
|
617
|
+
if (session$1 === void 0) return next(req);
|
|
618
|
+
const user = await new SessionGuard(provider, session$1).user();
|
|
619
|
+
return user === null ? next(req) : http.Response.redirectTo(redirectTo);
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
function requirePassword(redirectTo = "/confirm-password", passwordTimeoutSeconds = DEFAULT_PASSWORD_TIMEOUT_SECONDS, now = () => /* @__PURE__ */ new Date()) {
|
|
623
|
+
return async (req, next) => {
|
|
624
|
+
const session = requireSession(req);
|
|
625
|
+
const confirmedAt = session.get(PASSWORD_CONFIRMED_AT_SESSION_KEY);
|
|
626
|
+
const fresh = typeof confirmedAt === "number" && now().getTime() / 1e3 - confirmedAt < passwordTimeoutSeconds;
|
|
627
|
+
if (fresh) return next(req);
|
|
628
|
+
if (req.wantsJson()) {
|
|
629
|
+
return http.Response.json({ message: "Password confirmation required." }, 423);
|
|
630
|
+
}
|
|
631
|
+
return http.Response.redirectTo(redirectTo);
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
async function confirmPassword(provider, session, user, password, now = () => /* @__PURE__ */ new Date()) {
|
|
635
|
+
const credentials = { password };
|
|
636
|
+
if (!await provider.validateCredentials(user, credentials)) return false;
|
|
637
|
+
session.put(PASSWORD_CONFIRMED_AT_SESSION_KEY, Math.floor(now().getTime() / 1e3));
|
|
638
|
+
return true;
|
|
639
|
+
}
|
|
640
|
+
function requireSession(req) {
|
|
641
|
+
const session$1 = session.getSession(req);
|
|
642
|
+
if (session$1 === void 0) {
|
|
643
|
+
throw new http.HttpException(
|
|
644
|
+
500,
|
|
645
|
+
"Session authentication requires the session middleware to run first."
|
|
646
|
+
);
|
|
647
|
+
}
|
|
648
|
+
return session$1;
|
|
649
|
+
}
|
|
650
|
+
var PasswordStatus = {
|
|
651
|
+
ResetLinkSent: "passwords.sent",
|
|
652
|
+
PasswordReset: "passwords.reset",
|
|
653
|
+
InvalidUser: "passwords.user",
|
|
654
|
+
InvalidToken: "passwords.token",
|
|
655
|
+
InvalidPassword: "passwords.password",
|
|
656
|
+
ResetThrottled: "passwords.throttled"
|
|
657
|
+
};
|
|
658
|
+
var ArrayTokenRepository = class {
|
|
659
|
+
store = /* @__PURE__ */ new Map();
|
|
660
|
+
hasher;
|
|
661
|
+
expireMinutes;
|
|
662
|
+
throttleSeconds;
|
|
663
|
+
now;
|
|
664
|
+
makeToken;
|
|
665
|
+
constructor(options) {
|
|
666
|
+
this.hasher = options.hasher;
|
|
667
|
+
this.expireMinutes = options.expireMinutes ?? 60;
|
|
668
|
+
this.throttleSeconds = options.throttleSeconds ?? 60;
|
|
669
|
+
this.now = options.now ?? (() => /* @__PURE__ */ new Date());
|
|
670
|
+
this.makeToken = options.createToken ?? (() => crypto.randomBytes(20).toString("hex"));
|
|
671
|
+
}
|
|
672
|
+
async create(user) {
|
|
673
|
+
const token = this.makeToken();
|
|
674
|
+
this.store.set(user.getAuthIdentifier(), {
|
|
675
|
+
hashed: this.hasher.make(token),
|
|
676
|
+
createdAt: this.now().getTime()
|
|
677
|
+
});
|
|
678
|
+
return token;
|
|
679
|
+
}
|
|
680
|
+
async exists(user, token) {
|
|
681
|
+
const record = this.store.get(user.getAuthIdentifier());
|
|
682
|
+
if (record === void 0 || this.expired(record)) return false;
|
|
683
|
+
return this.hasher.check(token, record.hashed);
|
|
684
|
+
}
|
|
685
|
+
async recentlyCreatedToken(user) {
|
|
686
|
+
const record = this.store.get(user.getAuthIdentifier());
|
|
687
|
+
if (record === void 0) return false;
|
|
688
|
+
return (this.now().getTime() - record.createdAt) / 1e3 < this.throttleSeconds;
|
|
689
|
+
}
|
|
690
|
+
async delete(user) {
|
|
691
|
+
this.store.delete(user.getAuthIdentifier());
|
|
692
|
+
}
|
|
693
|
+
async deleteExpired() {
|
|
694
|
+
for (const [key, record] of this.store) {
|
|
695
|
+
if (this.expired(record)) this.store.delete(key);
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
expired(record) {
|
|
699
|
+
return (this.now().getTime() - record.createdAt) / 6e4 >= this.expireMinutes;
|
|
700
|
+
}
|
|
701
|
+
};
|
|
702
|
+
var PasswordBroker = class {
|
|
703
|
+
constructor(users, tokens, events) {
|
|
704
|
+
this.users = users;
|
|
705
|
+
this.tokens = tokens;
|
|
706
|
+
this.events = events;
|
|
707
|
+
}
|
|
708
|
+
users;
|
|
709
|
+
tokens;
|
|
710
|
+
events;
|
|
711
|
+
/**
|
|
712
|
+
* Send a reset link: resolve the user from `credentials`, throttle repeat requests, mint a token,
|
|
713
|
+
* and hand it to `send`. Returns {@link PasswordStatus.ResetLinkSent} on success.
|
|
714
|
+
*/
|
|
715
|
+
async sendResetLink(credentials, send) {
|
|
716
|
+
const user = await this.users.retrieveByCredentials(credentials);
|
|
717
|
+
if (user === null) return PasswordStatus.InvalidUser;
|
|
718
|
+
if (await this.tokens.recentlyCreatedToken(user)) return PasswordStatus.ResetThrottled;
|
|
719
|
+
const token = await this.tokens.create(user);
|
|
720
|
+
await send(user, token);
|
|
721
|
+
return PasswordStatus.ResetLinkSent;
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* Reset a password: resolve the user, require a non-empty password, verify the token, then run
|
|
725
|
+
* `reset` to persist and delete the token. Returns {@link PasswordStatus.PasswordReset} on success.
|
|
726
|
+
*/
|
|
727
|
+
async reset(credentials, reset) {
|
|
728
|
+
const user = await this.users.retrieveByCredentials(this.lookupOnly(credentials));
|
|
729
|
+
if (user === null) return PasswordStatus.InvalidUser;
|
|
730
|
+
if (typeof credentials.password !== "string" || credentials.password === "") {
|
|
731
|
+
return PasswordStatus.InvalidPassword;
|
|
732
|
+
}
|
|
733
|
+
if (!await this.tokens.exists(user, credentials.token)) return PasswordStatus.InvalidToken;
|
|
734
|
+
await reset(user, credentials.password);
|
|
735
|
+
await this.tokens.delete(user);
|
|
736
|
+
this.events?.dispatch(new PasswordReset(user));
|
|
737
|
+
return PasswordStatus.PasswordReset;
|
|
738
|
+
}
|
|
739
|
+
/** The user-lookup credentials, with `token`/`password` removed so they don't act as match fields. */
|
|
740
|
+
lookupOnly(credentials) {
|
|
741
|
+
const lookup = {};
|
|
742
|
+
for (const [key, value] of Object.entries(credentials)) {
|
|
743
|
+
if (key !== "token" && key !== "password") lookup[key] = value;
|
|
744
|
+
}
|
|
745
|
+
return lookup;
|
|
746
|
+
}
|
|
747
|
+
};
|
|
748
|
+
var REMEMBER_TOKEN = "remember_token";
|
|
749
|
+
var GenericUser = class {
|
|
750
|
+
constructor(attributes, identifierName = "id", passwordName = "password") {
|
|
751
|
+
this.attributes = attributes;
|
|
752
|
+
this.identifierName = identifierName;
|
|
753
|
+
this.passwordName = passwordName;
|
|
754
|
+
}
|
|
755
|
+
attributes;
|
|
756
|
+
identifierName;
|
|
757
|
+
passwordName;
|
|
758
|
+
getAuthIdentifier() {
|
|
759
|
+
const id = this.attributes[this.identifierName];
|
|
760
|
+
if (typeof id === "number" || typeof id === "string") return id;
|
|
761
|
+
return "";
|
|
762
|
+
}
|
|
763
|
+
getAuthIdentifierName() {
|
|
764
|
+
return this.identifierName;
|
|
765
|
+
}
|
|
766
|
+
getAuthPassword() {
|
|
767
|
+
const password = this.attributes[this.passwordName];
|
|
768
|
+
return typeof password === "string" ? password : "";
|
|
769
|
+
}
|
|
770
|
+
setAuthPassword(hashed) {
|
|
771
|
+
this.attributes[this.passwordName] = hashed;
|
|
772
|
+
}
|
|
773
|
+
getRememberToken() {
|
|
774
|
+
const token = this.attributes[REMEMBER_TOKEN];
|
|
775
|
+
return typeof token === "string" ? token : null;
|
|
776
|
+
}
|
|
777
|
+
setRememberToken(token) {
|
|
778
|
+
this.attributes[REMEMBER_TOKEN] = token;
|
|
779
|
+
}
|
|
780
|
+
/** Read an arbitrary attribute, used by providers to match credentials. */
|
|
781
|
+
getAttribute(key) {
|
|
782
|
+
return this.attributes[key];
|
|
783
|
+
}
|
|
784
|
+
};
|
|
785
|
+
var ArrayUserProvider = class {
|
|
786
|
+
constructor(users, hasher) {
|
|
787
|
+
this.users = users;
|
|
788
|
+
this.hasher = hasher;
|
|
789
|
+
}
|
|
790
|
+
users;
|
|
791
|
+
hasher;
|
|
792
|
+
retrieveById(identifier) {
|
|
793
|
+
const user = this.users.find((candidate) => candidate.getAuthIdentifier() === identifier);
|
|
794
|
+
return Promise.resolve(user ?? null);
|
|
795
|
+
}
|
|
796
|
+
retrieveByToken(identifier, token) {
|
|
797
|
+
const user = this.users.find(
|
|
798
|
+
(candidate) => String(candidate.getAuthIdentifier()) === String(identifier)
|
|
799
|
+
);
|
|
800
|
+
const stored = user?.getRememberToken();
|
|
801
|
+
if (user === void 0 || stored === null || stored === void 0 || stored.length === 0) {
|
|
802
|
+
return Promise.resolve(null);
|
|
803
|
+
}
|
|
804
|
+
return Promise.resolve(safeEqual2(stored, token) ? user : null);
|
|
805
|
+
}
|
|
806
|
+
updateRememberToken(user, token) {
|
|
807
|
+
if (isRememberable(user)) user.setRememberToken(token);
|
|
808
|
+
return Promise.resolve();
|
|
809
|
+
}
|
|
810
|
+
retrieveByCredentials(credentials) {
|
|
811
|
+
const keys = Object.keys(credentials).filter((key) => !key.includes("password"));
|
|
812
|
+
if (keys.length === 0) return Promise.resolve(null);
|
|
813
|
+
const user = this.users.find(
|
|
814
|
+
(candidate) => keys.every((key) => candidate.getAttribute(key) === credentials[key])
|
|
815
|
+
);
|
|
816
|
+
return Promise.resolve(user ?? null);
|
|
817
|
+
}
|
|
818
|
+
validateCredentials(user, credentials) {
|
|
819
|
+
const password = credentials["password"];
|
|
820
|
+
if (typeof password !== "string") return Promise.resolve(false);
|
|
821
|
+
return Promise.resolve(this.hasher.check(password, user.getAuthPassword()));
|
|
822
|
+
}
|
|
823
|
+
/**
|
|
824
|
+
* Re-hash and persist the user's password when its cost parameters no longer match the hasher's
|
|
825
|
+
* (or always, when `force` is set) — the Laravel `rehashPasswordIfRequired`. Persists through the
|
|
826
|
+
* {@link PasswordUpdatable} seam, mirroring how remember tokens are persisted.
|
|
827
|
+
*/
|
|
828
|
+
rehashPasswordIfRequired(user, credentials, force = false) {
|
|
829
|
+
const password = credentials["password"];
|
|
830
|
+
if (typeof password !== "string") return Promise.resolve();
|
|
831
|
+
if (!force && !this.hasher.needsRehash(user.getAuthPassword())) return Promise.resolve();
|
|
832
|
+
if (isPasswordUpdatable(user)) user.setAuthPassword(this.hasher.make(password));
|
|
833
|
+
return Promise.resolve();
|
|
834
|
+
}
|
|
835
|
+
};
|
|
836
|
+
function isRememberable(user) {
|
|
837
|
+
return "setRememberToken" in user && typeof user.setRememberToken === "function";
|
|
838
|
+
}
|
|
839
|
+
function isPasswordUpdatable(user) {
|
|
840
|
+
return "setAuthPassword" in user && typeof user.setAuthPassword === "function";
|
|
841
|
+
}
|
|
842
|
+
function safeEqual2(a, b) {
|
|
843
|
+
const bufferA = Buffer.from(a);
|
|
844
|
+
const bufferB = Buffer.from(b);
|
|
845
|
+
if (bufferA.length !== bufferB.length) return false;
|
|
846
|
+
return crypto.timingSafeEqual(bufferA, bufferB);
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
// src/index.ts
|
|
850
|
+
var VERSION = "0.1.0";
|
|
851
|
+
|
|
852
|
+
exports.ArrayTokenRepository = ArrayTokenRepository;
|
|
853
|
+
exports.ArrayUserProvider = ArrayUserProvider;
|
|
854
|
+
exports.Attempting = Attempting;
|
|
855
|
+
exports.AuthManager = AuthManager;
|
|
856
|
+
exports.Authenticated = Authenticated;
|
|
857
|
+
exports.AuthenticationError = AuthenticationError;
|
|
858
|
+
exports.CurrentDeviceLogout = CurrentDeviceLogout;
|
|
859
|
+
exports.EmailVerifier = EmailVerifier;
|
|
860
|
+
exports.Failed = Failed;
|
|
861
|
+
exports.GenericUser = GenericUser;
|
|
862
|
+
exports.Lockout = Lockout;
|
|
863
|
+
exports.Login = Login;
|
|
864
|
+
exports.Logout = Logout;
|
|
865
|
+
exports.OtherDeviceLogout = OtherDeviceLogout;
|
|
866
|
+
exports.PASSWORD_CONFIRMED_AT_SESSION_KEY = PASSWORD_CONFIRMED_AT_SESSION_KEY;
|
|
867
|
+
exports.PASSWORD_HASH_SESSION_KEY = PASSWORD_HASH_SESSION_KEY;
|
|
868
|
+
exports.PasswordBroker = PasswordBroker;
|
|
869
|
+
exports.PasswordReset = PasswordReset;
|
|
870
|
+
exports.PasswordStatus = PasswordStatus;
|
|
871
|
+
exports.Registered = Registered;
|
|
872
|
+
exports.RequestGuard = RequestGuard;
|
|
873
|
+
exports.SessionGuard = SessionGuard;
|
|
874
|
+
exports.TokenGuard = TokenGuard;
|
|
875
|
+
exports.VERSION = VERSION;
|
|
876
|
+
exports.Validated = Validated;
|
|
877
|
+
exports.Verified = Verified;
|
|
878
|
+
exports.authenticateSession = authenticateSession;
|
|
879
|
+
exports.authenticateToken = authenticateToken;
|
|
880
|
+
exports.confirmPassword = confirmPassword;
|
|
881
|
+
exports.getUser = getUser;
|
|
882
|
+
exports.redirectIfAuthenticated = redirectIfAuthenticated;
|
|
883
|
+
exports.requirePassword = requirePassword;
|
|
884
|
+
//# sourceMappingURL=index.cjs.map
|
|
885
|
+
//# sourceMappingURL=index.cjs.map
|