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
1 change: 1 addition & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"updateInternalDependencies": "patch",
"ignore": [
"@forgerock/device-client",
"@forgerock/device-client-app",
"@forgerock/davinci-app",
"@forgerock/davinci-suites",
"@forgerock/mock-api-v2",
Expand Down
24 changes: 24 additions & 0 deletions e2e/device-client-app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
25 changes: 25 additions & 0 deletions e2e/device-client-app/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import baseConfig from '../../eslint.config.mjs';

export default [
{
ignores: [
'node_modules',
'*.md',
'LICENSE',
'.swcrc',
'.babelrc',
'.env*',
'.bin',
'dist',
'.eslintignore',
'**/*.html',
'**/*.svg',
'**/*.css',
'public',
'*.json',
'*.d.ts',
'.gitignore',
],
},
...baseConfig,
];
22 changes: 22 additions & 0 deletions e2e/device-client-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "@forgerock/device-client-app",
"version": "0.0.0",
"private": true,
"scripts": {
"build": "pnpm nx nxBuild",
"lint": "pnpm nx nxLint",
"preview": "pnpm nx nxPreview",
"serve": "pnpm nx nxServe"
},
"dependencies": {
"@forgerock/device-client": "workspace:*",
"@forgerock/javascript-sdk": "4.7.0",
"effect": "^3.12.7"
},
"nx": {
"tags": ["scope:e2e"]
},
"devDependencies": {
"@effect/language-service": "^0.20.0"
}
}
1 change: 1 addition & 0 deletions e2e/device-client-app/public/typescript.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions e2e/device-client-app/public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions e2e/device-client-app/src/_callback/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!doctype html>
<html>
<head>
<title>Logged In | E2E Test | Ping Identity JavaScript SDK</title>
</head>

<body></body>
</html>
9 changes: 9 additions & 0 deletions e2e/device-client-app/src/device-binding/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!doctype html>
<html>
<head>
<title>E2E Test | Ping Identity JavaScript SDK</title>
</head>
<body>
<script type="module" src="./main.ts"></script>
</body>
</html>
60 changes: 60 additions & 0 deletions e2e/device-client-app/src/device-binding/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
*
* 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 { Console, Effect } from 'effect';
import { getUser, LoginAndGetClient, handleError, handleSuccess } from '../utils/index.js';

const deviceBinding = Effect.gen(function* () {
const client = yield* LoginAndGetClient;
const user = yield* getUser;
const query = {
userId: user.sub,
realm: 'alpha',
};

const deviceArr = yield* Effect.promise(() => client.bound.get(query));

if ((Array.isArray(deviceArr) && !deviceArr.length) || 'error' in deviceArr) {
yield* Console.log('No devices found or error occurred', deviceArr);
return yield* Effect.fail(new Error('No devices found or error occurred'));
}
yield* Console.log('GET devices', deviceArr);

const [device] = deviceArr;

yield* Console.log('device', device);

const updatedDevice = yield* Effect.promise(() =>
client.bound.update({
...query,
device: { ...device, deviceName: 'UpdatedDeviceName' },
}),
);

if ('error' in updatedDevice) {
return yield* Effect.fail(new Error(`Failed to update device: ${updatedDevice.error}`));
}

yield* Console.log('updated device', updatedDevice);

const deletedDevice = yield* Effect.promise(() =>
client.bound.delete({
...query,
device: updatedDevice,
}),
);

if (deletedDevice !== null && deletedDevice.error) {
return yield* Effect.fail(new Error(`Failed to delete device: ${deletedDevice.error}`));
}

yield* Console.log('deleted', deletedDevice);
});

Effect.runPromise(deviceBinding).then(handleSuccess).catch(handleError);
9 changes: 9 additions & 0 deletions e2e/device-client-app/src/device-profile/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!doctype html>
<html>
<head>
<title>E2E Test | Ping Identity JavaScript SDK</title>
</head>
<body>
<script type="module" src="./main.ts"></script>
</body>
</html>
60 changes: 60 additions & 0 deletions e2e/device-client-app/src/device-profile/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
*
* 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 { Console, Effect } from 'effect';
import { getUser, LoginAndGetClient, handleError, handleSuccess } from '../utils/index.js';

