From d368616d71147e35e15d53be19f71a1881914807 Mon Sep 17 00:00:00 2001 From: ryanbas21 Date: Tue, 30 Jan 2024 14:05:11 -0700 Subject: [PATCH] feat(javascript-sdk): handle-device-name-in-response handle the device name of a security key by parsing the response and returning the name thats in the html string --- .github/workflows/ci.yml | 11 +- .verdaccio/config.yml | 6 +- e2e/autoscript-suites/package.json | 5 +- e2e/autoscript-suites/tsconfig.spec.json | 1 + e2e/mock-api/src/index.js | 5 +- package-lock.json | 585 +++++++++++++----- .../src/fr-recovery-codes/index.ts | 6 +- .../fr-recovery-codes/recovery-codes.test.ts | 6 + .../fr-recovery-codes/script-parser.test.ts | 19 +- .../src/fr-recovery-codes/script-parser.ts | 23 +- .../script-text.mock.data.ts | 14 +- plugins/wait-for-api/tsconfig.lib.json | 1 + 12 files changed, 522 insertions(+), 160 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dcbfade5c..dcd318b11 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,10 @@ jobs: cache: 'npm' cache-dependency-path: '**/package-lock.json' - name: Setup custom host for sdkapp.example.com - run: sudo echo "127.0.0.1 sdkapp.example.com auth.example.com api.example.com user.example.com" | sudo tee -a /etc/hosts + run: | + sudo echo "127.0.0.1 localhost sdkapp.example.com auth.example.com api.example.com user.example.com" | sudo tee -a /etc/hosts + sudo echo "::1 ip6-localhost ip6-loopback" | sudo tee -a /etc/hosts + - name: npm install # if: steps.cache.outputs.cache-hit != 'true' run: npm ci @@ -41,12 +44,15 @@ jobs: - run: npx nx affected --t lint --parallel --max-parallel=3 - run: npx nx affected --t test --parallel --max-parallel=3 - run: npx nx affected --t test --configuration=integration - - run: npx nx affected --t e2e --parallel 1 --exclude token-vault-suites # It's important that we always run this step, otherwise in the case of any failures in preceding non-Nx steps, the agents will keep running and waste billable minutes - name: Stop All Agents if: ${{ always() }} run: npx nx-cloud stop-all-agents + - name: e2e + run: npm run nx e2e autoscript-suites + env: + NX_CLOUD_DISTRIBUTED_EXECUTION: false - name: 'Artifacts' uses: actions/upload-artifact@v3 with: @@ -92,6 +98,7 @@ jobs: - run: npm install @nrwl/nx-cloud - name: Setup custom host for sdkapp.example.com run: sudo echo "127.0.0.1 sdkapp.example.com auth.example.com api.example.com user.example.com" | sudo tee -a /etc/hosts + - run: sudo echo "::1 sdkapp.example.com auth.example.com api.example.com user.example.com" | sudo tee -a /etc/hosts - run: npx playwright install chromium firefox webkit - name: Start Nx Agent ${{ matrix.agent }} run: npx nx-cloud start-agent diff --git a/.verdaccio/config.yml b/.verdaccio/config.yml index da96c9b6d..055a3933a 100644 --- a/.verdaccio/config.yml +++ b/.verdaccio/config.yml @@ -12,13 +12,9 @@ uplinks: maxage: 60m packages: - '@forgerock/*': - access: $all - publish: $authenticated - '**': access: $all - publish: $authenticated + publish: $all # if package is not available locally, proxy requests to npm registry proxy: npmjs diff --git a/e2e/autoscript-suites/package.json b/e2e/autoscript-suites/package.json index 8a589b830..f388b85d3 100644 --- a/e2e/autoscript-suites/package.json +++ b/e2e/autoscript-suites/package.json @@ -18,5 +18,8 @@ "bugs": { "url": "https://github.com/ForgeRock/forgerock-javascript-sdk/issues" }, - "homepage": "https://github.com/ForgeRock/forgerock-javascript-sdk#readme" + "homepage": "https://github.com/ForgeRock/forgerock-javascript-sdk#readme", + "nx": { + "includedScripts": [] + } } diff --git a/e2e/autoscript-suites/tsconfig.spec.json b/e2e/autoscript-suites/tsconfig.spec.json index e1790a02d..d48ccb404 100644 --- a/e2e/autoscript-suites/tsconfig.spec.json +++ b/e2e/autoscript-suites/tsconfig.spec.json @@ -6,6 +6,7 @@ "noImplicitAny": false }, "include": [ + "playwright.config.ts", "utilities/*", "suites/*", "**/*.test.ts", diff --git a/e2e/mock-api/src/index.js b/e2e/mock-api/src/index.js index 5da0e4819..d2081f302 100644 --- a/e2e/mock-api/src/index.js +++ b/e2e/mock-api/src/index.js @@ -7,7 +7,7 @@ * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ - +import * as dns from 'dns'; import cors from 'cors'; import express from 'express'; import cookieParser from 'cookie-parser'; @@ -21,7 +21,10 @@ import { MOCK_PORT } from './app/env.config'; import authRoutes from './app/routes.auth'; import resourceRoutes from './app/routes.resource'; +dns.setDefaultResultOrder('ipv4first'); + const app = express(); + app.use(express.json()); app.use('/am/XUI/images', express.static(path.join(__dirname, 'public'))); app.use(cookieParser()); diff --git a/package-lock.json b/package-lock.json index e616f55c6..5040de03e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,12 @@ "packages": { "": { "name": "@forgerock/javascript-sdk", - "workspaces": ["e2e/*", "packages/*", "samples/*", "shared/*"], + "workspaces": [ + "e2e/*", + "packages/*", + "samples/*", + "shared/*" + ], "devDependencies": { "@changesets/changelog-github": "^0.4.8", "@changesets/cli": "^2.26.1", @@ -4018,10 +4023,14 @@ "version": "0.17.18", "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.17.18.tgz", "integrity": "sha512-EmwL+vUBZJ7mhFCs5lA4ZimpUH3WMAoqvOIYhVQwdIgSpHC8ImHdsRyhHAVxpDYUSm0lWvd63z0XH1IlImS2Qw==", - "cpu": ["arm"], + "cpu": [ + "arm" + ], "dev": true, "optional": true, - "os": ["android"], + "os": [ + "android" + ], "engines": { "node": ">=12" } @@ -4030,10 +4039,14 @@ "version": "0.17.18", "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.17.18.tgz", "integrity": "sha512-/iq0aK0eeHgSC3z55ucMAHO05OIqmQehiGay8eP5l/5l+iEr4EIbh4/MI8xD9qRFjqzgkc0JkX0LculNC9mXBw==", - "cpu": ["arm64"], + "cpu": [ + "arm64" + ], "dev": true, "optional": true, - "os": ["android"], + "os": [ + "android" + ], "engines": { "node": ">=12" } @@ -4042,10 +4055,14 @@ "version": "0.17.18", "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.17.18.tgz", "integrity": "sha512-x+0efYNBF3NPW2Xc5bFOSFW7tTXdAcpfEg2nXmxegm4mJuVeS+i109m/7HMiOQ6M12aVGGFlqJX3RhNdYM2lWg==", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "dev": true, "optional": true, - "os": ["android"], + "os": [ + "android" + ], "engines": { "node": ">=12" } @@ -4054,21 +4071,29 @@ "version": "0.17.18", "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.17.18.tgz", "integrity": "sha512-6tY+djEAdF48M1ONWnQb1C+6LiXrKjmqjzPNPWXhu/GzOHTHX2nh8Mo2ZAmBFg0kIodHhciEgUBtcYCAIjGbjQ==", - "cpu": ["arm64"], + "cpu": [ + "arm64" + ], "dev": true, "optional": true, - "os": ["darwin"], + "os": [ + "darwin" + ], "engines": { "node": ">=12" } }, "node_modules/@esbuild/darwin-x64": { "version": "0.17.19", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "dev": true, "license": "MIT", "optional": true, - "os": ["darwin"], + "os": [ + "darwin" + ], "engines": { "node": ">=12" } @@ -4077,10 +4102,14 @@ "version": "0.17.18", "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.17.18.tgz", "integrity": "sha512-fw/ZfxfAzuHfaQeMDhbzxp9mc+mHn1Y94VDHFHjGvt2Uxl10mT4CDavHm+/L9KG441t1QdABqkVYwakMUeyLRA==", - "cpu": ["arm64"], + "cpu": [ + "arm64" + ], "dev": true, "optional": true, - "os": ["freebsd"], + "os": [ + "freebsd" + ], "engines": { "node": ">=12" } @@ -4089,10 +4118,14 @@ "version": "0.17.18", "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.17.18.tgz", "integrity": "sha512-FQFbRtTaEi8ZBi/A6kxOC0V0E9B/97vPdYjY9NdawyLd4Qk5VD5g2pbWN2VR1c0xhzcJm74HWpObPszWC+qTew==", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "dev": true, "optional": true, - "os": ["freebsd"], + "os": [ + "freebsd" + ], "engines": { "node": ">=12" } @@ -4101,10 +4134,14 @@ "version": "0.17.18", "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.17.18.tgz", "integrity": "sha512-jW+UCM40LzHcouIaqv3e/oRs0JM76JfhHjCavPxMUti7VAPh8CaGSlS7cmyrdpzSk7A+8f0hiedHqr/LMnfijg==", - "cpu": ["arm"], + "cpu": [ + "arm" + ], "dev": true, "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">=12" } @@ -4113,10 +4150,14 @@ "version": "0.17.18", "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.17.18.tgz", "integrity": "sha512-R7pZvQZFOY2sxUG8P6A21eq6q+eBv7JPQYIybHVf1XkQYC+lT7nDBdC7wWKTrbvMXKRaGudp/dzZCwL/863mZQ==", - "cpu": ["arm64"], + "cpu": [ + "arm64" + ], "dev": true, "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">=12" } @@ -4125,10 +4166,14 @@ "version": "0.17.18", "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.17.18.tgz", "integrity": "sha512-ygIMc3I7wxgXIxk6j3V00VlABIjq260i967Cp9BNAk5pOOpIXmd1RFQJQX9Io7KRsthDrQYrtcx7QCof4o3ZoQ==", - "cpu": ["ia32"], + "cpu": [ + "ia32" + ], "dev": true, "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">=12" } @@ -4137,10 +4182,14 @@ "version": "0.17.18", "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.17.18.tgz", "integrity": "sha512-bvPG+MyFs5ZlwYclCG1D744oHk1Pv7j8psF5TfYx7otCVmcJsEXgFEhQkbhNW8otDHL1a2KDINW20cfCgnzgMQ==", - "cpu": ["loong64"], + "cpu": [ + "loong64" + ], "dev": true, "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">=12" } @@ -4149,10 +4198,14 @@ "version": "0.17.18", "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.17.18.tgz", "integrity": "sha512-oVqckATOAGuiUOa6wr8TXaVPSa+6IwVJrGidmNZS1cZVx0HqkTMkqFGD2HIx9H1RvOwFeWYdaYbdY6B89KUMxA==", - "cpu": ["mips64el"], + "cpu": [ + "mips64el" + ], "dev": true, "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">=12" } @@ -4161,10 +4214,14 @@ "version": "0.17.18", "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.17.18.tgz", "integrity": "sha512-3dLlQO+b/LnQNxgH4l9rqa2/IwRJVN9u/bK63FhOPB4xqiRqlQAU0qDU3JJuf0BmaH0yytTBdoSBHrb2jqc5qQ==", - "cpu": ["ppc64"], + "cpu": [ + "ppc64" + ], "dev": true, "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">=12" } @@ -4173,10 +4230,14 @@ "version": "0.17.18", "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.17.18.tgz", "integrity": "sha512-/x7leOyDPjZV3TcsdfrSI107zItVnsX1q2nho7hbbQoKnmoeUWjs+08rKKt4AUXju7+3aRZSsKrJtaRmsdL1xA==", - "cpu": ["riscv64"], + "cpu": [ + "riscv64" + ], "dev": true, "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">=12" } @@ -4185,10 +4246,14 @@ "version": "0.17.18", "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.17.18.tgz", "integrity": "sha512-cX0I8Q9xQkL/6F5zWdYmVf5JSQt+ZfZD2bJudZrWD+4mnUvoZ3TDDXtDX2mUaq6upMFv9FlfIh4Gfun0tbGzuw==", - "cpu": ["s390x"], + "cpu": [ + "s390x" + ], "dev": true, "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">=12" } @@ -4197,10 +4262,14 @@ "version": "0.17.18", "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.17.18.tgz", "integrity": "sha512-66RmRsPlYy4jFl0vG80GcNRdirx4nVWAzJmXkevgphP1qf4dsLQCpSKGM3DUQCojwU1hnepI63gNZdrr02wHUA==", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "dev": true, "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">=12" } @@ -4209,10 +4278,14 @@ "version": "0.17.18", "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.17.18.tgz", "integrity": "sha512-95IRY7mI2yrkLlTLb1gpDxdC5WLC5mZDi+kA9dmM5XAGxCME0F8i4bYH4jZreaJ6lIZ0B8hTrweqG1fUyW7jbg==", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "dev": true, "optional": true, - "os": ["netbsd"], + "os": [ + "netbsd" + ], "engines": { "node": ">=12" } @@ -4221,10 +4294,14 @@ "version": "0.17.18", "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.17.18.tgz", "integrity": "sha512-WevVOgcng+8hSZ4Q3BKL3n1xTv5H6Nb53cBrtzzEjDbbnOmucEVcZeGCsCOi9bAOcDYEeBZbD2SJNBxlfP3qiA==", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "dev": true, "optional": true, - "os": ["openbsd"], + "os": [ + "openbsd" + ], "engines": { "node": ">=12" } @@ -4233,10 +4310,14 @@ "version": "0.17.18", "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.17.18.tgz", "integrity": "sha512-Rzf4QfQagnwhQXVBS3BYUlxmEbcV7MY+BH5vfDZekU5eYpcffHSyjU8T0xucKVuOcdCsMo+Ur5wmgQJH2GfNrg==", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "dev": true, "optional": true, - "os": ["sunos"], + "os": [ + "sunos" + ], "engines": { "node": ">=12" } @@ -4245,10 +4326,14 @@ "version": "0.17.18", "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.17.18.tgz", "integrity": "sha512-Kb3Ko/KKaWhjeAm2YoT/cNZaHaD1Yk/pa3FTsmqo9uFh1D1Rfco7BBLIPdDOozrObj2sahslFuAQGvWbgWldAg==", - "cpu": ["arm64"], + "cpu": [ + "arm64" + ], "dev": true, "optional": true, - "os": ["win32"], + "os": [ + "win32" + ], "engines": { "node": ">=12" } @@ -4257,10 +4342,14 @@ "version": "0.17.18", "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.17.18.tgz", "integrity": "sha512-0/xUMIdkVHwkvxfbd5+lfG7mHOf2FRrxNbPiKWg9C4fFrB8H0guClmaM3BFiRUYrznVoyxTIyC/Ou2B7QQSwmw==", - "cpu": ["ia32"], + "cpu": [ + "ia32" + ], "dev": true, "optional": true, - "os": ["win32"], + "os": [ + "win32" + ], "engines": { "node": ">=12" } @@ -4269,10 +4358,14 @@ "version": "0.17.18", "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.17.18.tgz", "integrity": "sha512-qU25Ma1I3NqTSHJUOKi9sAH1/Mzuvlke0ioMJRthLXKm7JiSKVwFghlGbDLOO2sARECGhja4xYfRAZNPAkooYg==", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "dev": true, "optional": true, - "os": ["win32"], + "os": [ + "win32" + ], "engines": { "node": ">=12" } @@ -6705,10 +6798,14 @@ }, "node_modules/@nx/nx-darwin-x64": { "version": "16.3.2", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "dev": true, "optional": true, - "os": ["darwin"], + "os": [ + "darwin" + ], "engines": { "node": ">= 10" } @@ -8239,11 +8336,15 @@ }, "node_modules/@swc/core-darwin-x64": { "version": "1.3.66", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "dev": true, "license": "Apache-2.0 AND MIT", "optional": true, - "os": ["darwin"], + "os": [ + "darwin" + ], "engines": { "node": ">=10" } @@ -10245,7 +10346,9 @@ "node_modules/ansi-html-community": { "version": "0.0.8", "dev": true, - "engines": ["node >= 0.8.0"], + "engines": [ + "node >= 0.8.0" + ], "license": "Apache-2.0", "bin": { "ansi-html": "bin/ansi-html" @@ -11770,7 +11873,9 @@ "version": "3.2.0", "dev": true, "license": "MIT", - "workspaces": ["website"], + "workspaces": [ + "website" + ], "dependencies": { "typanion": "^3.8.0" }, @@ -14190,10 +14295,14 @@ "version": "0.17.19", "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.17.19.tgz", "integrity": "sha512-rIKddzqhmav7MSmoFCmDIb6e2W57geRsM94gV2l38fzhXMwq7hZoClug9USI2pFRGL06f4IOPHHpFNOkWieR8A==", - "cpu": ["arm"], + "cpu": [ + "arm" + ], "dev": true, "optional": true, - "os": ["android"], + "os": [ + "android" + ], "engines": { "node": ">=12" } @@ -14202,10 +14311,14 @@ "version": "0.17.19", "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.17.19.tgz", "integrity": "sha512-KBMWvEZooR7+kzY0BtbTQn0OAYY7CsiydT63pVEaPtVYF0hXbUaOyZog37DKxK7NF3XacBJOpYT4adIJh+avxA==", - "cpu": ["arm64"], + "cpu": [ + "arm64" + ], "dev": true, "optional": true, - "os": ["android"], + "os": [ + "android" + ], "engines": { "node": ">=12" } @@ -14214,10 +14327,14 @@ "version": "0.17.19", "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.17.19.tgz", "integrity": "sha512-uUTTc4xGNDT7YSArp/zbtmbhO0uEEK9/ETW29Wk1thYUJBz3IVnvgEiEwEa9IeLyvnpKrWK64Utw2bgUmDveww==", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "dev": true, "optional": true, - "os": ["android"], + "os": [ + "android" + ], "engines": { "node": ">=12" } @@ -14226,10 +14343,14 @@ "version": "0.17.19", "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.17.19.tgz", "integrity": "sha512-80wEoCfF/hFKM6WE1FyBHc9SfUblloAWx6FJkFWTWiCoht9Mc0ARGEM47e67W9rI09YoUxJL68WHfDRYEAvOhg==", - "cpu": ["arm64"], + "cpu": [ + "arm64" + ], "dev": true, "optional": true, - "os": ["darwin"], + "os": [ + "darwin" + ], "engines": { "node": ">=12" } @@ -14238,10 +14359,14 @@ "version": "0.17.19", "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.17.19.tgz", "integrity": "sha512-pBwbc7DufluUeGdjSU5Si+P3SoMF5DQ/F/UmTSb8HXO80ZEAJmrykPyzo1IfNbAoaqw48YRpv8shwd1NoI0jcQ==", - "cpu": ["arm64"], + "cpu": [ + "arm64" + ], "dev": true, "optional": true, - "os": ["freebsd"], + "os": [ + "freebsd" + ], "engines": { "node": ">=12" } @@ -14250,10 +14375,14 @@ "version": "0.17.19", "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.17.19.tgz", "integrity": "sha512-4lu+n8Wk0XlajEhbEffdy2xy53dpR06SlzvhGByyg36qJw6Kpfk7cp45DR/62aPH9mtJRmIyrXAS5UWBrJT6TQ==", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "dev": true, "optional": true, - "os": ["freebsd"], + "os": [ + "freebsd" + ], "engines": { "node": ">=12" } @@ -14262,10 +14391,14 @@ "version": "0.17.19", "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.17.19.tgz", "integrity": "sha512-cdmT3KxjlOQ/gZ2cjfrQOtmhG4HJs6hhvm3mWSRDPtZ/lP5oe8FWceS10JaSJC13GBd4eH/haHnqf7hhGNLerA==", - "cpu": ["arm"], + "cpu": [ + "arm" + ], "dev": true, "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">=12" } @@ -14274,10 +14407,14 @@ "version": "0.17.19", "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.17.19.tgz", "integrity": "sha512-ct1Tg3WGwd3P+oZYqic+YZF4snNl2bsnMKRkb3ozHmnM0dGWuxcPTTntAF6bOP0Sp4x0PjSF+4uHQ1xvxfRKqg==", - "cpu": ["arm64"], + "cpu": [ + "arm64" + ], "dev": true, "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">=12" } @@ -14286,10 +14423,14 @@ "version": "0.17.19", "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.17.19.tgz", "integrity": "sha512-w4IRhSy1VbsNxHRQpeGCHEmibqdTUx61Vc38APcsRbuVgK0OPEnQ0YD39Brymn96mOx48Y2laBQGqgZ0j9w6SQ==", - "cpu": ["ia32"], + "cpu": [ + "ia32" + ], "dev": true, "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">=12" } @@ -14298,10 +14439,14 @@ "version": "0.17.19", "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.17.19.tgz", "integrity": "sha512-2iAngUbBPMq439a+z//gE+9WBldoMp1s5GWsUSgqHLzLJ9WoZLZhpwWuym0u0u/4XmZ3gpHmzV84PonE+9IIdQ==", - "cpu": ["loong64"], + "cpu": [ + "loong64" + ], "dev": true, "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">=12" } @@ -14310,10 +14455,14 @@ "version": "0.17.19", "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.17.19.tgz", "integrity": "sha512-LKJltc4LVdMKHsrFe4MGNPp0hqDFA1Wpt3jE1gEyM3nKUvOiO//9PheZZHfYRfYl6AwdTH4aTcXSqBerX0ml4A==", - "cpu": ["mips64el"], + "cpu": [ + "mips64el" + ], "dev": true, "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">=12" } @@ -14322,10 +14471,14 @@ "version": "0.17.19", "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.17.19.tgz", "integrity": "sha512-/c/DGybs95WXNS8y3Ti/ytqETiW7EU44MEKuCAcpPto3YjQbyK3IQVKfF6nbghD7EcLUGl0NbiL5Rt5DMhn5tg==", - "cpu": ["ppc64"], + "cpu": [ + "ppc64" + ], "dev": true, "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">=12" } @@ -14334,10 +14487,14 @@ "version": "0.17.19", "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.17.19.tgz", "integrity": "sha512-FC3nUAWhvFoutlhAkgHf8f5HwFWUL6bYdvLc/TTuxKlvLi3+pPzdZiFKSWz/PF30TB1K19SuCxDTI5KcqASJqA==", - "cpu": ["riscv64"], + "cpu": [ + "riscv64" + ], "dev": true, "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">=12" } @@ -14346,10 +14503,14 @@ "version": "0.17.19", "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.17.19.tgz", "integrity": "sha512-IbFsFbxMWLuKEbH+7sTkKzL6NJmG2vRyy6K7JJo55w+8xDk7RElYn6xvXtDW8HCfoKBFK69f3pgBJSUSQPr+4Q==", - "cpu": ["s390x"], + "cpu": [ + "s390x" + ], "dev": true, "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">=12" } @@ -14358,10 +14519,14 @@ "version": "0.17.19", "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.17.19.tgz", "integrity": "sha512-68ngA9lg2H6zkZcyp22tsVt38mlhWde8l3eJLWkyLrp4HwMUr3c1s/M2t7+kHIhvMjglIBrFpncX1SzMckomGw==", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "dev": true, "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">=12" } @@ -14370,10 +14535,14 @@ "version": "0.17.19", "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.17.19.tgz", "integrity": "sha512-CwFq42rXCR8TYIjIfpXCbRX0rp1jo6cPIUPSaWwzbVI4aOfX96OXY8M6KNmtPcg7QjYeDmN+DD0Wp3LaBOLf4Q==", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "dev": true, "optional": true, - "os": ["netbsd"], + "os": [ + "netbsd" + ], "engines": { "node": ">=12" } @@ -14382,10 +14551,14 @@ "version": "0.17.19", "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.17.19.tgz", "integrity": "sha512-cnq5brJYrSZ2CF6c35eCmviIN3k3RczmHz8eYaVlNasVqsNY+JKohZU5MKmaOI+KkllCdzOKKdPs762VCPC20g==", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "dev": true, "optional": true, - "os": ["openbsd"], + "os": [ + "openbsd" + ], "engines": { "node": ">=12" } @@ -14394,10 +14567,14 @@ "version": "0.17.19", "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.17.19.tgz", "integrity": "sha512-vCRT7yP3zX+bKWFeP/zdS6SqdWB8OIpaRq/mbXQxTGHnIxspRtigpkUcDMlSCOejlHowLqII7K2JKevwyRP2rg==", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "dev": true, "optional": true, - "os": ["sunos"], + "os": [ + "sunos" + ], "engines": { "node": ">=12" } @@ -14406,10 +14583,14 @@ "version": "0.17.19", "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.17.19.tgz", "integrity": "sha512-yYx+8jwowUstVdorcMdNlzklLYhPxjniHWFKgRqH7IFlUEa0Umu3KuYplf1HUZZ422e3NU9F4LGb+4O0Kdcaag==", - "cpu": ["arm64"], + "cpu": [ + "arm64" + ], "dev": true, "optional": true, - "os": ["win32"], + "os": [ + "win32" + ], "engines": { "node": ">=12" } @@ -14418,10 +14599,14 @@ "version": "0.17.19", "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.17.19.tgz", "integrity": "sha512-eggDKanJszUtCdlVs0RB+h35wNlb5v4TWEkq4vZcmVt5u/HiDZrTXe2bWFQUez3RgNHwx/x4sk5++4NSSicKkw==", - "cpu": ["ia32"], + "cpu": [ + "ia32" + ], "dev": true, "optional": true, - "os": ["win32"], + "os": [ + "win32" + ], "engines": { "node": ">=12" } @@ -14430,10 +14615,14 @@ "version": "0.17.19", "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.17.19.tgz", "integrity": "sha512-lAhycmKnVOuRYNtRtatQR1LPQf2oYCkRGkSFnseDAKPl8lu5SOsK/e1sXe5a0Pc5kHIHe6P2I/ilntNv2xf3cA==", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "dev": true, "optional": true, - "os": ["win32"], + "os": [ + "win32" + ], "engines": { "node": ">=12" } @@ -15367,7 +15556,9 @@ "node_modules/extsprintf": { "version": "1.3.0", "dev": true, - "engines": ["node >=0.6.0"], + "engines": [ + "node >=0.6.0" + ], "license": "MIT" }, "node_modules/fast-deep-equal": { @@ -15984,7 +16175,9 @@ "dev": true, "license": "MIT", "optional": true, - "os": ["darwin"], + "os": [ + "darwin" + ], "engines": { "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } @@ -20227,7 +20420,9 @@ }, "node_modules/jsonparse": { "version": "1.3.1", - "engines": ["node >= 0.2.0"], + "engines": [ + "node >= 0.2.0" + ], "license": "MIT" }, "node_modules/JSONStream": { @@ -22772,7 +22967,9 @@ "hasInstallScript": true, "license": "MIT", "optional": true, - "os": ["!win32"], + "os": [ + "!win32" + ], "peer": true, "dependencies": { "node-addon-api": "^3.0.0", @@ -29770,10 +29967,14 @@ "version": "0.18.6", "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.18.6.tgz", "integrity": "sha512-J3lwhDSXBBppSzm/LC1uZ8yKSIpExc+5T8MxrYD9KNVZG81FOAu2VF2gXi/6A/LwDDQQ+b6DpQbYlo3VwxFepQ==", - "cpu": ["arm"], + "cpu": [ + "arm" + ], "dev": true, "optional": true, - "os": ["android"], + "os": [ + "android" + ], "engines": { "node": ">=12" } @@ -29782,10 +29983,14 @@ "version": "0.18.6", "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.18.6.tgz", "integrity": "sha512-pL0Ci8P9q1sWbtPx8CXbc8JvPvvYdJJQ+LO09PLFsbz3aYNdFBGWJjiHU+CaObO4Ames+GOFpXRAJZS2L3ZK/A==", - "cpu": ["arm64"], + "cpu": [ + "arm64" + ], "dev": true, "optional": true, - "os": ["android"], + "os": [ + "android" + ], "engines": { "node": ">=12" } @@ -29794,10 +29999,14 @@ "version": "0.18.6", "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.18.6.tgz", "integrity": "sha512-hE2vZxOlJ05aY28lUpB0y0RokngtZtcUB+TVl9vnLEnY0z/8BicSvrkThg5/iI1rbf8TwXrbr2heEjl9fLf+EA==", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "dev": true, "optional": true, - "os": ["android"], + "os": [ + "android" + ], "engines": { "node": ">=12" } @@ -29806,21 +30015,29 @@ "version": "0.18.6", "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.18.6.tgz", "integrity": "sha512-/tuyl4R+QhhoROQtuQj9E/yfJtZNdv2HKaHwYhhHGQDN1Teziem2Kh7BWQMumfiY7Lu9g5rO7scWdGE4OsQ6MQ==", - "cpu": ["arm64"], + "cpu": [ + "arm64" + ], "dev": true, "optional": true, - "os": ["darwin"], + "os": [ + "darwin" + ], "engines": { "node": ">=12" } }, "node_modules/tsup/node_modules/@esbuild/darwin-x64": { "version": "0.18.6", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "dev": true, "license": "MIT", "optional": true, - "os": ["darwin"], + "os": [ + "darwin" + ], "engines": { "node": ">=12" } @@ -29829,10 +30046,14 @@ "version": "0.18.6", "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.18.6.tgz", "integrity": "sha512-bq10jFv42V20Kk77NvmO+WEZaLHBKuXcvEowixnBOMkaBgS7kQaqTc77ZJDbsUpXU3KKNLQFZctfaeINmeTsZA==", - "cpu": ["arm64"], + "cpu": [ + "arm64" + ], "dev": true, "optional": true, - "os": ["freebsd"], + "os": [ + "freebsd" + ], "engines": { "node": ">=12" } @@ -29841,10 +30062,14 @@ "version": "0.18.6", "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.18.6.tgz", "integrity": "sha512-HbDLlkDZqUMBQaiday0pJzB6/8Xx/10dI3xRebJBReOEeDSeS+7GzTtW9h8ZnfB7/wBCqvtAjGtWQLTNPbR2+g==", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "dev": true, "optional": true, - "os": ["freebsd"], + "os": [ + "freebsd" + ], "engines": { "node": ">=12" } @@ -29853,10 +30078,14 @@ "version": "0.18.6", "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.18.6.tgz", "integrity": "sha512-C+5kb6rgsGMmvIdUI7v1PPgC98A6BMv233e97aXZ5AE03iMdlILFD/20HlHrOi0x2CzbspXn9HOnlE4/Ijn5Kw==", - "cpu": ["arm"], + "cpu": [ + "arm" + ], "dev": true, "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">=12" } @@ -29865,10 +30094,14 @@ "version": "0.18.6", "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.18.6.tgz", "integrity": "sha512-NMY9yg/88MskEZH2s4i6biz/3av+M8xY5ua4HE7CCz5DBz542cr7REe317+v7oKjnYBCijHpkzo5vU85bkXQmQ==", - "cpu": ["arm64"], + "cpu": [ + "arm64" + ], "dev": true, "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">=12" } @@ -29877,10 +30110,14 @@ "version": "0.18.6", "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.18.6.tgz", "integrity": "sha512-AXazA0ljvQEp7cA9jscABNXsjodKbEcqPcAE3rDzKN82Vb3lYOq6INd+HOCA7hk8IegEyHW4T72Z7QGIhyCQEA==", - "cpu": ["ia32"], + "cpu": [ + "ia32" + ], "dev": true, "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">=12" } @@ -29889,10 +30126,14 @@ "version": "0.18.6", "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.18.6.tgz", "integrity": "sha512-JjBf7TwY7ldcPgHYt9UcrjZB03+WZqg/jSwMAfzOzM5ZG+tu5umUqzy5ugH/crGI4eoDIhSOTDp1NL3Uo/05Fw==", - "cpu": ["loong64"], + "cpu": [ + "loong64" + ], "dev": true, "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">=12" } @@ -29901,10 +30142,14 @@ "version": "0.18.6", "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.18.6.tgz", "integrity": "sha512-kATNsslryVxcH1sO3KP2nnyUWtZZVkgyhAUnyTVVa0OQQ9pmDRjTpHaE+2EQHoCM5wt/uav2edrAUqbwn3tkKQ==", - "cpu": ["mips64el"], + "cpu": [ + "mips64el" + ], "dev": true, "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">=12" } @@ -29913,10 +30158,14 @@ "version": "0.18.6", "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.18.6.tgz", "integrity": "sha512-B+wTKz+8pi7mcWXFQV0LA79dJ+qhiut5uK9q0omoKnq8yRIwQJwfg3/vclXoqqcX89Ri5Y5538V0Se2v5qlcLA==", - "cpu": ["ppc64"], + "cpu": [ + "ppc64" + ], "dev": true, "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">=12" } @@ -29925,10 +30174,14 @@ "version": "0.18.6", "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.18.6.tgz", "integrity": "sha512-h44RBLVXFUSjvhOfseE+5UxQ/r9LVeqK2S8JziJKOm9W7SePYRPDyn7MhzhNCCFPkcjIy+soCxfhlJXHXXCR0A==", - "cpu": ["riscv64"], + "cpu": [ + "riscv64" + ], "dev": true, "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">=12" } @@ -29937,10 +30190,14 @@ "version": "0.18.6", "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.18.6.tgz", "integrity": "sha512-FlYpyr2Xc2AUePoAbc84NRV+mj7xpsISeQ36HGf9etrY5rTBEA+IU9HzWVmw5mDFtC62EQxzkLRj8h5Hq85yOQ==", - "cpu": ["s390x"], + "cpu": [ + "s390x" + ], "dev": true, "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">=12" } @@ -29949,10 +30206,14 @@ "version": "0.18.6", "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.18.6.tgz", "integrity": "sha512-Mc4EUSYwzLci77u0Kao6ajB2WbTe5fNc7+lHwS3a+vJISC/oprwURezUYu1SdWAYoczbsyOvKAJwuNftoAdjjg==", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "dev": true, "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">=12" } @@ -29961,10 +30222,14 @@ "version": "0.18.6", "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.18.6.tgz", "integrity": "sha512-3hgZlp7NqIM5lNG3fpdhBI5rUnPmdahraSmwAi+YX/bp7iZ7mpTv2NkypGs/XngdMtpzljICxnUG3uPfqLFd3w==", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "dev": true, "optional": true, - "os": ["netbsd"], + "os": [ + "netbsd" + ], "engines": { "node": ">=12" } @@ -29973,10 +30238,14 @@ "version": "0.18.6", "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.18.6.tgz", "integrity": "sha512-aEWTdZQHtSRROlDYn7ygB8yAqtnall/UnmoVIJVqccKitkAWVVSYocQUWrBOxLEFk8XdlRouVrLZe6WXszyviA==", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "dev": true, "optional": true, - "os": ["openbsd"], + "os": [ + "openbsd" + ], "engines": { "node": ">=12" } @@ -29985,10 +30254,14 @@ "version": "0.18.6", "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.18.6.tgz", "integrity": "sha512-uxk/5yAGpjKZUHOECtI9W+9IcLjKj+2m0qf+RG7f7eRBHr8wP6wsr3XbNbgtOD1qSpPapd6R2ZfSeXTkCcAo5g==", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "dev": true, "optional": true, - "os": ["sunos"], + "os": [ + "sunos" + ], "engines": { "node": ">=12" } @@ -29997,10 +30270,14 @@ "version": "0.18.6", "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.18.6.tgz", "integrity": "sha512-oXlXGS9zvNCGoAT/tLHAsFKrIKye1JaIIP0anCdpaI+Dc10ftaNZcqfLzEwyhdzFAYInXYH4V7kEdH4hPyo9GA==", - "cpu": ["arm64"], + "cpu": [ + "arm64" + ], "dev": true, "optional": true, - "os": ["win32"], + "os": [ + "win32" + ], "engines": { "node": ">=12" } @@ -30009,10 +30286,14 @@ "version": "0.18.6", "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.18.6.tgz", "integrity": "sha512-qh7IcAHUvvmMBmoIG+V+BbE9ZWSR0ohF51e5g8JZvU08kZF58uDFL5tHs0eoYz31H6Finv17te3W3QB042GqVA==", - "cpu": ["ia32"], + "cpu": [ + "ia32" + ], "dev": true, "optional": true, - "os": ["win32"], + "os": [ + "win32" + ], "engines": { "node": ">=12" } @@ -30021,10 +30302,14 @@ "version": "0.18.6", "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.18.6.tgz", "integrity": "sha512-9UDwkz7Wlm4N9jnv+4NL7F8vxLhSZfEkRArz2gD33HesAFfMLGIGNVXRoIHtWNw8feKsnGly9Hq1EUuRkWl0zA==", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "dev": true, "optional": true, - "os": ["win32"], + "os": [ + "win32" + ], "engines": { "node": ">=12" } @@ -30244,7 +30529,9 @@ "version": "3.12.1", "dev": true, "license": "MIT", - "workspaces": ["website"] + "workspaces": [ + "website" + ] }, "node_modules/type-check": { "version": "0.4.0", @@ -30959,7 +31246,9 @@ "node_modules/verror": { "version": "1.10.0", "dev": true, - "engines": ["node >=0.6.0"], + "engines": [ + "node >=0.6.0" + ], "license": "MIT", "dependencies": { "assert-plus": "^1.0.0", @@ -32176,7 +32465,7 @@ }, "packages/javascript-sdk": { "name": "@forgerock/javascript-sdk", - "version": "4.2.0", + "version": "4.3.0", "license": "MIT" }, "packages/token-vault": { @@ -32914,10 +33203,14 @@ "version": "0.17.18", "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.17.18.tgz", "integrity": "sha512-Qq84ykvLvya3dO49wVC9FFCNUfSrQJLbxhoQk/TE1r6MjHo3sFF2tlJCwMjhkBVq3/ahUisj7+EpRSz0/+8+9A==", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "dev": true, "optional": true, - "os": ["darwin"], + "os": [ + "darwin" + ], "engines": { "node": ">=12" } diff --git a/packages/javascript-sdk/src/fr-recovery-codes/index.ts b/packages/javascript-sdk/src/fr-recovery-codes/index.ts index 35366feb9..7b67ea8a5 100644 --- a/packages/javascript-sdk/src/fr-recovery-codes/index.ts +++ b/packages/javascript-sdk/src/fr-recovery-codes/index.ts @@ -11,7 +11,7 @@ import { CallbackType } from '../auth/enums'; import type TextOutputCallback from '../fr-auth/callbacks/text-output-callback'; import type FRStep from '../fr-auth/fr-step'; -import { parseDisplayRecoveryCodesText } from './script-parser'; +import { parseDeviceNameText, parseDisplayRecoveryCodesText } from './script-parser'; /** * Utility for handling recovery code nodes. @@ -28,6 +28,10 @@ import { parseDisplayRecoveryCodesText } from './script-parser'; * ``` */ abstract class FRRecoveryCodes { + public static getDeviceName(step: FRStep): string { + const text = this.getDisplayCallback(step)?.getOutputByName('message', '') ?? ''; + return parseDeviceNameText(text); + } /** * Retrieves the recovery codes by parsing the JavaScript message text in callback. * diff --git a/packages/javascript-sdk/src/fr-recovery-codes/recovery-codes.test.ts b/packages/javascript-sdk/src/fr-recovery-codes/recovery-codes.test.ts index d5892cbc3..ab59402be 100644 --- a/packages/javascript-sdk/src/fr-recovery-codes/recovery-codes.test.ts +++ b/packages/javascript-sdk/src/fr-recovery-codes/recovery-codes.test.ts @@ -12,6 +12,7 @@ import FRStep from '../fr-auth/fr-step'; import FRRecoveryCodes from './index'; import { displayRecoveryCodesResponse, + expectedDeviceName, expectedRecoveryCodes, otherResponse, } from './script-text.mock.data'; @@ -34,4 +35,9 @@ describe('Class for managing the Display Recovery Codes node', () => { const recoveryCodes = FRRecoveryCodes.getCodes(step); expect(recoveryCodes).toStrictEqual(expectedRecoveryCodes); }); + it('should return a display name from the getDisplayName method', () => { + const step = new FRStep(displayRecoveryCodesResponse); + const displayName = FRRecoveryCodes.getDeviceName(step); + expect(displayName).toStrictEqual(expectedDeviceName); + }); }); diff --git a/packages/javascript-sdk/src/fr-recovery-codes/script-parser.test.ts b/packages/javascript-sdk/src/fr-recovery-codes/script-parser.test.ts index d247af912..f3bcc5bac 100644 --- a/packages/javascript-sdk/src/fr-recovery-codes/script-parser.test.ts +++ b/packages/javascript-sdk/src/fr-recovery-codes/script-parser.test.ts @@ -8,12 +8,27 @@ * of the MIT license. See the LICENSE file for details. */ -import { parseDisplayRecoveryCodesText } from './script-parser'; -import { displayRecoveryCodes, expectedRecoveryCodes } from './script-text.mock.data'; +import { parseDeviceNameText, parseDisplayRecoveryCodesText } from './script-parser'; +import { + displayRecoveryCodes, + expectedRecoveryCodes, + securityKeyCustomNameResponse, + securityKeyResponse, +} from './script-text.mock.data'; describe('Parsing of the Display Recovery Codes script text', () => { it('should parse the Display Recovery Codes Text', () => { const result = parseDisplayRecoveryCodesText(displayRecoveryCodes); expect(result).toStrictEqual(expectedRecoveryCodes); }); + it('should parse the display name from recovery codes script', () => { + const text = securityKeyResponse; + const result = parseDeviceNameText(text); + expect(result).toStrictEqual('New Security Key'); + }); + it('should parse a custom name out of the recovery text', () => { + const text = securityKeyCustomNameResponse; + const result = parseDeviceNameText(text); + expect(result).toStrictEqual('My Custom Device Name'); + }); }); diff --git a/packages/javascript-sdk/src/fr-recovery-codes/script-parser.ts b/packages/javascript-sdk/src/fr-recovery-codes/script-parser.ts index 9d67635ad..92ef8fbd3 100644 --- a/packages/javascript-sdk/src/fr-recovery-codes/script-parser.ts +++ b/packages/javascript-sdk/src/fr-recovery-codes/script-parser.ts @@ -16,6 +16,7 @@ function parseDisplayRecoveryCodesText(text: string): string[] { * "\n" + * ... ` */ + const recoveryCodesMatches = text.match(/\s[\w\W]"([\w]*)\\/g); const recoveryCodes = Array.isArray(recoveryCodesMatches) && @@ -27,4 +28,24 @@ function parseDisplayRecoveryCodesText(text: string): string[] { return recoveryCodes || []; } -export { parseDisplayRecoveryCodesText }; +/** + * + * @param text + * @returns string + */ +function parseDeviceNameText(text: string): string { + /** + * We default the device name to 'New Security Key' + * If the user has a device name, it will be wrapped in tags + * e.g. ` ... My Security Key ... ` + * We want to remove the tags and just return the device name + * e.g. ` ... My Security Key ... ` + */ + const displayName = + text + ?.match(/\s*.*<\/em>/g)?.[0] + ?.replace('', '') + ?.replace('', '') ?? 'New Security Key'; + return displayName; +} +export { parseDeviceNameText, parseDisplayRecoveryCodesText }; diff --git a/packages/javascript-sdk/src/fr-recovery-codes/script-text.mock.data.ts b/packages/javascript-sdk/src/fr-recovery-codes/script-text.mock.data.ts index 28ecf0404..89b953020 100644 --- a/packages/javascript-sdk/src/fr-recovery-codes/script-text.mock.data.ts +++ b/packages/javascript-sdk/src/fr-recovery-codes/script-text.mock.data.ts @@ -75,6 +75,7 @@ const displayRecoveryCodesResponse = { }, ], }; +const expectedDeviceName = 'New Security Key'; const expectedRecoveryCodes = [ 'iZmEtxvQ00', @@ -106,4 +107,15 @@ const otherResponse = { ], }; -export { displayRecoveryCodes, displayRecoveryCodesResponse, expectedRecoveryCodes, otherResponse }; +const securityKeyResponse = `/* * Copyright 2018 ForgeRock AS. All Rights Reserved * * Use of this code requires a commercial software license with ForgeRock AS. * or with one of its affiliates. All use shall be exclusively subject * to such license between the licensee and ForgeRock AS. */ var newLocation = document.getElementById("wrapper"); var oldHtml = newLocation.getElementsByTagName("fieldset")[0].innerHTML; newLocation.getElementsByTagName("fieldset")[0].innerHTML = "
\n" + "
\n" + "

