From 328692c997941de97ead7fe28e64db2b68c079e0 Mon Sep 17 00:00:00 2001 From: Ryan Bas Date: Tue, 8 Sep 2026 13:14:22 -0600 Subject: [PATCH 1/4] refactor(device-client): replace javascript-sdk dependency with sdk-types ConfigOptions now aliases LegacyConfigOptions from @forgerock/sdk-types, removing the runtime dependency on @forgerock/javascript-sdk. The catalog entry remains for tools/interface-mapping-validator. --- packages/device-client/api-report/device-client.api.md | 5 +++-- .../device-client/api-report/device-client.types.api.md | 5 +++-- packages/device-client/package.json | 2 +- packages/device-client/src/lib/device.store.ts | 4 ++-- packages/device-client/src/lib/types/index.ts | 6 ++++-- packages/device-client/tsconfig.lib.json | 5 +++++ 6 files changed, 18 insertions(+), 9 deletions(-) diff --git a/packages/device-client/api-report/device-client.api.md b/packages/device-client/api-report/device-client.api.md index 117ed83ab1a..1f509bc2cbb 100644 --- a/packages/device-client/api-report/device-client.api.md +++ b/packages/device-client/api-report/device-client.api.md @@ -4,7 +4,7 @@ ```ts -import { ConfigOptions } from '@forgerock/javascript-sdk'; +import type { LegacyConfigOptions } from '@forgerock/sdk-types'; // @public (undocumented) export type Bluetooth = { @@ -21,7 +21,8 @@ export type Browser = { userAgent: string; }; -export { ConfigOptions } +// @public (undocumented) +export type ConfigOptions = LegacyConfigOptions; // @public (undocumented) export type DeleteDeviceQuery = { diff --git a/packages/device-client/api-report/device-client.types.api.md b/packages/device-client/api-report/device-client.types.api.md index 117ed83ab1a..1f509bc2cbb 100644 --- a/packages/device-client/api-report/device-client.types.api.md +++ b/packages/device-client/api-report/device-client.types.api.md @@ -4,7 +4,7 @@ ```ts -import { ConfigOptions } from '@forgerock/javascript-sdk'; +import type { LegacyConfigOptions } from '@forgerock/sdk-types'; // @public (undocumented) export type Bluetooth = { @@ -21,7 +21,8 @@ export type Browser = { userAgent: string; }; -export { ConfigOptions } +// @public (undocumented) +export type ConfigOptions = LegacyConfigOptions; // @public (undocumented) export type DeleteDeviceQuery = { diff --git a/packages/device-client/package.json b/packages/device-client/package.json index 89414653f25..ff92ec24648 100644 --- a/packages/device-client/package.json +++ b/packages/device-client/package.json @@ -27,7 +27,7 @@ "test:watch": "pnpm nx nxTest --watch" }, "dependencies": { - "@forgerock/javascript-sdk": "catalog:", + "@forgerock/sdk-types": "workspace:*", "@reduxjs/toolkit": "catalog:" }, "devDependencies": { diff --git a/packages/device-client/src/lib/device.store.ts b/packages/device-client/src/lib/device.store.ts index 8b18f5ac6f6..a047db79116 100644 --- a/packages/device-client/src/lib/device.store.ts +++ b/packages/device-client/src/lib/device.store.ts @@ -1,10 +1,10 @@ /* - * Copyright (c) 2025 Ping Identity Corporation. All rights reserved. + * Copyright (c) 2025 - 2026 Ping Identity Corporation. All rights reserved. * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ -import { type ConfigOptions } from '@forgerock/javascript-sdk'; +import { type ConfigOptions } from './types/index.js'; import { configureStore } from '@reduxjs/toolkit'; import { deviceService } from './services/index.js'; import type { OathDevice, RetrieveOathQuery } from './types/oath.types.js'; diff --git a/packages/device-client/src/lib/types/index.ts b/packages/device-client/src/lib/types/index.ts index 884c2a1d051..cdd4e5035c2 100644 --- a/packages/device-client/src/lib/types/index.ts +++ b/packages/device-client/src/lib/types/index.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025 Ping Identity Corporation. All rights reserved. + * Copyright (c) 2025 - 2026 Ping Identity Corporation. All rights reserved. * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. @@ -9,7 +9,9 @@ import { deviceClient } from '../device.store.js'; export type DeviceClient = ReturnType; // Re-export types from external dependencies that consumers need -export type { ConfigOptions } from '@forgerock/javascript-sdk'; +import type { LegacyConfigOptions } from '@forgerock/sdk-types'; + +export type ConfigOptions = LegacyConfigOptions; // Re-export local types export * from './oath.types.js'; diff --git a/packages/device-client/tsconfig.lib.json b/packages/device-client/tsconfig.lib.json index c0610b334d8..528982db5eb 100644 --- a/packages/device-client/tsconfig.lib.json +++ b/packages/device-client/tsconfig.lib.json @@ -19,5 +19,10 @@ "src/**/*.test.ts", "src/**/*.test.utils.ts", "src/lib/mock-data/*" + ], + "references": [ + { + "path": "../sdk-types/tsconfig.lib.json" + } ] } From 24d1ebecd979a4ee8bf8129a37ca4142e605fc40 Mon Sep 17 00:00:00 2001 From: Ryan Bas Date: Tue, 8 Sep 2026 13:17:37 -0600 Subject: [PATCH 2/4] refactor(e2e): migrate device-client-app to journey-client and oidc-client Replaces @forgerock/javascript-sdk usage with journey-client and oidc-client. Token renewal now uses backgroundRenew and oidc() error results are validated before caching. platformHeader is dropped as it is unsupported by the new clients. Lockfile updates included here. --- e2e/device-client-app/package.json | 4 +- e2e/device-client-app/src/utils/index.ts | 165 ++++++++++++++--------- e2e/device-client-app/tsconfig.app.json | 9 ++ pnpm-lock.yaml | 18 ++- 4 files changed, 127 insertions(+), 69 deletions(-) diff --git a/e2e/device-client-app/package.json b/e2e/device-client-app/package.json index 6f73e25b17f..a93422de139 100644 --- a/e2e/device-client-app/package.json +++ b/e2e/device-client-app/package.json @@ -10,7 +10,9 @@ }, "dependencies": { "@forgerock/device-client": "workspace:*", - "@forgerock/javascript-sdk": "catalog:", + "@forgerock/journey-client": "workspace:*", + "@forgerock/oidc-client": "workspace:*", + "@forgerock/sdk-types": "workspace:*", "effect": "catalog:effect" }, "devDependencies": { diff --git a/e2e/device-client-app/src/utils/index.ts b/e2e/device-client-app/src/utils/index.ts index d7b246ec9bd..2757421d61f 100644 --- a/e2e/device-client-app/src/utils/index.ts +++ b/e2e/device-client-app/src/utils/index.ts @@ -1,63 +1,66 @@ +/* + * + * Copyright © 2025 Ping Identity Corporation. All right reserved. + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + * + */ + import { deviceClient } from '@forgerock/device-client'; import type { ConfigOptions, DeviceClient } from '@forgerock/device-client/types'; import { - CallbackType, - Config, - FRAuth, - FRLoginFailure, - FRLoginSuccess, - FRStep, + callbackType, + journey, NameCallback, PasswordCallback, - SessionManager, - TokenManager, - UserManager, -} from '@forgerock/javascript-sdk'; + StepType, +} from '@forgerock/journey-client'; +import type { + JourneyClient, + JourneyClientConfig, + JourneyResult, +} from '@forgerock/journey-client/types'; +import { oidc } from '@forgerock/oidc-client'; +import type { OidcClient, OidcConfig } from '@forgerock/oidc-client/types'; import { Console, Effect } from 'effect'; -const logout = Effect.ignore( - Effect.tryPromise({ - try: () => SessionManager.logout(), - catch: (err) => new Error(`Logout failed: ${err}`), - }), -); +let cachedOidcClient: OidcClient | null = null; -const start = Effect.tryPromise({ - try: () => FRAuth.start(), - catch: (err) => new Error(`Authentication start failed: ${err}`), -}).pipe(Effect.tap((step) => Console.log('Called start', step))); +const oidcClientOrThrow = (): OidcClient => { + if (!cachedOidcClient) { + throw new Error('OIDC client not initialized'); + } + return cachedOidcClient; +}; -const checkFRStep = (step: FRStep | FRLoginFailure | FRLoginSuccess) => +const checkForStep = (step: JourneyResult) => Effect.try({ try: () => { - if (step.type == 'LoginSuccess' || step.type == 'LoginFailure') { - throw new Error(`Unexpected step type: ${step.type}`); - } else { + if (step && 'type' in step && step.type === StepType.Step) { return step; } + throw new Error(`Unexpected step type: ${JSON.stringify(step)}`); }, catch: (err) => new Error(`Failed to start authentication: ${err}`), }); -const callNext = (step: FRStep) => +const callNext = (client: JourneyClient, step: JourneyResult) => Effect.tryPromise({ - try: () => FRAuth.next(step), + try: () => client.next(step as Parameters[0]), catch: (err) => new Error(`Failed to proceed to next step: ${err}`), - }).pipe(Effect.tap((step) => Console.log('Got next step', step))); - -const getTokens = Effect.tryPromise({ - try: () => TokenManager.getTokens(), - catch: (err) => new Error(`Failed to get tokens: ${err}`), -}).pipe(Effect.tap((tokens) => Console.log('Got Tokens', tokens))); + }).pipe(Effect.tap((next) => Console.log('Got next step', next))); -const checkForLoginSuccess = (step: FRStep | FRLoginSuccess | FRLoginFailure) => { - if (step.type === 'LoginSuccess') { - return Effect.succeed(step); - } else if (step.type === 'LoginFailure') { +const checkForLoginSuccess = (result: JourneyResult) => { + if (result && 'type' in result && result.type === StepType.LoginSuccess) { + return Effect.succeed(result); + } else if (result && 'type' in result && result.type === StepType.LoginFailure) { return Effect.fail(new Error(`Login failed`)); } else { return Effect.fail( - new Error(`Unexpected step, expected to be in a LoginSuccess but got ${step.type}`), + new Error( + `Unexpected step, expected to be in a LoginSuccess but got ${JSON.stringify(result)}`, + ), ); } }; @@ -66,7 +69,6 @@ export const LoginAndGetClient = Effect.gen(function* () { const url = new URL(window.location.href); const amUrl = url.searchParams.get('amUrl') || 'https://openam-sdks.forgeblocks.com/am'; const realmPath = url.searchParams.get('realmPath') || 'alpha'; - const platformHeader = url.searchParams.get('platformHeader') === 'true' ? true : false; const tree = url.searchParams.get('tree') || 'selfservice'; /** @@ -77,7 +79,7 @@ export const LoginAndGetClient = Effect.gen(function* () { const un = url.searchParams.get('un') || 'devicetestuser'; const pw = url.searchParams.get('pw') || 'password'; - const config: ConfigOptions = { + const deviceConfig: ConfigOptions = { realmPath, serverConfig: { baseUrl: amUrl, @@ -85,45 +87,84 @@ export const LoginAndGetClient = Effect.gen(function* () { }, }; - yield* Effect.try(() => - Config.set({ - platformHeader, - realmPath, - tree, - clientId: 'WebOAuthClient', - scope: 'profile email me.read openid', - redirectUri: `${window.location.origin}/src/_callback/index.html`, - serverConfig: { - baseUrl: amUrl, - timeout: 3000, - }, - }), - ); - yield* logout; + const realmSegment = realmPath ? `/realms/root/realms/${realmPath}` : ''; + const wellknown = `${amUrl.replace(/\/$/, '')}/oauth2${realmSegment}/.well-known/openid-configuration`; + const redirectUri = `${window.location.origin}/src/_callback/index.html`; + + const journeyConfig: JourneyClientConfig = { + serverConfig: { + wellknown, + }, + }; + + const oidcConfig: OidcConfig = { + clientId: 'WebOAuthClient', + scope: 'profile email me.read openid', + redirectUri, + serverConfig: { + wellknown, + }, + }; + + const journeyClient = yield* Effect.tryPromise({ + try: () => journey({ config: journeyConfig }), + catch: (err) => new Error(`Failed to initialize journey client: ${err}`), + }); + + const oidcClient = yield* Effect.tryPromise({ + try: () => oidc({ config: oidcConfig }), + catch: (err) => new Error(`Failed to initialize OIDC client: ${err}`), + }); + + if ('error' in oidcClient) { + return yield* Effect.fail(new Error(`Failed to initialize OIDC client: ${oidcClient.error}`)); + } + + cachedOidcClient = oidcClient; + + yield* Effect.tryPromise({ + try: () => oidcClientOrThrow().user.logout(), + catch: (err) => new Error(`Logout failed: ${err}`), + }); - yield* start.pipe( - Effect.flatMap((step) => checkFRStep(step)), + yield* Effect.tryPromise({ + try: () => journeyClient.start({ journey: tree }), + catch: (err) => new Error(`Authentication start failed: ${err}`), + }).pipe( + Effect.tap((step) => Console.log('Called start', step)), + Effect.flatMap((step) => checkForStep(step)), Effect.map((step) => { - step.getCallbackOfType(CallbackType.NameCallback).setName(un); - step.getCallbackOfType(CallbackType.PasswordCallback).setPassword(pw); + step.getCallbackOfType(callbackType.NameCallback).setName(un); + step.getCallbackOfType(callbackType.PasswordCallback).setPassword(pw); return step; }), - Effect.flatMap((step) => callNext(step)), + Effect.flatMap((step) => callNext(journeyClient, step)), /** * Don't explicitly need this but if the journey changes * maybe we dont get a LoginSuccess */ Effect.flatMap((step) => checkForLoginSuccess(step)), - Effect.flatMap(() => getTokens), + Effect.flatMap(() => + Effect.tryPromise({ + try: () => oidcClientOrThrow().token.get({ backgroundRenew: true }), + catch: (err) => new Error(`Failed to get tokens: ${err}`), + }).pipe(Effect.tap((tokens) => Console.log('Got Tokens', tokens))), + ), ); - const client: DeviceClient = deviceClient(config); + const client: DeviceClient = deviceClient(deviceConfig); return client; }); export const getUser = Effect.tryPromise({ - try: () => UserManager.getCurrentUser() as Promise>, + try: async () => { + const response = await oidcClientOrThrow().user.info(); + if (response && 'error' in response) { + throw new Error(`Failed to get user info: ${response.error}`); + } + return response as unknown as Record; + }, catch: (err) => new Error(`Failed to get current user: ${err}`), }); diff --git a/e2e/device-client-app/tsconfig.app.json b/e2e/device-client-app/tsconfig.app.json index e68f53f5ba4..a9d76f1573c 100644 --- a/e2e/device-client-app/tsconfig.app.json +++ b/e2e/device-client-app/tsconfig.app.json @@ -27,6 +27,15 @@ "references": [ { "path": "../../packages/device-client/tsconfig.lib.json" + }, + { + "path": "../../packages/journey-client/tsconfig.lib.json" + }, + { + "path": "../../packages/oidc-client/tsconfig.lib.json" + }, + { + "path": "../../packages/sdk-types/tsconfig.lib.json" } ] } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e62a3e1c6b2..7e5c738087a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -345,9 +345,15 @@ importers: '@forgerock/device-client': specifier: workspace:* version: link:../../packages/device-client - '@forgerock/javascript-sdk': - specifier: 'catalog:' - version: 4.9.0 + '@forgerock/journey-client': + specifier: workspace:* + version: link:../../packages/journey-client + '@forgerock/oidc-client': + specifier: workspace:* + version: link:../../packages/oidc-client + '@forgerock/sdk-types': + specifier: workspace:* + version: link:../../packages/sdk-types effect: specifier: catalog:effect version: 3.21.0 @@ -479,9 +485,9 @@ importers: packages/device-client: dependencies: - '@forgerock/javascript-sdk': - specifier: 'catalog:' - version: 4.9.0 + '@forgerock/sdk-types': + specifier: workspace:* + version: link:../sdk-types '@reduxjs/toolkit': specifier: 'catalog:' version: 2.10.1 From ab8b9c423246d14f7e8405b362269517c2072651 Mon Sep 17 00:00:00 2001 From: Ryan Bas Date: Tue, 8 Sep 2026 15:04:08 -0600 Subject: [PATCH 3/4] chore(deps): override fast-uri and undici to patched versions Addresses mend scan findings for transitive CVEs: - fast-uri ^3.1.6 -> ^3.1.7 - undici ^7.29.0 -> ^7.29.1 vitest (CVE-2026-84373) is intentionally not touched here and will be updated separately. --- package.json | 4 ++-- pnpm-lock.yaml | 28 ++++++++++++++-------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 679da800a9a..2db0c1a5ae8 100644 --- a/package.json +++ b/package.json @@ -135,7 +135,7 @@ "rollup": "^4.59.0", "picomatch@>=4": "^4.0.4", "picomatch@<3": "^2.3.2", - "fast-uri": "^3.1.6", + "fast-uri": "^3.1.7", "qs": "^6.16.0", "@opentelemetry/core": "^2.8.0", "brace-expansion@<2": "~1.1.15", @@ -143,7 +143,7 @@ "brace-expansion@>=3 <4": "~3.0.2", "brace-expansion@>=4": "~5.0.8", "ws": "^8.21.1", - "undici": "^7.29.0", + "undici": "^7.29.1", "nanoid": "^5.1.16", "postcss": "^8.5.23" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7e5c738087a..d8b8dd22aac 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -71,7 +71,7 @@ overrides: rollup: ^4.59.0 picomatch@>=4: ^4.0.4 picomatch@<3: ^2.3.2 - fast-uri: ^3.1.6 + fast-uri: ^3.1.7 qs: ^6.16.0 '@opentelemetry/core': ^2.8.0 brace-expansion@<2: ~1.1.15 @@ -79,7 +79,7 @@ overrides: brace-expansion@>=3 <4: ~3.0.2 brace-expansion@>=4: ~5.0.8 ws: ^8.21.1 - undici: ^7.29.0 + undici: ^7.29.1 nanoid: ^5.1.16 postcss: ^8.5.23 @@ -5159,8 +5159,8 @@ packages: fast-string-width@3.0.2: resolution: {integrity: sha512-gX8LrtNEI5hq8DVUfRQMbr5lpaS4nMIWV+7XEbXk2b8kiQIizgnlr12B4dA3ZEx3308ze0O4Q1R+cHts8kyUJg==} - fast-uri@3.1.6: - resolution: {integrity: sha512-7Ical1vFEMr0onbVzEDIreM22I4khW+fzyQPwvAFWBp1iwdshSZRsL4jjRvPG9JP1uiqMHRto+YU6R2/CzDz5Q==} + fast-uri@3.1.7: + resolution: {integrity: sha512-dOvZVzjdZdz7phd9v6jCbwxrBW3fK6n8Rc0CtdmM4bumzMnxywBYhuph6J819RRw/ku+rLbelwfMunktuzVVHg==} fast-wrap-ansi@0.2.2: resolution: {integrity: sha512-7F2Fl+TjRSenLqlU3UjSH0iyqopqoZIu7eZVpEirP2g1GtWa2G/ecEmBdgz31+Mxr+ELclgg6sokpSFIQiZ02Q==} @@ -8101,8 +8101,8 @@ packages: undici-types@7.16.0: resolution: {integrity: sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==} - undici@7.29.0: - resolution: {integrity: sha512-IDxfleLmmbSskfWSUATiN1nfn2rDuvnMOqb5CWR92iIfojA0Ud+ulOAAEQ57LPr9rWmsreUyf5lwyao+7GNNVw==} + undici@7.29.1: + resolution: {integrity: sha512-RYONW2MeafgYlkVOKYKkA/Ag7BmXqgIWCa8t1m0JcxrQg9pI9lEqRhAOruOBCbAohOa/gkCF+iPi9hrgvTzu6Q==} engines: {node: '>=20.18.1'} unicode-canonical-property-names-ecmascript@2.0.1: @@ -8540,7 +8540,7 @@ snapshots: '@actions/http-client@4.0.1': dependencies: tunnel: 0.0.6 - undici: 7.29.0 + undici: 7.29.1 '@actions/io@3.0.2': {} @@ -9741,7 +9741,7 @@ snapshots: '@effect/sql': 0.44.2(@effect/experimental@0.54.6(@effect/platform@0.90.10(effect@3.21.0))(effect@3.21.0))(@effect/platform@0.90.10(effect@3.21.0))(effect@3.21.0) effect: 3.21.0 mime: 3.0.0 - undici: 7.29.0 + undici: 7.29.1 ws: 8.21.1 transitivePeerDependencies: - bufferutil @@ -10768,7 +10768,7 @@ snapshots: '@octokit/plugin-paginate-rest': 9.2.2(@octokit/core@5.2.2) '@octokit/plugin-rest-endpoint-methods': 10.4.1(@octokit/core@5.2.2) '@octokit/types': 12.6.0 - undici: 7.29.0 + undici: 7.29.1 '@octokit/auth-action@4.1.0': dependencies: @@ -12210,21 +12210,21 @@ snapshots: ajv@8.17.1: dependencies: fast-deep-equal: 3.1.3 - fast-uri: 3.1.6 + fast-uri: 3.1.7 json-schema-traverse: 1.0.0 require-from-string: 2.0.2 ajv@8.18.0: dependencies: fast-deep-equal: 3.1.3 - fast-uri: 3.1.6 + fast-uri: 3.1.7 json-schema-traverse: 1.0.0 require-from-string: 2.0.2 ajv@8.20.0: dependencies: fast-deep-equal: 3.1.3 - fast-uri: 3.1.6 + fast-uri: 3.1.7 json-schema-traverse: 1.0.0 require-from-string: 2.0.2 @@ -13757,7 +13757,7 @@ snapshots: dependencies: fast-string-truncated-width: 3.0.3 - fast-uri@3.1.6: {} + fast-uri@3.1.7: {} fast-wrap-ansi@0.2.2: dependencies: @@ -17144,7 +17144,7 @@ snapshots: undici-types@7.16.0: {} - undici@7.29.0: {} + undici@7.29.1: {} unicode-canonical-property-names-ecmascript@2.0.1: {} From 7cd770678a88574099a914f56d83eb8d3ad4799f Mon Sep 17 00:00:00 2001 From: Ryan Bas Date: Thu, 10 Sep 2026 14:16:00 -0600 Subject: [PATCH 4/4] refactor(device-client): address PR review feedback on types and effects - Import ConfigOptions/LegacyConfigOptions from @forgerock/sdk-types instead of legacy JS SDK - Type JourneyStep step as JourneyStep - Type UserInfoResponse in getUser util - Add Effect.catchAll to logout for fresh-state failure handling - Update copyright header year - Add changeset: minor bump @forgerock/device-client (tokenStore breaking note), patch app --- .changeset/remove-js-sdk-from-device-client.md | 7 +++++++ e2e/device-client-app/src/utils/index.ts | 17 +++++++++-------- packages/device-client/src/lib/device.store.ts | 2 +- 3 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 .changeset/remove-js-sdk-from-device-client.md diff --git a/.changeset/remove-js-sdk-from-device-client.md b/.changeset/remove-js-sdk-from-device-client.md new file mode 100644 index 00000000000..cfda63e9712 --- /dev/null +++ b/.changeset/remove-js-sdk-from-device-client.md @@ -0,0 +1,7 @@ +--- +'@forgerock/device-client': minor +--- + +Removed the dependency on `@forgerock/javascript-sdk` from `device-client` and the e2e app. + +**BREAKING:** The `tokenStore` config now accepts a `CustomStorageObject` (from `@forgerock/sdk-types`) instead of the legacy `TokenStoreObject`. Custom token-store implementers must adapt: `get` now returns `Promise` instead of `Promise`. Usage of the `'sessionStorage'`/`'localStorage'` string values is unaffected. diff --git a/e2e/device-client-app/src/utils/index.ts b/e2e/device-client-app/src/utils/index.ts index 2757421d61f..a3b996b72e1 100644 --- a/e2e/device-client-app/src/utils/index.ts +++ b/e2e/device-client-app/src/utils/index.ts @@ -1,6 +1,6 @@ /* * - * Copyright © 2025 Ping Identity Corporation. All right reserved. + * Copyright (c) 2025 - 2026 Ping Identity Corporation. All rights reserved. * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. @@ -20,9 +20,10 @@ import type { JourneyClient, JourneyClientConfig, JourneyResult, + JourneyStep, } from '@forgerock/journey-client/types'; import { oidc } from '@forgerock/oidc-client'; -import type { OidcClient, OidcConfig } from '@forgerock/oidc-client/types'; +import type { OidcClient, OidcConfig, UserInfoResponse } from '@forgerock/oidc-client/types'; import { Console, Effect } from 'effect'; let cachedOidcClient: OidcClient | null = null; @@ -45,9 +46,9 @@ const checkForStep = (step: JourneyResult) => catch: (err) => new Error(`Failed to start authentication: ${err}`), }); -const callNext = (client: JourneyClient, step: JourneyResult) => +const callNext = (client: JourneyClient, step: JourneyStep) => Effect.tryPromise({ - try: () => client.next(step as Parameters[0]), + try: () => client.next(step), catch: (err) => new Error(`Failed to proceed to next step: ${err}`), }).pipe(Effect.tap((next) => Console.log('Got next step', next))); @@ -125,7 +126,7 @@ export const LoginAndGetClient = Effect.gen(function* () { yield* Effect.tryPromise({ try: () => oidcClientOrThrow().user.logout(), catch: (err) => new Error(`Logout failed: ${err}`), - }); + }).pipe(Effect.catchAll((err) => Console.warn('Logout failed, continuing:', err))); yield* Effect.tryPromise({ try: () => journeyClient.start({ journey: tree }), @@ -158,12 +159,12 @@ export const LoginAndGetClient = Effect.gen(function* () { }); export const getUser = Effect.tryPromise({ - try: async () => { + try: async (): Promise => { const response = await oidcClientOrThrow().user.info(); - if (response && 'error' in response) { + if ('error' in response) { throw new Error(`Failed to get user info: ${response.error}`); } - return response as unknown as Record; + return response; }, catch: (err) => new Error(`Failed to get current user: ${err}`), }); diff --git a/packages/device-client/src/lib/device.store.ts b/packages/device-client/src/lib/device.store.ts index a047db79116..800427f4c4e 100644 --- a/packages/device-client/src/lib/device.store.ts +++ b/packages/device-client/src/lib/device.store.ts @@ -4,7 +4,7 @@ * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ -import { type ConfigOptions } from './types/index.js'; +import type { LegacyConfigOptions as ConfigOptions } from '@forgerock/sdk-types'; import { configureStore } from '@reduxjs/toolkit'; import { deviceService } from './services/index.js'; import type { OathDevice, RetrieveOathQuery } from './types/oath.types.js';