@auth/core
Advanced tools
Comparing version 0.25.0 to 0.25.1
@@ -45,3 +45,4 @@ /** | ||
import { JWTOptions } from "./jwt.js"; | ||
export { skipCSRFCheck, raw, setEnvDefaults, createActionURL }; | ||
import { isAuthAction } from "./lib/utils/actions.js"; | ||
export { skipCSRFCheck, raw, setEnvDefaults, createActionURL, isAuthAction }; | ||
export declare function Auth(request: Request, config: AuthConfig): Promise<ResponseInternal>; | ||
@@ -48,0 +49,0 @@ export declare function Auth(request: Request, config: Omit<AuthConfig, "raw">): Promise<Response>; |
@@ -45,3 +45,4 @@ /** | ||
import { toInternalRequest, toResponse } from "./lib/utils/web.js"; | ||
export { skipCSRFCheck, raw, setEnvDefaults, createActionURL }; | ||
import { isAuthAction } from "./lib/utils/actions.js"; | ||
export { skipCSRFCheck, raw, setEnvDefaults, createActionURL, isAuthAction }; | ||
/** | ||
@@ -48,0 +49,0 @@ * Core functionality provided by Auth.js. |
import { parse as parseCookie, serialize } from "cookie"; | ||
import { UnknownAction } from "../../errors.js"; | ||
import { isAuthAction } from "./actions.js"; | ||
async function getBody(req) { | ||
@@ -15,12 +16,2 @@ if (!("body" in req) || !req.body || req.method !== "POST") | ||
} | ||
const actions = [ | ||
"providers", | ||
"session", | ||
"csrf", | ||
"signin", | ||
"signout", | ||
"callback", | ||
"verify-request", | ||
"error", | ||
]; | ||
export async function toInternalRequest(req, config) { | ||
@@ -96,5 +87,2 @@ try { | ||
} | ||
function isAction(action) { | ||
return actions.includes(action); | ||
} | ||
/** @internal Parse the action and provider id from a URL pathname. */ | ||
@@ -110,3 +98,3 @@ export function parseActionAndProviderId(pathname, base) { | ||
const [action, providerId] = b; | ||
if (!isAction(action)) | ||
if (!isAuthAction(action)) | ||
throw new UnknownAction(`Cannot parse action at ${pathname}`); | ||
@@ -113,0 +101,0 @@ if (providerId && !["signin", "callback"].includes(action)) |
{ | ||
"name": "@auth/core", | ||
"version": "0.25.0", | ||
"version": "0.25.1", | ||
"description": "Authentication for the Web.", | ||
@@ -93,2 +93,3 @@ "keywords": [ | ||
"dev": "pnpm css && pnpm providers && tsc -w", | ||
"test:e2e": "playwright test -c ../utils/playwright.config.ts", | ||
"test": "vitest -c ../utils/vitest.config.ts", | ||
@@ -95,0 +96,0 @@ "providers": "node scripts/generate-providers" |
@@ -30,4 +30,6 @@ import type { CommonProviderOptions } from "./index.js"; | ||
secret?: string; | ||
/** Used with HTTP-based email providers */ | ||
/** Used with HTTP-based email providers. */ | ||
apiKey?: string; | ||
/** Used with SMTP-based email providers. */ | ||
server?: NodemailerConfig["server"]; | ||
generateVerificationToken?: () => Awaitable<string>; | ||
@@ -34,0 +36,0 @@ normalizeIdentifier?: (identifier: string) => string; |
@@ -1,2 +0,2 @@ | ||
import { EmailConfig } from "./email"; | ||
import { EmailConfig } from "./email.js"; | ||
import type { Transport, TransportOptions } from "nodemailer"; | ||
@@ -9,6 +9,6 @@ import * as JSONTransport from "nodemailer/lib/json-transport/index.js"; | ||
import * as StreamTransport from "nodemailer/lib/stream-transport/index.js"; | ||
import type { Awaitable, Theme } from "../types"; | ||
import type { Awaitable, Theme } from "../types.js"; | ||
type AllTransportOptions = string | SMTPTransport | SMTPTransport.Options | SMTPPool | SMTPPool.Options | SendmailTransport | SendmailTransport.Options | StreamTransport | StreamTransport.Options | JSONTransport | JSONTransport.Options | SESTransport | SESTransport.Options | Transport<any> | TransportOptions; | ||
export interface NodemailerConfig extends Omit<EmailConfig, "sendVerificationRequest" | "options"> { | ||
server: AllTransportOptions; | ||
export interface NodemailerConfig extends EmailConfig { | ||
server?: AllTransportOptions; | ||
sendVerificationRequest: (params: { | ||
@@ -15,0 +15,0 @@ identifier: string; |
import { createTransport } from "nodemailer"; | ||
import { html, text } from "./email"; | ||
import { html, text } from "./email.js"; | ||
import { AuthError } from "../errors.js"; | ||
export default function Nodemailer(config) { | ||
if (!config.server) | ||
throw new AuthError("Nodemailer requires a `server` configuration"); | ||
return { | ||
@@ -5,0 +8,0 @@ id: "nodemailer", |
@@ -58,4 +58,5 @@ /** | ||
import { JWTOptions } from "./jwt.js" | ||
import { isAuthAction } from "./lib/utils/actions.js" | ||
export { skipCSRFCheck, raw, setEnvDefaults, createActionURL } | ||
export { skipCSRFCheck, raw, setEnvDefaults, createActionURL, isAuthAction } | ||
@@ -62,0 +63,0 @@ export async function Auth( |
@@ -10,2 +10,3 @@ import { parse as parseCookie, serialize } from "cookie" | ||
} from "../../types.js" | ||
import { isAuthAction } from "./actions.js" | ||
@@ -24,13 +25,2 @@ async function getBody(req: Request): Promise<Record<string, any> | undefined> { | ||
const actions: AuthAction[] = [ | ||
"providers", | ||
"session", | ||
"csrf", | ||
"signin", | ||
"signout", | ||
"callback", | ||
"verify-request", | ||
"error", | ||
] | ||
export async function toInternalRequest( | ||
@@ -124,6 +114,2 @@ req: Request, | ||
function isAction(action: string): action is AuthAction { | ||
return actions.includes(action as AuthAction) | ||
} | ||
/** @internal Parse the action and provider id from a URL pathname. */ | ||
@@ -151,3 +137,3 @@ export function parseActionAndProviderId( | ||
if (!isAction(action)) | ||
if (!isAuthAction(action)) | ||
throw new UnknownAction(`Cannot parse action at ${pathname}`) | ||
@@ -154,0 +140,0 @@ |
@@ -46,4 +46,6 @@ import type { CommonProviderOptions } from "./index.js" | ||
secret?: string | ||
/** Used with HTTP-based email providers */ | ||
/** Used with HTTP-based email providers. */ | ||
apiKey?: string | ||
/** Used with SMTP-based email providers. */ | ||
server?: NodemailerConfig["server"] | ||
generateVerificationToken?: () => Awaitable<string> | ||
@@ -50,0 +52,0 @@ normalizeIdentifier?: (identifier: string) => string |
import { createTransport } from "nodemailer" | ||
import { EmailConfig, html, text } from "./email" | ||
import { EmailConfig, html, text } from "./email.js" | ||
import { AuthError } from "../errors.js" | ||
@@ -11,3 +12,3 @@ import type { Transport, TransportOptions } from "nodemailer" | ||
import * as StreamTransport from "nodemailer/lib/stream-transport/index.js" | ||
import type { Awaitable, Theme } from "../types" | ||
import type { Awaitable, Theme } from "../types.js" | ||
@@ -31,5 +32,4 @@ type AllTransportOptions = | ||
export interface NodemailerConfig | ||
extends Omit<EmailConfig, "sendVerificationRequest" | "options"> { | ||
server: AllTransportOptions | ||
export interface NodemailerConfig extends EmailConfig { | ||
server?: AllTransportOptions | ||
sendVerificationRequest: (params: { | ||
@@ -55,2 +55,5 @@ identifier: string | ||
): NodemailerConfig { | ||
if (!config.server) | ||
throw new AuthError("Nodemailer requires a `server` configuration") | ||
return { | ||
@@ -57,0 +60,0 @@ id: "nodemailer", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1381780
468
35060