@sourceregistry/sveltekit-oidc 1.7.0 → 1.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 +7 -0
- package/dist/server/index.js +9 -7
- package/dist/server/types.d.ts +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -155,6 +155,13 @@ export async function load(event) {
|
|
|
155
155
|
`OIDCContext`, so the standard setup above does not re-run unrelated page loads. If you destructure
|
|
156
156
|
the load event, pass both `cookies` and `depends`: `oidc.getPublicSession({cookies, depends})`.
|
|
157
157
|
|
|
158
|
+
When `oidc.handle` has already loaded an enriched session for the current request, project that
|
|
159
|
+
session without reading or enriching it again:
|
|
160
|
+
|
|
161
|
+
```ts
|
|
162
|
+
const session = oidc.toPublicSession(event.locals.oidc?.session ?? null, event.depends);
|
|
163
|
+
```
|
|
164
|
+
|
|
158
165
|
Periodic revalidation is disabled by default to avoid unnecessary page updates. Set
|
|
159
166
|
`revalidateIntervalMs` to a positive interval only when you need polling in addition to token-expiry
|
|
160
167
|
and provider session monitoring. Existing integrations that pass only `cookies` remain compatible;
|
package/dist/server/index.js
CHANGED
|
@@ -618,18 +618,20 @@ export function createOIDC(options) {
|
|
|
618
618
|
backChannelLogoutSessionSupported: Boolean(metadata.backchannel_logout_session_supported)
|
|
619
619
|
};
|
|
620
620
|
}
|
|
621
|
+
function createPublicSession(session, depends) {
|
|
622
|
+
depends?.(OIDC_SESSION_REVALIDATION_DEPENDENCY);
|
|
623
|
+
const publicSession = toPublicSession(session);
|
|
624
|
+
return publicSession && depends
|
|
625
|
+
? { ...publicSession, revalidationDependency: OIDC_SESSION_REVALIDATION_DEPENDENCY }
|
|
626
|
+
: publicSession;
|
|
627
|
+
}
|
|
621
628
|
return {
|
|
622
629
|
handle,
|
|
623
630
|
hook,
|
|
624
631
|
getMetadata,
|
|
625
632
|
getSession,
|
|
626
|
-
getPublicSession: async (event) =>
|
|
627
|
-
|
|
628
|
-
const session = toPublicSession(await getSession(event));
|
|
629
|
-
return session && event.depends
|
|
630
|
-
? { ...session, revalidationDependency: OIDC_SESSION_REVALIDATION_DEPENDENCY }
|
|
631
|
-
: session;
|
|
632
|
-
},
|
|
633
|
+
getPublicSession: async (event) => createPublicSession(await getSession(event), event.depends),
|
|
634
|
+
toPublicSession: createPublicSession,
|
|
633
635
|
getSessionManagementConfig,
|
|
634
636
|
login: signIn,
|
|
635
637
|
logout: signOut,
|
package/dist/server/types.d.ts
CHANGED
|
@@ -290,6 +290,8 @@ export type OIDCInstance<TClaims extends OIDCUserClaims = OIDCUserClaims, TSessi
|
|
|
290
290
|
cookies: Cookies;
|
|
291
291
|
depends?: (dependency: string) => void;
|
|
292
292
|
}) => Promise<OIDCPublicSession<TClaims> | null>;
|
|
293
|
+
/** Projects an already-loaded session without reading, refreshing, or enriching it again. */
|
|
294
|
+
toPublicSession: (session: TSession | null, depends?: (dependency: string) => void) => OIDCPublicSession<TClaims> | null;
|
|
293
295
|
getSessionManagementConfig: () => Promise<OIDCSessionManagementConfig>;
|
|
294
296
|
login: (event: MinimalRequestEvent, loginOptions?: OIDCLoginOptions) => Promise<never>;
|
|
295
297
|
logout: (event: MinimalRequestEvent, logoutOptions?: OIDCLogoutOptions) => Promise<never>;
|