@aura-stack/next 0.1.0 → 0.2.1

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/index.js CHANGED
@@ -1 +1 @@
1
- import{redirect as e}from"next/navigation";import{createAuth as t}from"@aura-stack/react/server";import{cookies as n,headers as r}from"next/headers";import{parseSetCookie as i}from"@aura-stack/react/cookies";const a=async e=>{let t=await n(),r=e.getSetCookie();for(let e of r){let{name:n,value:r,...a}=i(e);t.set(n,r??``,a)}},o=({api:e})=>async t=>{try{let n=await e.getSession({...t,headers:await r()});return n.success?n.session:null}catch{return console.error(`[error:server] getSession - Failed to retrieve session`),null}},s=({api:t})=>async(n,i)=>{let a=await t.signIn(n,{headers:await r(),...i,redirect:!!i?.redirect});return i?.redirect===!1?a:a.success&&a.signInURL?e(a.signInURL):a},c=({api:t})=>async n=>{let i=await t.signInCredentials({headers:await r(),...n,redirect:!!n.redirect});return await a(i.headers),i.success&&i.redirectURL?e(i.redirectURL):i},l=({api:t})=>async n=>{let i=await t.updateSession({headers:await r(),...n,redirect:!!n.redirect,session:n.session});return await a(i.headers),i.success&&i.redirectURL?e(i.redirectURL):i},u=({api:t})=>async n=>{let i=await t.signOut({headers:await r(),...n,redirect:!!n?.redirect});return await a(i.headers),i.success&&i.redirectURL?e(i.redirectURL):i},d=e=>({getSession:o(e),signIn:s(e),signInCredentials:c(e),updateSession:l(e),signOut:u(e)}),f=e=>{let n=t(e);return{core:n,api:d(n),handlers:n.handlers}};export{f as createAuth};
1
+ import{redirect as e}from"next/navigation.js";import{createAuth as t}from"@aura-stack/react/server";import{cookies as n,headers as r}from"next/headers.js";import{parseSetCookie as i}from"@aura-stack/react/cookies";const a=async e=>{let t=await n(),r=e.getSetCookie();for(let e of r){let{name:n,value:r,...a}=i(e);t.set(n,r??``,a)}},o=({api:e})=>async t=>{try{let n=await e.getSession({...t,headers:await r()});return n.success?n.session:null}catch{return console.error(`[error:server] getSession - Failed to retrieve session`),null}},s=({api:t})=>async(n,i)=>{let a=await t.signIn(n,{headers:await r(),...i,redirect:!!i?.redirect});return i?.redirect===!1?a:a.success&&a.signInURL?e(a.signInURL):a},c=({api:t})=>async n=>{let i=await t.signInCredentials({headers:await r(),...n,redirect:!!n.redirect});return await a(i.headers),i.success&&i.redirectURL?e(i.redirectURL):i},l=({api:t})=>async n=>{let i=await t.updateSession({headers:await r(),...n,redirect:!!n.redirect,session:n.session});return await a(i.headers),i.success&&i.redirectURL?e(i.redirectURL):i},u=({api:t})=>async n=>{let i=await t.signOut({headers:await r(),...n,redirect:!!n?.redirect});return await a(i.headers),i.success&&i.redirectURL?e(i.redirectURL):i},d=e=>({getSession:o(e),signIn:s(e),signInCredentials:c(e),updateSession:l(e),signOut:u(e)}),f=e=>{let n=t(e);return{core:n,api:d(n),handlers:n.handlers}};export{f as createAuth};
@@ -0,0 +1 @@
1
+ var e=require(`@aura-stack/react/oauth/authentik`);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/oauth/authentik";
@@ -0,0 +1 @@
1
+ export*from"@aura-stack/react/oauth/authentik";export{};
@@ -0,0 +1 @@
1
+ var e=require(`@aura-stack/react/oauth/google`);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/oauth/google";
@@ -0,0 +1 @@
1
+ export*from"@aura-stack/react/oauth/google";export{};
@@ -0,0 +1 @@
1
+ var e=require(`@aura-stack/react/oauth/hubspot`);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/oauth/hubspot";
@@ -0,0 +1 @@
1
+ export*from"@aura-stack/react/oauth/hubspot";export{};
@@ -0,0 +1 @@
1
+ var e=require(`@aura-stack/react/oauth/huggingface`);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/oauth/huggingface";
@@ -0,0 +1 @@
1
+ export*from"@aura-stack/react/oauth/huggingface";export{};
@@ -0,0 +1 @@
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./context.cjs`);let t=require(`@aura-stack/react`);exports.AuthProvider=e.AuthProvider,Object.defineProperty(exports,`createAuthClient`,{enumerable:!0,get:function(){return t.createAuthClient}}),Object.defineProperty(exports,`useAuthActions`,{enumerable:!0,get:function(){return t.useAuthActions}}),Object.defineProperty(exports,`useSession`,{enumerable:!0,get:function(){return t.useSession}}),Object.defineProperty(exports,`useSignIn`,{enumerable:!0,get:function(){return t.useSignIn}}),Object.defineProperty(exports,`useSignInCredentials`,{enumerable:!0,get:function(){return t.useSignInCredentials}}),Object.defineProperty(exports,`useSignOut`,{enumerable:!0,get:function(){return t.useSignOut}}),Object.defineProperty(exports,`useUpdateSession`,{enumerable:!0,get:function(){return t.useUpdateSession}});
@@ -0,0 +1,3 @@
1
+ import { AuthProvider } from "./context.js";
2
+ import { AuthClientOptions, AuthProviderProps, createAuthClient, useAuthActions, useSession, useSignIn, useSignInCredentials, useSignOut, useUpdateSession } from "@aura-stack/react";
3
+ export { type AuthClientOptions, AuthProvider, type AuthProviderProps, createAuthClient, useAuthActions, useSession, useSignIn, useSignInCredentials, useSignOut, useUpdateSession };
@@ -0,0 +1 @@
1
+ "use client";import{AuthProvider as e}from"./context.js";import{createAuthClient as t,useAuthActions as n,useSession as r,useSignIn as i,useSignInCredentials as a,useSignOut as o,useUpdateSession as s}from"@aura-stack/react";export{e as AuthProvider,t as createAuthClient,n as useAuthActions,r as useSession,i as useSignIn,a as useSignInCredentials,o as useSignOut,s as useUpdateSession};
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@aura-stack/react/context`),t=require(`react/jsx-runtime`),n=require(`next/router.js`);const r=({client:r,children:i,initialSession:a,redirect:o})=>{let s=(0,n.useRouter)();return(0,t.jsx)(e.AuthProvider,{client:r,initialSession:a,redirect:o??(e=>s.push(e)),children:i})};exports.AuthProvider=r;
@@ -0,0 +1,23 @@
1
+ import { AuthProviderProps } from "@aura-stack/react/context";
2
+ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
3
+
4
+ //#region src/pages/context.d.ts
5
+ /**
6
+ * Wrapper component that provides authentication context for Next.js Pages Router applications.
7
+ * Falls back to `router.push` from `next/router` when no custom `redirect` prop is supplied.
8
+ *
9
+ * @example
10
+ * const client = createAuthClient({ baseURL: "http://localhost:3000" })
11
+ *
12
+ * <AuthProvider client={client}>
13
+ * <App />
14
+ * </AuthProvider>
15
+ */
16
+ declare const AuthProvider: ({
17
+ client,
18
+ children,
19
+ initialSession,
20
+ redirect
21
+ }: AuthProviderProps) => _$react_jsx_runtime0.JSX.Element;
22
+ //#endregion
23
+ export { AuthProvider, type AuthProviderProps };
@@ -0,0 +1 @@
1
+ import{AuthProvider as e}from"@aura-stack/react/context";import{jsx as t}from"react/jsx-runtime";import{useRouter as n}from"next/router.js";const r=({client:r,children:i,initialSession:a,redirect:o})=>{let s=n();return t(e,{client:r,initialSession:a,redirect:o??(e=>s.push(e)),children:i})};export{r as AuthProvider};
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@aura-stack/react/context`),t=require(`react/jsx-runtime`),n=require(`@aura-stack/react/server`),r=require(`next/router.js`);const i=e=>`${e.headers[`x-forwarded-proto`]??`http`}://${e.headers[`x-forwarded-host`]??e.headers.host}`,a=(e,t)=>{for(let[n,r]of t.entries())n.toLowerCase()===`set-cookie`?e.setHeader(`Set-Cookie`,t.getSetCookie()):e.setHeader(n,r)},o=e=>async(t,n)=>{let r=t.method??`GET`,o=e[r];if(!o)return n.status(405).json({error:`Method ${r} Not Allowed`});let s=new URL(t.url,i(t)),c=new Request(s,{method:r,headers:new Headers(t.headers),body:r!==`GET`&&r!==`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`),a(n,e.headers);let r=await e.json();return n.status(e.status).json(r)}catch{return n.status(500).json({error:`Internal Server Error`})}},s=e=>{let t=(0,n.createAuth)(e);return{...t,toHandler:o(t.handlers)}},c=({client:n,children:i,initialSession:a,redirect:o})=>{let s=(0,r.useRouter)();return(0,t.jsx)(e.AuthProvider,{client:n,initialSession:a,redirect:o??(e=>s.push(e)),children:i})};exports.AuthProvider=c,exports.createAuth=s;
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.handlers)}};exports.AuthProvider=e.AuthProvider,exports.createAuth=a;
@@ -1,8 +1,7 @@
1
1
  import { t as core_d_exports } from "../core-BDwHYePg.js";
