@jwilleke/ngdpbase-types 5.40.0 → 5.41.1

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 (47) hide show
  1. package/lib/packages/media-date/index.d.ts +34 -0
  2. package/lib/packages/ngdpbase-types/index.d.ts +1 -1
  3. package/lib/src/ice/fileHandling.d.ts +6 -1
  4. package/lib/src/ice/runExport.d.ts +41 -0
  5. package/lib/src/ice/runImport.d.ts +16 -7
  6. package/lib/src/ice/shims/csv.d.ts +24 -0
  7. package/lib/src/ice/shims/export.d.ts +23 -0
  8. package/lib/src/ice/shims/index.d.ts +3 -1
  9. package/lib/src/ice/shims/svg.d.ts +27 -0
  10. package/lib/src/ice/shims/takeout.d.ts +83 -0
  11. package/lib/src/ice/types.d.ts +251 -5
  12. package/lib/src/ice/vet.d.ts +19 -0
  13. package/lib/src/managers/AttachmentManager.d.ts +86 -36
  14. package/lib/src/managers/AuthManager.d.ts +117 -7
  15. package/lib/src/managers/AuthManager.js +341 -37
  16. package/lib/src/managers/ConfigurationManager.d.ts +6 -0
  17. package/lib/src/managers/ExportManager.d.ts +16 -0
  18. package/lib/src/managers/ExportManager.js +25 -0
  19. package/lib/src/managers/FileManager.d.ts +182 -0
  20. package/lib/src/managers/ImportManager.d.ts +264 -16
  21. package/lib/src/managers/MediaManager.d.ts +11 -0
  22. package/lib/src/managers/SharedFolderManager.d.ts +320 -0
  23. package/lib/src/providers/BaseMediaProvider.d.ts +4 -0
  24. package/lib/src/providers/FileSystemMediaProvider.d.ts +25 -0
  25. package/lib/src/security/PolicyDecisionPoint.d.ts +3 -2
  26. package/lib/src/security/permissions.generated.d.ts +3 -3
  27. package/lib/src/types/File.d.ts +90 -0
  28. package/lib/src/types/express.d.ts +3 -1
  29. package/lib/src/types/linkedom.d.ts +2 -0
  30. package/lib/src/utils/auditEventNames.generated.d.ts +2 -0
  31. package/lib/src/utils/auditEventNames.generated.js +2 -0
  32. package/lib/src/utils/auditEvents.d.ts +3 -0
  33. package/lib/src/utils/auditEvents.js +3 -0
  34. package/lib/src/utils/fileMigrationPlan.d.ts +81 -0
  35. package/lib/src/utils/mediaFolderOverlap.d.ts +50 -0
  36. package/lib/src/utils/privateStoreAccess.d.ts +21 -0
  37. package/lib/src/utils/privateStoreAccess.js +11 -0
  38. package/lib/src/utils/privateStoreImport.d.ts +0 -10
  39. package/lib/src/utils/privateStorePath.d.ts +12 -0
  40. package/lib/src/utils/privateStorePath.js +18 -0
  41. package/lib/src/utils/recoveryWordsFile.d.ts +54 -0
  42. package/lib/src/utils/sessionEnd.d.ts +1 -0
  43. package/lib/src/utils/sessionEnd.js +4 -0
  44. package/lib/src/utils/sessionIdle.d.ts +4 -0
  45. package/lib/src/utils/sessionIdle.js +6 -0
  46. package/package.json +1 -1
  47. package/lib/src/providers/mediaFilenameDate.d.ts +0 -22
@@ -50,6 +50,12 @@ export interface FactorEntry {
50
50
  aal?: Aal;
51
51
  acr?: PhishingResistance;
52
52
  enabled?: boolean;
53
+ /**
54
+ * Where it comes among the second factors offered, lower first; none comes
55
+ * last (#1523, operator 2026-10-11). A number, because the configuration
56
+ * merge does not keep a custom entry's place in the list.
57
+ */
58
+ preference?: number;
53
59
  }
