@nano/session (1.0.0)

Published 2 weeks ago by HerrHase

Installation

@nano:registry=https://git.node001.net/api/packages/nano/npm/
npm install @nano/session@1.0.0
"@nano/session": "1.0.0"

About this package

Nano Session

Functions and Classes for handle session with @nano/sqlite.

API

Session

Session Object has all Function to create, valid and remove Session. Sqlite can
be the same or a seperated database.

import { getOrCreateSqlite } from '@nano/sqlite'
import { getOrCreateSqlite } from '@nano/session'

const db = getOrCreateSqlite({ uri: ':memory:', create: true, readwrite: true })
const session = new Session(db)

create(userId: number, agent: string, language: string, ip = '')

Create a new Session for User. Agent and Language from User will be used to create a Hmac value in the DB. The IP is optional. If
one of these values are changed, the session is invalid. After Creating the session you get a Random Token, and the userId as
hash.

get(userHash: string, token: string, agent: string, language: string, ip = '')

Get Session for User. If session has expired, the entry will be removed from Database.

destroy(sessionId: number)

Remove single Session for User with id of Session.

destroyAll(userId: number)

Remove all session for a User with UserId.

Dependencies

Dependencies

ID Version
@nano/sqlite ^1.0.1
dayjs ^1.11.13

Development Dependencies

ID Version
dotenv ^16.4.5
Details
npm
2 weeks ago
1
Björn Hase
MIT
latest
3.9 KiB
Assets (1)
Versions (3) View all
1.0.0 on 2026-08-23
0.1.1 on 2024-10-21
0.1.0 on 2024-07-25