@happyvertical/smrt-users 0.54.0 → 0.54.3
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/AGENTS.md +16 -0
- package/README.md +129 -3
- package/dist/chunks/{TerminalAuthService-BfxG493c.js → TerminalAuthService-Bc67JXJ5.js} +969 -155
- package/dist/chunks/TerminalAuthService-Bc67JXJ5.js.map +1 -0
- package/dist/collections/PasswordCredentialCollection.d.ts +53 -0
- package/dist/collections/PasswordCredentialCollection.d.ts.map +1 -0
- package/dist/collections/SessionCollection.d.ts +7 -2
- package/dist/collections/SessionCollection.d.ts.map +1 -1
- package/dist/collections/index.d.ts +1 -0
- package/dist/collections/index.d.ts.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +44 -4
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +424 -2
- package/dist/models/PasswordCredential.d.ts +36 -0
- package/dist/models/PasswordCredential.d.ts.map +1 -0
- package/dist/models/index.d.ts +1 -0
- package/dist/models/index.d.ts.map +1 -1
- package/dist/services/DeviceCredentialService.d.ts.map +1 -1
- package/dist/services/PasswordCredentialService.d.ts +302 -0
- package/dist/services/PasswordCredentialService.d.ts.map +1 -0
- package/dist/services/SessionService.d.ts +3 -1
- package/dist/services/SessionService.d.ts.map +1 -1
- package/dist/services/credential-hash.d.ts +76 -0
- package/dist/services/credential-hash.d.ts.map +1 -0
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.d.ts.map +1 -1
- package/dist/smrt-knowledge.json +208 -8
- package/dist/sveltekit/index.d.ts +1 -0
- package/dist/sveltekit/index.d.ts.map +1 -1
- package/dist/sveltekit/password-handlers.d.ts +91 -0
- package/dist/sveltekit/password-handlers.d.ts.map +1 -0
- package/dist/sveltekit.js +237 -68
- package/dist/sveltekit.js.map +1 -1
- package/package.json +12 -12
- package/dist/chunks/TerminalAuthService-BfxG493c.js.map +0 -1
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PasswordCredentialService — email + password sign-in for an existing,
|
|
3
|
+
* active user, and the password's lifecycle (#3274).
|
|
4
|
+
*
|
|
5
|
+
* ## Sign-in
|
|
6
|
+
*
|
|
7
|
+
* 1. Normalize the submitted identifier exactly as `User.emailKey` is.
|
|
8
|
+
* 2. Reserve a login attempt: subject = that email key (what the client
|
|
9
|
+
* typed, never a resolved user), source = the client address.
|
|
10
|
+
* 3. Always run one scrypt verification — against the stored hash, or a
|
|
11
|
+
* dummy hash when there is no such user or no password — so neither the
|
|
12
|
+
* response nor its timing says whether the account or credential exists.
|
|
13
|
+
* 4. Require an ACTIVE user and, when a tenant is given, an ACTIVE membership
|
|
14
|
+
* in it. Never create a user.
|
|
15
|
+
* 5. Mint a first-class session (`authMethod: 'password'`) through
|
|
16
|
+
* `SessionService.createSession`, then re-check that the credential that
|
|
17
|
+
* was verified is still the current one (closing the race with a
|
|
18
|
+
* concurrent change/reset, whose revocation sweep runs after its write).
|
|
19
|
+
* 6. Rehash under the current scrypt policy if the stored parameters are
|
|
20
|
+
* weaker, as a compare-and-set that never overwrites a newer password.
|
|
21
|
+
*
|
|
22
|
+
* Every refusal other than a rate limit is one {@link PasswordCredentialError}
|
|
23
|
+
* ("Invalid credentials."); a rate limit is {@link LoginRateLimitError}.
|
|
24
|
+
*
|
|
25
|
+
* ## Lifecycle and authority
|
|
26
|
+
*
|
|
27
|
+
* - `setPassword`: the person sets their own FIRST password from any
|
|
28
|
+
* first-class session, or an administrator holding `managePermission` sets
|
|
29
|
+
* one for someone else.
|
|
30
|
+
* - `changePassword`: the person replaces their own, proving the current one
|
|
31
|
+
* (through the limiter, so it is no oracle). Ends every other session of
|
|
32
|
+
* theirs.
|
|
33
|
+
* - `resetPassword`: an administrator replaces someone else's and, by
|
|
34
|
+
* default, flags `mustChange`. Ends every session of theirs.
|
|
35
|
+
* - `clearPassword`: an administrator, or the person proving the current one.
|
|
36
|
+
*
|
|
37
|
+
* A layered (device PIN) session never manages passwords, and an
|
|
38
|
+
* administrator may only manage people whose every active membership is in
|
|
39
|
+
* the administrator's session tenant — the credential is one per person
|
|
40
|
+
* across tenants, as the PIN is.
|
|
41
|
+
*
|
|
42
|
+
* @packageDocumentation
|
|
43
|
+
*/
|
|
44
|
+
import type { SmrtClassOptions } from '@happyvertical/smrt-core';
|
|
45
|
+
import { type SessionAuthMethod } from '../models/Session.js';
|
|
46
|
+
import { type ScryptParams } from './credential-hash.js';
|
|
47
|
+
import { InvalidCredentialsError, LoginAttemptLimiter, type LoginAttemptLimiterOptions } from './LoginAttemptLimiter.js';
|
|
48
|
+
import { type PermissionDefinition } from './PermissionCatalogService.js';
|
|
49
|
+
import { type SessionContext } from './SessionService.js';
|
|
50
|
+
/** Login-limiter kind and session `authMethod` for password sign-ins. */
|
|
51
|
+
export declare const PASSWORD_LOGIN_KIND = "password";
|
|
52
|
+
/** Default permission required to set, reset, or clear another person's password. */
|
|
53
|
+
export declare const DEFAULT_PASSWORD_MANAGE_PERMISSION = "users.password.manage";
|
|
54
|
+
/** Default minimum password length, in characters. */
|
|
55
|
+
export declare const DEFAULT_PASSWORD_MIN_LENGTH = 10;
|
|
56
|
+
/** Default maximum password length, in characters. */
|
|
57
|
+
export declare const DEFAULT_PASSWORD_MAX_LENGTH = 256;
|
|
58
|
+
/** No configuration may raise the maximum above this: it bounds hashing work. */
|
|
59
|
+
export declare const PASSWORD_MAX_LENGTH_CEILING = 1024;
|
|
60
|
+
/**
|
|
61
|
+
* Built-in denylist: a few of the most common passwords that pass a
|
|
62
|
+
* 10-character minimum. Deliberately small — extend it through
|
|
63
|
+
* `password.denylist` or `password.reject` (a breached-password check, say).
|
|
64
|
+
* Compared case-insensitively.
|
|
65
|
+
*/
|
|
66
|
+
export declare const DEFAULT_PASSWORD_DENYLIST: readonly string[];
|
|
67
|
+
/** Catalog definition for {@link DEFAULT_PASSWORD_MANAGE_PERMISSION}. */
|
|
68
|
+
export declare const PASSWORD_PERMISSION_DEFINITIONS: PermissionDefinition[];
|
|
69
|
+
/** Register the password management permission once when the service is used. */
|
|
70
|
+
export declare function ensurePasswordPermissionsRegistered(): void;
|
|
71
|
+
/**
|
|
72
|
+
* Every sign-in refusal that is not a rate limit: unknown identifier, no
|
|
73
|
+
* password, wrong password, inactive user, no membership. One message, so
|
|
74
|
+
* responses cannot enumerate accounts.
|
|
75
|
+
*/
|
|
76
|
+
export declare class PasswordCredentialError extends InvalidCredentialsError {
|
|
77
|
+
constructor(message?: string);
|
|
78
|
+
}
|
|
79
|
+
/** Thrown by set/change/reset/clear when the actor may not manage the password. */
|
|
80
|
+
export declare class PasswordCredentialForbiddenError extends Error {
|
|
81
|
+
constructor(message?: string);
|
|
82
|
+
}
|
|
83
|
+
/** Thrown by set/change/reset when the new password fails policy. */
|
|
84
|
+
export declare class PasswordPolicyError extends Error {
|
|
85
|
+
constructor(message: string);
|
|
86
|
+
}
|
|
87
|
+
/** What a policy hook can see besides the candidate password. */
|
|
88
|
+
export interface PasswordPolicyContext {
|
|
89
|
+
/** The person the password is for. */
|
|
90
|
+
userId: string;
|
|
91
|
+
/** Their normalized email, when they have one. */
|
|
92
|
+
email: string | null;
|
|
93
|
+
}
|
|
94
|
+
export interface PasswordPolicyOptions {
|
|
95
|
+
/** Minimum length in characters (Unicode code points, after NFKC). Default 10. */
|
|
96
|
+
minLength?: number;
|
|
97
|
+
/**
|
|
98
|
+
* Maximum length in characters. Default 256; may not exceed
|
|
99
|
+
* {@link PASSWORD_MAX_LENGTH_CEILING}. Longer input is refused before any
|
|
100
|
+
* hashing work, at sign-in too.
|
|
101
|
+
*/
|
|
102
|
+
maxLength?: number;
|
|
103
|
+
/**
|
|
104
|
+
* Extra passwords to refuse, added to {@link DEFAULT_PASSWORD_DENYLIST}.
|
|
105
|
+
* Compared case-insensitively.
|
|
106
|
+
*/
|
|
107
|
+
denylist?: Iterable<string>;
|
|
108
|
+
/**
|
|
109
|
+
* Host hook run after the built-in checks: return a message to refuse the
|
|
110
|
+
* password, or null to accept it. Use it for a breached-password service
|
|
111
|
+
* or shop-specific words. There are deliberately no composition rules.
|
|
112
|
+
*/
|
|
113
|
+
reject?: (password: string, context: PasswordPolicyContext) => string | null | undefined | Promise<string | null | undefined>;
|
|
114
|
+
/**
|
|
115
|
+
* Server-side secret mixed into every hash. Optional; changing it
|
|
116
|
+
* invalidates every stored password.
|
|
117
|
+
*/
|
|
118
|
+
pepper?: string;
|
|
119
|
+
/**
|
|
120
|
+
* scrypt parameters for new hashes. Defaults: N=2^15, r=8, p=1 (32 MiB).
|
|
121
|
+
* A stored hash with weaker parameters is rehashed on the next successful
|
|
122
|
+
* sign-in.
|
|
123
|
+
*/
|
|
124
|
+
scrypt?: Partial<ScryptParams>;
|
|
125
|
+
}
|
|
126
|
+
export interface PasswordCredentialServiceOptions extends SmrtClassOptions {
|
|
127
|
+
/** Lifetime of a password session in seconds. Default seven days. */
|
|
128
|
+
sessionTtl?: number;
|
|
129
|
+
/**
|
|
130
|
+
* Shared {@link LoginAttemptLimiter}. When omitted one is created from
|
|
131
|
+
* `limiter` (or defaults). Supplying the host's instance keeps password,
|
|
132
|
+
* PIN and terminal budgets in one table with one audit sink.
|
|
133
|
+
*/
|
|
134
|
+
loginLimiter?: LoginAttemptLimiter;
|
|
135
|
+
/** Options for the private limiter when `loginLimiter` is not supplied. */
|
|
136
|
+
limiter?: Omit<LoginAttemptLimiterOptions, keyof SmrtClassOptions>;
|
|
137
|
+
/** Permission slug an administrator needs to manage others' passwords. */
|
|
138
|
+
managePermission?: string;
|
|
139
|
+
/** Password policy. */
|
|
140
|
+
password?: PasswordPolicyOptions;
|
|
141
|
+
}
|
|
142
|
+
export interface PasswordSignInInput {
|
|
143
|
+
/** What the person typed as their email; normalized like `User.emailKey`. */
|
|
144
|
+
identifier: string;
|
|
145
|
+
password: string;
|
|
146
|
+
/**
|
|
147
|
+
* Tenant to sign into. When set, the person must hold an ACTIVE membership
|
|
148
|
+
* in it; when null/omitted the session carries no tenant context (and so
|
|
149
|
+
* no tenant permissions) until `switchSessionTenant`.
|
|
150
|
+
*/
|
|
151
|
+
tenantId?: string | null;
|
|
152
|
+
ipAddress?: string;
|
|
153
|
+
userAgent?: string;
|
|
154
|
+
/**
|
|
155
|
+
* The session id the client presented before signing in (its old cookie),
|
|
156
|
+
* if any. Revoked after a successful sign-in so a planted or previous
|
|
157
|
+
* session id never survives authentication (session fixation).
|
|
158
|
+
*/
|
|
159
|
+
replaceSessionId?: string | null;
|
|
160
|
+
}
|
|
161
|
+
export interface PasswordSignInResult {
|
|
162
|
+
/** The new session id: the cookie value. Never send it to client script. */
|
|
163
|
+
sessionId: string;
|
|
164
|
+
userId: string;
|
|
165
|
+
tenantId: string | null;
|
|
166
|
+
authMethod: SessionAuthMethod;
|
|
167
|
+
expiresAt: string;
|
|
168
|
+
/**
|
|
169
|
+
* True when an administrator reset the password: the session resolves to
|
|
170
|
+
* no permissions and can only call `changePassword`, which ends it; the
|
|
171
|
+
* person then signs in with the new password.
|
|
172
|
+
*/
|
|
173
|
+
mustChange: boolean;
|
|
174
|
+
}
|
|
175
|
+
export interface SetPasswordInput {
|
|
176
|
+
/** Resolved session of whoever is making the change. */
|
|
177
|
+
actor: SessionContext;
|
|
178
|
+
userId: string;
|
|
179
|
+
password: string;
|
|
180
|
+
ipAddress?: string;
|
|
181
|
+
}
|
|
182
|
+
export interface ChangePasswordInput {
|
|
183
|
+
/** The person's own session; the password changed is always theirs. */
|
|
184
|
+
actor: SessionContext;
|
|
185
|
+
currentPassword: string;
|
|
186
|
+
newPassword: string;
|
|
187
|
+
ipAddress?: string;
|
|
188
|
+
}
|
|
189
|
+
export interface ResetPasswordInput {
|
|
190
|
+
actor: SessionContext;
|
|
191
|
+
userId: string;
|
|
192
|
+
password: string;
|
|
193
|
+
/** Require a change at next sign-in. Default true. */
|
|
194
|
+
mustChange?: boolean;
|
|
195
|
+
ipAddress?: string;
|
|
196
|
+
}
|
|
197
|
+
export interface ClearPasswordInput {
|
|
198
|
+
actor: SessionContext;
|
|
199
|
+
userId: string;
|
|
200
|
+
/** Required when a person clears their own password. */
|
|
201
|
+
currentPassword?: string;
|
|
202
|
+
ipAddress?: string;
|
|
203
|
+
}
|
|
204
|
+
export declare class PasswordCredentialService {
|
|
205
|
+
private readonly options;
|
|
206
|
+
private readonly sessionTtl;
|
|
207
|
+
private readonly managePermission;
|
|
208
|
+
private readonly policy;
|
|
209
|
+
private sessionService;
|
|
210
|
+
private memberships;
|
|
211
|
+
private users;
|
|
212
|
+
private credentials;
|
|
213
|
+
private limiter;
|
|
214
|
+
private dummyHash;
|
|
215
|
+
constructor(options: PasswordCredentialServiceOptions);
|
|
216
|
+
static create(options: PasswordCredentialServiceOptions): Promise<PasswordCredentialService>;
|
|
217
|
+
initialize(): Promise<void>;
|
|
218
|
+
/** The limiter in use (shared or private). */
|
|
219
|
+
get loginLimiter(): LoginAttemptLimiter;
|
|
220
|
+
/**
|
|
221
|
+
* Verify an email and password and mint a session. Throws
|
|
222
|
+
* {@link PasswordCredentialError} for every refusal that is not a rate
|
|
223
|
+
* limit and {@link LoginRateLimitError} when the budget is exhausted.
|
|
224
|
+
*/
|
|
225
|
+
signIn(input: PasswordSignInInput): Promise<PasswordSignInResult>;
|
|
226
|
+
/**
|
|
227
|
+
* Set a password where the person has none: the person themself from any
|
|
228
|
+
* first-class session, or an administrator holding `managePermission` for
|
|
229
|
+
* someone else (which, if a password already exists, replaces it and ends
|
|
230
|
+
* every session of theirs like {@link resetPassword} without the
|
|
231
|
+
* must-change flag). A person who already has one uses
|
|
232
|
+
* {@link changePassword}.
|
|
233
|
+
*/
|
|
234
|
+
setPassword(input: SetPasswordInput): Promise<{
|
|
235
|
+
revokedSessions: number;
|
|
236
|
+
}>;
|
|
237
|
+
/**
|
|
238
|
+
* The person changes their own password, proving the current one. Every
|
|
239
|
+
* other session of theirs ends — the reason to change may be that it
|
|
240
|
+
* leaked — and so does this one when it is the restricted session a reset
|
|
241
|
+
* password signed in to.
|
|
242
|
+
*/
|
|
243
|
+
changePassword(input: ChangePasswordInput): Promise<{
|
|
244
|
+
revokedSessions: number;
|
|
245
|
+
endedCurrentSession: boolean;
|
|
246
|
+
}>;
|
|
247
|
+
/**
|
|
248
|
+
* Administrative reset: replace someone else's password and end every
|
|
249
|
+
* session they hold. `mustChange` (default true) makes the next sign-in a
|
|
250
|
+
* restricted session that can only change the password.
|
|
251
|
+
*/
|
|
252
|
+
resetPassword(input: ResetPasswordInput): Promise<{
|
|
253
|
+
revokedSessions: number;
|
|
254
|
+
}>;
|
|
255
|
+
/**
|
|
256
|
+
* Remove a person's password and end their password sessions. An
|
|
257
|
+
* administrator holding `managePermission`, or the person proving the
|
|
258
|
+
* current password (not from a must-change session).
|
|
259
|
+
*/
|
|
260
|
+
clearPassword(input: ClearPasswordInput): Promise<{
|
|
261
|
+
revokedSessions: number;
|
|
262
|
+
}>;
|
|
263
|
+
/** Whether the person has a password (for admin UIs; never for sign-in responses). */
|
|
264
|
+
hasPassword(userId: string): Promise<boolean>;
|
|
265
|
+
/**
|
|
266
|
+
* Check a candidate against the policy without storing it — for a form
|
|
267
|
+
* that wants to say "too short" before submitting. Throws
|
|
268
|
+
* {@link PasswordPolicyError}.
|
|
269
|
+
*/
|
|
270
|
+
validatePassword(password: string, userId: string): Promise<void>;
|
|
271
|
+
private findUserByEmailKey;
|
|
272
|
+
private requireUser;
|
|
273
|
+
/**
|
|
274
|
+
* Prove the current password for a self-service change or clear, through
|
|
275
|
+
* the limiter on the same subject key as sign-in, so these paths cannot be
|
|
276
|
+
* used to guess outside the sign-in budget.
|
|
277
|
+
*/
|
|
278
|
+
private verifyCurrent;
|
|
279
|
+
private assertNotLayered;
|
|
280
|
+
private assertCanManage;
|
|
281
|
+
/** Returns the normalized password to hash, or throws {@link PasswordPolicyError}. */
|
|
282
|
+
private assertPolicy;
|
|
283
|
+
private hashPassword;
|
|
284
|
+
/**
|
|
285
|
+
* Verify against the stored hash, or the dummy hash when there is none,
|
|
286
|
+
* doing the same scrypt work either way. A stored hash derived under
|
|
287
|
+
* weaker parameters than the current policy (before its upgrade rehash)
|
|
288
|
+
* would otherwise verify faster than the dummy does and reveal that the
|
|
289
|
+
* credential exists, so its verification is padded up to the policy's
|
|
290
|
+
* cost.
|
|
291
|
+
*/
|
|
292
|
+
private verifyEqualWork;
|
|
293
|
+
/**
|
|
294
|
+
* Rehash a just-verified password whose stored parameters are below the
|
|
295
|
+
* current policy. Best effort: a failure here must never turn a completed
|
|
296
|
+
* sign-in into an error, and the guarded write never replaces a password
|
|
297
|
+
* that changed after it was verified.
|
|
298
|
+
*/
|
|
299
|
+
private upgradeHashIfNeeded;
|
|
300
|
+
private recordManagement;
|
|
301
|
+
}
|
|
302
|
+
//# sourceMappingURL=PasswordCredentialService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PasswordCredentialService.d.ts","sourceRoot":"","sources":["../../src/services/PasswordCredentialService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAMjE,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAIL,KAAK,YAAY,EAGlB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,KAAK,0BAA0B,EAEhC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,KAAK,oBAAoB,EAE1B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,KAAK,cAAc,EAAkB,MAAM,qBAAqB,CAAC;AAE1E,yEAAyE;AACzE,eAAO,MAAM,mBAAmB,aAAa,CAAC;AAC9C,qFAAqF;AACrF,eAAO,MAAM,kCAAkC,0BAA0B,CAAC;AAC1E,sDAAsD;AACtD,eAAO,MAAM,2BAA2B,KAAK,CAAC;AAC9C,sDAAsD;AACtD,eAAO,MA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AAe,EAAE,MAAM,CAAC;QAAC,mBAAmB,EAAE,OAAO,CAAA;KAAE,CAAC;IA8CrE;;;;OAIG;IACG,aAAa,CACjB,KAAK,EAAE,kBAAkB,GACxB,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;IAoCvC;;;;OAIG;IACG,aAAa,CACjB,KAAK,EAAE,kBAAkB,GACxB,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;IAwCvC,sFAAsF;IAChF,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKnD;;;;OAIG;IACG,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAQzD,kBAAkB;YAKlB,WAAW;IAQzB;;;;OAIG;YACW,aAAa;IAqC3B,OAAO,CAAC,gBAAgB;YAQV,eAAe;IA8B7B,sFAAsF;YACxE,YAAY;IAoC1B,OAAO,CAAC,YAAY;IAIpB;;;;;;;OAOG;YACW,eAAe;IAU7B;;;;;OAKG;YACW,mBAAmB;YAwBnB,gBAAgB;CAY/B"}
|
|
@@ -189,7 +189,9 @@ export declare class SessionService {
|
|
|
189
189
|
/**
|
|
190
190
|
* Destroy all sessions for a user (logout from all devices)
|
|
191
191
|
*/
|
|
192
|
-
destroyAllUserSessions(userId: string
|
|
192
|
+
destroyAllUserSessions(userId: string, options?: {
|
|
193
|
+
exceptSessionId?: string;
|
|
194
|
+
}): Promise<number>;
|
|
193
195
|
/**
|
|
194
196
|
* Switch tenant context for a session.
|
|
195
197
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionService.d.ts","sourceRoot":"","sources":["../../src/services/SessionService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,OAAO,EACL,KAAK,oBAAoB,EAE1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;IACG,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAM5E;;OAEG;IACG,cAAc,CAAC,CAAC,EACpB,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAIzB;;OAEG;IACG,cAAc,CAClB,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,OAAO,CAAC;IAInB;;OAEG;WACU,MAAM,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,cAAc,CAAC;CAK7E"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* scrypt hashing shared by the PIN (#3276) and password (#3274) credentials.
|
|
3
|
+
*
|
|
4
|
+
* The encoded form is self-describing — `scrypt$N$r$p$saltB64$hashB64` — so
|
|
5
|
+
* every stored hash carries the parameters it was derived with. Raising the
|
|
6
|
+
* policy therefore never breaks an existing hash: it still verifies with its
|
|
7
|
+
* own parameters and is rehashed under the new ones on the next successful
|
|
8
|
+
* sign-in ({@link scryptHashNeedsUpgrade}).
|
|
9
|
+
*
|
|
10
|
+
* The secret is hashed as `pepper || 0x00 || secret`; an empty pepper is
|
|
11
|
+
* allowed. Comparison uses `timingSafeEqual`.
|
|
12
|
+
*
|
|
13
|
+
* Internal module: not exported from the package index.
|
|
14
|
+
*
|
|
15
|
+
* @packageDocumentation
|
|
16
|
+
*/
|
|
17
|
+
/** scrypt cost parameters. */
|
|
18
|
+
export interface ScryptParams {
|
|
19
|
+
/** CPU/memory cost; a power of two. */
|
|
20
|
+
N: number;
|
|
21
|
+
/** Block size. */
|
|
22
|
+
r: number;
|
|
23
|
+
/** Parallelisation. */
|
|
24
|
+
p: number;
|
|
25
|
+
}
|
|
26
|
+
/** Derived key length in bytes. */
|
|
27
|
+
export declare const SCRYPT_HASH_BYTES = 32;
|
|
28
|
+
/** Random salt length in bytes, fresh for every hash. */
|
|
29
|
+
export declare const SCRYPT_SALT_BYTES = 16;
|
|
30
|
+
/** True when `params` are structurally valid scrypt parameters within the ceilings. */
|
|
31
|
+
export declare function isValidScryptParams(params: ScryptParams): boolean;
|
|
32
|
+
/** Hash `secret` with a fresh random salt (or `salt`, for verification). */
|
|
33
|
+
export declare function hashSecret(secret: string, pepper: string, params: ScryptParams, salt?: Buffer): Promise<string>;
|
|
34
|
+
interface ParsedScryptHash {
|
|
35
|
+
params: ScryptParams;
|
|
36
|
+
salt: Buffer;
|
|
37
|
+
hash: Buffer;
|
|
38
|
+
}
|
|
39
|
+
/** Parse an encoded hash; null for anything malformed or out of bounds. */
|
|
40
|
+
export declare function parseScryptHash(encoded: string): ParsedScryptHash | null;
|
|
41
|
+
/**
|
|
42
|
+
* Verify `secret` against an encoded hash in constant time. A malformed
|
|
43
|
+
* encoding verifies false.
|
|
44
|
+
*/
|
|
45
|
+
export declare function verifySecretHash(secret: string, pepper: string, encoded: string): Promise<boolean>;
|
|
46
|
+
/**
|
|
47
|
+
* The scrypt derivations whose work makes up the difference between
|
|
48
|
+
* verifying `encoded` and verifying a hash under `policy` — empty when there
|
|
49
|
+
* is no meaningful difference. A malformed encoding verifies without
|
|
50
|
+
* deriving, so it owes the policy's whole cost.
|
|
51
|
+
*
|
|
52
|
+
* Every derivation keeps the policy's memory shape, so padding never touches
|
|
53
|
+
* more memory than one current-policy verification: whole lanes are spent as
|
|
54
|
+
* one derivation at the policy's own `N` and `r` with `p` lanes (`p` never
|
|
55
|
+
* exceeds the policy's), and the remainder as up to six single-lane
|
|
56
|
+
* derivations at the policy's `r` with halving powers of two for `N`. The
|
|
57
|
+
* total matches the policy's cost to within 1/64 of a lane.
|
|
58
|
+
*/
|
|
59
|
+
export declare function scryptPaddingParams(encoded: string, policy: ScryptParams): ScryptParams[];
|
|
60
|
+
/**
|
|
61
|
+
* After verifying against `encoded`, spend the work verifying under
|
|
62
|
+
* `policy` would have cost beyond it ({@link scryptPaddingParams}), so a hash
|
|
63
|
+
* still carrying weaker parameters costs about what a current-policy hash —
|
|
64
|
+
* such as the dummy hash a missing credential is compared against — does.
|
|
65
|
+
*/
|
|
66
|
+
export declare function padScryptWork(encoded: string, policy: ScryptParams): Promise<void>;
|
|
67
|
+
/** Relative scrypt work: ROMix runs `2·N` BlockMix rounds of cost `r`, `p` times. */
|
|
68
|
+
export declare function scryptCost(params: ScryptParams): number;
|
|
69
|
+
/**
|
|
70
|
+
* True when the stored hash was derived with weaker parameters than
|
|
71
|
+
* `policy` on any axis (or cannot be parsed), so it should be rehashed after
|
|
72
|
+
* the next successful verification.
|
|
73
|
+
*/
|
|
74
|
+
export declare function scryptHashNeedsUpgrade(encoded: string, policy: ScryptParams): boolean;
|
|
75
|
+
export {};
|
|
76
|
+
//# sourceMappingURL=credential-hash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential-hash.d.ts","sourceRoot":"","sources":["../../src/services/credential-hash.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,8BAA8B;AAC9B,MAAM,WAAW,YAAY;IAC3B,uCAAuC;IACvC,CAAC,EAAE,MAAM,CAAC;IACV,kBAAkB;IAClB,CAAC,EAAE,MAAM,CAAC;IACV,uBAAuB;IACvB,CAAC,EAAE,MAAM,CAAC;CACX;AAED,mCAAmC;AACnC,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,yDAAyD;AACzD,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAWpC,uFAAuF;AACvF,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAcjE;AA2BD,4EAA4E;AAC5E,wBAAsB,UAAU,CAC9B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,YAAY,EACpB,IAAI,GAAE,MAAuC,GAC5C,OAAO,CAAC,MAAM,CAAC,CAGjB;AAED,UAAU,gBAAgB;IACxB,MAAM,EAAE,YAAY,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,2EAA2E;AAC3E,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAWxE;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,OAAO,CAAC,CAQlB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,YAAY,GACnB,YAAY,EAAE,CAkBhB;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,YAAY,GACnB,OAAO,CAAC,IAAI,CAAC,CAIf;AAED,qFAAqF;AACrF,wBAAgB,UAAU,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAEvD;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,YAAY,GACnB,OAAO,CAQT"}
|
package/dist/services/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export { MagicLinkError, type MagicLinkResult, MagicLinkService, type MagicLinkS
|
|
|
10
10
|
export { MobileAuthError, type MobileAuthErrorCode, MobileAuthService, type MobileAuthServiceOptions, type MobileBootstrapContext, type MobileLoginContext, type MobileLogoutResult, type MobileRequestMeta, type MobileResolvedUser, type MobileTenantContext, readMobileBearerToken, validateMobileRedirectUri, } from './MobileAuthService.js';
|
|
11
11
|
export { type CreateAuthorizationUrlOptions, decodeOidcTransaction, encodeOidcTransaction, getUsersOidcConfig, type OidcCallbackResult, OidcLoginError, type OidcLoginResult, OidcLoginService, type OidcLoginServiceOptions, type OidcProviderConfig, type OidcProviderKind, type OidcProviderMetadata, type OidcProviderResolution, type OidcProviderResolutionOptions, type OidcTokenEndpointAuthMethod, type OidcTokenSet, type OidcTransaction, type ResolvedOidcProviderConfig, resolveOidcProviderConfig, type UsersOidcConfig, } from './OidcLoginService.js';
|
|
12
12
|
export { assertOperationPermission, checkOperationPermission, hasOperationPermission, type OperationPermissionAllowReason, type OperationPermissionDecision, type OperationPermissionDenyReason, OperationPermissionError, type OperationPermissionOptions, } from './OperationPermissionService.js';
|
|
13
|
+
export { type ChangePasswordInput, type ClearPasswordInput, DEFAULT_PASSWORD_DENYLIST, DEFAULT_PASSWORD_MANAGE_PERMISSION, DEFAULT_PASSWORD_MAX_LENGTH, DEFAULT_PASSWORD_MIN_LENGTH, ensurePasswordPermissionsRegistered, PASSWORD_LOGIN_KIND, PASSWORD_MAX_LENGTH_CEILING, PASSWORD_PERMISSION_DEFINITIONS, PasswordCredentialError, PasswordCredentialForbiddenError, PasswordCredentialService, type PasswordCredentialServiceOptions, type PasswordPolicyContext, PasswordPolicyError, type PasswordPolicyOptions, type PasswordSignInInput, type PasswordSignInResult, type ResetPasswordInput, type SetPasswordInput, } from './PasswordCredentialService.js';
|
|
13
14
|
export { deriveOperationPermissionCollectionName, deriveOperationPermissionSlug, normalizeOperationPermissionAction, type OperationPermissionCollectionInput, type PermissionCatalog, PermissionCatalogService, type PermissionCatalogSource, type PermissionCatalogSyncResult, type PermissionDefinition, type PostgresPermissionAction, type PostgresPermissionBinding, registerPermissionDefinitions, syncPermissionCatalog, type UsersConfig, } from './PermissionCatalogService.js';
|
|
14
15
|
export { type PermissionResolutionOptions, type PermissionResolutionResult, PermissionResolver, type PermissionResolverOptions, type TenantPermissionInheritanceResult, } from './PermissionResolver.js';
|
|
15
16
|
export { applyPostgresPermissionPolicies, type GeneratePostgresPermissionSqlResult, generatePostgresPermissionSql, type PostgresPermissionPolicyReportItem, type PostgresPermissionPolicyTarget, } from './PostgresPermissionPolicies.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","s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