Skip to content

Commit 0091471

Browse files
committed
feat: SSR compatibility for journey-client and oidc-client (PoC)
Make journey-client and oidc-client importable and usable in Node.js/SSR environments by eliminating eager browser global references and decoupling PKCE generation from sessionStorage. Storage: Replace eager sessionStorage/localStorage references with lazy globalThis access via getBrowserStorage(). Add configurable storage option to JourneyClientConfig so SSR callers can provide a custom noop adapter. PKCE: Decouple generation from storage — createAuthorizeUrl now returns { url, verifier, state } instead of writing to sessionStorage. Callers persist PKCE values however they choose (cookies, server session, etc.). Token exchange accepts optional pkceValues parameter to skip sessionStorage. Guard redirect() with typeof window check for server environments. Export createJourneyObject for client-side step reconstitution. SvelteKit PoC in e2e/svelte-app demonstrates the full flow: server-side journey start, client-side credential submission, server-side PKCE authorize URL generation with cookie-based verifier persistence, and server-side token exchange against the AM mock API.
1 parent 916e21c commit 0091471

98 files changed

Lines changed: 23873 additions & 88 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

e2e/oidc-app/src/utils/oidc-app.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,14 @@ export async function oidcApp({ config, urlParams }) {
8888
});
8989

9090
document.getElementById('login-redirect').addEventListener('click', async () => {
91-
const authorizeUrl = await oidcClient.authorize.url();
92-
if (typeof authorizeUrl !== 'string' && 'error' in authorizeUrl) {
93-
console.error('Authorization URL Error:', authorizeUrl);
94-
displayError(authorizeUrl);
91+
const authorizeResult = await oidcClient.authorize.url();
92+
if ('error' in authorizeResult) {
93+
console.error('Authorization URL Error:', authorizeResult);
94+
displayError(authorizeResult);
9595
return;
9696
} else {
97-
console.log('Authorization URL:', authorizeUrl);
98-
window.location.assign(authorizeUrl);
97+
console.log('Authorization URL:', authorizeResult.url);
98+
window.location.assign(authorizeResult.url);
9999
}
100100
});
101101

e2e/svelte-app/.svelte-kit/ambient.d.ts

Lines changed: 522 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
export { matchers } from './matchers.js';
2+
3+
export const nodes = [
4+
() => import('./nodes/0'),
5+
() => import('./nodes/1'),
6+
() => import('./nodes/2'),
7+
() => import('./nodes/3')
8+
];
9+
10+
export const server_loads = [];
11+
12+
export const dictionary = {
13+
"/": [~2],
14+
"/callback": [~3]
15+
};
16+
17+
export const hooks = {
18+
handleError: (({ error }) => { console.error(error) }),
19+
20+
reroute: (() => {}),
21+
transport: {}
22+
};
23+
24+
export const decoders = Object.fromEntries(Object.entries(hooks.transport).map(([k, v]) => [k, v.decode]));
25+
export const encoders = Object.fromEntries(Object.entries(hooks.transport).map(([k, v]) => [k, v.encode]));
26+
27+
export const hash = false;
28+
29+
export const decode = (type, value) => decoders[type](value);
30+
31+
export { default as root } from '../root.js';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const matchers = {};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as component } from "../../../../src/routes/+layout.svelte";

e2e/svelte-app/.svelte-kit/generated/client-optimized/nodes/1.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as component } from "../../../../src/routes/+page.svelte";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as component } from "../../../../src/routes/callback/+page.svelte";
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
export { matchers } from './matchers.js';
2+
3+
export const nodes = [
4+
() => import('./nodes/0'),
5+
() => import('./nodes/1'),
6+
() => import('./nodes/2'),
7+
() => import('./nodes/3')
8+
];
9+
10+
export const server_loads = [];
11+
12+
export const dictionary = {
13+
"/": [~2],
14+
"/callback": [~3]
15+
};
16+
17+
export const hooks = {
18+
handleError: (({ error }) => { console.error(error) }),
19+
20+
reroute: (() => {}),
21+
transport: {}
22+
};
23+
24+
export const decoders = Object.fromEntries(Object.entries(hooks.transport).map(([k, v]) => [k, v.decode]));
25+
export const encoders = Object.fromEntries(Object.entries(hooks.transport).map(([k, v]) => [k, v.encode]));
26+
27+
export const hash = false;
28+
29+
export const decode = (type, value) => decoders[type](value);
30+
31+
export { default as root } from '../root.js';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const matchers = {};

0 commit comments

Comments
 (0)