
Research
/Security News
9 Malicious NuGet Packages Deliver Time-Delayed Destructive Payloads
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.
svelte-kit-connect-redis
Advanced tools
svelte-kit-connect-redis provides Redis session storage for svelte-kit-sessions.
svelte-kit-connect-redis requires svelte-kit-sessions to installed and one of the following compatible Redis clients:
Install with redis:
$ npm install redis svelte-kit-connect-redis svelte-kit-sessions
$ yarn add redis svelte-kit-connect-redis svelte-kit-sessions
$ pnpm add redis svelte-kit-connect-redis svelte-kit-sessions
Install with ioredis:
$ npm install ioredis svelte-kit-connect-redis svelte-kit-sessions
$ yarn add ioredis svelte-kit-connect-redis svelte-kit-sessions
$ pnpm add ioredis svelte-kit-connect-redis svelte-kit-sessions
svelte-kit-connect-redis can be used as a custom store for svelte-kit-sessions as follows.
Note For more information about svelte-kit-sessions, see https://www.npmjs.com/package/svelte-kit-sessions.
// src/hooks.server.ts
import type { Handle } from '@sveltejs/kit';
import { sveltekitSessionHandle } from 'svelte-kit-sessions';
import RedisStore from 'svelte-kit-connect-redis';
import { createClient } from 'redis';
const client = redis.createClient({
url: 'redis://{your redis endpoint}'
});
const clientConnection = await client.connect();
export const handle: Handle = sveltekitSessionHandle({
secret: 'secret',
store: new RedisStore({ client: clientConnection })
});
// src/hooks.server.ts
import type { Handle } from '@sveltejs/kit';
import { sveltekitSessionHandle } from 'svelte-kit-sessions';
import RedisStore from 'svelte-kit-connect-redis';
import { Redis } from 'ioredis';
const client = new Redis({
host: '{your redis host}',
port: 6379
});
export const handle: Handle = sveltekitSessionHandle({
secret: 'secret',
store: new RedisStore({ client })
});
import RedisStore from 'svelte-kit-connect-redis';
new RedisStore(options);
Create a Redis store for svelte-kit-sessions.
A summary of the options is as follows.
| Name | Type | required/optional | Description |
|---|---|---|---|
| client | redis.RedisClientType | ioredis.Redis | required | An instance of redis or ioredis |
| prefix | string | optional | Key prefix in Redis (default: sess:). |
| serializer | Serializer | optional | Provide a custom encoder/decoder to use when storing and retrieving session data from Redis (default: JSON.parse and JSON.stringify). |
| ttl | number | optional | ttl to be used if ttl is Infinity when used from svelte-kit-sessions |
An instance of redis or ioredis.
Key prefix in Redis (default: sess:).
Provide a custom encoder/decoder to use when storing and retrieving session data from Redis (default: JSON.parse and JSON.stringify).
Note When setting up a custom serializer, the following interface must be satisfied.
interface Serializer {
parse(s: string): SessionStoreData | Promise<SessionStoreData>;
stringify(data: SessionStoreData): string;
}
When svelte-kit-sessions calls a method of the store (the set function), ttl(milliseconds) is passed to it. However, if the cookie options expires and maxAge are not set, the ttl passed will be Infinity.
If the ttl passed is Infinity, the ttl to be set can be set with this option. The unit is milliseconds.
// `svelte-kit-connect-redis` implementation excerpts
const ONE_DAY_IN_SECONDS = 86400;
export default class RedisStore implements Store {
constructor(options: RedisStoreOptions) {
this.ttl = options.ttl || ONE_DAY_IN_SECONDS * 1000;
}
ttl: number;
async set(id: string, storeData: SessionStoreData, ttl: number): Promise<void> {
// omission ...
if (ttl !== Infinity) {
// if `ttl` passed as argument is *not* Infinity, use the argument `ttl` as it is.
await this.client.set(key, serialized, { PX: ttl });
return;
}
// if `ttl` passed as argument is Infinity, use `options.ttl` or default.
await this.client.set(key, serialized, { PX: this.ttl });
}
}
[0.1.0] - 2024-01-09
FAQs
Redis session storage for svelte-kit-sessions.
The npm package svelte-kit-connect-redis receives a total of 35 weekly downloads. As such, svelte-kit-connect-redis popularity was classified as not popular.
We found that svelte-kit-connect-redis demonstrated a not healthy version release cadence and project activity because the last version was released 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 researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.