@eventuras/fides-auth-next 0.8.1 → 1.0.0-beta.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/README.md +162 -108
- package/dist/auth.d.ts +101 -54
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +65 -75
- package/dist/auth.js.map +1 -1
- package/dist/cookie-store.d.ts +3 -5
- package/dist/cookie-store.d.ts.map +1 -1
- package/dist/cookie-store.js +3 -8
- package/dist/cookie-store.js.map +1 -1
- package/dist/index.d.ts +4 -21
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -18
- package/package.json +9 -43
- package/dist/cookies.d.ts +0 -132
- package/dist/cookies.d.ts.map +0 -1
- package/dist/cookies.js +0 -220
- package/dist/cookies.js.map +0 -1
- package/dist/heartbeat-handler.d.ts +0 -36
- package/dist/heartbeat-handler.d.ts.map +0 -1
- package/dist/heartbeat-handler.js +0 -40
- package/dist/heartbeat-handler.js.map +0 -1
- package/dist/oidc-callback.d.ts +0 -60
- package/dist/oidc-callback.d.ts.map +0 -1
- package/dist/oidc-callback.js +0 -45
- package/dist/oidc-callback.js.map +0 -1
- package/dist/oidc-login.d.ts +0 -37
- package/dist/oidc-login.d.ts.map +0 -1
- package/dist/oidc-login.js +0 -36
- package/dist/oidc-login.js.map +0 -1
- package/dist/oidc-logout.d.ts +0 -56
- package/dist/oidc-logout.d.ts.map +0 -1
- package/dist/oidc-logout.js +0 -47
- package/dist/oidc-logout.js.map +0 -1
- package/dist/request.d.ts +0 -11
- package/dist/request.d.ts.map +0 -1
- package/dist/request.js +0 -43
- package/dist/request.js.map +0 -1
- package/dist/store/index.d.ts +0 -103
- package/dist/store/index.d.ts.map +0 -1
- package/dist/store/index.js +0 -3
package/dist/cookies.js
DELETED
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
import { cookies } from "next/headers";
|
|
2
|
-
import { createLogger } from "@eventuras/fides-auth/logger";
|
|
3
|
-
import { ACCESS_TOKEN_COOKIE_NAME, ACCESS_TOKEN_COOKIE_NAME as ACCESS_TOKEN_COOKIE_NAME$1, COOKIE_INFO_BYTES, COOKIE_INFO_BYTES as COOKIE_INFO_BYTES$1, COOKIE_MAX_BYTES, CookieTooLargeError, ID_TOKEN_COOKIE_NAME, assertCookieWithinLimit, assertCookieWithinLimit as assertCookieWithinLimit$1, cookieByteSize, defaultOAuthCookieOptions, defaultSessionCookieOptions, defaultSessionCookieOptions as defaultSessionCookieOptions$1 } from "@eventuras/fides-auth/cookies";
|
|
4
|
-
// src/cookies.ts
|
|
5
|
-
/**
|
|
6
|
-
* Cookie helpers for Next.js authentication flows.
|
|
7
|
-
*
|
|
8
|
-
* IMPORTANT: These functions can ONLY be used in:
|
|
9
|
-
* - Server Actions (functions marked with 'use server')
|
|
10
|
-
* - Route Handlers (files in app/api directory)
|
|
11
|
-
* - Server Components (async React components)
|
|
12
|
-
*
|
|
13
|
-
* They CANNOT be used in:
|
|
14
|
-
* - Client Components (marked with 'use client')
|
|
15
|
-
* - Middleware (use NextResponse.cookies instead)
|
|
16
|
-
* - Edge Runtime without proper configuration
|
|
17
|
-
*/
|
|
18
|
-
var logger = createLogger({ namespace: "fides-auth-next:cookies" });
|
|
19
|
-
/**
|
|
20
|
-
* Sets a cookie with the given name and value.
|
|
21
|
-
*
|
|
22
|
-
* @param name - Cookie name
|
|
23
|
-
* @param value - Cookie value
|
|
24
|
-
* @param options - Cookie options (defaults to session cookie options)
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* ```ts
|
|
28
|
-
* // In a server action or route handler
|
|
29
|
-
* await setAuthCookie('session', encryptedJwt);
|
|
30
|
-
*
|
|
31
|
-
* // With custom options
|
|
32
|
-
* await setAuthCookie(ACCESS_TOKEN_COOKIE_NAME, encryptedAccessToken, {
|
|
33
|
-
* maxAge: 60 * 60, // 1 hour
|
|
34
|
-
* });
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
async function setAuthCookie(name, value, options = defaultSessionCookieOptions) {
|
|
38
|
-
try {
|
|
39
|
-
const cookieStore = await cookies();
|
|
40
|
-
const cookieOptions = {
|
|
41
|
-
...defaultSessionCookieOptions,
|
|
42
|
-
...options
|
|
43
|
-
};
|
|
44
|
-
const size = assertCookieWithinLimit(name, value);
|
|
45
|
-
if (size >= COOKIE_INFO_BYTES) logger.info({
|
|
46
|
-
cookieName: name,
|
|
47
|
-
size
|
|
48
|
-
}, "Cookie approaching browser size limit");
|
|
49
|
-
cookieStore.set(name, value, cookieOptions);
|
|
50
|
-
logger.debug({
|
|
51
|
-
cookieName: name,
|
|
52
|
-
maxAge: cookieOptions.maxAge,
|
|
53
|
-
secure: cookieOptions.secure
|
|
54
|
-
}, "Cookie set successfully");
|
|
55
|
-
} catch (error) {
|
|
56
|
-
logger.error({
|
|
57
|
-
error,
|
|
58
|
-
cookieName: name
|
|
59
|
-
}, "Failed to set cookie");
|
|
60
|
-
throw error;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Gets a cookie value by name.
|
|
65
|
-
*
|
|
66
|
-
* @param name - Cookie name
|
|
67
|
-
* @returns Cookie value or null if not found
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* ```ts
|
|
71
|
-
* // In a server action or route handler
|
|
72
|
-
* const sessionCookie = await getAuthCookie('session');
|
|
73
|
-
* if (sessionCookie) {
|
|
74
|
-
* // Validate and use session
|
|
75
|
-
* }
|
|
76
|
-
* ```
|
|
77
|
-
*/
|
|
78
|
-
async function getAuthCookie(name) {
|
|
79
|
-
try {
|
|
80
|
-
const cookie = (await cookies()).get(name);
|
|
81
|
-
if (!cookie?.value) {
|
|
82
|
-
logger.debug({ cookieName: name }, "Cookie not found");
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
|
-
logger.debug({ cookieName: name }, "Cookie retrieved");
|
|
86
|
-
return cookie.value;
|
|
87
|
-
} catch (error) {
|
|
88
|
-
logger.error({
|
|
89
|
-
error,
|
|
90
|
-
cookieName: name
|
|
91
|
-
}, "Failed to get cookie");
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Deletes a cookie by name.
|
|
97
|
-
*
|
|
98
|
-
* @param name - Cookie name to delete
|
|
99
|
-
*
|
|
100
|
-
* @example
|
|
101
|
-
* ```ts
|
|
102
|
-
* // In a server action or route handler
|
|
103
|
-
* await deleteAuthCookie('session');
|
|
104
|
-
* ```
|
|
105
|
-
*/
|
|
106
|
-
async function deleteAuthCookie(name) {
|
|
107
|
-
try {
|
|
108
|
-
(await cookies()).delete(name);
|
|
109
|
-
logger.debug({ cookieName: name }, "Cookie deleted successfully");
|
|
110
|
-
} catch (error) {
|
|
111
|
-
logger.error({
|
|
112
|
-
error,
|
|
113
|
-
cookieName: name
|
|
114
|
-
}, "Failed to delete cookie");
|
|
115
|
-
throw error;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Deletes multiple cookies at once. The login transaction cookie is cleared by
|
|
120
|
-
* `clearTransaction` from `@eventuras/fides-auth/server`.
|
|
121
|
-
*
|
|
122
|
-
* @param names - Array of cookie names to delete
|
|
123
|
-
*
|
|
124
|
-
* @example
|
|
125
|
-
* ```ts
|
|
126
|
-
* await deleteAuthCookies(['session', ACCESS_TOKEN_COOKIE_NAME, ID_TOKEN_COOKIE_NAME]);
|
|
127
|
-
* ```
|
|
128
|
-
*/
|
|
129
|
-
async function deleteAuthCookies(names) {
|
|
130
|
-
try {
|
|
131
|
-
const cookieStore = await cookies();
|
|
132
|
-
for (const name of names) cookieStore.delete(name);
|
|
133
|
-
logger.debug({ cookieNames: names }, "Multiple cookies deleted successfully");
|
|
134
|
-
} catch (error) {
|
|
135
|
-
logger.error({
|
|
136
|
-
error,
|
|
137
|
-
cookieNames: names
|
|
138
|
-
}, "Failed to delete cookies");
|
|
139
|
-
throw error;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Sets the session cookie with proper security settings.
|
|
144
|
-
* This is a convenience wrapper around setAuthCookie.
|
|
145
|
-
*
|
|
146
|
-
* @param encryptedJwt - The encrypted JWT session token
|
|
147
|
-
* @param options - Optional cookie options (merged with defaults)
|
|
148
|
-
*
|
|
149
|
-
* @example
|
|
150
|
-
* ```ts
|
|
151
|
-
* const jwt = await createEncryptedJWT(session, secret);
|
|
152
|
-
* await setSessionCookie(jwt);
|
|
153
|
-
* ```
|
|
154
|
-
*/
|
|
155
|
-
async function setSessionCookie(encryptedJwt, options = {}) {
|
|
156
|
-
await setAuthCookie("session", encryptedJwt, {
|
|
157
|
-
...defaultSessionCookieOptions,
|
|
158
|
-
...options
|
|
159
|
-
});
|
|
160
|
-
logger.info("Session cookie set");
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Sets the access-token cookie ("session_at") with session cookie settings.
|
|
164
|
-
*
|
|
165
|
-
* @param encryptedJwt - The encrypted JWT wrapping the access token
|
|
166
|
-
* @param options - Optional cookie options (merged with session defaults)
|
|
167
|
-
*/
|
|
168
|
-
async function setAccessTokenCookie(encryptedJwt, options = {}) {
|
|
169
|
-
await setAuthCookie(ACCESS_TOKEN_COOKIE_NAME, encryptedJwt, {
|
|
170
|
-
...defaultSessionCookieOptions,
|
|
171
|
-
...options
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Gets the access-token cookie ("session_at") value, or null if absent.
|
|
176
|
-
*/
|
|
177
|
-
async function getAccessTokenCookie() {
|
|
178
|
-
return await getAuthCookie(ACCESS_TOKEN_COOKIE_NAME);
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Deletes the access-token cookie ("session_at").
|
|
182
|
-
*/
|
|
183
|
-
async function deleteAccessTokenCookie() {
|
|
184
|
-
await deleteAuthCookie(ACCESS_TOKEN_COOKIE_NAME);
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* Gets the current session cookie value.
|
|
188
|
-
* Returns null if no session cookie exists.
|
|
189
|
-
*
|
|
190
|
-
* @returns Encrypted JWT session token or null
|
|
191
|
-
*
|
|
192
|
-
* @example
|
|
193
|
-
* ```ts
|
|
194
|
-
* const sessionToken = await getSessionCookie();
|
|
195
|
-
* if (sessionToken) {
|
|
196
|
-
* const { status, session } = await validateSessionJwt(sessionToken, secret);
|
|
197
|
-
* // ...
|
|
198
|
-
* }
|
|
199
|
-
* ```
|
|
200
|
-
*/
|
|
201
|
-
async function getSessionCookie() {
|
|
202
|
-
return await getAuthCookie("session");
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Deletes the session cookie.
|
|
206
|
-
* Use this when logging out or when session validation fails.
|
|
207
|
-
*
|
|
208
|
-
* @example
|
|
209
|
-
* ```ts
|
|
210
|
-
* await deleteSessionCookie();
|
|
211
|
-
* redirect('/');
|
|
212
|
-
* ```
|
|
213
|
-
*/
|
|
214
|
-
async function deleteSessionCookie() {
|
|
215
|
-
await deleteAuthCookie("session");
|
|
216
|
-
logger.info("Session cookie deleted");
|
|
217
|
-
}
|
|
218
|
-
export { ACCESS_TOKEN_COOKIE_NAME$1 as ACCESS_TOKEN_COOKIE_NAME, COOKIE_INFO_BYTES$1 as COOKIE_INFO_BYTES, COOKIE_MAX_BYTES, CookieTooLargeError, ID_TOKEN_COOKIE_NAME, assertCookieWithinLimit$1 as assertCookieWithinLimit, cookieByteSize, defaultOAuthCookieOptions, defaultSessionCookieOptions$1 as defaultSessionCookieOptions, deleteAccessTokenCookie, deleteAuthCookie, deleteAuthCookies, deleteSessionCookie, getAccessTokenCookie, getAuthCookie, getSessionCookie, setAccessTokenCookie, setAuthCookie, setSessionCookie };
|
|
219
|
-
|
|
220
|
-
//# sourceMappingURL=cookies.js.map
|
package/dist/cookies.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cookies.js","names":[],"sources":["../src/cookies.ts"],"sourcesContent":["/**\n * Cookie helpers for Next.js authentication flows.\n *\n * IMPORTANT: These functions can ONLY be used in:\n * - Server Actions (functions marked with 'use server')\n * - Route Handlers (files in app/api directory)\n * - Server Components (async React components)\n *\n * They CANNOT be used in:\n * - Client Components (marked with 'use client')\n * - Middleware (use NextResponse.cookies instead)\n * - Edge Runtime without proper configuration\n */\n\nimport {\n ACCESS_TOKEN_COOKIE_NAME,\n COOKIE_INFO_BYTES,\n assertCookieWithinLimit,\n defaultSessionCookieOptions,\n} from '@eventuras/fides-auth/cookies';\nimport type { CookieOptions } from '@eventuras/fides-auth/cookies';\nimport { createLogger } from '@eventuras/fides-auth/logger';\nimport { cookies } from 'next/headers';\n\n// Re-export the framework-agnostic cookie attributes, limits, and size guard from\n// the core package so existing import sites keep working. This Next adapter only\n// owns the actual cookie I/O (via next/headers); the values and the size check\n// itself live in @eventuras/fides-auth/cookies.\nexport {\n COOKIE_INFO_BYTES,\n COOKIE_MAX_BYTES,\n CookieTooLargeError,\n ACCESS_TOKEN_COOKIE_NAME,\n ID_TOKEN_COOKIE_NAME,\n defaultSessionCookieOptions,\n defaultOAuthCookieOptions,\n cookieByteSize,\n assertCookieWithinLimit,\n} from '@eventuras/fides-auth/cookies';\nexport type { CookieOptions } from '@eventuras/fides-auth/cookies';\n\nconst logger = createLogger({ namespace: 'fides-auth-next:cookies' });\n\n/**\n * Sets a cookie with the given name and value.\n *\n * @param name - Cookie name\n * @param value - Cookie value\n * @param options - Cookie options (defaults to session cookie options)\n *\n * @example\n * ```ts\n * // In a server action or route handler\n * await setAuthCookie('session', encryptedJwt);\n *\n * // With custom options\n * await setAuthCookie(ACCESS_TOKEN_COOKIE_NAME, encryptedAccessToken, {\n * maxAge: 60 * 60, // 1 hour\n * });\n * ```\n */\nexport async function setAuthCookie(\n name: string,\n value: string,\n options: CookieOptions = defaultSessionCookieOptions\n): Promise<void> {\n try {\n const cookieStore = await cookies();\n const cookieOptions = { ...defaultSessionCookieOptions, ...options };\n\n // Fail loudly above the browser per-cookie limit (the browser would otherwise\n // drop the cookie silently). The size check lives in the core package.\n const size = assertCookieWithinLimit(name, value);\n if (size >= COOKIE_INFO_BYTES) {\n logger.info({ cookieName: name, size }, 'Cookie approaching browser size limit');\n }\n\n cookieStore.set(name, value, cookieOptions);\n\n logger.debug({\n cookieName: name,\n maxAge: cookieOptions.maxAge,\n secure: cookieOptions.secure\n }, 'Cookie set successfully');\n } catch (error) {\n logger.error({ error, cookieName: name }, 'Failed to set cookie');\n throw error;\n }\n}\n\n/**\n * Gets a cookie value by name.\n *\n * @param name - Cookie name\n * @returns Cookie value or null if not found\n *\n * @example\n * ```ts\n * // In a server action or route handler\n * const sessionCookie = await getAuthCookie('session');\n * if (sessionCookie) {\n * // Validate and use session\n * }\n * ```\n */\nexport async function getAuthCookie(name: string): Promise<string | null> {\n try {\n const cookieStore = await cookies();\n const cookie = cookieStore.get(name);\n\n if (!cookie?.value) {\n logger.debug({ cookieName: name }, 'Cookie not found');\n return null;\n }\n\n logger.debug({ cookieName: name }, 'Cookie retrieved');\n return cookie.value;\n } catch (error) {\n logger.error({ error, cookieName: name }, 'Failed to get cookie');\n return null;\n }\n}\n\n/**\n * Deletes a cookie by name.\n *\n * @param name - Cookie name to delete\n *\n * @example\n * ```ts\n * // In a server action or route handler\n * await deleteAuthCookie('session');\n * ```\n */\nexport async function deleteAuthCookie(name: string): Promise<void> {\n try {\n const cookieStore = await cookies();\n cookieStore.delete(name);\n\n logger.debug({ cookieName: name }, 'Cookie deleted successfully');\n } catch (error) {\n logger.error({ error, cookieName: name }, 'Failed to delete cookie');\n throw error;\n }\n}\n\n/**\n * Deletes multiple cookies at once. The login transaction cookie is cleared by\n * `clearTransaction` from `@eventuras/fides-auth/server`.\n *\n * @param names - Array of cookie names to delete\n *\n * @example\n * ```ts\n * await deleteAuthCookies(['session', ACCESS_TOKEN_COOKIE_NAME, ID_TOKEN_COOKIE_NAME]);\n * ```\n */\nexport async function deleteAuthCookies(names: string[]): Promise<void> {\n try {\n const cookieStore = await cookies();\n\n for (const name of names) {\n cookieStore.delete(name);\n }\n\n logger.debug({ cookieNames: names }, 'Multiple cookies deleted successfully');\n } catch (error) {\n logger.error({ error, cookieNames: names }, 'Failed to delete cookies');\n throw error;\n }\n}\n\n/**\n * Sets the session cookie with proper security settings.\n * This is a convenience wrapper around setAuthCookie.\n *\n * @param encryptedJwt - The encrypted JWT session token\n * @param options - Optional cookie options (merged with defaults)\n *\n * @example\n * ```ts\n * const jwt = await createEncryptedJWT(session, secret);\n * await setSessionCookie(jwt);\n * ```\n */\nexport async function setSessionCookie(\n encryptedJwt: string,\n options: Partial<CookieOptions> = {}\n): Promise<void> {\n await setAuthCookie('session', encryptedJwt, {\n ...defaultSessionCookieOptions,\n ...options,\n });\n\n logger.info('Session cookie set');\n}\n\n/**\n * Sets the access-token cookie (\"session_at\") with session cookie settings.\n *\n * @param encryptedJwt - The encrypted JWT wrapping the access token\n * @param options - Optional cookie options (merged with session defaults)\n */\nexport async function setAccessTokenCookie(\n encryptedJwt: string,\n options: Partial<CookieOptions> = {}\n): Promise<void> {\n await setAuthCookie(ACCESS_TOKEN_COOKIE_NAME, encryptedJwt, {\n ...defaultSessionCookieOptions,\n ...options,\n });\n}\n\n/**\n * Gets the access-token cookie (\"session_at\") value, or null if absent.\n */\nexport async function getAccessTokenCookie(): Promise<string | null> {\n return await getAuthCookie(ACCESS_TOKEN_COOKIE_NAME);\n}\n\n/**\n * Deletes the access-token cookie (\"session_at\").\n */\nexport async function deleteAccessTokenCookie(): Promise<void> {\n await deleteAuthCookie(ACCESS_TOKEN_COOKIE_NAME);\n}\n\n/**\n * Gets the current session cookie value.\n * Returns null if no session cookie exists.\n *\n * @returns Encrypted JWT session token or null\n *\n * @example\n * ```ts\n * const sessionToken = await getSessionCookie();\n * if (sessionToken) {\n * const { status, session } = await validateSessionJwt(sessionToken, secret);\n * // ...\n * }\n * ```\n */\nexport async function getSessionCookie(): Promise<string | null> {\n return await getAuthCookie('session');\n}\n\n/**\n * Deletes the session cookie.\n * Use this when logging out or when session validation fails.\n *\n * @example\n * ```ts\n * await deleteSessionCookie();\n * redirect('/');\n * ```\n */\nexport async function deleteSessionCookie(): Promise<void> {\n await deleteAuthCookie('session');\n logger.info('Session cookie deleted');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAyCA,IAAM,SAAS,aAAa,EAAE,WAAW,0BAA0B,CAAC;;;;;;;;;;;;;;;;;;;AAoBpE,eAAsB,cACpB,MACA,OACA,UAAyB,6BACV;CACf,IAAI;EACF,MAAM,cAAc,MAAM,QAAQ;EAClC,MAAM,gBAAgB;GAAE,GAAG;GAA6B,GAAG;EAAQ;EAInE,MAAM,OAAO,wBAAwB,MAAM,KAAK;EAChD,IAAI,QAAQ,mBACV,OAAO,KAAK;GAAE,YAAY;GAAM;EAAK,GAAG,uCAAuC;EAGjF,YAAY,IAAI,MAAM,OAAO,aAAa;EAE1C,OAAO,MAAM;GACX,YAAY;GACZ,QAAQ,cAAc;GACtB,QAAQ,cAAc;EACxB,GAAG,yBAAyB;CAC9B,SAAS,OAAO;EACd,OAAO,MAAM;GAAE;GAAO,YAAY;EAAK,GAAG,sBAAsB;EAChE,MAAM;CACR;AACF;;;;;;;;;;;;;;;;AAiBA,eAAsB,cAAc,MAAsC;CACxE,IAAI;EAEF,MAAM,UAAS,MADW,QAAQ,EAAA,CACP,IAAI,IAAI;EAEnC,IAAI,CAAC,QAAQ,OAAO;GAClB,OAAO,MAAM,EAAE,YAAY,KAAK,GAAG,kBAAkB;GACrD,OAAO;EACT;EAEA,OAAO,MAAM,EAAE,YAAY,KAAK,GAAG,kBAAkB;EACrD,OAAO,OAAO;CAChB,SAAS,OAAO;EACd,OAAO,MAAM;GAAE;GAAO,YAAY;EAAK,GAAG,sBAAsB;EAChE,OAAO;CACT;AACF;;;;;;;;;;;;AAaA,eAAsB,iBAAiB,MAA6B;CAClE,IAAI;EAEF,CAAA,MAD0B,QAAQ,EAAA,CACtB,OAAO,IAAI;EAEvB,OAAO,MAAM,EAAE,YAAY,KAAK,GAAG,6BAA6B;CAClE,SAAS,OAAO;EACd,OAAO,MAAM;GAAE;GAAO,YAAY;EAAK,GAAG,yBAAyB;EACnE,MAAM;CACR;AACF;;;;;;;;;;;;AAaA,eAAsB,kBAAkB,OAAgC;CACtE,IAAI;EACF,MAAM,cAAc,MAAM,QAAQ;EAElC,KAAK,MAAM,QAAQ,OACjB,YAAY,OAAO,IAAI;EAGzB,OAAO,MAAM,EAAE,aAAa,MAAM,GAAG,uCAAuC;CAC9E,SAAS,OAAO;EACd,OAAO,MAAM;GAAE;GAAO,aAAa;EAAM,GAAG,0BAA0B;EACtE,MAAM;CACR;AACF;;;;;;;;;;;;;;AAeA,eAAsB,iBACpB,cACA,UAAkC,CAAC,GACpB;CACf,MAAM,cAAc,WAAW,cAAc;EAC3C,GAAG;EACH,GAAG;CACL,CAAC;CAED,OAAO,KAAK,oBAAoB;AAClC;;;;;;;AAQA,eAAsB,qBACpB,cACA,UAAkC,CAAC,GACpB;CACf,MAAM,cAAc,0BAA0B,cAAc;EAC1D,GAAG;EACH,GAAG;CACL,CAAC;AACH;;;;AAKA,eAAsB,uBAA+C;CACnE,OAAO,MAAM,cAAc,wBAAwB;AACrD;;;;AAKA,eAAsB,0BAAyC;CAC7D,MAAM,iBAAiB,wBAAwB;AACjD;;;;;;;;;;;;;;;;AAiBA,eAAsB,mBAA2C;CAC/D,OAAO,MAAM,cAAc,SAAS;AACtC;;;;;;;;;;;AAYA,eAAsB,sBAAqC;CACzD,MAAM,iBAAiB,SAAS;CAChC,OAAO,KAAK,wBAAwB;AACtC"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Server-side heartbeat handler for Next.js route handlers — a thin wrapper over
|
|
3
|
-
* the framework-agnostic handler in `@eventuras/fides-auth/server`, wiring it to
|
|
4
|
-
* the Next cookie store and the global POST rate limiter.
|
|
5
|
-
*
|
|
6
|
-
* Pairs with the client-side `useHeartbeat` hook: when the user is active, the
|
|
7
|
-
* client POSTs here, and this handler exchanges the current refresh token for a
|
|
8
|
-
* fresh access token (and rotated refresh token, if the IdP rotates).
|
|
9
|
-
*/
|
|
10
|
-
import { type SessionPersistence, type SessionSecret } from '@eventuras/fides-auth/server';
|
|
11
|
-
import type { OAuthConfig } from '@eventuras/fides-auth/oauth';
|
|
12
|
-
export interface HeartbeatHandlerConfig {
|
|
13
|
-
/** OAuth/OIDC configuration used to refresh the access token. */
|
|
14
|
-
oauthConfig: OAuthConfig;
|
|
15
|
-
/** Session encryption secret. */
|
|
16
|
-
secret: SessionSecret;
|
|
17
|
-
/** Where the session lives. Defaults to the cookies under `secret`; see `serverPersistence`. */
|
|
18
|
-
persistence?: SessionPersistence;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Handles a heartbeat request in a Next.js route handler. `createFidesAuth`
|
|
22
|
-
* returns this with `oauthConfig` and `secret` bound.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```ts
|
|
26
|
-
* // app/(auth)/api/auth/heartbeat/route.ts
|
|
27
|
-
* import { handleHeartbeat } from '@eventuras/fides-auth-next/heartbeat-handler';
|
|
28
|
-
* import { oauthConfig } from '@/utils/oauthConfig';
|
|
29
|
-
*
|
|
30
|
-
* export async function POST(request: Request) {
|
|
31
|
-
* return handleHeartbeat(request, { oauthConfig, secret: process.env.SESSION_SECRET! });
|
|
32
|
-
* }
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
export declare function handleHeartbeat(request: Request, config: HeartbeatHandlerConfig): Promise<Response>;
|
|
36
|
-
//# sourceMappingURL=heartbeat-handler.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"heartbeat-handler.d.ts","sourceRoot":"","sources":["../src/heartbeat-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,aAAa,EACnB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAK/D,MAAM,WAAW,sBAAsB;IACrC,iEAAiE;IACjE,WAAW,EAAE,WAAW,CAAC;IAEzB,iCAAiC;IACjC,MAAM,EAAE,aAAa,CAAC;IAEtB,gGAAgG;IAChG,WAAW,CAAC,EAAE,kBAAkB,CAAC;CAClC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,sBAAsB,GAC7B,OAAO,CAAC,QAAQ,CAAC,CAQnB"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { nextCookieStore } from "./cookie-store.js";
|
|
2
|
-
import { globalPOSTRateLimit } from "./request.js";
|
|
3
|
-
import { handleHeartbeat as handleHeartbeat$1 } from "@eventuras/fides-auth/server";
|
|
4
|
-
// src/heartbeat-handler.ts
|
|
5
|
-
/**
|
|
6
|
-
* Server-side heartbeat handler for Next.js route handlers — a thin wrapper over
|
|
7
|
-
* the framework-agnostic handler in `@eventuras/fides-auth/server`, wiring it to
|
|
8
|
-
* the Next cookie store and the global POST rate limiter.
|
|
9
|
-
*
|
|
10
|
-
* Pairs with the client-side `useHeartbeat` hook: when the user is active, the
|
|
11
|
-
* client POSTs here, and this handler exchanges the current refresh token for a
|
|
12
|
-
* fresh access token (and rotated refresh token, if the IdP rotates).
|
|
13
|
-
*/
|
|
14
|
-
/**
|
|
15
|
-
* Handles a heartbeat request in a Next.js route handler. `createFidesAuth`
|
|
16
|
-
* returns this with `oauthConfig` and `secret` bound.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```ts
|
|
20
|
-
* // app/(auth)/api/auth/heartbeat/route.ts
|
|
21
|
-
* import { handleHeartbeat } from '@eventuras/fides-auth-next/heartbeat-handler';
|
|
22
|
-
* import { oauthConfig } from '@/utils/oauthConfig';
|
|
23
|
-
*
|
|
24
|
-
* export async function POST(request: Request) {
|
|
25
|
-
* return handleHeartbeat(request, { oauthConfig, secret: process.env.SESSION_SECRET! });
|
|
26
|
-
* }
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
async function handleHeartbeat(request, config) {
|
|
30
|
-
return handleHeartbeat$1(request, {
|
|
31
|
-
oauthConfig: config.oauthConfig,
|
|
32
|
-
secret: config.secret,
|
|
33
|
-
persistence: config.persistence,
|
|
34
|
-
cookies: await nextCookieStore(),
|
|
35
|
-
rateLimit: globalPOSTRateLimit
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
export { handleHeartbeat };
|
|
39
|
-
|
|
40
|
-
//# sourceMappingURL=heartbeat-handler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"heartbeat-handler.js","names":["coreHandleHeartbeat"],"sources":["../src/heartbeat-handler.ts"],"sourcesContent":["/**\n * Server-side heartbeat handler for Next.js route handlers — a thin wrapper over\n * the framework-agnostic handler in `@eventuras/fides-auth/server`, wiring it to\n * the Next cookie store and the global POST rate limiter.\n *\n * Pairs with the client-side `useHeartbeat` hook: when the user is active, the\n * client POSTs here, and this handler exchanges the current refresh token for a\n * fresh access token (and rotated refresh token, if the IdP rotates).\n */\n\nimport {\n handleHeartbeat as coreHandleHeartbeat,\n type SessionPersistence,\n type SessionSecret,\n} from '@eventuras/fides-auth/server';\nimport type { OAuthConfig } from '@eventuras/fides-auth/oauth';\n\nimport { nextCookieStore } from './cookie-store.js';\nimport { globalPOSTRateLimit } from './request.js';\n\nexport interface HeartbeatHandlerConfig {\n /** OAuth/OIDC configuration used to refresh the access token. */\n oauthConfig: OAuthConfig;\n\n /** Session encryption secret. */\n secret: SessionSecret;\n\n /** Where the session lives. Defaults to the cookies under `secret`; see `serverPersistence`. */\n persistence?: SessionPersistence;\n}\n\n/**\n * Handles a heartbeat request in a Next.js route handler. `createFidesAuth`\n * returns this with `oauthConfig` and `secret` bound.\n *\n * @example\n * ```ts\n * // app/(auth)/api/auth/heartbeat/route.ts\n * import { handleHeartbeat } from '@eventuras/fides-auth-next/heartbeat-handler';\n * import { oauthConfig } from '@/utils/oauthConfig';\n *\n * export async function POST(request: Request) {\n * return handleHeartbeat(request, { oauthConfig, secret: process.env.SESSION_SECRET! });\n * }\n * ```\n */\nexport async function handleHeartbeat(\n request: Request,\n config: HeartbeatHandlerConfig,\n): Promise<Response> {\n return coreHandleHeartbeat(request, {\n oauthConfig: config.oauthConfig,\n secret: config.secret,\n persistence: config.persistence,\n cookies: await nextCookieStore(),\n rateLimit: globalPOSTRateLimit,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,eAAsB,gBACpB,SACA,QACmB;CACnB,OAAOA,kBAAoB,SAAS;EAClC,aAAa,OAAO;EACpB,QAAQ,OAAO;EACf,aAAa,OAAO;EACpB,SAAS,MAAM,gBAAgB;EAC/B,WAAW;CACb,CAAC;AACH"}
|
package/dist/oidc-callback.d.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OIDC callback handler for Next.js route handlers — a thin wrapper over the
|
|
3
|
-
* framework-agnostic handler in `@eventuras/fides-auth/server`, wiring it to the
|
|
4
|
-
* Next cookie store and the global GET rate limiter.
|
|
5
|
-
*/
|
|
6
|
-
import { type SessionPersistence, type SessionSecret } from '@eventuras/fides-auth/server';
|
|
7
|
-
import type { MapSession, OAuthConfig } from '@eventuras/fides-auth/oauth';
|
|
8
|
-
export interface OidcCallbackConfig {
|
|
9
|
-
/** OAuth/OIDC configuration (issuer, clientId, clientSecret, redirect_uri, scope) */
|
|
10
|
-
oauthConfig: OAuthConfig;
|
|
11
|
-
/** Opens the login transaction and encrypts the session. Must match the login's. */
|
|
12
|
-
secret: SessionSecret;
|
|
13
|
-
/** Where the session lives. Defaults to the cookies under `secret`; see `serverPersistence`. */
|
|
14
|
-
persistence?: SessionPersistence;
|
|
15
|
-
/** Public application URL (used to reconstruct the callback URL and validate redirects) */
|
|
16
|
-
applicationUrl: string;
|
|
17
|
-
/**
|
|
18
|
-
* Name of the ID token claim that contains user roles.
|
|
19
|
-
* @default 'roles'
|
|
20
|
-
*/
|
|
21
|
-
rolesClaim?: string;
|
|
22
|
-
/** Changes the session before it is stored, e.g. to add `data`. See {@link MapSession}. */
|
|
23
|
-
mapSession?: MapSession;
|
|
24
|
-
/**
|
|
25
|
-
* Default path to redirect to after login if no returnTo cookie is set.
|
|
26
|
-
* @default '/'
|
|
27
|
-
*/
|
|
28
|
-
defaultRedirectPath?: string;
|
|
29
|
-
/**
|
|
30
|
-
* Optional function to validate the returnTo path.
|
|
31
|
-
* If not provided, only same-origin paths are allowed.
|
|
32
|
-
*/
|
|
33
|
-
validateReturnTo?: (path: string) => boolean;
|
|
34
|
-
/**
|
|
35
|
-
* Reserved for backwards compatibility. Currently not applied — the session
|
|
36
|
-
* cookie lifetime is fixed by the default cookie options.
|
|
37
|
-
*/
|
|
38
|
-
sessionDurationDays?: number;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Handles the OIDC callback in a Next.js route handler. `createFidesAuth` returns
|
|
42
|
-
* this with `oauthConfig` and `secret` bound.
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* ```ts
|
|
46
|
-
* // In app/api/auth/callback/oidc/route.ts
|
|
47
|
-
* import { handleOidcCallback } from '@eventuras/fides-auth-next/oidc-callback';
|
|
48
|
-
*
|
|
49
|
-
* export async function GET(request: Request) {
|
|
50
|
-
* return handleOidcCallback(request, {
|
|
51
|
-
* oauthConfig,
|
|
52
|
-
* secret: process.env.SESSION_SECRET!,
|
|
53
|
-
* applicationUrl: 'https://example.com',
|
|
54
|
-
* rolesClaim: 'roles',
|
|
55
|
-
* });
|
|
56
|
-
* }
|
|
57
|
-
* ```
|
|
58
|
-
*/
|
|
59
|
-
export declare function handleOidcCallback(request: Request, config: OidcCallbackConfig): Promise<Response>;
|
|
60
|
-
//# sourceMappingURL=oidc-callback.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"oidc-callback.d.ts","sourceRoot":"","sources":["../src/oidc-callback.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,aAAa,EACnB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAK3E,MAAM,WAAW,kBAAkB;IACjC,qFAAqF;IACrF,WAAW,EAAE,WAAW,CAAC;IAEzB,oFAAoF;IACpF,MAAM,EAAE,aAAa,CAAC;IAEtB,gGAAgG;IAChG,WAAW,CAAC,EAAE,kBAAkB,CAAC;IAEjC,2FAA2F;IAC3F,cAAc,EAAE,MAAM,CAAC;IAEvB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,2FAA2F;IAC3F,UAAU,CAAC,EAAE,UAAU,CAAC;IAExB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IAE7C;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,QAAQ,CAAC,CAenB"}
|
package/dist/oidc-callback.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { nextCookieStore } from "./cookie-store.js";
|
|
2
|
-
import { globalGETRateLimit } from "./request.js";
|
|
3
|
-
import { handleOidcCallback as handleOidcCallback$1 } from "@eventuras/fides-auth/server";
|
|
4
|
-
// src/oidc-callback.ts
|
|
5
|
-
/**
|
|
6
|
-
* OIDC callback handler for Next.js route handlers — a thin wrapper over the
|
|
7
|
-
* framework-agnostic handler in `@eventuras/fides-auth/server`, wiring it to the
|
|
8
|
-
* Next cookie store and the global GET rate limiter.
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Handles the OIDC callback in a Next.js route handler. `createFidesAuth` returns
|
|
12
|
-
* this with `oauthConfig` and `secret` bound.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```ts
|
|
16
|
-
* // In app/api/auth/callback/oidc/route.ts
|
|
17
|
-
* import { handleOidcCallback } from '@eventuras/fides-auth-next/oidc-callback';
|
|
18
|
-
*
|
|
19
|
-
* export async function GET(request: Request) {
|
|
20
|
-
* return handleOidcCallback(request, {
|
|
21
|
-
* oauthConfig,
|
|
22
|
-
* secret: process.env.SESSION_SECRET!,
|
|
23
|
-
* applicationUrl: 'https://example.com',
|
|
24
|
-
* rolesClaim: 'roles',
|
|
25
|
-
* });
|
|
26
|
-
* }
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
async function handleOidcCallback(request, config) {
|
|
30
|
-
return handleOidcCallback$1(request, {
|
|
31
|
-
oauthConfig: config.oauthConfig,
|
|
32
|
-
secret: config.secret,
|
|
33
|
-
persistence: config.persistence,
|
|
34
|
-
applicationUrl: config.applicationUrl,
|
|
35
|
-
rolesClaim: config.rolesClaim,
|
|
36
|
-
mapSession: config.mapSession,
|
|
37
|
-
defaultRedirectPath: config.defaultRedirectPath,
|
|
38
|
-
validateReturnTo: config.validateReturnTo,
|
|
39
|
-
cookies: await nextCookieStore(),
|
|
40
|
-
rateLimit: globalGETRateLimit
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
export { handleOidcCallback };
|
|
44
|
-
|
|
45
|
-
//# sourceMappingURL=oidc-callback.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"oidc-callback.js","names":["coreHandleOidcCallback"],"sources":["../src/oidc-callback.ts"],"sourcesContent":["/**\n * OIDC callback handler for Next.js route handlers — a thin wrapper over the\n * framework-agnostic handler in `@eventuras/fides-auth/server`, wiring it to the\n * Next cookie store and the global GET rate limiter.\n */\n\nimport {\n handleOidcCallback as coreHandleOidcCallback,\n type SessionPersistence,\n type SessionSecret,\n} from '@eventuras/fides-auth/server';\nimport type { MapSession, OAuthConfig } from '@eventuras/fides-auth/oauth';\n\nimport { nextCookieStore } from './cookie-store.js';\nimport { globalGETRateLimit } from './request.js';\n\nexport interface OidcCallbackConfig {\n /** OAuth/OIDC configuration (issuer, clientId, clientSecret, redirect_uri, scope) */\n oauthConfig: OAuthConfig;\n\n /** Opens the login transaction and encrypts the session. Must match the login's. */\n secret: SessionSecret;\n\n /** Where the session lives. Defaults to the cookies under `secret`; see `serverPersistence`. */\n persistence?: SessionPersistence;\n\n /** Public application URL (used to reconstruct the callback URL and validate redirects) */\n applicationUrl: string;\n\n /**\n * Name of the ID token claim that contains user roles.\n * @default 'roles'\n */\n rolesClaim?: string;\n\n /** Changes the session before it is stored, e.g. to add `data`. See {@link MapSession}. */\n mapSession?: MapSession;\n\n /**\n * Default path to redirect to after login if no returnTo cookie is set.\n * @default '/'\n */\n defaultRedirectPath?: string;\n\n /**\n * Optional function to validate the returnTo path.\n * If not provided, only same-origin paths are allowed.\n */\n validateReturnTo?: (path: string) => boolean;\n\n /**\n * Reserved for backwards compatibility. Currently not applied — the session\n * cookie lifetime is fixed by the default cookie options.\n */\n sessionDurationDays?: number;\n}\n\n/**\n * Handles the OIDC callback in a Next.js route handler. `createFidesAuth` returns\n * this with `oauthConfig` and `secret` bound.\n *\n * @example\n * ```ts\n * // In app/api/auth/callback/oidc/route.ts\n * import { handleOidcCallback } from '@eventuras/fides-auth-next/oidc-callback';\n *\n * export async function GET(request: Request) {\n * return handleOidcCallback(request, {\n * oauthConfig,\n * secret: process.env.SESSION_SECRET!,\n * applicationUrl: 'https://example.com',\n * rolesClaim: 'roles',\n * });\n * }\n * ```\n */\nexport async function handleOidcCallback(\n request: Request,\n config: OidcCallbackConfig,\n): Promise<Response> {\n // Map explicitly rather than spreading: sessionDurationDays is accepted for\n // backwards compatibility but the core handler doesn't take it.\n return coreHandleOidcCallback(request, {\n oauthConfig: config.oauthConfig,\n secret: config.secret,\n persistence: config.persistence,\n applicationUrl: config.applicationUrl,\n rolesClaim: config.rolesClaim,\n mapSession: config.mapSession,\n defaultRedirectPath: config.defaultRedirectPath,\n validateReturnTo: config.validateReturnTo,\n cookies: await nextCookieStore(),\n rateLimit: globalGETRateLimit,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4EA,eAAsB,mBACpB,SACA,QACmB;CAGnB,OAAOA,qBAAuB,SAAS;EACrC,aAAa,OAAO;EACpB,QAAQ,OAAO;EACf,aAAa,OAAO;EACpB,gBAAgB,OAAO;EACvB,YAAY,OAAO;EACnB,YAAY,OAAO;EACnB,qBAAqB,OAAO;EAC5B,kBAAkB,OAAO;EACzB,SAAS,MAAM,gBAAgB;EAC/B,WAAW;CACb,CAAC;AACH"}
|
package/dist/oidc-login.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OIDC login initiation for Next.js route handlers — a thin wrapper over the
|
|
3
|
-
* framework-agnostic handler in `@eventuras/fides-auth/server`, wiring it to the
|
|
4
|
-
* Next cookie store and the global GET rate limiter.
|
|
5
|
-
*/
|
|
6
|
-
import { type OidcLoginConfig as CoreOidcLoginConfig, type SessionSecret } from '@eventuras/fides-auth/server';
|
|
7
|
-
import type { OAuthConfig } from '@eventuras/fides-auth/oauth';
|
|
8
|
-
export interface OidcLoginConfig {
|
|
9
|
-
/** OAuth/OIDC configuration */
|
|
10
|
-
oauthConfig: OAuthConfig;
|
|
11
|
-
/** Seals the login transaction. Must match the callback's. */
|
|
12
|
-
secret: SessionSecret;
|
|
13
|
-
/**
|
|
14
|
-
* Validates and sanitizes the returnTo parameter.
|
|
15
|
-
* Should return a safe path or null to use the default.
|
|
16
|
-
* @default Only allows relative paths starting with /
|
|
17
|
-
*/
|
|
18
|
-
validateReturnTo?: (rawReturnTo: string) => string | null;
|
|
19
|
-
/** Per-request authorization parameters, e.g. `prompt` or `login_hint`. Reserved keys throw. */
|
|
20
|
-
authorizationParameters?: CoreOidcLoginConfig['authorizationParameters'];
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Handles OIDC login initiation in a Next.js route handler. `createFidesAuth`
|
|
24
|
-
* returns this with `oauthConfig` and `secret` bound.
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* ```ts
|
|
28
|
-
* // In app/api/auth/login/route.ts
|
|
29
|
-
* import { handleOidcLogin } from '@eventuras/fides-auth-next/oidc-login';
|
|
30
|
-
*
|
|
31
|
-
* export async function GET(request: Request) {
|
|
32
|
-
* return handleOidcLogin(request, { oauthConfig, secret: process.env.SESSION_SECRET! });
|
|
33
|
-
* }
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
export declare function handleOidcLogin(request: Request, config: OidcLoginConfig): Promise<Response>;
|
|
37
|
-
//# sourceMappingURL=oidc-login.d.ts.map
|
package/dist/oidc-login.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"oidc-login.d.ts","sourceRoot":"","sources":["../src/oidc-login.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,KAAK,eAAe,IAAI,mBAAmB,EAC3C,KAAK,aAAa,EACnB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAK/D,MAAM,WAAW,eAAe;IAC9B,+BAA+B;IAC/B,WAAW,EAAE,WAAW,CAAC;IAEzB,8DAA8D;IAC9D,MAAM,EAAE,aAAa,CAAC;IAEtB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;IAE1D,gGAAgG;IAChG,uBAAuB,CAAC,EAAE,mBAAmB,CAAC,yBAAyB,CAAC,CAAC;CAC1E;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,QAAQ,CAAC,CASnB"}
|
package/dist/oidc-login.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { nextCookieStore } from "./cookie-store.js";
|
|
2
|
-
import { globalGETRateLimit } from "./request.js";
|
|
3
|
-
import { handleOidcLogin as handleOidcLogin$1 } from "@eventuras/fides-auth/server";
|
|
4
|
-
// src/oidc-login.ts
|
|
5
|
-
/**
|
|
6
|
-
* OIDC login initiation for Next.js route handlers — a thin wrapper over the
|
|
7
|
-
* framework-agnostic handler in `@eventuras/fides-auth/server`, wiring it to the
|
|
8
|
-
* Next cookie store and the global GET rate limiter.
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Handles OIDC login initiation in a Next.js route handler. `createFidesAuth`
|
|
12
|
-
* returns this with `oauthConfig` and `secret` bound.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```ts
|
|
16
|
-
* // In app/api/auth/login/route.ts
|
|
17
|
-
* import { handleOidcLogin } from '@eventuras/fides-auth-next/oidc-login';
|
|
18
|
-
*
|
|
19
|
-
* export async function GET(request: Request) {
|
|
20
|
-
* return handleOidcLogin(request, { oauthConfig, secret: process.env.SESSION_SECRET! });
|
|
21
|
-
* }
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
async function handleOidcLogin(request, config) {
|
|
25
|
-
return handleOidcLogin$1(request, {
|
|
26
|
-
oauthConfig: config.oauthConfig,
|
|
27
|
-
secret: config.secret,
|
|
28
|
-
validateReturnTo: config.validateReturnTo,
|
|
29
|
-
authorizationParameters: config.authorizationParameters,
|
|
30
|
-
cookies: await nextCookieStore(),
|
|
31
|
-
rateLimit: globalGETRateLimit
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
export { handleOidcLogin };
|
|
35
|
-
|
|
36
|
-
//# sourceMappingURL=oidc-login.js.map
|
package/dist/oidc-login.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"oidc-login.js","names":["coreHandleOidcLogin"],"sources":["../src/oidc-login.ts"],"sourcesContent":["/**\n * OIDC login initiation for Next.js route handlers — a thin wrapper over the\n * framework-agnostic handler in `@eventuras/fides-auth/server`, wiring it to the\n * Next cookie store and the global GET rate limiter.\n */\n\nimport {\n handleOidcLogin as coreHandleOidcLogin,\n type OidcLoginConfig as CoreOidcLoginConfig,\n type SessionSecret,\n} from '@eventuras/fides-auth/server';\nimport type { OAuthConfig } from '@eventuras/fides-auth/oauth';\n\nimport { nextCookieStore } from './cookie-store.js';\nimport { globalGETRateLimit } from './request.js';\n\nexport interface OidcLoginConfig {\n /** OAuth/OIDC configuration */\n oauthConfig: OAuthConfig;\n\n /** Seals the login transaction. Must match the callback's. */\n secret: SessionSecret;\n\n /**\n * Validates and sanitizes the returnTo parameter.\n * Should return a safe path or null to use the default.\n * @default Only allows relative paths starting with /\n */\n validateReturnTo?: (rawReturnTo: string) => string | null;\n\n /** Per-request authorization parameters, e.g. `prompt` or `login_hint`. Reserved keys throw. */\n authorizationParameters?: CoreOidcLoginConfig['authorizationParameters'];\n}\n\n/**\n * Handles OIDC login initiation in a Next.js route handler. `createFidesAuth`\n * returns this with `oauthConfig` and `secret` bound.\n *\n * @example\n * ```ts\n * // In app/api/auth/login/route.ts\n * import { handleOidcLogin } from '@eventuras/fides-auth-next/oidc-login';\n *\n * export async function GET(request: Request) {\n * return handleOidcLogin(request, { oauthConfig, secret: process.env.SESSION_SECRET! });\n * }\n * ```\n */\nexport async function handleOidcLogin(\n request: Request,\n config: OidcLoginConfig,\n): Promise<Response> {\n return coreHandleOidcLogin(request, {\n oauthConfig: config.oauthConfig,\n secret: config.secret,\n validateReturnTo: config.validateReturnTo,\n authorizationParameters: config.authorizationParameters,\n cookies: await nextCookieStore(),\n rateLimit: globalGETRateLimit,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAgDA,eAAsB,gBACpB,SACA,QACmB;CACnB,OAAOA,kBAAoB,SAAS;EAClC,aAAa,OAAO;EACpB,QAAQ,OAAO;EACf,kBAAkB,OAAO;EACzB,yBAAyB,OAAO;EAChC,SAAS,MAAM,gBAAgB;EAC/B,WAAW;CACb,CAAC;AACH"}
|
package/dist/oidc-logout.d.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* RP-initiated logout for Next.js route handlers — a thin wrapper over the
|
|
3
|
-
* framework-agnostic handler in `@eventuras/fides-auth/server`, wiring it to the
|
|
4
|
-
* Next cookie store and the global POST rate limiter.
|
|
5
|
-
*/
|
|
6
|
-
import { type SessionPersistence, type SessionSecret } from '@eventuras/fides-auth/server';
|
|
7
|
-
import type { OAuthConfig } from '@eventuras/fides-auth/oauth';
|
|
8
|
-
export interface OidcLogoutConfig {
|
|
9
|
-
/** OAuth/OIDC configuration */
|
|
10
|
-
oauthConfig: OAuthConfig;
|
|
11
|
-
/** Session encryption secret. */
|
|
12
|
-
secret: SessionSecret;
|
|
13
|
-
/** Where the session lives. Defaults to the cookies under `secret`; see `serverPersistence`. */
|
|
14
|
-
persistence?: SessionPersistence;
|
|
15
|
-
/**
|
|
16
|
-
* URI the provider redirects back to after logout. Must be registered with the
|
|
17
|
-
* provider as a post-logout redirect URI.
|
|
18
|
-
*/
|
|
19
|
-
postLogoutRedirectUri: string;
|
|
20
|
-
/** Opaque value echoed back on the post-logout redirect. */
|
|
21
|
-
state?: string;
|
|
22
|
-
/** `logout_hint`, when the provider documents one. */
|
|
23
|
-
logoutHint?: string;
|
|
24
|
-
/** Whether to send `client_id`. Default true. */
|
|
25
|
-
includeClientId?: boolean;
|
|
26
|
-
/** Request methods that may trigger a logout. @default ['POST'] */
|
|
27
|
-
allowedMethods?: string[];
|
|
28
|
-
/** Public application URL, used to check the `Origin` header behind a proxy. */
|
|
29
|
-
applicationUrl?: string;
|
|
30
|
-
/**
|
|
31
|
-
* Where to send the user when the provider advertises no end_session_endpoint.
|
|
32
|
-
* @default postLogoutRedirectUri
|
|
33
|
-
*/
|
|
34
|
-
fallbackRedirectUri?: string;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Handles logout in a Next.js route handler: clears the session cookies and
|
|
38
|
-
* redirects to the provider's end-session endpoint with `id_token_hint`.
|
|
39
|
-
* `createFidesAuth` returns this with `oauthConfig` and `secret` bound.
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* ```ts
|
|
43
|
-
* // In app/api/auth/logout/route.ts
|
|
44
|
-
* import { handleOidcLogout } from '@eventuras/fides-auth-next/oidc-logout';
|
|
45
|
-
*
|
|
46
|
-
* export async function POST(request: Request) {
|
|
47
|
-
* return handleOidcLogout(request, {
|
|
48
|
-
* oauthConfig,
|
|
49
|
-
* secret: process.env.SESSION_SECRET!,
|
|
50
|
-
* postLogoutRedirectUri: 'https://example.com/',
|
|
51
|
-
* });
|
|
52
|
-
* }
|
|
53
|
-
* ```
|
|
54
|
-
*/
|
|
55
|
-
export declare function handleOidcLogout(request: Request, config: OidcLogoutConfig): Promise<Response>;
|
|
56
|
-
//# sourceMappingURL=oidc-logout.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"oidc-logout.d.ts","sourceRoot":"","sources":["../src/oidc-logout.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,aAAa,EACnB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAK/D,MAAM,WAAW,gBAAgB;IAC/B,+BAA+B;IAC/B,WAAW,EAAE,WAAW,CAAC;IAEzB,iCAAiC;IACjC,MAAM,EAAE,aAAa,CAAC;IAEtB,gGAAgG;IAChG,WAAW,CAAC,EAAE,kBAAkB,CAAC;IAEjC;;;OAGG;IACH,qBAAqB,EAAE,MAAM,CAAC;IAE9B,4DAA4D;IAC5D,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,sDAAsD;IACtD,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,iDAAiD;IACjD,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B,mEAAmE;IACnE,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAE1B,gFAAgF;IAChF,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,QAAQ,CAAC,CAenB"}
|
package/dist/oidc-logout.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { nextCookieStore } from "./cookie-store.js";
|
|
2
|
-
import { globalPOSTRateLimit } from "./request.js";
|
|
3
|
-
import { handleOidcLogout as handleOidcLogout$1 } from "@eventuras/fides-auth/server";
|
|
4
|
-
// src/oidc-logout.ts
|
|
5
|
-
/**
|
|
6
|
-
* RP-initiated logout for Next.js route handlers — a thin wrapper over the
|
|
7
|
-
* framework-agnostic handler in `@eventuras/fides-auth/server`, wiring it to the
|
|
8
|
-
* Next cookie store and the global POST rate limiter.
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Handles logout in a Next.js route handler: clears the session cookies and
|
|
12
|
-
* redirects to the provider's end-session endpoint with `id_token_hint`.
|
|
13
|
-
* `createFidesAuth` returns this with `oauthConfig` and `secret` bound.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```ts
|
|
17
|
-
* // In app/api/auth/logout/route.ts
|
|
18
|
-
* import { handleOidcLogout } from '@eventuras/fides-auth-next/oidc-logout';
|
|
19
|
-
*
|
|
20
|
-
* export async function POST(request: Request) {
|
|
21
|
-
* return handleOidcLogout(request, {
|
|
22
|
-
* oauthConfig,
|
|
23
|
-
* secret: process.env.SESSION_SECRET!,
|
|
24
|
-
* postLogoutRedirectUri: 'https://example.com/',
|
|
25
|
-
* });
|
|
26
|
-
* }
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
async function handleOidcLogout(request, config) {
|
|
30
|
-
return handleOidcLogout$1(request, {
|
|
31
|
-
oauthConfig: config.oauthConfig,
|
|
32
|
-
secret: config.secret,
|
|
33
|
-
persistence: config.persistence,
|
|
34
|
-
postLogoutRedirectUri: config.postLogoutRedirectUri,
|
|
35
|
-
state: config.state,
|
|
36
|
-
logoutHint: config.logoutHint,
|
|
37
|
-
includeClientId: config.includeClientId,
|
|
38
|
-
fallbackRedirectUri: config.fallbackRedirectUri,
|
|
39
|
-
allowedMethods: config.allowedMethods,
|
|
40
|
-
applicationUrl: config.applicationUrl,
|
|
41
|
-
cookies: await nextCookieStore(),
|
|
42
|
-
rateLimit: globalPOSTRateLimit
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
export { handleOidcLogout };
|
|
46
|
-
|
|
47
|
-
//# sourceMappingURL=oidc-logout.js.map
|
package/dist/oidc-logout.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"oidc-logout.js","names":["coreHandleOidcLogout"],"sources":["../src/oidc-logout.ts"],"sourcesContent":["/**\n * RP-initiated logout for Next.js route handlers — a thin wrapper over the\n * framework-agnostic handler in `@eventuras/fides-auth/server`, wiring it to the\n * Next cookie store and the global POST rate limiter.\n */\n\nimport {\n handleOidcLogout as coreHandleOidcLogout,\n type SessionPersistence,\n type SessionSecret,\n} from '@eventuras/fides-auth/server';\nimport type { OAuthConfig } from '@eventuras/fides-auth/oauth';\n\nimport { nextCookieStore } from './cookie-store.js';\nimport { globalPOSTRateLimit } from './request.js';\n\nexport interface OidcLogoutConfig {\n /** OAuth/OIDC configuration */\n oauthConfig: OAuthConfig;\n\n /** Session encryption secret. */\n secret: SessionSecret;\n\n /** Where the session lives. Defaults to the cookies under `secret`; see `serverPersistence`. */\n persistence?: SessionPersistence;\n\n /**\n * URI the provider redirects back to after logout. Must be registered with the\n * provider as a post-logout redirect URI.\n */\n postLogoutRedirectUri: string;\n\n /** Opaque value echoed back on the post-logout redirect. */\n state?: string;\n\n /** `logout_hint`, when the provider documents one. */\n logoutHint?: string;\n\n /** Whether to send `client_id`. Default true. */\n includeClientId?: boolean;\n\n /** Request methods that may trigger a logout. @default ['POST'] */\n allowedMethods?: string[];\n\n /** Public application URL, used to check the `Origin` header behind a proxy. */\n applicationUrl?: string;\n\n /**\n * Where to send the user when the provider advertises no end_session_endpoint.\n * @default postLogoutRedirectUri\n */\n fallbackRedirectUri?: string;\n}\n\n/**\n * Handles logout in a Next.js route handler: clears the session cookies and\n * redirects to the provider's end-session endpoint with `id_token_hint`.\n * `createFidesAuth` returns this with `oauthConfig` and `secret` bound.\n *\n * @example\n * ```ts\n * // In app/api/auth/logout/route.ts\n * import { handleOidcLogout } from '@eventuras/fides-auth-next/oidc-logout';\n *\n * export async function POST(request: Request) {\n * return handleOidcLogout(request, {\n * oauthConfig,\n * secret: process.env.SESSION_SECRET!,\n * postLogoutRedirectUri: 'https://example.com/',\n * });\n * }\n * ```\n */\nexport async function handleOidcLogout(\n request: Request,\n config: OidcLogoutConfig,\n): Promise<Response> {\n return coreHandleOidcLogout(request, {\n oauthConfig: config.oauthConfig,\n secret: config.secret,\n persistence: config.persistence,\n postLogoutRedirectUri: config.postLogoutRedirectUri,\n state: config.state,\n logoutHint: config.logoutHint,\n includeClientId: config.includeClientId,\n fallbackRedirectUri: config.fallbackRedirectUri,\n allowedMethods: config.allowedMethods,\n applicationUrl: config.applicationUrl,\n cookies: await nextCookieStore(),\n rateLimit: globalPOSTRateLimit,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyEA,eAAsB,iBACpB,SACA,QACmB;CACnB,OAAOA,mBAAqB,SAAS;EACnC,aAAa,OAAO;EACpB,QAAQ,OAAO;EACf,aAAa,OAAO;EACpB,uBAAuB,OAAO;EAC9B,OAAO,OAAO;EACd,YAAY,OAAO;EACnB,iBAAiB,OAAO;EACxB,qBAAqB,OAAO;EAC5B,gBAAgB,OAAO;EACvB,gBAAgB,OAAO;EACvB,SAAS,MAAM,gBAAgB;EAC/B,WAAW;CACb,CAAC;AACH"}
|