@jwilleke/ngdpbase-types 0.0.0 → 5.18.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 (302) 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 +391 -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 +89 -0
  71. package/lib/src/managers/DatabaseManager.js +236 -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/sqliteLocation.d.ts +17 -0
  158. package/lib/src/providers/sqliteLocation.js +55 -0
  159. package/lib/src/providers/sqliteMigrations.d.ts +48 -0
  160. package/lib/src/providers/sqliteMigrations.js +72 -0
  161. package/lib/src/rendering/githubAlerts.d.ts +22 -0
  162. package/lib/src/rendering/htmlPolicy.d.ts +76 -0
  163. package/lib/src/rendering/markdownConverter.d.ts +73 -0
  164. package/lib/src/security/PolicyDecisionPoint.d.ts +245 -0
  165. package/lib/src/security/PolicyInformationPoint.d.ts +448 -0
  166. package/lib/src/security/pageActions.d.ts +40 -0
  167. package/lib/src/security/permissions.generated.d.ts +78 -0
  168. package/lib/src/types/Asset.d.ts +414 -0
  169. package/lib/src/types/Catalog.d.ts +61 -0
  170. package/lib/src/types/Comment.d.ts +11 -0
  171. package/lib/src/types/Config.d.ts +388 -0
  172. package/lib/src/types/Organization.d.ts +78 -0
  173. package/lib/src/types/OrganizationProvider.d.ts +38 -0
  174. package/lib/src/types/Page.d.ts +220 -0
  175. package/lib/src/types/Person.d.ts +56 -0
  176. package/lib/src/types/PersonProvider.d.ts +25 -0
  177. package/lib/src/types/Policy.d.ts +139 -0
  178. package/lib/src/types/Policy.js +17 -0
  179. package/lib/src/types/Provider.d.ts +810 -0
  180. package/lib/src/types/Role.d.ts +84 -0
  181. package/lib/src/types/RoleProvider.d.ts +35 -0
  182. package/lib/src/types/Schema.d.ts +425 -0
  183. package/lib/src/types/Share.d.ts +172 -0
  184. package/lib/src/types/Share.js +81 -0
  185. package/lib/src/types/User.d.ts +304 -0
  186. package/lib/src/types/Version.d.ts +189 -0
  187. package/lib/src/types/WikiEngine.d.ts +128 -0
  188. package/lib/src/types/express.d.ts +120 -0
  189. package/lib/src/types/express.js +1 -0
  190. package/lib/src/types/guards.d.ts +78 -0
  191. package/lib/src/types/heic-decode.d.ts +16 -0
  192. package/lib/src/types/index.d.ts +19 -0
  193. package/lib/src/types/linkedom.d.ts +77 -0
  194. package/lib/src/types/markdown-it-plugins.d.ts +21 -0
  195. package/lib/src/utils/DeltaStorage.d.ts +118 -0
  196. package/lib/src/utils/LocaleUtils.d.ts +105 -0
  197. package/lib/src/utils/LocaleUtils.js +294 -0
  198. package/lib/src/utils/PageNameMatcher.d.ts +98 -0
  199. package/lib/src/utils/PathPreflight.d.ts +38 -0
  200. package/lib/src/utils/PathPreflight.js +50 -0
  201. package/lib/src/utils/SectionUtils.d.ts +40 -0
  202. package/lib/src/utils/addonConfigLayer.d.ts +144 -0
  203. package/lib/src/utils/addonConfigLayer.js +382 -0
  204. package/lib/src/utils/addonDatabaseRules.d.ts +25 -0
  205. package/lib/src/utils/addonDatabaseRules.js +57 -0
  206. package/lib/src/utils/addonHost.d.ts +51 -0
  207. package/lib/src/utils/addonHost.js +72 -0
  208. package/lib/src/utils/addonInstaller.d.ts +109 -0
  209. package/lib/src/utils/addonLock.d.ts +37 -0
  210. package/lib/src/utils/addonLock.js +48 -0
  211. package/lib/src/utils/addonPageSync.d.ts +45 -0
  212. package/lib/src/utils/addonProvenance.d.ts +48 -0
  213. package/lib/src/utils/addonTarball.d.ts +41 -0
  214. package/lib/src/utils/addonsPathResolver.d.ts +76 -0
  215. package/lib/src/utils/addonsPathResolver.js +129 -0
  216. package/lib/src/utils/assetMetadataTags.d.ts +66 -0
  217. package/lib/src/utils/atomicWrite.d.ts +28 -0
  218. package/lib/src/utils/auditConfigChange.d.ts +57 -0
  219. package/lib/src/utils/auditEventNames.d.ts +50 -0
  220. package/lib/src/utils/auditEventNames.generated.d.ts +163 -0
  221. package/lib/src/utils/auditEventNames.generated.js +168 -0
  222. package/lib/src/utils/auditEventNames.js +49 -0
  223. package/lib/src/utils/auditEvents.d.ts +265 -0
  224. package/lib/src/utils/auditEvents.js +309 -0
  225. package/lib/src/utils/auditRegistry.d.ts +102 -0
  226. package/lib/src/utils/auditRegistry.js +168 -0
  227. package/lib/src/utils/bip39English.d.ts +2 -0
  228. package/lib/src/utils/configEnvKeys.d.ts +68 -0
  229. package/lib/src/utils/configFiles.d.ts +74 -0
  230. package/lib/src/utils/configFiles.js +150 -0
  231. package/lib/src/utils/delegation.d.ts +48 -0
  232. package/lib/src/utils/deriveUsername.d.ts +21 -0
  233. package/lib/src/utils/explainMediaPath.d.ts +123 -0
  234. package/lib/src/utils/formerTitles.d.ts +69 -0
  235. package/lib/src/utils/frontmatterAccess.d.ts +54 -0
  236. package/lib/src/utils/headlessAdminPassword.d.ts +55 -0
  237. package/lib/src/utils/imageTransform.d.ts +52 -0
  238. package/lib/src/utils/instanceEnvSecret.d.ts +51 -0
  239. package/lib/src/utils/jobSlots.d.ts +43 -0
  240. package/lib/src/utils/keywordNormalizer.d.ts +127 -0
  241. package/lib/src/utils/logger.d.ts +70 -0
  242. package/lib/src/utils/logger.js +106 -0
  243. package/lib/src/utils/magicLinkDeviceState.d.ts +95 -0
  244. package/lib/src/utils/managerUtils.d.ts +40 -0
  245. package/lib/src/utils/migrateLegacyPrivateAttachments.d.ts +15 -0
  246. package/lib/src/utils/orgFilename.d.ts +22 -0
  247. package/lib/src/utils/pageFeature.d.ts +27 -0
  248. package/lib/src/utils/pageFrontmatter.d.ts +21 -0
  249. package/lib/src/utils/pageNotes.d.ts +150 -0
  250. package/lib/src/utils/pageTitleRule.d.ts +37 -0
  251. package/lib/src/utils/pageToArticle.d.ts +59 -0
  252. package/lib/src/utils/pageUrl.d.ts +18 -0
  253. package/lib/src/utils/passwordChange.d.ts +12 -0
  254. package/lib/src/utils/passwordHash.d.ts +60 -0
  255. package/lib/src/utils/permissionCatalog.d.ts +52 -0
  256. package/lib/src/utils/pluginFormatters.d.ts +452 -0
  257. package/lib/src/utils/pluginFormatters.js +714 -0
  258. package/lib/src/utils/privateLinkRewrite.d.ts +42 -0
  259. package/lib/src/utils/privateStoreAccess.d.ts +57 -0
  260. package/lib/src/utils/privateStoreAccess.js +65 -0
  261. package/lib/src/utils/privateStoreCatalogs.d.ts +40 -0
  262. package/lib/src/utils/privateStoreCrypto.d.ts +127 -0
  263. package/lib/src/utils/privateStoreDoor.d.ts +181 -0
  264. package/lib/src/utils/privateStoreExport.d.ts +72 -0
  265. package/lib/src/utils/privateStoreFiles.d.ts +120 -0
  266. package/lib/src/utils/privateStoreMeta.d.ts +64 -0
  267. package/lib/src/utils/privateStoreMigrations.d.ts +37 -0
  268. package/lib/src/utils/privateStorePath.d.ts +259 -0
  269. package/lib/src/utils/privateStorePath.js +436 -0
  270. package/lib/src/utils/privateStoreTakeout.d.ts +76 -0
  271. package/lib/src/utils/privateStoreUnlock.d.ts +175 -0
  272. package/lib/src/utils/proxyClaim.d.ts +59 -0
  273. package/lib/src/utils/proxyClaim.js +30 -0
  274. package/lib/src/utils/redactPrivateNames.d.ts +21 -0
  275. package/lib/src/utils/redactPrivateNames.js +89 -0
  276. package/lib/src/utils/redactSecrets.d.ts +58 -0
  277. package/lib/src/utils/redactSecrets.js +171 -0
  278. package/lib/src/utils/renameLinkRewrite.d.ts +112 -0
  279. package/lib/src/utils/roleGrants.d.ts +35 -0
  280. package/lib/src/utils/safeRedirect.d.ts +32 -0
  281. package/lib/src/utils/schedule.d.ts +54 -0
  282. package/lib/src/utils/secretFileMode.d.ts +17 -0
  283. package/lib/src/utils/seededShippedPages.d.ts +45 -0
  284. package/lib/src/utils/sensitiveValues.d.ts +59 -0
  285. package/lib/src/utils/sensitiveValues.js +106 -0
  286. package/lib/src/utils/sessionEnd.d.ts +12 -0
  287. package/lib/src/utils/sessionGeneration.d.ts +24 -0
  288. package/lib/src/utils/sessionIdle.d.ts +41 -0
  289. package/lib/src/utils/sessionLimits.d.ts +68 -0
  290. package/lib/src/utils/shareLockbox.d.ts +64 -0
  291. package/lib/src/utils/sigstoreTrustedRoot.d.ts +33 -0
  292. package/lib/src/utils/sniffMime.d.ts +21 -0
  293. package/lib/src/utils/storeSearchIndex.d.ts +75 -0
  294. package/lib/src/utils/subjectMayDo.d.ts +21 -0
  295. package/lib/src/utils/systemCategoryRules.d.ts +30 -0
  296. package/lib/src/utils/systemCategoryRules.js +41 -0
  297. package/lib/src/utils/userCreateError.d.ts +62 -0
  298. package/lib/src/utils/username.d.ts +53 -0
  299. package/lib/src/utils/vaultUrlRewrite.d.ts +27 -0
  300. package/lib/src/utils/version.d.ts +84 -0
  301. package/lib/src/utils/videoFrame.d.ts +21 -0
  302. package/package.json +54 -3
