@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,172 @@
1
+ /**
2
+ * Share links (#842) — capability tokens granting anonymous access to a
3
+ * defined scope of content.
4
+ *
5
+ * The scope is a typed object (decision 6 extraction seam): future scope
6
+ * kinds add a discriminant + evaluator without changing the token model.
7
+ * v1 ships exactly one kind: keyword.
8
+ */
9
+ /** v1 scope: everything carrying a keyword (media EXIF/XMP + page user-keywords). */
10
+ export interface KeywordShareScope {
11
+ kind: 'keyword';
12
+ keyword: string;
13
+ }
14
+ /**
15
+ * A vault's content, shared by its owner (#1388): chosen pages, or the whole
16
+ * vault. Pages are named by uuid, so renaming one does not break the link.
17
+ * Only the current pages are covered, never their history.
18
+ */
19
+ export interface VaultShareScope {
20
+ kind: 'vault';
21
+ /** The vault's owner — the only one who may issue, extend or revoke it. */
22
+ owner: string;
23
+ /** The vault id: `pages/vaults/{owner}/{vault}/`. */
24
+ vault: string;
25
+ /** Page uuids, or null for the whole vault, including pages added while the link is live. */
26
+ pages: string[] | null;
27
+ }
28
+ /** Union of all scope kinds. */
29
+ export type ShareScope = KeywordShareScope | VaultShareScope;
30
+ /** Fixed expiry choices (decision 4). `null` = until cancelled. */
31
+ export type ShareTtl = '24h' | '7d' | '30d' | null;
32
+ /**
33
+ * One share record — persisted as one JSON file per share.
34
+ *
35
+ * `id` is the management handle (list/revoke); `token` is the anonymous
36
+ * capability and never appears in management URLs.
37
+ */
38
+ /**
39
+ * What a share delegates, in the policy resource shape (#1221, epic #1225).
40
+ * A share is a delegation by the user who issues it: `actions` it may perform
41
+ * and `resources` it may perform them on, never more than the issuer held at
42
+ * the time. #1222 evaluates them; this is the record.
43
+ */
44
+ export interface ShareResource {
45
+ /** Resource type the evaluator knows: `page`, `media`, … */
46
+ type: string;
47
+ /** Match pattern. `keyword:<name>` means "everything carrying this keyword". */
48
+ pattern: string;
49
+ }
50
+ /** What a share delegates when the issuer asks for nothing more: read-only. */
51
+ export declare const DEFAULT_SHARE_ACTIONS: readonly string[];
52
+ /** Reserved keyword excluding content from every share (decision 1). */
53
+ export declare const OWNER_ONLY_KEYWORD = "owner-only";
54
+ /**
55
+ * What a request that presented a share token carries (#1222, epic #1225).
56
+ *
57
+ * The share-side twin of `AgentTokenGrant`: it rides on `PermissionSubject`
58
+ * as `viaShare`, and the evaluator applies it as a ceiling — the action must
59
+ * be one of `actions`, the resource must be covered by `resources`, the share
60
+ * must not have passed `expiresAt`, and `issuer` must STILL hold the action
61
+ * when the decision is made. A delegation, not a copy of authority: revoke
62
+ * the issuer's role and every share they issued stops on the next request.
63
+ */
64
+ export interface ShareGrant {
65
+ /** The share's management id — what audit records name. */
66
+ id: string;
67
+ /** Username of the delegator; resolved live at every decision. */
68
+ issuer: string;
69
+ /** Actions delegated, a subset of what the issuer held at issue. */
70
+ actions: string[];
71
+ /** What the delegation covers. */
72
+ resources: ShareResource[];
73
+ /** ISO 8601 expiry, or null = until revoked. */
74
+ expiresAt: string | null;
75
+ }
76
+ /**
77
+ * Does a share cover a resource of `type` carrying `keywords`?
78
+ *
79
+ * The single reader of the `keyword:<name>` grammar. The evaluator asks it
80
+ * about a page's user-keywords; the share routes ask it about a media item's
81
+ * EXIF/XMP keywords. A pattern this function does not understand covers
82
+ * nothing — an unknown grammar is a refusal, never a wildcard — and content
83
+ * carrying `owner-only` is never covered, whatever else it carries.
84
+ */
85
+ export declare function shareCoversResource(resources: readonly ShareResource[], type: string, keywords: readonly string[]): boolean;
86
+ /**
87
+ * Does a share name the vault `owner/vault` at all — whole, or any page in it?
88
+ * The container half of a vault share: who may step into the vault. Which
89
+ * pages it may then read is {@link shareCoversVaultPage}.
90
+ */
91
+ export declare function shareNamesVault(resources: readonly ShareResource[], owner: string, vault: string): boolean;
92
+ /**
93
+ * Does a share cover this page? The one rule both page doors ask (the decider
94
+ * and the list filter): a page in a vault by its uuid or its whole vault
95
+ * (#1388), any other page by its user-keywords.
96
+ */
97
+ export declare function shareCoversPage(resources: readonly ShareResource[], pageName: string, metadata: {
98
+ uuid?: string;
99
+ 'user-keywords'?: string[];
100
+ }): boolean;
101
+ /** The vault a vault link covers, read from its resources, or null for any other share (#1388). */
102
+ export declare function vaultOfShare(resources: readonly ShareResource[]): {
103
+ owner: string;
104
+ vault: string;
105
+ } | null;
106
+ /** Does a share cover the page `uuid` in the vault `owner/vault`? */
107
+ export declare function shareCoversVaultPage(resources: readonly ShareResource[], owner: string, vault: string, uuid: string | undefined): boolean;
108
+ /** The resources a scope names, in the shape the evaluator matches. */
109
+ export declare function resourcesForScope(scope: ShareScope): ShareResource[];
110
+ export interface ShareRecord {
111
+ /** Management identifier (UUID v4). */
112
+ id: string;
113
+ /** Capability token — 64-char crypto-random hex. Unguessable; IS the grant. */
114
+ token: string;
115
+ /** Typed scope object (decision 6). */
116
+ scope: ShareScope;
117
+ /** Permissions delegated — a subset of what the issuer held when issuing (#1221). */
118
+ actions: string[];
119
+ /** What the delegation covers, in the policy resource shape (#1221). */
120
+ resources: ShareResource[];
121
+ /** Username of the issuing user — the delegator whose live authority bounds the share (#1222). */
122
+ createdBy: string;
123
+ /** ISO 8601 creation timestamp. */
124
+ createdAt: string;
125
+ /** ISO 8601 expiry, or null = until cancelled (decision 4). */
126
+ expiresAt: string | null;
127
+ /** ISO 8601 revocation timestamp — record retained for audit (decision 5). */
128
+ revokedAt?: string;
129
+ /**
130
+ * The owner's own note for a vault link, e.g. "For Dr Smith, October"
131
+ * (#1388). Shown to the owner only: never in a log or an audit record.
132
+ */
133
+ label?: string;
134
+ /** How many times a vault link has been used (#1388). */
135
+ visitCount?: number;
136
+ /** The most recent visits through a vault link, newest first, for its owner (#1388). */
137
+ visits?: ShareVisit[];
138
+ /**
139
+ * For a link to an encrypted vault (#1388): the public half of the link's
140
+ * key pair, made in the owner's browser. The server locks the link's pages
141
+ * and files for it and can never open them; the private half is in the
142
+ * link after `#` and never reaches the server.
143
+ */
144
+ lockedFor?: import('../utils/shareLockbox.js').LinkPublicKey;
145
+ }
146
+ /**
147
+ * One visit through a vault link, as its owner sees it (#1388): when, and
148
+ * what was opened. The audit trail keeps the full record, with the address.
149
+ */
150
+ export interface ShareVisit {
151
+ at: string;
152
+ /** The page opened, by uuid. */
153
+ page?: string;
154
+ /** The file opened, by id. */
155
+ file?: string;
156
+ /** The link's page list was opened. */
157
+ list?: true;
158
+ }
159
+ /** A page admitted to a share scope, with fields for a search-result-style listing. */
160
+ export interface SharePageEntry {
161
+ name: string;
162
+ title?: string;
163
+ uuid?: string;
164
+ /** System category (falls back to user category) for the chip row. */
165
+ category?: string;
166
+ /** User keywords for the chip row. */
167
+ keywords?: string[];
168
+ /** Content snippet (same generator as search results). */
169
+ excerpt?: string;
170
+ /** ISO 8601 last-modified timestamp. */
171
+ lastModified?: string;
172
+ }
@@ -0,0 +1,81 @@
1
+ import { parsePrivatePageName } from '../utils/privateStorePath.js';
2
+ /** What a share delegates when the issuer asks for nothing more: read-only. */
3
+ export const DEFAULT_SHARE_ACTIONS = ['page-read', 'asset-read'];
4
+ /** Reserved keyword excluding content from every share (decision 1). */
5
+ export const OWNER_ONLY_KEYWORD = 'owner-only';
6
+ /** The prefix of the keyword pattern grammar a share resource speaks. */
7
+ const KEYWORD_PATTERN = 'keyword:';
8
+ /** `vault:{owner}/{vault}` — every current page in the vault (#1388). */
9
+ const VAULT_PATTERN = 'vault:';
10
+ /** `vault-page:{owner}/{vault}/{uuid}` — one page in the vault (#1388). */
11
+ const VAULT_PAGE_PATTERN = 'vault-page:';
12
+ /**
13
+ * Does a share cover a resource of `type` carrying `keywords`?
14
+ *
15
+ * The single reader of the `keyword:<name>` grammar. The evaluator asks it
16
+ * about a page's user-keywords; the share routes ask it about a media item's
17
+ * EXIF/XMP keywords. A pattern this function does not understand covers
18
+ * nothing — an unknown grammar is a refusal, never a wildcard — and content
19
+ * carrying `owner-only` is never covered, whatever else it carries.
20
+ */
21
+ export function shareCoversResource(resources, type, keywords) {
22
+ if (keywords.includes(OWNER_ONLY_KEYWORD))
23
+ return false;
24
+ return resources.some((r) => r.type === type &&
25
+ r.pattern.startsWith(KEYWORD_PATTERN) &&
26
+ keywords.includes(r.pattern.slice(KEYWORD_PATTERN.length)));
27
+ }
28
+ /**
29
+ * Does a share name the vault `owner/vault` at all — whole, or any page in it?
30
+ * The container half of a vault share: who may step into the vault. Which
31
+ * pages it may then read is {@link shareCoversVaultPage}.
32
+ */
33
+ export function shareNamesVault(resources, owner, vault) {
34
+ const whole = `${VAULT_PATTERN}${owner}/${vault}`;
35
+ const pagePrefix = `${VAULT_PAGE_PATTERN}${owner}/${vault}/`;
36
+ return resources.some((r) => r.type === 'page' && (r.pattern === whole || r.pattern.startsWith(pagePrefix)));
37
+ }
38
+ /**
39
+ * Does a share cover this page? The one rule both page doors ask (the decider
40
+ * and the list filter): a page in a vault by its uuid or its whole vault
41
+ * (#1388), any other page by its user-keywords.
42
+ */
43
+ export function shareCoversPage(resources, pageName, metadata) {
44
+ const vaultPage = parsePrivatePageName(pageName);
45
+ if (vaultPage)
46
+ return shareCoversVaultPage(resources, vaultPage.owner, vaultPage.store, metadata.uuid);
47
+ return shareCoversResource(resources, 'page', metadata['user-keywords'] ?? []);
48
+ }
49
+ /** The vault a vault link covers, read from its resources, or null for any other share (#1388). */
50
+ export function vaultOfShare(resources) {
51
+ for (const r of resources) {
52
+ if (r.type !== 'page')
53
+ continue;
54
+ const rest = r.pattern.startsWith(VAULT_PATTERN) ? r.pattern.slice(VAULT_PATTERN.length)
55
+ : r.pattern.startsWith(VAULT_PAGE_PATTERN) ? r.pattern.slice(VAULT_PAGE_PATTERN.length) : null;
56
+ if (rest === null)
57
+ continue;
58
+ const [owner, vault] = rest.split('/');
59
+ if (owner && vault)
60
+ return { owner, vault };
61
+ }
62
+ return null;
63
+ }
64
+ /** Does a share cover the page `uuid` in the vault `owner/vault`? */
65
+ export function shareCoversVaultPage(resources, owner, vault, uuid) {
66
+ const whole = `${VAULT_PATTERN}${owner}/${vault}`;
67
+ const one = uuid ? `${VAULT_PAGE_PATTERN}${owner}/${vault}/${uuid}` : null;
68
+ return resources.some((r) => r.type === 'page' && (r.pattern === whole || (one !== null && r.pattern === one)));
69
+ }
70
+ /** The resources a scope names, in the shape the evaluator matches. */
71
+ export function resourcesForScope(scope) {
72
+ if (scope.kind === 'vault') {
73
+ if (scope.pages === null)
74
+ return [{ type: 'page', pattern: `${VAULT_PATTERN}${scope.owner}/${scope.vault}` }];
75
+ return scope.pages.map((uuid) => ({ type: 'page', pattern: `${VAULT_PAGE_PATTERN}${scope.owner}/${scope.vault}/${uuid}` }));
76
+ }
77
+ return [
78
+ { type: 'page', pattern: `keyword:${scope.keyword}` },
79
+ { type: 'media', pattern: `keyword:${scope.keyword}` }
80
+ ];
81
+ }
@@ -0,0 +1,304 @@
1
+ /**
2
+ * User type definitions for ngdpbase
3
+ *
4
+ * This module defines types for users, authentication, roles, and permissions
5
+ * used by UserManager and authorization systems.
6
+ */
7
+ /**
8
+ * An item pinned to the user's My Links sidebar section. The shape is unified
9
+ * across wiki pages and arbitrary app-route bookmarks (e.g. /my/journal,
10
+ * /profile, /search?q=foo). `url` is the canonical identifier; `pageName` is
11
+ * carried for wiki pages so the rendering path can still use page-aware
12
+ * affordances when relevant.
13
+ *
14
+ * Legacy entries (`{pageName, title}` only, no `url`) are normalised at read
15
+ * time by normalizePinnedItem in src/utils/pinnedItems.ts.
16
+ */
17
+ export interface PinnedItem {
18
+ url: string;
19
+ title: string;
20
+ pageName?: string;
21
+ pinnedAt?: string;
22
+ }
23
+ /**
24
+ * @deprecated Use PinnedItem. Kept as an alias for back-compat with callers
25
+ * that only handle wiki-page pins.
26
+ */
27
+ export type PinnedPage = PinnedItem;
28
+ /**
29
+ * User preferences
30
+ *
31
+ * User-specific settings and preferences.
32
+ */
33
+ export interface UserPreferences {
34
+ /** Editor smart pairs (auto-close brackets, quotes) */
35
+ 'editor.plain.smartpairs'?: boolean;
36
+ /** Editor auto-indent */
37
+ 'editor.autoindent'?: boolean;
38
+ /** Show line numbers in editor */
39
+ 'editor.linenumbers'?: boolean;
40
+ /** Editor theme (light, dark, etc.) */
41
+ 'editor.theme'?: string;
42
+ /** Display page size for lists */
43
+ 'display.pagesize'?: string;
44
+ /** Show tooltips */
45
+ 'display.tooltips'?: boolean;
46
+ /** Reader mode enabled */
47
+ 'display.readermode'?: boolean;
48
+ /** Date format (iso, us, eu, etc.) */
49
+ 'display.dateformat'?: string;
50
+ /** Timezone */
51
+ timezone?: string;
52
+ /** Language/locale */
53
+ locale?: string;
54
+ /** Items pinned to the My Links sidebar section (wiki pages and app-route URLs) */
55
+ 'nav.pinnedPages'?: PinnedItem[];
56
+ /** Additional custom preferences */
57
+ [key: string]: unknown;
58
+ }
59
+ /**
60
+ * User object
61
+ *
62
+ * Complete user record stored in the user provider.
63
+ */
64
+ export interface User {
65
+ /** Username (unique identifier for login) */
66
+ username: string;
67
+ /** Email address */
68
+ email: string;
69
+ /** Display name (full name) */
70
+ displayName: string;
71
+ /** Hashed password (SHA-256 or bcrypt) */
72
+ password: string;
73
+ /**
74
+ * @deprecated since #617 iteration 3b. Role membership is now stored
75
+ * canonically as OrganizationRole records owned by `RoleManager`; resolve
76
+ * a user's roles via `RoleManager.resolveUserRoles(username)`. The field
77
+ * is retained as optional for backwards compatibility while in-flight
78
+ * `users.json` files still carry it; the `strip-user-roles.ts` migration
79
+ * removes it. New code MUST NOT read or write this field directly.
80
+ */
81
+ roles?: string[];
82
+ /** Whether user account is active */
83
+ isActive: boolean;
84
+ /** Whether user is system user */
85
+ isSystem: boolean;
86
+ /** Whether user is external (LDAP, OAuth) */
87
+ isExternal: boolean;
88
+ /**
89
+ * A test account (#1805): it holds test or synthetic data, never real data,
90
+ * so a site can keep the two apart by account and show which is which.
91
+ *
92
+ * An attribute, not a role — it grants nothing and no policy reads it. Set
93
+ * by an administrator (`user-create` / `user-edit`), marked in the admin
94
+ * user list, shown to the signed-in person as a banner, and handed to the
95
+ * host as `userContext.isTest` and the OIDC `test_account` claim, so the
96
+ * host decides what a test account may do.
97
+ *
98
+ * Optional in storage only: an account saved before the flag existed has
99
+ * none. Every read through UserManager returns it as a boolean, `false`
100
+ * when absent.
101
+ */
102
+ isTest?: boolean;
103
+ /**
104
+ * Freeze this account's identity against self-service change (#1029).
105
+ *
106
+ * For a shared account whose credentials are published — a demo login, say —
107
+ * letting the holder edit their own identity hands the account away:
108
+ *
109
+ * - **password** — the first visitor to change it locks out every other
110
+ * visitor and makes the published credential wrong.
111
+ * - **email** — worse, and the reason this covers more than the password.
112
+ * Magic-link login resolves an account by email address
113
+ * (`MagicLinkAuthProvider.getUserByEmail`), so a visitor who repoints the
114
+ * address at their own inbox can magic-link back in indefinitely. The
115
+ * password lock alone would not have stopped them.
116
+ * - **displayName** — defacement on a public instance.
117
+ *
118
+ * Preferences, avatar and pinned links stay editable: the point is to let a
119
+ * visitor drive the account, not to freeze it.
120
+ *
121
+ * Blocks the `/profile` path only. An administrator can still change any of
122
+ * it through `/admin/users/<name>/edit`, which requires `user-edit`, so the
123
+ * account is never unrecoverable.
124
+ *
125
+ * Distinct from `isSystem`, which means "cannot be deleted" and is set on
126
+ * `admin` — an account that must keep self-service password change.
127
+ */
128
+ profileLocked?: boolean;
129
+ /**
130
+ * Raised on every password change (#1482). A session stamped with an older
131
+ * value is signed out on its next request. See `utils/sessionGeneration`.
132
+ */
133
+ sessionGeneration?: number;
134
+ /** When the password last changed, ISO 8601 (#1592); written only by setPassword(). */
135
+ passwordChangedAt?: string;
136
+ /** Account creation timestamp (ISO 8601) */
137
+ createdAt: string;
138
+ /** Last login timestamp (ISO 8601) */
139
+ lastLogin?: string;
140
+ /** Total login count */
141
+ loginCount: number;
142
+ /** User preferences */
143
+ preferences: UserPreferences;
144
+ /** Profile picture URL or data */
145
+ avatar?: string;
146
+ /** Wiki page name for this user's profile page */
147
+ profilePage?: string;
148
+ /** Additional metadata */
149
+ metadata?: Record<string, unknown>;
150
+ /**
151
+ * Allowed authentication methods for this user.
152
+ * If absent, the user may use any method enabled at the system level.
153
+ * If present, only the listed provider IDs are accepted (e.g. ["oidc:google", "password"]).
154
+ * Useful for ensuring admin accounts can always use password as an emergency fallback.
155
+ */
156
+ allowedAuthMethods?: string[];
157
+ }
158
+ /**
159
+ * User creation data
160
+ *
161
+ * Data required to create a new user (no password hash yet).
162
+ */
163
+ export interface UserCreateData {
164
+ /** Username (unique) */
165
+ username: string;
166
+ /** Email address */
167
+ email: string;
168
+ /** Display name */
169
+ displayName: string;
170
+ /** Plain text password (will be hashed) */
171
+ password: string;
172
+ /** Initial roles */
173
+ roles?: string[];
174
+ /** Whether account starts active */
175
+ isActive?: boolean;
176
+ /** User preferences */
177
+ preferences?: Partial<UserPreferences>;
178
+ }
179
+ /**
180
+ * User update data
181
+ *
182
+ * Partial user data for updates (all fields optional).
183
+ */
184
+ export interface UserUpdateData {
185
+ /** Email address */
186
+ email?: string;
187
+ /** Display name */
188
+ displayName?: string;
189
+ /** New plain text password (will be hashed) */
190
+ password?: string;
191
+ /** Updated roles */
192
+ roles?: string[];
193
+ /** Active status */
194
+ isActive?: boolean;
195
+ /** Updated preferences */
196
+ preferences?: Partial<UserPreferences>;
197
+ /** Avatar */
198
+ avatar?: string;
199
+ /** Metadata */
200
+ metadata?: Record<string, unknown>;
201
+ }
202
+ /**
203
+ * User session data
204
+ *
205
+ * Active session information stored by session manager.
206
+ */
207
+ export interface UserSession {
208
+ /** Session ID (unique) */
209
+ sessionId: string;
210
+ /** Username */
211
+ username: string;
212
+ /** User ID (username or external ID) */
213
+ userId: string;
214
+ /** Session creation timestamp (ISO 8601) */
215
+ createdAt: string;
216
+ /** Session expiration timestamp (ISO 8601) */
217
+ expiresAt: string;
218
+ /** Last activity timestamp (ISO 8601) */
219
+ lastActivity: string;
220
+ /** Client IP address */
221
+ ipAddress?: string;
222
+ /** User agent string */
223
+ userAgent?: string;
224
+ /** Additional session data */
225
+ data?: Record<string, unknown>;
226
+ }
227
+ /**
228
+ * User authentication result
229
+ *
230
+ * Result of authentication attempt.
231
+ */
232
+ export interface AuthResult {
233
+ /** Whether authentication succeeded */
234
+ success: boolean;
235
+ /** User object if successful */
236
+ user?: User;
237
+ /** Session ID if successful */
238
+ sessionId?: string;
239
+ /** Error message if failed */
240
+ error?: string;
241
+ /** Error code (invalid_credentials, account_disabled, etc.) */
242
+ errorCode?: string;
243
+ }
244
+ /**
245
+ * User role definition
246
+ *
247
+ * Defines a role and its permissions.
248
+ */
249
+ export interface Role {
250
+ /** Role name (unique identifier) */
251
+ name: string;
252
+ /** Display name */
253
+ displayName: string;
254
+ /** Role description */
255
+ description?: string;
256
+ /** Permissions granted by this role */
257
+ permissions: string[];
258
+ /** Whether this is a system role (cannot be deleted) */
259
+ isSystem: boolean;
260
+ /** Parent roles (inheritance) */
261
+ inherits?: string[];
262
+ }
263
+ /**
264
+ * User permission
265
+ *
266
+ * Defines a specific permission.
267
+ */
268
+ export interface Permission {
269
+ /** Permission name (unique identifier) */
270
+ name: string;
271
+ /** Display name */
272
+ displayName: string;
273
+ /** Permission description */
274
+ description?: string;
275
+ /** Resource this permission applies to */
276
+ resource: string;
277
+ /** Action allowed (view, edit, delete, etc.) */
278
+ action: string;
279
+ /** Whether this is a system permission */
280
+ isSystem: boolean;
281
+ }
282
+ /**
283
+ * User profile
284
+ *
285
+ * Public user profile (safe to expose to other users).
286
+ */
287
+ export interface UserProfile {
288
+ /** Username */
289
+ username: string;
290
+ /** Display name */
291
+ displayName: string;
292
+ /** Email (may be hidden based on privacy settings) */
293
+ email?: string;
294
+ /** Avatar */
295
+ avatar?: string;
296
+ /** Roles (may be filtered based on permissions) */
297
+ roles?: string[];
298
+ /** Whether user is active */
299
+ isActive: boolean;
300
+ /** Account creation date */
301
+ createdAt: string;
302
+ /** Last login (may be hidden) */
303
+ lastLogin?: string;
304
+ }