@gravito/echo 3.1.1 → 3.1.2

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 (292) hide show
  1. package/README.md +24 -9
  2. package/dist/OrbitEcho.d.ts +76 -60
  3. package/dist/index.d.ts +31 -16
  4. package/dist/index.js +1 -1596
  5. package/dist/index.js.map +3 -28
  6. package/dist/{echo/src/middleware → middleware}/RequestBufferMiddleware.d.ts +3 -3
  7. package/dist/providers/GenericProvider.d.ts +37 -19
  8. package/dist/providers/GitHubProvider.d.ts +21 -13
  9. package/dist/providers/StripeProvider.d.ts +20 -13
  10. package/dist/providers/index.d.ts +14 -4
  11. package/dist/receive/SignatureValidator.d.ts +33 -1
  12. package/dist/receive/WebhookReceiver.d.ts +139 -22
  13. package/dist/receive/index.d.ts +0 -1
  14. package/dist/send/WebhookDispatcher.d.ts +159 -16
  15. package/dist/send/index.d.ts +0 -1
  16. package/dist/types.d.ts +669 -57
  17. package/package.json +5 -2
  18. package/dist/OrbitEcho.d.ts.map +0 -1
  19. package/dist/atlas/src/DB.d.ts +0 -348
  20. package/dist/atlas/src/OrbitAtlas.d.ts +0 -9
  21. package/dist/atlas/src/config/defineConfig.d.ts +0 -14
  22. package/dist/atlas/src/config/index.d.ts +0 -7
  23. package/dist/atlas/src/config/loadConfig.d.ts +0 -41
  24. package/dist/atlas/src/connection/Connection.d.ts +0 -112
  25. package/dist/atlas/src/connection/ConnectionManager.d.ts +0 -180
  26. package/dist/atlas/src/connection/ReplicaConnectionPool.d.ts +0 -54
  27. package/dist/atlas/src/drivers/BunSQLDriver.d.ts +0 -32
  28. package/dist/atlas/src/drivers/BunSQLPreparedStatement.d.ts +0 -118
  29. package/dist/atlas/src/drivers/MongoDBDriver.d.ts +0 -36
  30. package/dist/atlas/src/drivers/MySQLDriver.d.ts +0 -79
  31. package/dist/atlas/src/drivers/PostgresDriver.d.ts +0 -96
  32. package/dist/atlas/src/drivers/RedisDriver.d.ts +0 -43
  33. package/dist/atlas/src/drivers/SQLiteDriver.d.ts +0 -45
  34. package/dist/atlas/src/drivers/types.d.ts +0 -260
  35. package/dist/atlas/src/errors/index.d.ts +0 -45
  36. package/dist/atlas/src/grammar/Grammar.d.ts +0 -342
  37. package/dist/atlas/src/grammar/MongoGrammar.d.ts +0 -47
  38. package/dist/atlas/src/grammar/MySQLGrammar.d.ts +0 -54
  39. package/dist/atlas/src/grammar/NullGrammar.d.ts +0 -35
  40. package/dist/atlas/src/grammar/PostgresGrammar.d.ts +0 -62
  41. package/dist/atlas/src/grammar/SQLiteGrammar.d.ts +0 -32
  42. package/dist/atlas/src/index.d.ts +0 -79
  43. package/dist/atlas/src/migration/Migration.d.ts +0 -64
  44. package/dist/atlas/src/migration/MigrationRepository.d.ts +0 -65
  45. package/dist/atlas/src/migration/Migrator.d.ts +0 -110
  46. package/dist/atlas/src/migration/index.d.ts +0 -6
  47. package/dist/atlas/src/observability/AtlasMetrics.d.ts +0 -33
  48. package/dist/atlas/src/observability/AtlasObservability.d.ts +0 -15
  49. package/dist/atlas/src/observability/AtlasTracer.d.ts +0 -12
  50. package/dist/atlas/src/observability/index.d.ts +0 -9
  51. package/dist/atlas/src/orm/Repository.d.ts +0 -247
  52. package/dist/atlas/src/orm/index.d.ts +0 -6
  53. package/dist/atlas/src/orm/model/DirtyTracker.d.ts +0 -121
  54. package/dist/atlas/src/orm/model/Model.d.ts +0 -458
  55. package/dist/atlas/src/orm/model/ModelRegistry.d.ts +0 -20
  56. package/dist/atlas/src/orm/model/concerns/HasAttributes.d.ts +0 -150
  57. package/dist/atlas/src/orm/model/concerns/HasEvents.d.ts +0 -36
  58. package/dist/atlas/src/orm/model/concerns/HasPersistence.d.ts +0 -92
  59. package/dist/atlas/src/orm/model/concerns/HasRelationships.d.ts +0 -117
  60. package/dist/atlas/src/orm/model/concerns/HasSerialization.d.ts +0 -64
  61. package/dist/atlas/src/orm/model/concerns/applyMixins.d.ts +0 -15
  62. package/dist/atlas/src/orm/model/concerns/index.d.ts +0 -12
  63. package/dist/atlas/src/orm/model/decorators.d.ts +0 -138
  64. package/dist/atlas/src/orm/model/errors.d.ts +0 -52
  65. package/dist/atlas/src/orm/model/index.d.ts +0 -10
  66. package/dist/atlas/src/orm/model/relationships.d.ts +0 -207
  67. package/dist/atlas/src/orm/model/types.d.ts +0 -12
  68. package/dist/atlas/src/orm/schema/SchemaRegistry.d.ts +0 -124
  69. package/dist/atlas/src/orm/schema/SchemaSniffer.d.ts +0 -54
  70. package/dist/atlas/src/orm/schema/index.d.ts +0 -6
  71. package/dist/atlas/src/orm/schema/types.d.ts +0 -85
  72. package/dist/atlas/src/pool/AdaptivePoolManager.d.ts +0 -98
  73. package/dist/atlas/src/pool/PoolHealthChecker.d.ts +0 -91
  74. package/dist/atlas/src/pool/PoolStrategy.d.ts +0 -129
  75. package/dist/atlas/src/pool/PoolWarmer.d.ts +0 -92
  76. package/dist/atlas/src/query/Expression.d.ts +0 -60
  77. package/dist/atlas/src/query/NPlusOneDetector.d.ts +0 -10
  78. package/dist/atlas/src/query/QueryBuilder.d.ts +0 -643
  79. package/dist/atlas/src/query/RelationshipResolver.d.ts +0 -23
  80. package/dist/atlas/src/query/clauses/GroupByClause.d.ts +0 -51
  81. package/dist/atlas/src/query/clauses/HavingClause.d.ts +0 -70
  82. package/dist/atlas/src/query/clauses/JoinClause.d.ts +0 -87
  83. package/dist/atlas/src/query/clauses/LimitClause.d.ts +0 -82
  84. package/dist/atlas/src/query/clauses/OrderByClause.d.ts +0 -69
  85. package/dist/atlas/src/query/clauses/SelectClause.d.ts +0 -71
  86. package/dist/atlas/src/query/clauses/WhereClause.d.ts +0 -167
  87. package/dist/atlas/src/query/clauses/index.d.ts +0 -11
  88. package/dist/atlas/src/schema/Blueprint.d.ts +0 -276
  89. package/dist/atlas/src/schema/ColumnDefinition.d.ts +0 -154
  90. package/dist/atlas/src/schema/ForeignKeyDefinition.d.ts +0 -37
  91. package/dist/atlas/src/schema/MigrationGenerator.d.ts +0 -45
  92. package/dist/atlas/src/schema/Schema.d.ts +0 -131
  93. package/dist/atlas/src/schema/SchemaDiff.d.ts +0 -73
  94. package/dist/atlas/src/schema/TypeGenerator.d.ts +0 -57
  95. package/dist/atlas/src/schema/TypeWriter.d.ts +0 -42
  96. package/dist/atlas/src/schema/grammars/MySQLSchemaGrammar.d.ts +0 -23
  97. package/dist/atlas/src/schema/grammars/PostgresSchemaGrammar.d.ts +0 -26
  98. package/dist/atlas/src/schema/grammars/SQLiteSchemaGrammar.d.ts +0 -28
  99. package/dist/atlas/src/schema/grammars/SchemaGrammar.d.ts +0 -97
  100. package/dist/atlas/src/schema/grammars/index.d.ts +0 -7
  101. package/dist/atlas/src/schema/index.d.ts +0 -8
  102. package/dist/atlas/src/seed/Factory.d.ts +0 -90
  103. package/dist/atlas/src/seed/Seeder.d.ts +0 -28
  104. package/dist/atlas/src/seed/SeederRunner.d.ts +0 -74
  105. package/dist/atlas/src/seed/index.d.ts +0 -6
  106. package/dist/atlas/src/sharding/ShardingManager.d.ts +0 -59
  107. package/dist/atlas/src/types/index.d.ts +0 -1182
  108. package/dist/atlas/src/utils/CursorEncoding.d.ts +0 -63
  109. package/dist/atlas/src/utils/levenshtein.d.ts +0 -9
  110. package/dist/core/src/Application.d.ts +0 -215
  111. package/dist/core/src/CommandKernel.d.ts +0 -33
  112. package/dist/core/src/ConfigManager.d.ts +0 -65
  113. package/dist/core/src/Container/RequestScopeManager.d.ts +0 -62
  114. package/dist/core/src/Container/RequestScopeMetrics.d.ts +0 -144
  115. package/dist/core/src/Container.d.ts +0 -153
  116. package/dist/core/src/ErrorHandler.d.ts +0 -66
  117. package/dist/core/src/Event.d.ts +0 -5
  118. package/dist/core/src/EventManager.d.ts +0 -123
  119. package/dist/core/src/GlobalErrorHandlers.d.ts +0 -47
  120. package/dist/core/src/GravitoServer.d.ts +0 -28
  121. package/dist/core/src/HookManager.d.ts +0 -591
  122. package/dist/core/src/Listener.d.ts +0 -4
  123. package/dist/core/src/Logger.d.ts +0 -20
  124. package/dist/core/src/PlanetCore.d.ts +0 -378
  125. package/dist/core/src/RequestContext.d.ts +0 -97
  126. package/dist/core/src/Route.d.ts +0 -36
  127. package/dist/core/src/Router.d.ts +0 -284
  128. package/dist/core/src/ServiceProvider.d.ts +0 -178
  129. package/dist/core/src/adapters/GravitoEngineAdapter.d.ts +0 -27
  130. package/dist/core/src/adapters/PhotonAdapter.d.ts +0 -175
  131. package/dist/core/src/adapters/bun/BunContext.d.ts +0 -49
  132. package/dist/core/src/adapters/bun/BunNativeAdapter.d.ts +0 -31
  133. package/dist/core/src/adapters/bun/BunRequest.d.ts +0 -31
  134. package/dist/core/src/adapters/bun/RadixNode.d.ts +0 -19
  135. package/dist/core/src/adapters/bun/RadixRouter.d.ts +0 -31
  136. package/dist/core/src/adapters/bun/types.d.ts +0 -20
  137. package/dist/core/src/adapters/photon-types.d.ts +0 -73
  138. package/dist/core/src/adapters/types.d.ts +0 -235
  139. package/dist/core/src/cli/queue-commands.d.ts +0 -6
  140. package/dist/core/src/engine/AOTRouter.d.ts +0 -129
  141. package/dist/core/src/engine/FastContext.d.ts +0 -123
  142. package/dist/core/src/engine/Gravito.d.ts +0 -136
  143. package/dist/core/src/engine/MinimalContext.d.ts +0 -100
  144. package/dist/core/src/engine/analyzer.d.ts +0 -27
  145. package/dist/core/src/engine/constants.d.ts +0 -23
  146. package/dist/core/src/engine/index.d.ts +0 -26
  147. package/dist/core/src/engine/path.d.ts +0 -26
  148. package/dist/core/src/engine/pool.d.ts +0 -83
  149. package/dist/core/src/engine/types.d.ts +0 -146
  150. package/dist/core/src/error-handling/RequestScopeErrorContext.d.ts +0 -126
  151. package/dist/core/src/events/BackpressureManager.d.ts +0 -215
  152. package/dist/core/src/events/CircuitBreaker.d.ts +0 -229
  153. package/dist/core/src/events/DeadLetterQueue.d.ts +0 -219
  154. package/dist/core/src/events/EventBackend.d.ts +0 -12
  155. package/dist/core/src/events/EventOptions.d.ts +0 -204
  156. package/dist/core/src/events/EventPriorityQueue.d.ts +0 -301
  157. package/dist/core/src/events/FlowControlStrategy.d.ts +0 -109
  158. package/dist/core/src/events/IdempotencyCache.d.ts +0 -60
  159. package/dist/core/src/events/MessageQueueBridge.d.ts +0 -184
  160. package/dist/core/src/events/PriorityEscalationManager.d.ts +0 -82
  161. package/dist/core/src/events/RetryScheduler.d.ts +0 -104
  162. package/dist/core/src/events/WorkerPool.d.ts +0 -98
  163. package/dist/core/src/events/WorkerPoolConfig.d.ts +0 -153
  164. package/dist/core/src/events/WorkerPoolMetrics.d.ts +0 -65
  165. package/dist/core/src/events/aggregation/AggregationWindow.d.ts +0 -77
  166. package/dist/core/src/events/aggregation/DeduplicationManager.d.ts +0 -135
  167. package/dist/core/src/events/aggregation/EventAggregationManager.d.ts +0 -108
  168. package/dist/core/src/events/aggregation/EventBatcher.d.ts +0 -99
  169. package/dist/core/src/events/aggregation/types.d.ts +0 -117
  170. package/dist/core/src/events/index.d.ts +0 -25
  171. package/dist/core/src/events/observability/EventMetrics.d.ts +0 -132
  172. package/dist/core/src/events/observability/EventTracer.d.ts +0 -68
  173. package/dist/core/src/events/observability/EventTracing.d.ts +0 -161
  174. package/dist/core/src/events/observability/OTelEventMetrics.d.ts +0 -332
  175. package/dist/core/src/events/observability/ObservableHookManager.d.ts +0 -108
  176. package/dist/core/src/events/observability/StreamWorkerMetrics.d.ts +0 -76
  177. package/dist/core/src/events/observability/index.d.ts +0 -24
  178. package/dist/core/src/events/observability/metrics-types.d.ts +0 -16
  179. package/dist/core/src/events/types.d.ts +0 -134
  180. package/dist/core/src/exceptions/AuthenticationException.d.ts +0 -8
  181. package/dist/core/src/exceptions/AuthorizationException.d.ts +0 -8
  182. package/dist/core/src/exceptions/CircularDependencyException.d.ts +0 -9
  183. package/dist/core/src/exceptions/GravitoException.d.ts +0 -23
  184. package/dist/core/src/exceptions/HttpException.d.ts +0 -9
  185. package/dist/core/src/exceptions/ModelNotFoundException.d.ts +0 -10
  186. package/dist/core/src/exceptions/ValidationException.d.ts +0 -22
  187. package/dist/core/src/exceptions/index.d.ts +0 -7
  188. package/dist/core/src/health/HealthProvider.d.ts +0 -67
  189. package/dist/core/src/helpers/Arr.d.ts +0 -19
  190. package/dist/core/src/helpers/Str.d.ts +0 -23
  191. package/dist/core/src/helpers/data.d.ts +0 -25
  192. package/dist/core/src/helpers/errors.d.ts +0 -34
  193. package/dist/core/src/helpers/response.d.ts +0 -41
  194. package/dist/core/src/helpers.d.ts +0 -338
  195. package/dist/core/src/http/CookieJar.d.ts +0 -51
  196. package/dist/core/src/http/cookie.d.ts +0 -29
  197. package/dist/core/src/http/middleware/BodySizeLimit.d.ts +0 -16
  198. package/dist/core/src/http/middleware/Cors.d.ts +0 -24
  199. package/dist/core/src/http/middleware/Csrf.d.ts +0 -23
  200. package/dist/core/src/http/middleware/HeaderTokenGate.d.ts +0 -28
  201. package/dist/core/src/http/middleware/SecurityHeaders.d.ts +0 -29
  202. package/dist/core/src/http/middleware/ThrottleRequests.d.ts +0 -18
  203. package/dist/core/src/http/types.d.ts +0 -374
  204. package/dist/core/src/index.d.ts +0 -88
  205. package/dist/core/src/instrumentation/index.d.ts +0 -35
  206. package/dist/core/src/instrumentation/opentelemetry.d.ts +0 -178
  207. package/dist/core/src/instrumentation/types.d.ts +0 -182
  208. package/dist/core/src/observability/Metrics.d.ts +0 -244
  209. package/dist/core/src/observability/QueueDashboard.d.ts +0 -136
  210. package/dist/core/src/reliability/DeadLetterQueueManager.d.ts +0 -350
  211. package/dist/core/src/reliability/RetryPolicy.d.ts +0 -217
  212. package/dist/core/src/reliability/index.d.ts +0 -6
  213. package/dist/core/src/router/ControllerDispatcher.d.ts +0 -12
  214. package/dist/core/src/router/RequestValidator.d.ts +0 -20
  215. package/dist/core/src/runtime.d.ts +0 -119
  216. package/dist/core/src/security/Encrypter.d.ts +0 -33
  217. package/dist/core/src/security/Hasher.d.ts +0 -29
  218. package/dist/core/src/testing/HttpTester.d.ts +0 -39
  219. package/dist/core/src/testing/TestResponse.d.ts +0 -78
  220. package/dist/core/src/testing/index.d.ts +0 -2
  221. package/dist/core/src/types/events.d.ts +0 -94
  222. package/dist/echo/src/OrbitEcho.d.ts +0 -115
  223. package/dist/echo/src/index.d.ts +0 -64
  224. package/dist/echo/src/providers/GenericProvider.d.ts +0 -53
  225. package/dist/echo/src/providers/GitHubProvider.d.ts +0 -35
  226. package/dist/echo/src/providers/StripeProvider.d.ts +0 -38
  227. package/dist/echo/src/providers/index.d.ts +0 -14
  228. package/dist/echo/src/receive/SignatureValidator.d.ts +0 -67
  229. package/dist/echo/src/receive/WebhookReceiver.d.ts +0 -185
  230. package/dist/echo/src/receive/index.d.ts +0 -2
  231. package/dist/echo/src/send/WebhookDispatcher.d.ts +0 -198
  232. package/dist/echo/src/send/index.d.ts +0 -1
  233. package/dist/echo/src/types.d.ts +0 -756
  234. package/dist/index.d.ts.map +0 -1
  235. package/dist/monitor/src/MonitorOrbit.d.ts +0 -43
  236. package/dist/monitor/src/config.d.ts +0 -106
  237. package/dist/monitor/src/health/HealthController.d.ts +0 -28
  238. package/dist/monitor/src/health/HealthRegistry.d.ts +0 -80
  239. package/dist/monitor/src/health/index.d.ts +0 -36
  240. package/dist/monitor/src/index.d.ts +0 -13
  241. package/dist/monitor/src/metrics/MetricsController.d.ts +0 -22
  242. package/dist/monitor/src/metrics/MetricsRegistry.d.ts +0 -136
  243. package/dist/monitor/src/metrics/index.d.ts +0 -11
  244. package/dist/monitor/src/tracing/TracingManager.d.ts +0 -97
  245. package/dist/monitor/src/tracing/index.d.ts +0 -10
  246. package/dist/photon/src/index.d.ts +0 -89
  247. package/dist/photon/src/middleware/binary.d.ts +0 -31
  248. package/dist/photon/src/middleware/htmx.d.ts +0 -39
  249. package/dist/photon/src/middleware/ratelimit-redis.d.ts +0 -50
  250. package/dist/photon/src/middleware/ratelimit.d.ts +0 -161
  251. package/dist/photon/src/openapi.d.ts +0 -19
  252. package/dist/providers/GenericProvider.d.ts.map +0 -1
  253. package/dist/providers/GitHubProvider.d.ts.map +0 -1
  254. package/dist/providers/StripeProvider.d.ts.map +0 -1
  255. package/dist/providers/index.d.ts.map +0 -1
  256. package/dist/receive/SignatureValidator.d.ts.map +0 -1
  257. package/dist/receive/WebhookReceiver.d.ts.map +0 -1
  258. package/dist/receive/index.d.ts.map +0 -1
  259. package/dist/send/WebhookDispatcher.d.ts.map +0 -1
  260. package/dist/send/index.d.ts.map +0 -1
  261. package/dist/types.d.ts.map +0 -1
  262. /package/dist/{echo/src/dlq → dlq}/DeadLetterQueue.d.ts +0 -0
  263. /package/dist/{echo/src/dlq → dlq}/MemoryDeadLetterQueue.d.ts +0 -0
  264. /package/dist/{echo/src/dlq → dlq}/index.d.ts +0 -0
  265. /package/dist/{echo/src/middleware → middleware}/index.d.ts +0 -0
  266. /package/dist/{echo/src/observability → observability}/index.d.ts +0 -0
  267. /package/dist/{echo/src/observability → observability}/logging/ConsoleEchoLogger.d.ts +0 -0
  268. /package/dist/{echo/src/observability → observability}/logging/EchoLogger.d.ts +0 -0
  269. /package/dist/{echo/src/observability → observability}/logging/index.d.ts +0 -0
  270. /package/dist/{echo/src/observability → observability}/metrics/MetricsProvider.d.ts +0 -0
  271. /package/dist/{echo/src/observability → observability}/metrics/NoopMetricsProvider.d.ts +0 -0
  272. /package/dist/{echo/src/observability → observability}/metrics/PrometheusMetricsProvider.d.ts +0 -0
  273. /package/dist/{echo/src/observability → observability}/metrics/index.d.ts +0 -0
  274. /package/dist/{echo/src/observability → observability}/tracing/NoopTracer.d.ts +0 -0
  275. /package/dist/{echo/src/observability → observability}/tracing/Tracer.d.ts +0 -0
  276. /package/dist/{echo/src/observability → observability}/tracing/index.d.ts +0 -0
  277. /package/dist/{echo/src/providers → providers}/LinearProvider.d.ts +0 -0
  278. /package/dist/{echo/src/providers → providers}/PaddleProvider.d.ts +0 -0
  279. /package/dist/{echo/src/providers → providers}/ShopifyProvider.d.ts +0 -0
  280. /package/dist/{echo/src/providers → providers}/SlackProvider.d.ts +0 -0
  281. /package/dist/{echo/src/providers → providers}/TwilioProvider.d.ts +0 -0
  282. /package/dist/{echo/src/providers → providers}/base/BaseProvider.d.ts +0 -0
  283. /package/dist/{echo/src/providers → providers}/base/HeaderUtils.d.ts +0 -0
  284. /package/dist/{echo/src/replay → replay}/WebhookReplayService.d.ts +0 -0
  285. /package/dist/{echo/src/replay → replay}/index.d.ts +0 -0
  286. /package/dist/{echo/src/resilience → resilience}/CircuitBreaker.d.ts +0 -0
  287. /package/dist/{echo/src/resilience → resilience}/index.d.ts +0 -0
  288. /package/dist/{echo/src/rotation → rotation}/KeyRotationManager.d.ts +0 -0
  289. /package/dist/{echo/src/rotation → rotation}/index.d.ts +0 -0
  290. /package/dist/{echo/src/storage → storage}/MemoryWebhookStore.d.ts +0 -0
  291. /package/dist/{echo/src/storage → storage}/WebhookStore.d.ts +0 -0
  292. /package/dist/{echo/src/storage → storage}/index.d.ts +0 -0
