@getstrata/core 2.2.60 → 3.0.3

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 (330) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/core/audit/exportAuditLogs.d.ts +12 -3
  3. package/dist/core/audit/exportStore.d.ts +6 -2
  4. package/dist/core/audit/siemFormatter.d.ts +2 -2
  5. package/dist/core/auth/abilityCatalog.d.ts +1 -9
  6. package/dist/core/auth/authContext.d.ts +2 -0
  7. package/dist/core/auth/authOutcome.d.ts +32 -0
  8. package/dist/core/auth/authReader.d.ts +22 -0
  9. package/dist/core/auth/basicAuthGuard.d.ts +19 -3
  10. package/dist/core/auth/emailVerification.d.ts +1 -1
  11. package/dist/core/auth/guard.d.ts +27 -6
  12. package/dist/core/auth/intendedUrlCookie.d.ts +13 -7
  13. package/dist/core/auth/jwt.d.ts +5 -4
  14. package/dist/core/auth/jwtGuard.d.ts +7 -6
  15. package/dist/core/auth/membershipContext.d.ts +10 -7
  16. package/dist/core/auth/membershipContextMiddleware.d.ts +3 -3
  17. package/dist/core/auth/membershipMiddleware.d.ts +1 -2
  18. package/dist/core/auth/membershipServiceImplementation.d.ts +1 -1
  19. package/dist/core/auth/oauth/oidcIdToken.d.ts +25 -16
  20. package/dist/core/auth/oauth/oidcProvider.d.ts +6 -4
  21. package/dist/core/auth/oauth/providers.d.ts +3 -1
  22. package/dist/core/auth/oneTimeToken.d.ts +2 -3
  23. package/dist/core/auth/passwordConfirmCookie.d.ts +15 -6
  24. package/dist/core/auth/passwordLogin.d.ts +5 -5
  25. package/dist/core/auth/pendingMfaCookie.d.ts +2 -2
  26. package/dist/core/auth/policy.d.ts +23 -10
  27. package/dist/core/auth/requireAuthCapability.d.ts +3 -0
  28. package/dist/core/auth/resolveMembershipService.d.ts +3 -2
  29. package/dist/core/auth/saml/samlAssertionReplay.d.ts +4 -4
  30. package/dist/core/auth/saml/samlServiceProvider.d.ts +11 -7
  31. package/dist/core/auth/scimAuthMiddleware.d.ts +10 -3
  32. package/dist/core/auth/sessionCookie.d.ts +20 -9
  33. package/dist/core/auth/sessionGuard.d.ts +14 -3
  34. package/dist/core/cache/createCacheStore.d.ts +6 -3
  35. package/dist/core/cache/redisCacheStore.d.ts +5 -1
  36. package/dist/core/cache/repository.d.ts +5 -1
  37. package/dist/core/cache/simpleCache.d.ts +2 -1
  38. package/dist/core/cache/tokens.d.ts +8 -0
  39. package/dist/core/config/applicationConfig.d.ts +21 -0
  40. package/dist/core/config/configSnapshot.d.ts +3 -0
  41. package/dist/core/config/envSchema.d.ts +3 -2
  42. package/dist/core/contracts/application.d.ts +153 -0
  43. package/dist/core/contracts/authUserDirectory.d.ts +24 -7
  44. package/dist/core/contracts/container.d.ts +20 -23
  45. package/dist/core/contracts/di.d.ts +4 -2
  46. package/dist/core/contracts/executionContext.d.ts +5 -0
  47. package/dist/core/contracts/executionOperations.d.ts +10 -0
  48. package/dist/core/contracts/executionOwnership.d.ts +38 -0
  49. package/dist/core/contracts/persistence.d.ts +20 -0
  50. package/dist/core/contracts/serviceTokens.d.ts +32 -18
  51. package/dist/core/contracts/services.d.ts +63 -0
  52. package/dist/core/contracts/token.d.ts +19 -0
  53. package/dist/core/crypto/fieldEncryption.d.ts +19 -7
  54. package/dist/core/crypto/fieldEncryptionRotation.d.ts +21 -5
  55. package/dist/core/crypto/mfaSecret.d.ts +10 -3
  56. package/dist/core/database/baseRepository.d.ts +14 -10
  57. package/dist/core/database/bindings.d.ts +6 -0
  58. package/dist/core/database/bunSql.d.ts +3 -12
  59. package/dist/core/database/definitions.d.ts +209 -0
  60. package/dist/core/database/dialect.d.ts +5 -24
  61. package/dist/core/database/driverPorts.d.ts +116 -0
  62. package/dist/core/database/errors.d.ts +47 -7
  63. package/dist/core/database/factory.d.ts +51 -31
  64. package/dist/core/database/index.d.ts +9 -10
  65. package/dist/core/database/keyset.d.ts +2 -1
  66. package/dist/core/database/legacyNativeTransaction.d.ts +5 -0
  67. package/dist/core/database/manager.d.ts +12 -0
  68. package/dist/core/database/model.d.ts +91 -97
  69. package/dist/core/database/modelQuery.d.ts +9 -5
  70. package/dist/core/database/modelRegistry.d.ts +52 -33
  71. package/dist/core/database/mysqlConnection.d.ts +1 -19
  72. package/dist/core/database/mysqlNative.d.ts +38 -0
  73. package/dist/core/database/nativeTransactions.d.ts +16 -0
  74. package/dist/core/database/ormInternal.d.ts +85 -0
  75. package/dist/core/database/ormRuntime.d.ts +4 -0
  76. package/dist/core/database/ownedReadOnlyObservation.d.ts +16 -0
  77. package/dist/core/database/postgresNative.d.ts +11 -0
  78. package/dist/core/database/query.d.ts +24 -23
  79. package/dist/core/database/queryPlanSnapshot.d.ts +7 -0
  80. package/dist/core/database/rawMysql.d.ts +7 -0
  81. package/dist/core/database/rawPostgres.d.ts +23 -0
  82. package/dist/core/database/rawSqlite.d.ts +6 -0
  83. package/dist/core/database/relationQueries.d.ts +3 -2
  84. package/dist/core/database/relationQuery.d.ts +24 -6
  85. package/dist/core/database/repositoryQuery.d.ts +6 -1
  86. package/dist/core/database/schema/driver.d.ts +1 -1
  87. package/dist/core/database/seeders/types.d.ts +1 -1
  88. package/dist/core/database/session.d.ts +13 -0
  89. package/dist/core/database/sessionFactory.d.ts +9 -0
  90. package/dist/core/database/sqlDialects.d.ts +22 -0
  91. package/dist/core/database/tokens.d.ts +7 -0
  92. package/dist/core/database/transactionSession.d.ts +43 -0
  93. package/dist/core/errors/http.d.ts +4 -1
  94. package/dist/core/events/{eventBus.d.ts → eventBusClass.d.ts} +1 -3
  95. package/dist/core/events/index.d.ts +2 -3
  96. package/dist/core/events/outbox/index.d.ts +44 -13
  97. package/dist/core/events/outbox/metrics.d.ts +4 -4
  98. package/dist/core/events/outbox/workerTransport.d.ts +17 -0
  99. package/dist/core/http/authMiddleware.d.ts +2 -2
  100. package/dist/core/http/authorizeMiddleware.d.ts +2 -2
  101. package/dist/core/http/bodySizeLimitMiddleware.d.ts +1 -1
  102. package/dist/core/http/conditionalResponse.d.ts +7 -2
  103. package/dist/core/http/contentSecurityPolicy.d.ts +4 -3
  104. package/dist/core/http/corsMiddleware.d.ts +2 -1
  105. package/dist/core/http/csrfMiddleware.d.ts +6 -1
  106. package/dist/core/http/csrfToken.d.ts +17 -7
  107. package/dist/core/http/databaseError.d.ts +4 -0
  108. package/dist/core/http/etag.d.ts +5 -2
  109. package/dist/core/http/flashMiddleware.d.ts +1 -1
  110. package/dist/core/http/flashSession.d.ts +13 -7
  111. package/dist/core/http/index.d.ts +1 -1
  112. package/dist/core/http/loginThrottleMiddleware.d.ts +3 -3
  113. package/dist/core/http/memoryThrottleMiddleware.d.ts +2 -2
  114. package/dist/core/http/parseMultipartUpload.d.ts +3 -2
  115. package/dist/core/http/requestMetaContext.d.ts +5 -0
  116. package/dist/core/http/requireAbilityMiddleware.d.ts +1 -1
  117. package/dist/core/http/requireAuthMiddleware.d.ts +2 -2
  118. package/dist/core/http/requirePasswordConfirmMiddleware.d.ts +2 -1
  119. package/dist/core/http/requireVerifiedMiddleware.d.ts +2 -2
  120. package/dist/core/http/requireWebAuthMiddleware.d.ts +2 -2
  121. package/dist/core/http/response.d.ts +4 -3
  122. package/dist/core/http/scimThrottleMiddleware.d.ts +4 -3
  123. package/dist/core/http/securedRouteModelBinding.d.ts +10 -3
  124. package/dist/core/http/securityHeadersMiddleware.d.ts +1 -2
  125. package/dist/core/http/signedUrl.d.ts +8 -6
  126. package/dist/core/http/throttleMiddleware.d.ts +9 -5
  127. package/dist/core/http/uploads.d.ts +9 -3
  128. package/dist/core/http/webErrorResponse.d.ts +8 -2
  129. package/dist/core/jobs/exportAuditLogsJob.d.ts +5 -2
  130. package/dist/core/jobs/invalidateCacheTagsJob.d.ts +5 -4
  131. package/dist/core/lifecycle/gracefulShutdown.d.ts +2 -5
  132. package/dist/core/logging/requestLoggingMiddleware.d.ts +1 -1
  133. package/dist/core/mail/mailer.d.ts +7 -5
  134. package/dist/core/openapi/generator.d.ts +12 -4
  135. package/dist/core/openapi/registeredRoute.d.ts +4 -4
  136. package/dist/core/queue/createAppQueue.d.ts +9 -4
  137. package/dist/core/queue/failedJobMetrics.d.ts +11 -2
  138. package/dist/core/queue/failedJobRepository.d.ts +6 -3
  139. package/dist/core/queue/failedJobService.d.ts +1 -0
  140. package/dist/core/queue/index.d.ts +16 -6
  141. package/dist/core/queue/jobRegistry.d.ts +3 -2
  142. package/dist/core/queue/jobRunner.d.ts +10 -4
  143. package/dist/core/queue/publicQueue.d.ts +18 -9
  144. package/dist/core/queue/queueConfig.d.ts +20 -10
  145. package/dist/core/queue/queueHandoff.d.ts +31 -0
  146. package/dist/core/queue/queueMetrics.d.ts +10 -3
  147. package/dist/core/queue/queueServices.d.ts +28 -0
  148. package/dist/core/queue/queueWorkerTransport.d.ts +28 -0
  149. package/dist/core/queue/redisQueue.d.ts +19 -10
  150. package/dist/core/queue/redisQueueKeys.d.ts +5 -5
  151. package/dist/core/queue/redisStreams.d.ts +17 -10
  152. package/dist/core/queue/resilientQueue.d.ts +10 -4
  153. package/dist/core/queue/types.d.ts +1 -0
  154. package/dist/core/runtime/appKeyPrefix.d.ts +5 -5
  155. package/dist/core/runtime/application.d.ts +7 -0
  156. package/dist/core/runtime/executionContext.d.ts +9 -0
  157. package/dist/core/runtime/executionTasks.d.ts +49 -0
  158. package/dist/core/runtime/resourceJournal.d.ts +67 -0
  159. package/dist/core/runtime/serviceGraph.d.ts +14 -0
  160. package/dist/core/security/oauthState.d.ts +13 -9
  161. package/dist/core/security/publicReads.d.ts +2 -2
  162. package/dist/core/security/safeFetch.d.ts +1 -0
  163. package/dist/core/security/safeUrl.d.ts +3 -0
  164. package/dist/core/security/scimTenantTokens.d.ts +1 -1
  165. package/dist/core/security/tokenExpiry.d.ts +1 -1
  166. package/dist/core/security/webhookSignature.d.ts +1 -1
  167. package/dist/core/storage/storage.d.ts +24 -16
  168. package/dist/core/tenant/databaseTenantContext.d.ts +5 -7
  169. package/dist/core/tenant/resolveTenant.d.ts +2 -2
  170. package/dist/core/tenant/scopedDatabasePolicy.d.ts +8 -0
  171. package/dist/core/tenant/tenantDatabaseScope.d.ts +3 -7
  172. package/dist/core/tenant/tenantMiddleware.d.ts +15 -4
  173. package/dist/core/tracing/otel.d.ts +4 -6
  174. package/dist/core/tracing/tracingMiddleware.d.ts +3 -3
  175. package/dist/core/view/etaViewEngine.d.ts +1 -1
  176. package/dist/core/view/index.d.ts +5 -4
  177. package/dist/core/view/tokens.d.ts +8 -0
  178. package/dist/core/view/viewRenderer.d.ts +2 -2
  179. package/dist/core/view/webErrorView.d.ts +8 -7
  180. package/dist/core/view/webLayoutData.d.ts +6 -4
  181. package/dist/entries/audit/exportAuditLogs.js +87 -1024
  182. package/dist/entries/audit/siemFormatter.js +4 -90
  183. package/dist/entries/auth/abilityCatalog.js +28 -0
  184. package/dist/entries/auth/accessControl.js +5 -16
  185. package/dist/entries/auth/accountStateMigration.js +216 -236
  186. package/dist/entries/auth/authOutcome.js +80 -0
  187. package/dist/entries/auth/authReader.js +68 -0
  188. package/dist/entries/auth/basicAuthGuard.js +144 -1249
  189. package/dist/entries/auth/emailVerification.js +2 -2
  190. package/dist/entries/auth/intendedUrlCookie.js +35 -59
  191. package/dist/entries/auth/jwt.js +22 -47
  192. package/dist/entries/auth/jwtGuard.js +99 -231
  193. package/dist/entries/auth/membershipMiddleware.js +71 -10
  194. package/dist/entries/auth/membershipScope.js +16 -22
  195. package/dist/entries/auth/membershipService.js +11 -28
  196. package/dist/entries/auth/oauth/oidcProvider.js +59 -64
  197. package/dist/entries/auth/oauth/providers.js +12 -95
  198. package/dist/entries/auth/oauth/samlProvider.js +53 -1080
  199. package/dist/entries/auth/oneTimeToken.js +27 -289
  200. package/dist/entries/auth/passwordConfirmCookie.js +40 -63
  201. package/dist/entries/auth/passwordLogin.js +94 -399
  202. package/dist/entries/auth/pendingMfaCookie.js +6 -6
  203. package/dist/entries/auth/policy.js +22 -56
  204. package/dist/entries/auth/saml/samlServiceProvider.js +55 -1084
  205. package/dist/entries/auth/scimAuthMiddleware.js +16 -3358
  206. package/dist/entries/auth/sessionCookie.js +58 -73
  207. package/dist/entries/auth/sessionGuard.js +95 -248
  208. package/dist/entries/auth/tokenHash.js +11 -43
  209. package/dist/entries/cache/createCacheStore.js +126 -117
  210. package/dist/entries/cache/repository.js +25 -0
  211. package/dist/entries/cache/simpleCache.js +12 -7
  212. package/dist/entries/cache/tokens.js +9 -0
  213. package/dist/entries/config/applicationConfig.js +163 -0
  214. package/dist/entries/config/envSchema.js +21 -4
  215. package/dist/entries/contracts/application.js +1 -0
  216. package/dist/entries/contracts/authUserDirectory.js +10 -0
  217. package/dist/entries/contracts/container.js +99 -26
  218. package/dist/entries/contracts/di.js +3 -0
  219. package/dist/entries/contracts/executionContext.js +7 -0
  220. package/dist/entries/contracts/executionOperations.js +7 -0
  221. package/dist/entries/contracts/executionOwnership.js +7 -0
  222. package/dist/entries/contracts/membership.js +1 -0
  223. package/dist/entries/contracts/persistence.js +1 -0
  224. package/dist/entries/contracts/serviceTokens.js +26 -116
  225. package/dist/entries/contracts/services.js +98 -0
  226. package/dist/entries/contracts/token.js +41 -0
  227. package/dist/entries/crypto/fieldEncryption.js +49 -50
  228. package/dist/entries/crypto/mfaSecret.js +86 -82
  229. package/dist/entries/database/acquisitionMetrics.js +107 -0
  230. package/dist/entries/database/baseRepository.d.ts +2 -0
  231. package/dist/entries/database/bindings.js +2082 -0
  232. package/dist/entries/database/definitions.js +175 -0
  233. package/dist/entries/database/errors.js +114 -89
  234. package/dist/entries/database/factory.js +67 -28
  235. package/dist/entries/database/migrations.js +172 -224
  236. package/dist/entries/database/model.d.ts +1 -0
  237. package/dist/entries/database/ownedReadOnlyObservation.js +1282 -0
  238. package/dist/entries/database/query.js +159 -161
  239. package/dist/entries/database/repositoryQuery.d.ts +1 -0
  240. package/dist/entries/database/repositoryQuery.js +1 -1373
  241. package/dist/entries/database/schema.js +216 -236
  242. package/dist/entries/database/session.js +1 -0
  243. package/dist/entries/database/sqliteConnection.js +525 -83
  244. package/dist/entries/database/tokens.js +9 -0
  245. package/dist/entries/errors/http.js +118 -1
  246. package/dist/entries/http/authMiddleware.js +8 -5
  247. package/dist/entries/http/authorizeMiddleware.js +1 -1
  248. package/dist/entries/http/bodySizeLimitMiddleware.js +2 -2
  249. package/dist/entries/http/clientIp.js +2 -2
  250. package/dist/entries/http/conditionalResponse.js +19 -7
  251. package/dist/entries/http/corsMiddleware.js +6 -101
  252. package/dist/entries/http/csrfMiddleware.js +92 -106
  253. package/dist/entries/http/csrfToken.js +58 -94
  254. package/dist/entries/http/etag.js +7 -4
  255. package/dist/entries/http/flashMiddleware.js +57 -99
  256. package/dist/entries/http/flashSession.js +41 -68
  257. package/dist/entries/http/memoryThrottleMiddleware.js +43 -186
  258. package/dist/entries/http/metricsMiddleware.js +2 -16
  259. package/dist/entries/http/parseMultipartUpload.js +15 -29
  260. package/dist/entries/http/requireAbilityMiddleware.js +2 -2
  261. package/dist/entries/http/requirePasswordConfirmMiddleware.js +19 -31
  262. package/dist/entries/http/requireVerifiedMiddleware.js +4 -7
  263. package/dist/entries/http/requireWebAuthMiddleware.js +2 -2
  264. package/dist/entries/http/response.js +67 -233
  265. package/dist/entries/http/routeMiddleware.js +0 -14
  266. package/dist/entries/http/scimThrottleMiddleware.js +43 -237
  267. package/dist/entries/http/securedRouteModelBinding.js +37 -25
  268. package/dist/entries/http/securityHeadersMiddleware.js +8 -25
  269. package/dist/entries/http/signedUrl.js +20 -110
  270. package/dist/entries/http/throttleMiddleware.js +41 -185
  271. package/dist/entries/http/uploads.js +9 -24
  272. package/dist/entries/jobs/exportAuditLogsJob.js +17 -1498
  273. package/dist/entries/jobs/invalidateCacheTagsJob.js +12 -47
  274. package/dist/entries/logging/requestLoggingMiddleware.js +4 -4
  275. package/dist/entries/mail/mailer.js +68 -78
  276. package/dist/entries/openapi/generator.js +33 -100
  277. package/dist/entries/queue/createAppQueue.js +416 -256
  278. package/dist/entries/queue/failedJobRepository.js +17 -8
  279. package/dist/entries/queue/failedJobService.js +1 -0
  280. package/dist/entries/queue/jobRunner.js +141 -66
  281. package/dist/entries/queue/publicQueue.js +411 -257
  282. package/dist/entries/queue/queueConfig.js +61 -0
  283. package/dist/entries/queue/queueHandoff.js +318 -0
  284. package/dist/entries/queue/queueMetrics.js +989 -1386
  285. package/dist/entries/queue/queueServices.js +133 -0
  286. package/dist/entries/queue/queueWorkerTransport.js +1703 -0
  287. package/dist/entries/queue/redisQueue.js +282 -180
  288. package/dist/entries/queue.js +6 -45
  289. package/dist/entries/runtime/application.js +1585 -0
  290. package/dist/entries/runtime/asyncContextStore.js +0 -16
  291. package/dist/entries/security/oauthState.js +35 -67
  292. package/dist/entries/security/publicReads.js +4 -4
  293. package/dist/entries/security/safeFetch.js +1 -0
  294. package/dist/entries/security/scimTenantTokens.js +3 -3
  295. package/dist/entries/security/tokenExpiry.js +2 -2
  296. package/dist/entries/security/totp.js +1 -87
  297. package/dist/entries/security/webhookSignature.js +2 -90
  298. package/dist/entries/storage/storage.js +120 -45
  299. package/dist/entries/tenant/databaseTenantContext.js +6 -907
  300. package/dist/entries/tenant/publicTenantHost.js +78 -0
  301. package/dist/entries/tenant/resolveTenant.js +14 -0
  302. package/dist/entries/tenant/scopedDatabasePolicy.js +75 -0
  303. package/dist/entries/tenant/tenancyConfig.js +1 -19
  304. package/dist/entries/tenant/tenantDatabaseScope.js +3 -892
  305. package/dist/entries/tracing/tracingMiddleware.js +104 -173
  306. package/dist/entries/view/tokens.js +11 -0
  307. package/dist/framework/public-api.d.ts +62 -44
  308. package/dist/index.js +10435 -11351
  309. package/dist/internal/ormInternal.js +117 -0
  310. package/dist/internal/ormRuntime.js +5000 -0
  311. package/package.json +158 -46
  312. package/dist/core/database/bindConnection.d.ts +0 -1
  313. package/dist/core/database/boundConnection.d.ts +0 -5
  314. package/dist/core/database/defaultConnection.d.ts +0 -7
  315. package/dist/core/database/namedConnections.d.ts +0 -15
  316. package/dist/core/database/readOnlyCollector.d.ts +0 -7
  317. package/dist/core/database/repositoryConnection.d.ts +0 -4
  318. package/dist/core/database/transaction.d.ts +0 -23
  319. package/dist/core/database/transactionControl.d.ts +0 -6
  320. package/dist/core/events/deferredModelEvents.d.ts +0 -7
  321. package/dist/core/facades/index.d.ts +0 -10
  322. package/dist/core/runtime/applicationRegistry.d.ts +0 -18
  323. package/dist/entries/database/bindConnection.js +0 -1
  324. package/dist/entries/database/boundConnection.js +0 -1
  325. package/dist/entries/database/defaultConnection.js +0 -1
  326. package/dist/entries/database/namedConnections.js +0 -1
  327. package/dist/entries/database/repositoryConnection.js +0 -1
  328. package/dist/entries/database/transaction.js +0 -1
  329. package/dist/entries/facades.js +0 -711
  330. package/dist/entries/runtime/applicationRegistry.js +0 -1
