Skip to content
Merged
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
5 changes: 2 additions & 3 deletions .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
"@forgerock/oidc-app",
"@forgerock/oidc-suites",
"@forgerock/local-release-tool",
"@pingidentity/protect",
"@pingidentity/protect-app",
"@pingidentity/protect-suites"
"@forgerock/protect-app",
"@forgerock/protect-suites"
]
}
5 changes: 5 additions & 0 deletions .changeset/small-rats-cut.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@forgerock/protect': minor
---

Implemented ping protect package
16 changes: 11 additions & 5 deletions e2e/davinci-app/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ import type {
DaVinciConfig,
DavinciClient,
GetClient,
InternalErrorResponse,
NodeStates,
ProtectCollector,
RequestMiddleware,
} from '@forgerock/davinci-client/types';
import { protect } from '@pingidentity/protect';
import { protect } from '@forgerock/protect';

import textComponent from './components/text.js';
import passwordComponent from './components/password.js';
Expand Down Expand Up @@ -82,7 +84,7 @@ const urlParams = new URLSearchParams(window.location.search);
const protectAPI = protect({ envId: '02fb4743-189a-4bc7-9d6c-a919edfe6447' });
const continueToken = urlParams.get('continueToken');
const formEl = document.getElementById('form') as HTMLFormElement;
let resumed: any;
let resumed: InternalErrorResponse | NodeStates | undefined;

// Initialize Protect
const error = await protectAPI.start();
Expand Down Expand Up @@ -331,9 +333,13 @@ const urlParams = new URLSearchParams(window.location.search);
if (!resumed) {
node = await davinciClient.start({ query });
} else {
node = resumed;
console.log('node is resumed');
console.log(node);
if (!resumed.error) {
node = resumed;
console.log('node is resumed');
console.log(node);
} else {
console.error('Error resuming flow:', resumed.error);
}
}

