@blokjs/runner 0.2.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 (307) hide show
  1. package/dist/Blok.d.ts +19 -0
  2. package/dist/Blok.js +184 -0
  3. package/dist/Blok.js.map +1 -0
  4. package/dist/BlokResponse.d.ts +16 -0
  5. package/dist/BlokResponse.js +28 -0
  6. package/dist/BlokResponse.js.map +1 -0
  7. package/dist/Configuration.d.ts +37 -0
  8. package/dist/Configuration.js +248 -0
  9. package/dist/Configuration.js.map +1 -0
  10. package/dist/ConfigurationResolver.d.ts +7 -0
  11. package/dist/ConfigurationResolver.js +15 -0
  12. package/dist/ConfigurationResolver.js.map +1 -0
  13. package/dist/DefaultLogger.d.ts +65 -0
  14. package/dist/DefaultLogger.js +101 -0
  15. package/dist/DefaultLogger.js.map +1 -0
  16. package/dist/LocalStorage.d.ts +7 -0
  17. package/dist/LocalStorage.js +56 -0
  18. package/dist/LocalStorage.js.map +1 -0
  19. package/dist/MemoryUsage.d.ts +22 -0
  20. package/dist/MemoryUsage.js +83 -0
  21. package/dist/MemoryUsage.js.map +1 -0
  22. package/dist/NodeMap.d.ts +7 -0
  23. package/dist/NodeMap.js +13 -0
  24. package/dist/NodeMap.js.map +1 -0
  25. package/dist/ResolverBase.d.ts +8 -0
  26. package/dist/ResolverBase.js +18 -0
  27. package/dist/ResolverBase.js.map +1 -0
  28. package/dist/Runner.d.ts +25 -0
  29. package/dist/Runner.js +32 -0
  30. package/dist/Runner.js.map +1 -0
  31. package/dist/RunnerNode.d.ts +9 -0
  32. package/dist/RunnerNode.js +8 -0
  33. package/dist/RunnerNode.js.map +1 -0
  34. package/dist/RunnerNodeBase.d.ts +4 -0
  35. package/dist/RunnerNodeBase.js +3 -0
  36. package/dist/RunnerNodeBase.js.map +1 -0
  37. package/dist/RunnerSteps.d.ts +14 -0
  38. package/dist/RunnerSteps.js +110 -0
  39. package/dist/RunnerSteps.js.map +1 -0
  40. package/dist/RuntimeAdapterNode.d.ts +19 -0
  41. package/dist/RuntimeAdapterNode.js +87 -0
  42. package/dist/RuntimeAdapterNode.js.map +1 -0
  43. package/dist/RuntimeRegistry.d.ts +61 -0
  44. package/dist/RuntimeRegistry.js +87 -0
  45. package/dist/RuntimeRegistry.js.map +1 -0
  46. package/dist/TriggerBase.d.ts +119 -0
  47. package/dist/TriggerBase.js +413 -0
  48. package/dist/TriggerBase.js.map +1 -0
  49. package/dist/adapters/BunRuntimeAdapter.d.ts +38 -0
  50. package/dist/adapters/BunRuntimeAdapter.js +169 -0
  51. package/dist/adapters/BunRuntimeAdapter.js.map +1 -0
  52. package/dist/adapters/DockerRuntimeAdapter.d.ts +85 -0
  53. package/dist/adapters/DockerRuntimeAdapter.js +298 -0
  54. package/dist/adapters/DockerRuntimeAdapter.js.map +1 -0
  55. package/dist/adapters/HttpRuntimeAdapter.d.ts +58 -0
  56. package/dist/adapters/HttpRuntimeAdapter.js +152 -0
  57. package/dist/adapters/HttpRuntimeAdapter.js.map +1 -0
  58. package/dist/adapters/NodeJsRuntimeAdapter.d.ts +23 -0
  59. package/dist/adapters/NodeJsRuntimeAdapter.js +67 -0
  60. package/dist/adapters/NodeJsRuntimeAdapter.js.map +1 -0
  61. package/dist/adapters/RuntimeAdapter.d.ts +42 -0
  62. package/dist/adapters/RuntimeAdapter.js +2 -0
  63. package/dist/adapters/RuntimeAdapter.js.map +1 -0
  64. package/dist/adapters/WasmRuntimeAdapter.d.ts +69 -0
  65. package/dist/adapters/WasmRuntimeAdapter.js +279 -0
  66. package/dist/adapters/WasmRuntimeAdapter.js.map +1 -0
  67. package/dist/cache/NodeResultCache.d.ts +286 -0
  68. package/dist/cache/NodeResultCache.js +499 -0
  69. package/dist/cache/NodeResultCache.js.map +1 -0
  70. package/dist/cache/index.d.ts +1 -0
  71. package/dist/cache/index.js +2 -0
  72. package/dist/cache/index.js.map +1 -0
  73. package/dist/cost/CostEstimator.d.ts +57 -0
  74. package/dist/cost/CostEstimator.js +171 -0
  75. package/dist/cost/CostEstimator.js.map +1 -0
  76. package/dist/cost/index.d.ts +4 -0
  77. package/dist/cost/index.js +3 -0
  78. package/dist/cost/index.js.map +1 -0
  79. package/dist/cost/pricing.d.ts +24 -0
  80. package/dist/cost/pricing.js +169 -0
  81. package/dist/cost/pricing.js.map +1 -0
  82. package/dist/defineNode.d.ts +155 -0
  83. package/dist/defineNode.js +191 -0
  84. package/dist/defineNode.js.map +1 -0
  85. package/dist/graphql/GraphQLSchemaGenerator.d.ts +129 -0
  86. package/dist/graphql/GraphQLSchemaGenerator.js +425 -0
  87. package/dist/graphql/GraphQLSchemaGenerator.js.map +1 -0
  88. package/dist/hmr/FileWatcher.d.ts +62 -0
  89. package/dist/hmr/FileWatcher.js +185 -0
  90. package/dist/hmr/FileWatcher.js.map +1 -0
  91. package/dist/hmr/HmrDevConsole.d.ts +13 -0
  92. package/dist/hmr/HmrDevConsole.js +46 -0
  93. package/dist/hmr/HmrDevConsole.js.map +1 -0
  94. package/dist/hmr/HotReloadManager.d.ts +84 -0
  95. package/dist/hmr/HotReloadManager.js +195 -0
  96. package/dist/hmr/HotReloadManager.js.map +1 -0
  97. package/dist/hmr/index.d.ts +39 -0
  98. package/dist/hmr/index.js +38 -0
  99. package/dist/hmr/index.js.map +1 -0
  100. package/dist/index.d.ts +107 -0
  101. package/dist/index.js +107 -0
  102. package/dist/index.js.map +1 -0
  103. package/dist/integrations/APMIntegration.d.ts +141 -0
  104. package/dist/integrations/APMIntegration.js +212 -0
  105. package/dist/integrations/APMIntegration.js.map +1 -0
  106. package/dist/integrations/AzureMonitorIntegration.d.ts +118 -0
  107. package/dist/integrations/AzureMonitorIntegration.js +254 -0
  108. package/dist/integrations/AzureMonitorIntegration.js.map +1 -0
  109. package/dist/integrations/CloudWatchIntegration.d.ts +135 -0
  110. package/dist/integrations/CloudWatchIntegration.js +293 -0
  111. package/dist/integrations/CloudWatchIntegration.js.map +1 -0
  112. package/dist/integrations/SentryIntegration.d.ts +153 -0
  113. package/dist/integrations/SentryIntegration.js +200 -0
  114. package/dist/integrations/SentryIntegration.js.map +1 -0
  115. package/dist/integrations/index.d.ts +19 -0
  116. package/dist/integrations/index.js +16 -0
  117. package/dist/integrations/index.js.map +1 -0
  118. package/dist/marketplace/RuntimeAutoScaler.d.ts +148 -0
  119. package/dist/marketplace/RuntimeAutoScaler.js +366 -0
  120. package/dist/marketplace/RuntimeAutoScaler.js.map +1 -0
  121. package/dist/marketplace/RuntimeCatalog.d.ts +174 -0
  122. package/dist/marketplace/RuntimeCatalog.js +339 -0
  123. package/dist/marketplace/RuntimeCatalog.js.map +1 -0
  124. package/dist/marketplace/RuntimeDiscovery.d.ts +86 -0
  125. package/dist/marketplace/RuntimeDiscovery.js +219 -0
  126. package/dist/marketplace/RuntimeDiscovery.js.map +1 -0
  127. package/dist/marketplace/RuntimeHealthMonitor.d.ts +100 -0
  128. package/dist/marketplace/RuntimeHealthMonitor.js +241 -0
  129. package/dist/marketplace/RuntimeHealthMonitor.js.map +1 -0
  130. package/dist/marketplace/RuntimeMetricsDashboard.d.ts +113 -0
  131. package/dist/marketplace/RuntimeMetricsDashboard.js +293 -0
  132. package/dist/marketplace/RuntimeMetricsDashboard.js.map +1 -0
  133. package/dist/monitoring/CircuitBreaker.d.ts +107 -0
  134. package/dist/monitoring/CircuitBreaker.js +238 -0
  135. package/dist/monitoring/CircuitBreaker.js.map +1 -0
  136. package/dist/monitoring/DistributedTracer.d.ts +125 -0
  137. package/dist/monitoring/DistributedTracer.js +230 -0
  138. package/dist/monitoring/DistributedTracer.js.map +1 -0
  139. package/dist/monitoring/HealthCheck.d.ts +54 -0
  140. package/dist/monitoring/HealthCheck.js +102 -0
  141. package/dist/monitoring/HealthCheck.js.map +1 -0
  142. package/dist/monitoring/PerformanceProfiler.d.ts +63 -0
  143. package/dist/monitoring/PerformanceProfiler.js +229 -0
  144. package/dist/monitoring/PerformanceProfiler.js.map +1 -0
  145. package/dist/monitoring/PrometheusBootstrap.d.ts +30 -0
  146. package/dist/monitoring/PrometheusBootstrap.js +71 -0
  147. package/dist/monitoring/PrometheusBootstrap.js.map +1 -0
  148. package/dist/monitoring/PrometheusMetricsBridge.d.ts +60 -0
  149. package/dist/monitoring/PrometheusMetricsBridge.js +216 -0
  150. package/dist/monitoring/PrometheusMetricsBridge.js.map +1 -0
  151. package/dist/monitoring/RateLimiter.d.ts +58 -0
  152. package/dist/monitoring/RateLimiter.js +128 -0
  153. package/dist/monitoring/RateLimiter.js.map +1 -0
  154. package/dist/monitoring/StructuredLogger.d.ts +131 -0
  155. package/dist/monitoring/StructuredLogger.js +207 -0
  156. package/dist/monitoring/StructuredLogger.js.map +1 -0
  157. package/dist/monitoring/TracingBootstrap.d.ts +69 -0
  158. package/dist/monitoring/TracingBootstrap.js +129 -0
  159. package/dist/monitoring/TracingBootstrap.js.map +1 -0
  160. package/dist/monitoring/TriggerMetricsCollector.d.ts +94 -0
  161. package/dist/monitoring/TriggerMetricsCollector.js +174 -0
  162. package/dist/monitoring/TriggerMetricsCollector.js.map +1 -0
  163. package/dist/monitoring/index.d.ts +9 -0
  164. package/dist/monitoring/index.js +10 -0
  165. package/dist/monitoring/index.js.map +1 -0
  166. package/dist/openapi/OpenAPIGenerator.d.ts +192 -0
  167. package/dist/openapi/OpenAPIGenerator.js +373 -0
  168. package/dist/openapi/OpenAPIGenerator.js.map +1 -0
  169. package/dist/openapi/index.d.ts +20 -0
  170. package/dist/openapi/index.js +20 -0
  171. package/dist/openapi/index.js.map +1 -0
  172. package/dist/security/ABAC.d.ts +224 -0
  173. package/dist/security/ABAC.js +380 -0
  174. package/dist/security/ABAC.js.map +1 -0
  175. package/dist/security/AuditLogger.d.ts +242 -0
  176. package/dist/security/AuditLogger.js +317 -0
  177. package/dist/security/AuditLogger.js.map +1 -0
  178. package/dist/security/AuthMiddleware.d.ts +163 -0
  179. package/dist/security/AuthMiddleware.js +274 -0
  180. package/dist/security/AuthMiddleware.js.map +1 -0
  181. package/dist/security/EncryptionAtRest.d.ts +206 -0
  182. package/dist/security/EncryptionAtRest.js +236 -0
  183. package/dist/security/EncryptionAtRest.js.map +1 -0
  184. package/dist/security/OAuthProvider.d.ts +334 -0
  185. package/dist/security/OAuthProvider.js +719 -0
  186. package/dist/security/OAuthProvider.js.map +1 -0
  187. package/dist/security/PIIDetector.d.ts +233 -0
  188. package/dist/security/PIIDetector.js +354 -0
  189. package/dist/security/PIIDetector.js.map +1 -0
  190. package/dist/security/RBAC.d.ts +143 -0
  191. package/dist/security/RBAC.js +285 -0
  192. package/dist/security/RBAC.js.map +1 -0
  193. package/dist/security/SecretManager.d.ts +652 -0
  194. package/dist/security/SecretManager.js +1146 -0
  195. package/dist/security/SecretManager.js.map +1 -0
  196. package/dist/security/TLSConfig.d.ts +305 -0
  197. package/dist/security/TLSConfig.js +550 -0
  198. package/dist/security/TLSConfig.js.map +1 -0
  199. package/dist/security/index.d.ts +79 -0
  200. package/dist/security/index.js +80 -0
  201. package/dist/security/index.js.map +1 -0
  202. package/dist/testing/TestHarness.d.ts +189 -0
  203. package/dist/testing/TestHarness.js +272 -0
  204. package/dist/testing/TestHarness.js.map +1 -0
  205. package/dist/testing/TestLogger.d.ts +103 -0
  206. package/dist/testing/TestLogger.js +153 -0
  207. package/dist/testing/TestLogger.js.map +1 -0
  208. package/dist/testing/WorkflowTestRunner.d.ts +172 -0
  209. package/dist/testing/WorkflowTestRunner.js +355 -0
  210. package/dist/testing/WorkflowTestRunner.js.map +1 -0
  211. package/dist/testing/index.d.ts +21 -0
  212. package/dist/testing/index.js +22 -0
  213. package/dist/testing/index.js.map +1 -0
  214. package/dist/tracing/InMemoryRunStore.d.ts +44 -0
  215. package/dist/tracing/InMemoryRunStore.js +341 -0
  216. package/dist/tracing/InMemoryRunStore.js.map +1 -0
  217. package/dist/tracing/PostgresRunStore.d.ts +82 -0
  218. package/dist/tracing/PostgresRunStore.js +640 -0
  219. package/dist/tracing/PostgresRunStore.js.map +1 -0
  220. package/dist/tracing/RunStore.d.ts +38 -0
  221. package/dist/tracing/RunStore.js +2 -0
  222. package/dist/tracing/RunStore.js.map +1 -0
  223. package/dist/tracing/RunTracker.d.ts +75 -0
  224. package/dist/tracing/RunTracker.js +374 -0
  225. package/dist/tracing/RunTracker.js.map +1 -0
  226. package/dist/tracing/SqliteRunStore.d.ts +53 -0
  227. package/dist/tracing/SqliteRunStore.js +703 -0
  228. package/dist/tracing/SqliteRunStore.js.map +1 -0
  229. package/dist/tracing/TraceRouter.d.ts +47 -0
  230. package/dist/tracing/TraceRouter.js +904 -0
  231. package/dist/tracing/TraceRouter.js.map +1 -0
  232. package/dist/tracing/TracingLogger.d.ts +21 -0
  233. package/dist/tracing/TracingLogger.js +62 -0
  234. package/dist/tracing/TracingLogger.js.map +1 -0
  235. package/dist/tracing/createStore.d.ts +30 -0
  236. package/dist/tracing/createStore.js +75 -0
  237. package/dist/tracing/createStore.js.map +1 -0
  238. package/dist/tracing/index.d.ts +13 -0
  239. package/dist/tracing/index.js +9 -0
  240. package/dist/tracing/index.js.map +1 -0
  241. package/dist/tracing/sanitize.d.ts +7 -0
  242. package/dist/tracing/sanitize.js +95 -0
  243. package/dist/tracing/sanitize.js.map +1 -0
  244. package/dist/tracing/types.d.ts +178 -0
  245. package/dist/tracing/types.js +3 -0
  246. package/dist/tracing/types.js.map +1 -0
  247. package/dist/types/Average.d.ts +11 -0
  248. package/dist/types/Average.js +2 -0
  249. package/dist/types/Average.js.map +1 -0
  250. package/dist/types/Condition.d.ts +8 -0
  251. package/dist/types/Condition.js +2 -0
  252. package/dist/types/Condition.js.map +1 -0
  253. package/dist/types/Conditions.d.ts +5 -0
  254. package/dist/types/Conditions.js +2 -0
  255. package/dist/types/Conditions.js.map +1 -0
  256. package/dist/types/Config.d.ts +12 -0
  257. package/dist/types/Config.js +2 -0
  258. package/dist/types/Config.js.map +1 -0
  259. package/dist/types/Flow.d.ts +5 -0
  260. package/dist/types/Flow.js +2 -0
  261. package/dist/types/Flow.js.map +1 -0
  262. package/dist/types/GlobalOptions.d.ts +11 -0
  263. package/dist/types/GlobalOptions.js +2 -0
  264. package/dist/types/GlobalOptions.js.map +1 -0
  265. package/dist/types/Inputs.d.ts +5 -0
  266. package/dist/types/Inputs.js +2 -0
  267. package/dist/types/Inputs.js.map +1 -0
  268. package/dist/types/JsonLikeObject.d.ts +3 -0
  269. package/dist/types/JsonLikeObject.js +2 -0
  270. package/dist/types/JsonLikeObject.js.map +1 -0
  271. package/dist/types/Mapper.d.ts +5 -0
  272. package/dist/types/Mapper.js +2 -0
  273. package/dist/types/Mapper.js.map +1 -0
  274. package/dist/types/Node.d.ts +10 -0
  275. package/dist/types/Node.js +2 -0
  276. package/dist/types/Node.js.map +1 -0
  277. package/dist/types/ParamsDictionary.d.ts +3 -0
  278. package/dist/types/ParamsDictionary.js +2 -0
  279. package/dist/types/ParamsDictionary.js.map +1 -0
  280. package/dist/types/Properties.d.ts +5 -0
  281. package/dist/types/Properties.js +2 -0
  282. package/dist/types/Properties.js.map +1 -0
  283. package/dist/types/Targets.d.ts +5 -0
  284. package/dist/types/Targets.js +2 -0
  285. package/dist/types/Targets.js.map +1 -0
  286. package/dist/types/Trigger.d.ts +5 -0
  287. package/dist/types/Trigger.js +2 -0
  288. package/dist/types/Trigger.js.map +1 -0
  289. package/dist/types/TriggerHttp.d.ts +7 -0
  290. package/dist/types/TriggerHttp.js +2 -0
  291. package/dist/types/TriggerHttp.js.map +1 -0
  292. package/dist/types/TriggerResponse.d.ts +6 -0
  293. package/dist/types/TriggerResponse.js +2 -0
  294. package/dist/types/TriggerResponse.js.map +1 -0
  295. package/dist/types/Triggers.d.ts +5 -0
  296. package/dist/types/Triggers.js +2 -0
  297. package/dist/types/Triggers.js.map +1 -0
  298. package/dist/types/TryCatch.d.ts +6 -0
  299. package/dist/types/TryCatch.js +2 -0
  300. package/dist/types/TryCatch.js.map +1 -0
  301. package/dist/visualization/NodeDependencyGraph.d.ts +76 -0
  302. package/dist/visualization/NodeDependencyGraph.js +418 -0
  303. package/dist/visualization/NodeDependencyGraph.js.map +1 -0
  304. package/dist/visualization/WorkflowVisualizer.d.ts +144 -0
  305. package/dist/visualization/WorkflowVisualizer.js +446 -0
  306. package/dist/visualization/WorkflowVisualizer.js.map +1 -0
  307. package/package.json +95 -0
