
Security News
How Enterprise Security Is Adapting to AI-Accelerated Threats
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.
svelte-session-manager
Advanced tools
Session store for svelte (currently only for JWT)
import { derived } from 'svelte';
import { Session, login } from 'svelte-session-manager';
// use localStorage as backing store
let session = new Session(localStorage);
// session may still be valid
if(!session.isValid) {
await login(session, 'https://mydomain.com/authenticate', 'a user', 'a secret');
}
session.isValid; // true when auth was ok or localStorage token is still valid
export const values = derived(
session,
($session, set) => {
if (!session.isValid) {
set([]); // session has expired no more data
} else {
fetch('https://mydomain.com/values', {
headers: {
...session.authorizationHeader
}
}).then(async data => set(await data.json()));
}
return () => {};
}
,[]);
// $values contains fetch result as long as session has not expired
export BROWSER=safari|chrome|...
npm|yarn test
Data as preserved in the backing store
Type: Object
User session To create as session backed by browser local storage
let session = new Session(localStorage);
or session storage
let session = new Session(sessionStorage);
data SessionDataentitlements Set<string>subscriptions Set<Object> store subscriptionsexpirationDate Datestore SessionData backing store to use for save same as data parampersist into the packing store
http header suitable for fetch
Returns Object header The http header.
Returns string header.Authorization The Bearer access token.
As long as the expirationTimer is running we must be valid
Returns boolean true if session is valid (not expired)
remove all tokens from the session and the backing store
Fired when the session changes
subscription FunctionBring session into the valid state by calling the authorization endpoint and asking for a access_token. Executess a POST on the endpoint url providing username, and password as json
session Session to be openedendpoint string authorization urlusername string id of the userpassword string user credentialsWith npm do:
npm install svelte-session-manager
BSD-2-Clause
FAQs
Session store for svelte (currently only for JWT)
The npm package svelte-session-manager receives a total of 809 weekly downloads. As such, svelte-session-manager popularity was classified as not popular.
We found that svelte-session-manager 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.

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.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.