54
60
  export interface Factor {
55
61
  provider: string;
@@ -126,6 +132,8 @@ export interface PendingSignIn {
126
132
  requestLocation?: string | null;
127
133
  /** Private-store keys unlocked by the password, held until the sign-in completes or is dropped. */
128
134
  privateStoreHandle?: string;
135
+ /** The level this account's roles require (`requiredAalFor`), so the second factors that reach it are offered first (#1523 Q2). */
136
+ requiredAal?: Aal;
129
137
  /** The second factor, once satisfied. */
130
138
  approved?: SatisfiedFactor;
131
139
  /** Refused by the person (Deny). */
@@ -172,7 +180,8 @@ export interface ApprovalVisitor {
172
180
  }
173
181
  /** A second factor a person has enrolled and can use now. */
174
182
  export interface AvailableSecondFactor {
175
- id: 'email-link';
183
+ /** The second step's method: `email-link` for the email link (its entry is `magic-link`), else the provider id. */
184
+ id: string;
176
185
  label: string;
177
186
  /** Where it goes, masked for display (j***@example.com). */
178
187
  target: string;
@@ -453,13 +462,47 @@ export declare function answeredWithPage(mode: ReauthMode): boolean;
453
462
  /**
454
463
  * A step-up asked for and not yet given, kept on the session (#2145): which
455
464
  * permission it was for, where the prompt returns, and whether going there
456
- * does the action again (a page GET) or only brings the person back to it.
465
+ * does the action again (a page GET, or a form POST kept to be redone, #2154)
466
+ * or only brings the person back to it.
457
467
  */
458
468
  export interface PendingStepUp {
459
469
  permission: string;
460
470
  next: string;
461
471
  replays: boolean;
472
+ /** The kept form POST the confirmation releases (#2154). */
473
+ replay?: string;
462
474
  }
475
+ /**
476
+ * Where a script's own prompt is (#2193): a page that sent a request by
477
+ * `fetch` and was refused waits on the prompt its refusal named, and sends
478
+ * again only when that prompt, not another tab's, is confirmed.
479
+ */
480
+ export type StepUpPromptState = 'waiting' | 'confirmed' | 'cancelled';
481
+ /** A script's prompt as the session keeps it (#2193): its id and where it is. */
482
+ export interface StepUpPrompt {
483
+ id: string;
484
+ state: StepUpPromptState;
485
+ }
486
+ /** A prompt id as minted (#2193), or null for anything else. */
487
+ export declare function stepUpPromptId(value: unknown): string | null;
488
+ /** Where a fresh sign-in sends the browser to redo a form POST (#2154). */
489
+ export declare const STEP_UP_CONTINUE_PATH = "/auth/reauth/continue";
490
+ /** What the continue page does (#2154): post `fields` to `action` (`back` is the page it came from), or go `back` with nothing redone. */
491
+ export type StepUpReplayAnswer = {
492
+ action: string;
493
+ fields: Array<[string, string]>;
494
+ back: string;
495
+ } | {
496
+ back: string;
497
+ };
498
+ /**
499
+ * A form POST's fields as they can be posted again to give the same body
500
+ * (#2154), or null when they cannot: a file upload, a nested field, a name
501
+ * with brackets. A list goes back as `name[]`, which parses to a list even
502
+ * of one. `_csrf` is left out: the replay carries the session's token. A
503
+ * secret (`SECRET_FIELD`) is never kept, so such a form is null too.
504
+ */
505
+ export declare function replayableFields(req: Request): Array<[string, string]> | null;
463
506
  /** The step-up answer (#1525, #1635), for the caller to send in its own form. */
464
507
  export interface FreshSignInAnswer {
465
508
  /** The refused permission. */
@@ -530,6 +573,12 @@ declare class AuthManager extends BaseManager {
530
573
  * converted to entries when a site still sets only that (#1523).
531
574
  */
532
575
  private readFactorEntries;
576
+ /**
577
+ * #1523: with the `magic-link` entry off or not listed, an enrolled email
578
+ * second factor is no longer asked for. The operator may mean that, but it
579
+ * must not happen silently.
580
+ */
581
+ private warnIfEmailSecondFactorsDropped;
533
582
  /**
534
583
  * The outside OpenID Connect providers (#1743): one `OidcAuthProvider` per
535
584
  * enabled entry of `ngdpbase.auth.oidc.providers`, plus the old
@@ -1129,6 +1178,14 @@ declare class AuthManager extends BaseManager {
1129
1178
  * refused outright: it can never give a fresh factor.
1130
1179
  */
1131
1180
  askForFreshSignIn(req: Request, userContext: unknown, permission: string, mode: ReauthMode): Promise<FreshSignInAnswer>;
1181
+ /**
1182
+ * Where this session's prompt `id` is (#2193): waiting, confirmed or
1183
+ * cancelled, or unknown (another session's, dropped, or not an id). Reads
1184
+ * only, so asking it often changes nothing in the session.
1185
+ */
1186
+ stepUpPromptState(req: Request, id: unknown): StepUpPromptState | 'unknown';
1187
+ /** The prompt's Cancel (#2193): a waiting prompt of this session is cancelled, so its page stops waiting. */
1188
+ cancelStepUpPrompt(req: Request, id: unknown): void;
1132
1189
  /** Record a step-up event: a prompt, a success or a failure (#1525). */
1133
1190
  recordReauth(req: Request, eventType: AuditEventName, result: 'success' | 'failure', permission: string, detail: string): Promise<void>;
1134
1191
  /**
@@ -1141,8 +1198,11 @@ declare class AuthManager extends BaseManager {
1141
1198
  * directly, against the method), and when going there does not redo the
1142
1199
  * action (a form POST, a script's request, a download) the page there says
1143
1200
  * it can be done now (`takeStepUpNotice`).
1201
+ *
1202
+ * #2193: `prompt`, the id a script's refusal named, is confirmed when it is
1203
+ * this session's and still waiting; no other prompt is.
1144
1204
  */
1145
- completeReauth(req: Request, result: AuthenticateResult, method: string, next: string): Promise<SignInRecord | null>;
1205
+ completeReauth(req: Request, result: AuthenticateResult, method: string, next: string, prompt?: unknown): Promise<SignInRecord | null>;
1146
1206
  /**
1147
1207
  * Whether this request's page says "Confirmed — you can do it now" (#2145):
1148
1208
  * the first page the browser opens after a re-authentication that could not
@@ -1150,6 +1210,31 @@ declare class AuthManager extends BaseManager {
1150
1210
  * opened clears it, so it is said once.
1151
1211
  */
1152
1212
  takeStepUpNotice(req: Request): boolean;
1213
+ /** #2154: form POSTs kept for their fresh sign-in, by a random id. In memory: a restart drops them. */
1214
+ private stepUpReplays;
1215
+ /**
1216
+ * Keep a form POST answered with the prompt, to be redone after it
1217
+ * (#2154); its id, or null when it cannot be redone exactly. Only a page's
1218
+ * POST by a signed-in person, to an address on this site. Each prompt keeps
1219
+ * its own, so the same button pressed in two tabs loses neither (#2176); a
1220
+ * session keeps at most `STEP_UP_REPLAYS_PER_SESSION`, an account
1221
+ * `STEP_UP_REPLAYS_PER_ACCOUNT` and the site `STEP_UP_REPLAYS_TOTAL`, a new
1222
+ * prompt dropping the oldest past that, unconfirmed first, and any past its
1223
+ * time. It waits `STEP_UP_REPLAY_WAIT_MS` for the confirmation, which
1224
+ * restarts its clock. A session's end drops its own (`dropStepUpReplays`).
1225
+ */
1226
+ private keepStepUpReplay;
1227
+ /** A session ended (#2176): the form POSTs it kept go with it (`endSession`). */
1228
+ dropStepUpReplays(sessionId: string): void;
1229
+ /**
1230
+ * Take the kept form POST `id` for the continue page (#2154). Single-use:
1231
+ * taken, it is gone, whatever the answer. Another session's or person's is
1232
+ * refused (null); one not confirmed (the prompt's Cancel) or past its time
1233
+ * only goes back, a confirmed one with the note (#2145). Otherwise the page
1234
+ * posts the fields to the same address. A refusal or one past its time is
1235
+ * recorded as a `reauth-failure`; any other past its time is dropped.
1236
+ */
1237
+ takeStepUpReplay(req: Request, id: unknown): Promise<StepUpReplayAnswer | null>;
1153
1238
  /**
1154
1239
  * The one sign-in completion step (#1758): every way a person finishes
1155
1240
  * signing in — a password, a passkey, a second factor, an email link, an
@@ -1256,6 +1341,14 @@ declare class AuthManager extends BaseManager {
1256
1341
  * never satisfies step-up.
1257
1342
  */
1258
1343
  stepUpNeeded(permission: string, signIn: SignInRecord | undefined, roles: readonly string[], delegated: boolean, now?: number, cap?: number): boolean;
1344
+ /**
1345
+ * Whether `signIn` is fresh enough for every step-up permission (#2193): the
1346
+ * window and the level are one for all of them, so a page waiting on its
1347
+ * prompt asks this without naming the permission. With step-up off, every
1348
+ * sign-in is.
1349
+ */
1350
+ signInFresh(signIn: SignInRecord | undefined, roles: readonly string[], delegated: boolean, now?: number, cap?: number): boolean;
1351
+ private freshUnder;
1259
1352
  /**
1260
1353
  * A session's sign-in after a re-authentication (#1525): the new factors
1261
1354
  * join the old, the assessment is redone over all of them, and the sign-in
@@ -1353,11 +1446,28 @@ declare class AuthManager extends BaseManager {
1353
1446
  /** Whether an email link can be a second factor on this site now (#1523): mail and an explicit base-url. */
1354
1447
  emailLinksAvailable(): boolean;
1355
1448
  /**
1356
- * The second factors `username` has enrolled and can use now (#1523). Any
1357
- * enrolled factor works; one that is not truly available (no mail transport)
1358
- * is not offered. Empty means the sign-in is one step, as before.
1449
+ * Whether the email link can be a second factor now (#1523): its entry in
1450
+ * `ngdpbase.auth.factors` (`magic-link`, or its alias `email-link`) listed
1451
+ * and enabled, mail, and an explicit base-url.
1452
+ */
1453
+ emailSecondFactorAvailable(): boolean;
1454
+ /**
1455
+ * The second factors that may follow `first`, in the order they are offered
1456
+ * (#1523; Q2, operator 2026-10-31): every enabled entry of
1457
+ * `ngdpbase.auth.factors` other than the one the sign-in started with, whose
1458
+ * level is known (its provider registered, or the email link). Those that,
1459
+ * with the first step, reach `requiredAal` come first; then by `preference`,
1460
+ * lower first, an entry with none last. Entry ids.
1461
+ */
1462
+ secondFactorOrder(first: Pick<AuthenticateResult, 'provider' | 'factors'>, requiredAal: number): string[];
1463
+ /**
1464
+ * The second factors `username` has enrolled and can use now (#1523), in
1465
+ * `secondFactorOrder` after the pending sign-in's first step; without one,
1466
+ * by `preference`. Only what the second step can run is offered — today the
1467
+ * email link — and one that is not truly available (no mail transport) is
1468
+ * not. Empty means the sign-in is one step, as before.
1359
1469
  */
1360
- secondFactorsFor(username: string): AvailableSecondFactor[];
1470
+ secondFactorsFor(username: string, signIn?: Pick<PendingSignIn, 'first' | 'requiredAal'>): AvailableSecondFactor[];
1361
1471
  /**
1362
1472
  * Whether a successful first step needs a second (#1532, operator
1363
1473
  * 2026-10-22): everyone who arrives with only a password behind them — a