mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 08:13:56 +10:00
feat: update webhook handling and triggering
This commit is contained in:
12
packages/lib/server-only/crypto/sign.ts
Normal file
12
packages/lib/server-only/crypto/sign.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { hashString } from '../auth/hash';
|
||||
import { encryptSecondaryData } from './encrypt';
|
||||
|
||||
export const sign = (data: unknown) => {
|
||||
const stringified = JSON.stringify(data);
|
||||
|
||||
const hashed = hashString(stringified);
|
||||
|
||||
const signature = encryptSecondaryData({ data: hashed });
|
||||
|
||||
return signature;
|
||||
};
|
||||
12
packages/lib/server-only/crypto/verify.ts
Normal file
12
packages/lib/server-only/crypto/verify.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { hashString } from '../auth/hash';
|
||||
import { decryptSecondaryData } from './decrypt';
|
||||
|
||||
export const verify = (data: unknown, signature: string) => {
|
||||
const stringified = JSON.stringify(data);
|
||||
|
||||
const hashed = hashString(stringified);
|
||||
|
||||
const decrypted = decryptSecondaryData(signature);
|
||||
|
||||
return decrypted === hashed;
|
||||
};
|
||||
Reference in New Issue
Block a user