Skip to content

Commit d96fa7e

Browse files
committed
refactor: Rename sign.ts to hmac.ts and update function name to createHmacSignature
1 parent 2d32a6b commit d96fa7e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/utils/sign.ts renamed to src/utils/hmac.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Use Web Crypto API to create HMAC-SHA256 signature
33
* Returns the signature as a hex string
44
*/
5-
export const sign = async (data: string, secret: string) => {
5+
export const createHmacSignature = async (data: string, secret: string) => {
66
const algorithm = { name: 'HMAC', hash: 'SHA-256' };
77

88
const enc = new TextEncoder();

src/workers/webhook-delivery.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { v4 as uuid } from 'uuid';
22
import { WEBHOOK_RETRY, WEBHOOK_DELIVERY_TIMEOUT } from '../constants';
33
import { MessageBody } from '../types';
44
import { fetchWithTimeout, getHeaders } from '../utils';
5-
import { sign } from '../utils/sign';
5+
import { createHmacSignature } from '../utils/hmac';
66
import { logger } from '../logger';
77

88
export const webhookDelivery = async (message: MessageBody, env: Env) => {
@@ -39,7 +39,7 @@ export const webhookDelivery = async (message: MessageBody, env: Env) => {
3939
};
4040

4141
if (webhook.secret) {
42-
const signature = await sign(JSON.stringify(requestBody), webhook.secret);
42+
const signature = await createHmacSignature(JSON.stringify(requestBody), webhook.secret);
4343
requestHeaders['X-Signature'] = signature;
4444
}
4545

0 commit comments

Comments
 (0)