2
- import { _ as DecodeJWTOptions, a as GetSessionAPIReturn, d as SignInCredentialsAPIOptions, f as SignInCredentialsAPIReturn, g as UpdateSessionAPIReturn, h as UpdateSessionAPIOptions, i as GetSessionAPIOptions, l as SignInAPIOptions, m as SignOutAPIReturn, n as BuiltInOAuthProvider, o as LiteralUnion, p as SignOutAPIOptions, r as FromShapeToObject, u as SignInAPIReturn, v as EncodeJWTOptions, y as TypedJWTPayload } from "../index-eKek4f4_.js";
2
+ import { _ as UpdateSessionAPIOptions, a as GetSessionAPIReturn, b as EncodeJWTOptions, d as SignInCredentialsAPIOptions, f as SignInCredentialsAPIReturn, g as SignUpAPIReturn, h as SignUpAPIOptions, i as GetSessionAPIOptions, l as SignInAPIOptions, m as SignOutAPIReturn, n as BuiltInOAuthProvider, o as LiteralUnion, p as SignOutAPIOptions, r as FromShapeToObject, u as SignInAPIReturn, v as UpdateSessionAPIReturn, x as TypedJWTPayload, y as DecodeJWTOptions } from "../index-CbFxTFu9.js";
3
+ import { AuthProvider, AuthProviderProps } from "./context.js";
3
4
  import { AuthConfig as AuthConfig$1 } from "@aura-stack/react";