@@ -1,38 +0,0 @@
1
- /**
2
- * Stripe webhook provider.
3
- * @module @gravito/echo/providers
4
- */
5
- import type { WebhookVerificationResult } from '../types';
6
- import { BaseProvider } from './base/BaseProvider';
7
- /**
8
- * Stripe webhook provider.
9
- *
10
- * Verifies Stripe webhook signatures using their standard format.
11
- * @see {@link https://stripe.com/docs/webhooks/signatures | Stripe Webhook Signatures}
12
- *
13
- * @example
14
- * ```typescript
15
- * const provider = new StripeProvider();
16
- * const result = await provider.verify(body, headers, process.env.STRIPE_WEBHOOK_SECRET);
17
- * ```
18
- */
19
- export declare class StripeProvider extends BaseProvider {
20
- readonly name = "stripe";
21
- constructor(options?: {
22
- tolerance?: number;
23
- });
24
- /**
25
- * Verifies the Stripe webhook signature.
26
- *
27
- * @param payload - Raw request body.
28
- * @param headers - Request headers.
29
- * @param secret - Stripe webhook secret (signing secret).
30
- * @returns Verification result.
31
- * @throws Error if signature computation fails.
32
- */
33
- verify(payload: string | Buffer, headers: Record<string, string | string[] | undefined>, secret: string): Promise<WebhookVerificationResult>;
34
- /**
35
- * Extracts the event type from the Stripe payload.
36
- */
37
- parseEventType(payload: unknown): string | undefined;
38
- }
@@ -1,14 +0,0 @@
1
- /**
2
- * Webhook providers for various services.
3
- * @module @gravito/echo/providers
4
- */
5
- export { BaseProvider, type ProviderOptions } from './base/BaseProvider';
6
- export { getHeader, getHeaders, hasHeader } from './base/HeaderUtils';
7
- export { GenericProvider } from './GenericProvider';
8
- export { GitHubProvider } from './GitHubProvider';
9
- export { LinearProvider } from './LinearProvider';
10
- export { PaddleProvider } from './PaddleProvider';
11
- export { ShopifyProvider } from './ShopifyProvider';
12
- export { SlackProvider } from './SlackProvider';
13
- export { StripeProvider } from './StripeProvider';
14
- export { TwilioProvider } from './TwilioProvider';
@@ -1,67 +0,0 @@
1
- /**
2
- * @fileoverview Signature validation utilities
3
- *
4
- * Provides HMAC-based signature verification for webhook payloads.
5
- *
6
- * @module @gravito/echo/receive
7
- */
8
- /**
9
- * Compute HMAC-SHA256 signature
10
- */
11
- export declare function computeHmacSha256(payload: string | Buffer, secret: string): Promise<string>;
12
- /**
13
- * Computes an HMAC-SHA256 signature and returns it as a base64 encoded string.
14
- *
15
- * Used by providers that require base64 encoding for their signatures (e.g., Shopify).
16
- *
17
- * @param payload - The raw data to sign.
18
- * @param secret - The shared secret key.
19
- * @returns The base64 encoded HMAC-SHA256 signature.
20
- * @throws Error if the crypto operations fail.
21
- *
22
- * @example
23
- * ```typescript
24
- * const sig = await computeHmacSha256Base64('data', 'secret');
25
- * ```
26
- */
27
- export declare function computeHmacSha256Base64(payload: string | Buffer, secret: string): Promise<string>;
28
- /**
29
- * Compute HMAC-SHA1 signature (for legacy providers)
30
- */
31
- export declare function computeHmacSha1(payload: string | Buffer, secret: string): Promise<string>;
32
- /**
33
- * Computes an HMAC-SHA1 signature and returns it as a base64 encoded string.
34
- *
35
- * Primarily used for legacy services or specific providers like Twilio that
36
- * still rely on SHA1-based HMAC for their webhook verification.
37
- *
38
- * @param payload - The raw data to sign.
39
- * @param secret - The shared secret key.
40
- * @returns The base64 encoded HMAC-SHA1 signature.
41
- * @throws Error if the crypto operations fail.
42
- *
43
- * @example
44
- * ```typescript
45
- * const sig = await computeHmacSha1Base64('data', 'secret');
46
- * ```
47
- */
48
- export declare function computeHmacSha1Base64(payload: string | Buffer, secret: string): Promise<string>;
49
- /**
50
- * Timing-safe string comparison to prevent timing attacks
51
- */
52
- export declare function timingSafeEqual(a: string, b: string): boolean;
53
- /**
54
- * Validate timestamp is within tolerance
55
- *
56
- * @param timestamp - Unix timestamp in seconds
57
- * @param tolerance - Tolerance in seconds (default: 300 = 5 minutes)
58
- */
59
- export declare function validateTimestamp(timestamp: number, tolerance?: number): boolean;
60
- /**
61
- * Parse Stripe-style signature header
62
- * Format: t=timestamp,v1=signature,v1=signature2
63
- */
64
- export declare function parseStripeSignature(header: string): {
65
- timestamp: number;
66
- signatures: string[];
67
- } | null;
@@ -1,185 +0,0 @@
1
- /**
2
- * @fileoverview Webhook Receiver
3
- *
4
- * Handles incoming webhooks with signature verification.
5
- *
6
- * @module @gravito/echo/receive
7
- */
8
- import type { GravitoContext } from '@gravito/core';
9
- import { type EchoLogger } from '../observability/logging';
10
- import { type MetricsProvider } from '../observability/metrics';
11
- import { type Tracer } from '../observability/tracing';
12
- import type { KeyRotationManager } from '../rotation/KeyRotationManager';
13
- import type { WebhookStore } from '../storage/WebhookStore';
14
- import type { ProviderKeyEntry, WebhookHandler, WebhookProvider, WebhookVerificationResult } from '../types';
15
- type ProviderClass = new (options?: Record<string, unknown>) => WebhookProvider;
16
- /**
17
- * WebhookReceiver orchestrates the end-to-end lifecycle of incoming webhooks.
18
- *
19
- * It acts as the central intake for all incoming requests, managing provider-specific
20
- * verification logic, multi-key rotation checks, persistent storage for auditing,
21
- * and routing validated events to their respective application-level handlers.
22
- *
23
- * @example Basic usage with Stripe
24
- * ```typescript
25
- * const receiver = new WebhookReceiver();
26
- *
27
- * // Register Stripe with its signing secret
28
- * receiver.registerProvider('stripe', 'whsec_...');
29
- *
30
- * // Listen for payment success events
31
- * receiver.on('stripe', 'payment_intent.succeeded', async (event) => {
32
- * const payment = event.payload;
33
- * await processPayment(payment.id);
34
- * });
35
- * ```
36
- *
37
- * @public
38
- */
39
- export declare class WebhookReceiver {
40
- private providers;
41
- private handlers;
42
- private globalHandlers;
43
- private store?;
44
- private metrics;
45
- private tracer;
46
- private logger;
47
- private keyRotationManager?;
48
- /**
49
- * Initializes the receiver and registers the suite of built-in providers.
50
- * Built-in providers include Stripe, GitHub, Shopify, Twilio, Slack, and others.
51
- */
52
- constructor();
53
- private providerTypes;
54
- /**
55
- * Assigns a storage engine for persisting and auditing incoming webhook data.
56
- *
57
- * @param store - Implementation of the WebhookStore interface.
58
- * @returns The current instance for method chaining.
59
- */
60
- setStore(store: WebhookStore): this;
61
- /**
62
- * Configures the metrics provider for performance and error monitoring.
63
- *
64
- * @param metrics - Implementation of the MetricsProvider interface.
65
- * @returns The current instance for method chaining.
66
- */
67
- setMetrics(metrics: MetricsProvider): this;
68
- /**
69
- * Configures the tracer for end-to-end request observability.
70
- *
71
- * @param tracer - Implementation of the Tracer interface.
72
- * @returns The current instance for method chaining.
73
- */
74
- setTracer(tracer: Tracer): this;
75
- /**
76
- * Configures the logger for diagnostic and security audit logging.
77
- *
78
- * @param logger - Implementation of the EchoLogger interface.
79
- * @returns The current instance for method chaining.
80
- */
81
- setLogger(logger: EchoLogger): this;
82
- /**
83
- * Attaches a key rotation manager for handling dynamic secret updates.
84
- *
85
- * @param manager - Instance of KeyRotationManager.
86
- * @returns The current instance for method chaining.
87
- */
88
- setKeyRotationManager(manager: KeyRotationManager): this;
89
- /**
90
- * Extends the receiver with a custom webhook provider implementation.
91
- *
92
- * Use this to add support for services not included in the built-in provider set.
93
- *
94
- * @param name - Unique identifier for the provider type (e.g., 'custom-crm').
95
- * @param ProviderCls - Constructor for the class implementing WebhookProvider.
96
- * @returns The current instance for method chaining.
97
- */
98
- registerProviderType(name: string, ProviderCls: ProviderClass): this;
99
- /**
100
- * Configures a named provider instance with its security credentials.
101
- *
102
- * @param name - Unique identifier for this provider instance (used in routing).
103
- * @param secret - The shared secret used to verify incoming request signatures.
104
- * @param options - Settings like the provider type and signature time tolerance.
105
- * @returns The current instance for method chaining.
106
- * @throws {Error} If the specified provider type has not been registered.
107
- */
108
- registerProvider(name: string, secret: string, options?: {
109
- type?: string;
110
- tolerance?: number;
111
- }): this;
112
- /**
113
- * Registers a provider instance with support for multiple secrets and rotation.
114
- *
115
- * This is the preferred registration method for high-availability environments
116
- * where zero-downtime key rotation is required.
117
- *
118
- * @param name - Unique identifier for this provider instance.
119
- * @param keys - A list of valid keys (active and pending) for this provider.
120
- * @param options - Settings like the provider type and signature time tolerance.
121
- * @returns The current instance for method chaining.
122
- * @throws {Error} If KeyRotationManager is not set or the provider type is unknown.
123
- */
124
- registerProviderWithRotation(name: string, keys: ProviderKeyEntry[], options?: {
125
- type?: string;
126
- tolerance?: number;
127
- }): this;
128
- /**
129
- * Subscribes a handler function to a specific event type from a provider.
130
- *
131
- * @param providerName - The name of the registered provider instance.
132
- * @param eventType - The exact semantic type of the event (e.g., 'order.placed').
133
- * @param handler - The asynchronous function to execute when a matching event arrives.
134
- * @returns The current instance for method chaining.
135
- */
136
- on<T = unknown>(providerName: string, eventType: string, handler: WebhookHandler<T>): this;
137
- /**
138
- * Subscribes a catch-all handler for all valid events from a specific provider.
139
- *
140
- * @param providerName - The name of the registered provider instance.
141
- * @param handler - Function to execute for every authenticated event from this provider.
142
- * @returns The current instance for method chaining.
143
- */
144
- onAll<T = unknown>(providerName: string, handler: WebhookHandler<T>): this;
145
- /**
146
- * Orchestrates the verification and asynchronous processing of an incoming webhook.
147
- *
148
- * This is the main entry point for requests. It performs the following:
149
- * 1. Signature validation (supporting multi-key fallback if rotation is enabled).
150
- * 2. Event persistence to storage for audit trails.
151
- * 3. Execution of all matching event-specific and global handlers.
152
- * 4. Automatic instrumentation for metrics and tracing.
153
- *
154
- * @param providerName - The name of the provider instance targeted by the request.
155
- * @param body - The raw request body as received from the socket.
156
- * @param headers - Complete set of HTTP headers for signature extraction.
157
- * @param context - Optional Gravito context for accessing buffered requests.
158
- * @returns Verification status, event metadata, and processing result.
159
- * @throws {Error} If handler execution or event storage fails.
160
- */
161
- handle(providerName: string, body: string | Buffer, headers: Record<string, string | string[] | undefined>, context?: GravitoContext): Promise<WebhookVerificationResult & {
162
- handled: boolean;
163
- eventId?: string;
164
- }>;
165
- /**
166
- * Internal utility to categorize verification errors for metrics reporting.
167
- *
168
- * @param error - The raw error message from the provider or rotation manager.
169
- * @returns A semantic error category string (e.g., 'missing_header', 'signature_invalid').
170
- */
171
- private categorizeError;
172
- /**
173
- * Performs a standalone signature verification without triggering side-effects.
174
- *
175
- * This method verifies the authenticity of a webhook request without persisting it
176
- * to storage or executing any registered handlers. Useful for pre-validation logic.
177
- *
178
- * @param providerName - The identifier of the provider instance to use for verification.
179
- * @param body - The raw request body.
180
- * @param headers - The incoming HTTP headers.
181
- * @returns A promise resolving to the verification result.
182
- */
183
- verify(providerName: string, body: string | Buffer, headers: Record<string, string | string[] | undefined>): Promise<WebhookVerificationResult>;
184
- }
185
- export {};
@@ -1,2 +0,0 @@
1
- export * from './SignatureValidator';
2
- export * from './WebhookReceiver';
@@ -1,198 +0,0 @@
1
- /**
2
- * @fileoverview Webhook Dispatcher
3
- *
4
- * Reliably sends webhooks to external services with retry support.
5
- *
6
- * @module @gravito/echo/send
7
- */
8
- import type { DeadLetterQueue } from '../dlq/DeadLetterQueue';
9
- import type { EchoLogger } from '../observability/logging';
10
- import { type MetricsProvider } from '../observability/metrics';
11
- import { type Tracer } from '../observability/tracing';
12
- import type { BatchDispatchOptions, BatchDispatchResult, CircuitBreakerMetrics, WebhookDeliveryResult, WebhookDispatcherConfig, WebhookPayload } from '../types';
13
- /**
14
- * WebhookDispatcher manages the secure and reliable delivery of events to external targets.
15
- *
16
- * It provides a robust engine for sending signed webhook payloads to third-party
17
- * consumers, incorporating enterprise-grade reliability features such as:
18
- * - Exponential backoff retries for transient network/server errors.
19
- * - Per-host Circuit Breaking to prevent cascading failures.
20
- * - Dead Letter Queue (DLQ) integration for capturing permanently failed events.
21
- * - HMAC-SHA256 payload signing for authenticity.
22
- *
23
- * @example Dispatching a signed event
24
- * ```typescript
25
- * const dispatcher = new WebhookDispatcher({
26
- * secret: 'app-outbound-secret',
27
- * retry: { maxAttempts: 5 }
28
- * });
29
- *
30
- * const result = await dispatcher.dispatch({
31
- * url: 'https://consumer.com/webhooks',
32
- * event: 'order.shipped',
33
- * data: { orderId: 'ORD-123' }
34
- * });
35
- *
36
- * if (result.success) {
37
- * console.log('Webhook delivered successfully');
38
- * }
39
- * ```
40
- *
41
- * @public
42
- */
43
- export declare class WebhookDispatcher {
44
- private secret;
45
- private retryConfig;
46
- private timeout;
47
- private userAgent;
48
- private dlq?;
49
- private metrics;
50
- private tracer;
51
- private logger?;
52
- private circuitBreakers;
53
- private circuitBreakerConfig?;
54
- /**
55
- * Initializes the dispatcher with security and reliability policies.
56
- *
57
- * @param config - The configuration for payload signing, retry logic, and timeouts.
58
- */
59
- constructor(config: WebhookDispatcherConfig);
60
- /**
61
- * Attaches a Dead Letter Queue for capturing events that fail all delivery attempts.
62
- *
63
- * @param dlq - Implementation of the DeadLetterQueue interface.
64
- * @returns The current instance for method chaining.
65
- */
66
- setDeadLetterQueue(dlq: DeadLetterQueue): this;
67
- /**
68
- * Configures the metrics provider for delivery and failure tracking.
69
- *
70
- * @param metrics - Implementation of the MetricsProvider interface.
71
- * @returns The current instance for method chaining.
72
- */
73
- setMetrics(metrics: MetricsProvider): this;
74
- /**
75
- * Configures the distributed tracer for end-to-end request visibility.
76
- *
77
- * @param tracer - Implementation of the Tracer interface.
78
- * @returns The current instance for method chaining.
79
- */
80
- setTracer(tracer: Tracer): this;
81
- /**
82
- * Configures the logger for diagnostic and delivery audit logging.
83
- *
84
- * @param logger - Implementation of the EchoLogger interface.
85
- * @returns The current instance for method chaining.
86
- */
87
- setLogger(logger: EchoLogger): this;
88
- /**
89
- * Resolves or creates a dedicated circuit breaker instance for a specific host.
90
- *
91
- * Using per-host isolation ensures that an outage at one consumer does not
92
- * block or slow down deliveries to other healthy consumers.
93
- *
94
- * @param url - Destination URL used to derive the target host.
95
- * @returns The active circuit breaker instance, or undefined if disabled.
96
- */
97
- private getCircuitBreaker;
98
- /**
99
- * Retrieves the current health metrics for a specific target's circuit breaker.
100
- *
101
- * @param url - The target URL whose host metrics are requested.
102
- * @returns Current metrics or null if circuit breaking is not active for the host.
103
- */
104
- getCircuitBreakerMetrics(url: string): CircuitBreakerMetrics | null;
105
- /**
106
- * Manually resets a tripped circuit breaker to its CLOSED state for a specific target.
107
- *
108
- * @param url - The target URL whose host circuit should be reset.
109
- */
110
- resetCircuitBreaker(url: string): void;
111
- /**
112
- * Executes the end-to-end delivery of a signed webhook event.
113
- *
114
- * This method performs the following:
115
- * 1. Wraps the payload with an authenticity signature (HMAC-SHA256).
116
- * 2. Checks the state of the target's circuit breaker.
117
- * 3. Executes the HTTP POST request.
118
- * 4. Manages the retry lifecycle if errors occur.
119
- * 5. Enqueues failed events to the DLQ if configured.
120
- *
121
- * @param payload - Data and destination parameters for the dispatch.
122
- * @returns Final delivery outcome including success status and attempt count.
123
- * @throws {Error} If critical internal operations (like signing) fail.
124
- */
125
- dispatch<T = unknown>(payload: WebhookPayload<T>): Promise<WebhookDeliveryResult>;
126
- /**
127
- * Internal orchestration for the delivery retry loop.
128
- *
129
- * @param payload - The webhook payload.
130
- * @returns Final delivery result after all retry attempts.
131
- */
132
- private dispatchInternal;
133
- /**
134
- * Dispatches a batch of webhooks concurrently using an optimized worker pool.
135
- *
136
- * This method balances high throughput with source/target resource constraints
137
- * by allowing you to tune concurrency and error propagation policies.
138
- *
139
- * @param payloads - Collection of payloads to deliver.
140
- * @param options - Tuning parameters for concurrency and failure handling.
141
- * @returns A summary result of all dispatch attempts in the batch.
142
- *
143
- * @example Batch dispatch with concurrency control
144
- * ```typescript
145
- * const results = await dispatcher.dispatchBatch(payloads, {
146
- * concurrency: 10,
147
- * stopOnFirstFailure: false
148
- * });
149
- * console.log(`Batch complete. Succeeded: ${results.succeeded}, Failed: ${results.failed}`);
150
- * ```
151
- */
152
- dispatchBatch<T = unknown>(payloads: WebhookPayload<T>[], options?: BatchDispatchOptions): Promise<BatchDispatchResult>;
153
- /**
154
- * Re-attempts the delivery of a previously failed event from the Dead Letter Queue.
155
- *
156
- * If the delivery succeeds, the event is automatically removed from the DLQ.
157
- *
158
- * @param id - The unique identifier of the event in the DLQ.
159
- * @returns Result of the retry attempt, or null if the event ID is invalid.
160
- */
161
- retryFromDlq(id: string): Promise<WebhookDeliveryResult | null>;
162
- /**
163
- * Executes a single delivery attempt including signing and circuit breaker check.
164
- *
165
- * @param payload - The webhook payload.
166
- * @param attempt - The current attempt number.
167
- * @returns Detailed result of the single attempt.
168
- */
169
- private attemptDelivery;
170
- /**
171
- * Internal logic to decide if an attempt should be retried.
172
- *
173
- * @param result - The delivery result to evaluate.
174
- * @returns True if retry is eligible.
175
- */
176
- private shouldRetry;
177
- /**
178
- * Calculates the exponential backoff delay for the next attempt.
179
- *
180
- * @param attempt - The current attempt number.
181
- * @returns Delay in milliseconds.
182
- */
183
- private calculateDelay;
184
- /**
185
- * Standardized categorization of delivery errors for metrics.
186
- *
187
- * @param result - The delivery result to categorize.
188
- * @returns Category string.
189
- */
190
- private categorizeError;
191
- /**
192
- * Utility for asynchronous sleep.
193
- *
194
- * @param ms - Duration to sleep in ms.
195
- * @returns Promise that resolves after delay.
196
- */
197
- private sleep;
198
- }
@@ -1 +0,0 @@
1
- export * from './WebhookDispatcher';