
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
@solid-primitives/cookies
Advanced tools
A set of primitives for handling cookies in solid
createServerCookie
- Provides a getter and setter for a reactive cookie, which works isomorphically.createUserTheme
- Creates a Server Cookie providing a type safe way to store a theme and access it on the server or client.getCookiesString
- A primitive that allows for the cookie string to be accessed isomorphically on the client, or on the servernpm install @solid-primitives/cookies
# or
yarn add @solid-primitives/cookies
# or
pnpm add @solid-primitives/cookies
createServerCookie
A primitive for creating a cookie that can be accessed isomorphically on the client, or the server.
import { createServerCookie } from "@solid-primitives/cookies";
const [cookie, setCookie] = createServerCookie("cookieName");
cookie(); // => string | undefined
Custom cookie serializers and deserializers can also be implemented
import { createServerCookie } from "@solid-primitives/cookies";
const [serverCookie, setServerCookie] = createServerCookie("coolCookie", {
deserialize: str => (str ? str.split(" ") : []), // Deserializes cookie into a string[]
serialize: val => (val ? val.join(" ") : ""), // serializes the value back into a string
});
serverCookie(); // => string[]
createUserTheme
Composes createServerCookie
to provide a type safe way to store a theme and access it on the server or client.
import { createUserTheme } from "@solid-primitives/cookies";
const [theme, setTheme] = createUserTheme("cookieName");
theme(); // => "light" | "dark" | undefined
// with default value
const [theme, setTheme] = createUserTheme("cookieName", {
defaultValue: "light",
});
theme(); // => "light" | "dark"
getCookiesString
A primitive that allows for the cookie string to be accessed isomorphically on the client, or on the server.
Uses getRequestEvent
on the server and document.cookie
on the client.
import { getCookiesString, parseCookie } from "@solid-primitives/cookies";
const string = getCookiesString();
const cookie = parseCookie(string, "cookie_name");
PRs welcome :)
You can view a demo of this primitive here: https://codesandbox.io/p/sandbox/amazing-easley-wqk38i?file=%2Fsrc%2Fcookies_primitive%2Findex.ts%3A36%2C20
See CHANGELOG.md
FAQs
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
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.