Skip to content

Commit c975946

Browse files
committed
fix: sign interface for cookies
1 parent 7634b82 commit c975946

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ utilities provided by `@better-auth/utils`:
1616
|-------------------|----------------------------------------------------|
1717
| [**Digest**](#digest) | Hash inputs using sha family hash functions. |
1818
| [**HMAC**](#hmac) | Hash inputs using HMAC with a secret key. |
19-
| [**Random String**](#random-string) | Generate random strings with a specified length and charset. |
19+
| [**Random**](#random-string) | Generate random strings with a specified length and charset. |
2020
| [**RSA**](#rsa) | Perform encryption, decryption, signing, and verification with RSA keys. |
2121
| [**ECDSA**](#ecdsa) | Perform signing and verification with ECDSA keys. |
2222
| [**Base64**](#base64) | Encode and decode data in base64 format. |

src/cookies.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,15 @@ export const cookies = {
103103
const { name, value, attributes } = input;
104104
const opt = { ...attributes };
105105
const signature = input.signed
106-
? await hmac.sign(input.signed.key, value)
106+
? await hmac.sign(input.signed.key, {
107+
data: value,
108+
})
107109
: undefined;
108110
const base64Signature = signature
109111
? await base64.encode(signature, {
110-
urlSafe: true,
111-
padding: false,
112-
})
112+
urlSafe: true,
113+
padding: false,
114+
})
113115
: undefined;
114116
const _value = base64Signature ? `${value}.${base64Signature}` : value;
115117
let cookie = `${name}=${encodeURIComponent(_value)}`;

0 commit comments

Comments
 (0)