mirror of
https://github.com/SrIzan10/next-auth.git
synced 2026-05-01 10:55:20 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
34f334a71d | ||
|
|
172ad02f8c | ||
|
|
eed0001524 | ||
|
|
a2705fb5b9 | ||
|
|
cb1e5a7174 | ||
|
|
8cba5d06b5 |
6
app/README.md
Normal file
6
app/README.md
Normal file
@@ -0,0 +1,6 @@
|
||||
# NextAuth.js Development App
|
||||
|
||||
This folder contains a Next.js app using NextAuth.js for local development. See the following section on how to start:
|
||||
|
||||
[Setting up local environment
|
||||
](https://github.com/nextauthjs/next-auth/blob/main/CONTRIBUTING.md#setting-up-local-environment)
|
||||
@@ -52,7 +52,9 @@ TYPES_TARGETS.forEach((target) => {
|
||||
|
||||
const providersDir = path.join(process.cwd(), "/src/providers")
|
||||
|
||||
const files = fs.readdirSync(providersDir, "utf8")
|
||||
const files = fs
|
||||
.readdirSync(providersDir, "utf8")
|
||||
.filter((file) => file !== "index.js")
|
||||
|
||||
let importLines = ""
|
||||
let exportLines = `export default {\n`
|
||||
|
||||
@@ -145,7 +145,7 @@ export async function getSession (ctx) {
|
||||
return session
|
||||
}
|
||||
|
||||
async function getCsrfToken (ctx) {
|
||||
export async function getCsrfToken (ctx) {
|
||||
return (await _fetchData('csrf', ctx))?.csrfToken
|
||||
}
|
||||
|
||||
|
||||
3
types/adapters.d.ts
vendored
3
types/adapters.d.ts
vendored
@@ -1,7 +1,7 @@
|
||||
import { AppOptions } from "./internals"
|
||||
import { ConnectionOptions, EntitySchema } from "typeorm"
|
||||
import { User } from "."
|
||||
import { AppProvider } from "./internals/providers"
|
||||
import { AppProvider } from "./providers"
|
||||
|
||||
export interface Profile {
|
||||
id: string
|
||||
@@ -204,6 +204,7 @@ declare class TypeORMUserModel implements User {
|
||||
image?: string,
|
||||
emailVerified?: Date
|
||||
)
|
||||
[x: string]: unknown
|
||||
}
|
||||
|
||||
declare class TypeORMSessionModel implements Session {
|
||||
|
||||
33
types/index.d.ts
vendored
33
types/index.d.ts
vendored
@@ -251,14 +251,16 @@ export interface Account extends TokenSet, Record<string, unknown> {
|
||||
type: string
|
||||
}
|
||||
|
||||
/** The OAuth profile returned from your provider */
|
||||
export interface Profile extends Record<string, unknown> {
|
||||
export interface DefaultProfile {
|
||||
sub?: string
|
||||
name?: string
|
||||
email?: string
|
||||
image?: string
|
||||
}
|
||||
|
||||
/** The OAuth profile returned from your provider */
|
||||
export interface Profile extends Record<string, unknown>, DefaultProfile {}
|
||||
|
||||
/** [Documentation](https://next-auth.js.org/configuration/callbacks) */
|
||||
export interface CallbacksOptions<
|
||||
P extends Record<string, unknown> = Profile,
|
||||
@@ -364,6 +366,15 @@ export interface PagesOptions {
|
||||
newUser?: string
|
||||
}
|
||||
|
||||
export interface DefaultSession extends Record<string, unknown> {
|
||||
user?: {
|
||||
name?: string | null
|
||||
email?: string | null
|
||||
image?: string | null
|
||||
}
|
||||
expires?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Returned by `useSession`, `getSession`, returned by the `session` callback
|
||||
* and also the shape received as a prop on the `Provider` React Context
|
||||
@@ -373,11 +384,7 @@ export interface PagesOptions {
|
||||
* [`Provider`](https://next-auth.js.org/getting-started/client#provider) |
|
||||
* [`session` callback](https://next-auth.js.org/configuration/callbacks#jwt-callback)
|
||||
*/
|
||||
export interface Session extends Record<string, unknown> {
|
||||
user?: User
|
||||
accessToken?: string
|
||||
expires: string
|
||||
}
|
||||
export interface Session extends Record<string, unknown>, DefaultSession {}
|
||||
|
||||
/** [Documentation](https://next-auth.js.org/configuration/options#session) */
|
||||
export interface SessionOptions {
|
||||
@@ -386,6 +393,12 @@ export interface SessionOptions {
|
||||
updateAge?: number
|
||||
}
|
||||
|
||||
export interface DefaultUser {
|
||||
name?: string | null
|
||||
email?: string | null
|
||||
image?: string | null
|
||||
}
|
||||
|
||||
/**
|
||||
* The shape of the returned object in the OAuth providers' `profile` callback,
|
||||
* available in the `jwt` and `session` callbacks,
|
||||
@@ -396,11 +409,7 @@ export interface SessionOptions {
|
||||
* [`jwt` callback](https://next-auth.js.org/configuration/callbacks#jwt-callback) |
|
||||
* [`profile` OAuth provider callback](https://next-auth.js.org/configuration/providers#using-a-custom-provider)
|
||||
*/
|
||||
export interface User {
|
||||
name?: string | null
|
||||
email?: string | null
|
||||
image?: string | null
|
||||
}
|
||||
export interface User extends Record<string, unknown>, DefaultUser {}
|
||||
|
||||
declare function NextAuth(
|
||||
req: NextApiRequest,
|
||||
|
||||
2
types/internals/index.d.ts
vendored
2
types/internals/index.d.ts
vendored
@@ -1,6 +1,6 @@
|
||||
import { NextApiRequest, NextApiResponse } from "./utils"
|
||||
import { NextAuthOptions } from ".."
|
||||
import { AppProvider } from "./providers"
|
||||
import { AppProvider } from "../providers"
|
||||
|
||||
/** Options that are the same both in internal and user provided options. */
|
||||
export type NextAuthSharedOptions =
|
||||
|
||||
6
types/internals/providers.d.ts
vendored
6
types/internals/providers.d.ts
vendored
@@ -1,6 +0,0 @@
|
||||
import { CommonProviderOptions } from "../providers"
|
||||
|
||||
export interface AppProvider extends CommonProviderOptions {
|
||||
signinUrl: string
|
||||
callbackUrl: string
|
||||
}
|
||||
13
types/jwt.d.ts
vendored
13
types/jwt.d.ts
vendored
@@ -1,16 +1,19 @@
|
||||
import { JWT as JoseJWT, JWE } from "jose"
|
||||
import { NextApiRequest } from "./internals/utils"
|
||||
|
||||
export interface DefaultJWT extends Record<string, unknown> {
|
||||
name?: string | null
|
||||
email?: string | null
|
||||
picture?: string | null
|
||||
sub?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Returned by the `jwt` callback and `getToken`, when using JWT sessions
|
||||
*
|
||||
* [`jwt` callback](https://next-auth.js.org/configuration/callbacks#jwt-callback) | [`getToken`](https://next-auth.js.org/tutorials/securing-pages-and-api-routes#using-gettoken)
|
||||
*/
|
||||
export interface JWT extends Record<string, unknown> {
|
||||
name?: string | null
|
||||
email?: string | null
|
||||
picture?: string | null
|
||||
}
|
||||
export interface JWT extends Record<string, unknown>, DefaultJWT {}
|
||||
|
||||
export interface JWTEncodeParams {
|
||||
token?: JWT
|
||||
|
||||
5
types/providers.d.ts
vendored
5
types/providers.d.ts
vendored
@@ -161,6 +161,11 @@ export type AppProviders = Array<
|
||||
Provider | ReturnType<BuiltInProviders[keyof BuiltInProviders]>
|
||||
>
|
||||
|
||||
export interface AppProvider extends CommonProviderOptions {
|
||||
signinUrl: string
|
||||
callbackUrl: string
|
||||
}
|
||||
|
||||
declare const Providers: BuiltInProviders
|
||||
|
||||
export default Providers
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import Providers, { OAuthConfig } from "next-auth/providers"
|
||||
import Providers, { AppProvider, OAuthConfig } from "next-auth/providers"
|
||||
import {
|
||||
Adapter,
|
||||
EmailAppProvider,
|
||||
@@ -12,7 +12,6 @@ import * as JWTType from "next-auth/jwt"
|
||||
import { Socket } from "net"
|
||||
import { NextApiRequest, NextApiResponse } from "internals/utils"
|
||||
import { AppOptions } from "internals"
|
||||
import { AppProvider } from "internals/providers"
|
||||
|
||||
const req: NextApiRequest = Object.assign(new IncomingMessage(new Socket()), {
|
||||
query: {},
|
||||
|
||||
Reference in New Issue
Block a user