Your Recovery Codes

\n" + "

You must make a copy of these recovery codes. They cannot be displayed again.

\n" + "
\n" + "
\n" + "kw50qtmm32\n" + "
\n" + "
\n" + "Rt2Td8AK2s\n" + "
\n" + "
\n" + "6vZrIRCBJB\n" + "
\n" + "
\n" + "HCmL01Yiyv\n" + "
\n" + "
\n" + "BvDsSpazA2\n" + "
\n" + "
\n" + "T6pbKLyW2l\n" + "
\n" + "
\n" + "gZR0u6XubS\n" + "
\n" + "
\n" + "VZ1bH94IfO\n" + "
\n" + "
\n" + "O9BZ4bLefQ\n" + "
\n" + "
\n" + "NKNrBxlHCt\n" + "
\n" + "
\n" + "

Use one of these codes to authenticate if you lose your device, which has been named: New Security Key

\n" + "
\n" + "
" + oldHtml; document.body.appendChild(newLocation);`; +const securityKeyCustomNameResponse = `/* * Copyright 2018 ForgeRock AS. All Rights Reserved * * Use of this code requires a commercial software license with ForgeRock AS. * or with one of its affiliates. All use shall be exclusively subject * to such license between the licensee and ForgeRock AS. */ var newLocation = document.getElementById("wrapper"); var oldHtml = newLocation.getElementsByTagName("fieldset")[0].innerHTML; newLocation.getElementsByTagName("fieldset")[0].innerHTML = "
\n" + "
\n" + "