@@ -0,0 +1,213 @@
1
+ import BaseManager from './BaseManager.js';
2
+ import type { Policy, PolicySubject, PolicyResource } from '../types/Policy.js';
3
+ import { WikiEngine } from '../types/WikiEngine.js';
4
+ /**
5
+ * User context for policy evaluation
6
+ */
7
+ interface UserContext {
8
+ username?: string;
9
+ roles?: string[];
10
+ [key: string]: unknown;
11
+ }
12
+ /**
13
+ * Policy subject definition
14
+ */
15
+ /**
16
+ * What the request knows about the resource beyond its name, supplied by the
17
+ * PIP (#1504): today a page's `system-category`.
18
+ */
19
+ export type ResourceAttributes = Record<string, unknown>;
20
+ /**
21
+ * Access evaluation context
22
+ */
23
+ interface AccessContext {
24
+ pageName: string;
25
+ action: string;
26
+ userContext?: UserContext;
27
+ attributes?: ResourceAttributes;
28
+ }
29
+ /**
30
+ * How each policy resource type matches (#1504). The TYPES are declared in
31
+ * configuration, `ngdpbase.access.resource-types`, and read through
32
+ * ConfigurationManager; how a type matches is code, one matcher per type. A
33
+ * type that is not declared, or that has no matcher here, never matches — a
34
+ * policy naming it decides nothing (docs/access-policies.md).
35
+ */
36
+ export declare const RESOURCE_MATCHERS: Record<string, (pattern: string, pageName: string, attributes?: ResourceAttributes) => boolean>;
37
+ /**
38
+ * The resource types configuration declares (#1504), for the evaluator and the
39
+ * validator alike. When the key is not set at all — a configuration older than
40
+ * it — the matchers' own types apply, so an older site keeps deciding as it
41
+ * did; PolicyEvaluator.initialize() warns.
42
+ */
43
+ export declare function declaredResourceTypes(getProperty: (key: string, defaultValue: unknown) => unknown): Set<string>;
44
+ /**
45
+ * Access evaluation result
46
+ */
47
+ interface EvaluationResult {
48
+ hasDecision: boolean;
49
+ allowed: boolean;
50
+ reason: string;
51
+ policyName: string | null;
52
+ }
53
+ /**
54
+ * PolicyEvaluator - Evaluates access policies against a given context.
55
+ *
56
+ * PolicyEvaluator mimics how JSPWiki uses Java's built-in security framework
57
+ * (java.security) to load and evaluate security policies from a policy file.
58
+ * It evaluates policies in priority order and returns the first matching policy's
59
+ * decision.
60
+ *
61
+ * @class PolicyEvaluator
62
+ * @extends BaseManager
63
+ *
64
+ * @property {ConfigurationManager | null} configManager - Where the policies are read, live (#1431)
65
+ *
66
+ * @see {@link BaseManager} for base functionality
67
+ * @see {@link PolicyDecisionPoint.policies} for how the policies are read
68
+ * @see {@link PolicyInformationPoint} for access control integration
69
+ *
70
+ * @example
71
+ * const evaluator = engine.getManager('PolicyEvaluator');
72
+ * const result = await evaluator.evaluateAccess({
73
+ * pageName: 'Main',
74
+ * action: 'page:read',
75
+ * userContext: { username: 'admin', roles: ['admin'] }
76
+ * });
77
+ * if (result.allowed) console.log('Access granted');
78
+ */
79
+ declare class PolicyEvaluator extends BaseManager {
80
+ private configManager;
81
+ /**
82
+ * The policies in force NOW. Only the PDP interprets them (#1431 step 14b);
83
+ * this evaluator is the PDP's matching engine and asks it for the list, read
84
+ * live — PolicyManager used to hand back a copy taken at boot, so a policy
85
+ * edited in /admin/configuration was not enforced until a restart.
86
+ */
87
+ private policies;
88
+ /**
89
+ * Creates a new PolicyEvaluator instance
90
+ *
91
+ * @constructor
92
+ * @param {WikiEngine} engine - The wiki engine instance
93
+ */
94
+ constructor(engine: WikiEngine);
95
+ /**
96
+ * Initializes the PolicyEvaluator by getting its reference to ConfigurationManager
97
+ *
98
+ * @async
99
+ * @returns {Promise<void>}
100
+ * @throws {Error} If ConfigurationManager is not available
101
+ *
102
+ * @example
103
+ * await evaluator.initialize();
104
+ * console.log('Policy evaluator ready');
105
+ */
106
+ initialize(): Promise<void>;
107
+ /**
108
+ * Evaluates all relevant policies to make an access decision.
109
+ *
110
+ * Policies are evaluated in priority order (highest first). The first matching
111
+ * policy determines the access decision. If no policies match, access is denied.
112
+ *
113
+ * @async
114
+ * @param {AccessContext} context - The context of the access request
115
+ * @returns {Promise<EvaluationResult>} Evaluation result with decision and reason
116
+ *
117
+ * @example
118
+ * const result = await evaluator.evaluateAccess({
119
+ * pageName: 'AdminPanel',
120
+ * action: 'page:edit',
121
+ * userContext: { username: 'user', roles: ['editor'] }
122
+ * });
123
+ * console.log('Allowed:', result.allowed, 'Reason:', result.reason);
124
+ */
125
+ evaluateAccess(context: AccessContext): Promise<EvaluationResult>;
126
+ /**
127
+ * Checks if a single policy matches the given context.
128
+ *
129
+ * A policy matches if ALL of the following conditions are true:
130
+ * - Subject matches (user has required role)
131
+ * - Resource matches (page name matches pattern)
132
+ * - Action matches (action is in policy's action list)
133
+ *
134
+ * @param {Policy} policy - The policy to check
135
+ * @param {AccessContext} context - The access request context
136
+ * @returns {boolean} True if the policy matches, false otherwise
137
+ *
138
+ * @example
139
+ * const matches = evaluator.matches(policy, context);
140
+ * if (matches) console.log('Policy applies to this request');
141
+ */
142
+ matches(policy: Policy, context: AccessContext): boolean;
143
+ /**
144
+ * Check if the user context's roles match the policy's subject requirements.
145
+ *
146
+ * A user matches if:
147
+ * - No subjects specified (applies to everyone), OR
148
+ * - Policy includes "All" role (applies to everyone), OR
149
+ * - User has at least one role matching a policy subject
150
+ *
151
+ * @param {PolicySubject[] | undefined} policySubjects - The subjects array from the policy
152
+ * @param {UserContext | undefined} userContext - The user's context
153
+ * @returns {boolean} True if the user matches the policy subjects
154
+ *
155
+ * @example
156
+ * const matches = evaluator.matchesSubject(
157
+ * [{ type: 'role', value: 'admin' }],
158
+ * { username: 'user', roles: ['admin', 'editor'] }
159
+ * );
160
+ * // matches === true
161
+ */
162
+ matchesSubject(policySubjects: PolicySubject[] | undefined, userContext: UserContext | undefined): boolean;
163
+ /**
164
+ * Checks if the resource matches the policy's resources.
165
+ *
166
+ * Uses glob pattern matching (via micromatch) to check if the page name
167
+ * matches any of the policy's resource patterns.
168
+ *
169
+ * @param {PolicyResource[] | undefined} resources - The resources array from the policy
170
+ * @param {string} pageName - The name of the page being accessed
171
+ * @returns {boolean} True if a resource matches the page
172
+ *
173
+ * @example
174
+ * const matches = evaluator.matchesResource(
175
+ * [{ type: 'page', pattern: 'Admin*' }],
176
+ * 'AdminPanel'
177
+ * );
178
+ * // matches === true
179
+ */
180
+ /**
181
+ * `evaluateAccess` with the subject and the action fixed (#1219) — rule 10's
182
+ * `filter` shape, compiled once and applied to many resources.
183
+ *
184
+ * Policies that cannot match this subject or this action are dropped here,
185
+ * once; the predicate matches resources only, in the same order as
186
+ * `evaluateAccess` so first-match-wins gives the same answer. No log line
187
+ * per call: a listing asks this ~18k times, and the per-policy INFO line
188
+ * `evaluateAccess` writes is right for one decision and wrong for a filter.
189
+ */
190
+ compile(userContext: UserContext | undefined, action: string): (pageName: string, attributes?: ResourceAttributes) => EvaluationResult;
191
+ matchesResource(resources: PolicyResource[] | undefined, pageName: string, attributes?: ResourceAttributes): boolean;
192
+ /**
193
+ * Checks if the action matches the policy's actions.
194
+ *
195
+ * An action matches if:
196
+ * - No actions specified (applies to all actions), OR
197
+ * - Action is in the policy's action list, OR
198
+ * - Policy includes wildcard '*' (matches all actions)
199
+ *
200
+ * @param {string[] | undefined} actions - The actions array from the policy
201
+ * @param {string} action - The action being performed
202
+ * @returns {boolean} True if the action is in the policy's list
203
+ *
204
+ * @example
205
+ * const matches = evaluator.matchesAction(
206
+ * ['page:read', 'page:edit'],
207
+ * 'page:read'
208
+ * );
209
+ * // matches === true
210
+ */
211
+ matchesAction(actions: string[] | undefined, action: string): boolean;
212
+ }
213
+ export default PolicyEvaluator;
@@ -0,0 +1,358 @@
1
+ /**
2
+ * RenderingManager - Handles markdown rendering and macro expansion
3
+ */
4
+ import BaseManager from './BaseManager.js';
5
+ import type MarkupParser from '../parsers/MarkupParser.js';
6
+ import type WikiContext from '../context/WikiContext.js';
7
+ import { WikiEngine } from '../types/WikiEngine.js';
8
+ /**
9
+ * Table parameters
10
+ */
11
+ interface TableParams {
12
+ rowNumber: number;
13
+ style: string;
14
+ dataStyle: string;
15
+ headerStyle: string;
16
+ evenRowStyle: string;
17
+ oddRowStyle: string;
18
+ id?: string;
19
+ isStriped?: boolean;
20
+ }
21
+ /**
22
+ * User context
23
+ */
24
+ interface UserContext {
25
+ username?: string;
26
+ userName?: string;
27
+ displayName?: string;
28
+ [key: string]: unknown;
29
+ }
30
+ /**
31
+ * Request information
32
+ */
33
+ interface RequestInfo {
34
+ [key: string]: unknown;
35
+ }
36
+ /**
37
+ * Link graph structure
38
+ */
39
+ interface LinkGraph {
40
+ [pageName: string]: string[];
41
+ }
42
+ /**
43
+ * RenderingManager - Handles markdown rendering and macro expansion
44
+ *
45
+ * Similar to JSPWiki's RenderingManager, this manager orchestrates the conversion
46
+ * of markdown/wiki markup to HTML. It supports both legacy direct markdown rendering
47
+ * and the advanced MarkupParser with multi-phase processing.
48
+ *
49
+ * Key features:
50
+ * - Pluggable parser system (direct markdown-it vs MarkupParser)
51
+ * - Wiki link parsing and resolution
52
+ * - Link graph building for backlinks/orphaned pages
53
+ * - Plugin and variable expansion integration
54
+ * - Page name matching with plural support
55
+ *
56
+ * @class RenderingManager
57
+ * @extends BaseManager
58
+ *
59
+ * @property {MarkdownConverter|null} converter - markdown-it page converter (#1273)
60
+ * @property {Object} linkGraph - Graph of page links for backlink analysis
61
+ * @property {LinkParser} linkParser - Parser for wiki-style links
62
+ * @property {PageNameMatcher|null} pageNameMatcher - Matcher for page name resolution
63
+ * @property {Object} renderingConfig - Rendering configuration (parser selection, fallback, etc.)
64
+ *
65
+ * @see {@link BaseManager} for base functionality
66
+ * @see {@link MarkupParser} for advanced parsing
67
+ *
68
+ * @example
69
+ * const renderingManager = engine.getManager('RenderingManager');
70
+ * const html = await renderingManager.renderPage('# Hello World', { pageName: 'Main' });
71
+ */
72
+ declare class RenderingManager extends BaseManager {
73
+ private converter;
74
+ private linkGraph;
75
+ private linkParser;
76
+ private pageNameMatcher;
77
+ private renderingConfig;
78
+ private cachedPageNames;
79
+ /**
80
+ * Creates a new RenderingManager instance
81
+ *
82
+ * @constructor
83
+ * @param {WikiEngine} engine - The wiki engine instance
84
+ */
85
+ constructor(engine: WikiEngine);
86
+ /**
87
+ * Initialize the RenderingManager
88
+ *
89
+ * Sets up the markdown converter, link parser, and rendering configuration.
90
+ * Determines whether to use the advanced MarkupParser or the legacy direct converter.
91
+ *
92
+ * @async
93
+ * @param {Object} [config={}] - Configuration object (unused, reads from ConfigurationManager)
94
+ * @returns {Promise<void>}
95
+ *
96
+ * @example
97
+ * await renderingManager.initialize();
98
+ * console.log('RenderingManager ready');
99
+ */
100
+ initialize(config?: Record<string, unknown>): Promise<void>;
101
+ /**
102
+ * Get the MarkupParser instance (for WikiContext integration)
103
+ *
104
+ * Returns the advanced MarkupParser if enabled and initialized, or null
105
+ * if using legacy direct markdown rendering.
106
+ *
107
+ * @returns {MarkupParser|null} MarkupParser instance if available and enabled
108
+ *
109
+ * @example
110
+ * const parser = renderingManager.getParser();
111
+ * if (parser) {
112
+ * const html = await parser.parse(content, options);
113
+ * }
114
+ */
115
+ getParser(): MarkupParser | null;
116
+ /**
117
+ * Load modular rendering configuration from app-default/custom-config.json
118
+ *
119
+ * Reads configuration to determine which parser to use and whether to
120
+ * enable fallback, performance comparison, and debug logging.
121
+ *
122
+ * @private
123
+ * @returns {void}
124
+ */
125
+ loadRenderingConfiguration(): void;
126
+ /**
127
+ * Render markdown content to HTML with MarkupParser integration
128
+ * @param {string} content - Markdown content
129
+ * @param {string} pageName - Current page name
130
+ * @param {object} userContext - User context for authentication variables
131
+ * @param {object} requestInfo - Request information
132
+ * @returns {Promise<string>} Rendered HTML
133
+ */
134
+ renderMarkdown(content: string, pageName: string, userContext?: UserContext | null, requestInfo?: RequestInfo | null): Promise<string>;
135
+ /**
136
+ * Whose stores a `[store/Title]` link on this page resolves in (#1457): the
137
+ * owner of the page the link is written in.
138
+ *
139
+ * A private page carries its owner in its name; a public page's owner is its
140
+ * author. Resolved once per render and never from the reader — rendered HTML
141
+ * is cached and shared, so anything reader-shaped here would leak.
142
+ *
143
+ * The metadata read happens only when the content actually holds a candidate
144
+ * link, so an ordinary page costs one regex. The read has no caller behind
145
+ * it, like the link graph's.
146
+ */
147
+ private resolvePageOwner;
148
+ /**
149
+ * Render content using the advanced MarkupParser system
150
+ * @param {string} content - Content to render
151
+ * @param {string} pageName - Page name
152
+ * @param {object} userContext - User context
153
+ * @param {object} requestInfo - Request information
154
+ * @returns {Promise<string>} Rendered HTML
155
+ */
156
+ renderWithAdvancedParser(content: string, pageName: string, userContext: UserContext | null, requestInfo: RequestInfo | null): Promise<string>;
157
+ /**
158
+ * Render content using the legacy rendering system (backward compatibility)
159
+ * @param {string} content - Content to render
160
+ * @param {string} pageName - Page name
161
+ * @param {object} userContext - User context
162
+ * @param {object} requestInfo - Request information
163
+ * @returns {Promise<string>} Rendered HTML
164
+ */
165
+ renderWithLegacyParser(content: string, pageName: string, userContext: UserContext | null, requestInfo: RequestInfo | null): Promise<string>;
166
+ /**
167
+ * Perform performance comparison between advanced and legacy parsers (modular benchmarking)
168
+ * @param {string} content - Content that was parsed
169
+ * @param {string} pageName - Page name
170
+ * @param {object} userContext - User context
171
+ * @param {object} requestInfo - Request information
172
+ * @param {number} advancedTime - Time taken by advanced parser
173
+ */
174
+ performPerformanceComparison(content: string, pageName: string, userContext: UserContext | null, requestInfo: RequestInfo | null, advancedTime: number): Promise<void>;
175
+ /**
176
+ * Process JSPWiki-style table syntax with styling parameters
177
+ * @param {string} content - Content with JSPWiki table syntax
178
+ * @returns {string} Content with processed tables
179
+ */
180
+ processJSPWikiTables(content: string): string;
181
+ /**
182
+ * Process %%table-striped syntax for theme-based alternating rows
183
+ * @param {string} content - Content with %%table-striped syntax
184
+ * @returns {string} Content with processed tables
185
+ */
186
+ processTableStripedSyntax(content: string): string;
187
+ /**
188
+ * Parse table parameters from JSPWiki Table plugin syntax
189
+ * @param {string} paramString - Parameter string
190
+ * @returns {Object} Parsed parameters
191
+ */
192
+ parseTableParameters(paramString: string): TableParams;
193
+ /**
194
+ * Convert JSPWiki table syntax to markdown table syntax
195
+ * @param {string} tableContent - JSPWiki table content
196
+ * @param {Object} params - Table parameters
197
+ * @returns {string} Markdown table
198
+ */
199
+ convertJSPWikiTableToMarkdown(tableContent: string, params: TableParams): string;
200
+ /**
201
+ * Post-process rendered HTML tables to apply JSPWiki styling
202
+ * @param {string} html - Rendered HTML
203
+ * @returns {string} HTML with styled tables
204
+ */
205
+ postProcessTables(html: string): string;
206
+ /**
207
+ * Generate styled table HTML with CSS
208
+ * @param {Object} metadata - Table styling metadata
209
+ * @returns {string} Styled table opening tag with CSS
210
+ */
211
+ generateStyledTable(metadata: TableParams & {
212
+ id: string;
213
+ isStriped?: boolean;
214
+ }): string;
215
+ /**
216
+ * Expand macros in content
217
+ * @param {string} content - Content with macros
218
+ * @param {string} pageName - Current page name
219
+ * @param {object} userContext - User context for authentication variables
220
+ * @returns {string} Content with expanded macros
221
+ */
222
+ expandMacros(content: string, pageName: string, userContext?: UserContext | null, requestInfo?: RequestInfo | null): Promise<string>;
223
+ /**
224
+ * Expand a single JSPWiki-style system variable
225
+ * @param {string} variable - The variable name (including $)
226
+ * @param {string} pageName - Current page name
227
+ * @param {object} userContext - User context for authentication variables
228
+ * @returns {string} Expanded value
229
+ */
230
+ expandSystemVariable(variable: string, pageName: string, userContext?: UserContext | null): string;
231
+ /**
232
+ * Get total pages count
233
+ * Uses the provider's page cache for an accurate count.
234
+ * After installation, only counts pages from the main pages directory.
235
+ * @returns {number} Number of pages
236
+ */
237
+ getTotalPagesCount(): number;
238
+ /**
239
+ * Get server uptime in seconds
240
+ * @returns {number} Uptime in seconds
241
+ */
242
+ getUptime(): number;
243
+ /**
244
+ * Get application version from package.json
245
+ * @returns {string} Application version
246
+ */
247
+ getApplicationVersion(): string;
248
+ /**
249
+ * Expand JSPWiki-style system variables (legacy method for compatibility)
250
+ * @param {string} content - Content with system variables
251
+ * @returns {string} Content with expanded system variables
252
+ */
253
+ expandSystemVariables(content: string): string;
254
+ /**
255
+ * Format uptime in human-readable format
256
+ * @param {number} seconds - Uptime in seconds
257
+ * @returns {string} Formatted uptime
258
+ */
259
+ formatUptime(seconds: number): string;
260
+ /**
261
+ * Get the base URL for the application
262
+ * @returns {string} Base URL
263
+ */
264
+ getBaseUrl(): string;
265
+ /**
266
+ * Process wiki-style links [PageName]
267
+ * @param {string} content - Content with wiki links
268
+ * @returns {Promise<string>} Content with processed links
269
+ */
270
+ processWikiLinks(content: string): Promise<string>;
271
+ /**
272
+ * Build link graph for referring pages
273
+ */
274
+ buildLinkGraph(): Promise<void>;
275
+ /**
276
+ * Initialize LinkParser with page names and configuration
277
+ */
278
+ initializeLinkParser(): void;
279
+ /**
280
+ * Get link graph
281
+ * @returns {Object} Link graph object
282
+ */
283
+ getLinkGraph(): LinkGraph;
284
+ /**
285
+ * Rebuild link graph (called after page changes)
286
+ */
287
+ rebuildLinkGraph(): Promise<void>;
288
+ /**
289
+ * Update link graph for a single page (incremental update)
290
+ * Much faster than rebuildLinkGraph() for single page saves
291
+ *
292
+ * @param {string} pageName - Name of the page that was modified
293
+ * @param {string} content - New content of the page
294
+ */
295
+ updatePageInLinkGraph(pageName: string, content: string): void;
296
+ /**
297
+ * Add a page name to the cached list (for new pages)
298
+ * @param {string} pageName - Name of the new page
299
+ */
300
+ addPageToCache(pageName: string): void;
301
+ /** #1419: see PageManager.isSharedIndexable. Without a PageManager nothing can be sealed. */
302
+ private isSharedIndexable;
303
+ /**
304
+ * Remove a page from the link graph and cached names (for deleted pages)
305
+ * @param {string} pageName - Name of the deleted page
306
+ */
307
+ removePageFromLinkGraph(pageName: string): void;
308
+ /**
309
+ * Get pages that refer to a specific page
310
+ * @param {string} pageName - Target page name
311
+ * @returns {Array<string>} Array of referring page names
312
+ * @todo
313
+ * SHOULD BE using plugins/referringPagesPlugin.js
314
+ */
315
+ getReferringPages(pageName: string): string[];
316
+ /**
317
+ * Render page preview
318
+ * @param {string} content - Markdown content
319
+ * @param {string} pageName - Page name for context
320
+ * @param {object} userContext - User context for authentication variables
321
+ * @returns {Promise<string>} Rendered HTML preview
322
+ */
323
+ renderPreview(content: string, pageName: string, userContext?: UserContext | null): Promise<string>;
324
+ /**
325
+ * Get current username from user context
326
+ * @param {object} userContext - User context object
327
+ * @returns {string} Username or "Anonymous"
328
+ */
329
+ getUserName(userContext: UserContext | null): string;
330
+ /**
331
+ * Get current login status from user context
332
+ * @param {object} userContext - User context object
333
+ * @returns {string} Login status description
334
+ */
335
+ getLoginStatus(userContext: UserContext | null): string;
336
+ /**
337
+ * Render wiki links (JSPWiki-style links) using LinkParser
338
+ * @param {string} content - Content with wiki links
339
+ * @returns {string} Content with rendered links
340
+ */
341
+ renderWikiLinks(content: string): string;
342
+ /**
343
+ * Render plugins (JSPWiki-style plugins)
344
+ * @param {string} content - Content with plugin syntax
345
+ * @param {string} pageName - Page name for plugin context
346
+ * @returns {string} Content with rendered plugins
347
+ */
348
+ renderPlugins(content: string, pageName: string): Promise<string>;
349
+ /**
350
+ * Converts wiki markup to HTML using the provided WikiContext.
351
+ * This is the main entry point for the rendering pipeline.
352
+ * @param {WikiContext} context The context for the rendering operation.
353
+ * @param {string} content The raw wiki markup to render.
354
+ * @returns {Promise<string>} The rendered HTML.
355
+ */
356
+ textToHTML(context: WikiContext, content: string): Promise<string>;
357
+ }
358
+ export default RenderingManager;