@forgerock/protect 0.0.0-beta-20250825180717
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +233 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +10 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/lib/protect.d.ts +19 -0
- package/dist/src/lib/protect.d.ts.map +1 -0
- package/dist/src/lib/protect.js +209 -0
- package/dist/src/lib/protect.js.map +1 -0
- package/dist/src/lib/protect.mock.data.d.ts +5 -0
- package/dist/src/lib/protect.mock.data.d.ts.map +1 -0
- package/dist/src/lib/protect.mock.data.js +156 -0
- package/dist/src/lib/protect.mock.data.js.map +1 -0
- package/dist/src/lib/protect.types.d.ts +147 -0
- package/dist/src/lib/protect.types.d.ts.map +1 -0
- package/dist/src/lib/protect.types.js +10 -0
- package/dist/src/lib/protect.types.js.map +1 -0
- package/dist/src/lib/signals-sdk.d.ts +2 -0
- package/dist/src/lib/signals-sdk.d.ts.map +1 -0
- package/dist/src/lib/signals-sdk.js +17099 -0
- package/dist/src/lib/signals-sdk.js.map +1 -0
- package/dist/src/types.d.ts +2 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +10 -0
- package/dist/src/types.js.map +1 -0
- package/package.json +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Ping Identity Corporation
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
# Ping Protect
|
|
2
|
+
|
|
3
|
+
The Ping Protect module provides an API for interacting with the PingOne Signals (Protect) SDK to perform risk evaluations. It can be used with either a PingOne AIC/PingAM authentication journey with Protect callbacks or with a PingOne DaVinci flow with Protect collectors.
|
|
4
|
+
|
|
5
|
+
**IMPORTANT NOTE**: This module is not yet published. For the current published Ping Protect package please visit https://github.com/ForgeRock/forgerock-javascript-sdk/tree/develop/packages/ping-protect
|
|
6
|
+
|
|
7
|
+
## Full API
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
// Protect methods
|
|
11
|
+
start();
|
|
12
|
+
getData();
|
|
13
|
+
pauseBehavioralData();
|
|
14
|
+
resumeBehavioralData();
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quickstart with a PingOne AIC or PingAM Authentication Journey
|
|
18
|
+
|
|
19
|
+
The Ping Protect module is intended to be used along with the ForgeRock JavaScript SDK to provide the Protect feature.
|
|
20
|
+
|
|
21
|
+
### Requirements
|
|
22
|
+
|
|
23
|
+
1. PingOne Advanced Identity Cloud (aka PingOne AIC) platform or an up-to-date Ping Identity Access Management (aka PingAM)
|
|
24
|
+
2. PingOne tenant with Protect enabled
|
|
25
|
+
3. A Ping Protect Service configured in AIC or AM
|
|
26
|
+
4. A journey/tree with the appropriate Protect Nodes
|
|
27
|
+
5. A client application with the `@forgerock/javascript-sdk` and `@forgerock/protect` modules installed
|
|
28
|
+
|
|
29
|
+
### Integrate into a Client Application
|
|
30
|
+
|
|
31
|
+
#### Installation
|
|
32
|
+
|
|
33
|
+
Install both modules and their latest versions:
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
npm install @forgerock/javascript-sdk @forgerock/protect
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
#### Initialization (Recommended)
|
|
40
|
+
|
|
41
|
+
The `@forgerock/protect` module has a `protect()` function that accepts configuration options and returns a set of methods for interacting with Protect. The two main responsibilities of the Ping Protect module are the initialization of the profiling and data collection and the completion and preparation of the collected data for the server. You can find these two methods on the API returned by `protect()`.
|
|
42
|
+
|
|
43
|
+
- `start()`
|
|
44
|
+
- `getData()`
|
|
45
|
+
|
|
46
|
+
When calling `protect()`, you have many different options to configure what and how the data is collected. The most important and required of these settings is the `envId`. All other settings are optional.
|
|
47
|
+
|
|
48
|
+
The `start` method can be called at application startup, or when you receive the `PingOneProtectInitializeCallback` callback from the server. We recommend you call `start` as soon as you can to collect as much data as possible for higher accuracy.
|
|
49
|
+
|
|
50
|
+
```js
|
|
51
|
+
import { protect } from '@forgerock/protect';
|
|
52
|
+
|
|
53
|
+
// Call early in your application startup
|
|
54
|
+
const protectApi = protect({ envId: '12345' });
|
|
55
|
+
await protectApi.start();
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
#### Initialization (alternate)
|
|
59
|
+
|
|
60
|
+
Alternatively, you can delay the initialization until you receive the instruction from the server by way of the special callback: `PingOneProtectInitializeCallback`. To do this, you would call the `start` method when the callback is present in the journey.
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
if (step.getCallbacksOfType('PingOneProtectInitializeCallback')) {
|
|
64
|
+
// Asynchronous call
|
|
65
|
+
await protectApi.start();
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
#### Data collection
|
|
70
|
+
|
|
71
|
+
You then call the `FRAuth.next` method after initialization to move the user forward in the journey.
|
|
72
|
+
|
|
73
|
+
```js
|
|
74
|
+
FRAuth.next(step);
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
At some point in the journey, and as late as possible in order to collect as much data as you can, you will come across the `PingOneProtectEvaluationCallback`. This is when you call the `getData` method to package what's been collected for the server to evaluate.
|
|
78
|
+
|
|
79
|
+
```js
|
|
80
|
+
let data;
|
|
81
|
+
|
|
82
|
+
if (step.getCallbacksOfType('PingOneProtectEvaluationCallback')) {
|
|
83
|
+
// Asynchronous call
|
|
84
|
+
data = await protectApi.getData();
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Now that we have the data, set it on the callback in order to send it to the server when we call `next`.
|
|
89
|
+
|
|
90
|
+
```js
|
|
91
|
+
callback.setData(data);
|
|
92
|
+
|
|
93
|
+
FRAuth.next(step);
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Error Handling
|
|
97
|
+
|
|
98
|
+
The Protect API methods will return an error object if they fail. When you encounter an error during initialization or evaluation, set the error message on the callback using the `setClientError` method. Setting the message on the callback is how it gets sent to the server on the `FRAuth.next` method call.
|
|
99
|
+
|
|
100
|
+
```js
|
|
101
|
+
if (step.getCallbacksOfType('PingOneProtectInitializeCallback')) {
|
|
102
|
+
const callback = step.getCallbackOfType('PingOneProtectInitializeCallback');
|
|
103
|
+
|
|
104
|
+
// Asynchronous call
|
|
105
|
+
const result = await protectApi.start();
|
|
106
|
+
|
|
107
|
+
if (result?.error) {
|
|
108
|
+
callback.setClientError(result.error);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
A similar process is used for the evaluation step.
|
|
114
|
+
|
|
115
|
+
```js
|
|
116
|
+
if (step.getCallbacksOfType('PingOneProtectEvaluationCallback')) {
|
|
117
|
+
const callback = step.getCallbackOfType('PingOneProtectEvaluationCallback');
|
|
118
|
+
|
|
119
|
+
// Asynchronous call
|
|
120
|
+
const result = await protectApi.getData();
|
|
121
|
+
|
|
122
|
+
if (typeof result !== 'string' && 'error' in result) {
|
|
123
|
+
callback.setClientError(data.error);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Quickstart with a PingOne DaVinci Flow
|
|
129
|
+
|
|
130
|
+
The Ping Protect module is intended to be used along with the DaVinci client to provide the Ping Protect feature.
|
|
131
|
+
|
|
132
|
+
### Requirements
|
|
133
|
+
|
|
134
|
+
1. A PingOne environment with PingOne Protect added
|
|
135
|
+
2. A worker application configured in your PingOne environment
|
|
136
|
+
3. A DaVinci flow with the appropriate Protect connectors
|
|
137
|
+
4. A client application with the `@forgerock/davinci-client` and `@forgerock/protect` modules installed
|
|
138
|
+
|
|
139
|
+
### Integrate into a Client Application
|
|
140
|
+
|
|
141
|
+
#### Initialization (Recommended)
|
|
142
|
+
|
|
143
|
+
Install both modules and their latest versions:
|
|
144
|
+
|
|
145
|
+
```sh
|
|
146
|
+
npm install @forgerock/davinci-client @forgerock/protect
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
The `@forgerock/protect` module has a `protect()` function that accepts configuration options and returns a set of methods for interacting with Protect. The two main responsibilities of the Ping Protect module are the initialization of the profiling and data collection and the completion and preparation of the collected data for the server. You can find these two methods on the API returned by `protect()`.
|
|
150
|
+
|
|
151
|
+
- `start()`
|
|
152
|
+
- `getData()`
|
|
153
|
+
|
|
154
|
+
When calling `protect()`, you have many different options to configure what and how the data is collected. The most important and required of these settings is the `envId`. All other settings are optional.
|
|
155
|
+
|
|
156
|
+
The `start` method can be called at application startup, or when you receive the `ProtectCollector` from the server. We recommend you call `start` as soon as you can to collect as much data as possible for higher accuracy.
|
|
157
|
+
|
|
158
|
+
```js
|
|
159
|
+
import { protect } from '@forgerock/protect';
|
|
160
|
+
|
|
161
|
+
// Call early in your application startup
|
|
162
|
+
const protectApi = protect({ envId: '12345' });
|
|
163
|
+
await protectApi.start();
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
#### Initialization (alternate)
|
|
167
|
+
|
|
168
|
+
Alternatively, you can delay the initialization until you receive the instruction from the server by way of the `ProtectCollector`. To do this, you would call the `start` method when the collector is present in the flow. The Protect collector is returned from the server when it is configured with either a PingOne Forms connector or HTTP connector with Custom HTML Template.
|
|
169
|
+
|
|
170
|
+
```js
|
|
171
|
+
const collectors = davinciClient.getCollectors();
|
|
172
|
+
collectors.forEach((collector) => {
|
|
173
|
+
if (collector.type === 'ProtectCollector') {
|
|
174
|
+
// Optionally use configuration options from the flow to initialize the protect module
|
|
175
|
+
const config = collector.output.config;
|
|
176
|
+
|
|
177
|
+
// Initialize the Protect module and begin collecting data
|
|
178
|
+
const protectApi = protect({
|
|
179
|
+
envId: '12345',
|
|
180
|
+
behavioralDataCollection: config.behavioralDataCollection,
|
|
181
|
+
universalDeviceIdentification: config.universalDeviceIdentification,
|
|
182
|
+
});
|
|
183
|
+
await protectApi.start();
|
|
184
|
+
}
|
|
185
|
+
...
|
|
186
|
+
});
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
#### Data collection
|
|
190
|
+
|
|
191
|
+
When the user has finished filling out the form and is ready to submit, you can call the `getData` method to package what's been collected. The Protector collector should then be updated with this data to send back to the server to evaluate.
|
|
192
|
+
|
|
193
|
+
```js
|
|
194
|
+
async function onSubmitHandler() {
|
|
195
|
+
try {
|
|
196
|
+
const protectCollector = collectors.find((collector) => collector.type === 'ProtectCollector');
|
|
197
|
+
|
|
198
|
+
// Update the Protect collector with the data collected
|
|
199
|
+
if (protectCollector) {
|
|
200
|
+
const updater = davinciClient.update(protectCollector);
|
|
201
|
+
const data = await protectApi.getData();
|
|
202
|
+
updater(data);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// Submit all collectors and get the next node in the flow
|
|
206
|
+
await davinciClient.next();
|
|
207
|
+
} catch (err) {
|
|
208
|
+
// handle error
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Error Handling
|
|
214
|
+
|
|
215
|
+
The Protect API methods will return an error object if they fail. You may use this to return a message to the user or implement your own error handling.
|
|
216
|
+
|
|
217
|
+
**Example**: Handling error messages on `start`
|
|
218
|
+
|
|
219
|
+
```js
|
|
220
|
+
const result = await protectApi.start();
|
|
221
|
+
if (result?.error) {
|
|
222
|
+
console.error(`Error initializing Protect: ${result.error}`);
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
**Example**: Handling error messages on `getData`
|
|
227
|
+
|
|
228
|
+
```js
|
|
229
|
+
const result = await protectApi.getData();
|
|
230
|
+
if (typeof result !== 'string' && 'error' in result) {
|
|
231
|
+
console.error(`Failed to retrieve data from Protect: ${result.error}`);
|
|
232
|
+
}
|
|
233
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AASA,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
*
|
|
3
|
+
* Copyright © 2025 Ping Identity Corporation. All right reserved.
|
|
4
|
+
*
|
|
5
|
+
* This software may be modified and distributed under the terms
|
|
6
|
+
* of the MIT license. See the LICENSE file for details.
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
export * from './lib/protect.js';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Protect, ProtectConfig } from './protect.types.js';
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
_pingOneSignals: {
|
|
5
|
+
init: (initParams?: ProtectConfig) => Promise<void>;
|
|
6
|
+
getData: () => Promise<string>;
|
|
7
|
+
pauseBehavioralData: () => void;
|
|
8
|
+
resumeBehavioralData: () => void;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* @async
|
|
14
|
+
* @function protect - returns a set of methods to interact with the PingOne Signals SDK
|
|
15
|
+
* @param {ProtectConfig} options - the configuration options for the PingOne Signals SDK
|
|
16
|
+
* @returns {Promise<Protect>} - a set of methods to interact with the PingOne Signals SDK
|
|
17
|
+
*/
|
|
18
|
+
export declare function protect(options: ProtectConfig): Protect;
|
|
19
|
+
//# sourceMappingURL=protect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protect.d.ts","sourceRoot":"","sources":["../../../src/lib/protect.ts"],"names":[],"mappings":"AAiBA,OAAO,EACL,OAAO,EACP,aAAa,EAId,MAAM,oBAAoB,CAAC;AAG5B,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,eAAe,EAAE;YACf,IAAI,EAAE,CAAC,UAAU,CAAC,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;YACpD,OAAO,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;YAC/B,mBAAmB,EAAE,MAAM,IAAI,CAAC;YAChC,oBAAoB,EAAE,MAAM,IAAI,CAAC;SAClC,CAAC;KACH;CACF;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CA0OvD"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/*
|
|
2
|
+
*
|
|
3
|
+
* Copyright © 2025 Ping Identity Corporation. All right reserved.
|
|
4
|
+
*
|
|
5
|
+
* This software may be modified and distributed under the terms
|
|
6
|
+
* of the MIT license. See the LICENSE file for details.
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
import { CallbackType, } from '@forgerock/javascript-sdk';
|
|
10
|
+
/**
|
|
11
|
+
* @async
|
|
12
|
+
* @function protect - returns a set of methods to interact with the PingOne Signals SDK
|
|
13
|
+
* @param {ProtectConfig} options - the configuration options for the PingOne Signals SDK
|
|
14
|
+
* @returns {Promise<Protect>} - a set of methods to interact with the PingOne Signals SDK
|
|
15
|
+
*/
|
|
16
|
+
export function protect(options) {
|
|
17
|
+
let protectApiInitialized = false;
|
|
18
|
+
return {
|
|
19
|
+
start: async () => {
|
|
20
|
+
try {
|
|
21
|
+
/*
|
|
22
|
+
* Load the Ping Signals SDK
|
|
23
|
+
* this automatically pollutes the window
|
|
24
|
+
* there are no exports of this module
|
|
25
|
+
*/
|
|
26
|
+
await import('./signals-sdk.js');
|
|
27
|
+
protectApiInitialized = true;
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
console.error('error loading ping signals', err);
|
|
31
|
+
return { error: 'Failed to load PingOne Signals SDK' };
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
await window._pingOneSignals.init(options);
|
|
35
|
+
if (options.behavioralDataCollection === true) {
|
|
36
|
+
window._pingOneSignals.resumeBehavioralData();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
console.error('error initializing ping protect', err);
|
|
41
|
+
return { error: 'Failed to initialize PingOne Signals SDK' };
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
getData: async () => {
|
|
45
|
+
if (!protectApiInitialized) {
|
|
46
|
+
return { error: 'PingOne Signals SDK is not initialized' };
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
return await window._pingOneSignals.getData();
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
console.error('error getting data from ping protect', err);
|
|
53
|
+
return { error: 'Failed to get data from Protect' };
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
pauseBehavioralData: () => {
|
|
57
|
+
if (!protectApiInitialized) {
|
|
58
|
+
return { error: 'PingOne Signals SDK is not initialized' };
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
window._pingOneSignals.pauseBehavioralData();
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
console.error('error pausing behavioral data in ping protect', err);
|
|
65
|
+
return { error: 'Failed to pause behavioral data in Protect' };
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
resumeBehavioralData: () => {
|
|
69
|
+
if (!protectApiInitialized) {
|
|
70
|
+
return { error: 'PingOne Signals SDK is not initialized' };
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
window._pingOneSignals.resumeBehavioralData();
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
console.error('error resuming behavioral data in ping protect', err);
|
|
77
|
+
return { error: 'Failed to resume behavioral data in Protect' };
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
/** ***********************************************************************************************
|
|
81
|
+
* The following methods are required when using the Ping Protect Marketplace nodes, which has
|
|
82
|
+
* generic callbacks, but can be used for native nodes and/or either callback type.
|
|
83
|
+
*
|
|
84
|
+
* TODO: Marketplace node verfication with these methods has not yet been completed
|
|
85
|
+
*/
|
|
86
|
+
getPauseBehavioralData: (step) => {
|
|
87
|
+
// Check for native callback first
|
|
88
|
+
try {
|
|
89
|
+
const nativeCallback = step.getCallbackOfType(CallbackType.PingOneProtectEvaluationCallback);
|
|
90
|
+
const shouldPause = nativeCallback?.getPauseBehavioralData();
|
|
91
|
+
return shouldPause || false;
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
// Do nothing
|
|
96
|
+
}
|
|
97
|
+
// If we are here, we are dealing with Marketplace nodes
|
|
98
|
+
const cbs = step.getCallbacksOfType(CallbackType.MetadataCallback);
|
|
99
|
+
if (!cbs.length) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
const protectMetadataCb = cbs.find((metadataCallback) => {
|
|
103
|
+
const data = metadataCallback.getData();
|
|
104
|
+
return data._type === 'PingOneProtect';
|
|
105
|
+
});
|
|
106
|
+
if (!protectMetadataCb) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
const data = protectMetadataCb.getData();
|
|
110
|
+
if (data._action === 'protect_risk_evaluation') {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
return !!data.behavioralDataCollection;
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
getNodeConfig: (step) => {
|
|
118
|
+
// Check for native callback first
|
|
119
|
+
try {
|
|
120
|
+
const nativeCallback = step.getCallbackOfType(CallbackType.PingOneProtectInitializeCallback);
|
|
121
|
+
const config = nativeCallback?.getConfig();
|
|
122
|
+
return config;
|
|
123
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
124
|
+
}
|
|
125
|
+
catch (err) {
|
|
126
|
+
// Do nothing
|
|
127
|
+
}
|
|
128
|
+
const cbs = step.getCallbacksOfType(CallbackType.MetadataCallback);
|
|
129
|
+
if (!cbs.length) {
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|
|
132
|
+
const protectMetadataCb = cbs.find((metadataCallback) => {
|
|
133
|
+
const data = metadataCallback.getData();
|
|
134
|
+
return data._action === 'protect_initialize';
|
|
135
|
+
});
|
|
136
|
+
if (!protectMetadataCb) {
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
const data = protectMetadataCb.getData();
|
|
140
|
+
return data;
|
|
141
|
+
},
|
|
142
|
+
getProtectType: (step) => {
|
|
143
|
+
const cbs = step.getCallbacksOfType(CallbackType.MetadataCallback);
|
|
144
|
+
if (!cbs.length) {
|
|
145
|
+
return 'none';
|
|
146
|
+
}
|
|
147
|
+
const protectMetadataCb = cbs.find((cb) => {
|
|
148
|
+
const metadataCallback = cb;
|
|
149
|
+
const data = metadataCallback.getData();
|
|
150
|
+
return data._type === 'PingOneProtect';
|
|
151
|
+
});
|
|
152
|
+
if (!protectMetadataCb) {
|
|
153
|
+
return 'none';
|
|
154
|
+
}
|
|
155
|
+
const data = protectMetadataCb.getData();
|
|
156
|
+
return data._action === 'protect_initialize' ? 'initialize' : 'evaluate';
|
|
157
|
+
},
|
|
158
|
+
setNodeClientError: (step, value) => {
|
|
159
|
+
// Check for native callback first
|
|
160
|
+
const nativeEvaluationCallback = step.getCallbacksOfType(CallbackType.PingOneProtectEvaluationCallback);
|
|
161
|
+
const nativeInitializeCallback = step.getCallbacksOfType(CallbackType.PingOneProtectInitializeCallback);
|
|
162
|
+
const arr = [...nativeEvaluationCallback, ...nativeInitializeCallback];
|
|
163
|
+
if (arr.length) {
|
|
164
|
+
const cb = arr[0];
|
|
165
|
+
cb.setClientError(value);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
// If we are here, we are dealing with Marketplace nodes
|
|
169
|
+
const cbs = step.getCallbacksOfType(CallbackType.HiddenValueCallback);
|
|
170
|
+
if (!cbs.length) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
const clientErrorCb = cbs.find((hiddenValueCallback) => {
|
|
174
|
+
const output = hiddenValueCallback.getOutputByName('id', '');
|
|
175
|
+
return output === 'clientError';
|
|
176
|
+
});
|
|
177
|
+
if (!clientErrorCb) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
clientErrorCb.setInputValue(value);
|
|
181
|
+
},
|
|
182
|
+
setNodeInputValue: (step, value) => {
|
|
183
|
+
// Check for native callback first
|
|
184
|
+
try {
|
|
185
|
+
const nativeCallback = step.getCallbackOfType(CallbackType.PingOneProtectEvaluationCallback);
|
|
186
|
+
nativeCallback?.setData(value);
|
|
187
|
+
return;
|
|
188
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
189
|
+
}
|
|
190
|
+
catch (err) {
|
|
191
|
+
// Do nothing
|
|
192
|
+
}
|
|
193
|
+
// If we are here, we are dealing with Marketplace nodes
|
|
194
|
+
const cbs = step.getCallbacksOfType(CallbackType.HiddenValueCallback);
|
|
195
|
+
if (!cbs.length) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
const inputCb = cbs.find((hiddenValueCallback) => {
|
|
199
|
+
const output = hiddenValueCallback.getOutputByName('id', '');
|
|
200
|
+
return output === 'pingone_risk_evaluation_signals';
|
|
201
|
+
});
|
|
202
|
+
if (!inputCb) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
inputCb.setInputValue(value);
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
//# sourceMappingURL=protect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protect.js","sourceRoot":"","sources":["../../../src/lib/protect.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,YAAY,GAMb,MAAM,2BAA2B,CAAC;AAqBnC;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,OAAsB;IAC5C,IAAI,qBAAqB,GAAG,KAAK,CAAC;IAElC,OAAO;QACL,KAAK,EAAE,KAAK,IAAuC,EAAE;YACnD,IAAI,CAAC;gBACH;;;;mBAIG;gBACH,MAAM,MAAM,CAAC,kBAA4B,CAAC,CAAC;gBAC3C,qBAAqB,GAAG,IAAI,CAAC;YAC/B,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAC;gBACjD,OAAO,EAAE,KAAK,EAAE,oCAAoC,EAAE,CAAC;YACzD,CAAC;YAED,IAAI,CAAC;gBACH,MAAM,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBAE3C,IAAI,OAAO,CAAC,wBAAwB,KAAK,IAAI,EAAE,CAAC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C;YAEH,IAAI,CAAC,aAAa,EAAE,CAAC;gBACnB,OAAO;YACT,CAAC;YAED,aAAa,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QACrC,CAAC;QACD,iBAAiB,EAAE,CAAC,IAAY,EAAE,KAAa,EAAQ,EAAE;YACvD,kCAAkC;YAClC,IAAI,CAAC;gBACH,MAAM,cAAc,GAAG,IAAI,CAAC,iBAAiB,CAC3C,YAAY,CAAC,gCAAgC,CAC9C,CAAC;gBAEF,cAAc,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;gBAC/B,OAAO;gBACP,6DAA6D;YAC/D,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,aAAa;YACf,CAAC;YAED,wDAAwD;YACxD,MAAM,GAAG,GAAG,IAAI,CAAC,kBAAkB,CAAsB,YAAY,CAAC,mBAAmB,CAAC,CAAC;YAE3F,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;gBAChB,OAAO;YACT,CAAC;YAED,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,mBAAmB,EAAE,EAAE;gBAC/C,MAAM,MAAM,GAAG,mBAAmB,CAAC,eAAe,CAAS,IAAI,EAAE,EAAE,CAAC,CAAC;gBACrE,OAAO,MAAM,KAAK,iCAAiC,CAAC;YACtD,CAAC,CAAC,CAAC;YAEH,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,OAAO;YACT,CAAC;YAED,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC/B,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FRStep } from '@forgerock/javascript-sdk';
|
|
2
|
+
export declare const standardPingProtectInitializeStep: FRStep;
|
|
3
|
+
export declare const standardPingProtectEvaluationStep: FRStep;
|
|
4
|
+
export declare const noProtectType: FRStep;
|
|
5
|
+
//# sourceMappingURL=protect.mock.data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protect.mock.data.d.ts","sourceRoot":"","sources":["../../../src/lib/protect.mock.data.ts"],"names":[],"mappings":"AASA,OAAO,EAAgB,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAEjE,eAAO,MAAM,iCAAiC,QA6C5C,CAAC;AAEH,eAAO,MAAM,iCAAiC,QAwD5C,CAAC;AAEH,eAAO,MAAM,aAAa,QA0CxB,CAAC"}
|