denoland / denoland/fresh-auth-example

Use squishy_cookies to sign and verify user cookies

Open
#1 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
10
Forks
3
PR merge metrics
No merged PRs in 30d

Description

You can use https://deno.land/x/squishy_cookies to sign and verify cookies

```ts
import { createSignedCookie, verifySignedCookie } from 'https://deno.land/x/squishy_cookies@v0.2.4/mod.ts'

const { headers, cookie } = await createSignedCookie(
'id', '1', 'super_secret',
{ httpOnly: true, path: '/' }
)
return new Response(page, { headers })

// or

const headers = new Headers()
headers.append('set-cookie', cookie)

// Verifying a cookie

headers.append('cookie', cookie) // verifySignedCookie will search for 'cookie' header
const userId = await verifySignedCookie(headers, 'id', 'super_secret')
// userId is false if the verification failed or the cookie value
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.