4
- import { AuthProviderProps } from "@aura-stack/react/context";
5
- import * as _$react_jsx_runtime0 from "react/jsx-runtime";
6
5
  import { Identities } from "@aura-stack/react/identity";
7
6
  import * as _$next from "next";
8
7
 
@@ -302,6 +301,7 @@ declare const createAuth: <Identity extends Identities>(config: AuthConfig$1<Ide
302
301
  getSession: (options: GetSessionAPIOptions) => Promise<GetSessionAPIReturn<FromShapeToObject<Identity>>>;
303
302
  signIn: (oauth: LiteralUnion<BuiltInOAuthProvider>, options?: SignInAPIOptions) => Promise<SignInAPIReturn>;
304
303
  signInCredentials: (options: SignInCredentialsAPIOptions) => Promise<SignInCredentialsAPIReturn>;
304
+ signUp: <Payload extends Record<string, any> = {}>(options: SignUpAPIOptions<Payload>) => Promise<SignUpAPIReturn>;
305
305
  updateSession: (options: UpdateSessionAPIOptions<FromShapeToObject<Identity>>) => Promise<UpdateSessionAPIReturn<FromShapeToObject<Identity>>>;
306
306
  signOut: (options: SignOutAPIOptions) => Promise<SignOutAPIReturn>;
307
307
  };
