@jwilleke/ngdpbase-types 0.0.0 → 5.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (304) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +16 -2
  3. package/lib/packages/ngdpbase-types/index.d.ts +32 -0
  4. package/lib/packages/ngdpbase-types/testing.d.ts +43 -0
  5. package/lib/packages/ngdpbase-types/testing.js +53 -0
  6. package/lib/src/cache/CacheDependencies.d.ts +50 -0
  7. package/lib/src/cache/CacheDependencies.js +50 -0
  8. package/lib/src/cache/ICacheAdapter.d.ts +86 -0
  9. package/lib/src/cache/RegionCache.d.ts +171 -0
  10. package/lib/src/context/ActorContext.d.ts +48 -0
  11. package/lib/src/context/ActorContext.js +33 -0
  12. package/lib/src/context/ApiContext.d.ts +194 -0
  13. package/lib/src/context/ApiContext.js +273 -0
  14. package/lib/src/context/BaseContext.d.ts +110 -0
  15. package/lib/src/context/BaseContext.js +143 -0
  16. package/lib/src/context/JobContext.d.ts +153 -0
  17. package/lib/src/context/JobContext.js +144 -0
  18. package/lib/src/context/WikiContext.d.ts +404 -0
  19. package/lib/src/context/bootActions.d.ts +64 -0
  20. package/lib/src/context/bootActions.js +111 -0
  21. package/lib/src/converters/HtmlConverter.d.ts +70 -0
  22. package/lib/src/converters/IContentConverter.d.ts +94 -0
  23. package/lib/src/converters/JSPWikiConverter.d.ts +117 -0
  24. package/lib/src/converters/conversionWarning.d.ts +15 -0
  25. package/lib/src/converters/ncm/bridge.d.ts +22 -0
  26. package/lib/src/converters/ncm/existing.d.ts +23 -0
  27. package/lib/src/converters/ncm/fix/blocks.d.ts +89 -0
  28. package/lib/src/converters/ncm/fix/bulletMarkers.d.ts +21 -0
  29. package/lib/src/converters/ncm/fix/index.d.ts +36 -0
  30. package/lib/src/converters/ncm/fix/jspwikiBullets.d.ts +20 -0
  31. package/lib/src/converters/ncm/fix/jspwikiCodeMarkers.d.ts +38 -0
  32. package/lib/src/converters/ncm/fix/jspwikiHeadings.d.ts +25 -0
  33. package/lib/src/converters/ncm/fix/jspwikiIndent.d.ts +24 -0
  34. package/lib/src/converters/ncm/fix/jspwikiInsert.d.ts +21 -0
  35. package/lib/src/converters/ncm/fix/jspwikiItalic.d.ts +29 -0
  36. package/lib/src/converters/ncm/fix/jspwikiLinkLeftovers.d.ts +27 -0
  37. package/lib/src/converters/ncm/fix/moreInformationFooter.d.ts +25 -0
  38. package/lib/src/converters/ncm/fix/styleClosers.d.ts +25 -0
  39. package/lib/src/converters/ncm/fix/tightenLists.d.ts +30 -0
  40. package/lib/src/converters/ncm/fix/types.d.ts +33 -0
  41. package/lib/src/converters/ncm/footnotes.d.ts +39 -0
  42. package/lib/src/converters/ncm/images.d.ts +49 -0
  43. package/lib/src/converters/ncm/index.d.ts +20 -0
  44. package/lib/src/converters/ncm/links.d.ts +21 -0
  45. package/lib/src/converters/ncm/normalize.d.ts +39 -0
  46. package/lib/src/converters/ncm/placeholder.d.ts +25 -0
  47. package/lib/src/converters/ncm/tables.d.ts +36 -0
  48. package/lib/src/converters/ncm/types.d.ts +42 -0
  49. package/lib/src/http/egressPolicy.d.ts +52 -0
  50. package/lib/src/http/guardedFetch.d.ts +89 -0
  51. package/lib/src/http/guardedFetch.js +113 -0
  52. package/lib/src/http/guardedLookup.d.ts +48 -0
  53. package/lib/src/http/guardedLookup.js +73 -0
  54. package/lib/src/http/ssrf.d.ts +83 -0
  55. package/lib/src/http/ssrf.js +311 -0
  56. package/lib/src/mail/MailProvider.d.ts +36 -0
  57. package/lib/src/mail/NodemailerMailProvider.d.ts +26 -0
  58. package/lib/src/managers/AddonsManager.d.ts +691 -0
  59. package/lib/src/managers/AgentTokenManager.d.ts +269 -0
  60. package/lib/src/managers/AssetManager.d.ts +116 -0
  61. package/lib/src/managers/AttachmentManager.d.ts +1032 -0
  62. package/lib/src/managers/AuthManager.d.ts +1257 -0
  63. package/lib/src/managers/BackgroundJobManager.d.ts +434 -0
  64. package/lib/src/managers/BaseManager.d.ts +427 -0
  65. package/lib/src/managers/BaseManager.js +415 -0
  66. package/lib/src/managers/CacheManager.d.ts +159 -0
  67. package/lib/src/managers/CatalogManager.d.ts +235 -0
  68. package/lib/src/managers/CommentManager.d.ts +75 -0
  69. package/lib/src/managers/ConfigurationManager.d.ts +747 -0
  70. package/lib/src/managers/DatabaseManager.d.ts +188 -0
  71. package/lib/src/managers/DatabaseManager.js +590 -0
  72. package/lib/src/managers/EmailManager.d.ts +47 -0
  73. package/lib/src/managers/ExportManager.d.ts +129 -0
  74. package/lib/src/managers/ExportManager.js +420 -0
  75. package/lib/src/managers/FootnoteManager.d.ts +118 -0
  76. package/lib/src/managers/MediaManager.d.ts +279 -0
  77. package/lib/src/managers/MetricsManager.d.ts +89 -0
  78. package/lib/src/managers/NotificationManager.d.ts +165 -0
  79. package/lib/src/managers/OidcManager.d.ts +210 -0
  80. package/lib/src/managers/OrganizationManager.d.ts +107 -0
  81. package/lib/src/managers/PageManager.d.ts +1645 -0
  82. package/lib/src/managers/PersonManager.d.ts +48 -0
  83. package/lib/src/managers/PluginManager.d.ts +179 -0
  84. package/lib/src/managers/PluginManager.js +393 -0
  85. package/lib/src/managers/PolicyEvaluator.d.ts +213 -0
  86. package/lib/src/managers/RenderingManager.d.ts +358 -0
  87. package/lib/src/managers/RoleManager.d.ts +134 -0
  88. package/lib/src/managers/SearchManager.d.ts +402 -0
  89. package/lib/src/managers/ShareManager.d.ts +251 -0
  90. package/lib/src/managers/TemplateManager.d.ts +176 -0
  91. package/lib/src/managers/ThemeManager.d.ts +56 -0
  92. package/lib/src/managers/UserManager.d.ts +480 -0
  93. package/lib/src/managers/ValidationManager.d.ts +426 -0
  94. package/lib/src/managers/VariableManager.d.ts +145 -0
  95. package/lib/src/middleware/csrf.d.ts +3 -0
  96. package/lib/src/parsers/LinkParser.d.ts +457 -0
  97. package/lib/src/parsers/MarkupParser.d.ts +769 -0
  98. package/lib/src/parsers/context/ParseContext.d.ts +314 -0
  99. package/lib/src/parsers/data/emoji-map.d.ts +18 -0
  100. package/lib/src/parsers/dom/DOMBuilder.d.ts +210 -0
  101. package/lib/src/parsers/dom/DOMParser.d.ts +252 -0
  102. package/lib/src/parsers/dom/Tokenizer.d.ts +358 -0
  103. package/lib/src/parsers/dom/WikiDocument.d.ts +272 -0
  104. package/lib/src/parsers/dom/handlers/DOMLinkHandler.d.ts +260 -0
  105. package/lib/src/parsers/dom/handlers/DOMPluginHandler.d.ts +212 -0
  106. package/lib/src/parsers/dom/handlers/DOMVariableHandler.d.ts +171 -0
  107. package/lib/src/parsers/filters/BaseFilter.d.ts +269 -0
  108. package/lib/src/parsers/filters/FilterChain.d.ts +320 -0
  109. package/lib/src/parsers/handlers/BaseSyntaxHandler.d.ts +331 -0
  110. package/lib/src/parsers/handlers/HandlerRegistry.d.ts +225 -0
  111. package/lib/src/parsers/handlers/JSPWikiPreprocessor.d.ts +89 -0
  112. package/lib/src/parsers/handlers/LinkParserHandler.d.ts +80 -0
  113. package/lib/src/parsers/handlers/PluginSyntaxHandler.d.ts +78 -0
  114. package/lib/src/parsers/handlers/WikiFormHandler.d.ts +149 -0
  115. package/lib/src/parsers/handlers/WikiTagHandler.d.ts +125 -0
  116. package/lib/src/parsers/jspwikiTableRow.d.ts +39 -0
  117. package/lib/src/parsers/styleBlockSyntax.d.ts +14 -0
  118. package/lib/src/plugins/types.d.ts +79 -0
  119. package/lib/src/providers/AgentTokenAuthProvider.d.ts +40 -0
  120. package/lib/src/providers/AuthentikBearerAuthProvider.d.ts +75 -0
  121. package/lib/src/providers/BaseAttachmentProvider.d.ts +197 -0
  122. package/lib/src/providers/BaseAuthProvider.d.ts +220 -0
  123. package/lib/src/providers/BaseCacheProvider.d.ts +140 -0
  124. package/lib/src/providers/BaseCredentialsProvider.d.ts +84 -0
  125. package/lib/src/providers/BaseDatabaseProvider.d.ts +22 -0
  126. package/lib/src/providers/BaseDatabaseProvider.js +12 -0
  127. package/lib/src/providers/BaseLoggingProvider.d.ts +68 -0
  128. package/lib/src/providers/BaseLoggingProvider.js +37 -0
  129. package/lib/src/providers/BaseMediaProvider.d.ts +308 -0
  130. package/lib/src/providers/BasePageProvider.d.ts +337 -0
  131. package/lib/src/providers/BaseProvider.d.ts +98 -0
  132. package/lib/src/providers/BaseProvider.js +74 -0
  133. package/lib/src/providers/BaseSearchProvider.d.ts +362 -0
  134. package/lib/src/providers/BasicAttachmentProvider.d.ts +599 -0
  135. package/lib/src/providers/CloudflareAccessAuthProvider.d.ts +72 -0
  136. package/lib/src/providers/FileCredentialsProvider.d.ts +33 -0
  137. package/lib/src/providers/FileJobStateProvider.d.ts +58 -0
  138. package/lib/src/providers/FileLoggingProvider.d.ts +43 -0
  139. package/lib/src/providers/FileLoggingProvider.js +120 -0
  140. package/lib/src/providers/FileOidcAdapter.d.ts +25 -0
  141. package/lib/src/providers/FileSystemMediaProvider.d.ts +403 -0
  142. package/lib/src/providers/LunrSearchProvider.d.ts +280 -0
  143. package/lib/src/providers/MagicLinkAuthProvider.d.ts +125 -0
  144. package/lib/src/providers/NullCacheProvider.d.ts +72 -0
  145. package/lib/src/providers/OidcAuthProvider.d.ts +180 -0
  146. package/lib/src/providers/OidcBearerAuthProvider.d.ts +30 -0
  147. package/lib/src/providers/PasskeyAuthProvider.d.ts +58 -0
  148. package/lib/src/providers/PasswordAuthProvider.d.ts +20 -0
  149. package/lib/src/providers/SqliteDatabaseProvider.d.ts +55 -0
  150. package/lib/src/providers/SqliteDatabaseProvider.js +90 -0
  151. package/lib/src/providers/SqliteJobStateProvider.d.ts +41 -0
  152. package/lib/src/providers/databaseMigrations.d.ts +8 -0
  153. package/lib/src/providers/databaseMigrations.js +47 -0
  154. package/lib/src/providers/jobState.d.ts +99 -0
  155. package/lib/src/providers/lunrQueryToMiniSearch.d.ts +32 -0
  156. package/lib/src/providers/mediaFilenameDate.d.ts +22 -0
  157. package/lib/src/providers/sqliteBackup.d.ts +128 -0
  158. package/lib/src/providers/sqliteBackup.js +365 -0
  159. package/lib/src/providers/sqliteLocation.d.ts +17 -0
  160. package/lib/src/providers/sqliteLocation.js +55 -0
  161. package/lib/src/providers/sqliteMigrations.d.ts +48 -0
  162. package/lib/src/providers/sqliteMigrations.js +72 -0
  163. package/lib/src/rendering/githubAlerts.d.ts +22 -0
  164. package/lib/src/rendering/htmlPolicy.d.ts +76 -0
  165. package/lib/src/rendering/markdownConverter.d.ts +73 -0
  166. package/lib/src/security/PolicyDecisionPoint.d.ts +245 -0
  167. package/lib/src/security/PolicyInformationPoint.d.ts +448 -0
  168. package/lib/src/security/pageActions.d.ts +40 -0
  169. package/lib/src/security/permissions.generated.d.ts +78 -0
  170. package/lib/src/types/Asset.d.ts +414 -0
  171. package/lib/src/types/Catalog.d.ts +61 -0
  172. package/lib/src/types/Comment.d.ts +11 -0
  173. package/lib/src/types/Config.d.ts +388 -0
  174. package/lib/src/types/Organization.d.ts +78 -0
  175. package/lib/src/types/OrganizationProvider.d.ts +38 -0
  176. package/lib/src/types/Page.d.ts +220 -0
  177. package/lib/src/types/Person.d.ts +56 -0
  178. package/lib/src/types/PersonProvider.d.ts +25 -0
  179. package/lib/src/types/Policy.d.ts +139 -0
  180. package/lib/src/types/Policy.js +17 -0
  181. package/lib/src/types/Provider.d.ts +810 -0
  182. package/lib/src/types/Role.d.ts +84 -0
  183. package/lib/src/types/RoleProvider.d.ts +35 -0
  184. package/lib/src/types/Schema.d.ts +425 -0
  185. package/lib/src/types/Share.d.ts +172 -0
  186. package/lib/src/types/Share.js +81 -0
  187. package/lib/src/types/User.d.ts +304 -0
  188. package/lib/src/types/Version.d.ts +189 -0
  189. package/lib/src/types/WikiEngine.d.ts +128 -0
  190. package/lib/src/types/express.d.ts +120 -0
  191. package/lib/src/types/express.js +1 -0
  192. package/lib/src/types/guards.d.ts +78 -0
  193. package/lib/src/types/heic-decode.d.ts +16 -0
  194. package/lib/src/types/index.d.ts +19 -0
  195. package/lib/src/types/linkedom.d.ts +77 -0
  196. package/lib/src/types/markdown-it-plugins.d.ts +21 -0
  197. package/lib/src/utils/DeltaStorage.d.ts +118 -0
  198. package/lib/src/utils/LocaleUtils.d.ts +105 -0
  199. package/lib/src/utils/LocaleUtils.js +294 -0
  200. package/lib/src/utils/PageNameMatcher.d.ts +98 -0
  201. package/lib/src/utils/PathPreflight.d.ts +38 -0
  202. package/lib/src/utils/PathPreflight.js +50 -0
  203. package/lib/src/utils/SectionUtils.d.ts +40 -0
  204. package/lib/src/utils/addonConfigLayer.d.ts +144 -0
  205. package/lib/src/utils/addonConfigLayer.js +382 -0
  206. package/lib/src/utils/addonDatabaseRules.d.ts +25 -0
  207. package/lib/src/utils/addonDatabaseRules.js +57 -0
  208. package/lib/src/utils/addonHost.d.ts +51 -0
  209. package/lib/src/utils/addonHost.js +72 -0
  210. package/lib/src/utils/addonInstaller.d.ts +109 -0
  211. package/lib/src/utils/addonLock.d.ts +37 -0
  212. package/lib/src/utils/addonLock.js +48 -0
  213. package/lib/src/utils/addonPageSync.d.ts +45 -0
  214. package/lib/src/utils/addonProvenance.d.ts +48 -0
  215. package/lib/src/utils/addonTarball.d.ts +41 -0
  216. package/lib/src/utils/addonsPathResolver.d.ts +76 -0
  217. package/lib/src/utils/addonsPathResolver.js +129 -0
  218. package/lib/src/utils/assetMetadataTags.d.ts +66 -0
  219. package/lib/src/utils/atomicWrite.d.ts +28 -0
  220. package/lib/src/utils/auditConfigChange.d.ts +57 -0
  221. package/lib/src/utils/auditEventNames.d.ts +50 -0
  222. package/lib/src/utils/auditEventNames.generated.d.ts +169 -0
  223. package/lib/src/utils/auditEventNames.generated.js +174 -0
  224. package/lib/src/utils/auditEventNames.js +49 -0
  225. package/lib/src/utils/auditEvents.d.ts +265 -0
  226. package/lib/src/utils/auditEvents.js +309 -0
  227. package/lib/src/utils/auditRegistry.d.ts +102 -0
  228. package/lib/src/utils/auditRegistry.js +168 -0
  229. package/lib/src/utils/bip39English.d.ts +2 -0
  230. package/lib/src/utils/configEnvKeys.d.ts +68 -0
  231. package/lib/src/utils/configFiles.d.ts +74 -0
  232. package/lib/src/utils/configFiles.js +150 -0
  233. package/lib/src/utils/delegation.d.ts +48 -0
  234. package/lib/src/utils/deriveUsername.d.ts +21 -0
  235. package/lib/src/utils/explainMediaPath.d.ts +123 -0
  236. package/lib/src/utils/formerTitles.d.ts +69 -0
  237. package/lib/src/utils/frontmatterAccess.d.ts +54 -0
  238. package/lib/src/utils/headlessAdminPassword.d.ts +55 -0
  239. package/lib/src/utils/imageTransform.d.ts +52 -0
  240. package/lib/src/utils/instanceEnvSecret.d.ts +51 -0
  241. package/lib/src/utils/jobSlots.d.ts +43 -0
  242. package/lib/src/utils/keywordNormalizer.d.ts +127 -0
  243. package/lib/src/utils/logger.d.ts +70 -0
  244. package/lib/src/utils/logger.js +106 -0
  245. package/lib/src/utils/magicLinkDeviceState.d.ts +95 -0
  246. package/lib/src/utils/managerUtils.d.ts +40 -0
  247. package/lib/src/utils/migrateLegacyPrivateAttachments.d.ts +15 -0
  248. package/lib/src/utils/orgFilename.d.ts +22 -0
  249. package/lib/src/utils/pageFeature.d.ts +27 -0
  250. package/lib/src/utils/pageFrontmatter.d.ts +21 -0
  251. package/lib/src/utils/pageNotes.d.ts +150 -0
  252. package/lib/src/utils/pageTitleRule.d.ts +37 -0
  253. package/lib/src/utils/pageToArticle.d.ts +59 -0
  254. package/lib/src/utils/pageUrl.d.ts +18 -0
  255. package/lib/src/utils/passwordChange.d.ts +12 -0
  256. package/lib/src/utils/passwordHash.d.ts +60 -0
  257. package/lib/src/utils/permissionCatalog.d.ts +52 -0
  258. package/lib/src/utils/pluginFormatters.d.ts +452 -0
  259. package/lib/src/utils/pluginFormatters.js +714 -0
  260. package/lib/src/utils/privateLinkRewrite.d.ts +42 -0
  261. package/lib/src/utils/privateStoreAccess.d.ts +57 -0
  262. package/lib/src/utils/privateStoreAccess.js +65 -0
  263. package/lib/src/utils/privateStoreCatalogs.d.ts +40 -0
  264. package/lib/src/utils/privateStoreCrypto.d.ts +127 -0
  265. package/lib/src/utils/privateStoreDoor.d.ts +181 -0
  266. package/lib/src/utils/privateStoreExport.d.ts +72 -0
  267. package/lib/src/utils/privateStoreFiles.d.ts +120 -0
  268. package/lib/src/utils/privateStoreMeta.d.ts +64 -0
  269. package/lib/src/utils/privateStoreMigrations.d.ts +37 -0
  270. package/lib/src/utils/privateStorePath.d.ts +259 -0
  271. package/lib/src/utils/privateStorePath.js +436 -0
  272. package/lib/src/utils/privateStoreTakeout.d.ts +76 -0
  273. package/lib/src/utils/privateStoreUnlock.d.ts +175 -0
  274. package/lib/src/utils/proxyClaim.d.ts +59 -0
  275. package/lib/src/utils/proxyClaim.js +30 -0
  276. package/lib/src/utils/redactPrivateNames.d.ts +21 -0
  277. package/lib/src/utils/redactPrivateNames.js +89 -0
  278. package/lib/src/utils/redactSecrets.d.ts +58 -0
  279. package/lib/src/utils/redactSecrets.js +171 -0
  280. package/lib/src/utils/renameLinkRewrite.d.ts +112 -0
  281. package/lib/src/utils/roleGrants.d.ts +35 -0
  282. package/lib/src/utils/safeRedirect.d.ts +32 -0
  283. package/lib/src/utils/schedule.d.ts +54 -0
  284. package/lib/src/utils/secretFileMode.d.ts +17 -0
  285. package/lib/src/utils/seededShippedPages.d.ts +45 -0
  286. package/lib/src/utils/sensitiveValues.d.ts +59 -0
  287. package/lib/src/utils/sensitiveValues.js +106 -0
  288. package/lib/src/utils/sessionEnd.d.ts +12 -0
  289. package/lib/src/utils/sessionGeneration.d.ts +24 -0
  290. package/lib/src/utils/sessionIdle.d.ts +41 -0
  291. package/lib/src/utils/sessionLimits.d.ts +68 -0
  292. package/lib/src/utils/shareLockbox.d.ts +64 -0
  293. package/lib/src/utils/sigstoreTrustedRoot.d.ts +33 -0
  294. package/lib/src/utils/sniffMime.d.ts +21 -0
  295. package/lib/src/utils/storeSearchIndex.d.ts +75 -0
  296. package/lib/src/utils/subjectMayDo.d.ts +21 -0
  297. package/lib/src/utils/systemCategoryRules.d.ts +30 -0
  298. package/lib/src/utils/systemCategoryRules.js +41 -0
  299. package/lib/src/utils/userCreateError.d.ts +62 -0
  300. package/lib/src/utils/username.d.ts +53 -0
  301. package/lib/src/utils/vaultUrlRewrite.d.ts +27 -0
  302. package/lib/src/utils/version.d.ts +84 -0
  303. package/lib/src/utils/videoFrame.d.ts +21 -0
  304. package/package.json +54 -3