Your Recovery Codes

\n" + "

You must make a copy of these recovery codes. They cannot be displayed again.

\n" + "
\n" + "
\n" + "kw50qtmm32\n" + "
\n" + "
\n" + "Rt2Td8AK2s\n" + "
\n" + "
\n" + "6vZrIRCBJB\n" + "
\n" + "
\n" + "HCmL01Yiyv\n" + "
\n" + "
\n" + "BvDsSpazA2\n" + "
\n" + "
\n" + "T6pbKLyW2l\n" + "
\n" + "
\n" + "gZR0u6XubS\n" + "
\n" + "
\n" + "VZ1bH94IfO\n" + "
\n" + "
\n" + "O9BZ4bLefQ\n" + "
\n" + "
\n" + "NKNrBxlHCt\n" + "
\n" + "
\n" + "

Use one of these codes to authenticate if you lose your device, which has been named: My Custom Device Name

\n" + "
\n" + "
" + oldHtml; document.body.appendChild(newLocation);`; + +export { + displayRecoveryCodes, + displayRecoveryCodesResponse, + expectedDeviceName, + expectedRecoveryCodes, + otherResponse, + securityKeyCustomNameResponse, + securityKeyResponse, +}; diff --git a/plugins/wait-for-api/tsconfig.lib.json b/plugins/wait-for-api/tsconfig.lib.json index 33eca2c2c..cf94d8655 100644 --- a/plugins/wait-for-api/tsconfig.lib.json +++ b/plugins/wait-for-api/tsconfig.lib.json @@ -3,6 +3,7 @@ "compilerOptions": { "outDir": "../../dist/out-tsc", "declaration": true, + "skipLibCheck": true, "types": ["node"] }, "include": ["src/**/*.ts"],