Skip to content

Commit 096733d

Browse files
committed
feat: support signalsInitializationOptions pass-through config from AM
chore(protect): update signals-sdk to v5.6.9w chore(protect): fix JSDoc param type and update copyright year to 2026 chore(changeset): add changeset for SDKS-4726 signalsInitializationOptions support fix(protect): narrow SignalsInitializationOptions to Record<string, string> docs: update api report documentation
1 parent b28b6b0 commit 096733d

9 files changed

Lines changed: 15690 additions & 18078 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
'@forgerock/journey-client': patch
3+
'@forgerock/protect': patch
4+
---
5+
6+
Support `signalsInitializationOptions` pass-through config from AM in `PingOneProtectInitializeCallback`.
7+
8+
- `getConfig()` detects `signalsInitializationOptions` in the callback output; if it is a valid plain object, returns it directly as `SignalsInitializationOptions`
9+
- Falls back to the existing `ProtectConfig` construction when the property is absent or invalid (null, string, array)
10+
- `protect()` now accepts `ProtectConfig | SignalsInitializationOptions` so the pass-through config flows in without type assertions
11+
- Updates vendored Signals SDK from v5.6.0w to v5.6.9w

packages/journey-client/api-report/journey-client.api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ export class PingOneProtectEvaluationCallback extends BaseCallback {
318318
// @public
319319
export class PingOneProtectInitializeCallback extends BaseCallback {
320320
constructor(payload: Callback);
321-
getConfig(): {
321+
getConfig(): Record<string, string> | {
322322
envId: string;
323323
consoleLogEnabled: boolean;
324324
deviceAttributesToIgnore: string[];

packages/journey-client/api-report/journey-client.types.api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ export class PingOneProtectEvaluationCallback extends BaseCallback {
305305
// @public
306306
export class PingOneProtectInitializeCallback extends BaseCallback {
307307
constructor(payload: Callback);
308-
getConfig(): {
308+
getConfig(): Record<string, string> | {
309309
envId: string;
310310
consoleLogEnabled: boolean;
311311
deviceAttributesToIgnore: string[];

packages/journey-client/src/lib/callbacks/ping-protect-initialize-callback.test.ts

Lines changed: 123 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* ping-protect-intitialize-callback.test.ts
55
*
6-
* Copyright (c) 2024 - 2025 Ping Identity Corporation. All rights reserved.
6+
* Copyright (c) 2024 - 2026 Ping Identity Corporation. All rights reserved.
77
* This software may be modified and distributed under the terms
88
* of the MIT license. See the LICENSE file for details.
99
*/
@@ -89,6 +89,128 @@ describe('PingOneProtectInitializeCallback', () => {
8989
disableHub: false,
9090
});
9191
});
92+
it('should return signalsInitializationOptions directly when it is a valid plain object', () => {
93+
const signalsInitializationOptions = {
94+
agentIdentification: 'false',
95+
htmlGeoLocation: 'true',
96+
behavioralDataCollection: 'true',
97+
universalDeviceIdentification: 'false',
98+
option1: 'value1',
99+
disableTags: 'false',
100+
};
101+
102+
const callback = new PingOneProtectInitializeCallback({
103+
type: callbackType.PingOneProtectInitializeCallback,
104+
input: [],
105+
output: [
106+
{
107+
name: 'signalsInitializationOptions',
108+
value: signalsInitializationOptions,
109+
},
110+
{
111+
name: 'envId',
112+
value: 'legacy-env-id-that-should-be-ignored',
113+
},
114+
],
115+
});
116+
117+
const config = callback.getConfig();
118+
expect(config).toEqual(signalsInitializationOptions);
119+
expect(config).not.toHaveProperty('envId');
120+
});
121+
122+
it('should fallback to legacy config when signalsInitializationOptions is an array (invalid)', () => {
123+
const callback = new PingOneProtectInitializeCallback({
124+
type: callbackType.PingOneProtectInitializeCallback,
125+
input: [],
126+
output: [
127+
{
128+
name: 'signalsInitializationOptions',
129+
value: [],
130+
},
131+
{
132+
name: 'envId',
133+
value: '02fb4743-189a-4bc7-9d6c-a919edfe6447',
134+
},
135+
],
136+
});
137+
138+
const config = callback.getConfig();
139+
expect(config).toMatchObject({
140+
envId: '02fb4743-189a-4bc7-9d6c-a919edfe6447',
141+
behavioralDataCollection: true,
142+
disableTags: false,
143+
});
144+
});
145+
146+
it('should fallback to legacy config when signalsInitializationOptions is null (invalid)', () => {
147+
const callback = new PingOneProtectInitializeCallback({
148+
type: callbackType.PingOneProtectInitializeCallback,
149+
input: [],
150+
output: [
151+
{
152+
name: 'signalsInitializationOptions',
153+
value: null,
154+
},
155+
{
156+
name: 'envId',
157+
value: '02fb4743-189a-4bc7-9d6c-a919edfe6447',
158+
},
159+
],
160+
});
161+
162+
const config = callback.getConfig();
163+
expect(config).toMatchObject({
164+
envId: '02fb4743-189a-4bc7-9d6c-a919edfe6447',
165+
behavioralDataCollection: true,
166+
disableTags: false,
167+
});
168+
});
169+
170+
it('should fallback to legacy config when signalsInitializationOptions is a string (invalid)', () => {
171+
const callback = new PingOneProtectInitializeCallback({
172+
type: callbackType.PingOneProtectInitializeCallback,
173+
input: [],
174+
output: [
175+
{
176+
name: 'signalsInitializationOptions',
177+
value: 'somestring',
178+
},
179+
{
180+
name: 'envId',
181+
value: '02fb4743-189a-4bc7-9d6c-a919edfe6447',
182+
},
183+
],
184+
});
185+
186+
const config = callback.getConfig();
187+
expect(config).toMatchObject({
188+
envId: '02fb4743-189a-4bc7-9d6c-a919edfe6447',
189+
behavioralDataCollection: true,
190+
disableTags: false,
191+
});
192+
});
193+
194+
it('should fallback to legacy config when signalsInitializationOptions is missing', () => {
195+
const callback = new PingOneProtectInitializeCallback({
196+
type: callbackType.PingOneProtectInitializeCallback,
197+
input: [],
198+
output: [
199+
{
200+
name: 'envId',
201+
value: '02fb4743-189a-4bc7-9d6c-a919edfe6447',
202+
},
203+
],
204+
});
205+
206+
const config = callback.getConfig();
207+
expect(config).toMatchObject({
208+
envId: '02fb4743-189a-4bc7-9d6c-a919edfe6447',
209+
behavioralDataCollection: true,
210+
disableTags: false,
211+
});
212+
});
213+
92214
it('should test the setClientError method', () => {
93215
const callback = new PingOneProtectInitializeCallback({
94216
type: callbackType.PingOneProtectInitializeCallback,

packages/journey-client/src/lib/callbacks/ping-protect-initialize-callback.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2024 - 2025 Ping Identity Corporation. All rights reserved.
2+
* Copyright (c) 2024 - 2026 Ping Identity Corporation. All rights reserved.
33
* This software may be modified and distributed under the terms
44
* of the MIT license. See the LICENSE file for details.
55
*/
@@ -23,6 +23,18 @@ export class PingOneProtectInitializeCallback extends BaseCallback {
2323
* Get callback's initialization config settings
2424
*/
2525
public getConfig() {
26+
const signalsInitializationOptions = this.getOutputByName<Record<string, string> | undefined>(
27+
'signalsInitializationOptions',
28+
undefined,
29+
);
30+
if (
31+
signalsInitializationOptions !== null &&
32+
typeof signalsInitializationOptions === 'object' &&
33+
!Array.isArray(signalsInitializationOptions)
34+
) {
35+
return signalsInitializationOptions;
36+
}
37+
2638
const config = {
2739
envId: this.getOutputByName<string>('envId', ''),
2840
consoleLogEnabled: this.getOutputByName<boolean>('consoleLogEnabled', false),

packages/protect/src/lib/protect.test.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright © 2025 Ping Identity Corporation. All right reserved.
3+
* Copyright © 2025 - 2026 Ping Identity Corporation. All right reserved.
44
*
55
* This software may be modified and distributed under the terms
66
* of the MIT license. See the LICENSE file for details.
@@ -68,6 +68,29 @@ describe('protect (with successfully loaded signals sdk)', () => {
6868
});
6969

7070
describe('native node methods', () => {
71+
it('should call start with a signalsInitializationOptions pass-through config', async () => {
72+
const passthroughConfig = {
73+
envId: '12345',
74+
behavioralDataCollection: 'true',
75+
customOption: 'value1',
76+
};
77+
const protectApi = protect(passthroughConfig);
78+
await protectApi.start();
79+
expect(window._pingOneSignals.init).toHaveBeenCalledWith(passthroughConfig);
80+
});
81+
82+
it('should resume behavioralData when behavioralDataCollection is string "true"', async () => {
83+
const protectApi = protect({ envId: '12345', behavioralDataCollection: 'true' });
84+
await protectApi.start();
85+
expect(window._pingOneSignals.resumeBehavioralData).toHaveBeenCalled();
86+
});
87+
88+
it('should not resume behavioralData when behavioralDataCollection is string "false"', async () => {
89+
const protectApi = protect({ envId: '12345', behavioralDataCollection: 'false' });
90+
await protectApi.start();
91+
expect(window._pingOneSignals.resumeBehavioralData).not.toHaveBeenCalled();
92+
});
93+
7194
it('should call start', async () => {
7295
const protectApi = protect(config);
7396
const protectMock = vi.spyOn(protectApi, 'start');

packages/protect/src/lib/protect.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
/*
22
*
3-
* Copyright © 2025 Ping Identity Corporation. All right reserved.
3+
* Copyright © 2025 - 2026 Ping Identity Corporation. All right reserved.
44
*
55
* This software may be modified and distributed under the terms
66
* of the MIT license. See the LICENSE file for details.
77
*
88
*/
99

10-
import { Protect, ProtectConfig } from './protect.types.js';
10+
import { Protect, ProtectConfig, SignalsInitializationOptions } from './protect.types.js';
1111

1212
// Add Signals SDK namespace to the window object
1313
declare global {
1414
interface Window {
1515
_pingOneSignals: {
16-
init: (initParams?: ProtectConfig) => Promise<void>;
16+
init: (initParams?: ProtectConfig | SignalsInitializationOptions) => Promise<void>;
1717
getData: () => Promise<string>;
1818
pauseBehavioralData: () => void;
1919
resumeBehavioralData: () => void;
@@ -24,10 +24,10 @@ declare global {
2424
/**
2525
* @async
2626
* @function protect - returns a set of methods to interact with the PingOne Signals SDK
27-
* @param {ProtectConfig} options - the configuration options for the PingOne Signals SDK
27+
* @param {ProtectConfig | SignalsInitializationOptions} options - the configuration options for the PingOne Signals SDK
2828
* @returns {Promise<Protect>} - a set of methods to interact with the PingOne Signals SDK
2929
*/
30-
export function protect(options: ProtectConfig): Protect {
30+
export function protect(options: ProtectConfig | SignalsInitializationOptions): Protect {
3131
let protectApiInitialized = false;
3232

3333
return {
@@ -48,7 +48,10 @@ export function protect(options: ProtectConfig): Protect {
4848
try {
4949
await window._pingOneSignals.init(options);
5050

51-
if (options.behavioralDataCollection === true) {
51+
if (
52+
options.behavioralDataCollection === true ||
53+
options.behavioralDataCollection === 'true'
54+
) {
5255
window._pingOneSignals.resumeBehavioralData();
5356
}
5457
} catch (err) {

packages/protect/src/lib/protect.types.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
/*
22
*
3-
* Copyright © 2025 Ping Identity Corporation. All right reserved.
3+
* Copyright © 2025 - 2026 Ping Identity Corporation. All right reserved.
44
*
55
* This software may be modified and distributed under the terms
66
* of the MIT license. See the LICENSE file for details.
77
*
88
*/
99

10+
/**
11+
* @type SignalsInitializationOptions - Arbitrary string key-value map passed directly to the Signals SDK initialization.
12+
* Used when AM returns a `signalsInitializationOptions` output on the `PingOneProtectInitializeCallback`.
13+
*/
14+
export type SignalsInitializationOptions = Record<string, string>;
15+
1016
/**
1117
* @interface ProtectConfig - Interface for the Protect module configuration parameters
1218
* @description - envId is required. All other parameters are optional.

0 commit comments

Comments
 (0)