@@ -0,0 +1,210 @@
1
+ import type { IncomingMessage, ServerResponse } from 'http';
2
+ import BaseManager, { type BackupData } from './BaseManager.js';
3
+ import type { AuditEvent as OidcAuditEvent, SignInContext } from '@jwilleke/oidc-auth-server';
4
+ import type { PermissionSubject } from './UserManager.js';
5
+ import type { WikiEngine } from '../types/WikiEngine.js';
6
+ export declare const OIDC_PREFIX = "oidc-auth-server.";
7
+ export declare const OIDC_ENABLED_KEY = "oidc-auth-server.enabled";
8
+ /** Where the provider is mounted, below the base-url. */
9
+ export declare const OIDC_MOUNT = "/oidc";
10
+ /** ngdpbase's own sign-in and consent route for a pending interaction (#1572). */
11
+ export declare const OIDC_INTERACTION_PREFIX = "/interaction/";
12
+ /** The package reads these from the environment only; they are generated here when unset. */
13
+ export declare const OIDC_JWKS_ENV = "OIDC_AUTH_SERVER_JWKS";
14
+ export declare const OIDC_COOKIE_KEYS_ENV = "OIDC_AUTH_SERVER_COOKIE_KEYS";
15
+ /** The `acr` values ngdpbase's sign-in record can carry (SessionSignIn.acr). */
16
+ export declare const NGDPBASE_ACR_VALUES: string[];
17
+ /**
18
+ * The claim that says the account is a test account (#1805): always a boolean,
19
+ * so a client can tell "real" (`false`) from "not asked" (absent). Released
20
+ * with the `profile` scope — the provider drops any claim no scope names.
21
+ */
22
+ export declare const TEST_ACCOUNT_CLAIM = "test_account";
23
+ /** The package's scope-to-claims map with `test_account` added to `profile`. */
24
+ export declare function withTestAccountClaim(scopeClaims: Record<string, string[]> | undefined): Record<string, string[]>;
25
+ type Handler = (req: IncomingMessage, res: ServerResponse) => Promise<void>;
26
+ type OidcPackage = typeof import('@jwilleke/oidc-auth-server');
27
+ type AuthServer = ReturnType<OidcPackage['createAuthServer']>;
28
+ /** ngdpbase's own API as a resource server: tokens for it name this audience (#1576). */
29
+ export declare function apiResourceFor(baseUrl: string): string;
30
+ /**
31
+ * The AAL a token's `acr` stands for (#1576). `acr` names the strongest
32
+ * phishing resistance when there is one, hiding the level behind it, so
33
+ * `phr` and `phrh` read conservatively as 2: `phrh` reaches AAL3 only with
34
+ * more than a token says, and no shipped role needs AAL3. Unknown reads as 1.
35
+ */
36
+ export declare function aalOfAcr(acr: unknown): 1 | 2 | 3;
37
+ /** The permissions an app may be delegated: every defined one a delegation may carry. */
38
+ export declare function delegablePermissions(definitions: unknown): string[];
39
+ /** What a verified access token for ngdpbase's API stands for. */
40
+ export interface VerifiedAccessToken {
41
+ username: string;
42
+ clientId: string;
43
+ grantId: string;
44
+ scopes: string[];
45
+ aal: 1 | 2 | 3;
46
+ }
47
+ /** The issuer for a base-url: no trailing slash, the mount appended. */
48
+ export declare function issuerFor(baseUrl: string): string;
49
+ /** Plain HTTP is allowed only on this machine, where there is no wire to protect. */
50
+ export declare function isLoopbackHttp(issuer: string): boolean;
51
+ /** The operator's `oidc-auth-server.*` keys, minus ngdpbase's own; a derived key set by hand is a problem. */
52
+ export declare function operatorOidcConfig(custom: Record<string, unknown>): {
53
+ config: Record<string, unknown>;
54
+ problems: string[];
55
+ };
56
+ /** One app or device a person approved, as their profile lists it (#1601). */
57
+ export interface ApprovedApp {
58
+ grantId: string;
59
+ clientId: string;
60
+ name: string;
61
+ /** Approved through the device flow (RFC 8628): the client may use the device grant. */
62
+ device: boolean;
63
+ /** Everything the grant allows: OIDC scopes and API scopes, de-duplicated. */
64
+ scopes: string[];
65
+ /** ISO 8601. */
66
+ approvedAt: string | null;
67
+ expiresAt: string | null;
68
+ /**
69
+ * The app holds a refresh key, so its access is renewed automatically with
70
+ * a new key each time (#1764). False: it has only what it was given, which
71
+ * ends with the grant.
72
+ */
73
+ refreshable: boolean;
74
+ /** ISO 8601: when its key was last renewed; null when it has not been yet (#1764). */
75
+ renewedAt: string | null;
76
+ /** #1762 slice 6: who approved it while acting for this person; null when they approved it themselves. */
77
+ approvedBy: string | null;
78
+ /** The proxy grant it was approved under; null when the person approved it. */
79
+ proxyGrantId: string | null;
80
+ }
81
+ /** One RSA signing key as a JWKS, the shape OIDC_AUTH_SERVER_JWKS holds. */
82
+ export declare function generateJwks(): string;
83
+ export declare class OidcManager extends BaseManager {
84
+ private store;
85
+ private options;
86
+ private pkg;
87
+ private auth;
88
+ private issuer;
89
+ private apiResource;
90
+ /** The permissions an app may ask for on ngdpbase's API (`delegablePermissions`). */
91
+ private apiScopes;
92
+ constructor(engine: WikiEngine);
93
+ initialize(config?: Record<string, unknown>): Promise<void>;
94
+ /**
95
+ * Build the server with the `trust proxy` decision app.ts made for Express.
96
+ * Returns null when the manager is off or refused; the caller mounts nothing.
97
+ */
98
+ start(settings: {
99
+ trustProxy: boolean;
100
+ }): Handler | null;
101
+ /** The package's interaction helpers for the sign-in bridge (#1572); null when not serving. */
102
+ interactions(): AuthServer['interactions'] | null;
103
+ /**
104
+ * The pending request's own parameters (`prompt`, `max_age`, …), which the
105
+ * package's `details()` does not carry, and when it began (epoch seconds).
106
+ * The bridge reads them to refuse a request for a fresh sign-in it cannot
107
+ * give yet (#1525), and to accept one made after the request began.
108
+ */
109
+ pendingRequest(req: IncomingMessage, res: ServerResponse): Promise<{
110
+ params: Record<string, unknown>;
111
+ startedAt: number;
112
+ }>;
113
+ /** The audience a token for ngdpbase's API names; empty when off. */
114
+ getApiResource(): string;
115
+ /**
116
+ * Verify an access token presented to ngdpbase's API (#1576), in process:
117
+ * it must exist, be unexpired, name this API as its audience, not be bound
118
+ * to a key we do not check, and belong to an account that still passes
119
+ * findAccount (active; no password change since the sign-in, #1592).
120
+ * Null otherwise — never a reason, since the caller is unauthenticated.
121
+ */
122
+ verifyAccessToken(token: string): Promise<VerifiedAccessToken | null>;
123
+ /**
124
+ * Why `subject` may not approve an app asking for `scope`, in plain words,
125
+ * or null when they may (#1762 slice 6). Only someone acting for the person
126
+ * under a proxy grant is asked: each permission the app asks for on
127
+ * ngdpbase's API must be one the decision point permits that subject, which
128
+ * under a proxy is the grant, the represented person and the person acting
129
+ * all at once. The person themselves is not asked, as before: what an app
130
+ * of theirs can do is bounded by what they hold, at every use.
131
+ */
132
+ proxyApprovalRefusal(subject: PermissionSubject, scope: string): Promise<string | null>;
133
+ /**
134
+ * Finish the consent step (#1572) for `subject`. Acting for someone (#1762
135
+ * slice 6), the approval is also recorded beside the grant: who approved it
136
+ * and under which proxy grant, so the profile can say so, ending the proxy
137
+ * grant revokes it, and it works only while that grant is in force. Recorded
138
+ * in the audit log as an approval naming both people.
139
+ */
140
+ finishConsent(req: IncomingMessage, res: ServerResponse, subject: PermissionSubject): Promise<void>;
141
+ /** The proxy approvals of live grants, by grant id (#1762 slice 6). */
142
+ private proxyApprovals;
143
+ /**
144
+ * An app approved under a proxy grant works only while that grant is in
145
+ * force (#1762 slice 6), asked of AuthManager, which owns the grants; no
146
+ * answer is a refusal. One the person approved is not affected.
147
+ */
148
+ private approvalInForce;
149
+ /**
150
+ * The apps and devices `username` approved (#1601): one per live grant,
151
+ * newest first. Empty when the provider is off.
152
+ */
153
+ listGrants(username: string): Promise<ApprovedApp[]>;
154
+ /**
155
+ * End one of `username`'s grants and every code and token under it (#1601).
156
+ * False when no such grant is theirs — never revokes another person's.
157
+ * Recorded as oidcgrant-revoke by whoever revoked it (`by`, the owner when
158
+ * not given), naming the owner, as an agent token's revoke is (#1764);
159
+ * under a proxy grant, naming the person acting too (#1762 slice 6).
160
+ */
161
+ revokeGrant(username: string, grantId: string, by: PermissionSubject): Promise<boolean>;
162
+ /** What to call a client on the consent page: its registered name, else its id. */
163
+ clientName(clientId: string): Promise<string>;
164
+ /**
165
+ * End every provider session of an account (#1572), so signing out of
166
+ * ngdpbase also signs out of /oidc: the provider's own session cookie would
167
+ * otherwise keep finishing sign-ins for someone who left. Grants stay —
168
+ * consent is remembered — and tokens already issued run to their expiry.
169
+ */
170
+ endSessionsFor(username: string): Promise<number>;
171
+ /** The issuer once configured; empty when off. */
172
+ getIssuer(): string;
173
+ /**
174
+ * The person's claims for the package, or undefined — which fails the
175
+ * request closed — when the account is gone or disabled, or when this
176
+ * sign-in is older than the account's last password change (#1592): an app
177
+ * keeps nothing past a password change, as no web session does (#1482).
178
+ * Never roles: a session can hold fewer roles than the account (#1569).
179
+ * `test_account` is always a boolean (#1805), released with `profile`.
180
+ */
181
+ findAccount(accountId: string, signIn?: SignInContext): Promise<Record<string, unknown> | undefined>;
182
+ /**
183
+ * Record one provider event in ngdpbase's audit log (#1575). The package
184
+ * never passes a token, code or secret; the person is the account, the
185
+ * resource is the app. Returns the promise so the package can count a
186
+ * report the sink failed to take.
187
+ */
188
+ recordEvent(event: OidcAuditEvent): Promise<void>;
189
+ /**
190
+ * One provider event into the audit log. `revoker` is ngdpbase's own
191
+ * revoke (#1764): the record is by the person who revoked, naming the
192
+ * owner; under a proxy grant `user` is the represented person and `actor`
193
+ * the person acting (#1762 slice 6). Null for the provider's own events.
194
+ */
195
+ private writeEvent;
196
+ shutdown(): Promise<void>;
197
+ /**
198
+ * Who had granted which client access, for incident response — not a
199
+ * restorable copy. The store's rows are short-lived or hold presentable
200
+ * session ids; a restored one would revive access somebody may have ended.
201
+ */
202
+ backup(): Promise<BackupData>;
203
+ /** Refuse: there is nothing to restore from; people sign in again and clients re-consent. */
204
+ restore(_backupData: BackupData): Promise<void>;
205
+ /** Generate the signing keys and cookie keys into the instance .env when nothing supplies them. */
206
+ private ensureKeys;
207
+ /** Enabled but unusable: say why, loudly, and mount nothing. */
208
+ private refuse;
209
+ }
210
+ export default OidcManager;
@@ -0,0 +1,107 @@
1
+ import BaseManager, { type ManagerStats } from './BaseManager.js';
2
+ import type { WikiEngine } from '../types/WikiEngine.js';
3
+ import type { Organization, OrganizationUpdate } from '../types/Organization.js';
4
+ import type { OrganizationProvider } from '../types/OrganizationProvider.js';
5
+ /**
6
+ * Subset of install-form data this manager needs to seed the anchor org.
7
+ * Kept narrow so InstallService and tests can pass plain objects without
8
+ * importing the full InstallData type.
9
+ */
10
+ export interface OrganizationSeedData {
11
+ orgName: string;
12
+ orgLegalName?: string;
13
+ orgDescription?: string;
14
+ orgFoundingDate?: string;
15
+ orgUrl?: string;
16
+ orgAddressLocality?: string;
17
+ orgAddressRegion?: string;
18
+ orgAddressCountry?: string;
19
+ /** Email used for the install's primary technical contact. */
20
+ adminEmail?: string;
21
+ /** Filename to write under storagedir, e.g. "acme-corporation.json". */
22
+ filename?: string;
23
+ }
24
+ /**
25
+ * OrganizationManager — canonical core record for organizations (#617).
26
+ *
27
+ * Owns the on-disk Organization records end-to-end. The install's anchor
28
+ * org is identified by `ngdpbase.application.organization.file`; the rest
29
+ * of the org files in `storagedir` are additional orgs in a multi-org
30
+ * install. UserManager resolves `Person.memberOf` via `getInstallOrg()`,
31
+ * so the anchor org is the implicit parent for every user-paired Person.
32
+ */
33
+ declare class OrganizationManager extends BaseManager {
34
+ readonly description = "Canonical Organization records (#617)";
35
+ private provider;
36
+ private providerClass?;
37
+ private installOrgCache;
38
+ private byIdCache;
39
+ private byFileCache;
40
+ private metricsRef;
41
+ constructor(engine: WikiEngine);
42
+ initialize(config?: Record<string, unknown>): Promise<void>;
43
+ /** Provider accessor, mainly for tests. */
44
+ getProvider(): OrganizationProvider | null;
45
+ /**
46
+ * Create the anchor organization from the instance's own identity (#1027).
47
+ *
48
+ * Written to the organizations storage directory like any other record, so it
49
+ * is editable through the admin UI afterwards. That is the point: an org
50
+ * supplied by the deployment (a mounted ConfigMap file, say) is read-only and
51
+ * cannot be corrected without a redeploy. Application configuration should
52
+ * not require editing deployment manifests.
53
+ *
54
+ * Filename follows the convention the install wizard uses — the base-url host
55
+ * with dots as hyphens — so an instance seeded here and one installed through
56
+ * the wizard are indistinguishable afterwards.
57
+ */
58
+ private seedAnchorOrganization;
59
+ /**
60
+ * Return the install's anchor org, resolving or seeding one if needed (#1027).
61
+ *
62
+ * Three tiers, in order:
63
+ *
64
+ * 1. `ngdpbase.application.organization.file` names it — what the install
65
+ * wizard writes.
66
+ * 2. No key, but exactly one org record exists — adopt it. An install with
67
+ * a single organization has no ambiguity about which one anchors it, and
68
+ * requiring a config key to state the obvious is what left headless
69
+ * deployments silently unable to assign any role.
70
+ * 3. Nothing at all — seed a minimal record from the instance's own
71
+ * identity. An instance always belongs to *something*; having no anchor
72
+ * is never the correct end state, it just breaks role assignment.
73
+ *
74
+ * Deliberately never writes the config key back. Instance config is a
75
+ * read-only mount on containerised deployments, so a resolution strategy that
76
+ * depends on persisting a key would work locally and fail exactly where this
77
+ * problem actually bites.
78
+ */
79
+ getInstallOrg(): Promise<Organization | null>;
80
+ getById(id: string): Promise<Organization | null>;
81
+ getByFile(filename: string): Promise<Organization | null>;
82
+ /** #1006: how many organizations this instance holds. Count only. */
83
+ getManagerStats(): Promise<ManagerStats>;
84
+ list(): Promise<Organization[]>;
85
+ create(org: Organization, filename?: string): Promise<Organization>;
86
+ update(id: string, patch: OrganizationUpdate): Promise<Organization | null>;
87
+ delete(id: string): Promise<boolean>;
88
+ /**
89
+ * Clear all caches. Called on every write — the simplest correct
90
+ * invalidation. Per-key invalidation can come later if needed.
91
+ * Public so callers (e.g., admin "rebuild" tools) can force a cache miss.
92
+ */
93
+ invalidateCache(): void;
94
+ /**
95
+ * Seed the install's anchor org from install-form data. Idempotent: if an
96
+ * org file with the configured filename already exists, this is a no-op
97
+ * (returns the existing record). The org JSON-LD file at
98
+ * `<storagedir>/<file>` is the single source of truth for `name`, `url`,
99
+ * `address`, etc. — those fields live IN THE FILE, not in config. Config
100
+ * holds only the pointer (`ngdpbase.application.organization.file`).
101
+ */
102
+ seedFromConfig(data: OrganizationSeedData): Promise<Organization | null>;
103
+ private requireProvider;
104
+ private getMetrics;
105
+ private normalizeProviderName;
106
+ }
107
+ export default OrganizationManager;