@aura-stack/next 0.2.2 → 0.3.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.
@@ -1 +1 @@
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};
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=({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=t(e);return{...n,toHandler:i(n)}};export{e as AuthProvider,a as createAuth};
package/package.json CHANGED
@@ -1,17 +1,77 @@
1
1
  {
2
2
  "name": "@aura-stack/next",
3
- "version": "0.2.2",
3
+ "version": "0.3.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.",
7
+ "homepage": "https://aura-stack-auth.vercel.app",
8
+ "bugs": {
9
+ "url": "https://github.com/aura-stack-ts/auth/issues",
10
+ "email": "aurastackjs@gmail.com"
11
+ },
12
+ "license": "MIT",
13
+ "author": "Aura Stack <aurastackjs@gmail.com> | Hernan Alvarado <halvaradop.dev@gmail.com>",
7
14
  "repository": {
8
15
  "type": "git",
9
16
  "url": "git+https://github.com/aura-stack-ts/auth"
10
17
  },
18
+ "funding": {
19
+ "type": "github",
20
+ "url": "https://github.com/sponsors/halvaradop"
21
+ },
22
+ "publishConfig": {
23
+ "access": "public",
24
+ "registry": "https://registry.npmjs.org/"
25
+ },
11
26
  "sideEffects": false,
12
27
  "files": [
13
28
  "dist"
14
29
  ],
30
+ "keywords": [
31
+ "auth",
32
+ "oauth",
33
+ "oauth2",
34
+ "security",
35
+ "session",
36
+ "authentication",
37
+ "authorization",
38
+ "nextjs",
39
+ "next.js",
40
+ "server components",
41
+ "client components",
42
+ "server actions",
43
+ "server-side rendering",
44
+ "client-side rendering",
45
+ "react",
46
+ "typescript",
47
+ "javascript",
48
+ "web-api",
49
+ "aura-stack",
50
+ "aura-stack-ts",
51
+ "aura stack",
52
+ "aura stack ts"
53
+ ],
54
+ "dependencies": {
55
+ "@aura-stack/react": "0.3.1"
56
+ },
57
+ "devDependencies": {
58
+ "@testing-library/dom": "^10.4.1",
59
+ "@testing-library/react": "^16.3.2",
60
+ "@types/react": "^19.2.7",
61
+ "@types/react-dom": "^19.2.3",
62
+ "next": "^16.2.6",
63
+ "node-mocks-http": "^1.17.2",
64
+ "react": "^19.2.3",
65
+ "react-dom": "^19.2.3",
66
+ "vitest": "4.1.4",
67
+ "@aura-stack/tsconfig": "0.0.0",
68
+ "@aura-stack/tsdown-config": "0.0.0"
69
+ },
70
+ "peerDependencies": {
71
+ "next": ">=16.0.0",
72
+ "react": ">=19.0.0",
73
+ "react-dom": ">=19.0.0"
74
+ },
15
75
  "exports": {
16
76
  ".": {
17
77
  "types": "./dist/index.d.ts",
@@ -80,56 +140,6 @@
80
140
  },
81
141
  "./types": "./dist/@types/index.d.ts"
82
142
  },
83
- "keywords": [
84
- "auth",
85
- "oauth",
86
- "oauth2",
87
- "security",
88
- "session",
89
- "authentication",
90
- "authorization",
91
- "nextjs",
92
- "next.js",
93
- "server components",
94
- "client components",
95
- "server actions",
96
- "server-side rendering",
97
- "client-side rendering",
98
- "react",
99
- "typescript",
100
- "javascript",
101
- "web-api",
102
- "aura-stack",
103
- "aura-stack-ts",
104
- "aura auth",
105
- "aura-auth"
106
- ],
107
- "author": "Aura Stack <aurastackjs@gmail.com> | Hernan Alvarado <halvaradop.dev@gmail.com>",
108
- "homepage": "https://aura-stack-auth.vercel.app",
109
- "bugs": {
110
- "url": "https://github.com/aura-stack-ts/auth/issues"
111
- },
112
- "license": "MIT",
113
- "dependencies": {
114
- "@aura-stack/react": "0.2.2"
115
- },
116
- "devDependencies": {
117
- "@testing-library/dom": "^10.4.1",
118
- "@testing-library/react": "^16.3.2",
119
- "@types/react": "^19.2.7",
120
- "@types/react-dom": "^19.2.3",
121
- "next": "^16.2.6",
122
- "node-mocks-http": "^1.17.2",
123
- "react": "^19.2.3",
124
- "react-dom": "^19.2.3",
125
- "@aura-stack/tsdown-config": "0.0.0",
126
- "@aura-stack/tsconfig": "0.0.0"
127
- },
128
- "peerDependencies": {
129
- "next": ">=16.0.0",
130
- "react": ">=19.0.0",
131
- "react-dom": ">=19.0.0"
132
- },
133
143
  "scripts": {
134
144
  "dev": "tsdown --watch",
135
145
  "build": "pnpm sync:modules && tsdown",
@@ -140,8 +150,9 @@
140
150
  "test": "vitest --run",
141
151
  "test:watch": "vitest",
142
152
  "test:coverage": "vitest --run --coverage",
153
+ "test:types": "vitest --run --typecheck.only",
143
154
  "type-check": "tsc --noEmit",
144
- "clean": "rm -rf dist src/_core src/oauth",
155
+ "clean": "rm -rf dist src/_core src/oauth src/identity",
145
156
  "clean:cts": "[ -d dist ] && find dist -type f -name \"*.cts\" -delete || true",
146
157
  "sync:modules": "node ../shared/scripts/modules.js --from react"
147
158
  }
@@ -1,3 +0,0 @@
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 };
@@ -1,45 +0,0 @@
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 };