@gravito/echo 3.0.0 → 3.1.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.
- package/README.md +211 -0
- package/dist/atlas/src/DB.d.ts +301 -0
- package/dist/atlas/src/OrbitAtlas.d.ts +9 -0
- package/dist/atlas/src/config/defineConfig.d.ts +14 -0
- package/dist/atlas/src/config/index.d.ts +7 -0
- package/dist/atlas/src/config/loadConfig.d.ts +48 -0
- package/dist/atlas/src/connection/Connection.d.ts +108 -0
- package/dist/atlas/src/connection/ConnectionManager.d.ts +111 -0
- package/dist/atlas/src/drivers/BunSQLDriver.d.ts +32 -0
- package/dist/atlas/src/drivers/BunSQLPreparedStatement.d.ts +118 -0
- package/dist/atlas/src/drivers/MongoDBDriver.d.ts +36 -0
- package/dist/atlas/src/drivers/MySQLDriver.d.ts +66 -0
- package/dist/atlas/src/drivers/PostgresDriver.d.ts +83 -0
- package/dist/atlas/src/drivers/RedisDriver.d.ts +43 -0
- package/dist/atlas/src/drivers/SQLiteDriver.d.ts +45 -0
- package/dist/atlas/src/drivers/types.d.ts +260 -0
- package/dist/atlas/src/errors/index.d.ts +45 -0
- package/dist/atlas/src/grammar/Grammar.d.ts +342 -0
- package/dist/atlas/src/grammar/MongoGrammar.d.ts +47 -0
- package/dist/atlas/src/grammar/MySQLGrammar.d.ts +54 -0
- package/dist/atlas/src/grammar/NullGrammar.d.ts +35 -0
- package/dist/atlas/src/grammar/PostgresGrammar.d.ts +62 -0
- package/dist/atlas/src/grammar/SQLiteGrammar.d.ts +32 -0
- package/dist/atlas/src/index.d.ts +67 -0
- package/dist/atlas/src/migration/Migration.d.ts +64 -0
- package/dist/atlas/src/migration/MigrationRepository.d.ts +65 -0
- package/dist/atlas/src/migration/Migrator.d.ts +110 -0
- package/dist/atlas/src/migration/index.d.ts +6 -0
- package/dist/atlas/src/observability/AtlasMetrics.d.ts +11 -0
- package/dist/atlas/src/observability/AtlasObservability.d.ts +15 -0
- package/dist/atlas/src/observability/AtlasTracer.d.ts +12 -0
- package/dist/atlas/src/observability/index.d.ts +9 -0
- package/dist/atlas/src/orm/index.d.ts +5 -0
- package/dist/atlas/src/orm/model/DirtyTracker.d.ts +121 -0
- package/dist/atlas/src/orm/model/Model.d.ts +449 -0
- package/dist/atlas/src/orm/model/ModelRegistry.d.ts +20 -0
- package/dist/atlas/src/orm/model/concerns/HasAttributes.d.ts +136 -0
- package/dist/atlas/src/orm/model/concerns/HasEvents.d.ts +36 -0
- package/dist/atlas/src/orm/model/concerns/HasPersistence.d.ts +87 -0
- package/dist/atlas/src/orm/model/concerns/HasRelationships.d.ts +117 -0
- package/dist/atlas/src/orm/model/concerns/HasSerialization.d.ts +64 -0
- package/dist/atlas/src/orm/model/concerns/applyMixins.d.ts +15 -0
- package/dist/atlas/src/orm/model/concerns/index.d.ts +12 -0
- package/dist/atlas/src/orm/model/decorators.d.ts +109 -0
- package/dist/atlas/src/orm/model/errors.d.ts +52 -0
- package/dist/atlas/src/orm/model/index.d.ts +10 -0
- package/dist/atlas/src/orm/model/relationships.d.ts +207 -0
- package/dist/atlas/src/orm/model/types.d.ts +12 -0
- package/dist/atlas/src/orm/schema/SchemaRegistry.d.ts +123 -0
- package/dist/atlas/src/orm/schema/SchemaSniffer.d.ts +54 -0
- package/dist/atlas/src/orm/schema/index.d.ts +6 -0
- package/dist/atlas/src/orm/schema/types.d.ts +85 -0
- package/dist/atlas/src/query/Expression.d.ts +60 -0
- package/dist/atlas/src/query/NPlusOneDetector.d.ts +10 -0
- package/dist/atlas/src/query/QueryBuilder.d.ts +573 -0
- package/dist/atlas/src/query/clauses/GroupByClause.d.ts +51 -0
- package/dist/atlas/src/query/clauses/HavingClause.d.ts +70 -0
- package/dist/atlas/src/query/clauses/JoinClause.d.ts +87 -0
- package/dist/atlas/src/query/clauses/LimitClause.d.ts +82 -0
- package/dist/atlas/src/query/clauses/OrderByClause.d.ts +69 -0
- package/dist/atlas/src/query/clauses/SelectClause.d.ts +71 -0
- package/dist/atlas/src/query/clauses/WhereClause.d.ts +167 -0
- package/dist/atlas/src/query/clauses/index.d.ts +11 -0
- package/dist/atlas/src/schema/Blueprint.d.ts +276 -0
- package/dist/atlas/src/schema/ColumnDefinition.d.ts +154 -0
- package/dist/atlas/src/schema/ForeignKeyDefinition.d.ts +37 -0
- package/dist/atlas/src/schema/Schema.d.ts +131 -0
- package/dist/atlas/src/schema/grammars/MySQLSchemaGrammar.d.ts +23 -0
- package/dist/atlas/src/schema/grammars/PostgresSchemaGrammar.d.ts +26 -0
- package/dist/atlas/src/schema/grammars/SQLiteSchemaGrammar.d.ts +28 -0
- package/dist/atlas/src/schema/grammars/SchemaGrammar.d.ts +97 -0
- package/dist/atlas/src/schema/grammars/index.d.ts +7 -0
- package/dist/atlas/src/schema/index.d.ts +8 -0
- package/dist/atlas/src/seed/Factory.d.ts +90 -0
- package/dist/atlas/src/seed/Seeder.d.ts +28 -0
- package/dist/atlas/src/seed/SeederRunner.d.ts +74 -0
- package/dist/atlas/src/seed/index.d.ts +6 -0
- package/dist/atlas/src/types/index.d.ts +1100 -0
- package/dist/atlas/src/utils/levenshtein.d.ts +9 -0
- package/dist/core/src/Application.d.ts +215 -0
- package/dist/core/src/CommandKernel.d.ts +33 -0
- package/dist/core/src/ConfigManager.d.ts +26 -0
- package/dist/core/src/Container.d.ts +108 -0
- package/dist/core/src/ErrorHandler.d.ts +63 -0
- package/dist/core/src/Event.d.ts +5 -0
- package/dist/core/src/EventManager.d.ts +123 -0
- package/dist/core/src/GlobalErrorHandlers.d.ts +47 -0
- package/dist/core/src/GravitoServer.d.ts +28 -0
- package/dist/core/src/HookManager.d.ts +496 -0
- package/dist/core/src/Listener.d.ts +4 -0
- package/dist/core/src/Logger.d.ts +20 -0
- package/dist/core/src/PlanetCore.d.ts +289 -0
- package/dist/core/src/Route.d.ts +36 -0
- package/dist/core/src/Router.d.ts +284 -0
- package/dist/core/src/ServiceProvider.d.ts +156 -0
- package/dist/core/src/adapters/GravitoEngineAdapter.d.ts +27 -0
- package/dist/core/src/adapters/PhotonAdapter.d.ts +171 -0
- package/dist/core/src/adapters/bun/BunContext.d.ts +45 -0
- package/dist/core/src/adapters/bun/BunNativeAdapter.d.ts +31 -0
- package/dist/core/src/adapters/bun/BunRequest.d.ts +31 -0
- package/dist/core/src/adapters/bun/RadixNode.d.ts +19 -0
- package/dist/core/src/adapters/bun/RadixRouter.d.ts +31 -0
- package/dist/core/src/adapters/bun/types.d.ts +20 -0
- package/dist/core/src/adapters/photon-types.d.ts +73 -0
- package/dist/core/src/adapters/types.d.ts +235 -0
- package/dist/core/src/engine/AOTRouter.d.ts +124 -0
- package/dist/core/src/engine/FastContext.d.ts +100 -0
- package/dist/core/src/engine/Gravito.d.ts +137 -0
- package/dist/core/src/engine/MinimalContext.d.ts +79 -0
- package/dist/core/src/engine/analyzer.d.ts +27 -0
- package/dist/core/src/engine/constants.d.ts +23 -0
- package/dist/core/src/engine/index.d.ts +26 -0
- package/dist/core/src/engine/path.d.ts +26 -0
- package/dist/core/src/engine/pool.d.ts +83 -0
- package/dist/core/src/engine/types.d.ts +143 -0
- package/dist/core/src/events/CircuitBreaker.d.ts +229 -0
- package/dist/core/src/events/DeadLetterQueue.d.ts +145 -0
- package/dist/core/src/events/EventBackend.d.ts +11 -0
- package/dist/core/src/events/EventOptions.d.ts +109 -0
- package/dist/core/src/events/EventPriorityQueue.d.ts +202 -0
- package/dist/core/src/events/IdempotencyCache.d.ts +60 -0
- package/dist/core/src/events/index.d.ts +14 -0
- package/dist/core/src/events/observability/EventMetrics.d.ts +132 -0
- package/dist/core/src/events/observability/EventTracer.d.ts +68 -0
- package/dist/core/src/events/observability/EventTracing.d.ts +161 -0
- package/dist/core/src/events/observability/OTelEventMetrics.d.ts +240 -0
- package/dist/core/src/events/observability/ObservableHookManager.d.ts +108 -0
- package/dist/core/src/events/observability/index.d.ts +20 -0
- package/dist/core/src/events/observability/metrics-types.d.ts +16 -0
- package/dist/core/src/events/types.d.ts +75 -0
- package/dist/core/src/exceptions/AuthenticationException.d.ts +8 -0
- package/dist/core/src/exceptions/AuthorizationException.d.ts +8 -0
- package/dist/core/src/exceptions/CircularDependencyException.d.ts +9 -0
- package/dist/core/src/exceptions/GravitoException.d.ts +23 -0
- package/dist/core/src/exceptions/HttpException.d.ts +9 -0
- package/dist/core/src/exceptions/ModelNotFoundException.d.ts +10 -0
- package/dist/core/src/exceptions/ValidationException.d.ts +22 -0
- package/dist/core/src/exceptions/index.d.ts +7 -0
- package/dist/core/src/helpers/Arr.d.ts +19 -0
- package/dist/core/src/helpers/Str.d.ts +23 -0
- package/dist/core/src/helpers/data.d.ts +25 -0
- package/dist/core/src/helpers/errors.d.ts +34 -0
- package/dist/core/src/helpers/response.d.ts +41 -0
- package/dist/core/src/helpers.d.ts +338 -0
- package/dist/core/src/http/CookieJar.d.ts +51 -0
- package/dist/core/src/http/cookie.d.ts +29 -0
- package/dist/core/src/http/middleware/BodySizeLimit.d.ts +16 -0
- package/dist/core/src/http/middleware/Cors.d.ts +24 -0
- package/dist/core/src/http/middleware/Csrf.d.ts +23 -0
- package/dist/core/src/http/middleware/HeaderTokenGate.d.ts +28 -0
- package/dist/core/src/http/middleware/SecurityHeaders.d.ts +29 -0
- package/dist/core/src/http/middleware/ThrottleRequests.d.ts +18 -0
- package/dist/core/src/http/types.d.ts +355 -0
- package/dist/core/src/index.d.ts +76 -0
- package/dist/core/src/instrumentation/index.d.ts +35 -0
- package/dist/core/src/instrumentation/opentelemetry.d.ts +178 -0
- package/dist/core/src/instrumentation/types.d.ts +182 -0
- package/dist/core/src/reliability/DeadLetterQueueManager.d.ts +316 -0
- package/dist/core/src/reliability/RetryPolicy.d.ts +217 -0
- package/dist/core/src/reliability/index.d.ts +6 -0
- package/dist/core/src/router/ControllerDispatcher.d.ts +12 -0
- package/dist/core/src/router/RequestValidator.d.ts +20 -0
- package/dist/core/src/runtime.d.ts +119 -0
- package/dist/core/src/security/Encrypter.d.ts +33 -0
- package/dist/core/src/security/Hasher.d.ts +29 -0
- package/dist/core/src/testing/HttpTester.d.ts +39 -0
- package/dist/core/src/testing/TestResponse.d.ts +78 -0
- package/dist/core/src/testing/index.d.ts +2 -0
- package/dist/core/src/types/events.d.ts +94 -0
- package/dist/echo/src/OrbitEcho.d.ts +115 -0
- package/dist/echo/src/dlq/DeadLetterQueue.d.ts +94 -0
- package/dist/echo/src/dlq/MemoryDeadLetterQueue.d.ts +36 -0
- package/dist/echo/src/dlq/index.d.ts +2 -0
- package/dist/echo/src/index.d.ts +64 -0
- package/dist/echo/src/middleware/RequestBufferMiddleware.d.ts +62 -0
- package/dist/echo/src/middleware/index.d.ts +8 -0
- package/dist/echo/src/observability/index.d.ts +3 -0
- package/dist/echo/src/observability/logging/ConsoleEchoLogger.d.ts +37 -0
- package/dist/echo/src/observability/logging/EchoLogger.d.ts +38 -0
- package/dist/echo/src/observability/logging/index.d.ts +2 -0
- package/dist/echo/src/observability/metrics/MetricsProvider.d.ts +69 -0
- package/dist/echo/src/observability/metrics/NoopMetricsProvider.d.ts +17 -0
- package/dist/echo/src/observability/metrics/PrometheusMetricsProvider.d.ts +39 -0
- package/dist/echo/src/observability/metrics/index.d.ts +3 -0
- package/dist/echo/src/observability/tracing/NoopTracer.d.ts +33 -0
- package/dist/echo/src/observability/tracing/Tracer.d.ts +75 -0
- package/dist/echo/src/observability/tracing/index.d.ts +2 -0
- package/dist/echo/src/providers/GenericProvider.d.ts +53 -0
- package/dist/echo/src/providers/GitHubProvider.d.ts +35 -0
- package/dist/echo/src/providers/LinearProvider.d.ts +27 -0
- package/dist/echo/src/providers/PaddleProvider.d.ts +31 -0
- package/dist/echo/src/providers/ShopifyProvider.d.ts +27 -0
- package/dist/echo/src/providers/SlackProvider.d.ts +27 -0
- package/dist/echo/src/providers/StripeProvider.d.ts +38 -0
- package/dist/echo/src/providers/TwilioProvider.d.ts +31 -0
- package/dist/echo/src/providers/base/BaseProvider.d.ts +87 -0
- package/dist/echo/src/providers/base/HeaderUtils.d.ts +34 -0
- package/dist/echo/src/providers/index.d.ts +14 -0
- package/dist/echo/src/receive/SignatureValidator.d.ts +67 -0
- package/dist/echo/src/receive/WebhookReceiver.d.ts +185 -0
- package/dist/echo/src/receive/index.d.ts +2 -0
- package/dist/echo/src/replay/WebhookReplayService.d.ts +35 -0
- package/dist/echo/src/replay/index.d.ts +1 -0
- package/dist/echo/src/resilience/CircuitBreaker.d.ts +117 -0
- package/dist/echo/src/resilience/index.d.ts +10 -0
- package/dist/echo/src/rotation/KeyRotationManager.d.ts +127 -0
- package/dist/echo/src/rotation/index.d.ts +10 -0
- package/dist/echo/src/send/WebhookDispatcher.d.ts +198 -0
- package/dist/echo/src/send/index.d.ts +1 -0
- package/dist/echo/src/storage/MemoryWebhookStore.d.ts +14 -0
- package/dist/echo/src/storage/WebhookStore.d.ts +236 -0
- package/dist/echo/src/storage/index.d.ts +2 -0
- package/dist/echo/src/types.d.ts +756 -0
- package/dist/index.js +1332 -190
- package/dist/index.js.map +28 -10
- package/dist/photon/src/index.d.ts +84 -0
- package/dist/photon/src/middleware/binary.d.ts +31 -0
- package/dist/photon/src/middleware/htmx.d.ts +39 -0
- package/dist/photon/src/middleware/ratelimit.d.ts +157 -0
- package/dist/photon/src/openapi.d.ts +19 -0
- package/package.json +7 -5
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview \@gravito/echo - Enterprise Webhook Orchestration
|
|
3
|
+
*
|
|
4
|
+
* Echo provides a secure, reliable, and observable layer for handling webhooks
|
|
5
|
+
* in Gravito applications. It standardizes incoming webhook reception with
|
|
6
|
+
* signature verification and dynamic key rotation, while ensuring reliable
|
|
7
|
+
* outgoing delivery via exponential backoff and circuit breaking.
|
|
8
|
+
*
|
|
9
|
+
* @example Receiving webhooks from Stripe
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { OrbitEcho, WebhookReceiver } from '@gravito/echo'
|
|
12
|
+
*
|
|
13
|
+
* const core = new PlanetCore()
|
|
14
|
+
* core.install(new OrbitEcho({
|
|
15
|
+
* providers: {
|
|
16
|
+
* stripe: { name: 'stripe', secret: process.env.STRIPE_SECRET! }
|
|
17
|
+
* }
|
|
18
|
+
* }))
|
|
19
|
+
*
|
|
20
|
+
* const receiver = core.container.make<WebhookReceiver>('echo.receiver')
|
|
21
|
+
* receiver.on('stripe', 'payment_intent.succeeded', async (event) => {
|
|
22
|
+
* // Securely process validated payment
|
|
23
|
+
* })
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @example Dispatching reliable outgoing webhooks
|
|
27
|
+
* ```typescript
|
|
28
|
+
* import { WebhookDispatcher } from '@gravito/echo'
|
|
29
|
+
*
|
|
30
|
+
* const dispatcher = new WebhookDispatcher({ secret: 'app-secret' })
|
|
31
|
+
* await dispatcher.dispatch({
|
|
32
|
+
* url: 'https://consumer.com/hook',
|
|
33
|
+
* event: 'order.created',
|
|
34
|
+
* data: { id: 123 }
|
|
35
|
+
* })
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @module @gravito/echo
|
|
39
|
+
*/
|
|
40
|
+
export type { DeadLetterEvent, DeadLetterQueue } from './dlq/DeadLetterQueue';
|
|
41
|
+
export { MemoryDeadLetterQueue } from './dlq/MemoryDeadLetterQueue';
|
|
42
|
+
export { createRequestBufferMiddleware, RequestBufferMiddleware } from './middleware';
|
|
43
|
+
export { OrbitEcho } from './OrbitEcho';
|
|
44
|
+
export type { EchoLogEvent, EchoLogger } from './observability/logging';
|
|
45
|
+
export { ConsoleEchoLogger } from './observability/logging';
|
|
46
|
+
export type { MetricsProvider, WebhookMetricLabels } from './observability/metrics';
|
|
47
|
+
export { EchoMetrics, NoopMetricsProvider, PrometheusMetricsProvider, } from './observability/metrics';
|
|
48
|
+
export type { Span, SpanOptions, Tracer } from './observability/tracing';
|
|
49
|
+
export { NoopSpan, NoopTracer, SpanStatusCode } from './observability/tracing';
|
|
50
|
+
export { BaseProvider, type ProviderOptions } from './providers/base/BaseProvider';
|
|
51
|
+
export { GenericProvider } from './providers/GenericProvider';
|
|
52
|
+
export { GitHubProvider } from './providers/GitHubProvider';
|
|
53
|
+
export { LinearProvider } from './providers/LinearProvider';
|
|
54
|
+
export { PaddleProvider } from './providers/PaddleProvider';
|
|
55
|
+
export { ShopifyProvider } from './providers/ShopifyProvider';
|
|
56
|
+
export { SlackProvider } from './providers/SlackProvider';
|
|
57
|
+
export { StripeProvider } from './providers/StripeProvider';
|
|
58
|
+
export { TwilioProvider } from './providers/TwilioProvider';
|
|
59
|
+
export { computeHmacSha1, computeHmacSha256, parseStripeSignature, timingSafeEqual, validateTimestamp, } from './receive/SignatureValidator';
|
|
60
|
+
export { WebhookReceiver } from './receive/WebhookReceiver';
|
|
61
|
+
export { WebhookReplayService } from './replay/WebhookReplayService';
|
|
62
|
+
export { CircuitBreaker } from './resilience';
|
|
63
|
+
export { KeyRotationManager } from './rotation';
|
|
64
|
+
export type { BufferedRequest, CircuitBreakerConfig, CircuitBreakerMetrics, CircuitBreakerState, EchoConfig, EchoObservabilityConfig, KeyRotationConfig, ProviderKeyEntry, ReplayOptions, ReplayResult, RequestBufferConfig, RetryConfig, WebhookDeliveryResult, WebhookDispatcherConfig, WebhookEvent, WebhookHandler, WebhookPayload, WebhookProvider, WebhookProviderConfig, WebhookProviderConfigWithRotation, WebhookVerificationResult, } from './types';
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request Buffer Middleware
|
|
3
|
+
*
|
|
4
|
+
* 在驗證前緩存原始 Request Body,防止框架自動解析 JSON 導致簽章驗證失敗。
|
|
5
|
+
* 這個中介軟體會在請求處理鏈的早期階段攔截並緩存原始內容。
|
|
6
|
+
*
|
|
7
|
+
* @module @gravito/echo/middleware
|
|
8
|
+
* @since v1.1
|
|
9
|
+
*/
|
|
10
|
+
import type { GravitoContext } from '@gravito/core';
|
|
11
|
+
import type { BufferedRequest, RequestBufferConfig } from '../types';
|
|
12
|
+
/**
|
|
13
|
+
* Request Buffer 中介軟體類別
|
|
14
|
+
*
|
|
15
|
+
* 提供原始 Body 緩存功能,確保簽章驗證使用正確的未解析內容。
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const middleware = new RequestBufferMiddleware({
|
|
20
|
+
* maxBodySize: 5 * 1024 * 1024, // 5MB
|
|
21
|
+
* })
|
|
22
|
+
*
|
|
23
|
+
* core.adapter.use('*', middleware.handler())
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare class RequestBufferMiddleware {
|
|
27
|
+
private config;
|
|
28
|
+
constructor(config?: RequestBufferConfig);
|
|
29
|
+
/**
|
|
30
|
+
* 建立中介軟體處理函式
|
|
31
|
+
*
|
|
32
|
+
* @returns 中介軟體處理函式
|
|
33
|
+
*/
|
|
34
|
+
handler(): (c: GravitoContext, next: () => Promise<Response | undefined>) => Promise<Response | undefined>;
|
|
35
|
+
/**
|
|
36
|
+
* 從請求中讀取原始 body
|
|
37
|
+
*
|
|
38
|
+
* @param c - Gravito Context
|
|
39
|
+
* @returns 原始 body(string 或 Buffer)
|
|
40
|
+
*/
|
|
41
|
+
private readRawBody;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* 便捷工廠函式,用於建立 Request Buffer 中介軟體
|
|
45
|
+
*
|
|
46
|
+
* @param config - 中介軟體配置
|
|
47
|
+
* @returns 中介軟體處理函式
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* core.adapter.use('*', createRequestBufferMiddleware({
|
|
52
|
+
* maxBodySize: 5 * 1024 * 1024
|
|
53
|
+
* }))
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export declare function createRequestBufferMiddleware(config?: RequestBufferConfig): (c: GravitoContext, next: () => Promise<Response | undefined>) => Promise<Response | undefined>;
|
|
57
|
+
declare module '@gravito/core' {
|
|
58
|
+
interface GravitoVariables {
|
|
59
|
+
/** Buffered request for signature verification */
|
|
60
|
+
bufferedRequest?: BufferedRequest;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { EchoLogger } from './EchoLogger';
|
|
2
|
+
/**
|
|
3
|
+
* A basic implementation of {@link EchoLogger} that outputs logs to the system console.
|
|
4
|
+
* Logs are formatted as JSON strings to facilitate integration with log aggregators.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* const logger = new ConsoleEchoLogger();
|
|
9
|
+
* logger.info('Service started');
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare class ConsoleEchoLogger implements EchoLogger {
|
|
13
|
+
/**
|
|
14
|
+
* Enriches the log context with default module information and timestamps.
|
|
15
|
+
*
|
|
16
|
+
* @param base - The base context object.
|
|
17
|
+
* @param extra - Additional metadata to include.
|
|
18
|
+
* @returns A merged context object.
|
|
19
|
+
*/
|
|
20
|
+
private formatContext;
|
|
21
|
+
/**
|
|
22
|
+
* Outputs a debug-level log entry.
|
|
23
|
+
*/
|
|
24
|
+
debug(message: string, context?: Record<string, unknown>): void;
|
|
25
|
+
/**
|
|
26
|
+
* Outputs an info-level log entry.
|
|
27
|
+
*/
|
|
28
|
+
info(message: string, context?: Record<string, unknown>): void;
|
|
29
|
+
/**
|
|
30
|
+
* Outputs a warn-level log entry.
|
|
31
|
+
*/
|
|
32
|
+
warn(message: string, context?: Record<string, unknown>): void;
|
|
33
|
+
/**
|
|
34
|
+
* Outputs an error-level log entry.
|
|
35
|
+
*/
|
|
36
|
+
error(message: string, context?: Record<string, unknown>): void;
|
|
37
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a structured log event within the Echo module.
|
|
3
|
+
* Used to ensure consistency across different logging implementations.
|
|
4
|
+
*/
|
|
5
|
+
export interface EchoLogEvent {
|
|
6
|
+
/** Severity level of the log entry. */
|
|
7
|
+
level: 'debug' | 'info' | 'warn' | 'error';
|
|
8
|
+
/** Human-readable message describing the event. */
|
|
9
|
+
message: string;
|
|
10
|
+
/** Contextual metadata for better traceability. */
|
|
11
|
+
context: {
|
|
12
|
+
/** Always 'echo' to identify the source module. */
|
|
13
|
+
module: 'echo';
|
|
14
|
+
/** The specific sub-component triggering the log. */
|
|
15
|
+
component: 'receiver' | 'dispatcher' | 'dlq' | 'replay';
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Defines the standard logging interface for the Echo module.
|
|
21
|
+
* Implementations should handle structured data for observability.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const logger: EchoLogger = new ConsoleEchoLogger();
|
|
26
|
+
* logger.info('Webhook received', { provider: 'stripe' });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export interface EchoLogger {
|
|
30
|
+
/** Logs fine-grained informational events that are most useful to debug an application. */
|
|
31
|
+
debug(message: string, context?: Record<string, unknown>): void;
|
|
32
|
+
/** Logs informational messages that highlight the progress of the application at coarse-grained level. */
|
|
33
|
+
info(message: string, context?: Record<string, unknown>): void;
|
|
34
|
+
/** Logs potentially harmful situations. */
|
|
35
|
+
warn(message: string, context?: Record<string, unknown>): void;
|
|
36
|
+
/** Logs error events that might still allow the application to continue running. */
|
|
37
|
+
error(message: string, context?: Record<string, unknown>): void;
|
|
38
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines the interface for collecting application metrics.
|
|
3
|
+
* Implementations can bridge to Prometheus, StatsD, or other monitoring systems.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* const metrics: MetricsProvider = getMetrics();
|
|
8
|
+
* metrics.increment(EchoMetrics.INCOMING_TOTAL, { provider: 'stripe' });
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export interface MetricsProvider {
|
|
12
|
+
/**
|
|
13
|
+
* Increments a counter by 1.
|
|
14
|
+
* Counters are used for values that only increase (e.g., total requests).
|
|
15
|
+
*/
|
|
16
|
+
increment(name: string, labels?: Record<string, string>): void;
|
|
17
|
+
/**
|
|
18
|
+
* Records a value in a histogram.
|
|
19
|
+
* Histograms are used to track the distribution of values (e.g., request latency).
|
|
20
|
+
*/
|
|
21
|
+
histogram(name: string, value: number, labels?: Record<string, string>): void;
|
|
22
|
+
/**
|
|
23
|
+
* Sets a gauge to a specific value.
|
|
24
|
+
* Gauges are used for values that can go up and down (e.g., current queue size).
|
|
25
|
+
*/
|
|
26
|
+
gauge(name: string, value: number, labels?: Record<string, string>): void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Common labels used for webhook-related metrics.
|
|
30
|
+
*/
|
|
31
|
+
export interface WebhookMetricLabels {
|
|
32
|
+
/** The webhook provider name (e.g., 'stripe', 'github'). */
|
|
33
|
+
provider?: string;
|
|
34
|
+
/** The type of event received or sent. */
|
|
35
|
+
event_type?: string;
|
|
36
|
+
/** The outcome of the operation. */
|
|
37
|
+
status?: 'success' | 'failure';
|
|
38
|
+
/** The HTTP status code returned by the remote server. */
|
|
39
|
+
status_code?: string;
|
|
40
|
+
/** A category for the error if the operation failed. */
|
|
41
|
+
error_type?: string;
|
|
42
|
+
[key: string]: string | undefined;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Standard metric names used across the Echo module.
|
|
46
|
+
* Use these constants to ensure consistency in dashboards and alerts.
|
|
47
|
+
*/
|
|
48
|
+
export declare const EchoMetrics: {
|
|
49
|
+
/** Total number of incoming webhooks received. */
|
|
50
|
+
readonly INCOMING_TOTAL: "echo_incoming_webhooks_total";
|
|
51
|
+
/** Time taken to process an incoming webhook. */
|
|
52
|
+
readonly INCOMING_DURATION: "echo_incoming_duration_seconds";
|
|
53
|
+
/** Total number of incoming webhooks that failed signature verification. */
|
|
54
|
+
readonly INCOMING_VERIFICATION_FAILURES: "echo_incoming_verification_failures_total";
|
|
55
|
+
/** Total number of outgoing webhooks dispatched. */
|
|
56
|
+
readonly OUTGOING_TOTAL: "echo_outgoing_webhooks_total";
|
|
57
|
+
/** Time taken to deliver an outgoing webhook. */
|
|
58
|
+
readonly OUTGOING_DURATION: "echo_outgoing_duration_seconds";
|
|
59
|
+
/** Total number of retry attempts for outgoing webhooks. */
|
|
60
|
+
readonly OUTGOING_RETRIES: "echo_outgoing_retries_total";
|
|
61
|
+
/** Total number of outgoing webhooks that failed after all retries. */
|
|
62
|
+
readonly OUTGOING_FAILURES: "echo_outgoing_failures_total";
|
|
63
|
+
/** Current number of items in the Dead Letter Queue. */
|
|
64
|
+
readonly DLQ_SIZE: "echo_dlq_size";
|
|
65
|
+
/** Total number of items added to the DLQ. */
|
|
66
|
+
readonly DLQ_ENQUEUED: "echo_dlq_enqueued_total";
|
|
67
|
+
/** Total number of items successfully processed from the DLQ. */
|
|
68
|
+
readonly DLQ_PROCESSED: "echo_dlq_processed_total";
|
|
69
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { MetricsProvider } from './MetricsProvider';
|
|
2
|
+
/**
|
|
3
|
+
* A non-operational implementation of {@link MetricsProvider}.
|
|
4
|
+
* Used as the default provider to ensure the application remains functional
|
|
5
|
+
* even if no monitoring system is configured.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const metrics = new NoopMetricsProvider();
|
|
10
|
+
* metrics.increment('any_metric'); // Does nothing
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare class NoopMetricsProvider implements MetricsProvider {
|
|
14
|
+
increment(): void;
|
|
15
|
+
histogram(): void;
|
|
16
|
+
gauge(): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { MetricsProvider } from './MetricsProvider';
|
|
2
|
+
/**
|
|
3
|
+
* A Prometheus-compatible metrics provider.
|
|
4
|
+
* Collects and formats metrics in the Prometheus text-based format.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* const provider = new PrometheusMetricsProvider();
|
|
9
|
+
* provider.increment('http_requests_total', { method: 'POST' });
|
|
10
|
+
* console.log(provider.export());
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare class PrometheusMetricsProvider implements MetricsProvider {
|
|
14
|
+
private counters;
|
|
15
|
+
private histograms;
|
|
16
|
+
private gauges;
|
|
17
|
+
/**
|
|
18
|
+
* Increments a counter for the given name and labels.
|
|
19
|
+
*/
|
|
20
|
+
increment(name: string, labels?: Record<string, string>): void;
|
|
21
|
+
/**
|
|
22
|
+
* Records a value in a histogram for the given name and labels.
|
|
23
|
+
*/
|
|
24
|
+
histogram(name: string, value: number, labels?: Record<string, string>): void;
|
|
25
|
+
/**
|
|
26
|
+
* Sets a gauge to a specific value for the given name and labels.
|
|
27
|
+
*/
|
|
28
|
+
gauge(name: string, value: number, labels?: Record<string, string>): void;
|
|
29
|
+
/**
|
|
30
|
+
* Exports all collected metrics in Prometheus text format.
|
|
31
|
+
*
|
|
32
|
+
* @returns A string containing the formatted metrics.
|
|
33
|
+
*/
|
|
34
|
+
export(): string;
|
|
35
|
+
/**
|
|
36
|
+
* Builds a Prometheus-compatible metric key with labels.
|
|
37
|
+
*/
|
|
38
|
+
private buildKey;
|
|
39
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Span, Tracer } from './Tracer';
|
|
2
|
+
/**
|
|
3
|
+
* A non-operational implementation of {@link Span}.
|
|
4
|
+
* Used as a fallback when tracing is disabled to avoid null checks.
|
|
5
|
+
*/
|
|
6
|
+
export declare class NoopSpan implements Span {
|
|
7
|
+
setAttribute(): this;
|
|
8
|
+
setAttributes(): this;
|
|
9
|
+
addEvent(): this;
|
|
10
|
+
setStatus(): this;
|
|
11
|
+
end(): void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A non-operational implementation of {@link Tracer}.
|
|
15
|
+
* Ensures the application can run without a tracing backend.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const tracer = new NoopTracer();
|
|
20
|
+
* const span = tracer.startSpan('test');
|
|
21
|
+
* span.end();
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare class NoopTracer implements Tracer {
|
|
25
|
+
/**
|
|
26
|
+
* Returns a {@link NoopSpan} that does nothing.
|
|
27
|
+
*/
|
|
28
|
+
startSpan(): Span;
|
|
29
|
+
/**
|
|
30
|
+
* Executes the function with a {@link NoopSpan}.
|
|
31
|
+
*/
|
|
32
|
+
withSpan<T>(_name: string, fn: (span: Span) => T | Promise<T>): Promise<T>;
|
|
33
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a single unit of work in a trace.
|
|
3
|
+
* Compatible with OpenTelemetry Span interface to allow seamless integration.
|
|
4
|
+
*/
|
|
5
|
+
export interface Span {
|
|
6
|
+
/**
|
|
7
|
+
* Sets a single attribute on the span.
|
|
8
|
+
* Attributes provide additional metadata for the operation.
|
|
9
|
+
*/
|
|
10
|
+
setAttribute(key: string, value: string | number | boolean): this;
|
|
11
|
+
/**
|
|
12
|
+
* Sets multiple attributes on the span at once.
|
|
13
|
+
*/
|
|
14
|
+
setAttributes(attributes: Record<string, string | number | boolean>): this;
|
|
15
|
+
/**
|
|
16
|
+
* Records a specific event that occurred during the span's lifetime.
|
|
17
|
+
*/
|
|
18
|
+
addEvent(name: string, attributes?: Record<string, string | number>): this;
|
|
19
|
+
/**
|
|
20
|
+
* Sets the final status of the span.
|
|
21
|
+
*/
|
|
22
|
+
setStatus(status: {
|
|
23
|
+
code: SpanStatusCode;
|
|
24
|
+
message?: string;
|
|
25
|
+
}): this;
|
|
26
|
+
/**
|
|
27
|
+
* Marks the end of the span, making it ready for export.
|
|
28
|
+
*/
|
|
29
|
+
end(): void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Standard status codes for a {@link Span}.
|
|
33
|
+
*/
|
|
34
|
+
export declare enum SpanStatusCode {
|
|
35
|
+
/** Default status. */
|
|
36
|
+
UNSET = 0,
|
|
37
|
+
/** Operation completed successfully. */
|
|
38
|
+
OK = 1,
|
|
39
|
+
/** Operation failed. */
|
|
40
|
+
ERROR = 2
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Defines the tracing interface for the Echo module.
|
|
44
|
+
* Used to track the lifecycle of webhook requests and deliveries.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const tracer: Tracer = getTracer();
|
|
49
|
+
* await tracer.withSpan('process-webhook', async (span) => {
|
|
50
|
+
* span.setAttribute('provider', 'stripe');
|
|
51
|
+
* // ... logic
|
|
52
|
+
* });
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export interface Tracer {
|
|
56
|
+
/**
|
|
57
|
+
* Starts a new span without making it active.
|
|
58
|
+
* The caller is responsible for ending the span.
|
|
59
|
+
*/
|
|
60
|
+
startSpan(name: string, options?: SpanOptions): Span;
|
|
61
|
+
/**
|
|
62
|
+
* Executes a function within the context of a new span.
|
|
63
|
+
* Automatically ends the span when the function completes.
|
|
64
|
+
*/
|
|
65
|
+
withSpan<T>(name: string, fn: (span: Span) => T | Promise<T>): Promise<T>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Configuration options for starting a new {@link Span}.
|
|
69
|
+
*/
|
|
70
|
+
export interface SpanOptions {
|
|
71
|
+
/** The relationship between the span and its neighbors. */
|
|
72
|
+
kind?: 'client' | 'server' | 'producer' | 'consumer' | 'internal';
|
|
73
|
+
/** Initial attributes to set on the span. */
|
|
74
|
+
attributes?: Record<string, string | number | boolean>;
|
|
75
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic webhook provider.
|
|
3
|
+
* @module @gravito/echo/providers
|
|
4
|
+
*/
|
|
5
|
+
import type { WebhookVerificationResult } from '../types';
|
|
6
|
+
import { BaseProvider, type ProviderOptions } from './base/BaseProvider';
|
|
7
|
+
/**
|
|
8
|
+
* Configuration options for the generic provider.
|
|
9
|
+
*/
|
|
10
|
+
export interface GenericProviderOptions extends ProviderOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Custom header name for the signature.
|
|
13
|
+
* @defaultValue 'x-webhook-signature'
|
|
14
|
+
*/
|
|
15
|
+
signatureHeader?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Custom header name for the timestamp.
|
|
18
|
+
* @defaultValue 'x-webhook-timestamp'
|
|
19
|
+
*/
|
|
20
|
+
timestampHeader?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Generic webhook provider using HMAC-SHA256 for signature verification.
|
|
24
|
+
*
|
|
25
|
+
* Expected headers:
|
|
26
|
+
* - X-Webhook-Signature: HMAC-SHA256 hex signature.
|
|
27
|
+
* - X-Webhook-Timestamp: Unix timestamp (optional, used for replay protection).
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* const provider = new GenericProvider({
|
|
32
|
+
* signatureHeader: 'X-Custom-Sig',
|
|
33
|
+
* tolerance: 600
|
|
34
|
+
* });
|
|
35
|
+
* const result = await provider.verify(body, headers, secret);
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare class GenericProvider extends BaseProvider {
|
|
39
|
+
readonly name = "generic";
|
|
40
|
+
private signatureHeader;
|
|
41
|
+
private timestampHeader;
|
|
42
|
+
constructor(options?: GenericProviderOptions);
|
|
43
|
+
/**
|
|
44
|
+
* Verifies the webhook using HMAC-SHA256.
|
|
45
|
+
*
|
|
46
|
+
* @param payload - Raw request body.
|
|
47
|
+
* @param headers - Request headers.
|
|
48
|
+
* @param secret - Secret key for HMAC computation.
|
|
49
|
+
* @returns Verification result.
|
|
50
|
+
* @throws Error if signature computation fails.
|
|
51
|
+
*/
|
|
52
|
+
verify(payload: string | Buffer, headers: Record<string, string | string[] | undefined>, secret: string): Promise<WebhookVerificationResult>;
|
|
53
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub webhook provider.
|
|
3
|
+
* @module @gravito/echo/providers
|
|
4
|
+
*/
|
|
5
|
+
import type { WebhookVerificationResult } from '../types';
|
|
6
|
+
import { BaseProvider } from './base/BaseProvider';
|
|
7
|
+
/**
|
|
8
|
+
* GitHub webhook provider.
|
|
9
|
+
*
|
|
10
|
+
* Verifies GitHub webhook signatures using the `X-Hub-Signature-256` header.
|
|
11
|
+
* @see {@link https://docs.github.com/en/webhooks/using-webhooks/validating-webhook-deliveries | GitHub Webhook Validation}
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const provider = new GitHubProvider();
|
|
16
|
+
* const result = await provider.verify(body, headers, process.env.GITHUB_WEBHOOK_SECRET);
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare class GitHubProvider extends BaseProvider {
|
|
20
|
+
readonly name = "github";
|
|
21
|
+
/**
|
|
22
|
+
* Verifies the GitHub webhook signature.
|
|
23
|
+
*
|
|
24
|
+
* @param payload - Raw request body.
|
|
25
|
+
* @param headers - Request headers.
|
|
26
|
+
* @param secret - GitHub webhook secret.
|
|
27
|
+
* @returns Verification result.
|
|
28
|
+
* @throws Error if signature computation fails.
|
|
29
|
+
*/
|
|
30
|
+
verify(payload: string | Buffer, headers: Record<string, string | string[] | undefined>, secret: string): Promise<WebhookVerificationResult>;
|
|
31
|
+
/**
|
|
32
|
+
* Extracts the action from the GitHub payload if available.
|
|
33
|
+
*/
|
|
34
|
+
parseEventType(payload: unknown): string | undefined;
|
|
35
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { WebhookVerificationResult } from '../types';
|
|
2
|
+
import { BaseProvider } from './base/BaseProvider';
|
|
3
|
+
/**
|
|
4
|
+
* Linear webhook provider.
|
|
5
|
+
*
|
|
6
|
+
* Verifies Linear webhook signatures using the `Linear-Signature` header.
|
|
7
|
+
* @see {@link https://developers.linear.app/docs/graphql/webhooks#signature-verification | Linear Webhook Verification}
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const provider = new LinearProvider();
|
|
12
|
+
* const result = await provider.verify(body, headers, process.env.LINEAR_WEBHOOK_SECRET);
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare class LinearProvider extends BaseProvider {
|
|
16
|
+
readonly name = "linear";
|
|
17
|
+
/**
|
|
18
|
+
* Verifies the Linear webhook signature.
|
|
19
|
+
*
|
|
20
|
+
* @param payload - Raw request body.
|
|
21
|
+
* @param headers - Request headers.
|
|
22
|
+
* @param secret - Linear webhook secret.
|
|
23
|
+
* @returns Verification result.
|
|
24
|
+
* @throws Error if signature computation fails.
|
|
25
|
+
*/
|
|
26
|
+
verify(payload: string | Buffer, headers: Record<string, string | string[] | undefined>, secret: string): Promise<WebhookVerificationResult>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { WebhookVerificationResult } from '../types';
|
|
2
|
+
import { BaseProvider } from './base/BaseProvider';
|
|
3
|
+
/**
|
|
4
|
+
* Paddle webhook provider.
|
|
5
|
+
*
|
|
6
|
+
* Verifies Paddle webhook signatures using the `Paddle-Signature` header.
|
|
7
|
+
* @see {@link https://developer.paddle.com/webhooks/signature-verification | Paddle Signature Verification}
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const provider = new PaddleProvider();
|
|
12
|
+
* const result = await provider.verify(body, headers, process.env.PADDLE_WEBHOOK_SECRET);
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare class PaddleProvider extends BaseProvider {
|
|
16
|
+
readonly name = "paddle";
|
|
17
|
+
/**
|
|
18
|
+
* Verifies the Paddle webhook signature.
|
|
19
|
+
*
|
|
20
|
+
* @param payload - Raw request body.
|
|
21
|
+
* @param headers - Request headers.
|
|
22
|
+
* @param secret - Paddle webhook secret.
|
|
23
|
+
* @returns Verification result.
|
|
24
|
+
* @throws Error if signature computation fails.
|
|
25
|
+
*/
|
|
26
|
+
verify(payload: string | Buffer, headers: Record<string, string | string[] | undefined>, secret: string): Promise<WebhookVerificationResult>;
|
|
27
|
+
/**
|
|
28
|
+
* Parses the Paddle-Signature header into timestamp and signature components.
|
|
29
|
+
*/
|
|
30
|
+
private parsePaddleSignature;
|
|
31
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { WebhookVerificationResult } from '../types';
|
|
2
|
+
import { BaseProvider } from './base/BaseProvider';
|
|
3
|
+
/**
|
|
4
|
+
* Shopify webhook provider.
|
|
5
|
+
*
|
|
6
|
+
* Verifies Shopify webhook signatures using the `X-Shopify-Hmac-Sha256` header.
|
|
7
|
+
* @see {@link https://shopify.dev/docs/apps/webhooks/configuration/https#verify-webhook | Shopify Webhook Verification}
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const provider = new ShopifyProvider();
|
|
12
|
+
* const result = await provider.verify(body, headers, process.env.SHOPIFY_WEBHOOK_SECRET);
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare class ShopifyProvider extends BaseProvider {
|
|
16
|
+
readonly name = "shopify";
|
|
17
|
+
/**
|
|
18
|
+
* Verifies the Shopify webhook signature.
|
|
19
|
+
*
|
|
20
|
+
* @param payload - Raw request body.
|
|
21
|
+
* @param headers - Request headers.
|
|
22
|
+
* @param secret - Shopify webhook secret.
|
|
23
|
+
* @returns Verification result.
|
|
24
|
+
* @throws Error if signature computation fails.
|
|
25
|
+
*/
|
|
26
|
+
verify(payload: string | Buffer, headers: Record<string, string | string[] | undefined>, secret: string): Promise<WebhookVerificationResult>;
|
|
27
|
+
}
|