@lpshanley/oidc-start-react 0.6.0 → 0.7.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 +2 -0
- package/dist/functions.d.ts +4 -1
- package/dist/functions.js +5 -2
- package/dist/functions.server.js +1 -0
- package/dist/middleware.d.ts +5 -3
- package/dist/middleware.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -51,6 +51,8 @@ export const startInstance = createStart(() => ({
|
|
|
51
51
|
}))
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
+
`oidcMiddleware` serves one core. The `core` function takes no arguments and runs once, on the first request; its result is reused for every request after. It cannot pick a configuration per request.
|
|
55
|
+
|
|
54
56
|
## 3. Add the callback route
|
|
55
57
|
|
|
56
58
|
Create `src/routes/callback.ts`. The handler checks the provider response, establishes the session, and redirects to the local path chosen at sign-in.
|
package/dist/functions.d.ts
CHANGED
|
@@ -40,7 +40,10 @@ export declare function requireRecentAuth(options: GuardOptions & {
|
|
|
40
40
|
roles?: string[] | undefined;
|
|
41
41
|
};
|
|
42
42
|
}>;
|
|
43
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* An authorization URL; also starts a flow and queues its verifier cookie.
|
|
45
|
+
* That is a state change, so it is a POST and the CSRF middleware covers it.
|
|
46
|
+
*/
|
|
44
47
|
export declare const getSignInUrl: import("@tanstack/react-start").OptionalFetcher<undefined, z.ZodOptional<z.ZodObject<{
|
|
45
48
|
returnPathname: z.ZodOptional<z.ZodString>;
|
|
46
49
|
maxAge: z.ZodOptional<z.ZodNumber>;
|
package/dist/functions.js
CHANGED
|
@@ -37,8 +37,11 @@ export async function requireRecentAuth(options) {
|
|
|
37
37
|
redirectToSignIn(options, options.maxAge);
|
|
38
38
|
return { user };
|
|
39
39
|
}
|
|
40
|
-
/**
|
|
41
|
-
|
|
40
|
+
/**
|
|
41
|
+
* An authorization URL; also starts a flow and queues its verifier cookie.
|
|
42
|
+
* That is a state change, so it is a POST and the CSRF middleware covers it.
|
|
43
|
+
*/
|
|
44
|
+
export const getSignInUrl = createServerFn({ method: "POST" })
|
|
42
45
|
.validator(signInOptionsSchema.optional())
|
|
43
46
|
.handler(async ({ data }) => {
|
|
44
47
|
const { getSignInUrlBody } = await import("./functions.server.js");
|
package/dist/functions.server.js
CHANGED
|
@@ -20,6 +20,7 @@ export function getRecentAuthBody(maxAge) {
|
|
|
20
20
|
return checkRecentAuth({ maxAge }).isStale ? { user: null } : auth;
|
|
21
21
|
}
|
|
22
22
|
export async function getSignInUrlBody(options) {
|
|
23
|
+
setResponseHeader("Cache-Control", "no-store");
|
|
23
24
|
const context = getOidcContext();
|
|
24
25
|
const { url, setCookies } = await context.core.signIn(context.request, context.cookies, options, context.call);
|
|
25
26
|
for (const line of setCookies)
|
package/dist/middleware.d.ts
CHANGED
|
@@ -3,10 +3,12 @@ import type { OidcContext } from "./context.js";
|
|
|
3
3
|
import type { OidcCore } from "@lpshanley/oidc-start-core";
|
|
4
4
|
export type OidcMiddlewareSetup = OidcMiddlewareOptions | {
|
|
5
5
|
/**
|
|
6
|
-
* A core the app composed itself
|
|
7
|
-
* the
|
|
6
|
+
* A core the app composed itself. One middleware serves one core:
|
|
7
|
+
* this is called once, on the first request, and the result is
|
|
8
|
+
* reused for every request after. It cannot choose a core per
|
|
9
|
+
* request. For several tenants, create one middleware per tenant.
|
|
8
10
|
*/
|
|
9
|
-
core: (
|
|
11
|
+
core: () => OidcCore;
|
|
10
12
|
};
|
|
11
13
|
/**
|
|
12
14
|
* Request middleware after WorkOS's authkitMiddleware: resolves the session
|
package/dist/middleware.js
CHANGED
|
@@ -22,7 +22,7 @@ export function oidcMiddleware(setup) {
|
|
|
22
22
|
let core;
|
|
23
23
|
return createMiddleware({ type: "request" }).server(async ({ request, next, context }) => {
|
|
24
24
|
if ("core" in setup)
|
|
25
|
-
core ??= setup.core(
|
|
25
|
+
core ??= setup.core();
|
|
26
26
|
else {
|
|
27
27
|
const { createOidcCore } = await import("@lpshanley/oidc-start-core");
|
|
28
28
|
core ??= createOidcCore(setup);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lpshanley/oidc-start-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"node": ">=22.12.0"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@lpshanley/oidc-start-core": "0.
|
|
43
|
+
"@lpshanley/oidc-start-core": "0.7.0",
|
|
44
44
|
"zod": "4.6.7"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|