@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,220 @@
1
+ /**
2
+ * BaseAuthProvider — pluggable authentication provider interface.
3
+ *
4
+ * All authentication methods (password, magic link, OAuth, etc.) implement
5
+ * this interface and are registered with AuthManager, which dispatches
6
+ * initiate/verify calls to the appropriate provider.
7
+ *
8
+ * Pattern mirrors BasePageProvider / BaseAttachmentProvider / BaseMediaProvider.
9
+ *
10
+ * @see AuthManager
11
+ * @see PasswordAuthProvider
12
+ * @see MagicLinkAuthProvider
13
+ */
14
+ /**
15
+ * Context passed to initiate() for challenge-based auth flows.
16
+ *
17
+ * Note: providers that emit absolute URLs (magic-link verify links,
18
+ * OAuth callbacks) read the canonical base URL from ConfigurationManager
19
+ * at runtime — callers don't pass it in (#642 Iteration 3).
20
+ */
21
+ export interface AuthInitiateContext {
22
+ /** Email address (magic link) */
23
+ email?: string;
24
+ /** URL to redirect to after successful authentication */
25
+ redirect?: string;
26
+ /**
27
+ * #1022: opaque per-request value identifying the browser that asked for the
28
+ * link, mirrored into an HTTP-only cookie. Stored with the token so the
29
+ * redeeming browser can be compared against the requesting one.
30
+ */
31
+ deviceState?: string;
32
+ /**
33
+ * #1743: the signed-in account an outside identity is being connected to.
34
+ * Absent for a sign-in. A flow started to connect never signs anyone in,
35
+ * and a sign-in flow never connects.
36
+ */
37
+ connectFor?: string;
38
+ }
39
+ /**
40
+ * Credentials passed to verify(). Fields used depend on the provider.
41
+ */
42
+ export interface AuthVerifyCredentials {
43
+ /** Username — used by PasswordAuthProvider */
44
+ username?: string;
45
+ /** Password — used by PasswordAuthProvider */
46
+ password?: string;
47
+ /** One-time token — used by MagicLinkAuthProvider */
48
+ token?: string;
49
+ /** OAuth `state` from the callback — used by OidcAuthProvider */
50
+ state?: string;
51
+ /** The browser-binding value from the caller's cookie (#1022 magic link, #1630 OAuth) */
52
+ deviceState?: string;
53
+ /** A WebAuthn assertion and the single-use challenge it must answer — used by PasskeyAuthProvider (#448). */
54
+ webauthn?: {
55
+ response: unknown;
56
+ expectedChallenge: string;
57
+ };
58
+ }
59
+ /**
60
+ * Identity and authority of a delegated agent token (#946).
61
+ *
62
+ * Roles are deliberately absent: they are resolved live from the user record,
63
+ * so a token never carries a snapshot of authority that could outlive a change
64
+ * to the account.
65
+ */
66
+ export interface ViaToken {
67
+ /** Token record id */
68
+ id: string;
69
+ /** Human-readable token name, used in logs and page provenance */
70
+ name: string;
71
+ /** Scope ceiling this token may act within */
72
+ scopes: string[];
73
+ }
74
+ /**
75
+ * Returned by verify() on success.
76
+ */
77
+ export interface AuthResult {
78
+ /** Username of the authenticated user */
79
+ username: string;
80
+ /**
81
+ * Set by token-based providers (#946, #1048). Lets the caller enforce the
82
+ * token's scope ceiling and stamp page provenance.
83
+ *
84
+ * Declared here rather than read through a cast in AuthManager: the manager
85
+ * always passed this field along, but `AuthResult` did not admit it existed,
86
+ * so a provider that misspelled it or typed `scopes` wrongly still compiled
87
+ * and silently delivered nothing.
88
+ */
89
+ viaToken?: ViaToken;
90
+ /**
91
+ * The assurance level a bearer credential's sign-in reached (#1576), when
92
+ * it says. Roles above it step down for the request, as in a web session.
93
+ * Absent on credentials that carry no sign-in (agent tokens).
94
+ */
95
+ aal?: Aal;
96
+ /**
97
+ * What an outside identity provider said about its own sign-in (#1633), set
98
+ * only by outside sign-in providers. AuthManager reads it and decides what
99
+ * it counts for; a provider never does.
100
+ */
101
+ reported?: ReportedAssurance;
102
+ }
103
+ /**
104
+ * An outside identity provider's `amr` and `acr` (#1633), exactly as its
105
+ * verified ID token carried them: unchecked, so any type. AuthManager keeps
106
+ * only well-formed values (`reportedValues`) and maps them to a level
107
+ * (`outsideLevel`), counting them only for a provider the admin trusts.
108
+ */
109
+ export interface ReportedAssurance {
110
+ amr?: unknown;
111
+ acr?: unknown;
112
+ }
113
+ /**
114
+ * NIST SP 800-63B authenticator assurance level a factor gives on its own (#1523).
115
+ * 0 is "not a factor" — a known device skips a prompt but proves nothing.
116
+ */
117
+ export type Aal = 0 | 1 | 2 | 3;
118
+ /** Phishing resistance, strongest last: `phr`, then `phrh` (hardware) (#1523). */
119
+ export type PhishingResistance = 'phr' | 'phrh';
120
+ /**
121
+ * What a provider gives as a sign-in factor, declared in its code (#1523).
122
+ *
123
+ * Configuration (`ngdpbase.auth.factors`) may lower these, never raise them:
124
+ * the code is the ceiling because the code is what actually checks the
125
+ * credential. Know / have / are and device-boundness are derived from `amr`,
126
+ * so there is one source for them.
127
+ */
128
+ export interface FactorDescription {
129
+ /** RFC 8176 `amr` values, plus the unregistered `email` and `push`. */
130
+ amr: string[];
131
+ aal: Aal;
132
+ acr?: PhishingResistance;
133
+ /** Can start a sign-in, rather than only follow one as an additional factor. */
134
+ primary: boolean;
135
+ }
136
+ /**
137
+ * Interface all authentication providers must implement.
138
+ */
139
+ export interface AuthProvider {
140
+ /** Unique identifier, e.g. 'password', 'magic-link', 'oauth-google' */
141
+ readonly id: string;
142
+ /** Human-readable name shown in admin UIs */
143
+ readonly displayName: string;
144
+ /**
145
+ * What this provider gives as a sign-in factor (#1523). Absent on providers
146
+ * that carry delegated credentials (agent tokens, bearer JWTs): a delegated
147
+ * credential is a scope ceiling, never a factor, and is never offered at
148
+ * sign-in.
149
+ */
150
+ readonly factor?: FactorDescription;
151
+ /** Whether the bearer middleware tries this provider for `Authorization: Bearer` (#946, #1576). */
152
+ readonly acceptsBearer?: boolean;
153
+ /**
154
+ * Initiate a challenge-based auth flow.
155
+ * Called for flows that require a side-effect before verification
156
+ * (e.g. send a magic-link email, start an OAuth redirect).
157
+ * Credential-based providers (password) do not need to implement this.
158
+ */
159
+ initiate?(context: AuthInitiateContext): Promise<void>;
160
+ /**
161
+ * Verify credentials or a token.
162
+ * @returns AuthResult on success, null on failure.
163
+ */
164
+ verify(credentials: AuthVerifyCredentials): Promise<AuthResult | null>;
165
+ /**
166
+ * Consume a single-use token after a session has been created.
167
+ * Only needed for token-based providers (magic link, OAuth).
168
+ */
169
+ /**
170
+ * Consume a single-use token, returning whether this caller consumed it.
171
+ *
172
+ * #1021: callers gate session creation on the return value — a `false` means
173
+ * another request got there first and this one must not establish a session.
174
+ * An implementation that cannot distinguish the two must return `false`
175
+ * rather than `true`, since a wrong `true` re-opens the double-session hole.
176
+ */
177
+ consumeToken?(token: string): boolean;
178
+ /**
179
+ * Begin a redirect-based flow; returns the URL to send the browser to (#1049).
180
+ *
181
+ * Distinct from `initiate()`, which performs a side effect and returns
182
+ * nothing (magic-link sends an email). Here the URL *is* the result.
183
+ *
184
+ * Throws rather than returning a fallback when the flow cannot be started:
185
+ * there is no sensible substitute for "where should the browser go", and an
186
+ * empty string would send it nowhere with no error to explain why.
187
+ *
188
+ * May answer asynchronously: an OpenID Connect provider reads its issuer's
189
+ * discovery document before it knows where to send the browser (#1743).
190
+ */
191
+ startFlow?(context: AuthInitiateContext): string | Promise<string>;
192
+ /**
193
+ * Where the user was headed before this flow began, keyed by the flow's own
194
+ * handle — a magic-link token, an OAuth state nonce (#1049).
195
+ *
196
+ * Must be read BEFORE `consumeToken()`, which deletes the entry.
197
+ *
198
+ * Returns `'/'` rather than throwing when the handle is unknown: losing the
199
+ * destination degrades the landing page, it does not invalidate the sign-in,
200
+ * and failing the login over it would be a worse outcome than the front page.
201
+ */
202
+ getFlowRedirect?(handle: string): string;
203
+ /**
204
+ * The device-state value recorded when this flow was initiated (#1022), or
205
+ * null when the provider does not bind, or the handle predates the feature.
206
+ *
207
+ * Must be read BEFORE `consumeToken()`, which deletes the entry.
208
+ */
209
+ getDeviceState?(handle: string): string | null;
210
+ /**
211
+ * Create the account behind a first-time credential (#1049).
212
+ *
213
+ * Called before `verify()` on flows that provision on first sign-in, because
214
+ * the account must exist before a session can name it.
215
+ *
216
+ * @returns true if an account was created or already existed; false if the
217
+ * handle is unusable — which the caller should treat as a failed sign-in.
218
+ */
219
+ provisionIfNew?(handle: string): Promise<boolean>;
220
+ }
@@ -0,0 +1,140 @@
1
+ import type { WikiEngine } from '../types/WikiEngine.js';
2
+ import type { ProviderInfo } from '../types/Provider.js';
3
+ import BaseProvider from './BaseProvider.js';
4
+ /**
5
+ * Cache statistics structure
6
+ */
7
+ export interface CacheStats {
8
+ /** Number of cache hits */
9
+ hits: number;
10
+ /** Number of cache misses */
11
+ misses: number;
12
+ /** Number of keys in cache */
13
+ keys: number;
14
+ /** Approximate memory usage of keys */
15
+ ksize: number;
16
+ /** Approximate memory usage of values */
17
+ vsize: number;
18
+ /** Number of set operations */
19
+ sets: number;
20
+ /** Number of delete operations */
21
+ deletes: number;
22
+ /** Cache hit rate percentage */
23
+ hitRate: number;
24
+ }
25
+ /**
26
+ * Backup data structure
27
+ */
28
+ export interface BackupData {
29
+ provider: string;
30
+ initialized: boolean;
31
+ timestamp: string;
32
+ [key: string]: unknown;
33
+ }
34
+ /**
35
+ * BaseCacheProvider - Base class for all cache providers
36
+ *
37
+ * Provides the interface that all cache providers must implement.
38
+ * Follows the provider pattern established in AttachmentManager and PageManager.
39
+ *
40
+ * Cache providers implement different storage backends (node-cache, Redis, etc.)
41
+ *
42
+ * @class BaseCacheProvider
43
+ * @abstract
44
+ *
45
+ * @property {WikiEngine} engine - Reference to the wiki engine
46
+ * @property {boolean} initialized - Whether provider has been initialized
47
+ *
48
+ * @see {@link NodeCacheProvider} for in-memory implementation
49
+ * @see {@link RedisCacheProvider} for Redis implementation
50
+ * @see {@link CacheManager} for usage
51
+ */
52
+ declare abstract class BaseCacheProvider extends BaseProvider {
53
+ /**
54
+ * Reference to the wiki engine instance
55
+ */
56
+ protected engine: WikiEngine;
57
+ /**
58
+ * Whether the provider has been initialized
59
+ */
60
+ protected initialized: boolean;
61
+ /**
62
+ * Creates a new cache provider
63
+ *
64
+ * @constructor
65
+ * @param {WikiEngine} engine - The wiki engine instance
66
+ */
67
+ constructor(engine: WikiEngine);
68
+ /**
69
+ * Initialize the cache provider
70
+ * Implementations should load configuration from ConfigurationManager
71
+ * @returns {Promise<void>}
72
+ */
73
+ abstract initialize(): Promise<void>;
74
+ /**
75
+ * Get provider information
76
+ * @returns {ProviderInfo} Provider metadata
77
+ */
78
+ getProviderInfo(): ProviderInfo;
79
+ /**
80
+ * Get a value from the cache
81
+ * @template T
82
+ * @param {string} key - The cache key
83
+ * @returns {Promise<T | undefined>} The cached value or undefined if not found
84
+ */
85
+ abstract get<T = unknown>(key: string): Promise<T | undefined>;
86
+ /**
87
+ * Set a value in the cache
88
+ * @template T
89
+ * @param {string} key - The cache key
90
+ * @param {T} value - The value to cache
91
+ * @param {number} [ttlSec] - Time to live in seconds
92
+ * @returns {Promise<void>}
93
+ */
94
+ abstract set<T = unknown>(key: string, value: T, ttlSec?: number): Promise<void>;
95
+ /**
96
+ * Delete one or more keys from the cache
97
+ * @param {string | string[]} keys - Single key or array of keys to delete
98
+ * @returns {Promise<void>}
99
+ */
100
+ abstract del(keys: string | string[]): Promise<void>;
101
+ /**
102
+ * Clear cache entries
103
+ * @param {string} [pattern] - Optional pattern to match keys (e.g., 'user:*')
104
+ * @returns {Promise<void>}
105
+ */
106
+ abstract clear(pattern?: string): Promise<void>;
107
+ /**
108
+ * Get keys matching a pattern
109
+ * @param {string} [pattern='*'] - Pattern to match (e.g., 'user:*' or '*' for all)
110
+ * @returns {Promise<string[]>} Array of matching keys
111
+ */
112
+ abstract keys(pattern?: string): Promise<string[]>;
113
+ /**
114
+ * Get cache statistics
115
+ * @returns {Promise<CacheStats>} Cache statistics
116
+ */
117
+ abstract stats(): Promise<CacheStats>;
118
+ /**
119
+ * Check if the cache provider is healthy/connected
120
+ * @returns {Promise<boolean>} True if healthy
121
+ */
122
+ abstract isHealthy(): Promise<boolean>;
123
+ /**
124
+ * Close/cleanup the cache provider
125
+ * @returns {Promise<void>}
126
+ */
127
+ abstract close(): Promise<void>;
128
+ /**
129
+ * Backup cache configuration and state (optional)
130
+ * @returns {Promise<BackupData>} Backup data
131
+ */
132
+ backup(): Promise<BackupData>;
133
+ /**
134
+ * Restore cache from backup (optional)
135
+ * @param {BackupData} _backupData - Backup data
136
+ * @returns {Promise<void>}
137
+ */
138
+ restore(_backupData: BackupData): Promise<void>;
139
+ }
140
+ export default BaseCacheProvider;
@@ -0,0 +1,84 @@
1
+ /**
2
+ * The credentials store (#1524): an account's ways in beyond its password.
3
+ *
4
+ * Passwords stay on the user record and are never copied here (decided
5
+ * 2026-10-02). This store holds passkeys, verified email / phone addresses
6
+ * and known devices (TOTP seeds once #421 is built) — one row each, many per
7
+ * account.
8
+ *
9
+ * Every row is signed with `NGDPBASE_CREDENTIALS_KEY` (the instance `.env`).
10
+ * A row that does not verify is never returned: a planted row is ignored, and
11
+ * reported through `onRejected` so the owner of the store raises the alert.
12
+ *
13
+ * AuthManager is the only door; nothing else reads or writes a provider.
14
+ */
15
+ import BaseProvider from './BaseProvider.js';
16
+ /** The environment variable holding the signing and encryption key. */
17
+ export declare const CREDENTIALS_KEY_ENV = "NGDPBASE_CREDENTIALS_KEY";
18
+ /**
19
+ * `identity` (#1743): an outside OpenID Connect identity connected to the
20
+ * account — subject `${iss}#${sub}`, label the provider's name, secret the
21
+ * provider's verified email ('' when none).
22
+ *
23
+ * `proxy` (#1762): a proxy grant — the row's `username` is the person
24
+ * represented, `subject` the grant id, `secret` the grant's terms as JSON
25
+ * (whom it is for, the permissions, who made it, when it ends). Never a way
26
+ * in; AuthManager reads and writes it only through its proxy-grant methods.
27
+ */
28
+ export type CredentialKind = 'passkey' | 'totp' | 'email' | 'sms' | 'device' | 'identity' | 'proxy';
29
+ export declare const CREDENTIAL_KINDS: readonly CredentialKind[];
30
+ /** One credential, as stored. */
31
+ export interface CredentialRecord {
32
+ id: string;
33
+ username: string;
34
+ kind: CredentialKind;
35
+ /** What identifies it within its kind: a passkey's credential id, an address, a device token's hash, an outside identity's `iss#sub`. */
36
+ subject: string;
37
+ /** Kind-specific: a public key and counter, or empty (an encrypted TOTP seed once #421 is built). */
38
+ secret: string;
39
+ /** What the person calls it — "Jim's iPhone". */
40
+ label: string;
41
+ /** RFC 3339 with offset. */
42
+ createdAt: string;
43
+ lastUsedAt?: string;
44
+ }
45
+ /** Why a stored row was refused. */
46
+ export interface RejectedCredential {
47
+ /** What could be read of it — never trusted, only reported. */
48
+ row: Partial<CredentialRecord>;
49
+ reason: 'bad-signature' | 'unsigned' | 'malformed';
50
+ }
51
+ declare abstract class BaseCredentialsProvider extends BaseProvider {
52
+ /**
53
+ * Load the store. Rows that fail verification sign no one in and are
54
+ * reported; they are kept, unchanged, in quarantine (#1633) so a lost or
55
+ * changed key does not destroy them on the next write.
56
+ */
57
+ abstract initialize(onRejected: (rejected: RejectedCredential[]) => void): Promise<void>;
58
+ /** Rows held in quarantine because they failed verification (#1633). */
59
+ abstract quarantined(): RejectedCredential[];
60
+ /**
61
+ * Re-sign every quarantined row that is well formed under the current key
62
+ * and trust it again (#1633). Malformed rows, and rows that would duplicate a
63
+ * trusted credential, stay quarantined. Returns the rows now trusted.
64
+ */
65
+ abstract retrustQuarantined(): Promise<CredentialRecord[]>;
66
+ /** A person's verified credentials, oldest first. */
67
+ abstract list(username: string): CredentialRecord[];
68
+ abstract get(id: string): CredentialRecord | null;
69
+ /** Every verified row of one kind, whoever's, oldest first (#1762: the grants naming a person as proxy). */
70
+ abstract listKind(kind: CredentialKind): CredentialRecord[];
71
+ /** Add a row; refuses a second row with the same kind and subject. */
72
+ abstract add(record: CredentialRecord): Promise<void>;
73
+ /** Remove a row; returns whether it existed. */
74
+ abstract remove(id: string): Promise<boolean>;
75
+ /** The row with this kind and subject, which are unique together; null when none. */
76
+ abstract findBySubject(kind: CredentialKind, subject: string): CredentialRecord | null;
77
+ /** Record that a credential was just used, and its new secret when that changes (a passkey's counter). */
78
+ abstract touch(id: string, at: string, secret?: string): Promise<void>;
79
+ /** Change a row's display name; the row is re-signed. False when there is no such row. */
80
+ abstract relabel(id: string, label: string): Promise<boolean>;
81
+ /** Where it is kept, for the admin view. */
82
+ abstract location(): string;
83
+ }
84
+ export default BaseCredentialsProvider;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The application database (#1536): the one connection the row-storing
3
+ * providers share. A database provider opens it under its key, runs the
4
+ * migration ledger, answers for its integrity and closes it.
5
+ * `DatabaseManager` is the only door to it — nothing else opens a handle.
6
+ *
7
+ * Ported from yourPHR (yourphr#617), where it is in production.
8
+ */
9
+ import BaseProvider from './BaseProvider.js';
10
+ declare abstract class BaseDatabaseProvider<Handle = unknown> extends BaseProvider {
11
+ /** The open, migrated connection, for the providers built over it. */
12
+ abstract get handle(): Handle;
13
+ abstract integrityOk(): boolean;
14
+ /** Where the data lives and how big it is. */
15
+ abstract storage(): {
16
+ location: string;
17
+ sizeBytes: number;
18
+ encrypted: boolean;
19
+ };
20
+ abstract close(): void;
21
+ }
22
+ export default BaseDatabaseProvider;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The application database (#1536): the one connection the row-storing
3
+ * providers share. A database provider opens it under its key, runs the
4
+ * migration ledger, answers for its integrity and closes it.
5
+ * `DatabaseManager` is the only door to it — nothing else opens a handle.
6
+ *
7
+ * Ported from yourPHR (yourphr#617), where it is in production.
8
+ */
9
+ import BaseProvider from './BaseProvider.js';
10
+ class BaseDatabaseProvider extends BaseProvider {
11
+ }
12
+ export default BaseDatabaseProvider;
@@ -0,0 +1,68 @@
1
+ /**
2
+ * BaseLoggingProvider - Base class for all logging providers (Issue #169)
3
+ *
4
+ * Encapsulates winston transport + format construction behind the provider
5
+ * pattern, consistent with the Base*Provider family
6
+ * (Search/Audit/Cache/Page/User/...).
7
+ *
8
+ * IMPORTANT — deliberate deviation from the engine-based provider pattern:
9
+ * the logger is bootstrapped at module load (`src/utils/logger.ts`), long
10
+ * before the WikiEngine or ConfigurationManager exist, and is imported by
11
+ * virtually every module (including ConfigurationManager itself). A logging
12
+ * provider therefore CANNOT take an engine or read ConfigurationManager in a
13
+ * constructor/initialize() — doing so would create a bootstrap cycle. It is a
14
+ * pure, dependency-free transport/format factory. Provider *selection* happens
15
+ * later in `WikiEngine.initialize()` once config is resolved.
16
+ *
17
+ * @class BaseLoggingProvider
18
+ * @abstract
19
+ *
20
+ * @see {@link FileLoggingProvider} for the default file+console implementation
21
+ * @see {@link module:logger} for usage / selection
22
+ */
23
+ import type Transport from 'winston-transport';
24
+ import type { Logform } from 'winston';
25
+ import BaseProvider from './BaseProvider.js';
26
+ /**
27
+ * Logger configuration passed to a provider when (re)building transports.
28
+ * Mirrors {@link module:logger.LoggerConfig}.
29
+ */
30
+ export interface LoggingProviderConfig {
31
+ /** Log level (error, warn, info, debug) */
32
+ level?: string;
33
+ /** Log directory path — file transport is only added when this is set */
34
+ dir?: string;
35
+ /** Max log file size in bytes or string form (e.g. '1MB') */
36
+ maxSize?: number | string;
37
+ /** Max number of rotated log files */
38
+ maxFiles?: number;
39
+ }
40
+ /** Provider metadata, consistent with the other Base*Provider classes */
41
+ export interface LoggingProviderInfo {
42
+ name: string;
43
+ version: string;
44
+ description: string;
45
+ features: string[];
46
+ }
47
+ declare abstract class BaseLoggingProvider extends BaseProvider {
48
+ /**
49
+ * Build the winston transports for the given configuration.
50
+ *
51
+ * @param config - Resolved logger configuration
52
+ * @returns Array of winston transport instances
53
+ * @abstract
54
+ */
55
+ abstract createTransports(config: LoggingProviderConfig): Transport[];
56
+ /**
57
+ * Build the winston log format. Default is a timestamped single-line
58
+ * `printf`. Subclasses may override for structured/JSON output.
59
+ *
60
+ * @returns winston format
61
+ */
62
+ abstract createFormat(): Logform.Format;
63
+ /**
64
+ * Provider metadata.
65
+ */
66
+ getProviderInfo(): LoggingProviderInfo;
67
+ }
68
+ export default BaseLoggingProvider;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * BaseLoggingProvider - Base class for all logging providers (Issue #169)
3
+ *
4
+ * Encapsulates winston transport + format construction behind the provider
5
+ * pattern, consistent with the Base*Provider family
6
+ * (Search/Audit/Cache/Page/User/...).
7
+ *
8
+ * IMPORTANT — deliberate deviation from the engine-based provider pattern:
9
+ * the logger is bootstrapped at module load (`src/utils/logger.ts`), long
10
+ * before the WikiEngine or ConfigurationManager exist, and is imported by
11
+ * virtually every module (including ConfigurationManager itself). A logging
12
+ * provider therefore CANNOT take an engine or read ConfigurationManager in a
13
+ * constructor/initialize() — doing so would create a bootstrap cycle. It is a
14
+ * pure, dependency-free transport/format factory. Provider *selection* happens
15
+ * later in `WikiEngine.initialize()` once config is resolved.
16
+ *
17
+ * @class BaseLoggingProvider
18
+ * @abstract
19
+ *
20
+ * @see {@link FileLoggingProvider} for the default file+console implementation
21
+ * @see {@link module:logger} for usage / selection
22
+ */
23
+ import BaseProvider from './BaseProvider.js';
24
+ class BaseLoggingProvider extends BaseProvider {
25
+ /**
26
+ * Provider metadata.
27
+ */
28
+ getProviderInfo() {
29
+ return {
30
+ name: 'BaseLoggingProvider',
31
+ version: '1.0.0',
32
+ description: 'Base logging provider interface',
33
+ features: []
34
+ };
35
+ }
36
+ }
37
+ export default BaseLoggingProvider;