@aura-stack/next 0.1.0

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.
Files changed (81) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +128 -0
  3. package/dist/@types/index.cjs +0 -0
  4. package/dist/@types/index.d.ts +3 -0
  5. package/dist/@types/index.js +1 -0
  6. package/dist/_core/cookies.cjs +1 -0
  7. package/dist/_core/cookies.d.ts +1 -0
  8. package/dist/_core/cookies.js +1 -0
  9. package/dist/_core/crypto.cjs +1 -0
  10. package/dist/_core/crypto.d.ts +1 -0
  11. package/dist/_core/crypto.js +1 -0
  12. package/dist/_core/identity.cjs +1 -0
  13. package/dist/_core/identity.d.ts +1 -0
  14. package/dist/_core/identity.js +1 -0
  15. package/dist/_core/shared.cjs +1 -0
  16. package/dist/_core/shared.d.ts +1 -0
  17. package/dist/_core/shared.js +1 -0
  18. package/dist/client.cjs +1 -0
  19. package/dist/client.d.ts +24 -0
  20. package/dist/client.js +1 -0
  21. package/dist/core-BDwHYePg.d.ts +3 -0
  22. package/dist/index-B0R6c-K9.d.ts +45 -0
  23. package/dist/index-eKek4f4_.d.ts +10973 -0
  24. package/dist/index.cjs +1 -0
  25. package/dist/index.d.ts +41 -0
  26. package/dist/index.js +1 -0
  27. package/dist/oauth/atlassian.cjs +1 -0
  28. package/dist/oauth/atlassian.d.ts +1 -0
  29. package/dist/oauth/atlassian.js +1 -0
  30. package/dist/oauth/bitbucket.cjs +1 -0
  31. package/dist/oauth/bitbucket.d.ts +1 -0
  32. package/dist/oauth/bitbucket.js +1 -0
  33. package/dist/oauth/click-up.cjs +1 -0
  34. package/dist/oauth/click-up.d.ts +1 -0
  35. package/dist/oauth/click-up.js +1 -0
  36. package/dist/oauth/discord.cjs +1 -0
  37. package/dist/oauth/discord.d.ts +1 -0
  38. package/dist/oauth/discord.js +1 -0
  39. package/dist/oauth/dribbble.cjs +1 -0
  40. package/dist/oauth/dribbble.d.ts +1 -0
  41. package/dist/oauth/dribbble.js +1 -0
  42. package/dist/oauth/dropbox.cjs +1 -0
  43. package/dist/oauth/dropbox.d.ts +1 -0
  44. package/dist/oauth/dropbox.js +1 -0
  45. package/dist/oauth/figma.cjs +1 -0
  46. package/dist/oauth/figma.d.ts +1 -0
  47. package/dist/oauth/figma.js +1 -0
  48. package/dist/oauth/github.cjs +1 -0
  49. package/dist/oauth/github.d.ts +1 -0
  50. package/dist/oauth/github.js +1 -0
  51. package/dist/oauth/gitlab.cjs +1 -0
  52. package/dist/oauth/gitlab.d.ts +1 -0
  53. package/dist/oauth/gitlab.js +1 -0
  54. package/dist/oauth/index.cjs +1 -0
  55. package/dist/oauth/index.d.ts +1 -0
  56. package/dist/oauth/index.js +1 -0
  57. package/dist/oauth/mailchimp.cjs +1 -0
  58. package/dist/oauth/mailchimp.d.ts +1 -0
  59. package/dist/oauth/mailchimp.js +1 -0
  60. package/dist/oauth/notion.cjs +1 -0
  61. package/dist/oauth/notion.d.ts +1 -0
  62. package/dist/oauth/notion.js +1 -0
  63. package/dist/oauth/pinterest.cjs +1 -0
  64. package/dist/oauth/pinterest.d.ts +1 -0
  65. package/dist/oauth/pinterest.js +1 -0
  66. package/dist/oauth/spotify.cjs +1 -0
  67. package/dist/oauth/spotify.d.ts +1 -0
  68. package/dist/oauth/spotify.js +1 -0
  69. package/dist/oauth/strava.cjs +1 -0
  70. package/dist/oauth/strava.d.ts +1 -0
  71. package/dist/oauth/strava.js +1 -0
  72. package/dist/oauth/twitch.cjs +1 -0
  73. package/dist/oauth/twitch.d.ts +1 -0
  74. package/dist/oauth/twitch.js +1 -0
  75. package/dist/oauth/x.cjs +1 -0
  76. package/dist/oauth/x.d.ts +1 -0
  77. package/dist/oauth/x.js +1 -0
  78. package/dist/pages/index.cjs +1 -0
  79. package/dist/pages/index.d.ts +346 -0
  80. package/dist/pages/index.js +1 -0
  81. package/package.json +143 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Auth Stack Js
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,128 @@
1
+ <div align="center">
2
+
3
+ <h1><b>@aura-stack/next</b></h1>
4
+
5
+ **Aura Auth adapter and utilities for the Next.js ecosystem**
6
+
7
+ [![npm version](https://img.shields.io/npm/v/@aura-stack/next.svg)](https://www.npmjs.com/package/@aura-stack/next)
8
+ [![JSR version](https://jsr.io/badges/@aura-stack/next)](https://jsr.io/@aura-stack/next)
9
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
10
+
11
+ [Official Docs](https://aura-stack-auth.vercel.app/docs) · [Next.js Package Docs](https://aura-stack-auth.vercel.app/docs/packages/next)
12
+
13
+ </div>
14
+
15
+ ## Overview
16
+
17
+ `@aura-stack/next` provides a high-level, type-safe integration for **Next.js** applications using **Aura Auth**. It is designed for maximum developer experience in the App Router, offering dedicated utilities for Server Components, Server Actions, Middleware, and Route Handlers.
18
+
19
+ By utilizing a **"Concentrated API"** pattern, it optimizes core authentication logic for the Next.js runtime, automatically managing context-aware data like cookies and headers via `next/headers`.
20
+
21
+ ## Features
22
+
23
+ - **App Router Optimized** — Full support for React Server Components (RSC) and Server Actions.
24
+ - **Concentrated API** — Dedicated `auth.api` for Next.js that automates session fetching and redirects.
25
+ - **Aggregated Client Entry** — Consolidated `import { ... } from "@aura-stack/next/client"` for all hooks and context.
26
+ - **Type-safe by design** — Automatic type inference from your identity schema.
27
+
28
+ ## Installation
29
+
30
+ ```bash
31
+ pnpm add @aura-stack/next
32
+ ```
33
+
34
+ > [!NOTE]
35
+ > Ensure you have `react` (>= 19.x) installed.
36
+
37
+ ## Quick Start
38
+
39
+ ### 1. Create Auth Instance
40
+
41
+ Configure your auth instance in a shared file (e.g., `lib/auth.ts`).
42
+
43
+ ```ts
44
+ import { createAuth } from "@aura-stack/next"
45
+
46
+ export const auth = createAuth({
47
+ oauth: ["github"],
48
+ })
49
+
50
+ export const { api, core } = auth
51
+ ```
52
+
53
+ ### 2. Set Up Route Handler
54
+
55
+ Configure the catch-all route in `app/api/auth/[...auth]/route.ts`.
56
+
57
+ ```tsx
58
+ import { core } from "@/lib/auth"
59
+
60
+ export const { GET, POST, PATCH } = core.handlers
61
+ ```
62
+
63
+ ### 3. Access Session (Server-side)
64
+
65
+ Use the optimized API in your Server Components.
66
+
67
+ ```tsx
68
+ import { api } from "@/lib/auth"
69
+
70
+ export default async function Page() {
71
+ const session = await api.getSession()
72
+
73
+ if (!session) return <div>Not signed in</div>
74
+
75
+ return <div>Welcome, {session.user.name}</div>
76
+ }
77
+ ```
78
+
79
+ ### 4. Configure Auth Client Instance and Auth Provider
80
+
81
+ Wrap your application with the `AuthProvider` and pass it a configured Aura Auth client.
82
+
83
+ ```tsx
84
+ import { createAuthClient, AuthProvider } from "@aura-stack/next/client"
85
+ import type { PropsWithChildren } from "react"
86
+
87
+ const client = createAuthClient({
88
+ /* your config */
89
+ })
90
+
91
+ export const App = ({ children }: PropsWithChildren) => {
92
+ return <AuthProvider client={client}>{children}</AuthProvider>
93
+ }
94
+ ```
95
+
96
+ ### 5. Client-side Implementation
97
+
98
+ Use the consolidated client entry for hooks and context.
99
+
100
+ ```tsx
101
+ "use client"
102
+ import { useSession } from "@aura-stack/next/client"
103
+
104
+ export function Profile() {
105
+ const { session, status } = useSession()
106
+ if (status === "loading") return <p>Loading...</p>
107
+
108
+ return (
109
+ <div>
110
+ <p>Welcome, {session.user.name}!</p>
111
+ </div>
112
+ )
113
+ }
114
+ ```
115
+
116
+ ## Documentation
117
+
118
+ Visit the [**official documentation website**](https://aura-stack-auth.vercel.app).
119
+
120
+ ## License
121
+
122
+ Licensed under the [MIT License](../../LICENSE). © [Aura Stack](https://github.com/aura-stack-ts)
123
+
124
+ ---
125
+
126
+ <p align="center">
127
+ Made with ❤️ by <a href="https://github.com/aura-stack-ts">Aura Stack team</a>
128
+ </p>
File without changes
@@ -0,0 +1,3 @@
1
+ import { a as NextUpdateSessionReturn, i as NextUpdateSessionOptions, n as NextSignInReturn, r as NextSignOutReturn, t as NextSignInCredentials } from "../index-B0R6c-K9.js";
2
+ export * from "@aura-stack/react/types";
3
+ export { NextSignInCredentials, NextSignInReturn, NextSignOutReturn, NextUpdateSessionOptions, NextUpdateSessionReturn };
@@ -0,0 +1 @@
1
+ export{};
@@ -0,0 +1 @@
1
+ var e=require(`@aura-stack/react/cookies`);Object.keys(e).forEach(function(t){t!==`default`&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})});
@@ -0,0 +1 @@
1
+ export * from "@aura-stack/react/cookies";
@@ -0,0 +1 @@
1
+ export*from"@aura-stack/react/cookies";export{};
@@ -0,0 +1 @@
1
+ var e=require(`@aura-stack/react/crypto`);Object.keys(e).forEach(function(t){t!==`default`&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})});
@@ -0,0 +1 @@
1
+ export * from "@aura-stack/react/crypto";
@@ -0,0 +1 @@
1
+ export*from"@aura-stack/react/crypto";export{};
@@ -0,0 +1 @@
1
+ var e=require(`@aura-stack/react/identity`);Object.keys(e).forEach(function(t){t!==`default`&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})});
@@ -0,0 +1 @@
1
+ export * from "@aura-stack/react/identity";
@@ -0,0 +1 @@
1
+ export*from"@aura-stack/react/identity";export{};
@@ -0,0 +1 @@
1
+ var e=require(`@aura-stack/react/shared`);Object.keys(e).forEach(function(t){t!==`default`&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})});
@@ -0,0 +1 @@
1
+ export * from "@aura-stack/react/shared";
@@ -0,0 +1 @@
1
+ export*from"@aura-stack/react/shared";export{};
@@ -0,0 +1 @@
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@aura-stack/react`),t=require(`@aura-stack/react/context`),n=require(`next/navigation`),r=require(`react/jsx-runtime`);const i=({client:e,children:i,initialSession:a,redirect:o})=>{let s=(0,n.useRouter)();return(0,r.jsx)(t.AuthProvider,{client:e,initialSession:a,redirect:o??(e=>s.push(e)),children:i})};exports.AuthProvider=i,Object.defineProperty(exports,`createAuthClient`,{enumerable:!0,get:function(){return e.createAuthClient}}),Object.defineProperty(exports,`useAuthActions`,{enumerable:!0,get:function(){return e.useAuthActions}}),Object.defineProperty(exports,`useSession`,{enumerable:!0,get:function(){return e.useSession}}),Object.defineProperty(exports,`useSignIn`,{enumerable:!0,get:function(){return e.useSignIn}}),Object.defineProperty(exports,`useSignInCredentials`,{enumerable:!0,get:function(){return e.useSignInCredentials}}),Object.defineProperty(exports,`useSignOut`,{enumerable:!0,get:function(){return e.useSignOut}}),Object.defineProperty(exports,`useUpdateSession`,{enumerable:!0,get:function(){return e.useUpdateSession}});
@@ -0,0 +1,24 @@
1
+ import { AuthClientOptions, AuthProviderProps, User, createAuthClient, useAuthActions, useSession, useSignIn, useSignInCredentials, useSignOut, useUpdateSession } from "@aura-stack/react";
2
+ import { AuthProviderProps as AuthProviderProps$1 } from "@aura-stack/react/context";
3
+ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
4
+
5
+ //#region src/context.d.ts
6
+ /**
7
+ * Wrapper component that provides authentication context for Next.js App Router applications.
8
+ * Falls back to `router.push` from `next/navigation` when no custom `redirect` prop is supplied.
9
+ *
10
+ * @example
11
+ * const client = createAuthClient({ baseURL: "http://localhost:3000" })
12
+ *
13
+ * <AuthProvider client={client}>
14
+ * <App />
15
+ * </AuthProvider>
16
+ */
17
+ declare const AuthProvider: <DefaultUser extends User = User>({
18
+ client,
19
+ children,
20
+ initialSession,
21
+ redirect
22
+ }: AuthProviderProps$1<DefaultUser>) => _$react_jsx_runtime0.JSX.Element;
23
+ //#endregion
24
+ export { type AuthClientOptions, AuthProvider, type AuthProviderProps, createAuthClient, useAuthActions, useSession, useSignIn, useSignInCredentials, useSignOut, useUpdateSession };
package/dist/client.js ADDED
@@ -0,0 +1 @@
1
+ "use client";import{createAuthClient as e,useAuthActions as t,useSession as n,useSignIn as r,useSignInCredentials as i,useSignOut as a,useUpdateSession as o}from"@aura-stack/react";import{AuthProvider as s}from"@aura-stack/react/context";import{useRouter as c}from"next/navigation";import{jsx as l}from"react/jsx-runtime";const u=({client:e,children:t,initialSession:n,redirect:r})=>{let i=c();return l(s,{client:e,initialSession:n,redirect:r??(e=>i.push(e)),children:t})};export{u as AuthProvider,e as createAuthClient,t as useAuthActions,n as useSession,r as useSignIn,i as useSignInCredentials,a as useSignOut,o as useUpdateSession};
@@ -0,0 +1,3 @@
1
+ import * as import__aura_stack_react_types from "@aura-stack/react/types";
2
+ //#endregion
3
+ export { __exportAll as n, __reExport as r, core_d_exports as t };
@@ -0,0 +1,45 @@
1
+ import { n as __exportAll, r as __reExport, t as core_d_exports } from "./core-BDwHYePg.js";
2
+ import { Prettify, SignInAPIOptions, SignInAPIReturn, SignInCredentialsAPIOptions, SignInCredentialsAPIReturn, SignOutAPIOptions, SignOutAPIReturn, UpdateSessionAPIOptions, UpdateSessionAPIReturn, User } from "@aura-stack/react/types";
3
+
4
+ //#region src/@types/api.d.ts
5
+ /**
6
+ * Return type for the Next.js server `api.signIn` helper (see `packages/next/src/lib/api.ts`).
7
+ * When `Options` includes `redirect: true`, the helper calls `redirect()` and the type is `never` because execution does not continue.
8
+ */
9
+ type NextSignInReturn<Options extends SignInAPIOptions> = Options extends {
10
+ redirect: true;
11
+ } ? never : Options extends {
12
+ redirectTo: string;
13
+ } ? never : SignInAPIReturn;
14
+ /**
15
+ * Return type for the Next.js server `api.signInCredentials` helper.
16
+ * Same `never` rule as {@link NextSignInReturn} when a server redirect is triggered via options.
17
+ */
18
+ type NextSignInCredentials<Options extends SignInCredentialsAPIOptions> = Options extends {
19
+ redirect: true;
20
+ } ? never : Options extends {
21
+ redirectTo: string;
22
+ } ? never : SignInCredentialsAPIReturn;
23
+ type NextUpdateSessionOptions<DefaultUser extends User = User> = Prettify<Omit<UpdateSessionAPIOptions<DefaultUser>, "headers"> & {
24
+ headers?: HeadersInit;
25
+ }>;
26
+ /**
27
+ * Return type for the Next.js server `api.updateSession` helper.
28
+ */
29
+ type NextUpdateSessionReturn<Options extends NextUpdateSessionOptions<DefaultUser>, DefaultUser extends User = User> = Options extends {
30
+ redirect: true;
31
+ } ? never : Options extends {
32
+ redirectTo: string;
33
+ } ? never : UpdateSessionAPIReturn<DefaultUser>;
34
+ /**
35
+ * Return type for the Next.js server `api.signOut` helper.
36
+ * When `Options` includes a `redirectTo` string and the core API performs a redirect response, Next’s `redirect()` is invoked and the type is `never`.
37
+ */
38
+ type NextSignOutReturn<Options extends SignOutAPIOptions> = Options extends {
39
+ redirectTo: string;
40
+ } ? never : SignOutAPIReturn;
41
+ declare namespace index_d_exports {
42
+ export { NextSignInCredentials, NextSignInReturn, NextSignOutReturn, NextUpdateSessionOptions, NextUpdateSessionReturn };
43
+ }
44
+ //#endregion
45
+ export { NextUpdateSessionReturn as a, NextUpdateSessionOptions as i, NextSignInReturn as n, NextSignOutReturn as r, NextSignInCredentials as t };