@jwilleke/ngdpbase-types 0.0.0 → 5.19.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.
Files changed (304) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +16 -2
  3. package/lib/packages/ngdpbase-types/index.d.ts +32 -0
  4. package/lib/packages/ngdpbase-types/testing.d.ts +43 -0
  5. package/lib/packages/ngdpbase-types/testing.js +53 -0
  6. package/lib/src/cache/CacheDependencies.d.ts +50 -0
  7. package/lib/src/cache/CacheDependencies.js +50 -0
  8. package/lib/src/cache/ICacheAdapter.d.ts +86 -0
  9. package/lib/src/cache/RegionCache.d.ts +171 -0
  10. package/lib/src/context/ActorContext.d.ts +48 -0
  11. package/lib/src/context/ActorContext.js +33 -0
  12. package/lib/src/context/ApiContext.d.ts +194 -0
  13. package/lib/src/context/ApiContext.js +273 -0
  14. package/lib/src/context/BaseContext.d.ts +110 -0
  15. package/lib/src/context/BaseContext.js +143 -0
  16. package/lib/src/context/JobContext.d.ts +153 -0
  17. package/lib/src/context/JobContext.js +144 -0
  18. package/lib/src/context/WikiContext.d.ts +404 -0
  19. package/lib/src/context/bootActions.d.ts +64 -0
  20. package/lib/src/context/bootActions.js +111 -0
  21. package/lib/src/converters/HtmlConverter.d.ts +70 -0
  22. package/lib/src/converters/IContentConverter.d.ts +94 -0
  23. package/lib/src/converters/JSPWikiConverter.d.ts +117 -0
  24. package/lib/src/converters/conversionWarning.d.ts +15 -0
  25. package/lib/src/converters/ncm/bridge.d.ts +22 -0
  26. package/lib/src/converters/ncm/existing.d.ts +23 -0
  27. package/lib/src/converters/ncm/fix/blocks.d.ts +89 -0
  28. package/lib/src/converters/ncm/fix/bulletMarkers.d.ts +21 -0
  29. package/lib/src/converters/ncm/fix/index.d.ts +36 -0
  30. package/lib/src/converters/ncm/fix/jspwikiBullets.d.ts +20 -0
  31. package/lib/src/converters/ncm/fix/jspwikiCodeMarkers.d.ts +38 -0
  32. package/lib/src/converters/ncm/fix/jspwikiHeadings.d.ts +25 -0
  33. package/lib/src/converters/ncm/fix/jspwikiIndent.d.ts +24 -0
  34. package/lib/src/converters/ncm/fix/jspwikiInsert.d.ts +21 -0
  35. package/lib/src/converters/ncm/fix/jspwikiItalic.d.ts +29 -0
  36. package/lib/src/converters/ncm/fix/jspwikiLinkLeftovers.d.ts +27 -0
  37. package/lib/src/converters/ncm/fix/moreInformationFooter.d.ts +25 -0
  38. package/lib/src/converters/ncm/fix/styleClosers.d.ts +25 -0
  39. package/lib/src/converters/ncm/fix/tightenLists.d.ts +30 -0
  40. package/lib/src/converters/ncm/fix/types.d.ts +33 -0
  41. package/lib/src/converters/ncm/footnotes.d.ts +39 -0
  42. package/lib/src/converters/ncm/images.d.ts +49 -0
  43. package/lib/src/converters/ncm/index.d.ts +20 -0
  44. package/lib/src/converters/ncm/links.d.ts +21 -0
  45. package/lib/src/converters/ncm/normalize.d.ts +39 -0
  46. package/lib/src/converters/ncm/placeholder.d.ts +25 -0
  47. package/lib/src/converters/ncm/tables.d.ts +36 -0
  48. package/lib/src/converters/ncm/types.d.ts +42 -0
  49. package/lib/src/http/egressPolicy.d.ts +52 -0
  50. package/lib/src/http/guardedFetch.d.ts +89 -0
  51. package/lib/src/http/guardedFetch.js +113 -0
  52. package/lib/src/http/guardedLookup.d.ts +48 -0
  53. package/lib/src/http/guardedLookup.js +73 -0
  54. package/lib/src/http/ssrf.d.ts +83 -0
  55. package/lib/src/http/ssrf.js +311 -0
  56. package/lib/src/mail/MailProvider.d.ts +36 -0
  57. package/lib/src/mail/NodemailerMailProvider.d.ts +26 -0
  58. package/lib/src/managers/AddonsManager.d.ts +691 -0
  59. package/lib/src/managers/AgentTokenManager.d.ts +269 -0
  60. package/lib/src/managers/AssetManager.d.ts +116 -0
  61. package/lib/src/managers/AttachmentManager.d.ts +1032 -0
  62. package/lib/src/managers/AuthManager.d.ts +1257 -0
  63. package/lib/src/managers/BackgroundJobManager.d.ts +434 -0
  64. package/lib/src/managers/BaseManager.d.ts +427 -0
  65. package/lib/src/managers/BaseManager.js +415 -0
  66. package/lib/src/managers/CacheManager.d.ts +159 -0
  67. package/lib/src/managers/CatalogManager.d.ts +235 -0
  68. package/lib/src/managers/CommentManager.d.ts +75 -0
  69. package/lib/src/managers/ConfigurationManager.d.ts +747 -0
  70. package/lib/src/managers/DatabaseManager.d.ts +188 -0
  71. package/lib/src/managers/DatabaseManager.js +590 -0
  72. package/lib/src/managers/EmailManager.d.ts +47 -0
  73. package/lib/src/managers/ExportManager.d.ts +129 -0
  74. package/lib/src/managers/ExportManager.js +420 -0
  75. package/lib/src/managers/FootnoteManager.d.ts +118 -0
  76. package/lib/src/managers/MediaManager.d.ts +279 -0
  77. package/lib/src/managers/MetricsManager.d.ts +89 -0
  78. package/lib/src/managers/NotificationManager.d.ts +165 -0
  79. package/lib/src/managers/OidcManager.d.ts +210 -0
  80. package/lib/src/managers/OrganizationManager.d.ts +107 -0
  81. package/lib/src/managers/PageManager.d.ts +1645 -0
  82. package/lib/src/managers/PersonManager.d.ts +48 -0
  83. package/lib/src/managers/PluginManager.d.ts +179 -0
  84. package/lib/src/managers/PluginManager.js +393 -0
  85. package/lib/src/managers/PolicyEvaluator.d.ts +213 -0
  86. package/lib/src/managers/RenderingManager.d.ts +358 -0
  87. package/lib/src/managers/RoleManager.d.ts +134 -0
  88. package/lib/src/managers/SearchManager.d.ts +402 -0
  89. package/lib/src/managers/ShareManager.d.ts +251 -0
  90. package/lib/src/managers/TemplateManager.d.ts +176 -0
  91. package/lib/src/managers/ThemeManager.d.ts +56 -0
  92. package/lib/src/managers/UserManager.d.ts +480 -0
  93. package/lib/src/managers/ValidationManager.d.ts +426 -0
  94. package/lib/src/managers/VariableManager.d.ts +145 -0
  95. package/lib/src/middleware/csrf.d.ts +3 -0
  96. package/lib/src/parsers/LinkParser.d.ts +457 -0
  97. package/lib/src/parsers/MarkupParser.d.ts +769 -0
  98. package/lib/src/parsers/context/ParseContext.d.ts +314 -0
  99. package/lib/src/parsers/data/emoji-map.d.ts +18 -0
  100. package/lib/src/parsers/dom/DOMBuilder.d.ts +210 -0
  101. package/lib/src/parsers/dom/DOMParser.d.ts +252 -0
  102. package/lib/src/parsers/dom/Tokenizer.d.ts +358 -0
  103. package/lib/src/parsers/dom/WikiDocument.d.ts +272 -0
  104. package/lib/src/parsers/dom/handlers/DOMLinkHandler.d.ts +260 -0
  105. package/lib/src/parsers/dom/handlers/DOMPluginHandler.d.ts +212 -0
  106. package/lib/src/parsers/dom/handlers/DOMVariableHandler.d.ts +171 -0
  107. package/lib/src/parsers/filters/BaseFilter.d.ts +269 -0
  108. package/lib/src/parsers/filters/FilterChain.d.ts +320 -0
  109. package/lib/src/parsers/handlers/BaseSyntaxHandler.d.ts +331 -0
  110. package/lib/src/parsers/handlers/HandlerRegistry.d.ts +225 -0
  111. package/lib/src/parsers/handlers/JSPWikiPreprocessor.d.ts +89 -0
  112. package/lib/src/parsers/handlers/LinkParserHandler.d.ts +80 -0
  113. package/lib/src/parsers/handlers/PluginSyntaxHandler.d.ts +78 -0
  114. package/lib/src/parsers/handlers/WikiFormHandler.d.ts +149 -0
  115. package/lib/src/parsers/handlers/WikiTagHandler.d.ts +125 -0
  116. package/lib/src/parsers/jspwikiTableRow.d.ts +39 -0
  117. package/lib/src/parsers/styleBlockSyntax.d.ts +14 -0
  118. package/lib/src/plugins/types.d.ts +79 -0
  119. package/lib/src/providers/AgentTokenAuthProvider.d.ts +40 -0
  120. package/lib/src/providers/AuthentikBearerAuthProvider.d.ts +75 -0
  121. package/lib/src/providers/BaseAttachmentProvider.d.ts +197 -0
  122. package/lib/src/providers/BaseAuthProvider.d.ts +220 -0
  123. package/lib/src/providers/BaseCacheProvider.d.ts +140 -0
  124. package/lib/src/providers/BaseCredentialsProvider.d.ts +84 -0
  125. package/lib/src/providers/BaseDatabaseProvider.d.ts +22 -0
  126. package/lib/src/providers/BaseDatabaseProvider.js +12 -0
  127. package/lib/src/providers/BaseLoggingProvider.d.ts +68 -0
  128. package/lib/src/providers/BaseLoggingProvider.js +37 -0
  129. package/lib/src/providers/BaseMediaProvider.d.ts +308 -0
  130. package/lib/src/providers/BasePageProvider.d.ts +337 -0
  131. package/lib/src/providers/BaseProvider.d.ts +98 -0
  132. package/lib/src/providers/BaseProvider.js +74 -0
  133. package/lib/src/providers/BaseSearchProvider.d.ts +362 -0
  134. package/lib/src/providers/BasicAttachmentProvider.d.ts +599 -0
  135. package/lib/src/providers/CloudflareAccessAuthProvider.d.ts +72 -0
  136. package/lib/src/providers/FileCredentialsProvider.d.ts +33 -0
  137. package/lib/src/providers/FileJobStateProvider.d.ts +58 -0
  138. package/lib/src/providers/FileLoggingProvider.d.ts +43 -0
  139. package/lib/src/providers/FileLoggingProvider.js +120 -0
  140. package/lib/src/providers/FileOidcAdapter.d.ts +25 -0
  141. package/lib/src/providers/FileSystemMediaProvider.d.ts +403 -0
  142. package/lib/src/providers/LunrSearchProvider.d.ts +280 -0
  143. package/lib/src/providers/MagicLinkAuthProvider.d.ts +125 -0
  144. package/lib/src/providers/NullCacheProvider.d.ts +72 -0
  145. package/lib/src/providers/OidcAuthProvider.d.ts +180 -0
  146. package/lib/src/providers/OidcBearerAuthProvider.d.ts +30 -0
  147. package/lib/src/providers/PasskeyAuthProvider.d.ts +58 -0
  148. package/lib/src/providers/PasswordAuthProvider.d.ts +20 -0
  149. package/lib/src/providers/SqliteDatabaseProvider.d.ts +55 -0
  150. package/lib/src/providers/SqliteDatabaseProvider.js +90 -0
  151. package/lib/src/providers/SqliteJobStateProvider.d.ts +41 -0
  152. package/lib/src/providers/databaseMigrations.d.ts +8 -0
  153. package/lib/src/providers/databaseMigrations.js +47 -0
  154. package/lib/src/providers/jobState.d.ts +99 -0
  155. package/lib/src/providers/lunrQueryToMiniSearch.d.ts +32 -0
  156. package/lib/src/providers/mediaFilenameDate.d.ts +22 -0
  157. package/lib/src/providers/sqliteBackup.d.ts +128 -0
  158. package/lib/src/providers/sqliteBackup.js +365 -0
  159. package/lib/src/providers/sqliteLocation.d.ts +17 -0
  160. package/lib/src/providers/sqliteLocation.js +55 -0
  161. package/lib/src/providers/sqliteMigrations.d.ts +48 -0
  162. package/lib/src/providers/sqliteMigrations.js +72 -0
  163. package/lib/src/rendering/githubAlerts.d.ts +22 -0
  164. package/lib/src/rendering/htmlPolicy.d.ts +76 -0
  165. package/lib/src/rendering/markdownConverter.d.ts +73 -0
  166. package/lib/src/security/PolicyDecisionPoint.d.ts +245 -0
  167. package/lib/src/security/PolicyInformationPoint.d.ts +448 -0
  168. package/lib/src/security/pageActions.d.ts +40 -0
  169. package/lib/src/security/permissions.generated.d.ts +78 -0
  170. package/lib/src/types/Asset.d.ts +414 -0
  171. package/lib/src/types/Catalog.d.ts +61 -0
  172. package/lib/src/types/Comment.d.ts +11 -0
  173. package/lib/src/types/Config.d.ts +388 -0
  174. package/lib/src/types/Organization.d.ts +78 -0
  175. package/lib/src/types/OrganizationProvider.d.ts +38 -0
  176. package/lib/src/types/Page.d.ts +220 -0
  177. package/lib/src/types/Person.d.ts +56 -0
  178. package/lib/src/types/PersonProvider.d.ts +25 -0
  179. package/lib/src/types/Policy.d.ts +139 -0
  180. package/lib/src/types/Policy.js +17 -0
  181. package/lib/src/types/Provider.d.ts +810 -0
  182. package/lib/src/types/Role.d.ts +84 -0
  183. package/lib/src/types/RoleProvider.d.ts +35 -0
  184. package/lib/src/types/Schema.d.ts +425 -0
  185. package/lib/src/types/Share.d.ts +172 -0
  186. package/lib/src/types/Share.js +81 -0
  187. package/lib/src/types/User.d.ts +304 -0
  188. package/lib/src/types/Version.d.ts +189 -0
  189. package/lib/src/types/WikiEngine.d.ts +128 -0
  190. package/lib/src/types/express.d.ts +120 -0
  191. package/lib/src/types/express.js +1 -0
  192. package/lib/src/types/guards.d.ts +78 -0
  193. package/lib/src/types/heic-decode.d.ts +16 -0
  194. package/lib/src/types/index.d.ts +19 -0
  195. package/lib/src/types/linkedom.d.ts +77 -0
  196. package/lib/src/types/markdown-it-plugins.d.ts +21 -0
  197. package/lib/src/utils/DeltaStorage.d.ts +118 -0
  198. package/lib/src/utils/LocaleUtils.d.ts +105 -0
  199. package/lib/src/utils/LocaleUtils.js +294 -0
  200. package/lib/src/utils/PageNameMatcher.d.ts +98 -0
  201. package/lib/src/utils/PathPreflight.d.ts +38 -0
  202. package/lib/src/utils/PathPreflight.js +50 -0
  203. package/lib/src/utils/SectionUtils.d.ts +40 -0
  204. package/lib/src/utils/addonConfigLayer.d.ts +144 -0
  205. package/lib/src/utils/addonConfigLayer.js +382 -0
  206. package/lib/src/utils/addonDatabaseRules.d.ts +25 -0
  207. package/lib/src/utils/addonDatabaseRules.js +57 -0
  208. package/lib/src/utils/addonHost.d.ts +51 -0
  209. package/lib/src/utils/addonHost.js +72 -0
  210. package/lib/src/utils/addonInstaller.d.ts +109 -0
  211. package/lib/src/utils/addonLock.d.ts +37 -0
  212. package/lib/src/utils/addonLock.js +48 -0
  213. package/lib/src/utils/addonPageSync.d.ts +45 -0
  214. package/lib/src/utils/addonProvenance.d.ts +48 -0
  215. package/lib/src/utils/addonTarball.d.ts +41 -0
  216. package/lib/src/utils/addonsPathResolver.d.ts +76 -0
  217. package/lib/src/utils/addonsPathResolver.js +129 -0
  218. package/lib/src/utils/assetMetadataTags.d.ts +66 -0
  219. package/lib/src/utils/atomicWrite.d.ts +28 -0
  220. package/lib/src/utils/auditConfigChange.d.ts +57 -0
  221. package/lib/src/utils/auditEventNames.d.ts +50 -0
  222. package/lib/src/utils/auditEventNames.generated.d.ts +169 -0
  223. package/lib/src/utils/auditEventNames.generated.js +174 -0
  224. package/lib/src/utils/auditEventNames.js +49 -0
  225. package/lib/src/utils/auditEvents.d.ts +265 -0
  226. package/lib/src/utils/auditEvents.js +309 -0
  227. package/lib/src/utils/auditRegistry.d.ts +102 -0
  228. package/lib/src/utils/auditRegistry.js +168 -0
  229. package/lib/src/utils/bip39English.d.ts +2 -0
  230. package/lib/src/utils/configEnvKeys.d.ts +68 -0
  231. package/lib/src/utils/configFiles.d.ts +74 -0
  232. package/lib/src/utils/configFiles.js +150 -0
  233. package/lib/src/utils/delegation.d.ts +48 -0
  234. package/lib/src/utils/deriveUsername.d.ts +21 -0
  235. package/lib/src/utils/explainMediaPath.d.ts +123 -0
  236. package/lib/src/utils/formerTitles.d.ts +69 -0
  237. package/lib/src/utils/frontmatterAccess.d.ts +54 -0
  238. package/lib/src/utils/headlessAdminPassword.d.ts +55 -0
  239. package/lib/src/utils/imageTransform.d.ts +52 -0
  240. package/lib/src/utils/instanceEnvSecret.d.ts +51 -0
  241. package/lib/src/utils/jobSlots.d.ts +43 -0
  242. package/lib/src/utils/keywordNormalizer.d.ts +127 -0
  243. package/lib/src/utils/logger.d.ts +70 -0
  244. package/lib/src/utils/logger.js +106 -0
  245. package/lib/src/utils/magicLinkDeviceState.d.ts +95 -0
  246. package/lib/src/utils/managerUtils.d.ts +40 -0
  247. package/lib/src/utils/migrateLegacyPrivateAttachments.d.ts +15 -0
  248. package/lib/src/utils/orgFilename.d.ts +22 -0
  249. package/lib/src/utils/pageFeature.d.ts +27 -0
  250. package/lib/src/utils/pageFrontmatter.d.ts +21 -0
  251. package/lib/src/utils/pageNotes.d.ts +150 -0
  252. package/lib/src/utils/pageTitleRule.d.ts +37 -0
  253. package/lib/src/utils/pageToArticle.d.ts +59 -0
  254. package/lib/src/utils/pageUrl.d.ts +18 -0
  255. package/lib/src/utils/passwordChange.d.ts +12 -0
  256. package/lib/src/utils/passwordHash.d.ts +60 -0
  257. package/lib/src/utils/permissionCatalog.d.ts +52 -0
  258. package/lib/src/utils/pluginFormatters.d.ts +452 -0
  259. package/lib/src/utils/pluginFormatters.js +714 -0
  260. package/lib/src/utils/privateLinkRewrite.d.ts +42 -0
  261. package/lib/src/utils/privateStoreAccess.d.ts +57 -0
  262. package/lib/src/utils/privateStoreAccess.js +65 -0
  263. package/lib/src/utils/privateStoreCatalogs.d.ts +40 -0
  264. package/lib/src/utils/privateStoreCrypto.d.ts +127 -0
  265. package/lib/src/utils/privateStoreDoor.d.ts +181 -0
  266. package/lib/src/utils/privateStoreExport.d.ts +72 -0
  267. package/lib/src/utils/privateStoreFiles.d.ts +120 -0
  268. package/lib/src/utils/privateStoreMeta.d.ts +64 -0
  269. package/lib/src/utils/privateStoreMigrations.d.ts +37 -0
  270. package/lib/src/utils/privateStorePath.d.ts +259 -0
  271. package/lib/src/utils/privateStorePath.js +436 -0
  272. package/lib/src/utils/privateStoreTakeout.d.ts +76 -0
  273. package/lib/src/utils/privateStoreUnlock.d.ts +175 -0
  274. package/lib/src/utils/proxyClaim.d.ts +59 -0
  275. package/lib/src/utils/proxyClaim.js +30 -0
  276. package/lib/src/utils/redactPrivateNames.d.ts +21 -0
  277. package/lib/src/utils/redactPrivateNames.js +89 -0
  278. package/lib/src/utils/redactSecrets.d.ts +58 -0
  279. package/lib/src/utils/redactSecrets.js +171 -0
  280. package/lib/src/utils/renameLinkRewrite.d.ts +112 -0
  281. package/lib/src/utils/roleGrants.d.ts +35 -0
  282. package/lib/src/utils/safeRedirect.d.ts +32 -0
  283. package/lib/src/utils/schedule.d.ts +54 -0
  284. package/lib/src/utils/secretFileMode.d.ts +17 -0
  285. package/lib/src/utils/seededShippedPages.d.ts +45 -0
  286. package/lib/src/utils/sensitiveValues.d.ts +59 -0
  287. package/lib/src/utils/sensitiveValues.js +106 -0
  288. package/lib/src/utils/sessionEnd.d.ts +12 -0
  289. package/lib/src/utils/sessionGeneration.d.ts +24 -0
  290. package/lib/src/utils/sessionIdle.d.ts +41 -0
  291. package/lib/src/utils/sessionLimits.d.ts +68 -0
  292. package/lib/src/utils/shareLockbox.d.ts +64 -0
  293. package/lib/src/utils/sigstoreTrustedRoot.d.ts +33 -0
  294. package/lib/src/utils/sniffMime.d.ts +21 -0
  295. package/lib/src/utils/storeSearchIndex.d.ts +75 -0
  296. package/lib/src/utils/subjectMayDo.d.ts +21 -0
  297. package/lib/src/utils/systemCategoryRules.d.ts +30 -0
  298. package/lib/src/utils/systemCategoryRules.js +41 -0
  299. package/lib/src/utils/userCreateError.d.ts +62 -0
  300. package/lib/src/utils/username.d.ts +53 -0
  301. package/lib/src/utils/vaultUrlRewrite.d.ts +27 -0
  302. package/lib/src/utils/version.d.ts +84 -0
  303. package/lib/src/utils/videoFrame.d.ts +21 -0
  304. package/package.json +54 -3
