1 |
import { createHmac } from "node:crypto";
|
1✔ |
2 |
|
1✔ |
3 |
export interface SignRequestOptions {
|
1✔ |
4 |
key: string; |
1✔ |
5 |
secret: string; |
1✔ |
6 |
body: string; |
1✔ |
7 |
} |
1✔ |
8 |
|
1✔ |
9 |
export interface SignedRequest {
|
1✔ |
10 |
key: string; |
1✔ |
11 |
sign: string; |
1✔ |
12 |
} |
1✔ |
13 |
|
1✔ |
14 |
export function SignRequest({
|
|
15 |
key, |
56✔ |
16 |
secret, |
56✔ |
17 |
body, |
56✔ |
18 |
}: SignRequestOptions): SignedRequest { |
56✔ |
19 |
return { key, sign: createHmac("sha512", secret).update(body).digest("hex") }; |
56✔ |
20 |
} |
56✔ |