@eventuras/fides-auth-next 1.0.0-beta.1 → 1.0.0-beta.3
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 +36 -12
- package/dist/auth.d.ts +38 -15
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +1 -0
- package/dist/auth.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -42,12 +42,16 @@ of an app is a confidential client.
|
|
|
42
42
|
|---|---|---|
|
|
43
43
|
| `sessionStore` | none | Keeps sessions in a store, with only a handle in the cookie. See below. |
|
|
44
44
|
| `storeFields` | none | `(session) => fields`. Plain fields to keep next to each stored session, e.g. your own user id. |
|
|
45
|
-
| `
|
|
45
|
+
| `sessionDurationSeconds` | 43200 (12 hours) | How long a session lasts from login, in seconds. Refreshes don't extend it. |
|
|
46
|
+
| `refreshGraceSeconds` | 10 | With cookie sessions: how long after a refresh a request with the old cookie gets that refresh's result. 0 turns it off. |
|
|
46
47
|
| `applicationUrl` | the redirect URI's origin | The app's public origin, for the same-origin check and redirects. |
|
|
47
48
|
| `mapSession` | none | Changes the session built at login, e.g. to add `data`. |
|
|
48
|
-
| `
|
|
49
|
+
| `mapRefresh` | none | Changes the session a refresh leaves, e.g. to have `data` follow the claims. |
|
|
50
|
+
| `rolesClaim` | `'roles'` | Where the user's roles are in the ID token, at login and on every refresh that brings one: a claim's name, or a function of the claims for a nested one. False leaves the roles to `mapSession`. See [the core README](../fides-auth/README.md#sessions). |
|
|
49
51
|
| `validateReturnTo` | a path on this origin | Turns `?returnTo=` into a safe path, or null. |
|
|
50
52
|
| `defaultRedirectPath` | `'/'` | Where a login without a return path lands. |
|
|
53
|
+
| `loginSuccessParam` | `true` | Adds `?login=success` to the return path after a login. False leaves the path as it was. |
|
|
54
|
+
| `onLoginError` | none | `(error, request) => Response \| undefined`. Answers a failed login in place of the redirect. |
|
|
51
55
|
| `postLogoutRedirectUri` | `applicationUrl` | Where the provider sends the user after logout. |
|
|
52
56
|
| `rateLimit` | none | `(request) => boolean`. The handlers answer 429 when it returns false. |
|
|
53
57
|
| `logger` | JSON lines on the console | A `FidesLoggerFactory`. |
|
|
@@ -70,7 +74,16 @@ export const GET = (request: Request) => auth.handleSessionInfo(request);
|
|
|
70
74
|
```
|
|
71
75
|
|
|
72
76
|
The callback's path must be the redirect URI's. Login takes `?returnTo=/path`
|
|
73
|
-
and lands there with `?login=success
|
|
77
|
+
and lands there with `?login=success`, or on the path as it was with
|
|
78
|
+
`loginSuccessParam: false`.
|
|
79
|
+
|
|
80
|
+
A login that fails lands on `defaultRedirectPath` with
|
|
81
|
+
`?login=error&error=<code>`: `login_expired` when the login took too long or
|
|
82
|
+
its cookie was lost, `login_unavailable` when the provider couldn't be
|
|
83
|
+
reached, or the provider's own code, such as `access_denied`. The handlers
|
|
84
|
+
never answer with text of their own. See
|
|
85
|
+
[When a login fails](../fides-auth/README.md#when-a-login-fails) for the codes
|
|
86
|
+
and for `onLoginError`.
|
|
74
87
|
|
|
75
88
|
Logout answers only a `POST` from the app's own pages, so a form does it:
|
|
76
89
|
|
|
@@ -80,8 +93,10 @@ Logout answers only a `POST` from the app's own pages, so a form does it:
|
|
|
80
93
|
</form>
|
|
81
94
|
```
|
|
82
95
|
|
|
83
|
-
`handleSessionInfo` answers whether there is a session, and
|
|
84
|
-
|
|
96
|
+
`handleSessionInfo` answers whether there is a session, whose, and when it
|
|
97
|
+
ends: `expiresAt` is the session's own end, which a refresh doesn't move, so a
|
|
98
|
+
page can warn before the user is logged out. It never refreshes and never
|
|
99
|
+
returns tokens. `handleHeartbeat` is there for apps that tie
|
|
85
100
|
refreshes to user activity; it too answers only a same-origin `POST`.
|
|
86
101
|
|
|
87
102
|
## Reading the session
|
|
@@ -92,12 +107,15 @@ In Server Components, Server Actions and Route Handlers:
|
|
|
92
107
|
const session = await auth.readSession(); // Session | null
|
|
93
108
|
const { session, reason } = await auth.tryReadSession();
|
|
94
109
|
const tokens = await auth.getTokens(); // Tokens | null
|
|
110
|
+
const both = await auth.readSessionWithTokens(); // { session, tokens } in one read
|
|
95
111
|
```
|
|
96
112
|
|
|
97
113
|
`readSession` and `tryReadSession` share one read per render. A `Session` has
|
|
98
114
|
`user`, `scopes`, `data`, `idp`, `correlationId`, `createdAt` and `expiresAt`.
|
|
99
115
|
The tokens aren't on it: `getTokens` returns them, and `authorizedFetch` uses
|
|
100
|
-
them.
|
|
116
|
+
them. `getTokens` and `readSessionWithTokens` read every time, since a refresh
|
|
117
|
+
changes the tokens. A type argument, `createFidesAuth<AppData>(…)`, types
|
|
118
|
+
`data`.
|
|
101
119
|
|
|
102
120
|
`createSession`, `updateSession`, `refreshSession` and `clearSession` write
|
|
103
121
|
cookies, so they work in Server Actions and Route Handlers.
|
|
@@ -129,13 +147,16 @@ seconds; `ifExpiresWithin` changes that. The window never covers more than half
|
|
|
129
147
|
the token's lifetime, so a token shorter than the window isn't refreshed on
|
|
130
148
|
every request. It sets the new cookies on the response and on the request it
|
|
131
149
|
forwards, so the page renders with the refreshed session. A request without a
|
|
132
|
-
session cookie passes straight through, and a failed refresh leaves
|
|
133
|
-
as it is.
|
|
150
|
+
session cookie passes straight through, and a failed refresh leaves a cookie
|
|
151
|
+
session as it is. A session in a store with `withLock` is ended when the
|
|
152
|
+
provider refuses the refresh for good, and its cookie is deleted with it.
|
|
134
153
|
|
|
135
154
|
The proxy runs for every request a page makes, prefetches included. With cookie
|
|
136
|
-
sessions
|
|
137
|
-
|
|
138
|
-
|
|
155
|
+
sessions, a request sent before the new cookies arrived still carries the old
|
|
156
|
+
refresh token. For `refreshGraceSeconds` after a refresh, 10 by default, it
|
|
157
|
+
gets that refresh's result. After that, or on another instance, it spends the
|
|
158
|
+
old token again, which fails with `invalid_grant` when the provider rotates
|
|
159
|
+
refresh tokens; see
|
|
139
160
|
[Keeping the session fresh](../fides-auth/README.md#keeping-the-session-fresh)
|
|
140
161
|
in the core README. A `sessionStore` avoids it.
|
|
141
162
|
|
|
@@ -145,7 +166,10 @@ To send users without a session to the login, check the cookie first:
|
|
|
145
166
|
import { NextResponse, type NextRequest } from "next/server";
|
|
146
167
|
|
|
147
168
|
export function proxy(request: NextRequest) {
|
|
148
|
-
|
|
169
|
+
// A login that just failed lands here with ?login=error. Sending it to the
|
|
170
|
+
// login again would go in circles.
|
|
171
|
+
const failed = request.nextUrl.searchParams.get("login") === "error";
|
|
172
|
+
if (!failed && !request.cookies.has(auth.cookieNames.session)) {
|
|
149
173
|
return NextResponse.redirect(new URL("/api/auth/login", request.url));
|
|
150
174
|
}
|
|
151
175
|
return auth.refreshInProxy(request);
|
package/dist/auth.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { Session, TokenResponse, Tokens } from '@eventuras/fides-auth';
|
|
7
7
|
import type { OidcClient } from '@eventuras/fides-auth/oidc';
|
|
8
|
-
import { type FidesAuthConfig, type FidesAuthorizedFetchOptions, type FidesReadResult, type FidesRefreshResult, type RefreshSessionOptions } from '@eventuras/fides-auth/server';
|
|
8
|
+
import { type FidesAuthConfig, type FidesAuthorizedFetchOptions, type FidesReadResult, type FidesRefreshResult, type FidesSessionWithTokens, type RefreshSessionOptions } from '@eventuras/fides-auth/server';
|
|
9
9
|
import type { SessionClearedTrigger } from '@eventuras/fides-auth/session-events';
|
|
10
10
|
import { type NextRequest, NextResponse } from 'next/server';
|
|
11
11
|
/** Options for {@link FidesAuth.refreshInProxy}. */
|
|
@@ -17,8 +17,11 @@ export interface RefreshInProxyOptions {
|
|
|
17
17
|
*/
|
|
18
18
|
ifExpiresWithin?: number;
|
|
19
19
|
}
|
|
20
|
-
/**
|
|
21
|
-
|
|
20
|
+
/**
|
|
21
|
+
* The core instance's members, bound to the request's cookies. `TData` is the
|
|
22
|
+
* type of `session.data`.
|
|
23
|
+
*/
|
|
24
|
+
export interface FidesAuth<TData = Record<string, unknown>> {
|
|
22
25
|
/** `GET`, with an optional `?returnTo=`. Redirects to the provider. */
|
|
23
26
|
handleOidcLogin(request: Request, options?: {
|
|
24
27
|
authorizationParameters?: Record<string, string>;
|
|
@@ -38,22 +41,37 @@ export interface FidesAuth {
|
|
|
38
41
|
/** `GET`. Whether there is a session, and whose. Never refreshes, never returns tokens. */
|
|
39
42
|
handleSessionInfo(request: Request): Promise<Response>;
|
|
40
43
|
/** The session, or null. Cached per render. */
|
|
41
|
-
readSession(): Promise<Session | null>;
|
|
44
|
+
readSession(): Promise<Session<TData> | null>;
|
|
42
45
|
/** The session, or why there is none. Cached per render, together with `readSession`. */
|
|
43
|
-
tryReadSession(): Promise<FidesReadResult
|
|
46
|
+
tryReadSession(): Promise<FidesReadResult<TData>>;
|
|
44
47
|
/** The session's tokens, or null without a session. The access token may have expired. */
|
|
45
48
|
getTokens(): Promise<Tokens | null>;
|
|
49
|
+
/**
|
|
50
|
+
* The session and its tokens in one read, or why there is none. Not cached
|
|
51
|
+
* per render, since a refresh changes the tokens. The tokens are for the
|
|
52
|
+
* server: hand a Client Component `session`, never this result.
|
|
53
|
+
*/
|
|
54
|
+
readSessionWithTokens(): Promise<FidesSessionWithTokens<TData>>;
|
|
46
55
|
/**
|
|
47
56
|
* Refreshes the tokens, or with `ifExpiresWithin` only when the access token
|
|
48
57
|
* is about to expire. With cookie sessions this writes cookies, so it works
|
|
49
58
|
* only in Server Actions and Route Handlers; pages get theirs from
|
|
50
59
|
* `refreshInProxy`.
|
|
51
60
|
*/
|
|
52
|
-
refreshSession(options?: RefreshSessionOptions): Promise<FidesRefreshResult
|
|
53
|
-
/**
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
61
|
+
refreshSession(options?: RefreshSessionOptions): Promise<FidesRefreshResult<TData>>;
|
|
62
|
+
/**
|
|
63
|
+
* Starts a session from a token response, for a login that doesn't go through
|
|
64
|
+
* the handlers. `scopes` come from the response's `scope`; when the provider
|
|
65
|
+
* leaves it out, pass it along, e.g. `{ ...tokens, scope }`.
|
|
66
|
+
*/
|
|
67
|
+
createSession(tokens: TokenResponse): Promise<Session<TData>>;
|
|
68
|
+
/**
|
|
69
|
+
* Changes the user or data. Null when there is no session. It waits its
|
|
70
|
+
* turn after a refresh or another update of the session, and `update` gets
|
|
71
|
+
* the session as it is then, so `update` must not refresh or update the
|
|
72
|
+
* same session itself.
|
|
73
|
+
*/
|
|
74
|
+
updateSession(update: (session: Session<TData>) => Session<TData> | Promise<Session<TData>>): Promise<Session<TData> | null>;
|
|
57
75
|
/**
|
|
58
76
|
* Ends the session and revokes its refresh token where the provider has a
|
|
59
77
|
* revocation endpoint. With a store, the record is deleted too. `trigger`
|
|
@@ -64,8 +82,11 @@ export interface FidesAuth {
|
|
|
64
82
|
}): Promise<void>;
|
|
65
83
|
/**
|
|
66
84
|
* Ends every session of one user, wherever they are signed in, and revokes
|
|
67
|
-
* their refresh tokens. `sub` is the provider's, from the ID token.
|
|
68
|
-
*
|
|
85
|
+
* their refresh tokens. `sub` is the provider's, from the ID token. `iss`
|
|
86
|
+
* defaults to the provider's issuer from its metadata. When the provider
|
|
87
|
+
* can't be reached, it is the issuer this instance last saw, or else
|
|
88
|
+
* `oauthConfig.issuer`: pass `iss` when your ID tokens spell the issuer
|
|
89
|
+
* differently from your config. Needs a `sessionStore` with `findMatching`.
|
|
69
90
|
*
|
|
70
91
|
* @returns How many sessions it ended.
|
|
71
92
|
*/
|
|
@@ -90,9 +111,11 @@ export interface FidesAuth {
|
|
|
90
111
|
* Sets the new cookies on the response and on the request it forwards, so
|
|
91
112
|
* the page reads the refreshed session.
|
|
92
113
|
*
|
|
93
|
-
* A failed refresh leaves
|
|
114
|
+
* A failed refresh leaves a cookie session as it is. The next API call or
|
|
94
115
|
* heartbeat shows a session that is over; ending it here could undo a refresh
|
|
95
|
-
* that another instance completed with the same refresh token.
|
|
116
|
+
* that another instance completed with the same refresh token. A session in
|
|
117
|
+
* a store with `withLock` is ended when the provider refuses the refresh for
|
|
118
|
+
* good, and its cookie is deleted, on the response and on the request it forwards.
|
|
96
119
|
*/
|
|
97
120
|
refreshInProxy(request: NextRequest, options?: RefreshInProxyOptions): Promise<NextResponse>;
|
|
98
121
|
/** The session cookie's name, for a proxy that checks whether one is present. */
|
|
@@ -119,5 +142,5 @@ export interface FidesAuth {
|
|
|
119
142
|
* const session = await auth.readSession();
|
|
120
143
|
* ```
|
|
121
144
|
*/
|
|
122
|
-
export declare function createFidesAuth(config: FidesAuthConfig): FidesAuth
|
|
145
|
+
export declare function createFidesAuth<TData = Record<string, unknown>>(config: FidesAuthConfig<TData>): FidesAuth<TData>;
|
|
123
146
|
//# sourceMappingURL=auth.d.ts.map
|
package/dist/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAiB,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC3F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,2BAA2B,EAChC,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC3B,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAClF,OAAO,EAAE,KAAK,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAK7D,oDAAoD;AACpD,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAiB,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC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OAAO,CAAC;QAAE,QAAQ,EAAE,QAAQ,CAAC;QAAC,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC,CAAC;IAC5C;;;;;;;;;;;;OAYG;IACH,cAAc,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAE7F,iFAAiF;IACjF,QAAQ,CAAC,WAAW,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1C,sEAAsE;IACtE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;CAC3B;AA6CD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7D,MAAM,EAAE,eAAe,CAAC,KAAK,CAAC,GAC7B,SAAS,CAAC,KAAK,CAAC,CA0ClB"}
|
package/dist/auth.js
CHANGED
|
@@ -64,6 +64,7 @@ function createFidesAuth$1(config) {
|
|
|
64
64
|
readSession: cache(async () => (await tryReadSession()).session),
|
|
65
65
|
tryReadSession,
|
|
66
66
|
getTokens: async () => core.getTokens(await nextCookieStore()),
|
|
67
|
+
readSessionWithTokens: async () => core.readSessionWithTokens(await nextCookieStore()),
|
|
67
68
|
refreshSession: async (options) => core.refreshSession(await nextCookieStore(), options),
|
|
68
69
|
createSession: async (tokens) => core.createSession(await nextCookieStore(), tokens),
|
|
69
70
|
updateSession: async (update) => core.updateSession(await nextCookieStore(), update),
|
package/dist/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","names":["createFidesAuth","createCoreFidesAuth"],"sources":["../src/auth.ts"],"sourcesContent":["/**\n * createFidesAuth for Next.js. The core instance takes a CookieStore on every\n * call; this one gets it from `cookies()` in next/headers, caches session reads\n * per render, and adds refreshInProxy for `proxy.ts`.\n */\n\nimport type { CookieOptions, Session, TokenResponse, Tokens } from '@eventuras/fides-auth';\nimport type { OidcClient } from '@eventuras/fides-auth/oidc';\nimport {\n createFidesAuth as createCoreFidesAuth,\n type CookieStore,\n type FidesAuthConfig,\n type FidesAuthorizedFetchOptions,\n type FidesReadResult,\n type FidesRefreshResult,\n type RefreshSessionOptions,\n} from '@eventuras/fides-auth/server';\nimport type { SessionClearedTrigger } from '@eventuras/fides-auth/session-events';\nimport { type NextRequest, NextResponse } from 'next/server';\nimport { cache } from 'react';\n\nimport { nextCookieStore } from './cookie-store.js';\n\n/** Options for {@link FidesAuth.refreshInProxy}. */\nexport interface RefreshInProxyOptions {\n /**\n * Refresh when the access token expires within this many seconds, or within\n * half its lifetime if that is shorter.\n * @default 60\n */\n ifExpiresWithin?: number;\n}\n\n/** The core instance's members, bound to the request's cookies. */\nexport interface FidesAuth {\n /** `GET`, with an optional `?returnTo=`. Redirects to the provider. */\n handleOidcLogin(\n request: Request,\n options?: { authorizationParameters?: Record<string, string> },\n ): Promise<Response>;\n /** The provider's redirect back. Starts the session and redirects to the return path. */\n handleOidcCallback(request: Request): Promise<Response>;\n /**\n * `POST`. Ends the session, revokes its refresh token where the provider has\n * a revocation endpoint, and redirects to the provider's end-session endpoint.\n */\n handleOidcLogout(\n request: Request,\n options?: { state?: string; logoutHint?: string },\n ): Promise<Response>;\n /** `POST`. Refreshes the session. 401 means it is over; 503 means the provider or the store failed. */\n handleHeartbeat(request: Request): Promise<Response>;\n /** `GET`. Whether there is a session, and whose. Never refreshes, never returns tokens. */\n handleSessionInfo(request: Request): Promise<Response>;\n\n /** The session, or null. Cached per render. */\n readSession(): Promise<Session | null>;\n /** The session, or why there is none. Cached per render, together with `readSession`. */\n tryReadSession(): Promise<FidesReadResult>;\n /** The session's tokens, or null without a session. The access token may have expired. */\n getTokens(): Promise<Tokens | null>;\n /**\n * Refreshes the tokens, or with `ifExpiresWithin` only when the access token\n * is about to expire. With cookie sessions this writes cookies, so it works\n * only in Server Actions and Route Handlers; pages get theirs from\n * `refreshInProxy`.\n */\n refreshSession(options?: RefreshSessionOptions): Promise<FidesRefreshResult>;\n /** Starts a session from a token response, for a login that doesn't go through the handlers. */\n createSession(tokens: TokenResponse): Promise<Session>;\n /** Changes the user or data. Null when there is no session. */\n updateSession(update: (session: Session) => Session | Promise<Session>): Promise<Session | null>;\n /**\n * Ends the session and revokes its refresh token where the provider has a\n * revocation endpoint. With a store, the record is deleted too. `trigger`\n * defaults to `'logout'`.\n */\n clearSession(options?: { trigger?: SessionClearedTrigger }): Promise<void>;\n /**\n * Ends every session of one user, wherever they are signed in, and revokes\n * their refresh tokens. `sub` is the provider's, from the ID token. Needs a\n * `sessionStore` with `findMatching`.\n *\n * @returns How many sessions it ended.\n */\n endUserSessions(\n user: { sub: string; iss?: string },\n options?: { trigger?: SessionClearedTrigger },\n ): Promise<number>;\n /**\n * Calls an API with the session's access token. It never refreshes, so it is\n * safe in a Server Component; a 401 is an `http_error`.\n */\n authorizedFetch<T = undefined>(\n url: string | URL,\n options: FidesAuthorizedFetchOptions<T>,\n ): Promise<{ response: Response; data: T }>;\n /**\n * For `proxy.ts`. Refreshes a session whose access token expires within\n * `ifExpiresWithin` seconds, or within half its lifetime if that is shorter,\n * before the page renders, since a Server Component can't save a refresh.\n * Sets the new cookies on the response and on the request it forwards, so\n * the page reads the refreshed session.\n *\n * A failed refresh leaves the session as it is. The next API call or\n * heartbeat shows a session that is over; ending it here could undo a refresh\n * that another instance completed with the same refresh token.\n */\n refreshInProxy(request: NextRequest, options?: RefreshInProxyOptions): Promise<NextResponse>;\n\n /** The session cookie's name, for a proxy that checks whether one is present. */\n readonly cookieNames: { session: string };\n /** The instance's OIDC client, for protocol calls it doesn't wrap. */\n readonly oidc: OidcClient;\n}\n\n/** A cookie written while the proxy handled a request. `maxAge: 0` deletes it. */\ninterface CookieWrite {\n value: string;\n options?: CookieOptions;\n}\n\n/**\n * A CookieStore over the proxied request's cookies, which records the writes\n * so they can go both to the browser and to the forwarded request.\n */\nfunction proxyCookieStore(request: NextRequest): {\n cookies: CookieStore;\n writes: Map<string, CookieWrite>;\n} {\n const writes = new Map<string, CookieWrite>();\n const cookies: CookieStore = {\n // A cookie written earlier in this request reads back, as it would in the browser.\n get: (name) => {\n const written = writes.get(name);\n if (written) return written.options?.maxAge === 0 ? null : written.value;\n return request.cookies.get(name)?.value ?? null;\n },\n set: (name, value, options) => {\n writes.set(name, { value, options });\n },\n };\n return { cookies, writes };\n}\n\n/** Continues the request, carrying the cookie writes to the page and to the browser. */\nfunction forward(request: NextRequest, writes: Map<string, CookieWrite>): NextResponse {\n if (writes.size === 0) return NextResponse.next();\n\n for (const [name, { value, options }] of writes) {\n if (options?.maxAge === 0) request.cookies.delete(name);\n else request.cookies.set(name, value);\n }\n const response = NextResponse.next({ request: { headers: request.headers } });\n // A delete is a set with `maxAge: 0`, so the browser gets it with the cookie's own attributes.\n for (const [name, { value, options }] of writes) response.cookies.set(name, value, options);\n return response;\n}\n\n/**\n * Creates the app's auth instance. Call it once, in a module of its own, and\n * import the result. It reads nothing from the environment: pass the secret and\n * the provider config in.\n *\n * @example\n * ```ts\n * // lib/auth.ts\n * export const auth = createFidesAuth({ oauthConfig, secret: process.env.SESSION_SECRET! });\n *\n * // app/api/auth/login/route.ts\n * export const GET = (request: Request) => auth.handleOidcLogin(request);\n *\n * // A Server Component\n * const session = await auth.readSession();\n * ```\n */\nexport function createFidesAuth(config: FidesAuthConfig): FidesAuth {\n const core = createCoreFidesAuth(config);\n\n const tryReadSession = cache(\n async (): Promise<FidesReadResult> => core.tryReadSession(await nextCookieStore()),\n );\n\n return {\n handleOidcLogin: async (request, options) =>\n core.handleOidcLogin(request, await nextCookieStore(), options),\n handleOidcCallback: async (request) => core.handleOidcCallback(request, await nextCookieStore()),\n handleOidcLogout: async (request, options) =>\n core.handleOidcLogout(request, await nextCookieStore(), options),\n handleHeartbeat: async (request) => core.handleHeartbeat(request, await nextCookieStore()),\n handleSessionInfo: async (request) => core.handleSessionInfo(request, await nextCookieStore()),\n\n readSession: cache(async () => (await tryReadSession()).session),\n tryReadSession,\n getTokens: async () => core.getTokens(await nextCookieStore()),\n refreshSession: async (options) => core.refreshSession(await nextCookieStore(), options),\n createSession: async (tokens) => core.createSession(await nextCookieStore(), tokens),\n updateSession: async (update) => core.updateSession(await nextCookieStore(), update),\n clearSession: async (options) => core.clearSession(await nextCookieStore(), options),\n endUserSessions: (user, options) => core.endUserSessions(user, options),\n authorizedFetch: async (url, options) =>\n core.authorizedFetch(await nextCookieStore(), url, options),\n\n async refreshInProxy(request, { ifExpiresWithin = 60 } = {}) {\n // Without a session cookie there is nothing to refresh, and nothing to decrypt.\n if (!request.cookies.has(core.cookieNames.session)) return NextResponse.next();\n\n const { cookies, writes } = proxyCookieStore(request);\n await core.refreshSession(cookies, { ifExpiresWithin });\n return forward(request, writes);\n },\n\n get cookieNames() {\n return core.cookieNames;\n },\n oidc: core.oidc,\n };\n}\n"],"mappings":";;;;;;;;;AA8HA,SAAS,iBAAiB,SAGxB;CACA,MAAM,yBAAS,IAAI,IAAyB;CAY5C,OAAO;EAAE,SAAA;GATP,MAAM,SAAS;IACb,MAAM,UAAU,OAAO,IAAI,IAAI;IAC/B,IAAI,SAAS,OAAO,QAAQ,SAAS,WAAW,IAAI,OAAO,QAAQ;IACnE,OAAO,QAAQ,QAAQ,IAAI,IAAI,CAAC,EAAE,SAAS;GAC7C;GACA,MAAM,MAAM,OAAO,YAAY;IAC7B,OAAO,IAAI,MAAM;KAAE;KAAO;IAAQ,CAAC;GACrC;EAEO;EAAS;CAAO;AAC3B;;AAGA,SAAS,QAAQ,SAAsB,QAAgD;CACrF,IAAI,OAAO,SAAS,GAAG,OAAO,aAAa,KAAK;CAEhD,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,cAAc,QACvC,IAAI,SAAS,WAAW,GAAG,QAAQ,QAAQ,OAAO,IAAI;MACjD,QAAQ,QAAQ,IAAI,MAAM,KAAK;CAEtC,MAAM,WAAW,aAAa,KAAK,EAAE,SAAS,EAAE,SAAS,QAAQ,QAAQ,EAA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AQ,QAAQ,IAAI,KAAK,YAAY,OAAO,GAAG,OAAO,aAAa,KAAK;GAE7E,MAAM,EAAE,SAAS,WAAW,iBAAiB,OAAO;GACpD,MAAM,KAAK,eAAe,SAAS,EAAE,gBAAgB,CAAC;GACtD,OAAO,QAAQ,SAAS,MAAM;EAChC;EAEA,IAAI,cAAc;GAChB,OAAO,KAAK;EACd;EACA,MAAM,KAAK;CACb;AACF"}
|
|
1
|
+
{"version":3,"file":"auth.js","names":["createFidesAuth","createCoreFidesAuth"],"sources":["../src/auth.ts"],"sourcesContent":["/**\n * createFidesAuth for Next.js. The core instance takes a CookieStore on every\n * call; this one gets it from `cookies()` in next/headers, caches session reads\n * per render, and adds refreshInProxy for `proxy.ts`.\n */\n\nimport type { CookieOptions, Session, TokenResponse, Tokens } from '@eventuras/fides-auth';\nimport type { OidcClient } from '@eventuras/fides-auth/oidc';\nimport {\n createFidesAuth as createCoreFidesAuth,\n type CookieStore,\n type FidesAuthConfig,\n type FidesAuthorizedFetchOptions,\n type FidesReadResult,\n type FidesRefreshResult,\n type FidesSessionWithTokens,\n type RefreshSessionOptions,\n} from '@eventuras/fides-auth/server';\nimport type { SessionClearedTrigger } from '@eventuras/fides-auth/session-events';\nimport { type NextRequest, NextResponse } from 'next/server';\nimport { cache } from 'react';\n\nimport { nextCookieStore } from './cookie-store.js';\n\n/** Options for {@link FidesAuth.refreshInProxy}. */\nexport interface RefreshInProxyOptions {\n /**\n * Refresh when the access token expires within this many seconds, or within\n * half its lifetime if that is shorter.\n * @default 60\n */\n ifExpiresWithin?: number;\n}\n\n/**\n * The core instance's members, bound to the request's cookies. `TData` is the\n * type of `session.data`.\n */\nexport interface FidesAuth<TData = Record<string, unknown>> {\n /** `GET`, with an optional `?returnTo=`. Redirects to the provider. */\n handleOidcLogin(\n request: Request,\n options?: { authorizationParameters?: Record<string, string> },\n ): Promise<Response>;\n /** The provider's redirect back. Starts the session and redirects to the return path. */\n handleOidcCallback(request: Request): Promise<Response>;\n /**\n * `POST`. Ends the session, revokes its refresh token where the provider has\n * a revocation endpoint, and redirects to the provider's end-session endpoint.\n */\n handleOidcLogout(\n request: Request,\n options?: { state?: string; logoutHint?: string },\n ): Promise<Response>;\n /** `POST`. Refreshes the session. 401 means it is over; 503 means the provider or the store failed. */\n handleHeartbeat(request: Request): Promise<Response>;\n /** `GET`. Whether there is a session, and whose. Never refreshes, never returns tokens. */\n handleSessionInfo(request: Request): Promise<Response>;\n\n /** The session, or null. Cached per render. */\n readSession(): Promise<Session<TData> | null>;\n /** The session, or why there is none. Cached per render, together with `readSession`. */\n tryReadSession(): Promise<FidesReadResult<TData>>;\n /** The session's tokens, or null without a session. The access token may have expired. */\n getTokens(): Promise<Tokens | null>;\n /**\n * The session and its tokens in one read, or why there is none. Not cached\n * per render, since a refresh changes the tokens. The tokens are for the\n * server: hand a Client Component `session`, never this result.\n */\n readSessionWithTokens(): Promise<FidesSessionWithTokens<TData>>;\n /**\n * Refreshes the tokens, or with `ifExpiresWithin` only when the access token\n * is about to expire. With cookie sessions this writes cookies, so it works\n * only in Server Actions and Route Handlers; pages get theirs from\n * `refreshInProxy`.\n */\n refreshSession(options?: RefreshSessionOptions): Promise<FidesRefreshResult<TData>>;\n /**\n * Starts a session from a token response, for a login that doesn't go through\n * the handlers. `scopes` come from the response's `scope`; when the provider\n * leaves it out, pass it along, e.g. `{ ...tokens, scope }`.\n */\n createSession(tokens: TokenResponse): Promise<Session<TData>>;\n /**\n * Changes the user or data. Null when there is no session. It waits its\n * turn after a refresh or another update of the session, and `update` gets\n * the session as it is then, so `update` must not refresh or update the\n * same session itself.\n */\n updateSession(\n update: (session: Session<TData>) => Session<TData> | Promise<Session<TData>>,\n ): Promise<Session<TData> | null>;\n /**\n * Ends the session and revokes its refresh token where the provider has a\n * revocation endpoint. With a store, the record is deleted too. `trigger`\n * defaults to `'logout'`.\n */\n clearSession(options?: { trigger?: SessionClearedTrigger }): Promise<void>;\n /**\n * Ends every session of one user, wherever they are signed in, and revokes\n * their refresh tokens. `sub` is the provider's, from the ID token. `iss`\n * defaults to the provider's issuer from its metadata. When the provider\n * can't be reached, it is the issuer this instance last saw, or else\n * `oauthConfig.issuer`: pass `iss` when your ID tokens spell the issuer\n * differently from your config. Needs a `sessionStore` with `findMatching`.\n *\n * @returns How many sessions it ended.\n */\n endUserSessions(\n user: { sub: string; iss?: string },\n options?: { trigger?: SessionClearedTrigger },\n ): Promise<number>;\n /**\n * Calls an API with the session's access token. It never refreshes, so it is\n * safe in a Server Component; a 401 is an `http_error`.\n */\n authorizedFetch<T = undefined>(\n url: string | URL,\n options: FidesAuthorizedFetchOptions<T>,\n ): Promise<{ response: Response; data: T }>;\n /**\n * For `proxy.ts`. Refreshes a session whose access token expires within\n * `ifExpiresWithin` seconds, or within half its lifetime if that is shorter,\n * before the page renders, since a Server Component can't save a refresh.\n * Sets the new cookies on the response and on the request it forwards, so\n * the page reads the refreshed session.\n *\n * A failed refresh leaves a cookie session as it is. The next API call or\n * heartbeat shows a session that is over; ending it here could undo a refresh\n * that another instance completed with the same refresh token. A session in\n * a store with `withLock` is ended when the provider refuses the refresh for\n * good, and its cookie is deleted, on the response and on the request it forwards.\n */\n refreshInProxy(request: NextRequest, options?: RefreshInProxyOptions): Promise<NextResponse>;\n\n /** The session cookie's name, for a proxy that checks whether one is present. */\n readonly cookieNames: { session: string };\n /** The instance's OIDC client, for protocol calls it doesn't wrap. */\n readonly oidc: OidcClient;\n}\n\n/** A cookie written while the proxy handled a request. `maxAge: 0` deletes it. */\ninterface CookieWrite {\n value: string;\n options?: CookieOptions;\n}\n\n/**\n * A CookieStore over the proxied request's cookies, which records the writes\n * so they can go both to the browser and to the forwarded request.\n */\nfunction proxyCookieStore(request: NextRequest): {\n cookies: CookieStore;\n writes: Map<string, CookieWrite>;\n} {\n const writes = new Map<string, CookieWrite>();\n const cookies: CookieStore = {\n // A cookie written earlier in this request reads back, as it would in the browser.\n get: (name) => {\n const written = writes.get(name);\n if (written) return written.options?.maxAge === 0 ? null : written.value;\n return request.cookies.get(name)?.value ?? null;\n },\n set: (name, value, options) => {\n writes.set(name, { value, options });\n },\n };\n return { cookies, writes };\n}\n\n/** Continues the request, carrying the cookie writes to the page and to the browser. */\nfunction forward(request: NextRequest, writes: Map<string, CookieWrite>): NextResponse {\n if (writes.size === 0) return NextResponse.next();\n\n for (const [name, { value, options }] of writes) {\n if (options?.maxAge === 0) request.cookies.delete(name);\n else request.cookies.set(name, value);\n }\n const response = NextResponse.next({ request: { headers: request.headers } });\n // A delete is a set with `maxAge: 0`, so the browser gets it with the cookie's own attributes.\n for (const [name, { value, options }] of writes) response.cookies.set(name, value, options);\n return response;\n}\n\n/**\n * Creates the app's auth instance. Call it once, in a module of its own, and\n * import the result. It reads nothing from the environment: pass the secret and\n * the provider config in.\n *\n * @example\n * ```ts\n * // lib/auth.ts\n * export const auth = createFidesAuth({ oauthConfig, secret: process.env.SESSION_SECRET! });\n *\n * // app/api/auth/login/route.ts\n * export const GET = (request: Request) => auth.handleOidcLogin(request);\n *\n * // A Server Component\n * const session = await auth.readSession();\n * ```\n */\nexport function createFidesAuth<TData = Record<string, unknown>>(\n config: FidesAuthConfig<TData>,\n): FidesAuth<TData> {\n const core = createCoreFidesAuth(config);\n\n const tryReadSession = cache(\n async (): Promise<FidesReadResult<TData>> => core.tryReadSession(await nextCookieStore()),\n );\n\n return {\n handleOidcLogin: async (request, options) =>\n core.handleOidcLogin(request, await nextCookieStore(), options),\n handleOidcCallback: async (request) => core.handleOidcCallback(request, await nextCookieStore()),\n handleOidcLogout: async (request, options) =>\n core.handleOidcLogout(request, await nextCookieStore(), options),\n handleHeartbeat: async (request) => core.handleHeartbeat(request, await nextCookieStore()),\n handleSessionInfo: async (request) => core.handleSessionInfo(request, await nextCookieStore()),\n\n readSession: cache(async () => (await tryReadSession()).session),\n tryReadSession,\n getTokens: async () => core.getTokens(await nextCookieStore()),\n readSessionWithTokens: async () => core.readSessionWithTokens(await nextCookieStore()),\n refreshSession: async (options) => core.refreshSession(await nextCookieStore(), options),\n createSession: async (tokens) => core.createSession(await nextCookieStore(), tokens),\n updateSession: async (update) => core.updateSession(await nextCookieStore(), update),\n clearSession: async (options) => core.clearSession(await nextCookieStore(), options),\n endUserSessions: (user, options) => core.endUserSessions(user, options),\n authorizedFetch: async (url, options) =>\n core.authorizedFetch(await nextCookieStore(), url, options),\n\n async refreshInProxy(request, { ifExpiresWithin = 60 } = {}) {\n // Without a session cookie there is nothing to refresh, and nothing to decrypt.\n if (!request.cookies.has(core.cookieNames.session)) return NextResponse.next();\n\n const { cookies, writes } = proxyCookieStore(request);\n await core.refreshSession(cookies, { ifExpiresWithin });\n return forward(request, writes);\n },\n\n get cookieNames() {\n return core.cookieNames;\n },\n oidc: core.oidc,\n };\n}\n"],"mappings":";;;;;;;;;AAwJA,SAAS,iBAAiB,SAGxB;CACA,MAAM,yBAAS,IAAI,IAAyB;CAY5C,OAAO;EAAE,SAAA;GATP,MAAM,SAAS;IACb,MAAM,UAAU,OAAO,IAAI,IAAI;IAC/B,IAAI,SAAS,OAAO,QAAQ,SAAS,WAAW,IAAI,OAAO,QAAQ;IACnE,OAAO,QAAQ,QAAQ,IAAI,IAAI,CAAC,EAAE,SAAS;GAC7C;GACA,MAAM,MAAM,OAAO,YAAY;IAC7B,OAAO,IAAI,MAAM;KAAE;KAAO;IAAQ,CAAC;GACrC;EAEO;EAAS;CAAO;AAC3B;;AAGA,SAAS,QAAQ,SAAsB,QAAgD;CACrF,IAAI,OAAO,SAAS,GAAG,OAAO,aAAa,KAAK;CAEhD,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,cAAc,QACvC,IAAI,SAAS,WAAW,GAAG,QAAQ,QAAQ,OAAO,IAAI;MACjD,QAAQ,QAAQ,IAAI,MAAM,KAAK;CAEtC,MAAM,WAAW,aAAa,KAAK,EAAE,SAAS,EAAE,SAAS,QAAQ,QAAQ,EAAE,CAAC;CAE5E,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,cAAc,QAAQ,SAAS,Q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AAK,YAAY,OAAO,GAAG,OAAO,aAAa,KAAK;GAE7E,MAAM,EAAE,SAAS,WAAW,iBAAiB,OAAO;GACpD,MAAM,KAAK,eAAe,SAAS,EAAE,gBAAgB,CAAC;GACtD,OAAO,QAAQ,SAAS,MAAM;EAChC;EAEA,IAAI,cAAc;GAChB,OAAO,KAAK;EACd;EACA,MAAM,KAAK;CACb;AACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { createFidesAuth, type FidesAuth, type RefreshInProxyOptions, } from './auth.js';
|
|
2
2
|
export { nextCookieStore } from './cookie-store.js';
|
|
3
|
-
export type { Session, SessionInfo, TokenResponse, Tokens } from '@eventuras/fides-auth';
|
|
4
|
-
export type { CookieStore, FidesAuthConfig, FidesAuthorizedFetchOptions, FidesReadResult, FidesRefreshResult, MapSession, RefreshSessionOptions, SessionMatch, SessionStore, StoredSession, StoredSessionEntry, StoreFields, StoreSetContext, } from '@eventuras/fides-auth/server';
|
|
3
|
+
export type { Session, SessionInfo, SessionUser, TokenResponse, Tokens } from '@eventuras/fides-auth';
|
|
4
|
+
export type { CookieStore, FidesAuthConfig, FidesAuthorizedFetchOptions, FidesReadResult, FidesRefreshResult, FidesSessionWithTokens, LoginError, LoginErrorCode, MapSession, RefreshSessionOptions, RolesClaim, SessionMatch, SessionStore, StoredSession, StoredSessionEntry, StoreFields, StoreSetContext, StoreSetReason, } from '@eventuras/fides-auth/server';
|
|
5
5
|
//# 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":"AAAA,OAAO,EACL,eAAe,EACf,KAAK,SAAS,EACd,KAAK,qBAAqB,GAC3B,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,KAAK,SAAS,EACd,KAAK,qBAAqB,GAC3B,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACtG,YAAY,EACV,WAAW,EACX,eAAe,EACf,2BAA2B,EAC3B,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EACtB,UAAU,EACV,cAAc,EACd,UAAU,EACV,qBAAqB,EACrB,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,WAAW,EACX,eAAe,EACf,cAAc,GACf,MAAM,8BAA8B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eventuras/fides-auth-next",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.3",
|
|
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": {
|
|
@@ -31,14 +31,14 @@
|
|
|
31
31
|
"typescript": "^7.0.2",
|
|
32
32
|
"vite": "^8.3.5",
|
|
33
33
|
"vitest": "^4.1.10",
|
|
34
|
-
"@eventuras/fides-auth": "1.0.0-beta.
|
|
34
|
+
"@eventuras/fides-auth": "1.0.0-beta.3",
|
|
35
35
|
"@eventuras/typescript-config": "1.0.0",
|
|
36
36
|
"@eventuras/vite-config": "0.3.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"next": "^16.0.0",
|
|
40
40
|
"react": "^19.0.0",
|
|
41
|
-
"@eventuras/fides-auth": "^1.0.0-beta.
|
|
41
|
+
"@eventuras/fides-auth": "^1.0.0-beta.3"
|
|
42
42
|
},
|
|
43
43
|
"engines": {
|
|
44
44
|
"node": ">=22"
|