MCPcopy Create free account
hub / github.com/denoland/std / signCookie

Function signCookie

http/unstable_signed_cookie.ts:45–53  ·  view source on GitHub ↗
(
  value: string,
  key: CryptoKey,
)

Source from the content-addressed store, hash-verified

43 * @returns The signed cookie.
44 */
45export 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.

Callers 1

Calls 1

encodeHexFunction · 0.90

Tested by

no test coverage detected