From a328621b28dfe479240eeac4d1892049f2caac95 Mon Sep 17 00:00:00 2001 From: lucythecat Date: Sat, 9 Dec 2023 00:02:13 +0900 Subject: [PATCH] simplify docs structure --- .../content/guidebook/drizzle-orm.md | 0 .../email-verification-links/$express.md | 0 .../email-verification-links/$nextjs-app.md | 0 .../email-verification-links/$nextjs-pages.md | 0 .../email-verification-links/$nuxt.md | 0 .../email-verification-links/$sveltekit.md | 0 .../email-verification-links/index.md | 0 .../guidebook/password-reset-link/$express.md | 0 .../password-reset-link/$nextjs-app.md | 0 .../password-reset-link/$nextjs-pages.md | 0 .../guidebook/password-reset-link/$nuxt.md | 0 .../password-reset-link/$sveltekit.md | 0 .../guidebook/password-reset-link/index.md | 0 documentation/content/main/basics/database.md | 0 .../main/database-adapters/mongoose.md | 0 .../content/oauth/basics/oauth2-pkce.md | 0 documentation/content/oauth/basics/oauth2.md | 0 documentation/content/oauth/index.md | 0 .../content/oauth/providers/apple.md | 0 .../content/oauth/providers/kakao.md | 164 ------------------ .../content/oauth/providers/keycloak.md | 153 ---------------- .../reference/lucia/interfaces/auth.md | 0 .../reference/oauth/modules/providers.md | 0 .../src/components/MarkdownArticle.astro | 2 +- documentation/src/components/NavMenu.astro | 10 +- .../src/components/menus/OAuthMenu.astro | 0 documentation/src/layouts/DocLayout.astro | 14 +- documentation/src/layouts/MainLayout.astro | 71 ++++---- .../src/layouts/ReferenceLayout.astro | 63 ------- .../src/pages/getting-started/elysia.md | 0 .../src/pages/getting-started/express.md | 0 .../src/pages/getting-started/hono.md | 0 .../Lucia/createBlankSessionCookie.md | 13 -- .../pages/reference/Lucia/createSession.md | 19 -- .../reference/Lucia/createSessionCookie.md | 13 -- .../pages/reference/Lucia/getUserSessions.md | 17 -- .../src/pages/reference/Lucia/index.md | 68 -------- .../reference/Lucia/invalidateSession.md | 16 -- .../reference/Lucia/invalidateUserSessions.md | 16 -- .../pages/reference/Lucia/readBearerToken.md | 16 -- .../reference/Lucia/readSessionCookie.md | 16 -- .../pages/reference/Lucia/validateSession.md | 20 --- .../src/pages/reference/SessionCookie.md | 6 - documentation/src/pages/reference/TimeSpan.md | 6 - documentation/src/pages/reference/User.md | 19 -- documentation/src/pages/reference/index.md | 26 --- .../src/pages/reference/{ => main}/Adapter.md | 9 +- .../reference/{ => main}/DatabaseSession.md | 7 +- .../{ => main}/DatabaseSessionAttributes.md | 5 +- .../reference/{ => main}/DatabaseUser.md | 7 +- .../{ => main}/DatabaseUserAttributes.md | 5 +- .../{Scrypt => main/LegacyScrypt}/hash.md | 7 +- .../{ => main}/LegacyScrypt/index.md | 9 +- .../{ => main}/LegacyScrypt/verify.md | 7 +- .../main/Lucia/createBlankSessionCookie.md | 14 ++ .../reference/main/Lucia/createSession.md | 20 +++ .../main/Lucia/createSessionCookie.md | 14 ++ .../reference/main/Lucia/getUserSessions.md | 18 ++ .../src/pages/reference/main/Lucia/index.md | 69 ++++++++ .../reference/main/Lucia/invalidateSession.md | 17 ++ .../main/Lucia/invalidateUserSessions.md | 17 ++ .../reference/main/Lucia/readBearerToken.md | 17 ++ .../reference/main/Lucia/readSessionCookie.md | 17 ++ .../reference/main/Lucia/validateSession.md | 21 +++ .../{LegacyScrypt => main/Scrypt}/hash.md | 7 +- .../reference/{ => main}/Scrypt/index.md | 5 +- .../reference/{ => main}/Scrypt/verify.md | 7 +- .../src/pages/reference/{ => main}/Session.md | 7 +- .../src/pages/reference/main/SessionCookie.md | 7 + .../src/pages/reference/main/TimeSpan.md | 7 + .../src/pages/reference/main/User.md | 20 +++ .../pages/reference/{ => main}/generateId.md | 5 +- .../src/pages/reference/main/index.md | 29 ++++ 73 files changed, 388 insertions(+), 734 deletions(-) delete mode 100644 documentation/content/guidebook/drizzle-orm.md delete mode 100644 documentation/content/guidebook/email-verification-links/$express.md delete mode 100644 documentation/content/guidebook/email-verification-links/$nextjs-app.md delete mode 100644 documentation/content/guidebook/email-verification-links/$nextjs-pages.md delete mode 100644 documentation/content/guidebook/email-verification-links/$nuxt.md delete mode 100644 documentation/content/guidebook/email-verification-links/$sveltekit.md delete mode 100644 documentation/content/guidebook/email-verification-links/index.md delete mode 100644 documentation/content/guidebook/password-reset-link/$express.md delete mode 100644 documentation/content/guidebook/password-reset-link/$nextjs-app.md delete mode 100644 documentation/content/guidebook/password-reset-link/$nextjs-pages.md delete mode 100644 documentation/content/guidebook/password-reset-link/$nuxt.md delete mode 100644 documentation/content/guidebook/password-reset-link/$sveltekit.md delete mode 100644 documentation/content/guidebook/password-reset-link/index.md delete mode 100644 documentation/content/main/basics/database.md delete mode 100644 documentation/content/main/database-adapters/mongoose.md delete mode 100644 documentation/content/oauth/basics/oauth2-pkce.md delete mode 100644 documentation/content/oauth/basics/oauth2.md delete mode 100644 documentation/content/oauth/index.md delete mode 100644 documentation/content/oauth/providers/apple.md delete mode 100644 documentation/content/oauth/providers/kakao.md delete mode 100644 documentation/content/oauth/providers/keycloak.md delete mode 100644 documentation/content/reference/lucia/interfaces/auth.md delete mode 100644 documentation/content/reference/oauth/modules/providers.md delete mode 100644 documentation/src/components/menus/OAuthMenu.astro delete mode 100644 documentation/src/layouts/ReferenceLayout.astro delete mode 100644 documentation/src/pages/getting-started/elysia.md delete mode 100644 documentation/src/pages/getting-started/express.md delete mode 100644 documentation/src/pages/getting-started/hono.md delete mode 100644 documentation/src/pages/reference/Lucia/createBlankSessionCookie.md delete mode 100644 documentation/src/pages/reference/Lucia/createSession.md delete mode 100644 documentation/src/pages/reference/Lucia/createSessionCookie.md delete mode 100644 documentation/src/pages/reference/Lucia/getUserSessions.md delete mode 100644 documentation/src/pages/reference/Lucia/index.md delete mode 100644 documentation/src/pages/reference/Lucia/invalidateSession.md delete mode 100644 documentation/src/pages/reference/Lucia/invalidateUserSessions.md delete mode 100644 documentation/src/pages/reference/Lucia/readBearerToken.md delete mode 100644 documentation/src/pages/reference/Lucia/readSessionCookie.md delete mode 100644 documentation/src/pages/reference/Lucia/validateSession.md delete mode 100644 documentation/src/pages/reference/SessionCookie.md delete mode 100644 documentation/src/pages/reference/TimeSpan.md delete mode 100644 documentation/src/pages/reference/User.md delete mode 100644 documentation/src/pages/reference/index.md rename documentation/src/pages/reference/{ => main}/Adapter.md (84%) rename documentation/src/pages/reference/{ => main}/DatabaseSession.md (64%) rename documentation/src/pages/reference/{ => main}/DatabaseSessionAttributes.md (58%) rename documentation/src/pages/reference/{ => main}/DatabaseUser.md (61%) rename documentation/src/pages/reference/{ => main}/DatabaseUserAttributes.md (57%) rename documentation/src/pages/reference/{Scrypt => main/LegacyScrypt}/hash.md (50%) rename documentation/src/pages/reference/{ => main}/LegacyScrypt/index.md (80%) rename documentation/src/pages/reference/{ => main}/LegacyScrypt/verify.md (54%) create mode 100644 documentation/src/pages/reference/main/Lucia/createBlankSessionCookie.md create mode 100644 documentation/src/pages/reference/main/Lucia/createSession.md create mode 100644 documentation/src/pages/reference/main/Lucia/createSessionCookie.md create mode 100644 documentation/src/pages/reference/main/Lucia/getUserSessions.md create mode 100644 documentation/src/pages/reference/main/Lucia/index.md create mode 100644 documentation/src/pages/reference/main/Lucia/invalidateSession.md create mode 100644 documentation/src/pages/reference/main/Lucia/invalidateUserSessions.md create mode 100644 documentation/src/pages/reference/main/Lucia/readBearerToken.md create mode 100644 documentation/src/pages/reference/main/Lucia/readSessionCookie.md create mode 100644 documentation/src/pages/reference/main/Lucia/validateSession.md rename documentation/src/pages/reference/{LegacyScrypt => main/Scrypt}/hash.md (52%) rename documentation/src/pages/reference/{ => main}/Scrypt/index.md (94%) rename documentation/src/pages/reference/{ => main}/Scrypt/verify.md (56%) rename documentation/src/pages/reference/{ => main}/Session.md (70%) create mode 100644 documentation/src/pages/reference/main/SessionCookie.md create mode 100644 documentation/src/pages/reference/main/TimeSpan.md create mode 100644 documentation/src/pages/reference/main/User.md rename documentation/src/pages/reference/{ => main}/generateId.md (81%) create mode 100644 documentation/src/pages/reference/main/index.md diff --git a/documentation/content/guidebook/drizzle-orm.md b/documentation/content/guidebook/drizzle-orm.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/documentation/content/guidebook/email-verification-links/$express.md b/documentation/content/guidebook/email-verification-links/$express.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/documentation/content/guidebook/email-verification-links/$nextjs-app.md b/documentation/content/guidebook/email-verification-links/$nextjs-app.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/documentation/content/guidebook/email-verification-links/$nextjs-pages.md b/documentation/content/guidebook/email-verification-links/$nextjs-pages.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/documentation/content/guidebook/email-verification-links/$nuxt.md b/documentation/content/guidebook/email-verification-links/$nuxt.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/documentation/content/guidebook/email-verification-links/$sveltekit.md b/documentation/content/guidebook/email-verification-links/$sveltekit.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/documentation/content/guidebook/email-verification-links/index.md b/documentation/content/guidebook/email-verification-links/index.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/documentation/content/guidebook/password-reset-link/$express.md b/documentation/content/guidebook/password-reset-link/$express.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/documentation/content/guidebook/password-reset-link/$nextjs-app.md b/documentation/content/guidebook/password-reset-link/$nextjs-app.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/documentation/content/guidebook/password-reset-link/$nextjs-pages.md b/documentation/content/guidebook/password-reset-link/$nextjs-pages.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/documentation/content/guidebook/password-reset-link/$nuxt.md b/documentation/content/guidebook/password-reset-link/$nuxt.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/documentation/content/guidebook/password-reset-link/$sveltekit.md b/documentation/content/guidebook/password-reset-link/$sveltekit.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/documentation/content/guidebook/password-reset-link/index.md b/documentation/content/guidebook/password-reset-link/index.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/documentation/content/main/basics/database.md b/documentation/content/main/basics/database.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/documentation/content/main/database-adapters/mongoose.md b/documentation/content/main/database-adapters/mongoose.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/documentation/content/oauth/basics/oauth2-pkce.md b/documentation/content/oauth/basics/oauth2-pkce.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/documentation/content/oauth/basics/oauth2.md b/documentation/content/oauth/basics/oauth2.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/documentation/content/oauth/index.md b/documentation/content/oauth/index.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/documentation/content/oauth/providers/apple.md b/documentation/content/oauth/providers/apple.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/documentation/content/oauth/providers/kakao.md b/documentation/content/oauth/providers/kakao.md deleted file mode 100644 index 9343a2204..000000000 --- a/documentation/content/oauth/providers/kakao.md +++ /dev/null @@ -1,164 +0,0 @@ ---- -title: "Kakao OAuth provider" -description: "Learn how to use the Kakao OAuth provider" ---- - -OAuth integration for Kakao. Refer to [Prerequisites](https://developers.kakao.com/docs/latest/en/kakaologin/prerequisite) and [REST API docs for Kakao login](https://developers.kakao.com/docs/latest/en/kakaologin/rest-api) for getting the required credentials. Provider id is `kakao`. - -```ts -import { kakao } from "@lucia-auth/oauth/providers"; -import { auth } from "./lucia.js"; - -const kakaoAuth = kakao(auth, config); -``` - -## `kakao()` - -```ts -const kakao: ( - auth: Auth, - config: { - clientId: string; - clientSecret: string; - redirectUri: string; - scope?: string[]; - } -) => KakaoProvider; -``` - -##### Parameters - -| name | type | description | optional | -| --------------------- | ------------------------------------------ | ----------------------------- | :------: | -| `auth` | [`Auth`](/reference/lucia/interfaces/auth) | Lucia instance | | -| `config.clientId` | `string` | Kakao OAuth app client id | | -| `config.clientSecret` | `string` | Kakao OAuth app client secret | | -| `config.redirectUri` | `string` | an authorized redirect URI | ✓ | -| `config.scope` | `string[]` | an array of scopes | ✓ | - -##### Returns - -| type | description | -| --------------------------------- | -------------- | -| [`KakaoProvider`](#kakaoprovider) | Kakao provider | - -## Interfaces - -### `KakaoAuth` - -See [`OAuth2ProviderAuth`](/reference/oauth/interfaces/oauth2providerauth). - -```ts -// implements OAuth2ProviderAuth> -interface KakaoAuth<_Auth extends Auth> { - getAuthorizationUrl: () => Promise; - validateCallback: (code: string) => Promise>; -} -``` - -| type | -| --------------------------------- | -| [`KakaoUserAuth`](#kakaouserauth) | - -##### Generics - -| name | extends | default | -| ------- | ------------------------------------------ | ------- | -| `_Auth` | [`Auth`](/reference/lucia/interfaces/auth) | `Auth` | - -### `KakaoTokens` - -```ts -type KakaoTokens = { - accessToken: string; - expiresIn: number; - refreshToken: string; - refreshTokenExpiresIn: number; -}; -``` - -### `KakaoUser` - -```ts -type KakaoUser = { - id: number; - has_signed_up?: boolean; - connected_at?: string; - synced_at?: string; - properties?: Record; - kakao_account?: KakaoAccount; - for_partner?: Partner; -}; - -type KakaoAccount = { - profile_needs_agreement?: boolean; - profile_nickname_needs_agreement?: boolean; - profile_image_needs_agreement?: boolean; - profile?: Profile; - email_needs_agreement?: boolean; - is_email_valid?: boolean; - is_email_verified?: boolean; - email?: string; - name_needs_agreement?: boolean; - name?: string; - age_range_needs_agreement?: boolean; - // "1~9, 10~14, 15~19, 20~29, 30~39, 40~49, 50~59, 60~69, 70~79, 80~89, 90~"; - ag_range?: - | "1~9" - | "10~14" - | "15~19" - | "20~29" - | "30~39" - | "40~49" - | "50~59" - | "60~69" - | "70~79" - | "80~89" - | "90~"; - birthyear_needs_agreement?: boolean; - birthyear?: string; // "YYYY"; - birthday_needs_agreement?: boolean; - birthday?: string; // "MMDD"; - birthday_type?: "SOLAR" | "LUNAR"; - gender_needs_agreement?: boolean; - gender?: "female" | "male"; - phone_number_needs_agreement?: boolean; - phone_number?: string; - ci_needs_agreement?: boolean; - ci?: string; - ci_authenticated_at?: string; -}; - -type Profile = { - nickname?: string; - thumbnail_image_url?: string; - profile_image_url?: string; - is_default_image?: boolean; -}; - -type Partner = { - uuid?: string; -}; -``` - -### `KakaoUserAuth` - -Extends [`ProviderUserAuth`](/reference/oauth/interfaces/provideruserauth). - -```ts -interface KakaoUserAuth<_Auth extends Auth> extends ProviderUserAuth<_Auth> { - kakaoUser: KakaoUser; - kakaoTokens: KakaoTokens; -} -``` - -| properties | type | description | -| ------------- | ----------------------------- | ----------------- | -| `kakaoUser` | [`KakaoUser`](#kakaouser) | Kakao user | -| `kakaoTokens` | [`KakaoTokens`](#kakaotokens) | Access tokens etc | - -##### Generics - -| name | extends | -| ------- | ------------------------------------------ | -| `_Auth` | [`Auth`](/reference/lucia/interfaces/auth) | diff --git a/documentation/content/oauth/providers/keycloak.md b/documentation/content/oauth/providers/keycloak.md deleted file mode 100644 index 2310a7e89..000000000 --- a/documentation/content/oauth/providers/keycloak.md +++ /dev/null @@ -1,153 +0,0 @@ ---- -title: "Keycloak OAuth provider" -description: "Learn how to use the Keycloak OAuth provider" ---- - -OAuth integration for Keycloak. Refer to [Keycloak Documentation](https://www.keycloak.org/docs/latest/authorization_services/index.html) for getting the required credentials. Provider id is `keycloak`. - -```ts -import { keycloak } from "@lucia-auth/oauth/providers"; -import { auth } from "./lucia.js"; - -const keycloakAuth = keycloak(auth, config); -``` - -## `keycloak()` - -```ts -const keycloak: ( - auth: Auth, - config: { - domain: string; - realm: string; - clientId: string; - clientSecret: string; - scope?: string[]; - redirectUri?: string; - } -) => KeycloakProvider; -``` - -##### Parameters - -| name | type | description | optional | -| --------------------- | ------------------------------------------ | --------------------------------------------------- | :------: | -| `auth` | [`Auth`](/reference/lucia/interfaces/auth) | Lucia instance | | -| `config.domain` | `string` | Keycloak OAuth app client id (e.g. 'my.domain.com') | | -| `config.realm` | `string` | Keycloak Realm of client | | -| `config.clientId` | `string` | Keycloak OAuth app client id | | -| `config.clientSecret` | `string` | Keycloak OAuth app client secret | | -| `config.scope` | `string[]` | an array of scopes | ✓ | -| `config.redirectUri` | `string` | an authorized redirect URI | ✓ | - -##### Returns - -| type | description | -| --------------------------------------- | ----------------- | -| [`KeycloakProvider`](#keycloakprovider) | Keycloak provider | - -## Interfaces - -### `KeycloakAuth` - -See [`OAuth2ProviderAuth`](/reference/oauth/interfaces/oauth2providerauth). - -```ts -// implements OAuth2ProviderAuth> - -interface KeycloakAuth<_Auth extends Auth> { - getAuthorizationUrl: () => Promise; - validateCallback: (code: string) => Promise>; -} -``` - -| type | -| --------------------------------------- | -| [`KeycloakUserAuth`](#keycloakuserauth) | - -##### Generics - -| name | extends | default | -| ------- | ------------------------------------------ | ------- | -| `_Auth` | [`Auth`](/reference/lucia/interfaces/auth) | `Auth` | - -### `KeycloakTokens` - -```ts -type KeycloakTokens = { - accessToken: string; - accessTokenExpiresIn: number; - authTime: number; - issuedAtTime: number; - expirationTime: number; - refreshToken: string | null; - refreshTokenExpiresIn: number | null; -}; -``` - -### `KeycloakUser` - -```ts -type KeycloakUser = { - exp: number; - iat: number; - auth_time: number; - jti: string; - iss: string; - aud: string; - sub: string; - typ: string; - azp: string; - session_state: string; - at_hash: string; - acr: string; - sid: string; - email_verified: boolean; - name: string; - preferred_username: string; - given_name: string; - locale: string; - family_name: string; - email: string; - picture: string; - user: any; -}; -``` - -### `KeycloakRole` - -```ts -type KeycloakUser = PublicKeycloakUser | PrivateKeycloakUser; - -type KeycloakRole = { - role_type: "realm" | "resource"; - - client: null | string; // null if realm_access - - role: string; -}; -``` - -### `KeycloakUserAuth` - -Extends [`ProviderUserAuth`](/reference/oauth/interfaces/provideruserauth). - -```ts -interface KeycloakUserAuth<_Auth extends Auth> extends ProviderUserAuth<_Auth> { - keycloakUser: KeycloakUser; - keycloakTokens: KeycloakTokens; - keycloakRoles: KeycloakRoles; -} -``` - -| properties | type | description | -| ---------------- | ----------------------------------- | ---------------------------------------- | -| `keycloakUser` | [`KeycloakUser`](#keycloakuser) | Keycloak user | -| `keycloakTokens` | [`KeycloakTokens`](#keycloaktokens) | Access tokens etc | -| `keycloakRoles` | [`KeycloakRoles`](#keycloakroles) | Keycloak roles retrieved from OIDC Token | - -##### Generics - -| name | extends | -| ------- | ------------------------------------------ | -| `_Auth` | [`Auth`](/reference/lucia/interfaces/auth) | diff --git a/documentation/content/reference/lucia/interfaces/auth.md b/documentation/content/reference/lucia/interfaces/auth.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/documentation/content/reference/oauth/modules/providers.md b/documentation/content/reference/oauth/modules/providers.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/documentation/src/components/MarkdownArticle.astro b/documentation/src/components/MarkdownArticle.astro index bff84be8d..8e09110f8 100644 --- a/documentation/src/components/MarkdownArticle.astro +++ b/documentation/src/components/MarkdownArticle.astro @@ -15,7 +15,7 @@ :global(.md > ul) { @apply mb-6 mt-4 list-inside list-disc pl-2; } - :global(.md > ul > li > ul) { + :global(.md ul > li > ul) { @apply list-inside list-disc pl-6; } :global(.md p a) { diff --git a/documentation/src/components/NavMenu.astro b/documentation/src/components/NavMenu.astro index 421e1acbd..edd624959 100644 --- a/documentation/src/components/NavMenu.astro +++ b/documentation/src/components/NavMenu.astro @@ -8,7 +8,7 @@ export interface Section { pages: Page[]; } -export type Page = [title: string, href: string]; +export type Page = [title: string, href: string, format?: "code"]; function isSelected(href: string, currentPathname: string): boolean { if (removeLeadingSlash(href) === removeLeadingSlash(currentPathname)) { @@ -28,9 +28,9 @@ function removeLeadingSlash(s: string): string {
    { Astro.props.sections.map((section) => { - if (section.pages.length < 1) { - return null - } + if (section.pages.length < 1) { + return null; + } return (
  • {section.title}

    @@ -48,7 +48,7 @@ function removeLeadingSlash(s: string): string { ]} href={page[1]} > - {page[0]} + {page[2] === "code" ? {page[0]} : page[0]}
  • ); diff --git a/documentation/src/components/menus/OAuthMenu.astro b/documentation/src/components/menus/OAuthMenu.astro deleted file mode 100644 index e69de29bb..000000000 diff --git a/documentation/src/layouts/DocLayout.astro b/documentation/src/layouts/DocLayout.astro index 096d95fa9..b9ec5da02 100644 --- a/documentation/src/layouts/DocLayout.astro +++ b/documentation/src/layouts/DocLayout.astro @@ -6,11 +6,23 @@ import type { MarkdownLayoutProps } from "astro"; type Props = MarkdownLayoutProps<{ title: string; + format?: "code"; }>; --- -

    {Astro.props.frontmatter.title}

    + { + Astro.props.frontmatter.format === "code" ? ( +

    + {Astro.props.frontmatter.title} +

    + ) : ( +

    + {Astro.props.frontmatter.title} +

    + ) + } + diff --git a/documentation/src/layouts/MainLayout.astro b/documentation/src/layouts/MainLayout.astro index 0bd2e6aac..da7eb1a32 100644 --- a/documentation/src/layouts/MainLayout.astro +++ b/documentation/src/layouts/MainLayout.astro @@ -7,60 +7,53 @@ interface Props { title: string; } -const startHerePages: Page[] = [ - ["Getting-started", "/getting-started"], - ["Database", "/database"], - ["Upgrade to v3", "/upgrade-v3"] -]; - -const tutorialPages: Page[] = [ - ["GitHub OAuth", "/tutorials/github-oauth"], - ["Username and password", "/tutorials/username-and-password"] -]; - -const basicsPages: Page[] = [ - ["Sessions", "/basics/sessions"], - ["Users", "/basics/users"], - ["Configuration", "/basics/configuration"], - ["Troubleshooting", "/basics/help"], - ["API reference", "/reference"] -]; - -const guidesPages: Page[] = [ - ["Validate session cookies", "/guides/validate-session-cookies"], - ["Validate bearer tokens", "/guides/validate-bearer-tokens"], - ["OAuth", "/guides/oauth"], - ["Email and password", "/guides/email-and-password"], - ["Passkeys", "/guides/passkeys"], - ["Improving sessions", "/guides/improving-sessions"] -]; - -const communityPages: Page[] = [ - ["Discord", "https://discord.com/invite/PwrK3kpVR3"], - ["GitHub", "https://github.com/lucia-auth/lucia"], - ["Twitter", "https://twitter.com/lucia-auth"] -]; - const sections: Section[] = [ { title: "Start here", - pages: startHerePages + pages: [ + ["Getting-started", "/getting-started"], + ["Database", "/database"], + ["Upgrade to v3", "/upgrade-v3"] + ] }, { title: "Tutorials", - pages: tutorialPages + pages: [ + ["GitHub OAuth", "/tutorials/github-oauth"], + ["Username and password", "/tutorials/username-and-password"] + ] }, { title: "Basics", - pages: basicsPages + pages: [ + ["Sessions", "/basics/sessions"], + ["Users", "/basics/users"], + ["Configuration", "/basics/configuration"], + ["Troubleshooting", "/basics/help"] + ] }, { title: "Guides", - pages: guidesPages + pages: [ + ["Validate session cookies", "/guides/validate-session-cookies"], + ["Validate bearer tokens", "/guides/validate-bearer-tokens"], + ["OAuth", "/guides/oauth"], + ["Email and password", "/guides/email-and-password"], + ["Passkeys", "/guides/passkeys"], + ["Improving sessions", "/guides/improving-sessions"] + ] + }, + { + title: "API reference", + pages: [["lucia", "/reference/main", "code"]] }, { title: "Community", - pages: communityPages + pages: [ + ["Discord", "https://discord.com/invite/PwrK3kpVR3"], + ["GitHub", "https://github.com/lucia-auth/lucia"], + ["Twitter", "https://twitter.com/lucia-auth"] + ] } ]; --- diff --git a/documentation/src/layouts/ReferenceLayout.astro b/documentation/src/layouts/ReferenceLayout.astro deleted file mode 100644 index 5b9c578a5..000000000 --- a/documentation/src/layouts/ReferenceLayout.astro +++ /dev/null @@ -1,63 +0,0 @@ ---- -import BaseLayout from "./BaseLayout.astro"; -import MarkdownArticle from "src/components/MarkdownArticle.astro"; - -import type { Section, Page } from "@components/NavMenu.astro"; -import type { MarkdownLayoutProps } from "astro"; - -type Props = MarkdownLayoutProps<{ - type: string; - title?: string -}>; - -const functionPages: Page[] = [["generateId()", "/reference/generateId"]]; - -const classPages: Page[] = [ - ["LegacyScrypt", "/reference/LegacyScrypt"], - ["Lucia", "/reference/Lucia"], - ["SessionCookie", "/reference/SessionCookie"], - ["Scrypt", "/reference/Scrypt"], - ["TimeSpan", "/reference/TimeSpan"] -]; - -const interfacePages: Page[] = [ - ["Adapter", "/reference/Adapter"], - ["DatabaseSession", "/reference/DatabaseSession"], - ["DatabaseSessionAttributes", "/reference/DatabaseSessionAttributes"], - ["DatabaseUser", "/reference/DatabaseUser"], - ["DatabaseUserAttributes", "/reference/DatabaseUserAttributes"], - ["Session", "/reference/Session"], - ["User", "/reference/User"] -]; - -const sections: Section[] = [ - { - title: "Functions", - pages: functionPages - }, - { - title: "Classes", - pages: classPages - }, - { - title: "Interfaces", - pages: interfacePages - } -]; - -const type = Astro.props.frontmatter.type; -let displayName = Astro.url.pathname - .split("/") - .filter((val) => val !== "") - .at(-1)!; -if (type === "function" || type === "method") { - displayName = displayName + "()"; -} ---- - - -

    {Astro.props.frontmatter.title ?? displayName}

    - - - -
    diff --git a/documentation/src/pages/getting-started/elysia.md b/documentation/src/pages/getting-started/elysia.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/documentation/src/pages/getting-started/express.md b/documentation/src/pages/getting-started/express.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/documentation/src/pages/getting-started/hono.md b/documentation/src/pages/getting-started/hono.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/documentation/src/pages/reference/Lucia/createBlankSessionCookie.md b/documentation/src/pages/reference/Lucia/createBlankSessionCookie.md deleted file mode 100644 index c037fabc6..000000000 --- a/documentation/src/pages/reference/Lucia/createBlankSessionCookie.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -layout: "@layouts/ReferenceLayout.astro" -type: "method" ---- - -Creates a new cookie with a blank value that expires immediately to delete the existing session cookie. - -## Definition - -```ts -//$ SessionCookie=/reference/SessionCookie -function createBlankSessionCookie(): $$SessionCookie; -``` diff --git a/documentation/src/pages/reference/Lucia/createSession.md b/documentation/src/pages/reference/Lucia/createSession.md deleted file mode 100644 index bf0113fb5..000000000 --- a/documentation/src/pages/reference/Lucia/createSession.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -layout: "@layouts/ReferenceLayout.astro" -type: "method" ---- - -Creates a new session. - -## Definition - -```ts -//$ DatabaseSessionAttributes=/reference/DatabaseSessionAttributes -//$ Session=/reference/Session -function createSession(userId: string, attributes: $$DatabaseSessionAttributes): Promise<$$Session>; -``` - -### Parameters - -- `userId` -- `attributes`: Database session attributes diff --git a/documentation/src/pages/reference/Lucia/createSessionCookie.md b/documentation/src/pages/reference/Lucia/createSessionCookie.md deleted file mode 100644 index 07d7ad41d..000000000 --- a/documentation/src/pages/reference/Lucia/createSessionCookie.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -layout: "@layouts/ReferenceLayout.astro" -type: "method" ---- - -Creates a new session cookie. - -## Definition - -```ts -//$ SessionCookie=/reference/SessionCookie -function createSessionCookie(sessionId: string): $$SessionCookie; -``` diff --git a/documentation/src/pages/reference/Lucia/getUserSessions.md b/documentation/src/pages/reference/Lucia/getUserSessions.md deleted file mode 100644 index 10d6e9a44..000000000 --- a/documentation/src/pages/reference/Lucia/getUserSessions.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -layout: "@layouts/ReferenceLayout.astro" -type: "method" ---- - -Gets all sessions of a user. - -## Definition - -```ts -//$ Session=/reference/Session -function getUserSessions(userId: string): Promise; -``` - -### Parameters - -- `userId` diff --git a/documentation/src/pages/reference/Lucia/index.md b/documentation/src/pages/reference/Lucia/index.md deleted file mode 100644 index 9baf165ad..000000000 --- a/documentation/src/pages/reference/Lucia/index.md +++ /dev/null @@ -1,68 +0,0 @@ ---- -layout: "@layouts/ReferenceLayout.astro" -type: "class" ---- - -The core API. - -## Constructor - -```ts -//$ Adapter=/reference/Adapter -//$ TimeSpan=/reference/TimeSpan -//$ DatabaseSessionAttributes=/reference/DatabaseSessionAttributes -//$ DatabaseUserAttributes=/reference/DatabaseUserAttributes -function constructor< - _SessionAttributes extends {} = Record, - _UserAttributes extends {} = Record ->( - adapter: $$Adapter, - options?: { - sessionExpiresIn?: $$TimeSpan; - sessionCookie?: { - name?: string; - expires?: boolean; - attributes: { - sameSite?: "lax" | "strict"; - domain?: string; - path?: string; - secure?: boolean; - }; - }; - getSessionAttributes?: ( - databaseSessionAttributes: $$DatabaseSessionAttributes - ) => _SessionAttributes; - getUserAttributes?: (databaseUserAttributes: $$DatabaseUserAttributes) => _UserAttributes; - } -): this; -``` - -### Parameters - -- `adapter`: Database adapter -- `options`: - - `sessionExpiresIn`: How long a session lasts for maximum for inactive users - - `sessionCookie`: Session cookie options - - `name`: Cookie name (default: `auth_session`) - - `expires`: Set to `false` for cookies to persist indefinitely (default: `true`) - - `attributes`: Cookie attributes - - `sameSite` - - `domain` - - `path` - - `secure` - - `getSessionAttributes()`: Transforms database session attributes and the returned object is added to the [`Session`](/reference/Session) object - - `getUserAttributes()`: Transforms database user attributes and the returned object is added to the [`User`](/reference/User) object - -## Method - -- [`createBlankSessionCookie()`](/reference/Lucia/createBlankSessionCookie) -- [`createSession()`](/reference/Lucia/createSession) -- [`createSessionCookie()`](/reference/Lucia/createSessionCookie) -- [`getUserSessions()`](/reference/Lucia/getUserSessions) -- [`handleRequest()`](/reference/Lucia/handleRequest) -- [`createSessionCookie()`](/reference/Lucia/createSessionCookie) -- [`invalidateSession()`](/reference/Lucia/invalidateSession) -- [`invalidateUserSessions()`](/reference/Lucia/invalidateUserSessions) -- [`readBearerToken()`](/reference/Lucia/readBearerToken) -- [`readSessionCookie()`](/reference/Lucia/readSessionCookie) -- [`validateSession()`](/reference/Lucia/validateSession) diff --git a/documentation/src/pages/reference/Lucia/invalidateSession.md b/documentation/src/pages/reference/Lucia/invalidateSession.md deleted file mode 100644 index 2c65840b2..000000000 --- a/documentation/src/pages/reference/Lucia/invalidateSession.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -layout: "@layouts/ReferenceLayout.astro" -type: "method" ---- - -Invalidates a session. - -## Definition - -```ts -function invalidateSession(sessionId: string): Promise -``` - -### Parameters - -- `sessionId` diff --git a/documentation/src/pages/reference/Lucia/invalidateUserSessions.md b/documentation/src/pages/reference/Lucia/invalidateUserSessions.md deleted file mode 100644 index 9343a2b88..000000000 --- a/documentation/src/pages/reference/Lucia/invalidateUserSessions.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -layout: "@layouts/ReferenceLayout.astro" -type: "method" ---- - -Invalidates all sessions of a user. - -## Definition - -```ts -function invalidateUserSessions(userId: string): Promise -``` - -### Parameters - -- `userId` diff --git a/documentation/src/pages/reference/Lucia/readBearerToken.md b/documentation/src/pages/reference/Lucia/readBearerToken.md deleted file mode 100644 index 72d523787..000000000 --- a/documentation/src/pages/reference/Lucia/readBearerToken.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -layout: "@layouts/ReferenceLayout.astro" -type: "method" ---- - -Reads the bearer token from the `Authorization`` header. Returns `null` if the token doesn't exist. - -## Definition - -```ts -function readBearerToken(authorizationHeader: string): string | null -``` - -### Parameters - -- `authorizationHeader`: HTTP `Authorization` header diff --git a/documentation/src/pages/reference/Lucia/readSessionCookie.md b/documentation/src/pages/reference/Lucia/readSessionCookie.md deleted file mode 100644 index dd54cf679..000000000 --- a/documentation/src/pages/reference/Lucia/readSessionCookie.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -layout: "@layouts/ReferenceLayout.astro" -type: "method" ---- - -Reads the session cookie from the `Cookie` header. Returns `null` if the cookie doesn't exist. - -## Definition - -```ts -function readSessionCookie(cookieHeader: string): string | null -``` - -### Parameters - -- `cookieHeader`: HTTP `Cookie` header diff --git a/documentation/src/pages/reference/Lucia/validateSession.md b/documentation/src/pages/reference/Lucia/validateSession.md deleted file mode 100644 index a31965ba9..000000000 --- a/documentation/src/pages/reference/Lucia/validateSession.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -layout: "@layouts/ReferenceLayout.astro" -type: "method" ---- - -Validates a session with the session ID. Extends the session expiration if in idle state. - -## Definition - -```ts -//$ User=/reference/User -//$ Session=/reference/Session -function validateSession( - sessionId: string -): Promise<{ user: $$User; session: $$Session } | { user: null; session: null }>; -``` - -### Parameters - -- `sessionId` diff --git a/documentation/src/pages/reference/SessionCookie.md b/documentation/src/pages/reference/SessionCookie.md deleted file mode 100644 index 53e144df0..000000000 --- a/documentation/src/pages/reference/SessionCookie.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -layout: "@layouts/ReferenceLayout.astro" -type: "class" ---- - -See [`SessionCookie`](https://oslo.js.org/reference/session/SessionCookie/) from `oslo/session`. \ No newline at end of file diff --git a/documentation/src/pages/reference/TimeSpan.md b/documentation/src/pages/reference/TimeSpan.md deleted file mode 100644 index 0415c4db3..000000000 --- a/documentation/src/pages/reference/TimeSpan.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -layout: "@layouts/ReferenceLayout.astro" -type: "class" ---- - -See [`TimeSpan`](https://oslo.js.org/reference/main/TimeSpan/) from `oslo`. \ No newline at end of file diff --git a/documentation/src/pages/reference/User.md b/documentation/src/pages/reference/User.md deleted file mode 100644 index 324025c89..000000000 --- a/documentation/src/pages/reference/User.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -layout: "@layouts/ReferenceLayout.astro" -type: "interface" ---- - -Represents a user. - -## Definition - -```ts -//$ UserAttributes=/reference/UserAttributes -interface Session extends UserAttributes { - id: string; -} -``` - -### Properties - -- `id` diff --git a/documentation/src/pages/reference/index.md b/documentation/src/pages/reference/index.md deleted file mode 100644 index 78330fb4c..000000000 --- a/documentation/src/pages/reference/index.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -layout: "@layouts/ReferenceLayout.astro" -title: "API reference" ---- - -## Functions - -- [`generateId()`](/reference/generateId") - -## Classes - -- [`LegacyScrypt`](/reference/LegacyScrypt) -- [`Lucia`](/reference/Lucia) -- [`SessionCookie`](/reference/SessionCookie) -- [`Scrypt`](/reference/Scrypt) -- [`TimeSpan`](/reference/TimeSpan) - -## Interfaces - -- [`Adapter`](/reference/Adapter) -- [`DatabaseSession`](/reference/DatabaseSession) -- [`DatabaseSessionAttributes`](/reference/DatabaseSessionAttributes) -- [`DatabaseUser`](/reference/DatabaseUser) -- [`DatabaseUserAttributes`](/reference/DatabaseUserAttributes) -- [`Session`](/reference/Session) -- [`User`](/reference/User) diff --git a/documentation/src/pages/reference/Adapter.md b/documentation/src/pages/reference/main/Adapter.md similarity index 84% rename from documentation/src/pages/reference/Adapter.md rename to documentation/src/pages/reference/main/Adapter.md index 58a29b8de..106b9cba0 100644 --- a/documentation/src/pages/reference/Adapter.md +++ b/documentation/src/pages/reference/main/Adapter.md @@ -1,6 +1,7 @@ --- -layout: "@layouts/ReferenceLayout.astro" -type: "interface" +layout: "@layouts/DocLayout.astro" +title: "Adapter" +format: "code" --- Represents a database adapter. @@ -8,8 +9,8 @@ Represents a database adapter. ## Definition ```ts -//$ DatabaseSession=/reference/DatabaseSession -//$ DatabaseUser=/reference/DatabaseUser +//$ DatabaseSession=/reference/main/DatabaseSession +//$ DatabaseUser=/reference/main/DatabaseUser interface Adapter { deleteSession(sessionId: string): Promise; deleteUserSessions(userId: string): Promise; diff --git a/documentation/src/pages/reference/DatabaseSession.md b/documentation/src/pages/reference/main/DatabaseSession.md similarity index 64% rename from documentation/src/pages/reference/DatabaseSession.md rename to documentation/src/pages/reference/main/DatabaseSession.md index 3f6d0f2d3..4d6ca1978 100644 --- a/documentation/src/pages/reference/DatabaseSession.md +++ b/documentation/src/pages/reference/main/DatabaseSession.md @@ -1,6 +1,7 @@ --- -layout: "@layouts/ReferenceLayout.astro" -type: "interface" +layout: "@layouts/DocLayout.astro" +title: "DatabaseSession" +format: "code" --- Represents a session stored in a database. @@ -8,7 +9,7 @@ Represents a session stored in a database. ## Definition ```ts -//$ DatabaseSessionAttributes=/reference/DatabaseSessionAttributes +//$ DatabaseSessionAttributes=/reference/main/DatabaseSessionAttributes interface DatabaseSession { id: string; userId: string; diff --git a/documentation/src/pages/reference/DatabaseSessionAttributes.md b/documentation/src/pages/reference/main/DatabaseSessionAttributes.md similarity index 58% rename from documentation/src/pages/reference/DatabaseSessionAttributes.md rename to documentation/src/pages/reference/main/DatabaseSessionAttributes.md index c88ed1b15..1b60305ac 100644 --- a/documentation/src/pages/reference/DatabaseSessionAttributes.md +++ b/documentation/src/pages/reference/main/DatabaseSessionAttributes.md @@ -1,6 +1,7 @@ --- -layout: "@layouts/ReferenceLayout.astro" -type: "interface" +layout: "@layouts/DocLayout.astro" +title: "DatabaseSessionAttributes" +format: "code" --- Additional data stored in the session table. diff --git a/documentation/src/pages/reference/DatabaseUser.md b/documentation/src/pages/reference/main/DatabaseUser.md similarity index 61% rename from documentation/src/pages/reference/DatabaseUser.md rename to documentation/src/pages/reference/main/DatabaseUser.md index 27bddec0d..178ccbb37 100644 --- a/documentation/src/pages/reference/DatabaseUser.md +++ b/documentation/src/pages/reference/main/DatabaseUser.md @@ -1,6 +1,7 @@ --- -layout: "@layouts/ReferenceLayout.astro" -type: "interface" +layout: "@layouts/DocLayout.astro" +title: "DatabaseUser" +format: "code" --- Represents a session stored in a database. @@ -8,7 +9,7 @@ Represents a session stored in a database. ## Definition ```ts -//$ DatabaseUserAttributes=/reference/DatabaseUserAttributes +//$ DatabaseUserAttributes=/reference/main/DatabaseUserAttributes interface DatabaseUser { id: string; attributes: DatabaseUserAttributes; diff --git a/documentation/src/pages/reference/DatabaseUserAttributes.md b/documentation/src/pages/reference/main/DatabaseUserAttributes.md similarity index 57% rename from documentation/src/pages/reference/DatabaseUserAttributes.md rename to documentation/src/pages/reference/main/DatabaseUserAttributes.md index e41972e64..222b20957 100644 --- a/documentation/src/pages/reference/DatabaseUserAttributes.md +++ b/documentation/src/pages/reference/main/DatabaseUserAttributes.md @@ -1,6 +1,7 @@ --- -layout: "@layouts/ReferenceLayout.astro" -type: "interface" +layout: "@layouts/DocLayout.astro" +title: "DatabaseUserAttributes" +format: "code" --- Additional data stored in the user table. diff --git a/documentation/src/pages/reference/Scrypt/hash.md b/documentation/src/pages/reference/main/LegacyScrypt/hash.md similarity index 50% rename from documentation/src/pages/reference/Scrypt/hash.md rename to documentation/src/pages/reference/main/LegacyScrypt/hash.md index 861dd3aff..1a72f219c 100644 --- a/documentation/src/pages/reference/Scrypt/hash.md +++ b/documentation/src/pages/reference/main/LegacyScrypt/hash.md @@ -1,9 +1,10 @@ --- -layout: "@layouts/ReferenceLayout.astro" -type: "method" +layout: "@layouts/DocLayout.astro" +title: "LegacyScrypt.hash()" +format: "code" --- -Hashes the provided password with scrypt. +Method of [`LegacyScrypt`](/reference/main/LegacyScrypt). Hashes the provided password with scrypt. ## Definition diff --git a/documentation/src/pages/reference/LegacyScrypt/index.md b/documentation/src/pages/reference/main/LegacyScrypt/index.md similarity index 80% rename from documentation/src/pages/reference/LegacyScrypt/index.md rename to documentation/src/pages/reference/main/LegacyScrypt/index.md index 4ba284665..860b9968e 100644 --- a/documentation/src/pages/reference/LegacyScrypt/index.md +++ b/documentation/src/pages/reference/main/LegacyScrypt/index.md @@ -1,6 +1,7 @@ --- -layout: "@layouts/ReferenceLayout.astro" -type: "class" +layout: "@layouts/DocLayout.astro" +title: "LegacyScrypt" +format: "code" --- A pure JS implementation of Scrypt for projects that used Lucia v1/v2. For new projects, use [`Scrypt`](). @@ -23,8 +24,8 @@ function constructor(options?: { N?: number; r?: number; p?: number; dkLen?: num ## Methods -- [`hash()`](ref:password/Argon2id) -- [`verify()`](ref:password/Argon2id) +- [`hash()`](/reference/main/LegacyScrypt/hash) +- [`verify()`](/reference/main/LegacyScrypt/verify) ## Example diff --git a/documentation/src/pages/reference/LegacyScrypt/verify.md b/documentation/src/pages/reference/main/LegacyScrypt/verify.md similarity index 54% rename from documentation/src/pages/reference/LegacyScrypt/verify.md rename to documentation/src/pages/reference/main/LegacyScrypt/verify.md index d905b7821..7f142b099 100644 --- a/documentation/src/pages/reference/LegacyScrypt/verify.md +++ b/documentation/src/pages/reference/main/LegacyScrypt/verify.md @@ -1,9 +1,10 @@ --- -layout: "@layouts/ReferenceLayout.astro" -type: "method" +layout: "@layouts/DocLayout.astro" +title: "LegacyScrypt.verify()" +format: "code" --- -Verifies the password with the hash using scrypt. +Method of [`LegacyScrypt`](/reference/main/LegacyScrypt). Verifies the password with the hash using scrypt. ## Definition diff --git a/documentation/src/pages/reference/main/Lucia/createBlankSessionCookie.md b/documentation/src/pages/reference/main/Lucia/createBlankSessionCookie.md new file mode 100644 index 000000000..895bbece2 --- /dev/null +++ b/documentation/src/pages/reference/main/Lucia/createBlankSessionCookie.md @@ -0,0 +1,14 @@ +--- +layout: "@layouts/DocLayout.astro" +title: "Lucia.createBlankSessionCookie()" +format: "code" +--- + +Method of [`Lucia`](/reference/main/Lucia). Creates a new cookie with a blank value that expires immediately to delete the existing session cookie. + +## Definition + +```ts +//$ SessionCookie=/reference/main/SessionCookie +function createBlankSessionCookie(): $$SessionCookie; +``` \ No newline at end of file diff --git a/documentation/src/pages/reference/main/Lucia/createSession.md b/documentation/src/pages/reference/main/Lucia/createSession.md new file mode 100644 index 000000000..37f398ad3 --- /dev/null +++ b/documentation/src/pages/reference/main/Lucia/createSession.md @@ -0,0 +1,20 @@ +--- +layout: "@layouts/DocLayout.astro" +title: "Lucia.createSession()" +format: "code" +--- + +Method of [`Lucia`](/reference/main/Lucia). Creates a new session. + +## Definition + +```ts +//$ DatabaseSessionAttributes=/reference/main/DatabaseSessionAttributes +//$ Session=/reference/main/Session +function createSession(userId: string, attributes: $$DatabaseSessionAttributes): Promise<$$Session>; +``` + +### Parameters + +- `userId` +- `attributes`: Database session attributes diff --git a/documentation/src/pages/reference/main/Lucia/createSessionCookie.md b/documentation/src/pages/reference/main/Lucia/createSessionCookie.md new file mode 100644 index 000000000..97164193e --- /dev/null +++ b/documentation/src/pages/reference/main/Lucia/createSessionCookie.md @@ -0,0 +1,14 @@ +--- +layout: "@layouts/DocLayout.astro" +title: "Lucia.createSessionCookie()" +format: "code" +--- + +Method of [`Lucia`](/reference/main/Lucia). Creates a new session cookie. + +## Definition + +```ts +//$ SessionCookie=/reference/main/SessionCookie +function createSessionCookie(sessionId: string): $$SessionCookie; +``` diff --git a/documentation/src/pages/reference/main/Lucia/getUserSessions.md b/documentation/src/pages/reference/main/Lucia/getUserSessions.md new file mode 100644 index 000000000..27d2c4fa0 --- /dev/null +++ b/documentation/src/pages/reference/main/Lucia/getUserSessions.md @@ -0,0 +1,18 @@ +--- +layout: "@layouts/DocLayout.astro" +title: "Lucia.getUserSessions()" +format: "code" +--- + +Method of [`Lucia`](/reference/main/Lucia). Gets all sessions of a user. + +## Definition + +```ts +//$ Session=/reference/main/Session +function getUserSessions(userId: string): Promise; +``` + +### Parameters + +- `userId` diff --git a/documentation/src/pages/reference/main/Lucia/index.md b/documentation/src/pages/reference/main/Lucia/index.md new file mode 100644 index 000000000..593993c60 --- /dev/null +++ b/documentation/src/pages/reference/main/Lucia/index.md @@ -0,0 +1,69 @@ +--- +layout: "@layouts/DocLayout.astro" +title: "Lucia" +format: "code" +--- + +The core API. + +## Constructor + +```ts +//$ Adapter=/reference/main/Adapter +//$ TimeSpan=/reference/main/TimeSpan +//$ DatabaseSessionAttributes=/reference/main/DatabaseSessionAttributes +//$ DatabaseUserAttributes=/reference/main/DatabaseUserAttributes +function constructor< + _SessionAttributes extends {} = Record, + _UserAttributes extends {} = Record +>( + adapter: $$Adapter, + options?: { + sessionExpiresIn?: $$TimeSpan; + sessionCookie?: { + name?: string; + expires?: boolean; + attributes: { + sameSite?: "lax" | "strict"; + domain?: string; + path?: string; + secure?: boolean; + }; + }; + getSessionAttributes?: ( + databaseSessionAttributes: $$DatabaseSessionAttributes + ) => _SessionAttributes; + getUserAttributes?: (databaseUserAttributes: $$DatabaseUserAttributes) => _UserAttributes; + } +): this; +``` + +### Parameters + +- `adapter`: Database adapter +- `options`: + - `sessionExpiresIn`: How long a session lasts for maximum for inactive users + - `sessionCookie`: Session cookie options + - `name`: Cookie name (default: `auth_session`) + - `expires`: Set to `false` for cookies to persist indefinitely (default: `true`) + - `attributes`: Cookie attributes + - `sameSite` + - `domain` + - `path` + - `secure` + - `getSessionAttributes()`: Transforms database session attributes and the returned object is added to the [`Session`](/reference/main/Session) object + - `getUserAttributes()`: Transforms database user attributes and the returned object is added to the [`User`](/reference/main/User) object + +## Method + +- [`createBlankSessionCookie()`](/reference/main/Lucia/createBlankSessionCookie) +- [`createSession()`](/reference/main/Lucia/createSession) +- [`createSessionCookie()`](/reference/main/Lucia/createSessionCookie) +- [`getUserSessions()`](/reference/main/Lucia/getUserSessions) +- [`handleRequest()`](/reference/main/Lucia/handleRequest) +- [`createSessionCookie()`](/reference/main/Lucia/createSessionCookie) +- [`invalidateSession()`](/reference/main/Lucia/invalidateSession) +- [`invalidateUserSessions()`](/reference/main/Lucia/invalidateUserSessions) +- [`readBearerToken()`](/reference/main/Lucia/readBearerToken) +- [`readSessionCookie()`](/reference/main/Lucia/readSessionCookie) +- [`validateSession()`](/reference/main/Lucia/validateSession) diff --git a/documentation/src/pages/reference/main/Lucia/invalidateSession.md b/documentation/src/pages/reference/main/Lucia/invalidateSession.md new file mode 100644 index 000000000..ab874a401 --- /dev/null +++ b/documentation/src/pages/reference/main/Lucia/invalidateSession.md @@ -0,0 +1,17 @@ +--- +layout: "@layouts/DocLayout.astro" +title: "Lucia.invalidateSession()" +format: "code" +--- + +Method of [`Lucia`](/reference/main/Lucia). Invalidates a session. + +## Definition + +```ts +function invalidateSession(sessionId: string): Promise +``` + +### Parameters + +- `sessionId` diff --git a/documentation/src/pages/reference/main/Lucia/invalidateUserSessions.md b/documentation/src/pages/reference/main/Lucia/invalidateUserSessions.md new file mode 100644 index 000000000..e11d92974 --- /dev/null +++ b/documentation/src/pages/reference/main/Lucia/invalidateUserSessions.md @@ -0,0 +1,17 @@ +--- +layout: "@layouts/DocLayout.astro" +title: "Lucia.invalidateUserSessions()" +format: "code" +--- + +Method of [`Lucia`](/reference/main/Lucia). Invalidates all sessions of a user. + +## Definition + +```ts +function invalidateUserSessions(userId: string): Promise +``` + +### Parameters + +- `userId` diff --git a/documentation/src/pages/reference/main/Lucia/readBearerToken.md b/documentation/src/pages/reference/main/Lucia/readBearerToken.md new file mode 100644 index 000000000..c0effaaaf --- /dev/null +++ b/documentation/src/pages/reference/main/Lucia/readBearerToken.md @@ -0,0 +1,17 @@ +--- +layout: "@layouts/DocLayout.astro" +title: "Lucia.readBearerToken()" +format: "code" +--- + +Method of [`Lucia`](/reference/main/Lucia). Reads the bearer token from the `Authorization`` header. Returns `null` if the token doesn't exist. + +## Definition + +```ts +function readBearerToken(authorizationHeader: string): string | null +``` + +### Parameters + +- `authorizationHeader`: HTTP `Authorization` header diff --git a/documentation/src/pages/reference/main/Lucia/readSessionCookie.md b/documentation/src/pages/reference/main/Lucia/readSessionCookie.md new file mode 100644 index 000000000..ebe45532f --- /dev/null +++ b/documentation/src/pages/reference/main/Lucia/readSessionCookie.md @@ -0,0 +1,17 @@ +--- +layout: "@layouts/DocLayout.astro" +title: "Lucia.readSessionCookie()" +format: "code" +--- + +Method of [`Lucia`](/reference/main/Lucia). Reads the session cookie from the `Cookie` header. Returns `null` if the cookie doesn't exist. + +## Definition + +```ts +function readSessionCookie(cookieHeader: string): string | null +``` + +### Parameters + +- `cookieHeader`: HTTP `Cookie` header diff --git a/documentation/src/pages/reference/main/Lucia/validateSession.md b/documentation/src/pages/reference/main/Lucia/validateSession.md new file mode 100644 index 000000000..8af11f620 --- /dev/null +++ b/documentation/src/pages/reference/main/Lucia/validateSession.md @@ -0,0 +1,21 @@ +--- +layout: "@layouts/DocLayout.astro" +title: "Lucia.validateSession()" +format: "code" +--- + +Method of [`Lucia`](/reference/main/Lucia). Validates a session with the session ID. Extends the session expiration if in idle state. + +## Definition + +```ts +//$ User=/reference/main/User +//$ Session=/reference/main/Session +function validateSession( + sessionId: string +): Promise<{ user: $$User; session: $$Session } | { user: null; session: null }>; +``` + +### Parameters + +- `sessionId` diff --git a/documentation/src/pages/reference/LegacyScrypt/hash.md b/documentation/src/pages/reference/main/Scrypt/hash.md similarity index 52% rename from documentation/src/pages/reference/LegacyScrypt/hash.md rename to documentation/src/pages/reference/main/Scrypt/hash.md index 861dd3aff..e19d0b10a 100644 --- a/documentation/src/pages/reference/LegacyScrypt/hash.md +++ b/documentation/src/pages/reference/main/Scrypt/hash.md @@ -1,9 +1,10 @@ --- -layout: "@layouts/ReferenceLayout.astro" -type: "method" +layout: "@layouts/DocLayout.astro" +title: "Scrypt.hash()" +format: "code" --- -Hashes the provided password with scrypt. +Method of [`Scrypt`](/reference/main/Scrypt). Hashes the provided password with scrypt. ## Definition diff --git a/documentation/src/pages/reference/Scrypt/index.md b/documentation/src/pages/reference/main/Scrypt/index.md similarity index 94% rename from documentation/src/pages/reference/Scrypt/index.md rename to documentation/src/pages/reference/main/Scrypt/index.md index 24cff5781..21358fdac 100644 --- a/documentation/src/pages/reference/Scrypt/index.md +++ b/documentation/src/pages/reference/main/Scrypt/index.md @@ -1,6 +1,7 @@ --- -layout: "@layouts/ReferenceLayout.astro" -type: "class" +layout: "@layouts/DocLayout.astro" +title: "Scrypt" +format: "code" --- 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). diff --git a/documentation/src/pages/reference/Scrypt/verify.md b/documentation/src/pages/reference/main/Scrypt/verify.md similarity index 56% rename from documentation/src/pages/reference/Scrypt/verify.md rename to documentation/src/pages/reference/main/Scrypt/verify.md index d905b7821..47cb6b6a1 100644 --- a/documentation/src/pages/reference/Scrypt/verify.md +++ b/documentation/src/pages/reference/main/Scrypt/verify.md @@ -1,9 +1,10 @@ --- -layout: "@layouts/ReferenceLayout.astro" -type: "method" +layout: "@layouts/DocLayout.astro" +title: "Scrypt.verify()" +format: "code" --- -Verifies the password with the hash using scrypt. +Method of [`Scrypt`](/reference/main/Scrypt). Verifies the password with the hash using scrypt. ## Definition diff --git a/documentation/src/pages/reference/Session.md b/documentation/src/pages/reference/main/Session.md similarity index 70% rename from documentation/src/pages/reference/Session.md rename to documentation/src/pages/reference/main/Session.md index b24a64e58..abc4065e5 100644 --- a/documentation/src/pages/reference/Session.md +++ b/documentation/src/pages/reference/main/Session.md @@ -1,6 +1,7 @@ --- -layout: "@layouts/ReferenceLayout.astro" -type: "interface" +layout: "@layouts/DocLayout.astro" +title: "Session" +format: "code" --- Represents a session. @@ -8,7 +9,7 @@ Represents a session. ## Definition ```ts -//$ SessionAttributes=/reference/SessionAttributes +//$ SessionAttributes=/reference/main/SessionAttributes interface Session extends SessionAttributes { id: string; expiresAt: Date; diff --git a/documentation/src/pages/reference/main/SessionCookie.md b/documentation/src/pages/reference/main/SessionCookie.md new file mode 100644 index 000000000..2d213d9bb --- /dev/null +++ b/documentation/src/pages/reference/main/SessionCookie.md @@ -0,0 +1,7 @@ +--- +layout: "@layouts/DocLayout.astro" +title: "SessionCookie" +format: "code" +--- + +See [`SessionCookie`](https://oslo.js.org/reference/main/session/SessionCookie/) from `oslo/session`. \ No newline at end of file diff --git a/documentation/src/pages/reference/main/TimeSpan.md b/documentation/src/pages/reference/main/TimeSpan.md new file mode 100644 index 000000000..672154553 --- /dev/null +++ b/documentation/src/pages/reference/main/TimeSpan.md @@ -0,0 +1,7 @@ +--- +layout: "@layouts/DocLayout.astro" +title: "TimeSpan" +format: "code" +--- + +See [`TimeSpan`](https://oslo.js.org/reference/main/main/TimeSpan/) from `oslo`. \ No newline at end of file diff --git a/documentation/src/pages/reference/main/User.md b/documentation/src/pages/reference/main/User.md new file mode 100644 index 000000000..90de515eb --- /dev/null +++ b/documentation/src/pages/reference/main/User.md @@ -0,0 +1,20 @@ +--- +layout: "@layouts/DocLayout.astro" +title: "User" +format: "code" +--- + +Represents a user. + +## Definition + +```ts +//$ UserAttributes=/reference/main/UserAttributes +interface User extends UserAttributes { + id: string; +} +``` + +### Properties + +- `id` diff --git a/documentation/src/pages/reference/generateId.md b/documentation/src/pages/reference/main/generateId.md similarity index 81% rename from documentation/src/pages/reference/generateId.md rename to documentation/src/pages/reference/main/generateId.md index 8ae756889..09080c3dd 100644 --- a/documentation/src/pages/reference/generateId.md +++ b/documentation/src/pages/reference/main/generateId.md @@ -1,6 +1,7 @@ --- -layout: "@layouts/ReferenceLayout.astro" -type: "function" +layout: "@layouts/DocLayout.astro" +title: "generateId()" +format: "code" --- Generates a cryptographically strong random string made of `a-z` (lowercase) and `0-9`. diff --git a/documentation/src/pages/reference/main/index.md b/documentation/src/pages/reference/main/index.md new file mode 100644 index 000000000..5f2de03f9 --- /dev/null +++ b/documentation/src/pages/reference/main/index.md @@ -0,0 +1,29 @@ +--- +layout: "@layouts/DocLayout.astro" +title: "lucia" +format: "code" +--- + +API reference for `lucia`. + +## Functions + +- [`generateId()`](/reference/main/generateId) + +## Classes + +- [`LegacyScrypt`](/reference/main/LegacyScrypt) +- [`Lucia`](/reference/main/Lucia) +- [`SessionCookie`](/reference/main/SessionCookie) +- [`Scrypt`](/reference/main/Scrypt) +- [`TimeSpan`](/reference/main/TimeSpan) + +## Interfaces + +- [`Adapter`](/reference/main/Adapter) +- [`DatabaseSession`](/reference/main/DatabaseSession) +- [`DatabaseSessionAttributes`](/reference/main/DatabaseSessionAttributes) +- [`DatabaseUser`](/reference/main/DatabaseUser) +- [`DatabaseUserAttributes`](/reference/main/DatabaseUserAttributes) +- [`Session`](/reference/main/Session) +- [`User`](/reference/main/User)