@k-msg/webhook 0.5.0 → 0.7.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 +115 -357
- package/README_ko.md +176 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +24 -24
- package/dist/index.js.map +7 -7
- package/dist/index.mjs +25 -25
- package/dist/index.mjs.map +7 -7
- package/dist/security/security.manager.d.ts +15 -1
- package/dist/services/webhook.dispatcher.d.ts +3 -1
- package/dist/services/webhook.service.d.ts +0 -2
- package/dist/types/webhook.types.d.ts +7 -1
- package/package.json +4 -3
|
@@ -10,15 +10,29 @@ export interface SecurityConfig {
|
|
|
10
10
|
*/
|
|
11
11
|
export declare class SecurityManager {
|
|
12
12
|
private config;
|
|
13
|
-
constructor(webhookConfig: WebhookConfig);
|
|
13
|
+
constructor(webhookConfig: Pick<WebhookConfig, "algorithm" | "signatureHeader" | "signaturePrefix">);
|
|
14
|
+
/**
|
|
15
|
+
* Canonical string to sign when a timestamp header is present.
|
|
16
|
+
* Format: `${timestamp}.${payload}`
|
|
17
|
+
*/
|
|
18
|
+
createSignedPayload(payload: string, timestamp: string): string;
|
|
14
19
|
/**
|
|
15
20
|
* Webhook 페이로드에 대한 서명 생성
|
|
16
21
|
*/
|
|
17
22
|
generateSignature(payload: string, secret: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Generate signature for a timestamped webhook.
|
|
25
|
+
* (Recommended when also validating `X-Webhook-Timestamp` to prevent replay.)
|
|
26
|
+
*/
|
|
27
|
+
generateSignatureWithTimestamp(payload: string, timestamp: string, secret: string): string;
|
|
18
28
|
/**
|
|
19
29
|
* Webhook 서명 검증
|
|
20
30
|
*/
|
|
21
31
|
verifySignature(payload: string, signature: string, secret: string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Verify signature for a timestamped webhook.
|
|
34
|
+
*/
|
|
35
|
+
verifySignatureWithTimestamp(payload: string, timestamp: string, signature: string, secret: string): boolean;
|
|
22
36
|
/**
|
|
23
37
|
* HTTP 헤더에서 서명 추출
|
|
24
38
|
*/
|
|
@@ -13,12 +13,14 @@ export declare class MockHttpClient implements HttpClient {
|
|
|
13
13
|
export declare class WebhookDispatcher {
|
|
14
14
|
private config;
|
|
15
15
|
private httpClient;
|
|
16
|
+
private securityManager;
|
|
17
|
+
private retryManager;
|
|
16
18
|
constructor(config: WebhookConfig, httpClient?: HttpClient);
|
|
17
19
|
dispatch(event: WebhookEvent, endpoint: WebhookEndpoint): Promise<WebhookDelivery>;
|
|
18
20
|
private executeDelivery;
|
|
21
|
+
private shouldRetryAttempt;
|
|
19
22
|
private makeHttpRequest;
|
|
20
23
|
private buildHeaders;
|
|
21
|
-
private generateSignature;
|
|
22
24
|
private calculateRetryDelay;
|
|
23
25
|
private sleep;
|
|
24
26
|
private generateDeliveryId;
|
|
@@ -82,6 +82,11 @@ export interface WebhookDelivery {
|
|
|
82
82
|
id: string;
|
|
83
83
|
endpointId: string;
|
|
84
84
|
eventId: string;
|
|
85
|
+
/**
|
|
86
|
+
* Optional event type for filtering/stats.
|
|
87
|
+
* (Helpful because `payload` is a JSON string and timestamps need revival when parsed.)
|
|
88
|
+
*/
|
|
89
|
+
eventType?: WebhookEventType;
|
|
85
90
|
url: string;
|
|
86
91
|
httpMethod: "POST" | "PUT" | "PATCH";
|
|
87
92
|
headers: Record<string, string>;
|
|
@@ -140,7 +145,7 @@ export interface WebhookTestResult {
|
|
|
140
145
|
export declare const WebhookEventSchema: z.ZodObject<{
|
|
141
146
|
id: z.ZodString;
|
|
142
147
|
type: z.ZodString;
|
|
143
|
-
timestamp: z.ZodDate
|
|
148
|
+
timestamp: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDate>;
|
|
144
149
|
data: z.ZodAny;
|
|
145
150
|
metadata: z.ZodObject<{
|
|
146
151
|
providerId: z.ZodOptional<z.ZodString>;
|
|
@@ -187,6 +192,7 @@ export declare const WebhookDeliverySchema: z.ZodObject<{
|
|
|
187
192
|
id: z.ZodString;
|
|
188
193
|
endpointId: z.ZodString;
|
|
189
194
|
eventId: z.ZodString;
|
|
195
|
+
eventType: z.ZodOptional<z.ZodString>;
|
|
190
196
|
url: z.ZodString;
|
|
191
197
|
httpMethod: z.ZodEnum<{
|
|
192
198
|
POST: "POST";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@k-msg/webhook",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"packageManager": "bun@1.3.8",
|
|
5
5
|
"description": "Webhook system for real-time message event notifications",
|
|
6
6
|
"type": "module",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"zod": "^4.0.14",
|
|
33
|
-
"@k-msg/messaging": "0.
|
|
33
|
+
"@k-msg/messaging": "0.7.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"typescript": "^5.7.2",
|
|
@@ -47,7 +47,8 @@
|
|
|
47
47
|
],
|
|
48
48
|
"files": [
|
|
49
49
|
"dist",
|
|
50
|
-
"README.md"
|
|
50
|
+
"README.md",
|
|
51
|
+
"README_ko.md"
|
|
51
52
|
],
|
|
52
53
|
"repository": {
|
|
53
54
|
"type": "git",
|