Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): improved logging / renames / new exports #6085

Merged
merged 36 commits into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
cc77681
fix(core): fix some provider imports
balazsorban44 Dec 16, 2022
8d95e28
fix: clean up logger/errors
balazsorban44 Dec 16, 2022
28cd5dc
internal refactors
balazsorban44 Dec 16, 2022
7af21d0
rename
balazsorban44 Dec 16, 2022
b3a19e0
revert moduleResolution
balazsorban44 Dec 16, 2022
d8010b4
revert
balazsorban44 Dec 16, 2022
9d5758d
add ctodo comment
balazsorban44 Dec 16, 2022
3f04a35
fix sveltekit
balazsorban44 Dec 16, 2022
66fecd7
revert some name changes to keep the PR minimal
balazsorban44 Dec 16, 2022
c0814d7
more reverts
balazsorban44 Dec 16, 2022
d8b63ef
remove default export
balazsorban44 Dec 16, 2022
fc35018
reverts
balazsorban44 Dec 16, 2022
82698fd
Merge branch 'main' into refactor/cleanup
balazsorban44 Dec 16, 2022
c07156b
add examlpe to main entry
balazsorban44 Dec 16, 2022
200665b
add jsdoc linting
balazsorban44 Dec 16, 2022
d23beb8
add API reference generation
balazsorban44 Dec 16, 2022
6e8f10c
format
balazsorban44 Dec 16, 2022
8706f39
Merge branch 'main' into refactor/cleanup
balazsorban44 Dec 17, 2022
fe44976
Merge branch 'main' into refactor/cleanup
balazsorban44 Dec 17, 2022
2c3bfc8
run prettier check at lint
balazsorban44 Dec 17, 2022
b8993db
Merge branch 'main' into refactor/cleanup
balazsorban44 Dec 18, 2022
eb157c0
Merge branch 'main' into refactor/cleanup
balazsorban44 Dec 19, 2022
08878cc
use `ts` instead of `js` for code block language
balazsorban44 Dec 19, 2022
8132d65
update types import paths
balazsorban44 Dec 19, 2022
8f64dd2
chore: type updates
balazsorban44 Dec 19, 2022
94329cc
Merge branch 'main' into refactor/cleanup
balazsorban44 Dec 19, 2022
50656c4
fix import
balazsorban44 Dec 19, 2022
3fbad39
revert to `signIn` for now
balazsorban44 Dec 19, 2022
a9053e6
Merge branch 'main' into refactor/cleanup
balazsorban44 Dec 22, 2022
b9c5f04
revert sveltekit changes
balazsorban44 Dec 22, 2022
2c1b154
move types
balazsorban44 Dec 22, 2022
af70a6e
fix types entrypoint
balazsorban44 Dec 22, 2022
5452d1c
update submodule docs
balazsorban44 Dec 22, 2022
595e812
improve provider/adapter docs
balazsorban44 Dec 22, 2022
006ae6e
expose errors as module
balazsorban44 Dec 22, 2022
3412adc
remove manual errors from sidebar
balazsorban44 Dec 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
move types
  • Loading branch information
balazsorban44 committed Dec 22, 2022
commit 2c1b154658d445b12de32f4d810306b26af6980f
2 changes: 1 addition & 1 deletion packages/core/src/adapters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
* @module adapters
*/

import type { Account, Awaitable, User } from "./lib/types"
import type { Account, Awaitable, User } from "./types.js"

// TODO: Discuss if we should expose methods to serialize and deserialize
// the data? Many adapters share this logic, so it could be useful to
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ import { logger, setLogger, type LoggerInstance } from "./lib/utils/logger.js"
import { toInternalRequest, toResponse } from "./lib/web.js"

import type { Adapter } from "./adapters.js"
import type { JWTOptions } from "./jwt/types.js"
import type {
CallbacksOptions,
CookiesOptions,
EventCallbacks,
PagesOptions,
SessionOptions,
Theme,
} from "./lib/types.js"
} from "./types.js"
import type { Provider } from "./providers/index.js"
import { JWTOptions } from "./jwt.js"

