From 9c839233241884f6dbe75a72765444a0b8e3d13c Mon Sep 17 00:00:00 2001 From: Tobe O Date: Fri, 16 Aug 2019 09:02:59 -0400 Subject: [PATCH] writeCookies --- lib/src/cookie_signer.dart | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/src/cookie_signer.dart b/lib/src/cookie_signer.dart index 9adf048e..64747811 100644 --- a/lib/src/cookie_signer.dart +++ b/lib/src/cookie_signer.dart @@ -9,6 +9,8 @@ class CookieSigner { CookieSigner(List keyBytes, {Hash hash}) : hmac = Hmac(hash ?? sha256, keyBytes); + CookieSigner.fromHmac(this.hmac); + factory CookieSigner.fromStringKey(String key, {Hash hash}) { if (key.length != 32) { throw ArgumentError.value(key, 'key', 'must have a length of 32'); @@ -16,5 +18,14 @@ class CookieSigner { return CookieSigner(utf8.encode(key), hash: hash); } - CookieSigner.fromHmac(this.hmac); + Iterable readCookies(RequestContext req) {} + + void writeCookies(ResponseContext res, Iterable cookies) { + for (var cookie in cookies) { + signCookie(cookie); + res.cookies.add(cookie); + } + } + + void signCookie(Cookie cookie) {} }