@@ -0,0 +1,652 @@
1
+ /**
2
+ * Secret Management for Blok Framework
3
+ *
4
+ * Provides a unified interface for secret management across multiple providers:
5
+ * - HashiCorp Vault (KV v2 engine via REST API)
6
+ * - AWS Secrets Manager (via @aws-sdk/client-secrets-manager)
7
+ * - GCP Secret Manager (via @google-cloud/secret-manager)
8
+ * - Environment Variables (process.env)
9
+ * - In-Memory (for testing)
10
+ *
11
+ * Features:
12
+ * - Provider chain: try providers in order, first match wins
13
+ * - Caching layer with TTL and max size (LRU eviction)
14
+ * - Audit event emission for secret access tracking
15
+ * - Template resolution for `${secret:KEY}` patterns
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * import {
20
+ * SecretManager,
21
+ * EnvironmentSecretProvider,
22
+ * InMemorySecretProvider,
23
+ * } from "@blokjs/runner";
24
+ *
25
+ * // Simple setup with environment variables
26
+ * const secrets = new SecretManager({
27
+ * providers: [
28
+ * { type: "environment", config: { prefix: "BLOK_SECRET_" } },
29
+ * ],
30
+ * cache: { enabled: true, ttlMs: 60_000, maxSize: 100 },
31
+ * auditLog: true,
32
+ * });
33
+ *
34
+ * const dbPassword = await secrets.getSecret("DB_PASSWORD");
35
+ * const connStr = await secrets.resolveTemplate(
36
+ * "postgres://user:${secret:DB_PASSWORD}@host/db"
37
+ * );
38
+ * ```
39
+ */
40
+ import { EventEmitter } from "node:events";
41
+ /**
42
+ * Metadata associated with a stored secret
43
+ */
44
+ export interface SecretMetadata {
45
+ /** Version identifier for the secret */
46
+ version?: string;
47
+ /** Unix timestamp (ms) when the secret expires */
48
+ expiresAt?: number;
49
+ /** Arbitrary key-value tags */
50
+ tags?: Record<string, string>;
51
+ /** Human-readable description of the secret */
52
+ description?: string;
53
+ }
54
+ /**
55
+ * Interface that all secret providers must implement
56
+ */
57
+ export interface SecretProvider {
58
+ /** Unique name identifying this provider instance */
59
+ readonly name: string;
60
+ /**
61
+ * Retrieve a secret value by key
62
+ * @param key - The secret key to look up
63
+ * @returns The secret value, or null if not found
64
+ */
65
+ get(key: string): Promise<string | null>;
66
+ /**
67
+ * Store or update a secret value
68
+ * @param key - The secret key
69
+ * @param value - The secret value
70
+ * @param metadata - Optional metadata to associate with the secret
71
+ */
72
+ set(key: string, value: string, metadata?: SecretMetadata): Promise<void>;
73
+ /**
74
+ * Delete a secret by key
75
+ * @param key - The secret key to delete
76
+ */
77
+ delete(key: string): Promise<void>;
78
+ /**
79
+ * List secret keys, optionally filtered by prefix
80
+ * @param prefix - Optional prefix to filter keys
81
+ * @returns Array of secret key names
82
+ */
83
+ list(prefix?: string): Promise<string[]>;
84
+ /**
85
+ * Check whether a secret exists
86
+ * @param key - The secret key to check
87
+ * @returns True if the secret exists
88
+ */
89
+ exists(key: string): Promise<boolean>;
90
+ }
91
+ /**
92
+ * Event emitted when a secret is accessed
93
+ */
94
+ export interface SecretAccessEvent {
95
+ /** Type of operation */
96
+ operation: "get" | "set" | "delete" | "list" | "exists";
97
+ /** Secret key (omitted for list operations) */
98
+ key?: string;
99
+ /** Provider that served the request */
100
+ provider: string;
101
+ /** Whether the operation succeeded */
102
+ success: boolean;
103
+ /** Whether the result came from cache */
104
+ cached: boolean;
105
+ /** ISO 8601 timestamp */
106
+ timestamp: string;
107
+ /** Error message if the operation failed */
108
+ error?: string;
109
+ }
110
+ /**
111
+ * Configuration for an environment variable secret provider
112
+ */
113
+ export interface EnvironmentProviderConfig {
114
+ type: "environment";
115
+ config?: {
116
+ /** Prefix prepended to key names when reading env vars (e.g., "BLOK_SECRET_") */
117
+ prefix?: string;
118
+ /** Whether key lookups are case-sensitive (default: true) */
119
+ caseSensitive?: boolean;
120
+ };
121
+ }
122
+ /**
123
+ * Configuration for the in-memory secret provider
124
+ */
125
+ export interface InMemoryProviderConfig {
126
+ type: "memory";
127
+ config?: Record<string, never>;
128
+ }
129
+ /**
130
+ * Configuration for the HashiCorp Vault secret provider
131
+ */
132
+ export interface VaultProviderConfig {
133
+ type: "vault";
134
+ config: {
135
+ /** Vault server address (e.g., "https://vault.example.com:8200") */
136
+ address: string;
137
+ /** Authentication token */
138
+ token?: string;
139
+ /** Vault namespace (enterprise feature) */
140
+ namespace?: string;
141
+ /** KV mount path (default: "secret") */
142
+ mountPath?: string;
143
+ /** API version (default: "v1") */
144
+ apiVersion?: string;
145
+ };
146
+ }
147
+ /**
148
+ * Configuration for the AWS Secrets Manager provider
149
+ */
150
+ export interface AWSSecretsProviderConfig {
151
+ type: "aws";
152
+ config: {
153
+ /** AWS region (e.g., "us-east-1") */
154
+ region: string;
155
+ /** AWS access key ID (falls back to SDK defaults if omitted) */
156
+ accessKeyId?: string;
157
+ /** AWS secret access key */
158
+ secretAccessKey?: string;
159
+ /** AWS profile name from credentials file */
160
+ profile?: string;
161
+ };
162
+ }
163
+ /**
164
+ * Configuration for the GCP Secret Manager provider
165
+ */
166
+ export interface GCPSecretProviderConfig {
167
+ type: "gcp";
168
+ config: {
169
+ /** GCP project ID */
170
+ projectId: string;
171
+ /** Path to service account key file */
172
+ keyFile?: string;
173
+ };
174
+ }
175
+ /**
176
+ * Union of all supported provider configurations
177
+ */
178
+ export type SecretProviderConfig = EnvironmentProviderConfig | InMemoryProviderConfig | VaultProviderConfig | AWSSecretsProviderConfig | GCPSecretProviderConfig;
179
+ /**
180
+ * Cache configuration for the secret manager
181
+ */
182
+ export interface SecretCacheConfig {
183
+ /** Whether caching is enabled */
184
+ enabled: boolean;
185
+ /** Time-to-live in milliseconds */
186
+ ttlMs: number;
187
+ /** Maximum number of cached entries (LRU eviction) */
188
+ maxSize: number;
189
+ }
190
+ /**
191
+ * Top-level configuration for SecretManager
192
+ */
193
+ export interface SecretManagerConfig {
194
+ /** Ordered list of provider configurations; first match wins */
195
+ providers: SecretProviderConfig[];
196
+ /** Optional caching layer */
197
+ cache?: SecretCacheConfig;
198
+ /** Whether to emit audit events on secret access (default: false) */
199
+ auditLog?: boolean;
200
+ }
201
+ /**
202
+ * Secret provider backed by process.env
203
+ *
204
+ * Reads environment variables, optionally with a prefix. Supports
205
+ * case-insensitive lookups when configured.
206
+ *
207
+ * @example
208
+ * ```typescript
209
+ * const provider = new EnvironmentSecretProvider({ prefix: "APP_" });
210
+ * // Reads process.env.APP_DATABASE_URL
211
+ * const dbUrl = await provider.get("DATABASE_URL");
212
+ * ```
213
+ */
214
+ export declare class EnvironmentSecretProvider implements SecretProvider {
215
+ readonly name = "environment";
216
+ private prefix;
217
+ private caseSensitive;
218
+ constructor(config?: {
219
+ prefix?: string;
220
+ caseSensitive?: boolean;
221
+ });
222
+ /**
223
+ * Retrieve an environment variable value
224
+ * @param key - Variable name (without prefix)
225
+ */
226
+ get(key: string): Promise<string | null>;
227
+ /**
228
+ * Set an environment variable (primarily useful for testing)
229
+ * @param key - Variable name (without prefix)
230
+ * @param value - Value to set
231
+ */
232
+ set(key: string, value: string, _metadata?: SecretMetadata): Promise<void>;
233
+ /**
234
+ * Delete an environment variable
235
+ * @param key - Variable name (without prefix)
236
+ */
237
+ delete(key: string): Promise<void>;
238
+ /**
239
+ * List environment variable names matching the configured prefix
240
+ * @param prefix - Additional prefix to filter by (applied after the provider prefix)
241
+ */
242
+ list(prefix?: string): Promise<string[]>;
243
+ /**
244
+ * Check whether an environment variable exists
245
+ * @param key - Variable name (without prefix)
246
+ */
247
+ exists(key: string): Promise<boolean>;
248
+ /**
249
+ * Build the full environment variable name from a logical key
250
+ */
251
+ private resolveKey;
252
+ }
253
+ /**
254
+ * In-memory secret provider for testing and development
255
+ *
256
+ * Stores secrets in a Map with full CRUD support. Provides stats
257
+ * for debugging and verification.
258
+ *
259
+ * @example
260
+ * ```typescript
261
+ * const provider = new InMemorySecretProvider();
262
+ * await provider.set("API_KEY", "test-key-123");
263
+ * const key = await provider.get("API_KEY"); // "test-key-123"
264
+ * console.log(provider.getStats()); // { size: 1, keys: ["API_KEY"] }
265
+ * ```
266
+ */
267
+ export declare class InMemorySecretProvider implements SecretProvider {
268
+ readonly name = "memory";
269
+ private store;
270
+ /**
271
+ * Retrieve a secret from the in-memory store
272
+ * @param key - The secret key
273
+ */
274
+ get(key: string): Promise<string | null>;
275
+ /**
276
+ * Store a secret in the in-memory store
277
+ * @param key - The secret key
278
+ * @param value - The secret value
279
+ * @param metadata - Optional metadata
280
+ */
281
+ set(key: string, value: string, metadata?: SecretMetadata): Promise<void>;
282
+ /**
283
+ * Delete a secret from the in-memory store
284
+ * @param key - The secret key
285
+ */
286
+ delete(key: string): Promise<void>;
287
+ /**
288
+ * List all secret keys, optionally filtered by prefix
289
+ * @param prefix - Optional prefix filter
290
+ */
291
+ list(prefix?: string): Promise<string[]>;
292
+ /**
293
+ * Check whether a secret exists in the store
294
+ * @param key - The secret key
295
+ */
296
+ exists(key: string): Promise<boolean>;
297
+ /**
298
+ * Get debug statistics about the in-memory store
299
+ * @returns Object with size and list of keys
300
+ */
301
+ getStats(): {
302
+ size: number;
303
+ keys: string[];
304
+ };
305
+ /**
306
+ * Clear all secrets from the store
307
+ */
308
+ clear(): void;
309
+ }
310
+ /**
311
+ * HashiCorp Vault secret provider (KV v2 engine)
312
+ *
313
+ * Communicates with Vault via its HTTP REST API using the native `fetch` API.
314
+ * Supports token-based authentication, namespaces, and configurable mount paths.
315
+ *
316
+ * @example
317
+ * ```typescript
318
+ * const vault = new VaultSecretProvider({
319
+ * address: "https://vault.example.com:8200",
320
+ * token: process.env.VAULT_TOKEN,
321
+ * mountPath: "secret",
322
+ * });
323
+ *
324
+ * const dbPassword = await vault.get("database/credentials");
325
+ * ```
326
+ */
327
+ export declare class VaultSecretProvider implements SecretProvider {
328
+ readonly name = "vault";
329
+ private address;
330
+ private token;
331
+ private namespace;
332
+ private mountPath;
333
+ private apiVersion;
334
+ constructor(config: {
335
+ address: string;
336
+ token?: string;
337
+ namespace?: string;
338
+ mountPath?: string;
339
+ apiVersion?: string;
340
+ });
341
+ /**
342
+ * Read a secret from Vault KV v2
343
+ * @param key - The secret path within the mount
344
+ */
345
+ get(key: string): Promise<string | null>;
346
+ /**
347
+ * Write a secret to Vault KV v2
348
+ * @param key - The secret path within the mount
349
+ * @param value - The secret value
350
+ * @param metadata - Optional metadata (stored as custom_metadata)
351
+ */
352
+ set(key: string, value: string, metadata?: SecretMetadata): Promise<void>;
353
+ /**
354
+ * Delete a secret from Vault KV v2
355
+ * @param key - The secret path within the mount
356
+ */
357
+ delete(key: string): Promise<void>;
358
+ /**
359
+ * List secret keys under a given path prefix
360
+ * @param prefix - Optional path prefix
361
+ */
362
+ list(prefix?: string): Promise<string[]>;
363
+ /**
364
+ * Check whether a secret exists in Vault
365
+ * @param key - The secret path within the mount
366
+ */
367
+ exists(key: string): Promise<boolean>;
368
+ /**
369
+ * Update the Vault token (e.g., after token renewal)
370
+ * @param token - The new Vault token
371
+ */
372
+ setToken(token: string): void;
373
+ /**
374
+ * Build the full URL for a Vault KV v2 API call
375
+ */
376
+ private buildUrl;
377
+ /**
378
+ * Build common HTTP headers for Vault requests
379
+ */
380
+ private buildHeaders;
381
+ /**
382
+ * Set custom metadata on a secret in Vault KV v2
383
+ */
384
+ private setMetadata;
385
+ }
386
+ /**
387
+ * AWS Secrets Manager provider
388
+ *
389
+ * Uses the `@aws-sdk/client-secrets-manager` SDK, loaded dynamically at
390
+ * first use to avoid hard dependencies.
391
+ *
392
+ * @example
393
+ * ```typescript
394
+ * const aws = new AWSSecretsProvider({
395
+ * region: "us-east-1",
396
+ * });
397
+ *
398
+ * const apiKey = await aws.get("prod/api-key");
399
+ * ```
400
+ */
401
+ export declare class AWSSecretsProvider implements SecretProvider {
402
+ readonly name = "aws";
403
+ private region;
404
+ private accessKeyId;
405
+ private secretAccessKey;
406
+ private profile;
407
+ private client;
408
+ constructor(config: {
409
+ region: string;
410
+ accessKeyId?: string;
411
+ secretAccessKey?: string;
412
+ profile?: string;
413
+ });
414
+ /**
415
+ * Retrieve a secret from AWS Secrets Manager
416
+ * @param key - The secret name or ARN
417
+ */
418
+ get(key: string): Promise<string | null>;
419
+ /**
420
+ * Create or update a secret in AWS Secrets Manager
421
+ * @param key - The secret name
422
+ * @param value - The secret value
423
+ * @param metadata - Optional metadata (tags and description supported)
424
+ */
425
+ set(key: string, value: string, metadata?: SecretMetadata): Promise<void>;
426
+ /**
427
+ * Delete a secret from AWS Secrets Manager
428
+ * @param key - The secret name or ARN
429
+ */
430
+ delete(key: string): Promise<void>;
431
+ /**
432
+ * List secrets in AWS Secrets Manager, optionally filtered by name prefix
433
+ * @param prefix - Optional name prefix filter
434
+ */
435
+ list(prefix?: string): Promise<string[]>;
436
+ /**
437
+ * Check whether a secret exists in AWS Secrets Manager
438
+ * @param key - The secret name or ARN
439
+ */
440
+ exists(key: string): Promise<boolean>;
441
+ /**
442
+ * Lazily initialize and cache the AWS SecretsManager client
443
+ */
444
+ private getClient;
445
+ /**
446
+ * Dynamically import the AWS Secrets Manager SDK
447
+ */
448
+ private getSDK;
449
+ /**
450
+ * Type-safe check for AWS SDK error names
451
+ */
452
+ private isAWSError;
453
+ }
454
+ /**
455
+ * Google Cloud Secret Manager provider
456
+ *
457
+ * Uses the `@google-cloud/secret-manager` SDK, loaded dynamically at
458
+ * first use to avoid hard dependencies.
459
+ *
460
+ * @example
461
+ * ```typescript
462
+ * const gcp = new GCPSecretProvider({
463
+ * projectId: "my-project",
464
+ * });
465
+ *
466
+ * const apiKey = await gcp.get("api-key");
467
+ * ```
468
+ */
469
+ export declare class GCPSecretProvider implements SecretProvider {
470
+ readonly name = "gcp";
471
+ private projectId;
472
+ private keyFile;
473
+ private client;
474
+ constructor(config: {
475
+ projectId: string;
476
+ keyFile?: string;
477
+ });
478
+ /**
479
+ * Retrieve the latest version of a secret from GCP Secret Manager
480
+ * @param key - The secret ID
481
+ */
482
+ get(key: string): Promise<string | null>;
483
+ /**
484
+ * Create a secret and add a version, or add a new version to an existing secret
485
+ * @param key - The secret ID
486
+ * @param value - The secret value
487
+ * @param metadata - Optional metadata (tags mapped to GCP labels)
488
+ */
489
+ set(key: string, value: string, metadata?: SecretMetadata): Promise<void>;
490
+ /**
491
+ * Delete a secret from GCP Secret Manager
492
+ * @param key - The secret ID
493
+ */
494
+ delete(key: string): Promise<void>;
495
+ /**
496
+ * List secrets in the GCP project, optionally filtered by prefix
497
+ * @param prefix - Optional prefix filter applied to secret IDs
498
+ */
499
+ list(prefix?: string): Promise<string[]>;
500
+ /**
501
+ * Check whether a secret exists in GCP Secret Manager
502
+ * @param key - The secret ID
503
+ */
504
+ exists(key: string): Promise<boolean>;
505
+ /**
506
+ * Lazily initialize and cache the GCP Secret Manager client
507
+ */
508
+ private getClient;
509
+ /**
510
+ * Check for GCP "not found" errors (gRPC status code 5)
511
+ */
512
+ private isGCPNotFoundError;
513
+ /**
514
+ * Check for specific gRPC error codes from the GCP SDK
515
+ */
516
+ private isGCPError;
517
+ }
518
+ /**
519
+ * Unified Secret Manager for the Blok Framework
520
+ *
521
+ * Orchestrates multiple secret providers with a provider chain (first match
522
+ * wins), optional caching, and audit event emission.
523
+ *
524
+ * @example
525
+ * ```typescript
526
+ * const manager = new SecretManager({
527
+ * providers: [
528
+ * { type: "vault", config: { address: "https://vault:8200", token: "s.xxx" } },
529
+ * { type: "environment", config: { prefix: "BLOK_" } },
530
+ * ],
531
+ * cache: { enabled: true, ttlMs: 300_000, maxSize: 500 },
532
+ * auditLog: true,
533
+ * });
534
+ *
535
+ * manager.on("secretAccess", (event) => {
536
+ * console.log(`[audit] ${event.operation} ${event.key} via ${event.provider}`);
537
+ * });
538
+ *
539
+ * const password = await manager.getSecretOrThrow("DB_PASSWORD");
540
+ * const connStr = await manager.resolveTemplate(
541
+ * "postgres://admin:${secret:DB_PASSWORD}@db:5432/app"
542
+ * );
543
+ * ```
544
+ */
545
+ export declare class SecretManager extends EventEmitter {
546
+ private providers;
547
+ private cache;
548
+ private cacheConfig;
549
+ private auditLog;
550
+ private cacheAccessOrder;
551
+ constructor(config: SecretManagerConfig);
552
+ /**
553
+ * Retrieve a secret value by key
554
+ *
555
+ * Checks the cache first (if enabled), then queries each provider
556
+ * in order until a value is found.
557
+ *
558
+ * @param key - The secret key
559
+ * @returns The secret value, or null if not found in any provider
560
+ */
561
+ getSecret(key: string): Promise<string | null>;
562
+ /**
563
+ * Retrieve a secret or throw if it does not exist
564
+ *
565
+ * @param key - The secret key
566
+ * @returns The secret value
567
+ * @throws Error if the secret is not found in any provider
568
+ */
569
+ getSecretOrThrow(key: string): Promise<string>;
570
+ /**
571
+ * Store a secret value in the first writable provider
572
+ *
573
+ * @param key - The secret key
574
+ * @param value - The secret value
575
+ * @param metadata - Optional metadata to associate with the secret
576
+ */
577
+ setSecret(key: string, value: string, metadata?: SecretMetadata): Promise<void>;
578
+ /**
579
+ * Delete a secret from all providers that contain it
580
+ *
581
+ * @param key - The secret key
582
+ */
583
+ deleteSecret(key: string): Promise<void>;
584
+ /**
585
+ * List secret keys across all providers, optionally filtered by prefix
586
+ *
587
+ * Merges results from all providers and deduplicates.
588
+ *
589
+ * @param prefix - Optional prefix filter
590
+ * @returns Deduplicated array of secret key names
591
+ */
592
+ listSecrets(prefix?: string): Promise<string[]>;
593
+ /**
594
+ * Check whether a secret exists in any provider
595
+ *
596
+ * @param key - The secret key
597
+ * @returns True if the secret exists in at least one provider
598
+ */
599
+ exists(key: string): Promise<boolean>;
600
+ /**
601
+ * Resolve `${secret:KEY}` patterns in a template string
602
+ *
603
+ * Replaces every occurrence of `${secret:SOME_KEY}` with the actual
604
+ * secret value from the provider chain. Missing secrets are replaced
605
+ * with an empty string.
606
+ *
607
+ * @param template - The template string with `${secret:...}` placeholders
608
+ * @returns The resolved string with secret values substituted
609
+ *
610
+ * @example
611
+ * ```typescript
612
+ * const resolved = await manager.resolveTemplate(
613
+ * "mongodb://${secret:MONGO_USER}:${secret:MONGO_PASS}@host/db"
614
+ * );
615
+ * ```
616
+ */
617
+ resolveTemplate(template: string): Promise<string>;
618
+ /**
619
+ * Get the list of configured providers
620
+ * @returns Array of provider instances
621
+ */
622
+ getProviders(): SecretProvider[];
623
+ /**
624
+ * Get current cache statistics
625
+ * @returns Object with cache size and hit information
626
+ */
627
+ getCacheStats(): {
628
+ size: number;
629
+ maxSize: number;
630
+ enabled: boolean;
631
+ };
632
+ /**
633
+ * Clear the secret cache
634
+ */
635
+ clearCache(): void;
636
+ /**
637
+ * Create a provider instance from its configuration
638
+ */
639
+ private createProvider;
640
+ /**
641
+ * Retrieve a value from the cache, returning undefined if not found or expired
642
+ */
643
+ private getCached;
644
+ /**
645
+ * Store a value in the cache with TTL, evicting LRU entries if at capacity
646
+ */
647
+ private setCache;
648
+ /**
649
+ * Emit a secret access audit event
650
+ */
651
+ private emitAccess;
652
+ }