@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,251 @@
1
+ /**
2
+ * ShareManager — share-link capability tokens (#842 slice 1, #852).
3
+ *
4
+ * Issues, validates, revokes, and lists share links: unguessable tokens
5
+ * granting anonymous access to a typed scope of content. Routes (slice 2/3)
6
+ * consume ONLY the narrow issue/validate/revoke/list interface plus
7
+ * resolveScope — never the storage (decision 6 extraction seam).
8
+ *
9
+ * Scope is resolved live at request time, never snapshotted: tagging or
10
+ * untagging content immediately changes what a link exposes.
11
+ *
12
+ * Exclusions (safe by construction — decisions 1 and 3):
13
+ * - content carrying the reserved `owner-only` keyword (media EXIF/XMP
14
+ * keywords and page user-keywords alike)
15
+ * - pages with `private: true`, and media linked to them
16
+ * - pages with `audience` or per-action `access` frontmatter — a share
17
+ * must not silently widen an author's chosen audience
18
+ *
19
+ * Persistence: one JSON file per share under `ngdpbase.share.storagedir`
20
+ * (CommentManager pattern). Revoked shares keep their file for audit;
21
+ * validate() treats unknown, expired, and revoked tokens identically so
22
+ * share existence never leaks.
23
+ *
24
+ * Enabled via config: ngdpbase.share.enabled
25
+ *
26
+ * @see docs/sharing.md — the source of truth for all sharing
27
+ * @see MagicLinkAuthProvider — token-lifecycle prior art
28
+ */
29
+ import BaseManager, { type ManagerStats } from './BaseManager.js';
30
+ import type { WikiEngine } from '../types/WikiEngine.js';
31
+ import type { MediaItem } from '../providers/BaseMediaProvider.js';
32
+ import { OWNER_ONLY_KEYWORD, type ShareRecord, type ShareResource, type ShareScope, type VaultShareScope, type ShareTtl, type SharePageEntry } from '../types/Share.js';
33
+ import { type PermissionSubject } from './UserManager.js';
34
+ import { type ActorContext } from '../context/ActorContext.js';
35
+ import { type LinkPublicKey, type Lockbox } from '../utils/shareLockbox.js';
36
+ export { OWNER_ONLY_KEYWORD };
37
+ /** The most one extension may add to a link's lifetime (operator, 2026-09-29, #1388). */
38
+ export declare const SHARE_EXTEND_MAX_HOURS = 24;
39
+ /** The longest label an owner may give a vault link (#1388). */
40
+ export declare const SHARE_LABEL_MAX = 100;
41
+ /** Live content set a validated share exposes. */
42
+ export interface ResolvedShareScope {
43
+ media: MediaItem[];
44
+ pages: SharePageEntry[];
45
+ }
46
+ export default class ShareManager extends BaseManager {
47
+ private sharesDir;
48
+ private enabled;
49
+ /** token → record (validate path) */
50
+ private byToken;
51
+ /** id → record (management path) */
52
+ private byId;
53
+ /** share id → aggregated anonymous access hits awaiting flush (decision 5) */
54
+ private accessCounts;
55
+ /** How long access counts accumulate before a lazy flush to log + audit. */
56
+ private static readonly ACCESS_FLUSH_MS;
57
+ constructor(engine: WikiEngine);
58
+ initialize(): Promise<void>;
59
+ isEnabled(): boolean;
60
+ /**
61
+ * Issue a new share: a delegation by `issuer` of `actions` over `resources`
62
+ * (#1221, epic #1225).
63
+ *
64
+ * The route asks policy for `share-create` before calling this (#1224, #1638).
65
+ * Here the delegation rule is enforced: __nobody delegates what they do not
66
+ * hold.__ Every action the share would carry is checked against the
67
+ * issuer's live authority through the PDP (`PolicyDecisionPoint.permits`), with the
68
+ * issuer's own context (P1) so a token-bound issuer is bounded by the token
69
+ * ceiling too. A share asking for an action the issuer lacks is refused
70
+ * outright rather than trimmed silently — trimming would issue a credential
71
+ * the issuer did not describe.
72
+ */
73
+ issue(scope: ShareScope, ttl: ShareTtl, issuer: PermissionSubject, options?: {
74
+ actions?: readonly string[];
75
+ resources?: readonly ShareResource[];
76
+ }): Promise<ShareRecord>;
77
+ /**
78
+ * Issue a link to a vault's content (#1388): chosen pages, or the whole vault.
79
+ *
80
+ * Only the vault's owner issues one — no role, admin included, shares
81
+ * someone else's vault. The lifetime is the owner's choice, up to the
82
+ * `shareMaxDays` of the vault's system-category; there is no link that never
83
+ * expires. Read-only, like every share.
84
+ *
85
+ * @param scope - The vault, and its page uuids or null for the whole vault
86
+ * @param lifetimeHours - How long the link lasts, in hours
87
+ * @param issuer - The owner, as the request's own subject
88
+ * @param options - `label`: the owner's note for the link, never logged or
89
+ * audited. `lockedFor`: for an encrypted vault, the public half of the
90
+ * link's key pair, made in the owner's browser — required there, refused
91
+ * anywhere else.
92
+ */
93
+ issueVaultShare(scope: VaultShareScope, lifetimeHours: number, issuer: PermissionSubject, options?: {
94
+ label?: string;
95
+ lockedFor?: LinkPublicKey;
96
+ }): Promise<ShareRecord>;
97
+ /**
98
+ * Whether `owner`'s vault is encrypted: read from its `store.json`, the one
99
+ * file of a vault that is never sealed — or its kind is sealed (#1834), so a
100
+ * link into a sealed kind's vault is never issued as if it were plain.
101
+ */
102
+ isEncryptedVault(owner: string, vault: string): Promise<boolean>;
103
+ private vaultPlace;
104
+ /** The longest a new link to `vault` may last, in days (#1388). */
105
+ maxShareDays(vault: string): number;
106
+ /**
107
+ * Extend a live link by up to {@link SHARE_EXTEND_MAX_HOURS} hours (#1388).
108
+ * Only its issuer may, as often as they like, and past the lifetime maximum:
109
+ * that limits a link only when it is made. An expired, revoked or
110
+ * never-expiring link is not extended.
111
+ *
112
+ * @returns The new expiry, or null when there was nothing to extend
113
+ */
114
+ extend(id: string, hours: number, by: PermissionSubject): Promise<string | null>;
115
+ /** Does `who` hold `action` inside the vault a vault link names (#1539)? The container rule, then vault-owner. */
116
+ private permitsInScope;
117
+ /** The one place a share record is made: the issuer's delegation checked, audited, then stored. */
118
+ private create;
119
+ /**
120
+ * Validate a token. Returns the scope for a live share, or null.
121
+ *
122
+ * Unknown, expired, and revoked tokens are indistinguishable to the
123
+ * caller — routes render an identical 404 for all three so share
124
+ * existence never leaks.
125
+ */
126
+ validate(token: string): ShareScope | null;
127
+ /**
128
+ * Resolve a token into the subject the ordinary evaluator understands
129
+ * (#1222, epic #1225): nobody, carrying what the issuer delegated.
130
+ *
131
+ * The routes hand this subject to the same doors as any request; there is
132
+ * no second evaluator. `hasPermission` and `PolicyInformationPoint` read `viaShare` as
133
+ * a ceiling and re-check the issuer live. Null for an unknown, revoked or
134
+ * expired token — the same three the routes must not tell apart.
135
+ *
136
+ * The grant is a copy of the record's arrays, so nothing downstream can
137
+ * widen the share by mutating what it was handed.
138
+ */
139
+ subjectFor(token: string): PermissionSubject | null;
140
+ /** The record behind a token, or null when it must not open anything. */
141
+ private liveRecord;
142
+ /**
143
+ * Revoke a share by management id. Immediate; the record is retained
144
+ * (revokedAt set) for audit. Returns false for unknown or already-revoked.
145
+ */
146
+ revoke(id: string, revokedBy: string): Promise<boolean>;
147
+ /**
148
+ * List shares — all when `owner` is omitted (admin view), otherwise
149
+ * only those created by `owner`. Includes revoked and expired records;
150
+ * callers surface status from expiresAt/revokedAt.
151
+ */
152
+ /**
153
+ * #1006: active links, and how many of the total that is.
154
+ *
155
+ * Counts only. This manager holds capability tokens — a share link IS the
156
+ * credential — so the count is the most that may ever appear here.
157
+ */
158
+ getManagerStats(): Promise<ManagerStats>;
159
+ list(owner?: string): ShareRecord[];
160
+ /** Look up a share record by management id (management UI detail view). */
161
+ get(id: string): ShareRecord | null;
162
+ /**
163
+ * Record one anonymous access hit against the share behind `token`
164
+ * (decision 5: hits are logged as aggregated counts, not per-view rows).
165
+ * Counts flush to the log + audit trail lazily once the window elapses,
166
+ * and on shutdown. No-op for unknown tokens.
167
+ */
168
+ recordAccess(token: string): void;
169
+ /**
170
+ * Resolve a validated scope to its current content set, applying the
171
+ * safe-by-construction exclusions (decisions 1 and 3).
172
+ */
173
+ resolveScope(scope: ShareScope, ctx: ActorContext): Promise<ResolvedShareScope>;
174
+ /**
175
+ * The candidate pages of a vault link (#1388): the vault's current pages,
176
+ * or just the chosen ones, read as the share subject `ctx`. Whether each may
177
+ * be shown is still the page door's answer, asked by the route.
178
+ */
179
+ private resolveVaultScope;
180
+ /**
181
+ * Record one visit through a vault link (#1388): every page or file opened
182
+ * is its own `share-access` record, naming it by uuid or file id, never by
183
+ * title. Keyword links keep their batched counts.
184
+ */
185
+ recordVaultVisit(token: string, what: {
186
+ page?: string;
187
+ file?: string;
188
+ list?: true;
189
+ }, ipAddress?: string): Promise<void>;
190
+ private resolveKeywordScope;
191
+ /**
192
+ * True when a page must never appear in any share:
193
+ * - `private: true` (decision 1)
194
+ * - `owner-only` in user-keywords (decision 1)
195
+ * - `audience` or per-action `access` frontmatter (decision 3 — a share
196
+ * must not silently widen an author's chosen audience)
197
+ */
198
+ private isPageExcluded;
199
+ /** Prepare and lock everything a link to an encrypted vault covers. `ownerCtx` must hold the vault's key. */
200
+ prepareLockboxes(record: ShareRecord, ownerCtx: ActorContext): Promise<number>;
201
+ /**
202
+ * A page of `owner`'s vault changed (#1388): refresh it in every live link
203
+ * to that vault that covers it — or take it out, when it was deleted or
204
+ * moved away. Called by PageManager with the saving owner's context, which
205
+ * holds the vault key. Best-effort: one link's failure never stops a save.
206
+ */
207
+ refreshLockboxesForPage(ownerCtx: ActorContext, change: {
208
+ name: string | null;
209
+ uuid?: string;
210
+ previousName?: string | null;
211
+ }): Promise<void>;
212
+ /**
213
+ * A lockbox of a live link, for the recipient's browser to open — or null,
214
+ * the same for an unknown link, one that is not locked, and a missing item.
215
+ */
216
+ getLockbox(token: string, kind: 'manifest' | 'pages' | 'files', key?: string): Lockbox | null;
217
+ /** True when a link is locked for a key, and so is opened in the recipient's browser (#1388). */
218
+ isLockedLink(token: string): boolean;
219
+ private coversPage;
220
+ private lockboxPath;
221
+ private writeLockbox;
222
+ /**
223
+ * Render one page as the link's own subject — so nothing the link could not
224
+ * see reaches it through an include or a plugin — from the text the owner's
225
+ * context read, then lock it, and each vault file it uses, for the link.
226
+ */
227
+ private lockPage;
228
+ /** The link's list of pages, locked: titles are the owner's, so they are never served in the clear. */
229
+ private lockManifest;
230
+ private dropLockboxes;
231
+ /** Lockboxes of links that have expired or been revoked go at start-up, whatever was missed. */
232
+ private sweepLockboxes;
233
+ private persist;
234
+ private loadShares;
235
+ /**
236
+ * Flush aggregated access counts (one share, or all when `id` omitted) to
237
+ * the log and audit trail as a single `share-access` row each (decision 5).
238
+ */
239
+ private flushAccessCounts;
240
+ /** Audit create/revoke (decision 5). Never throws — shares work without audit. */
241
+ /**
242
+ * Record a share event through `recordAuditEvent`, which honours the on-failure rule
243
+ * configuration declares (#1202): a `refuse` event is flushed and a failure
244
+ * rejects, so the caller abandons the action; a `continue` one is
245
+ * fire-and-forget with the error counted. No catch here — swallowing the
246
+ * rejection is exactly what made the old `critical` claim a promise the code
247
+ * did not keep.
248
+ */
249
+ private audit;
250
+ shutdown(): Promise<void>;
251
+ }
@@ -0,0 +1,176 @@
1
+ import BaseManager from './BaseManager.js';
2
+ import { WikiEngine } from '../types/WikiEngine.js';
3
+ /**
4
+ * Configuration options for TemplateManager initialization
5
+ */
6
+ interface TemplateConfig extends Record<string, unknown> {
7
+ templatesDirectory?: string;
8
+ themesDirectory?: string;
9
+ }
10
+ /**
11
+ * Template object structure
12
+ */
13
+ interface Template {
14
+ name: string;
15
+ content: string;
16
+ path: string;
17
+ }
18
+ /**
19
+ * Theme object structure
20
+ */
21
+ interface Theme {
22
+ name: string;
23
+ content: string;
24
+ path: string;
25
+ }
26
+ /**
27
+ * Variables for template substitution
28
+ */
29
+ interface TemplateVariables {
30
+ uuid?: string;
31
+ date?: string;
32
+ timestamp?: string;
33
+ pageName?: string;
34
+ category?: string;
35
+ systemCategory?: string;
36
+ userKeywords?: string | string[];
37
+ [key: string]: string | string[] | undefined;
38
+ }
39
+ /**
40
+ * TemplateManager - Handles page templates and themes
41
+ *
42
+ * Similar to JSPWiki's TemplateManager, this manager provides template
43
+ * management for creating new pages from predefined templates and managing
44
+ * wiki themes for UI customization.
45
+ *
46
+ * Key features:
47
+ * - Page template management
48
+ * - Theme loading and switching
49
+ * - Default template creation
50
+ * - Template content retrieval
51
+ *
52
+ * @class TemplateManager
53
+ * @extends BaseManager
54
+ *
55
+ * @property {TemplateMap} templates - Loaded page templates
56
+ * @property {ThemeMap} themes - Loaded themes
57
+ * @property {string} templatesDirectory - Path to templates directory
58
+ * @property {string} themesDirectory - Path to themes directory
59
+ *
60
+ * @see {@link BaseManager} for base functionality
61
+ *
62
+ * @example
63
+ * const templateManager = engine.getManager('TemplateManager');
64
+ * const template = templateManager.getTemplate('Meeting Notes');
65
+ */
66
+ declare class TemplateManager extends BaseManager {
67
+ private templates;
68
+ private themes;
69
+ private templatesDirectory;
70
+ private themesDirectory;
71
+ /**
72
+ * Creates a new TemplateManager instance
73
+ *
74
+ * @constructor
75
+ * @param {WikiEngine} engine - The wiki engine instance
76
+ */
77
+ constructor(engine: WikiEngine);
78
+ /**
79
+ * Initialize the TemplateManager and load templates/themes
80
+ *
81
+ * @async
82
+ * @param {TemplateConfig} [config={}] - Configuration object
83
+ * @returns {Promise<void>}
84
+ */
85
+ initialize(config?: TemplateConfig): Promise<void>;
86
+ /**
87
+ * Load all page templates
88
+ *
89
+ * @returns {Promise<void>}
90
+ */
91
+ loadTemplates(): Promise<void>;
92
+ /**
93
+ * Load all themes
94
+ *
95
+ * @returns {Promise<void>}
96
+ */
97
+ loadThemes(): Promise<void>;
98
+ /**
99
+ * Create default page templates
100
+ *
101
+ * @returns {Promise<void>}
102
+ */
103
+ createDefaultTemplates(): Promise<void>;
104
+ /**
105
+ * Create default theme
106
+ *
107
+ * @returns {Promise<void>}
108
+ */
109
+ createDefaultTheme(): Promise<void>;
110
+ /**
111
+ * Get available templates
112
+ *
113
+ * @returns {Template[]} Available templates
114
+ */
115
+ getTemplates(): Template[];
116
+ /**
117
+ * Get a specific template
118
+ *
119
+ * @param {string} templateName - Template name
120
+ * @returns {Template | null} Template object or null
121
+ */
122
+ getTemplate(templateName: string): Template | null;
123
+ /**
124
+ * Apply template to create page content
125
+ *
126
+ * @param {string} templateName - Template to use
127
+ * @param {TemplateVariables} variables - Variables to substitute
128
+ * @returns {string} Generated content
129
+ * @throws {Error} If template is not found
130
+ */
131
+ applyTemplate(templateName: string, variables?: TemplateVariables): string;
132
+ /**
133
+ * Generate UUID for pages
134
+ *
135
+ * @returns {string} UUID
136
+ */
137
+ generateUUID(): string;
138
+ /**
139
+ * Get available themes
140
+ *
141
+ * @returns {Theme[]} Available themes
142
+ */
143
+ getThemes(): Theme[];
144
+ /**
145
+ * Get a specific theme
146
+ *
147
+ * @param {string} themeName - Theme name
148
+ * @returns {Theme | null} Theme object or null
149
+ */
150
+ getTheme(themeName: string): Theme | null;
151
+ /**
152
+ * Create a new template
153
+ *
154
+ * @param {string} templateName - Template name
155
+ * @param {string} content - Template content
156
+ * @returns {Promise<void>}
157
+ */
158
+ createTemplate(templateName: string, content: string): Promise<void>;
159
+ /**
160
+ * Create a new theme
161
+ *
162
+ * @param {string} themeName - Theme name
163
+ * @param {string} content - CSS content
164
+ * @returns {Promise<void>}
165
+ */
166
+ createTheme(themeName: string, content: string): Promise<void>;
167
+ /**
168
+ * Get template suggestions based on page name or category
169
+ *
170
+ * @param {string} pageName - Page name
171
+ * @param {string} category - Page category
172
+ * @returns {string[]} Suggested template names
173
+ */
174
+ suggestTemplates(pageName: string, category: string): string[];
175
+ }
176
+ export default TemplateManager;
@@ -0,0 +1,56 @@
1
+ export interface ThemeInfo {
2
+ name: string;
3
+ description: string;
4
+ version: string;
5
+ author: string;
6
+ /** Optional Google Fonts (or other) stylesheet URLs to inject in <head> */
7
+ fonts?: string[];
8
+ }
9
+ export interface ThemePaths {
10
+ /** Active theme name (folder name under themes/) */
11
+ activeTheme: string;
12
+ /** Path to themes/core.css — structural CSS shared by all themes */
13
+ coreCssPath: string;
14
+ /** Path to the active theme's CSS variables file */
15
+ variablesCssPath: string;
16
+ /** Path to the active theme's logo image */
17
+ logoPath: string;
18
+ /** Path to the active theme's favicon */
19
+ faviconPath: string;
20
+ /** Path to the shared location plugin CSS */
21
+ locationCssPath: string;
22
+ /** Metadata from theme.json */
23
+ themeInfo: ThemeInfo | null;
24
+ /** Optional font stylesheet URLs from theme.json fonts[] */
25
+ fontUrls: string[];
26
+ }
27
+ /**
28
+ * Returns a cached ThemeManager for the given active theme + themes directory.
29
+ *
30
+ * Use this everywhere instead of `new ThemeManager(...)` unless you specifically
31
+ * need a fresh instance (e.g. tests). The cache is keyed by `${themesDir}::${activeTheme}`
32
+ * so cache hits only when both match. Misses produce a new instance and replace
33
+ * the cached one.
34
+ */
35
+ export declare function getThemeManager(activeTheme: string, themesDir: string): ThemeManager;
36
+ /** Test/admin helper — drop the cache so the next getThemeManager() rebuilds. */
37
+ export declare function clearThemeManagerCache(): void;
38
+ export declare class ThemeManager {
39
+ private themesDir;
40
+ private activeTheme;
41
+ private _paths;
42
+ /** Cache key — `${themesDir}::${activeTheme}` — used by getThemeManager. */
43
+ readonly cacheKey: string;
44
+ constructor(activeTheme: string, themesDir: string);
45
+ private loadThemeInfo;
46
+ private buildPaths;
47
+ /** Resolve variables.css path — falls back to empty placeholder if theme has no custom vars */
48
+ private resolveVariablesCssPath;
49
+ /** Resolve favicon path: prefer favicon.svg → favicon.png → public fallback */
50
+ private resolveFaviconPath;
51
+ /** Resolve logo path: prefer logo.svg → logo.png → favicon.svg → favicon.png → public fallback */
52
+ private resolveLogoPath;
53
+ get paths(): ThemePaths;
54
+ /** List all available themes (subdirs of themes/ that have a theme.json) */
55
+ static listAvailable(themesDir: string): string[];
56
+ }