@@ -1,3 +1,4 @@
1
+ import type { DatabaseSession, TransactionSession } from "../../database/session";
1
2
  interface SamlAssertionReplayStore {
2
3
  consume(assertionId: string): Promise<void>;
3
4
  }
@@ -13,8 +14,7 @@ declare class InMemorySamlAssertionReplayStore implements SamlAssertionReplaySto
13
14
  clear(): void;
14
15
  private gc;
15
16
  }
16
- declare function setSamlAssertionReplayStoreForTests(store: SamlAssertionReplayStore | null): void;
17
- declare function resetSamlReplayCacheForTests(): void;
18
- declare function consumeSamlAssertion(assertionId: string): Promise<void>;
17
+ /** The canonical path receives its exact live invocation selection. */
18
+ declare function createSqlSamlAssertionReplayStore(selected: DatabaseSession | TransactionSession): SamlAssertionReplayStore;
19
19
  export type { SamlAssertionReplayStore };
20
- export { consumeSamlAssertion, InMemorySamlAssertionReplayStore, REPLAY_RETENTION_MS, resetSamlReplayCacheForTests, setSamlAssertionReplayStoreForTests, };
20
+ export { createSqlSamlAssertionReplayStore, InMemorySamlAssertionReplayStore, REPLAY_RETENTION_MS };
@@ -1,6 +1,6 @@
1
1
  import type { OAuthProfile } from "../oauth/types";
