Skip to content

Commit

Permalink
v2.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelmund committed Apr 12, 2022
1 parent 36160db commit eaa0274
Show file tree
Hide file tree
Showing 10 changed files with 487 additions and 378 deletions.
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,6 @@ npm i svelte-kit-cookie-session
yarn add svelte-kit-cookie-session
```

> :warning: **Because of some vite issues [#14](https://github.com/pixelmund/svelte-kit-cookie-session/issues/14) [#15](https://github.com/pixelmund/svelte-kit-cookie-session/issues/15)**: you should add the following to your `svelte.config`!
```js
const config = {
kit: {
vite: {
optimizeDeps: {
exclude: ["svelte-kit-cookie-session"],
},
},
},
};
```

Update your `app.d.ts` file to look something like:

```ts
Expand Down Expand Up @@ -114,6 +100,20 @@ export const handle = handleSession(
);
```

In case you're using [sequence()](https://kit.svelte.dev/docs/modules#sveltejs-kit-hooks-sequence), do this

```js
const sessionHandler = handleSession({
secret: "SOME_COMPLEX_SECRET_AT_LEAST_32_CHARS",
});
export const handle = sequence(sessionHandler, ({ resolve, event }) => {
// event.locals is populated with the session `event.locals.session`
// event.locals is also populated with all parsed cookies by handleSession, it would cause overhead to parse them again - `event.locals.cookies`.
// Do anything you want here
return resolve(event);
});
```

### ♻️ Secret rotation is supported. It allows you to change the secret used to sign and encrypt sessions while still being able to decrypt sessions that were created with a previous secret.

This is useful if you want to:
Expand Down
12 changes: 6 additions & 6 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
"check:watch": "svelte-check --tsconfig ./tsconfig.json --watch"
},
"devDependencies": {
"@sveltejs/adapter-node": "^1.0.0-next.68",
"@sveltejs/adapter-node": "^1.0.0-next.73",
"@sveltejs/kit": "next",
"svelte": "^3.46.4",
"svelte-check": "^2.4.5",
"svelte-preprocess": "^4.10.3",
"svelte": "^3.47.0",
"svelte-check": "^2.6.0",
"svelte-preprocess": "^4.10.5",
"tslib": "^2.3.1",
"typescript": "^4.5.5"
"typescript": "^4.6.3"
},
"type": "module",
"dependencies": {
"svelte-kit-cookie-session": "^2.1.0"
"svelte-kit-cookie-session": "^2.1.2"
}
}
Loading

0 comments on commit eaa0274

Please sign in to comment.