Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
svelte-baked-cookie
Advanced tools
🍪 Universal accessible hard-baked cookies for SvelteKit
From a single schema, type-defined cookies can be accessed in any environment.
npm i svelte-baked-cookie
bakery
function to define the cookie type and get bake
and rebake
.
See ts-serde for more information on type guard// bakery.js
import { bakery } from 'svelte-baked-cookie'
import { json, number, string } from 'svelte-baked-cookie/serde'
export const { bake, rebake } = bakery(
{
key1: string,
key2: number,
key3: json(
(x): x is string[] =>
Array.isArray(x) && x.every((y) => typeof y === 'string'),
[]
)
}
// {
// CookieSetOptions: (optional)
// }
)
cookies
object obtained from load
, etc. to the bake
function.// +layout.server.js
import { bake } from './bakery.js'
export const load = ({ cookies }) => {
const { bakedCookies } = bake(cookies)
// string
const str = bakedCookies.key1.get()
// number
const num = bakedCookies.key2.set()
// string[]
bakedCookies.key3.set(['value', 'set', 'by', 'server'])
return {
// ...
}
}
rebake
function can be used directly to obtain a writable
svelte-store of typed cookies.<!-- +page.svelte -->
<script>
import { rebake } from './bakery.js'
const cookies = rebake()
// key1: Writable<string>
// key2: Writable<number>
// key3: Writable<string[]>
const { key1, key2, key3 } = cookies
// string
$: console.log($key1)
// string
$: $key2 = 123
// or
$: key2.set(123)
// string[]
$: $key3 = ['value', 'set', 'by', 'client']
// or
$: key3.set(['value', 'set', 'by', 'client'])
</script>
pie
from +layout.server.js, etc. and make it the dough
of rebake
.// +layout.server.ts
import { bake } from './bakery.js'
export const load = ({ cookies }) => {
const { bakedCookies, pie } = bake(cookies)
// ...
return {
pie
}
}
<!-- +layout.svelte -->
<script>
import { rebake } from './bakery.js'
export let data
$: ({ pie } = data)
$: cookies = rebake(pie)
// key1: Writable<string>
// key2: Writable<number>
// key3: Writable<string[]>
$: { key1, key2, key3 } = cookies
</script>
This is optional, but it provides full consistency and typed cookie access to the application.
FAQs
🍪 Universal accessible hard-baked cookies for SvelteKit
The npm package svelte-baked-cookie receives a total of 9,302 weekly downloads. As such, svelte-baked-cookie popularity was classified as popular.
We found that svelte-baked-cookie demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.