2
- import { consumeSamlAssertion, InMemorySamlAssertionReplayStore, REPLAY_RETENTION_MS, resetSamlReplayCacheForTests, setSamlAssertionReplayStoreForTests } from "./samlAssertionReplay";
3
- interface SamlServiceProviderOptions {
2
+ import { createSqlSamlAssertionReplayStore, InMemorySamlAssertionReplayStore, REPLAY_RETENTION_MS, type SamlAssertionReplayStore } from "./samlAssertionReplay";
3
+ interface SamlServiceProviderConfig {
4
4
  idpSsoUrl: string;
5
5
  idpCert: string;
6
6
  spEntityId: string;
@@ -10,6 +10,9 @@ interface SamlServiceProviderOptions {
10
10
  wantAuthnResponseSigned?: boolean;
11
11
  disableRequestedAuthnContext?: boolean;
12
12
  }
13
+ interface SamlServiceProviderOptions extends SamlServiceProviderConfig {
14
+ readonly replayStore: SamlAssertionReplayStore;
15
+ }
13
16
  interface VerifiedSamlAssertion {
14
17
  Assertion?: {
15
18
  $?: {
@@ -49,19 +52,20 @@ type NodeSamlClient = {
49
52
  loggedOut: boolean;
50
53
  }>;
51
54
  };
52
- declare function readSamlEnvOptions(): SamlServiceProviderOptions;
55
+ declare function readSamlEnvOptions(env?: Readonly<Record<string, string | undefined>>): SamlServiceProviderConfig;
53
56
  type NodeSamlModule = {
54
57
  SAML: new (options: Record<string, unknown>) => NodeSamlClient;
55
58
  };
56
59
  declare function setNodeSamlLoaderForTests(loader: (() => Promise<NodeSamlModule>) | null): void;
57
60
  declare class SamlServiceProvider {
58
- private readonly options;
59
61
  private client;
62
+ private readonly options;
63
+ private readonly consumeAssertion;
60
64
  constructor(options: SamlServiceProviderOptions);
61
65
  private getClient;
62
66
  authorizationUrl(relayState: string): Promise<string>;
63
67
  consumePost(samlResponse: string, relayState?: string): Promise<OAuthProfile>;
64
68
  }
65
- declare function createSamlServiceProvider(options?: SamlServiceProviderOptions): SamlServiceProvider;
66
- export type { SamlServiceProviderOptions };
67
- export { consumeSamlAssertion, createSamlServiceProvider, InMemorySamlAssertionReplayStore, REPLAY_RETENTION_MS, readSamlEnvOptions, resetSamlReplayCacheForTests, SamlServiceProvider, setNodeSamlLoaderForTests, setSamlAssertionReplayStoreForTests, };
69
+ declare function createSamlServiceProvider(options: SamlServiceProviderOptions): SamlServiceProvider;
70
+ export type { SamlAssertionReplayStore, SamlServiceProviderConfig, SamlServiceProviderOptions };
71
+ export { createSamlServiceProvider, createSqlSamlAssertionReplayStore, InMemorySamlAssertionReplayStore, REPLAY_RETENTION_MS, readSamlEnvOptions, SamlServiceProvider, setNodeSamlLoaderForTests, };
@@ -1,3 +1,10 @@
1
- import type { Middleware } from "@getstrata/core/http/middleware";
2
- declare function createScimAuthMiddleware(): Middleware;
3
- export { createScimAuthMiddleware };
1
+ import type { DatabaseSession } from "../database/session";
2
+ import type { TenantContext } from "../tenant/tenantContext";
3
+ export interface ScimAuthenticationOptions {
4
+ readonly resolveToken: (token: string) => number | null;
5
+ readonly resolveTenant: (database: DatabaseSession, id: number) => Promise<TenantContext | null>;
6
+ }
7
+ export declare function createScimAuthenticator(options: ScimAuthenticationOptions): (request: Request, database: DatabaseSession) => Promise<TenantContext | Response>;
8
+ /** Breaking alias: this is an explicit metadata authenticator, not a next()-based transaction wrapper. */
9
+ export declare const createScimAuthMiddleware: typeof createScimAuthenticator;
10
+ export declare function jsonScimError(detail: string, status: number): Response;
@@ -1,4 +1,4 @@
1
- declare const SESSION_COOKIE: string;
1
+ declare const SESSION_COOKIE = "strata_session";
2
2
  declare const SESSION_TTL_SECONDS: number;
3
3
  declare const SESSION_REMEMBER_TTL_SECONDS: number;
4
4
  interface CreateSessionCookieOptions {
@@ -10,11 +10,22 @@ interface SignedSession {
10
10
  issuedAt: number;
11
11
  authVersion?: number;
12
12
  }
13
- declare function sessionCookieName(): string;
14
- declare function sessionTtlSeconds(): number;
15
- declare function sessionRememberTtlSeconds(): number;
16
- declare function readSession(request: Request): SignedSession | null;
17
- declare function readSessionUserId(request: Request): number | null;
13
+ export interface SessionWriteOptions extends SessionReadOptions {
14
+ readonly rememberTtlSeconds: number;
15
+ readonly production: boolean;
16
+ }
17
+ export declare function sessionCookieOptionsFromEnvironment(env: Readonly<Record<string, string | undefined>>): SessionWriteOptions;
18
+ export interface SessionReadOptions {
19
+ readonly cookieName: string;
20
+ readonly secret: string;
21
+ readonly ttlSeconds: number;
22
+ }
23
+ export declare function createSessionReader(options: SessionReadOptions): (request: Request) => SignedSession | null;
24
+ declare function sessionCookieName(env: Readonly<Record<string, string | undefined>>): string;
25
+ declare function sessionTtlSeconds(env: Readonly<Record<string, string | undefined>>): number;
26
+ declare function sessionRememberTtlSeconds(env: Readonly<Record<string, string | undefined>>): number;
27
+ declare function readSession(request: Request, options: SessionReadOptions): SignedSession | null;
28
+ declare function readSessionUserId(request: Request, options: SessionReadOptions): number | null;
18
29
  declare function isSessionInvalidated(issuedAt: number, validAfter: Date | string | null | undefined): boolean;
19
30
  interface SessionCookieDetails {
20
31
  authVersion?: number;
@@ -23,8 +34,8 @@ interface SessionCookieDetails {
23
34
  issuedAt: number;
24
35
  ttlSeconds: number;
25
36
  }
26
- declare function createSessionCookieDetails(userId: number, options?: CreateSessionCookieOptions): SessionCookieDetails;
27
- declare function createSessionCookie(userId: number, options?: CreateSessionCookieOptions): string;
28
- declare function clearSessionCookie(): string;
37
+ declare function createSessionCookieDetails(userId: number, options: CreateSessionCookieOptions | undefined, config: SessionWriteOptions): SessionCookieDetails;
38
+ declare function createSessionCookie(userId: number, options: CreateSessionCookieOptions | undefined, config: SessionWriteOptions): string;
39
+ declare function clearSessionCookie(config: Pick<SessionWriteOptions, "production" | "cookieName">): string;
29
40
  export type { CreateSessionCookieOptions, SessionCookieDetails, SignedSession };
30
41
  export { clearSessionCookie, createSessionCookie, createSessionCookieDetails, isSessionInvalidated, readSession, readSessionUserId, SESSION_COOKIE, SESSION_REMEMBER_TTL_SECONDS, SESSION_TTL_SECONDS, sessionCookieName, sessionRememberTtlSeconds, sessionTtlSeconds, };
@@ -1,9 +1,20 @@
1
- import type { ServiceContainerLike } from "../contracts/serviceContainer";
1
+ import { type AuthOutcome } from "@getstrata/core/auth/authOutcome";
2
+ import type { AuthAccountLookup, AuthSessionValidity } from "../contracts/authUserDirectory";
2
3
  import type { AuthUser } from "./authContext";
3
4
  import type { AuthGuard } from "./guard";
5
+ import { type readSession } from "./sessionCookie";
4
6
  declare class SessionGuard implements AuthGuard {
5
- private readonly container;
6
- constructor(container: ServiceContainerLike);
7
+ private readonly directory;
8
+ private readonly session;
9
+ constructor(directory: AuthAccountLookup, session: {
10
+ read(request: Request): ReturnType<typeof readSession>;
11
+ hasCredential(request: Request): boolean;
12
+ abilities(role: string): string[];
13
+ /** Null explicitly selects account epoch/cutoff validation without a session registry. */
14
+ validity: AuthSessionValidity | null;
15
+ });
16
+ authenticate(request: Request): Promise<AuthOutcome>;
7
17
  resolve(request: Request): Promise<AuthUser | null>;
18
+ private resolveUser;
8
19
  }
9
20
  export { SessionGuard };
@@ -6,8 +6,11 @@ interface CreateCacheStoreOptions {
6
6
  ttlMs: number;
7
7
  maxEntries: number;
8
8
  redisUrl?: string;
9
- redis?: RedisCacheOptions;
9
+ redis?: Readonly<RedisCacheOptions>;
10
+ namespace?: string;
10
11
  }
11
- declare function createCacheStore(options: CreateCacheStoreOptions): CacheStore;
12
+ /** Pure snapshot and driver validation shared by declarations and direct construction. */
13
+ declare function snapshotCacheStoreOptions(options: Readonly<CreateCacheStoreOptions>, requireExplicitNamespace?: boolean): Readonly<CreateCacheStoreOptions>;
14
+ declare function createCacheStore(options: Readonly<CreateCacheStoreOptions>): CacheStore;
12
15
  export type { CacheDriver, CreateCacheStoreOptions, RedisCacheOptions };
13
- export { createCacheStore };
16
+ export { createCacheStore, snapshotCacheStoreOptions };
@@ -8,6 +8,9 @@ type RedisCacheOptions = {
8
8
  metadataTtlMs?: number;
9
9
  metadataLimit?: number;
10
10
  };
11
+ declare const DEFAULT_CACHE_NAMESPACE = "strata:cache:v3:";
12
+ declare function validateCacheNamespace(namespace: string): void;
13
+ declare function normalizeRedisCacheOptions(ttlMs: number, maxEntries: number, options?: Readonly<RedisCacheOptions>): Readonly<Required<RedisCacheOptions>>;
11
14
  declare class RedisCacheStore implements CacheStore {
12
15
  private readonly redisUrl;
13
16
  private readonly ttlMs;
@@ -17,7 +20,7 @@ declare class RedisCacheStore implements CacheStore {
17
20
  private readonly options;
18
21
  private readonly fills;
19
22
  private closed;
20
- constructor(redisUrl: string, ttlMs: number, maxEntries: number, options?: RedisCacheOptions);
23
+ constructor(redisUrl: string, ttlMs: number, maxEntries: number, options?: RedisCacheOptions, namespace?: string);
21
24
  private createClient;
22
25
  close(): void;
23
26
  get<T>(key: string): Promise<T | undefined>;
@@ -35,4 +38,5 @@ declare class RedisCacheStore implements CacheStore {
35
38
  private execute;
36
39
  }
37
40
  export type { RedisCacheOptions };
41
+ export { DEFAULT_CACHE_NAMESPACE, normalizeRedisCacheOptions, validateCacheNamespace };
38
42
  export default RedisCacheStore;
@@ -1,3 +1,5 @@
1
+ import type { CacheLike } from "../../types/services";
2
+ import type { ExecutionOperations } from "../contracts/executionOperations";
1
3
  import type { CacheStore } from "./store";
2
4
  import TaggedCache from "./taggedCache";
3
5
  declare class CacheRepository {
@@ -15,5 +17,7 @@ declare class CacheRepository {
15
17
  clear(): Promise<void>;
16
18
  size(): Promise<number>;
17
19
  }
18
- export { CacheRepository };
20
+ /** Scoped authority delegates to the existing backend; the kernel owns actual work. */
21
+ declare function createGuardedCache(backend: CacheRepository, operations: ExecutionOperations): CacheLike;
22
+ export { CacheRepository, createGuardedCache };
19
23
  export default CacheRepository;
@@ -1,3 +1,4 @@
1
+ declare function validateSimpleCacheOptions(ttlMs: number, maxEntries: number): void;
1
2
  declare class SimpleCache {
2
3
  private readonly ttlMs;
3
4
  private readonly maxEntries;
@@ -21,5 +22,5 @@ declare class SimpleCache {
21
22
  private pruneExpired;
22
23
  private evictOverflow;
23
24
  }
24
- export { SimpleCache };
25
+ export { SimpleCache, validateSimpleCacheOptions };
25
26
  export default SimpleCache;
@@ -0,0 +1,8 @@
1
+ import type { CacheLike } from "../../types/services";
2
+ import type { CacheRepository } from "./repository";
3
+ /** One canonical identity across root, cache, service-token and bootstrap entrypoints. */
4
+ declare const CORE_CACHE_TOKEN: import("@getstrata/core/contracts/token").ServiceToken<CacheLike>;
5
+ /** Internal application backend; execution consumers depend on CORE_CACHE_TOKEN. */
6
+ declare const CORE_CACHE_BACKEND_TOKEN: import("@getstrata/core/contracts/token").ServiceToken<CacheRepository>;
7
+ export type { CacheLike };
8
+ export { CORE_CACHE_BACKEND_TOKEN, CORE_CACHE_TOKEN };
@@ -0,0 +1,21 @@
1
+ import type { EnvSchema } from "./envSchema";
2
+ type DeepReadonly<T> = T extends object ? {
3
+ readonly [Key in keyof T]: DeepReadonly<T[Key]>;
4
+ } : T;
5
+ type ValidatedEnvironment<Schema extends EnvSchema> = {
6
+ readonly [Key in keyof Schema]: Schema[Key] extends {
7
+ required: true;
8
+ } | {
9
+ default: string;
10
+ } ? string : string | undefined;
11
+ };
12
+ interface ConfigIntegerBounds {
13
+ readonly minimum?: number;
14
+ readonly maximum?: number;
15
+ }
16
+ /** Explicit input only. Conversion does not grant access to the host environment. */
17
+ declare function parseApplicationConfig<const Schema extends EnvSchema, Settings extends object>(schema: Schema, input: Readonly<Record<string, string | undefined>>, convert: (values: ValidatedEnvironment<Schema>) => Settings): DeepReadonly<Settings>;
18
+ declare function configInteger(field: string, value: string, bounds?: ConfigIntegerBounds): number;
19
+ declare function configEnum<const Choices extends readonly [string, ...string[]]>(field: string, value: string, choices: Choices): Choices[number];
20
+ export type { ConfigIntegerBounds, DeepReadonly, ValidatedEnvironment };
21
+ export { configEnum, configInteger, parseApplicationConfig };
@@ -0,0 +1,3 @@
1
+ import type { ApplicationConfigValue } from "../contracts/application";
2
+ declare function copyApplicationConfig(value: unknown, ancestors?: Set<object>): ApplicationConfigValue;
3
+ export { copyApplicationConfig };
@@ -2,11 +2,12 @@ interface EnvRule {
2
2
  required?: boolean;
3
3
  integer?: boolean;
4
4
  minimum?: number;
5
+ maximum?: number;
5
6
  default?: string;
6
7
  pattern?: RegExp;
7
8
  }
8
9
  type EnvSchema = Record<string, EnvRule>;
9
- declare function defineEnvSchema(schema: EnvSchema): EnvSchema;
10
- declare function validateEnv(schema: EnvSchema, env?: Record<string, string | undefined>): Record<string, string>;
10
+ declare function defineEnvSchema<const Schema extends EnvSchema>(schema: Schema): Schema;
11
+ declare function validateEnv(schema: EnvSchema, env?: Readonly<Record<string, string | undefined>>): Record<string, string>;
11
12
  export type { EnvRule, EnvSchema };
12
13
  export { defineEnvSchema, validateEnv };
@@ -0,0 +1,153 @@
1
+ import type { NonPromisePayload, ServiceDeclaration } from "./services";
2
+ import type { ServiceToken } from "./token";
3
+ /** Plain configuration data is copied and frozen before any application work begins. */
4
+ type ApplicationConfigValue = string | number | boolean | null | readonly ApplicationConfigValue[] | {
5
+ readonly [key: string]: ApplicationConfigValue;
6
+ };
7
+ type ApplicationConfig = Readonly<Record<string, ApplicationConfigValue>>;
8
+ type ApplicationPhase = "constructed" | "starting" | "ready" | "stopping" | "stopped" | "failed";
9
+ type BootDisposition = "not-started" | "pending" | "ready" | "failed" | "cancelled";
10
+ type CleanupDisposition = "not-required" | "open" | "pending" | "clean" | "failed";
11
+ type ResourcePhase = "stop" | "drain" | "flush" | "close";
12
+ interface ApplicationDiagnostic {
13
+ readonly code: string;
14
+ readonly kind: "startup" | "acquisition" | "cleanup";
15
+ readonly provider?: string;
16
+ readonly resource?: string;
17
+ readonly phase?: ResourcePhase;
18
+ /** Opaque caller-owned payload: never inspected, serialized or frozen by the owner. */
19
+ readonly error: unknown;
20
+ }
21
+ interface ApplicationSnapshot {
22
+ readonly phase: ApplicationPhase;
23
+ readonly boot: BootDisposition;
24
+ readonly cleanup: CleanupDisposition;
25
+ readonly pendingAcquisitions: readonly string[];
26
+ /** Includes settled unknown acquisitions for which no handle was returned. */
27
+ readonly retainedResources: readonly string[];
28
+ readonly errors: readonly ApplicationDiagnostic[];
29
+ }
30
+ interface StopResult {
31
+ /** True only when cleanup is confirmed clean, regardless of the boot outcome. */
32
+ readonly successful: boolean;
33
+ readonly timedOut: boolean;
34
+ readonly snapshot: ApplicationSnapshot;
35
+ }
36
+ /** Actual settlement of owned work; it may report failed cleanup with retained ownership. */
37
+ type CompletionResult = StopResult;
38
+ interface CleanupContext {
39
+ readonly signal: AbortSignal;
40
+ readonly reason: string;
41
+ }
42
+ /**
43
+ * Adapter outcome records use own data fields, including ok/value or error/disposition.
44
+ * Accessor or malformed outcomes become unknown acquisition failures without invoking getters.
45
+ */
46
+ type OpenOutcome<T> = {
47
+ readonly ok: true;
48
+ readonly value: T;
49
+ } | {
50
+ readonly ok: false;
51
+ readonly error: unknown;
52
+ readonly disposition: "not-acquired" | "cleaned" | "unknown";
53
+ readonly cleanupErrors?: readonly unknown[];
54
+ };
55
+ /**
56
+ * A declaration record with own data fields: name/open/close and any optional hooks.
57
+ * Accessors and inherited prototype methods are rejected before open is invoked.
58
+ * Class adapters can supply own arrow functions or an explicit declaration record.
59
+ */
60
+ interface ResourceSpec<T> {
61
+ readonly name: string;
62
+ /** A raw throw/rejection always means unknown disposal, without inspecting its payload. */
63
+ readonly open: (signal: AbortSignal) => OpenOutcome<T> | Promise<OpenOutcome<T>>;
64
+ readonly close: (value: T, context: CleanupContext) => void | Promise<void>;
65
+ readonly stop?: (value: T, context: CleanupContext) => void | Promise<void>;
66
+ readonly drain?: (value: T, context: CleanupContext) => void | Promise<void>;
67
+ readonly flush?: (value: T, context: CleanupContext) => void | Promise<void>;
68
+ }
69
+ interface ProviderScope {
70
+ readonly applicationId: string;
71
+ readonly config: ApplicationConfig;
72
+ readonly signal: AbortSignal;
73
+ resolve<T>(token: ServiceToken<T>): T;
74
+ acquire<T>(spec: ResourceSpec<T>): Promise<T>;
75
+ }
76
+ interface ProviderDefinition {
77
+ readonly name: string;
78
+ readonly requires?: readonly string[];
79
+ readonly setup: (scope: ProviderScope) => void | Promise<void>;
80
+ }
81
+ /** Uses the same owner as providers and starts after all providers have finished setup. */
82
+ type TransportDefinition = ProviderDefinition;
83
+ interface ApplicationDefinition {
84
+ readonly config?: ApplicationConfig;
85
+ readonly providers: readonly ProviderDefinition[];
86
+ readonly transports?: readonly TransportDefinition[];
87
+ readonly services?: readonly ServiceDeclaration[];
88
+ readonly overrides?: readonly ServiceDeclaration[];
89
+ readonly shutdownTimeoutMs?: number;
90
+ readonly startupCleanupTimeoutMs?: number;
91
+ }
92
+ type ExecutionActor = {
93
+ readonly kind: "principal";
94
+ readonly claims: ApplicationConfig;
95
+ } | {
96
+ readonly kind: "system";
97
+ readonly policy: string;
98
+ };
99
+ interface ExecutionEnvelopeFields {
100
+ readonly externalId?: string;
101
+ readonly metadata?: ApplicationConfig;
102
+ readonly tenant?: ApplicationConfig;
103
+ readonly signal?: AbortSignal;
104
+ readonly deadlineAtMs?: number;
105
+ }
106
+ type ExecutionEnvelope = ExecutionEnvelopeFields & ({
107
+ readonly kind: "request" | "command";
108
+ readonly actor?: ExecutionActor;
109
+ } | {
110
+ readonly kind: "job";
111
+ readonly actor: ExecutionActor;
112
+ });
113
+ type ExecutionContext = ExecutionEnvelope & {
114
+ readonly applicationId: string;
115
+ readonly executionId: string;
116
+ readonly metadata: ApplicationConfig;
117
+ readonly signal: AbortSignal;
118
+ };
119
+ /** A child observation settles after its body, admitted descendants and owned cleanup. */
120
+ type ExecutionTaskOutcome<T> = {
121
+ readonly ok: true;
122
+ readonly value: T;
123
+ } | {
124
+ readonly ok: false;
125
+ readonly error: unknown;
126
+ };
127
+ interface CommandScope {
128
+ readonly context: ExecutionContext;
129
+ readonly applicationId: string;
130
+ readonly config: ApplicationConfig;
131
+ readonly signal: AbortSignal;
132
+ /** Composition access expires with this callback's body lease; owned resources remain through its joined subtree. */
133
+ resolve<T>(token: ServiceToken<T>): T;
134
+ /** Own a resource through this callback's actual subtree and cleanup. */
135
+ readonly acquire: <T>(spec: ResourceSpec<T> & NonPromisePayload<T>) => Promise<T>;
136
+ /** Joined work in this execution; observation does not recover failures. */
137
+ readonly spawn: <T>(work: (scope: CommandScope) => T | Promise<T>) => Promise<ExecutionTaskOutcome<T>>;
138
+ }
139
+ interface Application {
140
+ readonly id: string;
141
+ readonly state: ApplicationSnapshot;
142
+ /** Shared while starting/ready; new calls once stopping begins get a cached terminal rejection. */
143
+ start(): Promise<void>;
144
+ /** Cached bounded observation. Timeout never releases the owner's resource obligations. */
145
+ stop(options?: {
146
+ readonly reason?: string;
147
+ }): Promise<StopResult>;
148
+ /** Stable, never rejecting; remains pending while owned operations are actually still running. */
149
+ readonly completion: Promise<CompletionResult>;
150
+ run<T>(work: (scope: CommandScope) => T | Promise<T>): Promise<T>;
151
+ run<T>(envelope: ExecutionEnvelope, work: (scope: CommandScope) => T | Promise<T>): Promise<T>;
152
+ }
153
+ export type { Application, ApplicationConfig, ApplicationConfigValue, ApplicationDefinition, ApplicationDiagnostic, ApplicationPhase, ApplicationSnapshot, BootDisposition, CleanupContext, CleanupDisposition, CommandScope, CompletionResult, ExecutionActor, ExecutionContext, ExecutionEnvelope, ExecutionTaskOutcome, OpenOutcome, ProviderDefinition, ProviderScope, ResourcePhase, ResourceSpec, StopResult, TransportDefinition, };
@@ -15,12 +15,29 @@ interface AuthUserRecord {
15
15
  mfa_secret?: string | null;
16
16
  mfa_recovery_codes?: string | null;
17
17
  }
18
- interface AuthUserDirectory {
19
- /** Participating directories must project fresh account status as AuthUser.isActive. */
20
- resolveUserFromToken(token: string): Promise<AuthUser | null>;
18
+ /** Expected lookup miss. Operational failures must retain their original error. */
19
+ declare class AuthAccountNotFoundError extends Error {
20
+ constructor();
21
+ }
22
+ interface AuthAccountLookup {
23
+ /** Throw AuthAccountNotFoundError only for an expected miss; retain operational failures. */
21
24
  findByIdOrThrow(id: number): Promise<AuthUserRecord>;
22
- hasActiveBrowserSession?(userId: number, issuedAt: number): Promise<boolean>;
23
- findByEmail?(email: string): Promise<AuthUserRecord | null>;
24
- verifyCredentials?(email: string, password: string): Promise<AuthUser | null>;
25
25
  }
26
- export type { AuthUserDirectory, AuthUserRecord };
26
+ interface AuthBearerResolver {
27
+ /** Participating resolvers must project fresh account status as AuthUser.isActive. */
28
+ resolveUserFromToken(token: string): Promise<AuthUser | null>;
29
+ }
30
+ interface AuthSessionValidity {
31
+ hasActiveBrowserSession(userId: number, issuedAt: number): Promise<boolean>;
32
+ }
33
+ interface AuthEmailLookup {
34
+ findByEmail(email: string): Promise<AuthUserRecord | null>;
35
+ }
36
+ interface AuthCredentialVerifier {
37
+ verifyCredentials(email: string, password: string): Promise<AuthUser | null>;
38
+ }
39
+ /** Adapter composition surface. Guards depend on the individual selected capabilities. */
40
+ interface AuthUserDirectory extends AuthAccountLookup, AuthBearerResolver, Partial<AuthSessionValidity & AuthEmailLookup & AuthCredentialVerifier> {
41
+ }
42
+ export type { AuthAccountLookup, AuthBearerResolver, AuthCredentialVerifier, AuthEmailLookup, AuthSessionValidity, AuthUserDirectory, AuthUserRecord, };
43
+ export { AuthAccountNotFoundError };
@@ -1,52 +1,49 @@
1
- declare const serviceTokenType: unique symbol;
2
- /** Invariant service identity; its runtime value remains the existing string key. */
3
- type ServiceToken<T> = string & {
4
- readonly [serviceTokenType]: (value: T) => T;
5
- };
6
- /** Prevent a typed token from falling back to an unchecked legacy overload. */
7
- type LegacyServiceKey = string & {
8
- readonly [serviceTokenType]?: never;
9
- };
10
- declare function createServiceToken<T>(key: string): ServiceToken<T>;
1
+ import { type AnyServiceToken, createServiceToken, type ServiceToken } from "@getstrata/core/contracts/token";
2
+ type ServiceKey = AnyServiceToken;
11
3
  type ServiceFactory<T> = (container: ServiceContainer) => T;
12
4
  interface ServiceContainerLike {
13
- has(key: string): boolean;
5
+ has(key: ServiceKey): boolean;
14
6
  resolve<T>(key: ServiceToken<T>): T;
15
- resolve<T>(key: LegacyServiceKey): T;
16
7
  }
8
+ /** One engine for cached values, factories, aliases and eager initialization. */
17
9
  declare class ServiceContainer implements ServiceContainerLike {
10
+ private readonly parent?;
18
11
  private readonly services;
19
12
  private readonly singletonFactories;
20
13
  private readonly bindings;
14
+ private readonly aliases;
15
+ private readonly initializations;
21
16
  private readonly resolutionPath;
17
+ private sealed;
18
+ constructor(parent?: ServiceContainer | undefined);
19
+ private mutable;
20
+ private clearDefinition;
22
21
  set<T>(key: ServiceToken<T>, value: NoInfer<T>): T;
23
- set<T>(key: LegacyServiceKey, value: T): T;
24
22
  singleton<T>(key: ServiceToken<T>, factory: ServiceFactory<NoInfer<T>>): void;
25
- singleton<T>(key: LegacyServiceKey, factory: ServiceFactory<T>): void;
26
23
  bind<T>(key: ServiceToken<T>, factory: ServiceFactory<NoInfer<T>>): void;
27
- bind<T>(key: LegacyServiceKey, factory: ServiceFactory<T>): void;
24
+ /** Assembly-only: graph.start uses this engine's sole in-flight slot and value cache. */
25
+ initialize<T>(key: ServiceToken<T>, factory: () => T | Promise<T>, signal: AbortSignal, checkpoint?: () => void): Promise<T>;
26
+ alias<T>(key: ServiceToken<T>, target: ServiceToken<NoInfer<T>>): void;
27
+ seal(): void;
28
28
  get<T>(key: ServiceToken<T>): T;
29
- get<T>(key: LegacyServiceKey): T;
30
29
  private resolveFactory;
31
30
  resolve<T>(key: ServiceToken<T>): T;
32
- resolve<T>(key: LegacyServiceKey): T;
33
31
  make<T>(key: ServiceToken<T>): T;
34
- make<T>(key: LegacyServiceKey): T;
35
32
  instance<T>(key: ServiceToken<T>, value: NoInfer<T>): T;
36
- instance<T>(key: LegacyServiceKey, value: T): T;
37
- has(key: string): boolean;
33
+ has(key: ServiceKey): boolean;
38
34
  }
39
35
  interface ConfigStoreLike {
40
36
  get<T>(key: string): T | undefined;
41
- require<T>(key: string): T;
37
+ getRequired<T>(key: string): T;
42
38
  has(key: string): boolean;
43
39
  }
40
+ /** Legacy mutable configuration; target applications inject validated immutable settings. */
44
41
  declare class ConfigStore implements ConfigStoreLike {
45
42
  private readonly values;
46
43
  set<T>(key: string, value: T): T;
47
44
  get<T>(key: string): T | undefined;
48
- require<T>(key: string): T;
45
+ getRequired<T>(key: string): T;
49
46
  has(key: string): boolean;
50
47
  }
51
- export type { ConfigStoreLike, LegacyServiceKey, ServiceContainerLike, ServiceFactory, ServiceToken, };
48
+ export type { ConfigStoreLike, ServiceContainerLike, ServiceFactory, ServiceToken };
52
49
  export { ConfigStore, createServiceToken, ServiceContainer };
@@ -1,15 +1,18 @@
1
1
  import type { CacheLike } from "../../types/services";
2
2
  import type { StorageManager } from "../storage/storage";
3
- import type { ConfigStore, ConfigStoreLike, LegacyServiceKey, ServiceContainer, ServiceFactory, ServiceToken } from "./container";
3
+ import type { ConfigStore, ConfigStoreLike, ServiceContainer, ServiceFactory, ServiceToken } from "./container";
4
+ import type { PersistenceInvocation } from "./persistence";
4
5
  type AppRouteMap = Record<string, any>;
5
6
  type CachedJson = <T>(cacheKey: string, loader: () => Promise<T>, tags?: string[], request?: Request) => Promise<Response>;
6
7
  interface AppDependencies {
8
+ readonly invoke: PersistenceInvocation;
7
9
  container: ServiceContainer;
8
10
  cache: CacheLike;
9
11
  storage: StorageManager;
10
12
  }
11
13
  type MutableAppDependencies = Partial<Omit<AppDependencies, "container">> & Pick<AppDependencies, "container">;
12
14
  interface ProviderContext {
15
+ readonly invoke: PersistenceInvocation;
13
16
  container: ServiceContainer;
14
17
  config: ConfigStore;
15
18
  dependencies: MutableAppDependencies;
@@ -29,6 +32,5 @@ interface AppContext {
29
32
  declare function getRequiredDependency<K extends keyof AppDependencies>(dependencies: Partial<AppDependencies>, key: K): AppDependencies[K];
30
33
  declare function assertAppDependenciesComplete(dependencies: MutableAppDependencies): asserts dependencies is AppDependencies;
31
34
  declare function resolveService<T>(dependencies: AppDependencies, token: ServiceToken<T>): T;
32
- declare function resolveService<T>(dependencies: AppDependencies, token: LegacyServiceKey): T;
33
35
  export type { AppContext, AppDependencies, AppRouteMap, CachedJson, MutableAppDependencies, ProviderContext, ServiceFactory, ServiceProvider, };
34
36
  export { assertAppDependenciesComplete, getRequiredDependency, resolveService };
@@ -0,0 +1,5 @@
1
+ import type { ExecutionContext } from "./application";
2
+ /** Canonical implicit execution dependency; applications cannot declare or override it. */
3
+ declare const CORE_EXECUTION_CONTEXT_TOKEN: import("@getstrata/core/contracts/token").ServiceToken<ExecutionContext>;
4
+ export type { ExecutionActor, ExecutionContext, ExecutionEnvelope, ExecutionTaskOutcome, } from "./application";
5
+ export { CORE_EXECUTION_CONTEXT_TOKEN };
@@ -0,0 +1,10 @@
1
+ /** Execution-bound admission to the current active callback's owned task tree. */
2
+ interface ExecutionOperations {
3
+ readonly assertActive: () => void;
4
+ /** Observe the actual body result while its complete owned subtree stays joined. */
5
+ readonly operation: <T>(work: () => T | Promise<T>) => Promise<T>;
6
+ }
7
+ /** Canonical implicit execution dependency; applications cannot declare or override it. */
8
+ declare const CORE_EXECUTION_OPERATIONS_TOKEN: import("@getstrata/core/contracts/token").ServiceToken<ExecutionOperations>;
9
+ export type { ExecutionOperations };
10
+ export { CORE_EXECUTION_OPERATIONS_TOKEN };
@@ -0,0 +1,38 @@
1
+ import type { ResourceSpec } from "./application";
2
+ import type { NonPromisePayload } from "./services";
3
+ /** Internal synchronous context installation around the complete leased invocation. */
4
+ type OwnedInvocation = <R>(invoke: () => R) => R;
5
+ /** Internal immutable observation; errors remain opaque caller-owned payloads. */
6
+ interface Joined<T> {
7
+ readonly invoked: boolean;
8
+ readonly body: Readonly<{
9
+ ok: true;
10
+ value: T;
11
+ }> | Readonly<{
12
+ ok: false;
13
+ error: unknown;
14
+ }>;
15
+ readonly strictFailed: boolean;
16
+ readonly retained: boolean;
17
+ /** Inspection only: these occurrences are already joined by the parent tree. */
18
+ readonly strict: readonly Readonly<{
19
+ error: unknown;
20
+ }>[];
21
+ }
22
+ /** Internal authority for one actual node; never supplied to public operation work. */
23
+ interface OwnedBoundary {
24
+ readonly acquire: <T>(spec: ResourceSpec<T> & NonPromisePayload<T>) => Promise<T>;
25
+ /** Complete trusted framework bookkeeping from this exact live direct body. */
26
+ readonly finalize: (work: () => undefined) => Promise<Joined<void>>;
27
+ /** Validate the current live body is this boundary or one of its actual descendants. */
28
+ readonly assertWithin: () => void;
29
+ /** Restore this exact live direct body for a native continuation, without reviving it. */
30
+ readonly bindNative: <A extends readonly unknown[], R>(work: (...args: A) => Promise<R>) => (...args: A) => Promise<R>;
31
+ }
32
+ /** Internal execution-bound dispatch through the existing task launcher and journal. */
33
+ interface OwnedExecution {
34
+ readonly joined: <T>(work: (task: OwnedBoundary) => T | Promise<T>, enter?: OwnedInvocation) => Promise<Joined<T>>;
35
+ }
36
+ declare const CORE_EXECUTION_OWNERSHIP_TOKEN: import("@getstrata/core/contracts/token").ServiceToken<OwnedExecution>;
37
+ export type { Joined, OwnedBoundary, OwnedExecution, OwnedInvocation };
38
+ export { CORE_EXECUTION_OWNERSHIP_TOKEN };
@@ -0,0 +1,20 @@
1
+ import type { DatabaseSession, TransactionSession } from "../database/session";
2
+ import type { ExecutionEnvelope } from "./application";
3
+ export type SelectedSession = DatabaseSession | TransactionSession;
4
+ export interface ExecutionPersistence {
5
+ readonly database: DatabaseSession;
6
+ readonly policy: ScopedPolicy;
7
+ }
8
+ export type PersistenceInvocation = <T>(envelope: ExecutionEnvelope, work: (ports: ExecutionPersistence) => T | Promise<T>) => Promise<T>;
9
+ export type EstablishedDatabasePolicy = Readonly<{
10
+ kind: "tenant";
11
+ tenantId: number;
12
+ }> | Readonly<{
13
+ kind: "bypass";
14
+ }> | Readonly<{
15
+ kind: "identifier";
16
+ identifier: string | number;
17
+ }>;
18
+ export interface ScopedPolicy {
19
+ run<T>(selected: SelectedSession, policy: EstablishedDatabasePolicy, work: (child: TransactionSession) => T | Promise<T>): Promise<T>;
20
+ }