@fluixi/oauth2 1.0.0-alpha.9 → 1.0.0-alpha.99
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/LICENSE +1 -1
- package/dist/backchannel.cjs +462 -0
- package/dist/backchannel.d.ts +39 -0
- package/dist/backchannel.d.ts.map +1 -0
- package/dist/backchannel.js +97 -0
- package/dist/backchannel.mjs +307 -0
- package/dist/{browser-PKG6L5U5.mjs → browser-LQSO5OS2.mjs} +2 -2
- package/dist/browser.cjs +6 -1
- package/dist/browser.mjs +6 -1
- package/dist/callback.cjs +2 -2
- package/dist/callback.js +1 -1
- package/dist/callback.mjs +3 -3
- package/dist/chunk-32562UUL.mjs +108 -0
- package/dist/{chunk-R7EX3WEX.mjs → chunk-P6SSCHQX.mjs} +1 -1
- package/dist/{chunk-NROGDLGR.mjs → chunk-V27WQGTT.mjs} +1 -1
- package/dist/discovery.cjs +6 -1
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +6 -1
- package/dist/discovery.mjs +6 -1
- package/dist/dpop-2Q6R3KLB.mjs +22 -0
- package/dist/{dpop-Y4AOLAWB.mjs → dpop-4FGDUD4B.mjs} +4 -4
- package/dist/index.cjs +108 -8
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.mjs +112 -12
- package/dist/module.cjs +1 -1
- package/dist/module.mjs +1 -1
- package/dist/server.cjs +649 -137
- package/dist/server.d.ts +64 -4
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +376 -61
- package/dist/server.mjs +532 -139
- package/dist/service-client.cjs +7 -2
- package/dist/service-client.mjs +9 -4
- package/dist/service.cjs +104 -5
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +38 -6
- package/dist/service.mjs +105 -6
- package/dist/session-monitor.cjs +98 -0
- package/dist/session-monitor.d.ts +32 -0
- package/dist/session-monitor.d.ts.map +1 -0
- package/dist/session-monitor.js +104 -0
- package/dist/session-monitor.mjs +77 -0
- package/dist/tokens.cjs +1 -1
- package/dist/tokens.d.ts +2 -2
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +1 -1
- package/dist/tokens.mjs +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/verify.cjs +7 -2
- package/dist/verify.mjs +12 -7
- package/package.json +17 -15
package/dist/server.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ClientAuthMethodInput } from './client-auth.js';
|
|
2
|
+
import { type LogoutStore } from './backchannel.js';
|
|
2
3
|
import { type Endpoints } from './types.js';
|
|
3
4
|
import { type AppModule } from '@fluixi/start/app';
|
|
4
5
|
export interface OAuthRoutesConfig {
|
|
@@ -18,6 +19,12 @@ export interface OAuthRoutesConfig {
|
|
|
18
19
|
secureCookie?: boolean;
|
|
19
20
|
/** Where to send the browser after a login with no recorded destination. */
|
|
20
21
|
defaultReturnTo?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Where back-channel logouts are kept, between the route that hears them and the requests
|
|
24
|
+
* that end their sessions. Default: this process's memory, right for one instance; several
|
|
25
|
+
* instances share one (see `LogoutStore`).
|
|
26
|
+
*/
|
|
27
|
+
logouts?: LogoutStore;
|
|
21
28
|
/**
|
|
22
29
|
* Origins a login may return to besides this server's own.
|
|
23
30
|
*
|
|
@@ -64,13 +71,41 @@ export interface OAuthRoutesConfig {
|
|
|
64
71
|
dpop?: boolean;
|
|
65
72
|
/** Default `ES256`. Must be in the provider's `dpop_signing_alg_values_supported`. */
|
|
66
73
|
dpopAlgorithm?: string;
|
|
74
|
+
/**
|
|
75
|
+
* What a page request from a signed-out visitor does.
|
|
76
|
+
*
|
|
77
|
+
* - `manual` (default): the page renders signed out and offers a way to sign in.
|
|
78
|
+
* - `silent`: the visitor is sent to the provider with `prompt=none`. Someone already
|
|
79
|
+
* signed in there comes back signed in without a click; anyone else comes straight back
|
|
80
|
+
* and the page renders signed out, and is not asked again for `silentRecheck` seconds.
|
|
81
|
+
* Single sign-on without forcing a sign-in on a public page.
|
|
82
|
+
* - `required`: the visitor is sent to sign in. For an app with nothing to show to a
|
|
83
|
+
* stranger, an admin console say.
|
|
84
|
+
*
|
|
85
|
+
* Only page loads are redirected (a GET for a document), never an API or asset request.
|
|
86
|
+
*/
|
|
87
|
+
signIn?: 'manual' | 'silent' | 'required';
|
|
88
|
+
/**
|
|
89
|
+
* How long `silent` takes a "nobody signed in" answer as current, in seconds. Default 60.
|
|
90
|
+
* Someone who signs in at the provider afterwards (in another app, another tab) is picked
|
|
91
|
+
* up on their first page load after it. Longer saves round trips for anonymous visitors.
|
|
92
|
+
*/
|
|
93
|
+
silentRecheck?: number;
|
|
94
|
+
/** Paths `silent` and `required` leave alone, besides the auth routes: `/health`, `/legal`. */
|
|
95
|
+
publicPaths?: string[];
|
|
96
|
+
/**
|
|
97
|
+
* Paths that always need someone signed in, whatever `signIn` says for the rest: a public
|
|
98
|
+
* site with a private area (`/o` for a workspace) sends a signed-out page load there to
|
|
99
|
+
* sign in, and shows the other pages as `signIn` decides.
|
|
100
|
+
*/
|
|
101
|
+
protectedPaths?: string[];
|
|
67
102
|
}
|
|
68
103
|
/**
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* Handles `<basePath>/login`, `/callback`, `/refresh`, `/me` and `/logout`, and passes
|
|
72
|
-
* anything else along untouched.
|
|
104
|
+
* A request carrying the session's access token: the `DPoP` scheme and a proof bound to the
|
|
105
|
+
* token when the provider bound it, `Bearer` otherwise.
|
|
73
106
|
*/
|
|
107
|
+
/** `fetch`, as the signed-in user. What `locals.auth.fetch` is. */
|
|
108
|
+
export type AuthorizedFetch = (input: string | URL, init?: RequestInit) => Promise<Response>;
|
|
74
109
|
export declare function oauthRoutes(config: OAuthRoutesConfig): (request: Request, next: () => Promise<Response>) => Promise<Response>;
|
|
75
110
|
/**
|
|
76
111
|
* Put the signed-in user on the request, so a server render knows who is looking.
|
|
@@ -98,6 +133,30 @@ export declare function oauthRoutes(config: OAuthRoutesConfig): (request: Reques
|
|
|
98
133
|
* having its session resolved first.
|
|
99
134
|
*/
|
|
100
135
|
export declare function sessionLocals(config: OAuthRoutesConfig): (request: Request, next: () => Promise<Response>) => Promise<Response>;
|
|
136
|
+
/** What `sessionLocals` leaves on a request: the user, and a `fetch` that calls as them. */
|
|
137
|
+
export interface ServerAuth<U = unknown> {
|
|
138
|
+
user: U | null;
|
|
139
|
+
session: {
|
|
140
|
+
expiresAt?: number;
|
|
141
|
+
} | null;
|
|
142
|
+
/** Absent when nobody is signed in. */
|
|
143
|
+
fetch?: AuthorizedFetch;
|
|
144
|
+
/**
|
|
145
|
+
* The visitor has a session but the provider could not be reached to confirm it: tell them
|
|
146
|
+
* it is down, rather than asking them to sign in again.
|
|
147
|
+
*/
|
|
148
|
+
unreachable?: boolean;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* The request's auth, for server code: a route's data loader, a server function, an API route.
|
|
152
|
+
* Reads the current request's locals, or `request`'s when one is given.
|
|
153
|
+
*
|
|
154
|
+
* ```ts
|
|
155
|
+
* const { fetch } = await requestAuth();
|
|
156
|
+
* const projects = await fetch?.(`${apiUrl}/projects`).then((r) => r.json());
|
|
157
|
+
* ```
|
|
158
|
+
*/
|
|
159
|
+
export declare function requestAuth<U = unknown>(request?: Request): Promise<ServerAuth<U>>;
|
|
101
160
|
/**
|
|
102
161
|
* The server half of `authModule`, listed in `src/app.config.server.ts`: the routes and the
|
|
103
162
|
* session middleware that `tokens: 'server'` needs, in the order they have to run.
|
|
@@ -106,4 +165,5 @@ export declare function sessionLocals(config: OAuthRoutesConfig): (request: Requ
|
|
|
106
165
|
* session resolved on the way past.
|
|
107
166
|
*/
|
|
108
167
|
export declare function authServerModule(config: OAuthRoutesConfig): AppModule;
|
|
168
|
+
export { memoryLogouts, type LogoutEntry, type LogoutStore } from './backchannel.js';
|
|
109
169
|
//# sourceMappingURL=server.d.ts.map
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAgCA,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAgCA,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAqD,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEvG,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAExD,OAAO,EAAgB,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEjE,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,8EAA8E;IAC9E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,yFAAyF;IACzF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6EAA6E;IAC7E,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6EAA6E;IAC7E,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,4EAA4E;IAC5E,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB;;;;;;;OAOG;IACH,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC;;;;;OAKG;IACH,eAAe,CAAC,EAAE,qBAAqB,CAAC;IACxC,uDAAuD;IACvD,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OA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