-
-
Notifications
You must be signed in to change notification settings - Fork 500
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
368a30c
commit 9d858c7
Showing
26 changed files
with
360 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
type: "interface" | ||
--- | ||
|
||
Represents a database adapter. | ||
|
||
## Definition | ||
|
||
```ts | ||
//$ DatabaseSession=ref:main | ||
//$ DatabaseUser=ref:main | ||
interface Adapter { | ||
deleteSession(sessionId: string): Promise<void>; | ||
deleteUserSessions(userId: string): Promise<void>; | ||
getSessionAndUser( | ||
sessionId: string | ||
): Promise<[session: $$DatabaseSession | null, user: $$DatabaseUser | null]>; | ||
getUserSessions(userId: string): Promise<$$DatabaseSession[]>; | ||
setSession(session: $$DatabaseSession): Promise<void>; | ||
updateSessionExpiration(sessionId: string, expiresAt: Date): Promise<void>; | ||
} | ||
``` | ||
|
||
### Methods | ||
|
||
- `deleteSession()`: Deletes the session | ||
- `deleteUserSessions()`: Deletes all sessions linked to the user | ||
- `getSessionAndUser()`: Returns the session and the user linked to the session | ||
- `getUserSessions()`: Returns all sessions linked to a user | ||
- `setSession()`: Inserts the session | ||
- `updateSessionExpiration()`: Updates the `expires_at` field of the session |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
type: "interface" | ||
--- | ||
|
||
Represents a session stored in a database. | ||
|
||
## Definition | ||
|
||
```ts | ||
//$ DatabaseSessionAttributes=ref:main | ||
interface DatabaseSession { | ||
id: string; | ||
userId: string; | ||
expiresAt: Date; | ||
attributes: $$DatabaseSessionAttributes; | ||
} | ||
``` | ||
|
||
### Properties | ||
|
||
- `id` | ||
- `userId` | ||
- `expiresAt` | ||
- `attributes` |
11 changes: 11 additions & 0 deletions
11
documentation-v3/src/reference/main/DatabaseSessionAttributes.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
type: "interface" | ||
--- | ||
|
||
Additional data stored in the session table. | ||
|
||
## Definition | ||
|
||
```ts | ||
interface DatabaseSessionAttributes {} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
type: "interface" | ||
--- | ||
|
||
Represents a session stored in a database. | ||
|
||
## Definition | ||
|
||
```ts | ||
//$ DatabaseUserAttributes=ref:main | ||
interface DatabaseUser { | ||
id: string; | ||
attributes: DatabaseUserAttributes; | ||
} | ||
``` | ||
|
||
### Properties | ||
|
||
- `id` | ||
- `userId` | ||
- `expiresAt` | ||
- `attributes` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
type: "interface" | ||
--- | ||
|
||
Additional data stored in the user table. | ||
|
||
## Definition | ||
|
||
```ts | ||
interface DatabaseUserAttributes {} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
type: "method" | ||
--- | ||
|
||
Hashes the provided password with scrypt. | ||
|
||
## Definition | ||
|
||
```ts | ||
function hash(password: string): Promise<string>; | ||
``` | ||
|
||
### Parameters | ||
|
||
- `password` | ||
|
||
## Example | ||
|
||
```ts | ||
const hash = await scrypt.hash(password); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
type: "class" | ||
--- | ||
|
||
A pure JS implementation of Scrypt for projects that used Lucia v1/v2. For new projects, use [`Scrypt`](). | ||
|
||
The output hash is a combination of the scrypt hash and the 32-bytes salt, in the format of `<salt>:<hash>`. | ||
|
||
## Constructor | ||
|
||
```ts | ||
function constructor(options?: { N?: number; r?: number; p?: number; dkLen?: number }): this; | ||
``` | ||
|
||
### Parameters | ||
|
||
- `options` | ||
- `N` (default: `16384`) | ||
- `r` (default: `16`) | ||
- `p` (default: `1`) | ||
- `dkLen` (default: `64`) | ||
|
||
## Methods | ||
|
||
- [`hash()`](ref:password/Argon2id) | ||
- [`verify()`](ref:password/Argon2id) | ||
|
||
## Example | ||
|
||
```ts | ||
import { LegacyScrypt } from "lucia"; | ||
|
||
const scrypt = new LegacyScrypt(); | ||
const hash = await scrypt.hash(password); | ||
const validPassword = await scrypt.verify(hash, password); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
type: "method" | ||
--- | ||
|
||
Verifies the password with the hash using scrypt. | ||
|
||
## Definition | ||
|
||
```ts | ||
function verify(hash: string, password: string): Promise<boolean>; | ||
``` | ||
|
||
### Parameters | ||
|
||
- `hash` | ||
- `password` | ||
|
||
## Example | ||
|
||
```ts | ||
const validPassword = await scrypt.verify(hash, password); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
type: "method" | ||
--- | ||
|
||
Hashes the provided password with scrypt. | ||
|
||
## Definition | ||
|
||
```ts | ||
function hash(password: string): Promise<string>; | ||
``` | ||
|
||
### Parameters | ||
|
||
- `password` | ||
|
||
## Example | ||
|
||
```ts | ||
const hash = await scrypt.hash(password); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
type: "class" | ||
--- | ||
|
||
A pure JS implementation of Scrypt. Provides methods for hashing passwords and verifying hashes with [scrypt](https://datatracker.ietf.org/doc/html/rfc7914). By default, the configuration is set to [the recommended values](https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html). | ||
|
||
The output hash is a combination of the scrypt hash and the 32-bytes salt, in the format of `<salt>:<hash>`. | ||
|
||
Since it's pure JS, it is anywhere from 2~3 times slower than implementations based on native code. See Oslo's [`Scrypt`]() for a faster API (Node.js-only). | ||
|
||
## Constructor | ||
|
||
```ts | ||
function constructor(options?: { N?: number; r?: number; p?: number; dkLen?: number }): this; | ||
``` | ||
|
||
### Parameters | ||
|
||
- `options` | ||
- `N` (default: `16384`) | ||
- `r` (default: `16`) | ||
- `p` (default: `1`) | ||
- `dkLen` (default: `64`) | ||
|
||
## Methods | ||
|
||
- [`hash()`](ref:password/Argon2id) | ||
- [`verify()`](ref:password/Argon2id) | ||
|
||
## Example | ||
|
||
```ts | ||
import { Scrypt } from "lucia"; | ||
|
||
const scrypt = new Scrypt(); | ||
const hash = await scrypt.hash(password); | ||
const validPassword = await scrypt.verify(hash, password); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
type: "method" | ||
--- | ||
|
||
Verifies the password with the hash using scrypt. | ||
|
||
## Definition | ||
|
||
```ts | ||
function verify(hash: string, password: string): Promise<boolean>; | ||
``` | ||
|
||
### Parameters | ||
|
||
- `hash` | ||
- `password` | ||
|
||
## Example | ||
|
||
```ts | ||
const validPassword = await scrypt.verify(hash, password); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
type: "interface" | ||
--- | ||
|
||
Represents a session. | ||
|
||
## Definition | ||
|
||
```ts | ||
//$ SessionAttributes=ref:main | ||
interface Session extends SessionAttributes { | ||
id: string; | ||
expiresAt: Date; | ||
fresh: boolean; | ||
userId: string; | ||
} | ||
``` | ||
|
||
|
||
### Properties | ||
|
||
- `id` | ||
- `expiresAt` | ||
- `fresh`: `true` if session was newly created or its expiration was extended | ||
- `userId` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
type: "class" | ||
--- | ||
|
||
See [`SessionCookie`](https://oslo.js.org/reference/session/SessionCookie/) from `oslo/session`. |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
type: "class" | ||
--- | ||
|
||
See [`TimeSpan`](https://oslo.js.org/reference/main/TimeSpan/) from `oslo`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
type: "interface" | ||
--- | ||
|
||
Represents a user. | ||
|
||
## Definition | ||
|
||
```ts | ||
//$ UserAttributes=ref:main | ||
interface Session extends UserAttributes { | ||
id: string; | ||
} | ||
``` | ||
|
||
|
||
### Properties | ||
|
||
- `id` |
Oops, something went wrong.