Skip to content

Commit 274dfdf

Browse files
committed
refactor(sdk): centralise store validation and remove internal selector export
- add assertValidStore() and getClientForReducerPath() to sdk-store so davinci and journey no longer duplicate the isSdkStoreHandle guard - davinci() and journey() now return GenericError on invalid store arg instead of throwing, matching the oidc() error contract - add conflicting-client guard to journey() via getClientForReducerPath - remove createWellknownSelector from sdk-store public index (internal detail) - conflictingClientId in oidc-client delegates to getClientForReducerPath - update e2e apps to handle new union return types from davinci() and journey()
1 parent 42e33a2 commit 274dfdf

19 files changed

Lines changed: 6130 additions & 7424 deletions

File tree

e2e/davinci-app/main.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import type {
1313
Collectors,
1414
CustomLogger,
1515
DaVinciConfig,
16-
DavinciClient,
1716
GetClient,
1817
InternalErrorResponse,
1918
NodeStates,
@@ -88,7 +87,11 @@ const requestMiddleware: RequestMiddleware<'DAVINCI_NEXT' | 'DAVINCI_START'>[] =
8887
const urlParams = new URLSearchParams(window.location.search);
8988

9089
(async () => {
91-
const davinciClient: DavinciClient = await davinci({ config, logger, requestMiddleware });
90+
const davinciResult = await davinci({ config, logger, requestMiddleware });
91+
if ('error' in davinciResult) {
92+
throw new Error(`Failed to initialize davinci client: ${davinciResult.error}`);
93+
}
94+
const davinciClient = davinciResult;
9295
const oidcResult = await oidc({ config: config as OidcConfig });
9396
if ('error' in oidcResult) {
9497
throw new Error(`Failed to initialize oidc client: ${oidcResult.error}`);

e2e/journey-app/main.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2025-2026 Ping Identity Corporation. All rights reserved.
2+
* Copyright (c) 2025 - 2026 Ping Identity Corporation. All rights reserved.
33
*
44
* This software may be modified and distributed under the terms
55
* of the MIT license. See the LICENSE file for details.
@@ -8,7 +8,7 @@ import './style.css';
88

99
import { journey } from '@forgerock/journey-client';
1010

11-
import type { JourneyClient, RequestMiddleware } from '@forgerock/journey-client/types';
11+
import type { RequestMiddleware } from '@forgerock/journey-client/types';
1212

1313
import { renderCallbacks } from './callback-map.js';
1414
import { renderDeleteDevicesSection } from './components/delete-device.js';
@@ -62,15 +62,14 @@ if (searchParams.get('middleware') === 'true') {
6262
const formEl = document.getElementById('form') as HTMLFormElement;
6363
const journeyEl = document.getElementById('journey') as HTMLDivElement;
6464

65-
let journeyClient: JourneyClient;
66-
try {
67-
journeyClient = await journey({ config: config, requestMiddleware });
68-
} catch (error) {
69-
const message = error instanceof Error ? error.message : 'Unknown error';
65+
const journeyResult = await journey({ config: config, requestMiddleware });
66+
if ('error' in journeyResult) {
67+
const message = journeyResult.error;
7068
console.error('Failed to initialize journey client:', message);
7169
errorEl.textContent = message;
7270
return;
7371
}
72+
const journeyClient = journeyResult;
7473
let step = await journeyClient.start({ journey: journeyName });
7574

7675
function renderError() {

0 commit comments

Comments
 (0)