/**
* Core functionality provided by Auth.js.
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/jwt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import { hkdf } from "@panva/hkdf"
import { EncryptJWT, jwtDecrypt } from "jose"
import { SessionStore } from "./lib/cookie.js"
import { Awaitable } from "./lib/types.js"
import { Awaitable } from "./types.js"
import type { LoggerInstance } from "./lib/utils/logger.js"

const DEFAULT_MAX_AGE = 30 * 24 * 60 * 60 // 30 days
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/assert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
UntrustedHost,
} from "./errors.js"

import type { AuthConfig, RequestInternal } from "./types.js"
import type { AuthConfig, RequestInternal } from "../types.js"
import type { WarningCode } from "./utils/logger.js"

type ConfigError =
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/callback-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { AccountNotLinked } from "./errors.js"
import { fromDate } from "./utils/date.js"

import type { AdapterSession, AdapterUser } from "../adapters.js"
import type { Account, InternalOptions, User } from "./types.js"
import type { Account, InternalOptions, User } from "../types.js"
import type { JWT } from "../jwt.js"
import type { OAuthConfig } from "../providers/index.js"
import type { SessionToken } from "./cookie.js"
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/callback-url.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { InternalOptions } from "../lib/types.js"
import type { InternalOptions } from "../types.js"

interface CreateCallbackUrlParams {
options: InternalOptions
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/cookie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {
CookiesOptions,
LoggerInstance,
SessionStrategy,
} from "../lib/types.js"
} from "../types.js"

// Uncomment to recalculate the estimated size
// of an empty session cookie
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/csrf-token.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createHash, randomString } from "./web.js"

import type { InternalOptions } from "./types.js"
import type { InternalOptions } from "../types.js"
interface CreateCSRFTokenParams {
options: InternalOptions
cookieValue?: string
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/default-callbacks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { CallbacksOptions } from "./types.js"
import type { CallbacksOptions } from "../types.js"

export const defaultCallbacks: CallbacksOptions = {
signIn() {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/email/signin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createHash, randomString } from "../web.js"

import type { InternalOptions } from "../types"
import type { InternalOptions } from "../../types.js"
/**
* Starts an e-mail login flow, by generating a token,
* and sending it to the user's e-mail (with the help of a DB adapter)
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type {
ResponseInternal,
AuthConfig,
ErrorPageParam,
} from "./types.js"
} from "../types.js"

export async function AuthInternal<
Body extends string | Record<string, any> | any[]
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type {
EventCallbacks,
InternalOptions,
RequestInternal,
} from "./types.js"
} from "../types.js"

interface InitParams {
url: URL
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/oauth/authorization-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type {
InternalOptions,
RequestInternal,
ResponseInternal,
} from "../types.js"
} from "../../types.js"
import type { Cookie } from "../cookie.js"

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/oauth/callback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type {
Profile,
RequestInternal,
TokenSet,
} from "../types"
} from "../../types.js"
import type { OAuthConfigInternal } from "../../providers/index.js"
import type { Cookie } from "../cookie.js"

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/oauth/nonce-handler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as o from "oauth4webapi"
import * as jwt from "../../jwt.js"

import type { InternalOptions } from "../types"
import type { InternalOptions } from "../../types.js"
import type { Cookie } from "../cookie.js"

const NONCE_MAX_AGE = 60 * 15 // 15 minutes in seconds
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/oauth/pkce-handler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as o from "oauth4webapi"
import * as jwt from "../../jwt.js"

import type { InternalOptions } from "../types"
import type { InternalOptions } from "../../types.js"
import type { Cookie } from "../cookie.js"

const PKCE_CODE_CHALLENGE_METHOD = "S256"
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/oauth/state-handler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as o from "oauth4webapi"
import type { InternalOptions, RequestInternal } from "../types"
import type { InternalOptions, RequestInternal } from "../../types.js"
import type { Cookie } from "../cookie.js"
import { InvalidState } from "../errors.js"

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/pages/error.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ErrorPageParam, Theme } from "../types.js"
import type { ErrorPageParam, Theme } from "../../types.js"

/**
* The following errors are passed as error query parameters to the default or overridden error page.
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/pages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type {
InternalOptions,
RequestInternal,
ResponseInternal,
} from "../types.js"
} from "../../types.js"
import type { Cookie } from "../cookie.js"

function send({ html, title, status, cookies, theme }: any): ResponseInternal {
Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/lib/pages/signin.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import type { InternalProvider, SignInPageErrorParam, Theme } from "../types"
import type {
InternalProvider,
SignInPageErrorParam,
Theme,
} from "../../types.js"

const signinErrors: Record<
Lowercase<SignInPageErrorParam | "default">,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/pages/signout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Theme } from "../types.js"
import type { Theme } from "../../types.js"

export interface SignoutProps {
url: URL
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/pages/verify-request.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Theme } from "../types.js"
import type { Theme } from "../../types.js"

interface VerifyRequestPageProps {
url: URL
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/providers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { merge } from "./utils/merge.js"

import type { InternalProvider } from "./types"
import type { InternalProvider } from "../types.js"
import type {
OAuthConfig,
OAuthConfigInternal,
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/lib/routes/callback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { createHash } from "../web.js"
import { handleAuthorized } from "./shared.js"

import type { AdapterSession } from "../../adapters.js"
import type { RequestInternal, ResponseInternal, User } from "../types.js"
import type { RequestInternal, ResponseInternal, User } from "../../types.js"
import type { Cookie, SessionStore } from "../cookie.js"
import type { InternalOptions } from "../types.js"
import type { InternalOptions } from "../../types.js"

/** Handle callbacks from login services */
export async function callback(params: {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/routes/providers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { InternalProvider, ResponseInternal } from "../types.js"
import type { InternalProvider, ResponseInternal } from "../../types.js"

export interface PublicProvider {
id: string
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/routes/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { JWTSessionError, SessionTokenError } from "../errors.js"
import { fromDate } from "../utils/date.js"

import type { Adapter } from "../../adapters.js"
import type { InternalOptions, ResponseInternal, Session } from "../types.js"
import type { InternalOptions, ResponseInternal, Session } from "../../types.js"
import type { SessionStore } from "../cookie.js"

/** Return a session object filtered via `callbacks.session` */
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/routes/shared.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AuthorizedCallbackError } from "../errors.js"
import { InternalOptions } from "../types.js"
import { InternalOptions } from "../../types.js"

import type { Adapter, AdapterUser } from "../../adapters.js"

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/routes/signin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {
InternalOptions,
RequestInternal,
ResponseInternal,
} from "../types"
} from "../../types.js"

/**
* Initiates the sign in process for OAuth and Email flows .
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/routes/signout.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SignOutError } from "../errors.js"

import type { InternalOptions, ResponseInternal } from "../types.js"
import type { InternalOptions, ResponseInternal } from "../../types.js"
import type { SessionStore } from "../cookie.js"

/**
Expand Down
Loading