@@ -0,0 +1,480 @@
1
+ import BaseManager, { BackupData } from './BaseManager.js';
2
+ import { type ActorContext } from '../context/ActorContext.js';
3
+ import { WikiEngine } from '../types/WikiEngine.js';
4
+ import { UserProvider } from '../types/Provider.js';
5
+ import { User, UserPreferences, UserSession } from '../types/User.js';
6
+ import type { ShareGrant } from '../types/Share.js';
7
+ /**
8
+ * The agent token a request arrived with (#946).
9
+ *
10
+ * Declared rather than reached by a cast (#1164). `hasPermission` used to read
11
+ * `viaToken` off a parameter typed `{ username; roles; isAuthenticated }` — a
12
+ * field the declared type did not mention. That is not a detail: the type
13
+ * described a three-field object, so satisfying it by BUILDING one was the
14
+ * obvious thing to do, and any object built that way silently carries no token
15
+ * for the ceiling to find. `AttachmentManager` did exactly that and bypassed
16
+ * the ceiling on the path that looked safe.
17
+ */
18
+ export interface AgentTokenGrant {
19
+ id: string;
20
+ name: string;
21
+ scopes: string[];
22
+ }
23
+ /**
24
+ * A person acting for another under a proxy grant (#1762 slice 2), as a
25
+ * subject carries it. The subject's `username` and `roles` are the person
26
+ * REPRESENTED; this names who is actually acting and under which grant.
27
+ *
28
+ * The PDP re-reads the grant on every decision (`AuthManager.liveProxyGrant`)
29
+ * — nothing here is trusted beyond naming it — and bounds the action by the
30
+ * grant's permissions and by what `actor` holds, live. A proxy is not a
31
+ * delegated credential for step-up: the actor's own fresh sign-in counts, so
32
+ * the subject's `signIn` and `aalCap` are the ACTOR's (the session's).
33
+ *
34
+ * `kind: 'impersonation'` is reserved for #1763 "view as"; nothing admits it
35
+ * yet, so a subject carrying it is refused everywhere.
36
+ */
37
+ export interface ProxyClaim {
38
+ kind: 'proxy' | 'impersonation';
39
+ /** The grant's id in the credentials store. */
40
+ grantId: string;
41
+ /** Who is acting: the grant's proxy. */
42
+ actor: string;
43
+ /** The grant's permissions as the subject was built with them; the live grant must still carry every one. */
44
+ scopes: string[];
45
+ /**
46
+ * The actor's OWN private-store handle (#1762 slice 5): where a key copy
47
+ * opened under this grant is held (`privateStoreUnlock.openKeyCopy`). It
48
+ * reaches only that copy — never the actor's own keys — and only while the
49
+ * copy was opened for this grant and this represented person (`dekFor`).
50
+ */
51
+ keyHandle?: string;
52
+ }
53
+ /**
54
+ * The subject for a check about nobody in particular (#1164).
55
+ *
56
+ * There is one honest reason to hand `hasPermission` a subject you built:
57
+ * asking what an ANONYMOUS visitor may do, where there is no user and no token
58
+ * by definition. Naming it once keeps that case explicit and keeps
59
+ * `check-permission-subject.ts` free to reject every inline literal — an
60
+ * escape hatch nobody can reach by accident.
61
+ */
62
+ export declare const ANONYMOUS_SUBJECT: PermissionSubject;
63
+ /** Config key naming the system principal. Ships as `$NGDPBASE_SYSTEM_USER` — env-owned, bare form (#631). */
64
+ export declare const SYSTEM_PRINCIPAL_KEY = "ngdpbase.system.principal";
65
+ /** Config key listing the roles the system principal holds. Ships as `["admin"]` (#631). */
66
+ export declare const SYSTEM_ROLES_KEY = "ngdpbase.system.roles";
67
+ /**
68
+ * Who a permission check is about.
69
+ *
70
+ * __Forward the context you were given; do not rebuild one.__ `viaToken` is
71
+ * optional because an ordinary session request has none — which means the type
72
+ * cannot force you to carry it. Rebuilding a subject from parts therefore still
73
+ * compiles, and still drops the ceiling. What stops that is
74
+ * `scripts/check-permission-subject.ts`, not the compiler.
75
+ */
76
+ export interface PermissionSubject {
77
+ username: string;
78
+ roles: string[];
79
+ isAuthenticated: boolean;
80
+ /** Present only when the request authenticated with an agent token. */
81
+ viaToken?: AgentTokenGrant;
82
+ /** Present only when the request presented a share token (#1222). Forwarded like `viaToken`. */
83
+ viaShare?: ShareGrant;
84
+ /**
85
+ * Present only when someone is acting for this subject's person under a
86
+ * proxy grant (#1762). Forwarded like `viaToken`; never combined with a
87
+ * token or a share (the PDP refuses a subject carrying both).
88
+ */
89
+ viaProxy?: ProxyClaim;
90
+ /** The address the request came from (#1179) — provenance for the record, set where the request subject is built. */
91
+ ipAddress?: string;
92
+ /**
93
+ * Opaque handle to this session's unlocked private-store keys (#1382).
94
+ * Random — not the session id — created at password login and dropped at
95
+ * logout; resolved live, so after logout it reaches nothing. Set only where
96
+ * the request subject is built; never recorded (`actorOf` must not gain it).
97
+ */
98
+ privateStoreHandle?: string;
99
+ /**
100
+ * How and when this session signed in (#1525, #1635): the factors and when
101
+ * each was last satisfied. Set only where the request subject is built from
102
+ * the session, so the PDP can decide a step-up permission itself — the door
103
+ * decides, not the route in front of it. Never recorded. Under `viaProxy`
104
+ * it is the actor's: the proxy's own fresh sign-in is what counts (#1762).
105
+ */
106
+ signIn?: import('./AuthManager.js').SignInRecord;
107
+ /**
108
+ * The highest level this account's allowed sign-in methods can reach, at
109
+ * least 1 (#1690). A role's required level never exceeds it: an account
110
+ * with no way to reach AAL2 holds its roles at AAL1. Set where the request
111
+ * subject is built, beside `signIn` — under `viaProxy`, the actor's
112
+ * account's cap, since it is the actor who signs in (#1762).
113
+ */
114
+ aalCap?: import('../providers/BaseAuthProvider.js').Aal;
115
+ }
116
+ /**
117
+ * The subject of work with no request behind it (#631, #1212).
118
+ *
119
+ * A job enqueued at 09:00 and run at 09:12 must authorise against 09:12's
120
+ * roles, so it carries who asked and __no roles__ — they resolve at decision
121
+ * time. Until #1212 that shape was "a `PermissionSubject` whose `roles` happen
122
+ * to be absent", which the type could not tell apart from a caller that
123
+ * forgot them. `resolveRolesNow` says it on purpose: the compiler now refuses
124
+ * a subject missing `roles`, and this is the one sanctioned way to ask for
125
+ * live resolution. `viaToken` / `viaShare` / `viaProxy` ride along exactly as on a request.
126
+ */
127
+ export interface JobSubject {
128
+ username: string;
129
+ isAuthenticated: boolean;
130
+ /** Roles are resolved live at decision time, not carried. */
131
+ resolveRolesNow: true;
132
+ viaToken?: AgentTokenGrant;
133
+ viaShare?: ShareGrant;
134
+ viaProxy?: ProxyClaim;
135
+ }
136
+ /**
137
+ * User creation input data
138
+ */
139
+ interface UserCreateInput {
140
+ username: string;
141
+ email: string;
142
+ displayName?: string;
143
+ password: string;
144
+ roles?: string[];
145
+ isExternal?: boolean;
146
+ isActive?: boolean;
147
+ acceptLanguage?: string;
148
+ /** Freeze password/email/displayName against self-service change (#1029). */
149
+ profileLocked?: boolean;
150
+ /** A test account (#1805): attribute only, grants nothing. Default false. */
151
+ isTest?: boolean;
152
+ }
153
+ /**
154
+ * User update input data
155
+ */
156
+ interface UserUpdateInput {
157
+ email?: string;
158
+ displayName?: string;
159
+ password?: string;
160
+ roles?: string[];
161
+ isActive?: boolean;
162
+ isExternal?: boolean;
163
+ /** A test account (#1805); the change is recorded on user-edit. */
164
+ isTest?: boolean;
165
+ preferences?: Partial<UserPreferences>;
166
+ profilePage?: string;
167
+ [key: string]: unknown;
168
+ }
169
+ /**
170
+ * UserManager - Handles user authentication, authorization, and roles
171
+ *
172
+ * Similar to JSPWiki's UserManager with role-based permissions. This manager
173
+ * orchestrates user operations through a pluggable provider system, allowing
174
+ * different storage backends (file, database, LDAP, etc.) to be used.
175
+ *
176
+ * Key responsibilities:
177
+ * - User authentication (login/logout)
178
+ * - Password management with hashing
179
+ * - Role and permission management
180
+ * - Session management
181
+ * - User profile management
182
+ * - Provider abstraction for storage
183
+ *
184
+ * Follows JSPWiki's provider pattern where the actual storage implementation
185
+ * is abstracted behind a provider interface. This allows for different storage
186
+ * backends (file, database, LDAP, etc.) to be swapped via configuration.
187
+ *
188
+ * @class UserManager
189
+ * @extends BaseManager
190
+ *
191
+ * @property {UserProvider|null} provider - The active user storage provider
192
+ * @property {string} providerClass - The class name of the loaded provider
193
+ * @property {Map<string, Role>} roles - Role definitions
194
+ * @property {Map<string, string>} permissions - Permission definitions
195
+ * @property {string} passwordSalt - Salt for password hashing
196
+ * @property {number} sessionExpiration - Session expiration time in milliseconds
197
+ * @property {string} defaultTimezone - Default timezone for users
198
+ *
199
+ * @see {@link BaseManager} for base functionality
200
+ * @see {@link FileUserProvider} for default provider implementation
201
+ *
202
+ * @example
203
+ * const userManager = engine.getManager('UserManager');
204
+ * const ok = await authManager.authenticate('password', { username: 'admin', password: 'password' });
205
+ * if (user) logger.info('Logged in:', user.username);
206
+ */
207
+ declare class UserManager extends BaseManager {
208
+ private provider;
209
+ private providerClass?;
210
+ private passwordSalt?;
211
+ /**
212
+ * Creates a new UserManager instance
213
+ *
214
+ * @constructor
215
+ * @param {WikiEngine} engine - The wiki engine instance
216
+ */
217
+ constructor(engine: WikiEngine);
218
+ /**
219
+ * Initialize the UserManager and load the configured provider
220
+ *
221
+ * Loads the user provider, role definitions, and creates a default admin
222
+ * user if no users exist.
223
+ *
224
+ * @async
225
+ * @param {Record<string, unknown>} [config={}] - Configuration object (unused, reads from ConfigurationManager)
226
+ * @returns {Promise<void>}
227
+ * @throws {Error} If ConfigurationManager is not available or provider fails to load
228
+ *
229
+ * @example
230
+ * await userManager.initialize();
231
+ * // Creates default admin if no users exist
232
+ */
233
+ initialize(config?: Record<string, unknown>): Promise<void>;
234
+ /** An email as accounts are compared on it (#1748): trimmed, any case. No provider rules (Gmail dots, plus addressing, aliases). */
235
+ private static emailKey;
236
+ /** The accounts holding this email, by username. Empty for no email. */
237
+ private accountsWithEmail;
238
+ /**
239
+ * One email, one account (#1748): refuse to save an email another account
240
+ * already has. Not a setting. Thrown as `email-taken`, so registration shows
241
+ * its safe message and other routes their own.
242
+ */
243
+ private assertEmailFree;
244
+ /**
245
+ * Accounts that share an email, saved before #1748 refused it. They are not
246
+ * changed — an admin decides — but they are never silent: the manager is
247
+ * degraded (dashboard, `manager-state-change` audit), the log says which,
248
+ * and admins get a notification. Until resolved, a lookup by that email
249
+ * refuses (see `getUserByEmail`).
250
+ */
251
+ private reportDuplicateEmails;
252
+ /**
253
+ * Normalize provider name from configuration (lowercase) to class name (PascalCase)
254
+ * @param {string} providerName - Provider name from configuration (e.g., 'fileuserprovider')
255
+ * @returns {string} Normalized class name (e.g., 'FileUserProvider')
256
+ * @private
257
+ */
258
+ private normalizeProviderName;
259
+ /**
260
+ * Get the current user provider instance
261
+ * @returns {UserProvider | null} The active provider
262
+ */
263
+ getCurrentUserProvider(): UserProvider | null;
264
+ /**
265
+ * Get provider information
266
+ * @private
267
+ */
268
+ private getProviderInfo;
269
+ /**
270
+ * Hash a password for storage (#1042).
271
+ *
272
+ * scrypt with a per-user random salt. Was one round of SHA-256 with a single
273
+ * instance-wide salt, which is fast to crack offline and made two users with
274
+ * the same password produce identical hashes.
275
+ *
276
+ * @param {string} password - Plain text password
277
+ * @returns {string} Self-describing hash: `scrypt$N$r$p$salt$hash`
278
+ */
279
+ hashPassword(password: string): Promise<string>;
280
+ /**
281
+ * Verify a password against a stored hash, in either scheme (#1042).
282
+ *
283
+ * Pre-#1042 hashes keep verifying against the instance-wide salt — the
284
+ * plaintext is not recoverable, so they cannot be converted in bulk. They are
285
+ * upgraded individually by `PasswordAuthProvider` on the next successful check (#1758).
286
+ *
287
+ * @param {string} password - Plain text password
288
+ * @param {string} hash - Stored hash, either scheme
289
+ * @returns {boolean} True if password matches
290
+ */
291
+ verifyPassword(password: string, hash: string): Promise<boolean>;
292
+ /** The value shipped in config; also the fallback when config is unreadable. */
293
+ private static readonly DEFAULT_BOOTSTRAP_PASSWORD;
294
+ /**
295
+ * Read the bootstrap password for the `admin` account.
296
+ *
297
+ * `ngdpbase.user.security.defaultpassword` ships as `admin123`, so a fresh
298
+ * install comes up unattended and the setup wizard is reachable. An operator
299
+ * who prefers it out of the repository can point the key at an env-ref —
300
+ * `"$NGDPBASE_ADMIN_PASSWORD"` — and a bare ref is strict, so an unset
301
+ * variable stops the boot rather than silently falling back to the default.
302
+ *
303
+ * The literal fallback below covers only a missing or blank config value,
304
+ * which is what an embedder or a partially-mocked test sees. It deliberately
305
+ * matches the shipped default: a caller with no configuration should get the
306
+ * documented account, not an exception.
307
+ */
308
+ private getBootstrapPassword;
309
+ /**
310
+ * Same, but null instead of throwing. For callers that merely want to WARN
311
+ * about the bootstrap password still being in force — an install with no
312
+ * such variable set is the normal case there, not an error.
313
+ */
314
+ private tryGetBootstrapPassword;
315
+ /**
316
+ * Check whether the admin account still has the configured bootstrap
317
+ * password. False when none is configured — there is then no shipped,
318
+ * well-known credential to warn about.
319
+ *
320
+ * @returns {Promise<boolean>} True if admin still has the bootstrap password
321
+ */
322
+ isAdminUsingDefaultPassword(): Promise<boolean>;
323
+ /**
324
+ * The roles an account is made with: those its sign-up path or the admin
325
+ * chose, plus `ngdpbase.user.account-roles`, the roles every account gets
326
+ * (#1539 — `vault-owner`, without which a person's own vaults refuse them).
327
+ */
328
+ private withAccountRoles;
329
+ /** `ngdpbase.user.account-roles`: the roles every account holds (#1539). */
330
+ private accountRoles;
331
+ /**
332
+ * Accounts made before a role joined `ngdpbase.user.account-roles` get it
333
+ * once, at boot (#1539) — RoleManager decides "once" and records each grant.
334
+ */
335
+ private grantAccountRolesToExistingAccounts;
336
+ /**
337
+ * Create the bootstrap admin account.
338
+ *
339
+ * Called only when the user store is empty. The password is
340
+ * `ngdpbase.user.security.defaultpassword`, which ships as `admin123` so a
341
+ * first run needs no setup; a headless install refuses that well-known value
342
+ * (#1087), and startup warns while the admin still uses it. Low first-run
343
+ * friction is a decision: warn, never force (crypto/auth review, 2026-10-05).
344
+ */
345
+ createDefaultAdmin(): Promise<void>;
346
+ /**
347
+ * The stored password hash of an active local account, or null (#1758).
348
+ * The password check is `PasswordAuthProvider`'s, through AuthManager — the
349
+ * one door for every check of a secret; this manager keeps the hash on the
350
+ * account and hands it only to that check. `getUser()` still strips it.
351
+ */
352
+ storedPasswordHash(username: string): Promise<string | null>;
353
+ /**
354
+ * Replace a stored hash with one at the current cost, after a successful
355
+ * check (#1042): the only moment it can be done, since the old digest can't
356
+ * be converted. Called by `PasswordAuthProvider` (#1758).
357
+ */
358
+ upgradePasswordHash(username: string, newHash: string, legacy: boolean): Promise<void>;
359
+ /** Count a completed sign-in on the account: last sign-in and sign-in count (#1758; AuthManager calls it for a sign-in, never a re-check). */
360
+ recordSignIn(username: string): Promise<void>;
361
+ /**
362
+ * Check if a display name conflicts with existing page names or other users
363
+ * @param {string} displayName - Display name to check
364
+ * @param {string | null} excludeUsername - Username to exclude from the check (for updates)
365
+ * @returns {Promise<boolean>} True if conflict exists
366
+ */
367
+ checkDisplayNamePageConflict(displayName: string, excludeUsername?: string | null): Promise<boolean>;
368
+ /**
369
+ * Create a user page for a new user.
370
+ *
371
+ * The page is written AS the new user (#1462): it is their page, and the
372
+ * door takes a new page's author from who is acting. Written as the admin
373
+ * who created the account — or as whoever ran self-registration — the
374
+ * profile would be authored by them, and `author-lock` would leave the
375
+ * account's own owner unable to edit it.
376
+ *
377
+ * @param {User} user - User object
378
+ * @param ctx - Who created the account, for the log line only
379
+ * @returns {Promise<boolean>} True if user page was created successfully
380
+ */
381
+ createUserPage(user: User, ctx: ActorContext): Promise<boolean>;
382
+ /**
383
+ * Who holds which role is RoleManager's (#1431 step 12). An account write
384
+ * that changes roles asks it; it is registered before UserManager, so its
385
+ * absence is a broken engine, not a degraded one.
386
+ */
387
+ private roleManager;
388
+ /** The subject's attributes are the PIP's (#1431 step 13); an account write asks it about names. */
389
+ private policyInformationPoint;
390
+ private auditSink;
391
+ /**
392
+ * Every account write goes through here (#1751): it writes, then bumps the
393
+ * account-data version, so cached renders that show names or decide by
394
+ * roles re-render.
395
+ */
396
+ private writeAccounts;
397
+ /**
398
+ * Create new user
399
+ * @param {UserCreateInput} userData - User data
400
+ * @returns {Promise<Omit<User, 'password'>>} Created user (without password)
401
+ */
402
+ createUser(userData: UserCreateInput, ctx: ActorContext): Promise<Omit<User, 'password'>>;
403
+ /**
404
+ * Update user
405
+ */
406
+ /**
407
+ * A forgotten password, reset with the 12 recovery words (#1452).
408
+ *
409
+ * The words are the account owner's own escrow: they unwrap the key the
410
+ * password used to, so proving them is proving you are the person the key
411
+ * was made for. The password wrap is replaced first — the recovery wrap and
412
+ * the key are unchanged, so every encrypted store still opens — and then the
413
+ * sign-in password is set, through `updateUser`, so the two stay one
414
+ * password and the change is recorded like any other.
415
+ *
416
+ * `false`, changing nothing, for any reason it cannot be done: no such
417
+ * account, an inactive or external one, no keys, or words that do not open
418
+ * them. The caller cannot tell which, so the door cannot be used to learn
419
+ * which accounts exist.
420
+ */
421
+ resetPasswordWithRecoveryWords(username: string, words: string, newPassword: string, ctx: ActorContext): Promise<boolean>;
422
+ updateUser(username: string, updates: UserUpdateInput, ctx: ActorContext): Promise<User>;
423
+ /**
424
+ * Delete user
425
+ */
426
+ deleteUser(username: string, ctx: ActorContext): Promise<boolean>;
427
+ /** Hand the account to AuthManager's one deactivation step (#1765); a failure there is logged, never thrown. */
428
+ private closeAccess;
429
+ getUsers(): Promise<Omit<User, 'password'>[]>;
430
+ getUser(username: string): Promise<Omit<User, 'password'> | undefined>;
431
+ /**
432
+ * Whether the account signs in with a password of its own: a local account
433
+ * whose record carries a hash. Asked here because this is the one door that
434
+ * sees the hash — `getUser()` strips it, which is why AuthManager's
435
+ * last-way-in rule, asking through `getUser()`, saw no password on any
436
+ * account and refused to remove anyone's only passkey (#1524).
437
+ */
438
+ hasPassword(username: string): Promise<boolean>;
439
+ getUserByEmail(email: string): Promise<Omit<User, 'password'> | undefined>;
440
+ /**
441
+ * #658: resolve the recipient address for /contact submissions.
442
+ *
443
+ * 1. Trimmed `recipientOverride` (from `ngdpbase.application.contact.recipient`)
444
+ * if non-empty — used verbatim, may be a list or alias.
445
+ * 2. Else: first user with the `admin` role whose email is non-empty AND
446
+ * not the install-default sentinel `admin@localhost`. The sentinel
447
+ * keeps the contact feature dormant on fresh installs that haven't
448
+ * set a real admin email yet, instead of mailing into a black hole.
449
+ * 3. Else: `null` — caller must render "Contact form is not configured"
450
+ * rather than attempting to send.
451
+ *
452
+ * The returned address is server-side only; never render it to clients.
453
+ */
454
+ getContactRecipient(recipientOverride: string): Promise<string | null>;
455
+ /**
456
+ * Search users by username, displayName, or email (case-insensitive substring).
457
+ * Optionally filter by role and active status.
458
+ */
459
+ searchUsers(query: string, options: {
460
+ role?: string;
461
+ limit?: number;
462
+ activeOnly?: boolean;
463
+ }, ctx: ActorContext): Promise<Omit<User, 'password'>[]>;
464
+ /**
465
+ * Persist a Person record paired with a newly-created User. The install's
466
+ * anchor org (when configured) is referenced via `memberOf`; without it
467
+ * the Person is written without an org link. Failures are logged, not
468
+ * thrown — auth must still succeed if Person storage is degraded.
469
+ */
470
+ private syncPersonOnCreate;
471
+ private syncPersonOnUpdate;
472
+ private syncPersonOnDelete;
473
+ createSession(username: string, additionalData?: Record<string, unknown>): Promise<string>;
474
+ getSession(sessionId: string): Promise<UserSession | null>;
475
+ deleteSession(sessionId: string): Promise<void>;
476
+ deleteUserSessions(username: string): Promise<void>;
477
+ backup(): Promise<BackupData>;
478
+ restore(backupData: BackupData): Promise<void>;
479
+ }
480
+ export default UserManager;