Skip to content

Commit

Permalink
update dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
pilcrowonpaper committed Jan 25, 2024
1 parent 9821f3e commit d252b36
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 26 deletions.
13 changes: 3 additions & 10 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,11 @@ node_modules
!.env.example
/.vscode
/.auri/*.md
/test-apps/**/.svelte-kit
/test-apps/**/.next
/test-apps/**/.nuxt
/examples/**/.svelte-kit
/examples/**/.next
/examples/**/.nuxt
/examples/**/.solid
/packages/**/dist
/documentation/dist

docs/dist
packages/*/dist

# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock

4 changes: 2 additions & 2 deletions docs/pages/basics/users.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ await db.createUser({
});
```

Use Oslo's [`generateRandomString()`](https://oslo.js.org/reference/random/generateRandomString) if you're looking for a more customizable option.
Use Oslo's [`generateRandomString()`](https://oslo.js.org/reference/crypto/generateRandomString) if you're looking for a more customizable option.

```ts
import { generateRandomString, alphabet } from "oslo/random";
import { generateRandomString, alphabet } from "oslo/crypto";

await db.createUser({
id: generateRandomString(15, alphabet("a-z", "A-Z", "0-9"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ The code should be valid for few minutes and linked to a single email.

```ts
import { TimeSpan, createDate } from "oslo";
import { generateRandomString, alphabet } from "oslo/random";
import { generateRandomString, alphabet } from "oslo/crypto";

async function generateEmailVerificationCode(userId: string, email: string): Promise<string> {
await db.table("email_verification_code").where("user_id", "=", userId).deleteAll();
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/guides/validate-session-cookies/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This guide is also available for:
- [SolidStart](/guides/validate-session-cookies/solidstart)
- [SvelteKit](/guides/validate-session-cookies/sveltekit)

**CSRF protection must be implemented when using cookies and forms.** This can be easily done by comparing the `Origin` and `Host` header.
**CSRF protection must be implemented when using cookies and forms.** This can be easily done by comparing the `Origin` and `Host` header.

For non-GET requests, check the request origin. You can use `readSessionCookie()` to get the session cookie from a HTTP `Cookie` header, and validate it with `Lucia.validateSession()`. Make sure to delete the session cookie if it's invalid and create a new session cookie when the expiration gets extended, which is indicated by `Session.fresh`.

Expand Down
2 changes: 1 addition & 1 deletion docs/pages/guides/validate-session-cookies/sveltekit.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import type { Actions, PageServerLoad } from "./$types";

export const load: PageServerLoad = async (event) => {
if (!event.locals.user) {
redirect("/login");
redirect("/login");
}
// ...
};
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/reference/main/generateId.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function generateId(length: number): string;
## Example

```ts
import { generateId } from "oslo/random";
import { generateId } from "lucia";

// 10-characters long string
generateId(10);
Expand Down
6 changes: 3 additions & 3 deletions docs/pages/tutorials/github-oauth/sveltekit.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export async function GET(event: RequestEvent): Promise<Response> {
sameSite: "lax"
});

redirect(302, url.toString());
redirect(302, url.toString());
}
```

Expand Down Expand Up @@ -210,7 +210,7 @@ You can validate requests by checking `locals.user`. The field `user.username` i
import type { PageServerLoad, Actions } from "./$types";

export const load: PageServerLoad = async (event) => {
if (!event.locals.user) redirect(302, "/login");
if (!event.locals.user) redirect(302, "/login");
return {
username: event.locals.user.username
};
Expand Down Expand Up @@ -243,7 +243,7 @@ export const actions: Actions = {
path: ".",
...sessionCookie.attributes
});
redirect(302, "/login");
redirect(302, "/login");
}
};
```
Expand Down
1 change: 0 additions & 1 deletion docs/pages/upgrade-v3/prisma/postgresql.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ The v3 Prisma adapter now requires all fields to be `camelCase`.

**Migration must be handled manually or else you will lose all your data**. **Do NOT use Prisma's migration tools as is**. Read this guide carefully as some parts depend on your current structure (**especially the table names**), and feel free to ask questions on our Discord server if you have any questions.


## Update session table

The main change to the session table is that the `idle_expires` and `active_expires` fields are replaced with a single `expiresAt` field. Unlike the previous columns, it's a `DateTime` type. Update the `Session` model. Make sure to add any custom attributes you previously had.
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@
},
"dependencies": {
"mocha": "^10.2.0",
"oslo": "^0.16.0"
"oslo": "0.28.2"
}
}
2 changes: 1 addition & 1 deletion packages/adapter-test/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Adapter, DatabaseSession, DatabaseUser } from "lucia";
import { generateRandomString, alphabet } from "oslo/random";
import { generateRandomString, alphabet } from "oslo/crypto";
import assert from "node:assert/strict";

export const databaseUser: DatabaseUser = {
Expand Down
2 changes: 1 addition & 1 deletion packages/lucia/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@
"vitest": "^0.33.0"
},
"dependencies": {
"oslo": "0.28.1"
"oslo": "0.28.2"
}
}
3 changes: 1 addition & 2 deletions packages/lucia/src/crypto.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { encodeHex, decodeHex } from "oslo/encoding";
import { constantTimeEqual } from "oslo/crypto";
import { constantTimeEqual, generateRandomString, alphabet } from "oslo/crypto";
import { scrypt } from "./scrypt/index.js";
import { alphabet, generateRandomString } from "oslo/random";

import type { PasswordHashingAlgorithm } from "oslo/password";

Expand Down
2 changes: 1 addition & 1 deletion packages/lucia/src/scrypt/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect, test } from "vitest";
import { scrypt } from "./index.js";
import { scryptSync as nodeScrypt } from "node:crypto";
import { generateRandomString, alphabet } from "oslo/random";
import { generateRandomString, alphabet } from "oslo/crypto";
import { encodeHex } from "oslo/encoding";

test("scrypt() output matches crypto", async () => {
Expand Down

0 comments on commit d252b36

Please sign in to comment.