formEl.addEventListener('submit', async (event) => {
Expand Down
2 changes: 1 addition & 1 deletion e2e/davinci-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@forgerock/davinci-client": "workspace:*",
"@forgerock/javascript-sdk": "4.7.0",
"@forgerock/sdk-logger": "workspace:*",
"@pingidentity/protect": "workspace:*"
"@forgerock/protect": "workspace:*"
},
"devDependencies": {}
}
4 changes: 2 additions & 2 deletions e2e/protect-app/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@pingidentity/protect-app",
"name": "@forgerock/protect-app",
"version": "0.0.0",
"description": "Ping Protect Test Apps",
"private": true,
Expand All @@ -12,7 +12,7 @@
},
"dependencies": {
"@forgerock/javascript-sdk": "4.7.0",
"@pingidentity/protect": "workspace:*"
"@forgerock/protect": "workspace:*"
},
"nx": {
"tags": ["scope:e2e"]
Expand Down
8 changes: 4 additions & 4 deletions e2e/protect-app/src/protect-marketplace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import './style.css';
import { protect } from '@pingidentity/protect';
import { protect } from '@forgerock/protect';
import {
CallbackType,
FRAuth,
Expand Down Expand Up @@ -64,10 +64,10 @@ const showUser = (user) => {
};

// Get the next step using the FRAuth API
const nextStep = (event?: Event, step?: FRStep) => {
const nextStep = async (event?: Event, step?: FRStep) => {
event?.preventDefault();
// eslint-disable-next-line @typescript-eslint/no-use-before-define
FRAuth.next(step).then(handleStep).catch(handleFatalError);
await FRAuth.next(step).then(handleStep).catch(handleFatalError);
};

// Define custom handlers to render and submit each expected step
Expand Down Expand Up @@ -193,7 +193,7 @@ const handleFatalError = (err) => {
};

// Begin the login flow
nextStep();
await nextStep();

document.getElementById('Error')?.addEventListener('click', nextStep);
document.getElementById('start-over')?.addEventListener('click', nextStep);
Expand Down
42 changes: 23 additions & 19 deletions e2e/protect-app/src/protect-native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import './style.css';
import { protect } from '@pingidentity/protect';
import { protect } from '@forgerock/protect';
import {
CallbackType,
Config,
Expand All @@ -23,7 +23,7 @@ import {
UserManager,
} from '@forgerock/javascript-sdk';

const protectAPI = await protect({ envId: '02fb4743-189a-4bc7-9d6c-a919edfe6447' });
const protectAPI = protect({ envId: '02fb4743-189a-4bc7-9d6c-a919edfe6447' });
const FATAL = 'Fatal';

await Config.setAsync({
Expand Down Expand Up @@ -78,10 +78,10 @@ const showUser = (user) => {
};

// Get the next step using the FRAuth API
const nextStep = (event?: Event, step?: FRStep) => {
const nextStep = async (event?: Event, step?: FRStep) => {
event?.preventDefault();
// eslint-disable-next-line @typescript-eslint/no-use-before-define
FRAuth.next(step).then(handleStep).catch(handleFatalError);
await FRAuth.next(step).then(handleStep).catch(handleFatalError);
};

// Define custom handlers to render and submit each expected step
Expand All @@ -106,30 +106,34 @@ const handlers = {
const protectCallback = step.getCallbackOfType<PingOneProtectInitializeCallback>(
CallbackType.PingOneProtectInitializeCallback,
);
try {
await protectAPI.start();
console.log('protect initialized');
} catch (err) {
console.error('error initailizing protect', err.message);
protectCallback.setClientError(err.message);
const result = await protectAPI.start();
console.log('protect initialized');

if (result?.error) {
console.error('error initailizing protect', result.error);
protectCallback.setClientError(result.error);
}

nextStep(event, step);
},
ProtectEval: async (step: FRStep) => {
console.log('protect evaluating');
let data;

const protectCallback = step.getCallbackOfType<PingOneProtectEvaluationCallback>(
CallbackType.PingOneProtectEvaluationCallback,
);
try {
data = await protectAPI.getData();

const result = await protectAPI.getData();

if (typeof result !== 'string' && 'error' in result) {
console.error('error getting data', result.error);
protectCallback.setClientError(result.error);
} else {
console.log('received data');
} catch (err) {
console.error('error getting data', err.message);
protectCallback.setClientError(err.message);
protectCallback.setData(result);
console.log('set data on evaluation callback');
}
protectCallback.setData(data);
console.log('set data on evaluation callback');

nextStep(event, step);
},
Error: (step) => {
Expand Down Expand Up @@ -204,7 +208,7 @@ const handleFatalError = (err) => {
};

// Begin the login flow
nextStep();
await nextStep();

document.getElementById('Error')?.addEventListener('click', nextStep);
document.getElementById('start-over')?.addEventListener('click', nextStep);
Expand Down
4 changes: 2 additions & 2 deletions e2e/protect-suites/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@pingidentity/protect-suites",
"name": "@forgerock/protect-suites",
"version": "0.0.0",
"private": true,
"description": "Ping Protect E2E Suites",
Expand All @@ -16,6 +16,6 @@
"type": "module",
"main": "src/index.js",
"nx": {
"implicitDependencies": ["@pingidentity/protect-app"]
"implicitDependencies": ["@forgerock/protect-app"]
}
}
2 changes: 1 addition & 1 deletion e2e/protect-suites/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const config: PlaywrightTestConfig = {
},
webServer: [
{
command: 'pnpm nx serve @pingidentity/protect-app',
command: 'pnpm nx serve @forgerock/protect-app',
port: 8443,
ignoreHTTPSErrors: true,
reuseExistingServer: !process.env.CI,
Expand Down
1 change: 1 addition & 0 deletions e2e/protect-suites/src/protect-native.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ test.describe('Test basic login flow with Ping Protect', () => {
await page.goto('/protect-native');
await expect(page.url()).toBe('http://localhost:8443/protect-native');

await expect(page.getByText('Ping Protect Native')).toBeVisible();
await expect(page.getByText('Protect initializing')).toBeVisible();

await page.getByPlaceholder('Username').fill(username);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"lint": "nx affected --target=lint",
"local-release": "pnpm ts-node tools/release/release.ts",
"nx": "nx",
"preinstall": "npx only-allow pnpm",
"postinstall": "ts-patch install",
"preinstall": "npx only-allow pnpm",
"prepare": "node .husky/install.mjs",
"serve": "nx serve",
"test": "CI=true nx affected:test",
Expand Down
Loading
Loading