Comparing version 3.2.0 to 3.2.1
# lucia | ||
## 3.2.1 | ||
### Patch changes | ||
- [#1708](https://github.com/lucia-auth/lucia/pull/1708) by [@pilcrowOnPaper](https://github.com/pilcrowOnPaper) : Update dependencies. | ||
## 3.2.0 | ||
@@ -4,0 +10,0 @@ |
@@ -1,5 +0,5 @@ | ||
import { TimeSpan } from "oslo"; | ||
import type { Cookie } from "oslo/cookie"; | ||
import { TimeSpan } from "./date.js"; | ||
import type { Adapter } from "./database.js"; | ||
import type { RegisteredDatabaseSessionAttributes, RegisteredDatabaseUserAttributes, RegisteredLucia, UserId } from "./index.js"; | ||
import type { Cookie } from "./cookie.js"; | ||
type SessionAttributes = RegisteredLucia extends Lucia<infer _SessionAttributes, any> ? _SessionAttributes : {}; | ||
@@ -6,0 +6,0 @@ type UserAttributes = RegisteredLucia extends Lucia<any, infer _UserAttributes> ? _UserAttributes : {}; |
@@ -1,3 +0,3 @@ | ||
import { TimeSpan, createDate, isWithinExpirationDate } from "oslo"; | ||
import { CookieController } from "oslo/cookie"; | ||
import { TimeSpan, createDate, isWithinExpirationDate } from "./date.js"; | ||
import { CookieController } from "./cookie.js"; | ||
import { generateIdFromEntropySize } from "./crypto.js"; | ||
@@ -4,0 +4,0 @@ export class Lucia { |
@@ -1,3 +0,1 @@ | ||
import type { PasswordHashingAlgorithm } from "oslo/password"; | ||
export type { PasswordHashingAlgorithm } from "oslo/password"; | ||
export declare function generateId(length: number): string; | ||
@@ -13,1 +11,5 @@ export declare function generateIdFromEntropySize(size: number): string; | ||
} | ||
export interface PasswordHashingAlgorithm { | ||
hash(password: string): Promise<string>; | ||
verify(hash: string, password: string): Promise<boolean>; | ||
} |
@@ -1,3 +0,4 @@ | ||
import { encodeHex, decodeHex, base32 } from "oslo/encoding"; | ||
import { constantTimeEqual, generateRandomString, alphabet } from "oslo/crypto"; | ||
import { decodeHex, encodeBase32LowerCaseNoPadding, encodeHexLowerCase } from "@oslojs/encoding"; | ||
import { generateRandomString } from "@oslojs/crypto/random"; | ||
import { constantTimeEqual } from "@oslojs/crypto/subtle"; | ||
import { scrypt } from "./scrypt/index.js"; | ||
@@ -13,20 +14,22 @@ async function generateScryptKey(data, salt, blockSize = 16) { | ||
}); | ||
return keyUint8Array; | ||
return new Uint8Array(keyUint8Array); | ||
} | ||
const random = { | ||
read(bytes) { | ||
crypto.getRandomValues(bytes); | ||
} | ||
}; | ||
export function generateId(length) { | ||
return generateRandomString(length, alphabet("0-9", "a-z")); | ||
const alphabet = "abcdefghijklmnopqrstuvwxyz0123456789"; | ||
return generateRandomString(random, alphabet, length); | ||
} | ||
export function generateIdFromEntropySize(size) { | ||
const buffer = crypto.getRandomValues(new Uint8Array(size)); | ||
return base32 | ||
.encode(buffer, { | ||
includePadding: false | ||
}) | ||
.toLowerCase(); | ||
return encodeBase32LowerCaseNoPadding(buffer); | ||
} | ||
export class Scrypt { | ||
async hash(password) { | ||
const salt = encodeHex(crypto.getRandomValues(new Uint8Array(16))); | ||
const salt = encodeHexLowerCase(crypto.getRandomValues(new Uint8Array(16))); | ||
const key = await generateScryptKey(password.normalize("NFKC"), salt); | ||
return `${salt}:${encodeHex(key)}`; | ||
return `${salt}:${encodeHexLowerCase(key)}`; | ||
} | ||
@@ -44,5 +47,5 @@ async verify(hash, password) { | ||
async hash(password) { | ||
const salt = encodeHex(crypto.getRandomValues(new Uint8Array(16))); | ||
const salt = encodeHexLowerCase(crypto.getRandomValues(new Uint8Array(16))); | ||
const key = await generateScryptKey(password.normalize("NFKC"), salt); | ||
return `s2:${salt}:${encodeHex(key)}`; | ||
return `s2:${salt}:${encodeHexLowerCase(key)}`; | ||
} | ||
@@ -49,0 +52,0 @@ async verify(hash, password) { |
export { Lucia } from "./core.js"; | ||
export { Scrypt, LegacyScrypt, generateId, generateIdFromEntropySize } from "./crypto.js"; | ||
export { TimeSpan } from "oslo"; | ||
export { Cookie } from "oslo/cookie"; | ||
export { verifyRequestOrigin } from "oslo/request"; | ||
export { TimeSpan } from "./date.js"; | ||
export { Cookie, CookieAttributes } from "./cookie.js"; | ||
export { verifyRequestOrigin } from "./request.js"; | ||
export type { User, Session, SessionCookieOptions, SessionCookieAttributesOptions } from "./core.js"; | ||
export type { DatabaseSession, DatabaseUser, Adapter } from "./database.js"; | ||
export type { PasswordHashingAlgorithm } from "./crypto.js"; | ||
export type { CookieAttributes } from "oslo/cookie"; | ||
import type { Lucia } from "./core.js"; | ||
@@ -11,0 +10,0 @@ export interface Register { |
export { Lucia } from "./core.js"; | ||
export { Scrypt, LegacyScrypt, generateId, generateIdFromEntropySize } from "./crypto.js"; | ||
export { TimeSpan } from "oslo"; | ||
export { Cookie } from "oslo/cookie"; | ||
export { verifyRequestOrigin } from "oslo/request"; | ||
export { TimeSpan } from "./date.js"; | ||
export { Cookie } from "./cookie.js"; | ||
export { verifyRequestOrigin } from "./request.js"; |
{ | ||
"name": "lucia", | ||
"version": "3.2.0", | ||
"version": "3.2.1", | ||
"description": "A simple and flexible authentication library", | ||
@@ -32,3 +32,4 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"oslo": "1.2.0" | ||
"@oslojs/crypto": "^1.0.1", | ||
"@oslojs/encoding": "^1.1.0" | ||
}, | ||
@@ -35,0 +36,0 @@ "scripts": { |
45970
20
682
2
+ Added@oslojs/crypto@^1.0.1
+ Added@oslojs/encoding@^1.1.0
+ Added@oslojs/asn1@1.0.0(transitive)
+ Added@oslojs/binary@1.0.0(transitive)
+ Added@oslojs/crypto@1.0.1(transitive)
+ Added@oslojs/encoding@1.1.0(transitive)
- Removedoslo@1.2.0
- Removed@emnapi/core@0.45.0(transitive)
- Removed@emnapi/runtime@0.45.0(transitive)
- Removed@node-rs/argon2@1.7.0(transitive)
- Removed@node-rs/argon2-android-arm-eabi@1.7.0(transitive)
- Removed@node-rs/argon2-android-arm64@1.7.0(transitive)
- Removed@node-rs/argon2-darwin-arm64@1.7.0(transitive)
- Removed@node-rs/argon2-darwin-x64@1.7.0(transitive)
- Removed@node-rs/argon2-freebsd-x64@1.7.0(transitive)
- Removed@node-rs/argon2-linux-arm-gnueabihf@1.7.0(transitive)
- Removed@node-rs/argon2-linux-arm64-gnu@1.7.0(transitive)
- Removed@node-rs/argon2-linux-arm64-musl@1.7.0(transitive)
- Removed@node-rs/argon2-linux-x64-gnu@1.7.0(transitive)
- Removed@node-rs/argon2-linux-x64-musl@1.7.0(transitive)
- Removed@node-rs/argon2-wasm32-wasi@1.7.0(transitive)
- Removed@node-rs/argon2-win32-arm64-msvc@1.7.0(transitive)
- Removed@node-rs/argon2-win32-ia32-msvc@1.7.0(transitive)
- Removed@node-rs/argon2-win32-x64-msvc@1.7.0(transitive)
- Removed@node-rs/bcrypt@1.9.0(transitive)
- Removed@node-rs/bcrypt-android-arm-eabi@1.9.0(transitive)
- Removed@node-rs/bcrypt-android-arm64@1.9.0(transitive)
- Removed@node-rs/bcrypt-darwin-arm64@1.9.0(transitive)
- Removed@node-rs/bcrypt-darwin-x64@1.9.0(transitive)
- Removed@node-rs/bcrypt-freebsd-x64@1.9.0(transitive)
- Removed@node-rs/bcrypt-linux-arm-gnueabihf@1.9.0(transitive)
- Removed@node-rs/bcrypt-linux-arm64-gnu@1.9.0(transitive)
- Removed@node-rs/bcrypt-linux-arm64-musl@1.9.0(transitive)
- Removed@node-rs/bcrypt-linux-x64-gnu@1.9.0(transitive)
- Removed@node-rs/bcrypt-linux-x64-musl@1.9.0(transitive)
- Removed@node-rs/bcrypt-wasm32-wasi@1.9.0(transitive)
- Removed@node-rs/bcrypt-win32-arm64-msvc@1.9.0(transitive)
- Removed@node-rs/bcrypt-win32-ia32-msvc@1.9.0(transitive)
- Removed@node-rs/bcrypt-win32-x64-msvc@1.9.0(transitive)
- Removed@tybys/wasm-util@0.8.3(transitive)
- Removedfs-monkey@1.0.6(transitive)
- Removedmemfs@3.5.3(transitive)
- Removedmemfs-browser@3.5.10302(transitive)
- Removedoslo@1.2.0(transitive)
- Removedtslib@2.8.1(transitive)