@eventuras/fides-auth-next 0.7.1 → 0.8.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.
- package/README.md +122 -20
- package/dist/auth.d.ts +76 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +97 -0
- package/dist/auth.js.map +1 -0
- package/dist/cookie-store.d.ts +1 -1
- package/dist/cookie-store.js +1 -2
- package/dist/cookies.d.ts +21 -9
- package/dist/cookies.d.ts.map +1 -1
- package/dist/cookies.js +8 -10
- package/dist/cookies.js.map +1 -1
- package/dist/heartbeat-handler.d.ts +18 -3
- package/dist/heartbeat-handler.d.ts.map +1 -1
- package/dist/heartbeat-handler.js +6 -4
- package/dist/heartbeat-handler.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/oidc-callback.d.ts +16 -2
- package/dist/oidc-callback.d.ts.map +1 -1
- package/dist/oidc-callback.js +7 -3
- package/dist/oidc-callback.js.map +1 -1
- package/dist/oidc-login.d.ts +14 -3
- package/dist/oidc-login.d.ts.map +1 -1
- package/dist/oidc-login.js +6 -4
- package/dist/oidc-login.js.map +1 -1
- package/dist/oidc-logout.d.ts +13 -1
- package/dist/oidc-logout.d.ts.map +1 -1
- package/dist/oidc-logout.js +5 -2
- package/dist/oidc-logout.js.map +1 -1
- package/dist/request.d.ts +8 -0
- package/dist/request.d.ts.map +1 -1
- package/dist/request.js +9 -2
- package/dist/request.js.map +1 -1
- package/package.json +16 -16
- package/dist/session.d.ts +0 -120
- package/dist/session.d.ts.map +0 -1
- package/dist/session.js +0 -152
- package/dist/session.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { nextCookieStore } from "./cookie-store.js";
|
|
2
2
|
import { globalPOSTRateLimit } from "./request.js";
|
|
3
3
|
import { handleHeartbeat as handleHeartbeat$1 } from "@eventuras/fides-auth/server";
|
|
4
|
-
|
|
4
|
+
// src/heartbeat-handler.ts
|
|
5
5
|
/**
|
|
6
6
|
* Server-side heartbeat handler for Next.js route handlers — a thin wrapper over
|
|
7
7
|
* the framework-agnostic handler in `@eventuras/fides-auth/server`, wiring it to
|
|
@@ -12,7 +12,8 @@ import { handleHeartbeat as handleHeartbeat$1 } from "@eventuras/fides-auth/serv
|
|
|
12
12
|
* fresh access token (and rotated refresh token, if the IdP rotates).
|
|
13
13
|
*/
|
|
14
14
|
/**
|
|
15
|
-
* Handles a heartbeat request in a Next.js route handler.
|
|
15
|
+
* Handles a heartbeat request in a Next.js route handler. `createFidesAuth`
|
|
16
|
+
* returns this with `oauthConfig` and `secret` bound.
|
|
16
17
|
*
|
|
17
18
|
* @example
|
|
18
19
|
* ```ts
|
|
@@ -21,18 +22,19 @@ import { handleHeartbeat as handleHeartbeat$1 } from "@eventuras/fides-auth/serv
|
|
|
21
22
|
* import { oauthConfig } from '@/utils/oauthConfig';
|
|
22
23
|
*
|
|
23
24
|
* export async function POST(request: Request) {
|
|
24
|
-
* return handleHeartbeat(request, { oauthConfig });
|
|
25
|
+
* return handleHeartbeat(request, { oauthConfig, secret: process.env.SESSION_SECRET! });
|
|
25
26
|
* }
|
|
26
27
|
* ```
|
|
27
28
|
*/
|
|
28
29
|
async function handleHeartbeat(request, config) {
|
|
29
30
|
return handleHeartbeat$1(request, {
|
|
30
31
|
oauthConfig: config.oauthConfig,
|
|
32
|
+
secret: config.secret,
|
|
33
|
+
persistence: config.persistence,
|
|
31
34
|
cookies: await nextCookieStore(),
|
|
32
35
|
rateLimit: globalPOSTRateLimit
|
|
33
36
|
});
|
|
34
37
|
}
|
|
35
|
-
//#endregion
|
|
36
38
|
export { handleHeartbeat };
|
|
37
39
|
|
|
38
40
|
//# sourceMappingURL=heartbeat-handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heartbeat-handler.js","names":[],"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 {
|
|
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';\nimport { globalPOSTRateLimit } from './request';\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/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from './cookie-store';
|
|
2
2
|
export * from './request';
|
|
3
|
-
export * from './
|
|
3
|
+
export * from './auth';
|
|
4
4
|
export * from './cookies';
|
|
5
5
|
export * from './oidc-callback';
|
|
6
6
|
export * from './oidc-login';
|
|
@@ -16,5 +16,7 @@ export * from '@eventuras/fides-auth/session-validation';
|
|
|
16
16
|
export * from '@eventuras/fides-auth/silent-login';
|
|
17
17
|
export * from '@eventuras/fides-auth/utils';
|
|
18
18
|
export * from '@eventuras/fides-auth/types';
|
|
19
|
-
export {
|
|
19
|
+
export {
|
|
20
|
+
/** @deprecated Only backs the deprecated default limiter. Use the handlers' `rateLimit` option. */
|
|
21
|
+
TokenBucket, } from '@eventuras/fides-auth/rate-limit';
|
|
20
22
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AAGpC,cAAc,SAAS,CAAC;AAGxB,cAAc,6BAA6B,CAAC;AAC5C,YAAY,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC/D,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sCAAsC,CAAC;AACrD,cAAc,uCAAuC,CAAC;AACtD,cAAc,0CAA0C,CAAC;AACzD,cAAc,oCAAoC,CAAC;AACnD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,OAAO;AACL,mGAAmG;AACnG,WAAW,GACZ,MAAM,kCAAkC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { nextCookieStore } from "./cookie-store.js";
|
|
2
2
|
import { globalGETRateLimit, globalPOSTRateLimit } from "./request.js";
|
|
3
|
-
import {
|
|
4
|
-
import { ACCESS_TOKEN_COOKIE_NAME, COOKIE_INFO_BYTES, COOKIE_MAX_BYTES, CookieTooLargeError, ID_TOKEN_COOKIE_NAME, assertCookieWithinLimit, cookieByteSize, defaultOAuthCookieOptions, defaultSessionCookieOptions, deleteAccessTokenCookie, deleteAuthCookie, deleteAuthCookies, deleteSessionCookie, getAccessTokenCookie, getAuthCookie, getSessionCookie, setAccessTokenCookie, setAuthCookie, setSessionCookie } from "./cookies.js";
|
|
3
|
+
import { handleHeartbeat } from "./heartbeat-handler.js";
|
|
5
4
|
import { handleOidcCallback } from "./oidc-callback.js";
|
|
6
5
|
import { handleOidcLogin } from "./oidc-login.js";
|
|
7
6
|
import { handleOidcLogout } from "./oidc-logout.js";
|
|
8
|
-
import {
|
|
7
|
+
import { AuthorizedFetchError, createFidesAuth } from "./auth.js";
|
|
8
|
+
import { ACCESS_TOKEN_COOKIE_NAME, COOKIE_INFO_BYTES, COOKIE_MAX_BYTES, CookieTooLargeError, ID_TOKEN_COOKIE_NAME, assertCookieWithinLimit, cookieByteSize, defaultOAuthCookieOptions, defaultSessionCookieOptions, deleteAccessTokenCookie, deleteAuthCookie, deleteAuthCookies, deleteSessionCookie, getAccessTokenCookie, getAuthCookie, getSessionCookie, setAccessTokenCookie, setAuthCookie, setSessionCookie } from "./cookies.js";
|
|
9
9
|
import { checkAuth, configureAuthLogger, createAuthStore, createAuthStoreHooks, initializeAuth, startSessionMonitor, useHeartbeat, useSessionMonitor } from "./store/index.js";
|
|
10
10
|
import { TokenBucket } from "@eventuras/fides-auth/rate-limit";
|
|
11
11
|
export * from "@eventuras/fides-auth/logger";
|
|
12
|
-
export * from "@eventuras/fides-auth/utils";
|
|
13
12
|
export * from "@eventuras/fides-auth/oauth";
|
|
14
13
|
export * from "@eventuras/fides-auth/session-events";
|
|
15
14
|
export * from "@eventuras/fides-auth/session-refresh";
|
|
16
15
|
export * from "@eventuras/fides-auth/session-validation";
|
|
17
16
|
export * from "@eventuras/fides-auth/silent-login";
|
|
17
|
+
export * from "@eventuras/fides-auth/utils";
|
|
18
18
|
export * from "@eventuras/fides-auth/types";
|
|
19
|
-
export { ACCESS_TOKEN_COOKIE_NAME, COOKIE_INFO_BYTES, COOKIE_MAX_BYTES, CookieTooLargeError, ID_TOKEN_COOKIE_NAME, TokenBucket, assertCookieWithinLimit, checkAuth,
|
|
19
|
+
export { ACCESS_TOKEN_COOKIE_NAME, AuthorizedFetchError, COOKIE_INFO_BYTES, COOKIE_MAX_BYTES, CookieTooLargeError, ID_TOKEN_COOKIE_NAME, TokenBucket, assertCookieWithinLimit, checkAuth, configureAuthLogger, cookieByteSize, createAuthStore, createAuthStoreHooks, createFidesAuth, defaultOAuthCookieOptions, defaultSessionCookieOptions, deleteAccessTokenCookie, deleteAuthCookie, deleteAuthCookies, deleteSessionCookie, getAccessTokenCookie, getAuthCookie, getSessionCookie, globalGETRateLimit, globalPOSTRateLimit, handleHeartbeat, handleOidcCallback, handleOidcLogin, handleOidcLogout, initializeAuth, nextCookieStore, setAccessTokenCookie, setAuthCookie, setSessionCookie, startSessionMonitor, useHeartbeat, useSessionMonitor };
|
package/dist/oidc-callback.d.ts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
|
|
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';
|
|
2
8
|
export interface OidcCallbackConfig {
|
|
3
9
|
/** OAuth/OIDC configuration (issuer, clientId, clientSecret, redirect_uri, scope) */
|
|
4
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;
|
|
5
15
|
/** Public application URL (used to reconstruct the callback URL and validate redirects) */
|
|
6
16
|
applicationUrl: string;
|
|
7
17
|
/**
|
|
@@ -9,6 +19,8 @@ export interface OidcCallbackConfig {
|
|
|
9
19
|
* @default 'roles'
|
|
10
20
|
*/
|
|
11
21
|
rolesClaim?: string;
|
|
22
|
+
/** Changes the session before it is stored, e.g. to add `data`. See {@link MapSession}. */
|
|
23
|
+
mapSession?: MapSession;
|
|
12
24
|
/**
|
|
13
25
|
* Default path to redirect to after login if no returnTo cookie is set.
|
|
14
26
|
* @default '/'
|
|
@@ -26,7 +38,8 @@ export interface OidcCallbackConfig {
|
|
|
26
38
|
sessionDurationDays?: number;
|
|
27
39
|
}
|
|
28
40
|
/**
|
|
29
|
-
* Handles the OIDC callback in a Next.js route handler.
|
|
41
|
+
* Handles the OIDC callback in a Next.js route handler. `createFidesAuth` returns
|
|
42
|
+
* this with `oauthConfig` and `secret` bound.
|
|
30
43
|
*
|
|
31
44
|
* @example
|
|
32
45
|
* ```ts
|
|
@@ -36,6 +49,7 @@ export interface OidcCallbackConfig {
|
|
|
36
49
|
* export async function GET(request: Request) {
|
|
37
50
|
* return handleOidcCallback(request, {
|
|
38
51
|
* oauthConfig,
|
|
52
|
+
* secret: process.env.SESSION_SECRET!,
|
|
39
53
|
* applicationUrl: 'https://example.com',
|
|
40
54
|
* rolesClaim: 'roles',
|
|
41
55
|
* });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oidc-callback.d.ts","sourceRoot":"","sources":["../src/oidc-callback.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
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
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { nextCookieStore } from "./cookie-store.js";
|
|
2
2
|
import { globalGETRateLimit } from "./request.js";
|
|
3
3
|
import { handleOidcCallback as handleOidcCallback$1 } from "@eventuras/fides-auth/server";
|
|
4
|
-
|
|
4
|
+
// src/oidc-callback.ts
|
|
5
5
|
/**
|
|
6
6
|
* OIDC callback handler for Next.js route handlers — a thin wrapper over the
|
|
7
7
|
* framework-agnostic handler in `@eventuras/fides-auth/server`, wiring it to the
|
|
8
8
|
* Next cookie store and the global GET rate limiter.
|
|
9
9
|
*/
|
|
10
10
|
/**
|
|
11
|
-
* Handles the OIDC callback in a Next.js route handler.
|
|
11
|
+
* Handles the OIDC callback in a Next.js route handler. `createFidesAuth` returns
|
|
12
|
+
* this with `oauthConfig` and `secret` bound.
|
|
12
13
|
*
|
|
13
14
|
* @example
|
|
14
15
|
* ```ts
|
|
@@ -18,6 +19,7 @@ import { handleOidcCallback as handleOidcCallback$1 } from "@eventuras/fides-aut
|
|
|
18
19
|
* export async function GET(request: Request) {
|
|
19
20
|
* return handleOidcCallback(request, {
|
|
20
21
|
* oauthConfig,
|
|
22
|
+
* secret: process.env.SESSION_SECRET!,
|
|
21
23
|
* applicationUrl: 'https://example.com',
|
|
22
24
|
* rolesClaim: 'roles',
|
|
23
25
|
* });
|
|
@@ -27,15 +29,17 @@ import { handleOidcCallback as handleOidcCallback$1 } from "@eventuras/fides-aut
|
|
|
27
29
|
async function handleOidcCallback(request, config) {
|
|
28
30
|
return handleOidcCallback$1(request, {
|
|
29
31
|
oauthConfig: config.oauthConfig,
|
|
32
|
+
secret: config.secret,
|
|
33
|
+
persistence: config.persistence,
|
|
30
34
|
applicationUrl: config.applicationUrl,
|
|
31
35
|
rolesClaim: config.rolesClaim,
|
|
36
|
+
mapSession: config.mapSession,
|
|
32
37
|
defaultRedirectPath: config.defaultRedirectPath,
|
|
33
38
|
validateReturnTo: config.validateReturnTo,
|
|
34
39
|
cookies: await nextCookieStore(),
|
|
35
40
|
rateLimit: globalGETRateLimit
|
|
36
41
|
});
|
|
37
42
|
}
|
|
38
|
-
//#endregion
|
|
39
43
|
export { handleOidcCallback };
|
|
40
44
|
|
|
41
45
|
//# sourceMappingURL=oidc-callback.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oidc-callback.js","names":[],"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 {
|
|
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';\nimport { globalGETRateLimit } from './request';\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
CHANGED
|
@@ -1,16 +1,27 @@
|
|
|
1
|
-
|
|
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';
|
|
2
8
|
export interface OidcLoginConfig {
|
|
3
9
|
/** OAuth/OIDC configuration */
|
|
4
10
|
oauthConfig: OAuthConfig;
|
|
11
|
+
/** Seals the login transaction. Must match the callback's. */
|
|
12
|
+
secret: SessionSecret;
|
|
5
13
|
/**
|
|
6
14
|
* Validates and sanitizes the returnTo parameter.
|
|
7
15
|
* Should return a safe path or null to use the default.
|
|
8
16
|
* @default Only allows relative paths starting with /
|
|
9
17
|
*/
|
|
10
18
|
validateReturnTo?: (rawReturnTo: string) => string | null;
|
|
19
|
+
/** Per-request authorization parameters, e.g. `prompt` or `login_hint`. Reserved keys throw. */
|
|
20
|
+
authorizationParameters?: CoreOidcLoginConfig['authorizationParameters'];
|
|
11
21
|
}
|
|
12
22
|
/**
|
|
13
|
-
* Handles OIDC login initiation in a Next.js route handler.
|
|
23
|
+
* Handles OIDC login initiation in a Next.js route handler. `createFidesAuth`
|
|
24
|
+
* returns this with `oauthConfig` and `secret` bound.
|
|
14
25
|
*
|
|
15
26
|
* @example
|
|
16
27
|
* ```ts
|
|
@@ -18,7 +29,7 @@ export interface OidcLoginConfig {
|
|
|
18
29
|
* import { handleOidcLogin } from '@eventuras/fides-auth-next/oidc-login';
|
|
19
30
|
*
|
|
20
31
|
* export async function GET(request: Request) {
|
|
21
|
-
* return handleOidcLogin(request, { oauthConfig });
|
|
32
|
+
* return handleOidcLogin(request, { oauthConfig, secret: process.env.SESSION_SECRET! });
|
|
22
33
|
* }
|
|
23
34
|
* ```
|
|
24
35
|
*/
|
package/dist/oidc-login.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oidc-login.d.ts","sourceRoot":"","sources":["../src/oidc-login.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
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
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { nextCookieStore } from "./cookie-store.js";
|
|
2
2
|
import { globalGETRateLimit } from "./request.js";
|
|
3
3
|
import { handleOidcLogin as handleOidcLogin$1 } from "@eventuras/fides-auth/server";
|
|
4
|
-
|
|
4
|
+
// src/oidc-login.ts
|
|
5
5
|
/**
|
|
6
6
|
* OIDC login initiation for Next.js route handlers — a thin wrapper over the
|
|
7
7
|
* framework-agnostic handler in `@eventuras/fides-auth/server`, wiring it to the
|
|
8
8
|
* Next cookie store and the global GET rate limiter.
|
|
9
9
|
*/
|
|
10
10
|
/**
|
|
11
|
-
* Handles OIDC login initiation in a Next.js route handler.
|
|
11
|
+
* Handles OIDC login initiation in a Next.js route handler. `createFidesAuth`
|
|
12
|
+
* returns this with `oauthConfig` and `secret` bound.
|
|
12
13
|
*
|
|
13
14
|
* @example
|
|
14
15
|
* ```ts
|
|
@@ -16,19 +17,20 @@ import { handleOidcLogin as handleOidcLogin$1 } from "@eventuras/fides-auth/serv
|
|
|
16
17
|
* import { handleOidcLogin } from '@eventuras/fides-auth-next/oidc-login';
|
|
17
18
|
*
|
|
18
19
|
* export async function GET(request: Request) {
|
|
19
|
-
* return handleOidcLogin(request, { oauthConfig });
|
|
20
|
+
* return handleOidcLogin(request, { oauthConfig, secret: process.env.SESSION_SECRET! });
|
|
20
21
|
* }
|
|
21
22
|
* ```
|
|
22
23
|
*/
|
|
23
24
|
async function handleOidcLogin(request, config) {
|
|
24
25
|
return handleOidcLogin$1(request, {
|
|
25
26
|
oauthConfig: config.oauthConfig,
|
|
27
|
+
secret: config.secret,
|
|
26
28
|
validateReturnTo: config.validateReturnTo,
|
|
29
|
+
authorizationParameters: config.authorizationParameters,
|
|
27
30
|
cookies: await nextCookieStore(),
|
|
28
31
|
rateLimit: globalGETRateLimit
|
|
29
32
|
});
|
|
30
33
|
}
|
|
31
|
-
//#endregion
|
|
32
34
|
export { handleOidcLogin };
|
|
33
35
|
|
|
34
36
|
//# sourceMappingURL=oidc-login.js.map
|
package/dist/oidc-login.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oidc-login.js","names":[],"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 {
|
|
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';\nimport { globalGETRateLimit } from './request';\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
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
|
|
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';
|
|
2
8
|
export interface OidcLogoutConfig {
|
|
3
9
|
/** OAuth/OIDC configuration */
|
|
4
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;
|
|
5
15
|
/**
|
|
6
16
|
* URI the provider redirects back to after logout. Must be registered with the
|
|
7
17
|
* provider as a post-logout redirect URI.
|
|
@@ -26,6 +36,7 @@ export interface OidcLogoutConfig {
|
|
|
26
36
|
/**
|
|
27
37
|
* Handles logout in a Next.js route handler: clears the session cookies and
|
|
28
38
|
* redirects to the provider's end-session endpoint with `id_token_hint`.
|
|
39
|
+
* `createFidesAuth` returns this with `oauthConfig` and `secret` bound.
|
|
29
40
|
*
|
|
30
41
|
* @example
|
|
31
42
|
* ```ts
|
|
@@ -35,6 +46,7 @@ export interface OidcLogoutConfig {
|
|
|
35
46
|
* export async function POST(request: Request) {
|
|
36
47
|
* return handleOidcLogout(request, {
|
|
37
48
|
* oauthConfig,
|
|
49
|
+
* secret: process.env.SESSION_SECRET!,
|
|
38
50
|
* postLogoutRedirectUri: 'https://example.com/',
|
|
39
51
|
* });
|
|
40
52
|
* }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oidc-logout.d.ts","sourceRoot":"","sources":["../src/oidc-logout.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { nextCookieStore } from "./cookie-store.js";
|
|
2
2
|
import { globalPOSTRateLimit } from "./request.js";
|
|
3
3
|
import { handleOidcLogout as handleOidcLogout$1 } from "@eventuras/fides-auth/server";
|
|
4
|
-
|
|
4
|
+
// src/oidc-logout.ts
|
|
5
5
|
/**
|
|
6
6
|
* RP-initiated logout for Next.js route handlers — a thin wrapper over the
|
|
7
7
|
* framework-agnostic handler in `@eventuras/fides-auth/server`, wiring it to the
|
|
@@ -10,6 +10,7 @@ import { handleOidcLogout as handleOidcLogout$1 } from "@eventuras/fides-auth/se
|
|
|
10
10
|
/**
|
|
11
11
|
* Handles logout in a Next.js route handler: clears the session cookies and
|
|
12
12
|
* redirects to the provider's end-session endpoint with `id_token_hint`.
|
|
13
|
+
* `createFidesAuth` returns this with `oauthConfig` and `secret` bound.
|
|
13
14
|
*
|
|
14
15
|
* @example
|
|
15
16
|
* ```ts
|
|
@@ -19,6 +20,7 @@ import { handleOidcLogout as handleOidcLogout$1 } from "@eventuras/fides-auth/se
|
|
|
19
20
|
* export async function POST(request: Request) {
|
|
20
21
|
* return handleOidcLogout(request, {
|
|
21
22
|
* oauthConfig,
|
|
23
|
+
* secret: process.env.SESSION_SECRET!,
|
|
22
24
|
* postLogoutRedirectUri: 'https://example.com/',
|
|
23
25
|
* });
|
|
24
26
|
* }
|
|
@@ -27,6 +29,8 @@ import { handleOidcLogout as handleOidcLogout$1 } from "@eventuras/fides-auth/se
|
|
|
27
29
|
async function handleOidcLogout(request, config) {
|
|
28
30
|
return handleOidcLogout$1(request, {
|
|
29
31
|
oauthConfig: config.oauthConfig,
|
|
32
|
+
secret: config.secret,
|
|
33
|
+
persistence: config.persistence,
|
|
30
34
|
postLogoutRedirectUri: config.postLogoutRedirectUri,
|
|
31
35
|
state: config.state,
|
|
32
36
|
logoutHint: config.logoutHint,
|
|
@@ -38,7 +42,6 @@ async function handleOidcLogout(request, config) {
|
|
|
38
42
|
rateLimit: globalPOSTRateLimit
|
|
39
43
|
});
|
|
40
44
|
}
|
|
41
|
-
//#endregion
|
|
42
45
|
export { handleOidcLogout };
|
|
43
46
|
|
|
44
47
|
//# sourceMappingURL=oidc-logout.js.map
|
package/dist/oidc-logout.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oidc-logout.js","names":[],"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 {
|
|
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';\nimport { globalPOSTRateLimit } from './request';\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"}
|
package/dist/request.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated Keys on the raw `X-Forwarded-For` header, and requests without it pass.
|
|
3
|
+
* Pass your own limiter as `rateLimit` to the handlers in `@eventuras/fides-auth/server`.
|
|
4
|
+
*/
|
|
1
5
|
export declare function globalGETRateLimit(): Promise<boolean>;
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Keys on the raw `X-Forwarded-For` header, and requests without it pass.
|
|
8
|
+
* Pass your own limiter as `rateLimit` to the handlers in `@eventuras/fides-auth/server`.
|
|
9
|
+
*/
|
|
2
10
|
export declare function globalPOSTRateLimit(): Promise<boolean>;
|
|
3
11
|
//# sourceMappingURL=request.d.ts.map
|
package/dist/request.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AAgBA,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC,CAiB3D;AAED,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,OAAO,CAAC,CAiB5D"}
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AAgBA;;;GAGG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC,CAiB3D;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,OAAO,CAAC,CAiB5D"}
|
package/dist/request.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { headers } from "next/headers";
|
|
2
2
|
import { TokenBucket } from "@eventuras/fides-auth/rate-limit";
|
|
3
3
|
import { createLogger } from "@eventuras/fides-auth/logger";
|
|
4
|
-
|
|
4
|
+
// src/request.ts
|
|
5
5
|
var logger = createLogger({ namespace: "fides-auth-next:request" });
|
|
6
6
|
var globalBucket = null;
|
|
7
7
|
function getBucket() {
|
|
8
8
|
if (!globalBucket) globalBucket = new TokenBucket(100, 1);
|
|
9
9
|
return globalBucket;
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Keys on the raw `X-Forwarded-For` header, and requests without it pass.
|
|
13
|
+
* Pass your own limiter as `rateLimit` to the handlers in `@eventuras/fides-auth/server`.
|
|
14
|
+
*/
|
|
11
15
|
async function globalGETRateLimit() {
|
|
12
16
|
try {
|
|
13
17
|
const clientIP = (await headers()).get("X-Forwarded-For");
|
|
@@ -19,6 +23,10 @@ async function globalGETRateLimit() {
|
|
|
19
23
|
return true;
|
|
20
24
|
}
|
|
21
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated Keys on the raw `X-Forwarded-For` header, and requests without it pass.
|
|
28
|
+
* Pass your own limiter as `rateLimit` to the handlers in `@eventuras/fides-auth/server`.
|
|
29
|
+
*/
|
|
22
30
|
async function globalPOSTRateLimit() {
|
|
23
31
|
try {
|
|
24
32
|
const clientIP = (await headers()).get("X-Forwarded-For");
|
|
@@ -30,7 +38,6 @@ async function globalPOSTRateLimit() {
|
|
|
30
38
|
return true;
|
|
31
39
|
}
|
|
32
40
|
}
|
|
33
|
-
//#endregion
|
|
34
41
|
export { globalGETRateLimit, globalPOSTRateLimit };
|
|
35
42
|
|
|
36
43
|
//# sourceMappingURL=request.js.map
|
package/dist/request.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.js","names":[],"sources":["../src/request.ts"],"sourcesContent":["import { headers } from 'next/headers';\nimport {TokenBucket} from '@eventuras/fides-auth/rate-limit';\nimport { createLogger } from '@eventuras/fides-auth/logger';\n\nconst logger = createLogger({ namespace: 'fides-auth-next:request' });\n\n// Initialize bucket lazily to avoid worker thread issues\nlet globalBucket: TokenBucket<string> | null = null;\n\nfunction getBucket(): TokenBucket<string> {\n if (!globalBucket) {\n globalBucket = new TokenBucket<string>(100, 1);\n }\n return globalBucket;\n}\n\nexport async function globalGETRateLimit(): Promise<boolean> {\n try {\n const headerStore = await headers();\n const clientIP = headerStore.get('X-Forwarded-For');\n if (clientIP === null) {\n return true;\n }\n return getBucket().consume(clientIP, 1);\n } catch (error) {\n // If worker thread crashes, allow the request through\n if (error instanceof Error && error.message.includes('worker')) {\n logger.error({ error }, 'Worker thread error in globalGETRateLimit');\n } else {\n logger.error({ error }, 'Unexpected error in globalGETRateLimit');\n }\n return true;\n }\n}\n\nexport async function globalPOSTRateLimit(): Promise<boolean> {\n try {\n const headerStore = await headers();\n const clientIP = headerStore.get('X-Forwarded-For');\n if (clientIP === null) {\n return true;\n }\n return getBucket().consume(clientIP, 3);\n } catch (error) {\n // If worker thread crashes, allow the request through\n if (error instanceof Error && error.message.includes('worker')) {\n logger.error({ error }, 'Worker thread error in globalPOSTRateLimit');\n } else {\n logger.error({ error }, 'Unexpected error in globalPOSTRateLimit');\n }\n return true;\n }\n}\n"],"mappings":";;;;AAIA,IAAM,SAAS,aAAa,EAAE,WAAW,0BAA0B,CAAC;AAGpE,IAAI,eAA2C;AAE/C,SAAS,YAAiC;CACxC,IAAI,CAAC,cACH,eAAe,IAAI,YAAoB,KAAK,CAAC;CAE/C,OAAO;AACT
|
|
1
|
+
{"version":3,"file":"request.js","names":[],"sources":["../src/request.ts"],"sourcesContent":["import { headers } from 'next/headers';\nimport {TokenBucket} from '@eventuras/fides-auth/rate-limit';\nimport { createLogger } from '@eventuras/fides-auth/logger';\n\nconst logger = createLogger({ namespace: 'fides-auth-next:request' });\n\n// Initialize bucket lazily to avoid worker thread issues\nlet globalBucket: TokenBucket<string> | null = null;\n\nfunction getBucket(): TokenBucket<string> {\n if (!globalBucket) {\n globalBucket = new TokenBucket<string>(100, 1);\n }\n return globalBucket;\n}\n\n/**\n * @deprecated Keys on the raw `X-Forwarded-For` header, and requests without it pass.\n * Pass your own limiter as `rateLimit` to the handlers in `@eventuras/fides-auth/server`.\n */\nexport async function globalGETRateLimit(): Promise<boolean> {\n try {\n const headerStore = await headers();\n const clientIP = headerStore.get('X-Forwarded-For');\n if (clientIP === null) {\n return true;\n }\n return getBucket().consume(clientIP, 1);\n } catch (error) {\n // If worker thread crashes, allow the request through\n if (error instanceof Error && error.message.includes('worker')) {\n logger.error({ error }, 'Worker thread error in globalGETRateLimit');\n } else {\n logger.error({ error }, 'Unexpected error in globalGETRateLimit');\n }\n return true;\n }\n}\n\n/**\n * @deprecated Keys on the raw `X-Forwarded-For` header, and requests without it pass.\n * Pass your own limiter as `rateLimit` to the handlers in `@eventuras/fides-auth/server`.\n */\nexport async function globalPOSTRateLimit(): Promise<boolean> {\n try {\n const headerStore = await headers();\n const clientIP = headerStore.get('X-Forwarded-For');\n if (clientIP === null) {\n return true;\n }\n return getBucket().consume(clientIP, 3);\n } catch (error) {\n // If worker thread crashes, allow the request through\n if (error instanceof Error && error.message.includes('worker')) {\n logger.error({ error }, 'Worker thread error in globalPOSTRateLimit');\n } else {\n logger.error({ error }, 'Unexpected error in globalPOSTRateLimit');\n }\n return true;\n }\n}\n"],"mappings":";;;;AAIA,IAAM,SAAS,aAAa,EAAE,WAAW,0BAA0B,CAAC;AAGpE,IAAI,eAA2C;AAE/C,SAAS,YAAiC;CACxC,IAAI,CAAC,cACH,eAAe,IAAI,YAAoB,KAAK,CAAC;CAE/C,OAAO;AACT;;;;;AAMA,eAAsB,qBAAuC;CAC3D,IAAI;EAEF,MAAM,YAAW,MADS,QAAQ,EAAA,CACL,IAAI,iBAAiB;EAClD,IAAI,aAAa,MACf,OAAO;EAET,OAAO,UAAU,CAAC,CAAC,QAAQ,UAAU,CAAC;CACxC,SAAS,OAAO;EAEd,IAAI,iBAAiB,SAAS,MAAM,QAAQ,SAAS,QAAQ,GAC3D,OAAO,MAAM,EAAE,MAAM,GAAG,2CAA2C;OAEnE,OAAO,MAAM,EAAE,MAAM,GAAG,wCAAwC;EAElE,OAAO;CACT;AACF;;;;;AAMA,eAAsB,sBAAwC;CAC5D,IAAI;EAEF,MAAM,YAAW,MADS,QAAQ,EAAA,CACL,IAAI,iBAAiB;EAClD,IAAI,aAAa,MACf,OAAO;EAET,OAAO,UAAU,CAAC,CAAC,QAAQ,UAAU,CAAC;CACxC,SAAS,OAAO;EAEd,IAAI,iBAAiB,SAAS,MAAM,QAAQ,SAAS,QAAQ,GAC3D,OAAO,MAAM,EAAE,MAAM,GAAG,4CAA4C;OAEpE,OAAO,MAAM,EAAE,MAAM,GAAG,yCAAyC;EAEnE,OAAO;CACT;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eventuras/fides-auth-next",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Next.js bindings for @eventuras/fides-auth",
|
|
5
5
|
"homepage": "https://github.com/losol/fides-auth/tree/main/packages/fides-auth-next#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"types": "./dist/index.d.ts",
|
|
19
19
|
"import": "./dist/index.js"
|
|
20
20
|
},
|
|
21
|
-
"./
|
|
22
|
-
"types": "./dist/
|
|
23
|
-
"import": "./dist/
|
|
21
|
+
"./auth": {
|
|
22
|
+
"types": "./dist/auth.d.ts",
|
|
23
|
+
"import": "./dist/auth.js"
|
|
24
24
|
},
|
|
25
25
|
"./cookie-store": {
|
|
26
26
|
"types": "./dist/cookie-store.d.ts",
|
|
@@ -58,27 +58,27 @@
|
|
|
58
58
|
"LICENSE"
|
|
59
59
|
],
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@eventuras/fides-auth-
|
|
62
|
-
"@eventuras/fides-auth": "0.
|
|
63
|
-
"@eventuras/fides-auth
|
|
61
|
+
"@eventuras/fides-auth-store": "0.3.0",
|
|
62
|
+
"@eventuras/fides-auth-react": "0.1.8",
|
|
63
|
+
"@eventuras/fides-auth": "0.15.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@testing-library/jest-dom": "7.0.
|
|
67
|
-
"@types/react": "^19.
|
|
68
|
-
"jsdom": "30.
|
|
69
|
-
"react": "^19.
|
|
70
|
-
"typescript": "^
|
|
71
|
-
"vite": "^8.
|
|
66
|
+
"@testing-library/jest-dom": "7.0.1",
|
|
67
|
+
"@types/react": "^19.3.0",
|
|
68
|
+
"jsdom": "30.1.3",
|
|
69
|
+
"react": "^19.3.1",
|
|
70
|
+
"typescript": "^7.0.2",
|
|
71
|
+
"vite": "^8.3.5",
|
|
72
72
|
"vitest": "^4.1.10",
|
|
73
|
-
"@eventuras/
|
|
74
|
-
"@eventuras/
|
|
73
|
+
"@eventuras/vite-config": "0.3.0",
|
|
74
|
+
"@eventuras/typescript-config": "1.0.0"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
77
|
"next": "^16.0.0",
|
|
78
78
|
"react": "^19.0.0"
|
|
79
79
|
},
|
|
80
80
|
"scripts": {
|
|
81
|
-
"build": "vite build",
|
|
81
|
+
"build": "vite build && tsc --emitDeclarationOnly",
|
|
82
82
|
"typecheck": "tsc --noEmit",
|
|
83
83
|
"dev": "vite build --watch",
|
|
84
84
|
"test": "vitest run",
|