@elysiajs/cookie
Advanced tools
Comparing version 0.1.0-rc.7 to 0.1.0-rc.8
import { serialize, parse } from 'cookie'; | ||
import { sign } from 'cookie-signature'; | ||
const unsign = (input, secret) => { | ||
if (secret === null) | ||
throw new TypeError('Secret key must be provided'); | ||
if (!input) | ||
return false; | ||
const value = input.slice(0, input.lastIndexOf('.')); | ||
return sign(value, secret) === input ? value : false; | ||
}; | ||
import { sign, unsign } from 'cookie-signature'; | ||
export const cookie = ({ signed, secret: secretKey, ...defaultOptions } = {}) => (app) => { | ||
@@ -12,0 +4,0 @@ const secret = !secretKey |
{ | ||
"name": "@elysiajs/cookie", | ||
"version": "0.1.0-rc.7", | ||
"version": "0.1.0-rc.8", | ||
"description": "Plugin for Elysia that add supports for get/set cookie", | ||
@@ -5,0 +5,0 @@ "author": { |
import type { Elysia, Handler } from 'elysia' | ||
import { serialize, parse, type CookieSerializeOptions } from 'cookie' | ||
import { sign } from 'cookie-signature' | ||
import { sign, unsign } from 'cookie-signature' | ||
@@ -29,13 +29,2 @@ export interface SetCookieOptions extends CookieSerializeOptions { | ||
// ? Bun doesn't support `crypto.timingSafeEqual` yet, using string equality instead | ||
// Temporary fix until native support | ||
const unsign = (input: string, secret: string | null) => { | ||
if (secret === null) throw new TypeError('Secret key must be provided') | ||
if (!input) return false | ||
const value = input.slice(0, input.lastIndexOf('.')) | ||
return sign(value, secret) === input ? value : false | ||
} | ||
export const cookie = | ||
@@ -42,0 +31,0 @@ ({ signed, secret: secretKey, ...defaultOptions }: CookieOptions = {}) => |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17017
219