@@ -320,25 +320,6 @@ declare const createAuth: <Identity extends Identities>(config: AuthConfig$1<Ide
320
320
  ALL: (request: Request) => Response | Promise<Response>;
321
321
  };
322
322
  };
323
- //#endregion
324
- //#region src/pages/context.d.ts
325
- /**
326
- * Wrapper component that provides authentication context for Next.js Pages Router applications.
327
- * Falls back to `router.push` from `next/router` when no custom `redirect` prop is supplied.
328
- *
329
- * @example
330
- * const client = createAuthClient({ baseURL: "http://localhost:3000" })
331
- *
332
- * <AuthProvider client={client}>
333
- * <App />
334
- * </AuthProvider>
335
- */
336
- declare const AuthProvider: ({
337
- client,
338
- children,
339
- initialSession,
340
- redirect
341
- }: AuthProviderProps) => _$react_jsx_runtime0.JSX.Element;
342
323
  type AuthConfig = core_d_exports.AuthConfig;
343
324
  type AuthInstance = core_d_exports.AuthInstance;
344
325
  type Session = core_d_exports.Session;
@@ -1 +1 @@
1
- import{AuthProvider as e}from"@aura-stack/react/context";import{jsx as t}from"react/jsx-runtime";import{createAuth as n}from"@aura-stack/react/server";import{useRouter as r}from"next/router.js";const i=e=>`${e.headers[`x-forwarded-proto`]??`http`}://${e.headers[`x-forwarded-host`]??e.headers.host}`,a=(e,t)=>{for(let[n,r]of t.entries())n.toLowerCase()===`set-cookie`?e.setHeader(`Set-Cookie`,t.getSetCookie()):e.setHeader(n,r)},o=e=>async(t,n)=>{let r=t.method??`GET`,o=e[r];if(!o)return n.status(405).json({error:`Method ${r} Not Allowed`});let s=new URL(t.url,i(t)),c=new Request(s,{method:r,headers:new Headers(t.headers),body:r!==`GET`&&r!==`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`),a(n,e.headers);let r=await e.json();return n.status(e.status).json(r)}catch{return n.status(500).json({error:`Internal Server Error`})}},s=e=>{let t=n(e);return{...t,toHandler:o(t.handlers)}},c=({client:n,children:i,initialSession:a,redirect:o})=>{let s=r();return t(e,{client:n,initialSession:a,redirect:o??(e=>s.push(e)),children:i})};export{c as AuthProvider,s as createAuth};
1
+ import{AuthProvider as e}from"./context.js";import{createAuth as t}from"@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=t(e);return{...n,toHandler:i(n.handlers)}};export{e as AuthProvider,a as createAuth};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aura-stack/next",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Authentication integration for Next.js applications. Supports App Router, Server Components, Route Handlers and client-side authentication powered by Aura Auth.",
@@ -106,14 +106,14 @@
106
106
  },
107
107
  "license": "MIT",
108
108
  "dependencies": {
109
- "@aura-stack/react": "0.1.0"
109
+ "@aura-stack/react": "0.2.1"
110
110
  },
111
111
  "devDependencies": {
112
112
  "@testing-library/dom": "^10.4.1",
113
113
  "@testing-library/react": "^16.3.2",
114
114
  "@types/react": "^19.2.7",
115
115
  "@types/react-dom": "^19.2.3",
116
- "next": "^16.1.6",
116
+ "next": "^16.2.6",
117
117
  "node-mocks-http": "^1.17.2",
118
118
  "react": "^19.2.3",
119
119
  "react-dom": "^19.2.3",