Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"updateInternalDependencies": "patch",
"ignore": [
"scratchpad",
"@forgerock/devtools-extension",
"@forgerock/devtools-bridge",
"@forgerock/devtools-types",
"@forgerock/pingone-scripts",
"@forgerock/device-client-app",
"@forgerock/davinci-app",
Expand Down
6 changes: 6 additions & 0 deletions .changeset/quiet-onions-study.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@forgerock/journey-client': minor
'@forgerock/oidc-client': minor
---

Adds subscribe method to public api
5 changes: 5 additions & 0 deletions .changeset/seven-hoops-win.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@forgerock/davinci-client': minor
---

Adds a get cache method to expose the cache for consumers like devtools
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
.pnpm-store/*
.npm/_logs

# Elm
elm-stuff/

# Generated code
logs/*
tmp/
Expand Down
5 changes: 5 additions & 0 deletions .prototools
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node = "22"
pnpm = "10"

[settings]
auto-install=true
8 changes: 3 additions & 5 deletions e2e/davinci-app/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import './style.css';

import { Config, FRUser, TokenManager } from '@forgerock/javascript-sdk';
import { davinci } from '@forgerock/davinci-client';
import { attachDevToolsBridge } from '@forgerock/devtools-bridge';
import type {
CustomLogger,
DaVinciConfig,
Expand Down Expand Up @@ -334,16 +335,13 @@ const urlParams = new URLSearchParams(window.location.search);
}
}

/**
* Optionally subscribe to the store to listen for all store updates
* This is useful for debugging and logging
* It returns an unsubscribe function that you can call to stop listening
*/
davinciClient.subscribe(() => {
const node = davinciClient.getNode();
console.log('Event emitted from store:', node);
});

attachDevToolsBridge(davinciClient, config);

const qs = window.location.search;
const searchParams = new URLSearchParams(qs);

Expand Down
1 change: 1 addition & 0 deletions e2e/davinci-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
},
"dependencies": {
"@forgerock/davinci-client": "workspace:*",
"@forgerock/devtools-bridge": "workspace:*",
"@forgerock/javascript-sdk": "4.7.0",
"@forgerock/protect": "workspace:*",
"@forgerock/sdk-logger": "workspace:*"
Expand Down
3 changes: 3 additions & 0 deletions e2e/davinci-app/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
{
"path": "../../packages/protect/tsconfig.lib.json"
},
{
"path": "../../packages/devtools-bridge/tsconfig.lib.json"
},
{
"path": "../../packages/davinci-client/tsconfig.lib.json"
}
Expand Down
2 changes: 2 additions & 0 deletions e2e/journey-app/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import './style.css';

import { journey } from '@forgerock/journey-client';
import { attachJourneyBridge } from '@forgerock/devtools-bridge';

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

Expand Down Expand Up @@ -65,6 +66,7 @@ if (searchParams.get('middleware') === 'true') {
let journeyClient: JourneyClient;
try {
journeyClient = await journey({ config: config, requestMiddleware });
attachJourneyBridge(journeyClient, config);
} catch (error) {
const message = error instanceof Error ? error.message : 'Unknown error';
console.error('Failed to initialize journey client:', message);
Expand Down
1 change: 1 addition & 0 deletions e2e/journey-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"serve": "pnpm nx nxServe"
},
"dependencies": {
"@forgerock/devtools-bridge": "workspace:*",
"@forgerock/journey-client": "workspace:*",
"@forgerock/oidc-client": "workspace:*",
"@forgerock/protect": "workspace:*",
Expand Down
7 changes: 5 additions & 2 deletions e2e/journey-app/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@
],
"references": [
{
"path": "../../packages/sdk-effects/logger/tsconfig.lib.json"
"path": "../../packages/device-client/tsconfig.lib.json"
},
{
"path": "../../packages/device-client/tsconfig.lib.json"
"path": "../../packages/sdk-effects/logger/tsconfig.lib.json"
},
{
"path": "../../packages/oidc-client/tsconfig.lib.json"
},
{
"path": "../../packages/devtools-bridge/tsconfig.lib.json"
},
{
"path": "../../packages/protect/tsconfig.lib.json"
},
Expand Down
1 change: 1 addition & 0 deletions e2e/oidc-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"serve": "pnpm nx nxServe"
},
"dependencies": {
"@forgerock/devtools-bridge": "workspace:*",
"@forgerock/oidc-client": "workspace:*"
},
"nx": {
Expand Down
2 changes: 2 additions & 0 deletions e2e/oidc-app/src/utils/oidc-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* of the MIT license. See the LICENSE file for details.
*
*/
import { attachOidcBridge } from '@forgerock/devtools-bridge';
import { oidc } from '@forgerock/oidc-client';
import type {
AuthorizationError,
Expand Down Expand Up @@ -54,6 +55,7 @@ export async function oidcApp({ config, urlParams }) {
if ('error' in oidcClient) {
displayError(oidcClient);
}
attachOidcBridge(oidcClient, config);

document.getElementById('login-background').addEventListener('click', async () => {
const authorizeOptions: GetAuthorizationUrlOptions =
Expand Down
3 changes: 3 additions & 0 deletions e2e/oidc-app/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"references": [
{
"path": "../../packages/oidc-client/tsconfig.lib.json"
},
{
"path": "../../packages/devtools-bridge/tsconfig.lib.json"
}
]
}
8 changes: 8 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ export default [
sourceTag: 'scope:sdk-types',
onlyDependOnLibsWithTags: [],
},
{
sourceTag: 'scope:devtools-types',
onlyDependOnLibsWithTags: [],
},
{
sourceTag: 'scope:devtools-bridge',
onlyDependOnLibsWithTags: ['scope:devtools-types', 'scope:package'],
},
],
},
],
Expand Down
88 changes: 72 additions & 16 deletions packages/davinci-client/api-report/davinci-client.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export interface CollectorErrors {
}

// @public (undocumented)
export type Collectors = FlowCollector | PasswordCollector | TextCollector | SingleSelectCollector | IdpCollector | SubmitCollector | ActionCollector<'ActionCollector'> | SingleValueCollector<'SingleValueCollector'> | MultiSelectCollector | DeviceAuthenticationCollector | DeviceRegistrationCollector | PhoneNumberCollector | ReadOnlyCollector | ValidatedTextCollector | ProtectCollector | PollingCollector | FidoRegistrationCollector | FidoAuthenticationCollector | QrCodeCollector | AgreementCollector | UnknownCollector;
export type Collectors = FlowCollector | PasswordCollector | TextCollector | SingleSelectCollector | IdpCollector | SubmitCollector | ActionCollector<'ActionCollector'> | SingleValueCollector<'SingleValueCollector'> | MultiSelectCollector | DeviceAuthenticationCollector | DeviceRegistrationCollector | PhoneNumberCollector | PhoneNumberExtensionCollector | ReadOnlyCollector | ValidatedTextCollector | ProtectCollector | PollingCollector | FidoRegistrationCollector | FidoAuthenticationCollector | QrCodeCollector | AgreementCollector | UnknownCollector;

// @public
export type CollectorValueType<T> = T extends {
Expand Down Expand Up @@ -212,7 +212,7 @@ export type CollectorValueType<T> = T extends {
} ? string[] : string | string[] | PhoneNumberInputValue | FidoRegistrationInputValue | FidoAuthenticationInputValue;

// @public (undocumented)
export type ComplexValueFields = DeviceAuthenticationField | DeviceRegistrationField | PhoneNumberField | FidoRegistrationField | FidoAuthenticationField | PollingField;
export type ComplexValueFields = DeviceAuthenticationField | DeviceRegistrationField | PhoneNumberField | PhoneNumberExtensionField | FidoRegistrationField | FidoAuthenticationField | PollingField;

// @public (undocumented)
export interface ContinueNode {
Expand Down Expand Up @@ -267,13 +267,11 @@ export function davinci<ActionType extends ActionTypes = ActionTypes>(input: {
resume: (input: {
continueToken: string;
}) => Promise<InternalErrorResponse | NodeStates>;
start: <QueryParams extends OutgoingQueryParams = OutgoingQueryParams>(options?: StartOptions<QueryParams> | undefined) => Promise<ContinueNode | StartNode | ErrorNode | FailureNode | SuccessNode>;
start: <QueryParams extends OutgoingQueryParams = OutgoingQueryParams>(options?: StartOptions<QueryParams> | undefined) => Promise<ContinueNode | ErrorNode | FailureNode | StartNode | SuccessNode>;
update: <T extends SingleValueCollectors | MultiSelectCollector | ObjectValueCollectors | AutoCollectors>(collector: T) => Updater<T>;
validate: (collector: SingleValueCollectors | ObjectValueCollectors | MultiValueCollectors | AutoCollectors) => Validator;
poll: (collector: PollingCollector) => Poller;
pollStatus: (collector: PollingCollector) => Poller;
getClient: () => {
status: "start";
} | {
action: string;
collectors: Collectors[];
description?: string;
Expand All @@ -287,6 +285,8 @@ export function davinci<ActionType extends ActionTypes = ActionTypes>(input: {
status: "error";
} | {
status: "failure";
} | {
status: "start";
} | {
authorization?: {
code?: string;
Expand All @@ -297,7 +297,7 @@ export function davinci<ActionType extends ActionTypes = ActionTypes>(input: {
getCollectors: () => Collectors[];
getError: () => DaVinciError | null;
getErrorCollectors: () => CollectorErrors[];
getNode: () => ContinueNode | StartNode | ErrorNode | FailureNode | SuccessNode;
getNode: () => ContinueNode | ErrorNode | FailureNode | StartNode | SuccessNode;
getServer: () => {
_links?: Links;
id?: string;
Expand All @@ -306,8 +306,6 @@ export function davinci<ActionType extends ActionTypes = ActionTypes>(input: {
href?: string;
eventName?: string;
status: "continue";
} | {
status: "start";
} | {
_links?: Links;
eventName?: string;
Expand All @@ -323,6 +321,8 @@ export function davinci<ActionType extends ActionTypes = ActionTypes>(input: {
interactionId?: string;
interactionToken?: string;
status: "failure";
} | {
status: "start";
} | {
_links?: Links;
eventName?: string;
Expand Down Expand Up @@ -524,6 +524,7 @@ export function davinci<ActionType extends ActionTypes = ActionTypes>(input: {
type: string;
};
};
getCache: (requestId: string) => unknown;
};
}>;

Expand Down Expand Up @@ -1035,7 +1036,7 @@ export type InferNoValueCollectorType<T extends NoValueCollectorTypes> = T exten
export type InferSingleValueCollectorType<T extends SingleValueCollectorTypes> = T extends 'TextCollector' ? TextCollector : T extends 'SingleSelectCollector' ? SingleSelectCollector : T extends 'ValidatedTextCollector' ? ValidatedTextCollector : T extends 'PasswordCollector' ? PasswordCollector : SingleValueCollectorWithValue<'SingleValueCollector'> | SingleValueCollectorNoValue<'SingleValueCollector'>;

// @public (undocumented)
export type InferValueObjectCollectorType<T extends ObjectValueCollectorTypes> = T extends 'DeviceAuthenticationCollector' ? DeviceAuthenticationCollector : T extends 'DeviceRegistrationCollector' ? DeviceRegistrationCollector : T extends 'PhoneNumberCollector' ? PhoneNumberCollector : ObjectOptionsCollectorWithObjectValue<'ObjectValueCollector'> | ObjectOptionsCollectorWithStringValue<'ObjectValueCollector'>;
export type InferValueObjectCollectorType<T extends ObjectValueCollectorTypes> = T extends 'DeviceAuthenticationCollector' ? DeviceAuthenticationCollector : T extends 'DeviceRegistrationCollector' ? DeviceRegistrationCollector : T extends 'PhoneNumberCollector' ? PhoneNumberCollector : T extends 'PhoneNumberExtensionCollector' ? PhoneNumberExtensionCollector : ObjectOptionsCollectorWithObjectValue<'ObjectValueCollector'> | ObjectOptionsCollectorWithStringValue<'ObjectValueCollector'>;

// @public (undocumented)
export type InitFlow = () => Promise<FlowNode | InternalErrorResponse>;
Expand Down Expand Up @@ -1170,8 +1171,8 @@ value: Record<string, unknown>;
}, string>;

// @public
export const nodeCollectorReducer: Reducer<(TextCollector | SingleSelectCollector | ValidatedTextCollector | PasswordCollector | MultiSelectCollector | DeviceAuthenticationCollector | DeviceRegistrationCollector | PhoneNumberCollector | IdpCollector | SubmitCollector | FlowCollector | QrCodeCollectorBase | AgreementCollector | ReadOnlyCollector | UnknownCollector | ProtectCollector | FidoRegistrationCollector | FidoAuthenticationCollector | PollingCollector | ActionCollector<"ActionCollector"> | SingleValueCollector<"SingleValueCollector">)[]> & {
getInitialState: () => (TextCollector | SingleSelectCollector | ValidatedTextCollector | PasswordCollector | MultiSelectCollector | DeviceAuthenticationCollector | DeviceRegistrationCollector | PhoneNumberCollector | IdpCollector | SubmitCollector | FlowCollector | QrCodeCollectorBase | AgreementCollector | ReadOnlyCollector | UnknownCollector | ProtectCollector | FidoRegistrationCollector | FidoAuthenticationCollector | PollingCollector | ActionCollector<"ActionCollector"> | SingleValueCollector<"SingleValueCollector">)[];
export const nodeCollectorReducer: Reducer<(TextCollector | SingleSelectCollector | ValidatedTextCollector | PasswordCollector | MultiSelectCollector | PhoneNumberExtensionCollector | DeviceAuthenticationCollector | DeviceRegistrationCollector | PhoneNumberCollector | IdpCollector | SubmitCollector | FlowCollector | QrCodeCollectorBase | AgreementCollector | ReadOnlyCollector | UnknownCollector | ProtectCollector | FidoRegistrationCollector | FidoAuthenticationCollector | PollingCollector | ActionCollector<"ActionCollector"> | SingleValueCollector<"SingleValueCollector">)[]> & {
getInitialState: () => (TextCollector | SingleSelectCollector | ValidatedTextCollector | PasswordCollector | MultiSelectCollector | PhoneNumberExtensionCollector | DeviceAuthenticationCollector | DeviceRegistrationCollector | PhoneNumberCollector | IdpCollector | SubmitCollector | FlowCollector | QrCodeCollectorBase | AgreementCollector | ReadOnlyCollector | UnknownCollector | ProtectCollector | FidoRegistrationCollector | FidoAuthenticationCollector | PollingCollector | ActionCollector<"ActionCollector"> | SingleValueCollector<"SingleValueCollector">)[];
};

// @public (undocumented)
Expand Down Expand Up @@ -1283,10 +1284,10 @@ export type ObjectValueAutoCollectorTypes = 'ObjectValueAutoCollector' | 'FidoRe
export type ObjectValueCollector<T extends ObjectValueCollectorTypes> = ObjectOptionsCollectorWithObjectValue<T> | ObjectOptionsCollectorWithStringValue<T> | ObjectValueCollectorWithObjectValue<T>;

// @public (undocumented)
export type ObjectValueCollectors = DeviceAuthenticationCollector | DeviceRegistrationCollector | PhoneNumberCollector | ObjectOptionsCollectorWithObjectValue<'ObjectSelectCollector'> | ObjectOptionsCollectorWithStringValue<'ObjectSelectCollector'>;
export type ObjectValueCollectors = DeviceAuthenticationCollector | DeviceRegistrationCollector | PhoneNumberCollector | PhoneNumberExtensionCollector | ObjectOptionsCollectorWithObjectValue<'ObjectSelectCollector'> | ObjectOptionsCollectorWithStringValue<'ObjectSelectCollector'>;

// @public
export type ObjectValueCollectorTypes = 'DeviceAuthenticationCollector' | 'DeviceRegistrationCollector' | 'PhoneNumberCollector' | 'ObjectOptionsCollector' | 'ObjectValueCollector' | 'ObjectSelectCollector';
export type ObjectValueCollectorTypes = 'DeviceAuthenticationCollector' | 'DeviceRegistrationCollector' | 'PhoneNumberCollector' | 'PhoneNumberExtensionCollector' | 'ObjectOptionsCollector' | 'ObjectValueCollector' | 'ObjectSelectCollector';

// @public (undocumented)
export interface ObjectValueCollectorWithObjectValue<T extends ObjectValueCollectorTypes, IV = Record<string, string>, OV = Record<string, string>> {
Expand Down Expand Up @@ -1328,13 +1329,68 @@ export type PasswordCollector = SingleValueCollectorNoValue<'PasswordCollector'>
// @public (undocumented)
export type PhoneNumberCollector = ObjectValueCollectorWithObjectValue<'PhoneNumberCollector', PhoneNumberInputValue, PhoneNumberOutputValue>;

// @public (undocumented)
export interface PhoneNumberExtensionCollector {
// (undocumented)
category: 'ObjectValueCollector';
// (undocumented)
error: string | null;
// (undocumented)
id: string;
// (undocumented)
input: {
key: string;
value: PhoneNumberExtensionInputValue;
type: string;
validation: (ValidationRequired | ValidationPhoneNumber)[] | null;
};
// (undocumented)
name: string;
// (undocumented)
output: {
key: string;
label: string;
type: string;
extensionLabel: string;
value: PhoneNumberExtensionOutputValue;
};
// (undocumented)
type: 'PhoneNumberExtensionCollector';
}

// @public (undocumented)
export type PhoneNumberExtensionField = PhoneNumberField & {
showExtension: boolean;
extensionLabel: string;
};

// @public (undocumented)
export interface PhoneNumberExtensionInputValue {
// (undocumented)
countryCode: string;
// (undocumented)
extension: string;
// (undocumented)
phoneNumber: string;
}

// @public (undocumented)
export interface PhoneNumberExtensionOutputValue {
// (undocumented)
countryCode?: string;
// (undocumented)
extension?: string;
// (undocumented)
phoneNumber?: string;
}

// @public (undocumented)
export type PhoneNumberField = {
type: 'PHONE_NUMBER';
key: string;
label: string;
defaultCountryCode: string | null;
required: boolean;
defaultCountryCode: string | null;
validatePhoneNumber: boolean;
};

Expand Down Expand Up @@ -1724,7 +1780,7 @@ export type UnknownField = Record<string, unknown>;
// @public (undocumented)
export const updateCollectorValues: ActionCreatorWithPayload< {
id: string;
value: string | string[] | PhoneNumberInputValue | FidoRegistrationInputValue | FidoAuthenticationInputValue;
value: string | string[] | PhoneNumberInputValue | PhoneNumberExtensionInputValue | FidoRegistrationInputValue | FidoAuthenticationInputValue;
index?: number;
}, string>;

Expand Down
Loading
Loading