@aura-stack/next 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@types/index.d.ts +2 -2
- package/dist/{index-BLRrX4DD.d.ts → index-CC_ocXOS.d.ts} +42 -8
- package/dist/index.d.ts +4 -44
- package/dist/pages/index.cjs +1 -1
- package/dist/pages/index.d.ts +4 -8113
- package/dist/pages/index.js +1 -1
- package/package.json +7 -5
- package/dist/core-BDwHYePg.d.ts +0 -3
- package/dist/index-BbJId8e2.d.ts +0 -11977
package/dist/@types/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as NextSignInCredentials, d as NextSignUpReturn, f as NextUpdateSessionOptions, i as NextPagesInstance, l as NextSignInReturn, n as NextAppInstance, p as NextUpdateSessionReturn, r as NextInstance, s as NextAPI, t as InferSignUp, u as NextSignOutReturn } from "../index-CC_ocXOS.js";
|
|
2
2
|
export * from "@aura-stack/react/types";
|
|
3
|
-
export { NextAPI, NextSignInCredentials, NextSignInReturn, NextSignOutReturn, NextSignUpReturn, NextUpdateSessionOptions, NextUpdateSessionReturn };
|
|
3
|
+
export { InferSignUp, NextAPI, NextAppInstance, NextInstance, NextPagesInstance, NextSignInCredentials, NextSignInReturn, NextSignOutReturn, NextSignUpReturn, NextUpdateSessionOptions, NextUpdateSessionReturn };
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { zod } from "@aura-stack/react/identity/zod";
|
|
2
|
+
import { NextApiRequest, NextApiResponse } from "next";
|
|
3
|
+
import { AuthInstance, BuiltInOAuthProvider, DisconnectProviderAPIOptions, DisconnectProviderAPIReturn, GetSessionAPIOptions, Handlers, InferSchema, LiteralUnion, Prettify, ProviderConnectedAPIOptions, ProviderConnectedAPIReturn, RefreshUserInfoAPIOptions, RefreshUserInfoAPIReturn, RemoveIndexSignature, RevokeTokenAPIOptions, RevokeTokenAPIReturn, SchemaTypes, Session, SignInAPIOptions, SignInAPIReturn, SignInCredentialsAPIOptions, SignInCredentialsAPIReturn, SignOutAPIOptions, SignOutAPIReturn, SignUpAPIOptions, SignUpAPIReturn, UpdateSessionAPIOptions, UpdateSessionAPIReturn, User, Wrap } from "@aura-stack/react/types";
|
|
3
4
|
|
|
5
|
+
//#region \0rolldown/runtime.js
|
|
6
|
+
//#endregion
|
|
4
7
|
//#region src/@types/api.d.ts
|
|
5
8
|
/**
|
|
6
9
|
* Return type for the Next.js server `api.signIn` helper (see `packages/next/src/lib/api.ts`).
|
|
@@ -47,22 +50,53 @@ type NextSignUpReturn<Options extends SignUpAPIOptions> = Options extends {
|
|
|
47
50
|
} ? never : Options extends {
|
|
48
51
|
redirectTo: string;
|
|
49
52
|
} ? never : SignUpAPIReturn;
|
|
50
|
-
interface NextAPI<DefaultUser extends User = User
|
|
51
|
-
getSession: (options?:
|
|
53
|
+
interface NextAPI<DefaultUser extends User = User, SignUpSchema extends SchemaTypes = zod.ZodObject<any>> {
|
|
54
|
+
getSession: (options?: GetSessionAPIOptions) => Promise<Session<DefaultUser> | null>;
|
|
52
55
|
signIn: <Options extends SignInAPIOptions>(provider: LiteralUnion<BuiltInOAuthProvider>, options?: Options) => Promise<NextSignInReturn<Options>>;
|
|
53
56
|
signInCredentials: <Options extends SignInCredentialsAPIOptions>(options: Options) => Promise<NextSignInCredentials<Options>>;
|
|
54
57
|
updateSession: <Options extends NextUpdateSessionOptions<DefaultUser>>(options: Options) => Promise<NextUpdateSessionReturn<Options, DefaultUser>>;
|
|
55
58
|
getProviderTokens: (oauth: LiteralUnion<BuiltInOAuthProvider>, options?: any) => Promise<any>;
|
|
56
59
|
getAccessToken: (oauth: LiteralUnion<BuiltInOAuthProvider>, options?: any) => Promise<any>;
|
|
57
60
|
signOut: <Options extends SignOutAPIOptions>(options?: Partial<Options>) => Promise<NextSignOutReturn<Options>>;
|
|
58
|
-
signUp: <Options extends SignUpAPIOptions
|
|
59
|
-
refreshUserInfo: <Options extends RefreshUserInfoAPIOptions>(oauth: LiteralUnion<BuiltInOAuthProvider>, options?: Options) => Promise<RefreshUserInfoAPIReturn
|
|
61
|
+
signUp: <Options extends SignUpAPIOptions<Wrap<RemoveIndexSignature<InferSchema<SignUpSchema>>>>>(options: Options) => Promise<NextSignUpReturn<Options>>;
|
|
62
|
+
refreshUserInfo: <Options extends RefreshUserInfoAPIOptions>(oauth: LiteralUnion<BuiltInOAuthProvider>, options?: Options) => Promise<RefreshUserInfoAPIReturn<DefaultUser>>;
|
|
60
63
|
revokeToken: <Options extends RevokeTokenAPIOptions>(oauth: LiteralUnion<BuiltInOAuthProvider>, options?: Options) => Promise<RevokeTokenAPIReturn>;
|
|
61
64
|
disconnectProvider: <Options extends DisconnectProviderAPIOptions>(oauth: LiteralUnion<BuiltInOAuthProvider>, options?: Options) => Promise<DisconnectProviderAPIReturn>;
|
|
62
65
|
isProviderConnected: <Options extends ProviderConnectedAPIOptions>(oauth: LiteralUnion<BuiltInOAuthProvider>, options?: Options) => Promise<ProviderConnectedAPIReturn>;
|
|
63
66
|
}
|
|
67
|
+
import * as import__aura_stack_react_types from "@aura-stack/react/types";
|
|
64
68
|
declare namespace index_d_exports {
|
|
65
|
-
export { NextAPI, NextSignInCredentials, NextSignInReturn, NextSignOutReturn, NextSignUpReturn, NextUpdateSessionOptions, NextUpdateSessionReturn };
|
|
69
|
+
export { InferSignUp, NextAPI, NextAppInstance, NextInstance, NextPagesInstance, NextSignInCredentials, NextSignInReturn, NextSignOutReturn, NextSignUpReturn, NextUpdateSessionOptions, NextUpdateSessionReturn };
|
|
66
70
|
}
|
|
71
|
+
type NextPagesInstance<DefaultUser extends User = User, SignUpSchema extends SchemaTypes = zod.ZodObject<any>> = AuthInstance<DefaultUser, SignUpSchema> & {
|
|
72
|
+
toHandler: (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
|
|
73
|
+
};
|
|
74
|
+
type NextAppInstance<DefaultUser extends User = User, SignUpSchema extends SchemaTypes = zod.ZodObject<any>> = {
|
|
75
|
+
core: AuthInstance<DefaultUser, SignUpSchema>;
|
|
76
|
+
api: NextAPI<DefaultUser, SignUpSchema>;
|
|
77
|
+
handlers: Handlers;
|
|
78
|
+
};
|
|
79
|
+
type NextInstance<DefaultUser extends User = User, SignUpSchema extends SchemaTypes = zod.ZodObject<any>> = NextAppInstance<DefaultUser, SignUpSchema> | NextPagesInstance<DefaultUser, SignUpSchema>;
|
|
80
|
+
/**
|
|
81
|
+
* Infers the sign-up data type from an {@link NextInstance} config's `signUp.schema`. It supports
|
|
82
|
+
* Zod, Valibot and ArkType schemas.
|
|
83
|
+
*
|
|
84
|
+
* > For TypeBox its recommended to use the `Static` utility type directly to infer the schema.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* const auth = createAuth({
|
|
88
|
+
* oauth: [],
|
|
89
|
+
* signUp: {
|
|
90
|
+
* schema: z.object({
|
|
91
|
+
* username: z.string(),
|
|
92
|
+
* nickname: z.string(),
|
|
93
|
+
* password: z.string(),
|
|
94
|
+
* })
|
|
95
|
+
* }
|
|
96
|
+
* })
|
|
97
|
+
*
|
|
98
|
+
* type SignUp = InferSignUp<typeof auth>
|
|
99
|
+
*/
|
|
100
|
+
type InferSignUp<T extends NextInstance> = T extends NextAppInstance<any, infer SignUpSchema> ? Prettify<Wrap<RemoveIndexSignature<InferSchema<SignUpSchema>>>> : T extends NextPagesInstance<any, infer SignUpSchema> ? Prettify<Wrap<RemoveIndexSignature<InferSchema<SignUpSchema>>>> : never;
|
|
67
101
|
//#endregion
|
|
68
|
-
export {
|
|
102
|
+
export { index_d_exports as a, NextSignInCredentials as c, NextSignUpReturn as d, NextUpdateSessionOptions as f, NextPagesInstance as i, NextSignInReturn as l, NextAppInstance as n, core_d_exports as o, NextUpdateSessionReturn as p, NextInstance as r, NextAPI as s, InferSignUp as t, NextSignOutReturn as u };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,48 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as NextSignUpReturn, i as NextSignOutReturn, n as NextSignInCredentials, r as NextSignInReturn, s as NextUpdateSessionReturn } from "./index-BLRrX4DD.js";
|
|
3
|
-
import { C as SignInAPIOptions, D as SignOutAPIOptions, S as Session$1, T as SignInCredentialsAPIOptions, _ as RefreshUserInfoAPIOptions, a as DeepPartial, b as RevokeTokenAPIOptions, d as GetSessionAPIOptions, g as ProviderConnectedAPIReturn, h as ProviderConnectedAPIOptions, i as BuiltInOAuthProvider, k as SignUpAPIOptions, l as GetProviderTokensAPIOptions, m as LiteralUnion, n as AccessTokenAPIReturn, o as DisconnectProviderAPIOptions, p as Handlers, r as AuthInstance$1, s as DisconnectProviderAPIReturn, t as AccessTokenAPIOptions, u as GetProviderTokensAPIReturn, v as RefreshUserInfoAPIReturn, x as RevokeTokenAPIReturn } from "./index-BbJId8e2.js";
|
|
1
|
+
import { a as index_d_exports, n as NextAppInstance, o as core_d_exports, r as NextInstance } from "./index-CC_ocXOS.js";
|
|
4
2
|
import { AuthConfig as AuthConfig$1 } from "@aura-stack/react";
|
|
3
|
+
import { zod } from "@aura-stack/react/identity/zod";
|
|
5
4
|
import { FromShapeToObject, Identities, SchemaTypes } from "@aura-stack/react/identity";
|
|
6
5
|
|
|
7
6
|
//#region src/createAuth.d.ts
|
|
8
|
-
declare const createAuth: <Identity extends Identities
|
|
9
|
-
|
|
10
|
-
* The core auth instance. It can be used to advanced use cases, such as creating custom behaviors.
|
|
11
|
-
* For most use cases, the `api` property should be sufficient, as it provides a higher-level API for common authentication tasks.
|
|
12
|
-
*/
|
|
13
|
-
core: AuthInstance$1<FromShapeToObject<Identity>, SignUpSchema>;
|
|
14
|
-
/**
|
|
15
|
-
* Built-in API functions for server-side operations related to the auth flows.
|
|
16
|
-
*/
|
|
17
|
-
api: {
|
|
18
|
-
getSession: (options?: GetSessionAPIOptions) => Promise<Session$1<FromShapeToObject<Identity>> | null>;
|
|
19
|
-
signIn: <Options extends SignInAPIOptions>(provider: LiteralUnion<BuiltInOAuthProvider>, options?: Options | undefined) => Promise<NextSignInReturn<Options>>;
|
|
20
|
-
signInCredentials: <Options extends SignInCredentialsAPIOptions>(options: Options) => Promise<NextSignInCredentials<Options>>;
|
|
21
|
-
updateSession: <Options extends {
|
|
22
|
-
redirect?: boolean | undefined;
|
|
23
|
-
request?: Request | undefined;
|
|
24
|
-
session: DeepPartial<Session$1<FromShapeToObject<Identity>>>;
|
|
25
|
-
redirectTo?: string | undefined;
|
|
26
|
-
skipCSRFCheck?: boolean | undefined;
|
|
27
|
-
doubleSubmitToken?: string | undefined;
|
|
28
|
-
headers?: HeadersInit | undefined;
|
|
29
|
-
}>(options: Options) => Promise<NextUpdateSessionReturn<Options, FromShapeToObject<Identity>>>;
|
|
30
|
-
getProviderTokens: (oauth: LiteralUnion<BuiltInOAuthProvider>, options?: GetProviderTokensAPIOptions) => Promise<GetProviderTokensAPIReturn>;
|
|
31
|
-
getAccessToken: (oauth: LiteralUnion<BuiltInOAuthProvider>, options?: AccessTokenAPIOptions) => Promise<AccessTokenAPIReturn>;
|
|
32
|
-
signOut: <Options extends SignOutAPIOptions>(options?: Partial<Options> | undefined) => Promise<NextSignOutReturn<Options>>;
|
|
33
|
-
signUp: <Options extends SignUpAPIOptions>(options: Options) => Promise<NextSignUpReturn<Options>>;
|
|
34
|
-
refreshUserInfo: <Options extends RefreshUserInfoAPIOptions>(oauth: LiteralUnion<BuiltInOAuthProvider>, options?: Options | undefined) => Promise<RefreshUserInfoAPIReturn<FromShapeToObject<Identity>>>;
|
|
35
|
-
revokeToken: <Options extends RevokeTokenAPIOptions>(oauth: LiteralUnion<BuiltInOAuthProvider>, options?: Options | undefined) => Promise<RevokeTokenAPIReturn>;
|
|
36
|
-
disconnectProvider: <Options extends DisconnectProviderAPIOptions>(oauth: LiteralUnion<BuiltInOAuthProvider>, options?: Options | undefined) => Promise<DisconnectProviderAPIReturn>;
|
|
37
|
-
isProviderConnected: <Options extends ProviderConnectedAPIOptions>(oauth: LiteralUnion<BuiltInOAuthProvider>, options?: Options | undefined) => Promise<ProviderConnectedAPIReturn>;
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* The handlers object contains the HTTP request handlers.
|
|
41
|
-
*/
|
|
42
|
-
handlers: Handlers;
|
|
43
|
-
};
|
|
44
|
-
type AuthConfig = core_d_exports.AuthConfig;
|
|
45
|
-
type AuthInstance = core_d_exports.AuthInstance;
|
|
46
|
-
type Session = core_d_exports.Session;
|
|
47
|
-
type User = core_d_exports.User;
|
|
48
|
-
export { type AuthConfig, type AuthInstance, type Session, type User, createAuth };
|
|
7
|
+
declare const createAuth: <Identity extends Identities = index_d_exports.EditableShape<index_d_exports.ZodIdentitySchema>, SignUpSchema extends SchemaTypes = zod.ZodObject<any>>(config: AuthConfig$1<Identity, SignUpSchema>) => NextAppInstance<FromShapeToObject<Identity>, SignUpSchema>;
|
|
8
|
+
export { type AuthConfig, type AuthInstance, type NextAppInstance, type NextInstance, type Session, type User, createAuth };
|
package/dist/pages/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./context.cjs`);let t=require(`@aura-stack/react/server`);const n=e=>`${e.headers[`x-forwarded-proto`]??`http`}://${e.headers[`x-forwarded-host`]??e.headers.host}`,r=(e,t)=>{for(let[n,r]of t.entries())n.toLowerCase()===`set-cookie`?e.setHeader(`Set-Cookie`,t.getSetCookie()):e.setHeader(n,r)},i=e=>async(t,i)=>{let a=t.method??`GET`,o=e[a];if(!o)return i.status(405).json({error:`Method ${a} Not Allowed`});let s=new URL(t.url,n(t)),c=new Request(s,{method:a,headers:new Headers(t.headers),body:a!==`GET`&&a!==`HEAD`?t.body:void 0});try{let e=await o(c);e.status>=300&&e.status<400&&!t.url?.includes(`/auth/signIn/`)&&!t.url?.includes(`/auth/callback/`)&&e.headers.delete(`Location`),r(i,e.headers);let n=await e.json();return i.status(e.status).json(n)}catch{return i.status(500).json({error:`Internal Server Error`})}},a=e=>{let n=(0,t.createAuth)(e);return{...n,toHandler:i(n
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./context.cjs`);let t=require(`@aura-stack/react/server`);const n=e=>`${e.headers[`x-forwarded-proto`]??`http`}://${e.headers[`x-forwarded-host`]??e.headers.host}`,r=(e,t)=>{for(let[n,r]of t.entries())n.toLowerCase()===`set-cookie`?e.setHeader(`Set-Cookie`,t.getSetCookie()):e.setHeader(n,r)},i=({handlers:e})=>async(t,i)=>{let a=t.method??`GET`,o=e[a];if(!o)return i.status(405).json({error:`Method ${a} Not Allowed`});let s=new URL(t.url,n(t)),c=new Request(s,{method:a,headers:new Headers(t.headers),body:a!==`GET`&&a!==`HEAD`?t.body:void 0});try{let e=await o(c);e.status>=300&&e.status<400&&!t.url?.includes(`/auth/signIn/`)&&!t.url?.includes(`/auth/callback/`)&&e.headers.delete(`Location`),r(i,e.headers);let n=await e.json();return i.status(e.status).json(n)}catch{return i.status(500).json({error:`Internal Server Error`})}},a=e=>{let n=(0,t.createAuth)(e);return{...n,toHandler:i(n)}};exports.AuthProvider=e.AuthProvider,exports.createAuth=a;
|