const deviceProfiling = Effect.gen(function* () {
const client = yield* LoginAndGetClient;
const user = yield* getUser;
const query = {
userId: user.sub,
realm: 'alpha',
};

const deviceArr = yield* Effect.promise(() => client.profile.get(query));

if ((Array.isArray(deviceArr) && !deviceArr.length) || 'error' in deviceArr) {
yield* Console.log('No devices found or error occurred', deviceArr);
return yield* Effect.fail(new Error('No devices found or error occurred'));
}
yield* Console.log('GET devices', deviceArr);

const [device] = deviceArr;

yield* Console.log('device', device);

const updatedDevice = yield* Effect.promise(() =>
client.profile.update({
...query,
device: { ...device, alias: 'UpdatedDeviceName' },
}),
);

if ('error' in updatedDevice) {
return yield* Effect.fail(new Error(`Failed to update device: ${updatedDevice.error}`));
}

yield* Console.log('updated device', updatedDevice);

const deletedDevice = yield* Effect.promise(() =>
client.profile.delete({
...query,
device: updatedDevice,
}),
);

if (deletedDevice !== null && deletedDevice.error) {
return yield* Effect.fail(new Error(`Failed to delete device: ${deletedDevice.error}`));
}

yield* Console.log('deleted', deletedDevice);
});

Effect.runPromise(deviceProfiling).then(handleSuccess).catch(handleError);
29 changes: 29 additions & 0 deletions e2e/device-client-app/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Device Client E2E Test Index | Ping Identity JavaScript SDK</title>
</head>
<body>
<div id="app">
<a href="https://vite.dev" target="_blank">
<img src="vite.svg" class="logo" alt="Vite logo" />
</a>
<a href="https://www.typescriptlang.org/" target="_blank">
<img src="typescript.svg" class="logo vanilla" alt="TypeScript logo" />
</a>
<p class="read-the-docs">Click on the Vite and TypeScript logos to learn more</p>
<h2>Device Client E2E Test Index | Ping Identity JavaScript SDK</h2>
<div id="nav">
<a href="/oath/">OATH</a>
<a href="/push/">PUSH</a>
<a href="/webauthn/">WebAuthN</a>
<a href="/device-binding/">Device Binding</a>
<a href="/device-profile/">Device Profiling</a>
</div>
</div>
<script type="module" src="index.ts"></script>
</body>
</html>
10 changes: 10 additions & 0 deletions e2e/device-client-app/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
*
* 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 './style.css';
9 changes: 9 additions & 0 deletions e2e/device-client-app/src/oath/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!doctype html>
<html>
<head>
<title>E2E Test | Ping Identity JavaScript SDK</title>
</head>
<body>
<script type="module" src="./main.ts"></script>
</body>
</html>
47 changes: 47 additions & 0 deletions e2e/device-client-app/src/oath/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
*
* 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 { Console, Effect } from 'effect';
import { getUser, LoginAndGetClient, handleError, handleSuccess } from '../utils/index.js';

const oath = Effect.gen(function* () {
const client = yield* LoginAndGetClient;
const user = yield* getUser;
const query = {
userId: user.sub,
realm: 'alpha',
};

const deviceArr = yield* Effect.promise(() => client.oath.get(query));

if ((Array.isArray(deviceArr) && !deviceArr.length) || 'error' in deviceArr) {
yield* Console.log('No devices found or error occurred', deviceArr);
return yield* Effect.fail(new Error('No devices found or error occurred'));
}
yield* Console.log('GET devices', deviceArr);

const [device] = deviceArr;

yield* Console.log('device', device);

const deletedDevice = yield* Effect.promise(() =>
client.oath.delete({
...query,
device,
}),
);

if (deletedDevice !== null && deletedDevice.error) {
return yield* Effect.fail(new Error(`Failed to delete device: ${deletedDevice.error}`));
}

yield* Console.log('deleted', deletedDevice);
});

Effect.runPromise(oath).then(handleSuccess).catch(handleError);
9 changes: 9 additions & 0 deletions e2e/device-client-app/src/push/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!doctype html>
<html>
<head>
<title>E2E Test | Ping Identity JavaScript SDK</title>
</head>
<body>
<script type="module" src="./main.ts"></script>
</body>
</html>
47 changes: 47 additions & 0 deletions e2e/device-client-app/src/push/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
*
* 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 { Console, Effect } from 'effect';
import { getUser, LoginAndGetClient, handleError, handleSuccess } from '../utils/index.js';

const push = Effect.gen(function* () {
const client = yield* LoginAndGetClient;
const user = yield* getUser;
const query = {
userId: user.sub,
realm: 'alpha',
};

const deviceArr = yield* Effect.promise(() => client.push.get(query));

if ((Array.isArray(deviceArr) && !deviceArr.length) || 'error' in deviceArr) {
yield* Console.log('No devices found or error occurred', deviceArr);
return yield* Effect.fail(new Error('No devices found or error occurred'));
}
yield* Console.log('GET devices', deviceArr);

const [device] = deviceArr;

yield* Console.log('device', device);

const deletedDevice = yield* Effect.promise(() =>
client.push.delete({
...query,
device,
}),
);

if (deletedDevice !== null && deletedDevice.error) {
return yield* Effect.fail(new Error(`Failed to delete device: ${deletedDevice.error}`));
}

yield* Console.log('deleted', deletedDevice);
});

Effect.runPromise(push).then(handleSuccess).catch(handleError);
Loading
Loading