( value: string, key: CryptoKey, )
| 43 | * @returns The signed cookie. |
| 44 | */ |
| 45 | export async function signCookie( |
| 46 | value: string, |
| 47 | key: CryptoKey, |
| 48 | ): Promise<string> { |
| 49 | const data = encoder.encode(value); |
| 50 | const signature = await crypto.subtle.sign("HMAC", key, data); |
| 51 | const signatureHex = encodeHex(signature); |
| 52 | return `${value}.${signatureHex}`; |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Returns a promise of a boolean indicating whether the signed cookie is valid. |
no test coverage detected