From 16b84ebd8bd9883cb224be8a128483d4923ad1a6 Mon Sep 17 00:00:00 2001 From: CeciliaAvila Date: Wed, 27 Nov 2024 08:49:25 -0300 Subject: [PATCH 1/6] Use tsup to compile ESM-only filenamify package --- libraries/botbuilder/package.json | 6 +-- .../botbuilder/src/fileTranscriptStore.ts | 4 +- yarn.lock | 44 ++----------------- 3 files changed, 8 insertions(+), 46 deletions(-) diff --git a/libraries/botbuilder/package.json b/libraries/botbuilder/package.json index 18775a5582..9411662f94 100644 --- a/libraries/botbuilder/package.json +++ b/libraries/botbuilder/package.json @@ -40,7 +40,6 @@ "filenamify": "^6.0.0", "fs-extra": "^11.2.0", "htmlparser2": "^9.0.1", - "import-sync": "^2.2.2", "uuid": "^10.0.0", "zod": "^3.23.8" }, @@ -51,12 +50,13 @@ "node-mocks-http": "^1.16.0" }, "scripts": { - "build": "tsc -b", + "build": "yarn prebuild && tsc -b", "build-docs": "typedoc --theme markdown --entryPoint botbuilder --excludePrivate --includeDeclarations --ignoreCompilerErrors --module amd --out ..\\..\\doc\\botbuilder .\\lib\\index.d.ts ..\\botbuilder-core\\lib\\index.d.ts ..\\botframework-schema\\lib\\index.d.ts --hideGenerator --name \"Bot Builder SDK\" --readme none", "build:rollup": "yarn clean && yarn build && api-extractor run --verbose --local", - "clean": "rimraf _ts3.4 lib tsconfig.tsbuildinfo", + "clean": "rimraf _ts3.4 lib dist tsconfig.tsbuildinfo", "depcheck": "depcheck --config ../../.depcheckrc", "lint": "eslint .", + "prebuild": "tsup ../../node_modules/filenamify/*.js --format cjs --dts --out-dir dist/filenamify --clean --sourcemap", "postbuild": "downlevel-dts lib _ts3.4/lib --checksum", "test": "npm-run-all build test:mocha", "test:compat": "api-extractor run --verbose", diff --git a/libraries/botbuilder/src/fileTranscriptStore.ts b/libraries/botbuilder/src/fileTranscriptStore.ts index 7fc325d234..cc8106d2da 100644 --- a/libraries/botbuilder/src/fileTranscriptStore.ts +++ b/libraries/botbuilder/src/fileTranscriptStore.ts @@ -8,9 +8,7 @@ import { join, parse } from 'path'; import { mkdirp, pathExists, readdir, readFile, remove, writeFile } from 'fs-extra'; import { Activity, PagedResult, TranscriptInfo, TranscriptStore } from 'botbuilder-core'; -import importSync from 'import-sync'; - -const filenamify = importSync('filenamify').default; +import filenamify from '../dist/filenamify/index'; /** * @private diff --git a/yarn.lock b/yarn.lock index db4fd32504..1cf28bf893 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2800,11 +2800,6 @@ dependencies: is-negated-glob "^1.0.0" -"@httptoolkit/esm@^3.3.0": - version "3.3.0" - resolved "https://registry.yarnpkg.com/@httptoolkit/esm/-/esm-3.3.0.tgz#7eb6f2487c55c25c57b623c81ac64c3ec5097e09" - integrity sha512-gS+TH14750cveYP5p2q/oLyjVV5+qRFZMOpsPzK1KrgacqKc6RLDmt3ioGaMjsn1aianQbROkl4QXDJmO5swPA== - "@humanfs/core@^0.19.1": version "0.19.1" resolved "https://registry.yarnpkg.com/@humanfs/core/-/core-0.19.1.tgz#17c55ca7d426733fe3c561906b8173c336b40a77" @@ -9624,13 +9619,6 @@ import-meta-resolve@^3.0.0: resolved "https://registry.yarnpkg.com/import-meta-resolve/-/import-meta-resolve-3.1.1.tgz#75d194ae465d17c15736f414734310c87d4c45d7" integrity sha512-qeywsE/KC3w9Fd2ORrRDUw6nS/nLwZpXgfrOc2IILvZYnCaEMd+D56Vfg9k4G29gIeVi3XKql1RQatME8iYsiw== -import-sync@^2.2.2: - version "2.2.2" - resolved "https://registry.yarnpkg.com/import-sync/-/import-sync-2.2.2.tgz#c1bfc7b63b57ec12301426bc103a7846f93a7957" - integrity sha512-MQ+8aB1LZu0dHqTmpkOJ5DLCqQNVNqbMrH/S9nvHChUSMsAlX6R3ydQhX3R5/YfCU6+qU3cbASiX59hJisMKgg== - dependencies: - "@httptoolkit/esm" "^3.3.0" - imurmurhash@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" @@ -14409,16 +14397,8 @@ string-argv@~0.3.1: resolved "https://registry.yarnpkg.com/string-argv/-/string-argv-0.3.1.tgz#95e2fbec0427ae19184935f816d74aaa4c5c19da" integrity sha512-a1uQGz7IyVy9YwhqjZIZu1c8JO8dNIe20xBmSS6qu9kv++k3JGzCVmprbNN5Kn+BgzD5E7YYwg1CcjuJMRNsvg== -"string-width-cjs@npm:string-width@^4.2.0": - version "4.2.3" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" - integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" - -"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.0.0, string-width@^4.2.2, string-width@^4.2.3: +"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.0.0, string-width@^4.2.2, string-width@^4.2.3: + name string-width-cjs version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -14533,14 +14513,7 @@ stringify-entities@^4.0.0: character-entities-html4 "^2.0.0" character-entities-legacy "^3.0.0" -"strip-ansi-cjs@npm:strip-ansi@^6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" - integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== - dependencies: - ansi-regex "^5.0.1" - -strip-ansi@6.0.1, strip-ansi@^6.0.1: +"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@6.0.1, strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -15969,7 +15942,7 @@ workerpool@^6.5.1: resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.5.1.tgz#060f73b39d0caf97c6db64da004cd01b4c099544" integrity sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA== -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== @@ -15996,15 +15969,6 @@ wrap-ansi@^6.2.0: string-width "^4.1.0" strip-ansi "^6.0.0" -wrap-ansi@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" - integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - wrap-ansi@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214" From 628dde834a080ebd3c5229f5c6a7b07f09b6bec2 Mon Sep 17 00:00:00 2001 From: CeciliaAvila Date: Thu, 28 Nov 2024 10:25:06 -0300 Subject: [PATCH 2/6] Update yamls to include node 22 --- .github/workflows/depcheck.yml | 4 ++-- .github/workflows/lint.yml | 6 +++--- .github/workflows/test-compat.yml | 6 +++--- .github/workflows/test-consumer.yml | 6 +++--- .github/workflows/test-repoutils.yml | 6 +++--- .github/workflows/test-schemas.yml | 6 +++--- .github/workflows/tests.yml | 4 ++-- build/yaml/botbuilder-js-daily.yml | 2 +- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.github/workflows/depcheck.yml b/.github/workflows/depcheck.yml index b14e32bc8f..1ab4931686 100644 --- a/.github/workflows/depcheck.yml +++ b/.github/workflows/depcheck.yml @@ -21,10 +21,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: use node 20.x + - name: use node 22.x uses: actions/setup-node@v2-beta with: - node-version: 20.x + node-version: 22.x - name: yarn cache dir id: yarn-cache-dir diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 11c8564e67..80604516ba 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -21,10 +21,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: use node 20.x + - name: use node 22.x uses: actions/setup-node@v2-beta with: - node-version: 20.x + node-version: 22.x - name: yarn cache dir id: yarn-cache-dir @@ -33,7 +33,7 @@ jobs: - uses: actions/cache@v2 with: path: ${{ steps.yarn-cache-dir.outputs.dir }} - key: ${{ runner.os }}-node20.x-yarn-${{ hashFiles('**/yarn.lock') }} + key: ${{ runner.os }}-node22.x-yarn-${{ hashFiles('**/yarn.lock') }} - name: yarn run: yarn --frozen-lockfile diff --git a/.github/workflows/test-compat.yml b/.github/workflows/test-compat.yml index 704d92a21e..6db8ccbc01 100644 --- a/.github/workflows/test-compat.yml +++ b/.github/workflows/test-compat.yml @@ -21,10 +21,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: use node 20.x + - name: use node 22.x uses: actions/setup-node@v2-beta with: - node-version: 20.x + node-version: 22.x - name: yarn cache dir id: yarn-cache-dir @@ -33,7 +33,7 @@ jobs: - uses: actions/cache@v2 with: path: ${{ steps.yarn-cache-dir.outputs.dir }} - key: ${{ runner.os }}-node20.x-yarn-${{ hashFiles('**/yarn.lock') }} + key: ${{ runner.os }}-node22.x-yarn-${{ hashFiles('**/yarn.lock') }} - name: yarn run: yarn --frozen-lockfile diff --git a/.github/workflows/test-consumer.yml b/.github/workflows/test-consumer.yml index d20072b2b4..45091af3a7 100644 --- a/.github/workflows/test-consumer.yml +++ b/.github/workflows/test-consumer.yml @@ -21,10 +21,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: use node 20.x + - name: use node 22.x uses: actions/setup-node@v2-beta with: - node-version: 20.x + node-version: 22.x - name: yarn cache dir id: yarn-cache-dir @@ -33,7 +33,7 @@ jobs: - uses: actions/cache@v2 with: path: ${{ steps.yarn-cache-dir.outputs.dir }} - key: ${{ runner.os }}-node20.x-yarn-${{ hashFiles('**/yarn.lock') }} + key: ${{ runner.os }}-node22.x-yarn-${{ hashFiles('**/yarn.lock') }} - name: yarn run: yarn --frozen-lockfile diff --git a/.github/workflows/test-repoutils.yml b/.github/workflows/test-repoutils.yml index fd907e8133..c958ac69fb 100644 --- a/.github/workflows/test-repoutils.yml +++ b/.github/workflows/test-repoutils.yml @@ -21,10 +21,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: use node 20.x + - name: use node 22.x uses: actions/setup-node@v2-beta with: - node-version: 20.x + node-version: 22.x - name: yarn cache dir id: yarn-cache-dir @@ -33,7 +33,7 @@ jobs: - uses: actions/cache@v2 with: path: ${{ steps.yarn-cache-dir.outputs.dir }} - key: ${{ runner.os }}-node20.x-yarn-${{ hashFiles('**/yarn.lock') }} + key: ${{ runner.os }}-node22.x-yarn-${{ hashFiles('**/yarn.lock') }} - name: yarn run: yarn --frozen-lockfile diff --git a/.github/workflows/test-schemas.yml b/.github/workflows/test-schemas.yml index 44389cdffa..69e9359a97 100644 --- a/.github/workflows/test-schemas.yml +++ b/.github/workflows/test-schemas.yml @@ -21,10 +21,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: use node 20.x + - name: use node 22.x uses: actions/setup-node@v2-beta with: - node-version: 20.x + node-version: 22.x - name: yarn cache dir id: yarn-cache-dir @@ -33,7 +33,7 @@ jobs: - uses: actions/cache@v2 with: path: ${{ steps.yarn-cache-dir.outputs.dir }} - key: ${{ runner.os }}-node20.x-yarn-${{ hashFiles('**/yarn.lock') }} + key: ${{ runner.os }}-node22.x-yarn-${{ hashFiles('**/yarn.lock') }} - name: npm install @microsoft/botframework-cli@next --global run: npm install @microsoft/botframework-cli@next --global diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ff70187ff1..94a21d62fc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -21,7 +21,7 @@ jobs: strategy: matrix: os: [ubuntu, windows] - node-version: [18.x, 20.x] + node-version: [18.x, 20.x, 22.x] steps: - uses: actions/checkout@v2 @@ -50,7 +50,7 @@ jobs: run: yarn test:github - name: coveralls - if: matrix.node-version == '20.x' + if: matrix.node-version == '22.x' uses: coverallsapp/github-action@v1.1.2 with: github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/build/yaml/botbuilder-js-daily.yml b/build/yaml/botbuilder-js-daily.yml index fd7f6648c8..5a3cccb4df 100644 --- a/build/yaml/botbuilder-js-daily.yml +++ b/build/yaml/botbuilder-js-daily.yml @@ -6,7 +6,7 @@ pool: vmImage: 'ubuntu-latest' variables: - NodeVersion: 20.x + NodeVersion: 22.x Packaging.EnableSBOMSigning: true YARN_CACHE_FOLDER: $(Pipeline.Workspace)/.yarn # SDK_JS_org_registry_Url: define this in Azure From f361b1607a7a61b7e9acb892f2ff29fd1ae38d0e Mon Sep 17 00:00:00 2001 From: CeciliaAvila Date: Thu, 28 Nov 2024 14:58:23 -0300 Subject: [PATCH 3/6] Throw error on crypto.createDecipher for node 22 --- .../src/botConfiguration.ts | 5 +- libraries/botframework-config/src/encrypt.ts | 29 +++++++++-- .../tests/loadAndSave.test.js | 51 ++++++++++++------- 3 files changed, 61 insertions(+), 24 deletions(-) diff --git a/libraries/botframework-config/src/botConfiguration.ts b/libraries/botframework-config/src/botConfiguration.ts index 94fa77452a..a39ee7fad5 100644 --- a/libraries/botframework-config/src/botConfiguration.ts +++ b/libraries/botframework-config/src/botConfiguration.ts @@ -304,7 +304,10 @@ export class BotConfiguration extends BotConfigurationBase { } } } - } catch { + } catch (legacyErr) { + if (legacyErr.message.includes('Node.js versions')) { + throw legacyErr; + } throw err; } } diff --git a/libraries/botframework-config/src/encrypt.ts b/libraries/botframework-config/src/encrypt.ts index 52a0686ddd..73e9b06fdf 100644 --- a/libraries/botframework-config/src/encrypt.ts +++ b/libraries/botframework-config/src/encrypt.ts @@ -6,6 +6,7 @@ */ import crypto from 'crypto'; +import { version as nodeVersion } from 'process'; /** * @private @@ -100,10 +101,28 @@ export function decryptString(encryptedValue: string, secret: string): string { * @param secret */ export function legacyDecrypt(encryptedValue: string, secret: string): string { - // LEGACY for pre standardized SHA256 encryption, this uses some undocumented nodejs MD5 hash internally and is deprecated - const decipher: crypto.Decipher = crypto.createDecipher('aes192', secret); - let value: string = decipher.update(encryptedValue, 'hex', 'utf8'); - value += decipher.final('utf8'); + const UNSUPPORTED_VERSION = '22.0.0'; + if (!isNodeCompatible(nodeVersion, UNSUPPORTED_VERSION)) { + throw new Error(`This method is not available for Node.js versions over ${UNSUPPORTED_VERSION}.`); + } else { + // LEGACY for pre standardized SHA256 encryption, this uses some undocumented nodejs MD5 hash internally and is deprecated + const decipher: crypto.Decipher = crypto.createDecipher('aes192', secret); + let value: string = decipher.update(encryptedValue, 'hex', 'utf8'); + value += decipher.final('utf8'); + + return value; + } +} - return value; +/** + * private + * + * @param currentVersion The current version of Node.js. + * @param minVersion The minimum unsupported version. + * @returns true if the current version of Node is lower than the unsupported version. + */ +function isNodeCompatible(currentVersion: string, minVersion: string): boolean { + const [currentMajor] = currentVersion.replace('v', '').split('.').map(Number); + const [minMajor] = minVersion.split('.').map(Number); + return currentMajor < minMajor; } diff --git a/libraries/botframework-config/tests/loadAndSave.test.js b/libraries/botframework-config/tests/loadAndSave.test.js index 11c887e27e..16080c4dc9 100644 --- a/libraries/botframework-config/tests/loadAndSave.test.js +++ b/libraries/botframework-config/tests/loadAndSave.test.js @@ -8,6 +8,7 @@ const testBotPath = require.resolve('./test.bot'); const govTestBotPath = require.resolve('./govTest.bot'); const legacyBotPath = require.resolve('./legacy.bot'); const saveBotPath = testBotPath.replace('test.bot', 'save.bot'); +const [nodeVersion] = process.version.replace('v', '').split('.').map(Number); describe('LoadAndSaveTests', function () { it('DeserializeBotFile', async function () { @@ -89,12 +90,19 @@ describe('LoadAndSaveTests', function () { const config = await bf.BotConfiguration.load(testBotPath); await config.saveAs(saveBotPath, secret); - await assert.rejects( - bf.BotConfiguration.load(saveBotPath), - new Error( - 'You are attempting to perform an operation which needs access to the secret and --secret is missing' - ) - ); + if (nodeVersion >= 22) { + await assert.rejects( + bf.BotConfiguration.load(saveBotPath), + new Error('This method is not available for Node.js versions over 22.0.0.'), + ); + } else { + await assert.rejects( + bf.BotConfiguration.load(saveBotPath), + new Error( + 'You are attempting to perform an operation which needs access to the secret and --secret is missing' + ), + ); + } }); it('LoadAndVerifyChannelServiceSync', async function () { @@ -354,17 +362,24 @@ describe('LoadAndSaveTests', function () { }); it('LegacyEncryption', async function () { - let config = await bf.BotConfiguration.load(legacyBotPath, 'password'); - assert.equal(config.services[0].appPassword, 'xyzpdq', 'value should be unencrypted'); - assert.ok(config.padlock != null, 'padlock should exist'); - assert.ok(!config.secretKey, 'secretKey should not exist'); - - const secret = bf.BotConfiguration.generateKey(); - await config.saveAs(saveBotPath, secret); - config = await bf.BotConfiguration.load(saveBotPath, secret); - fs.unlinkSync(saveBotPath); - assert.ok(config.padlock != null, 'padlock should exist'); - assert.ok(config.padlock.length > 0, 'padlock should not be empty'); - assert.ok(!config.secretKey, 'secretKey should not exist'); + if (nodeVersion >= 22) { + await assert.rejects( + bf.BotConfiguration.load(legacyBotPath, 'password'), + new Error('This method is not available for Node.js versions over 22.0.0.'), + ); + } else { + let config = await bf.BotConfiguration.load(legacyBotPath, 'password'); + assert.equal(config.services[0].appPassword, 'xyzpdq', 'value should be unencrypted'); + assert.ok(config.padlock != null, 'padlock should exist'); + assert.ok(!config.secretKey, 'secretKey should not exist'); + + const secret = bf.BotConfiguration.generateKey(); + await config.saveAs(saveBotPath, secret); + config = await bf.BotConfiguration.load(saveBotPath, secret); + fs.unlinkSync(saveBotPath); + assert.ok(config.padlock != null, 'padlock should exist'); + assert.ok(config.padlock.length > 0, 'padlock should not be empty'); + assert.ok(!config.secretKey, 'secretKey should not exist'); + } }); }); From 55479c7c64bf857fdc84a90725bfa182f37a8e85 Mon Sep 17 00:00:00 2001 From: CeciliaAvila Date: Thu, 28 Nov 2024 17:12:54 -0300 Subject: [PATCH 4/6] Add NODE_NO_WARNINGS flag to bf dialogs:merge exec --- .../botbuilder-dialogs-declarative/tests/schemaMergeTest.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/botbuilder-dialogs-declarative/tests/schemaMergeTest.js b/libraries/botbuilder-dialogs-declarative/tests/schemaMergeTest.js index c5c7afb560..cc858cae7b 100644 --- a/libraries/botbuilder-dialogs-declarative/tests/schemaMergeTest.js +++ b/libraries/botbuilder-dialogs-declarative/tests/schemaMergeTest.js @@ -14,7 +14,7 @@ async function runCommand(command, envObject) { // We need to combine our process.env with envObject so, // 1) We can use existing env vars (like from CI), and // 2) npx doesn't like to install without the existing APPDATA windows env var. - const env = { ...process.env, ...envObject }; + const env = { ...process.env, ...envObject, NODE_NO_WARNINGS: 1 }; const { stdout, stderr } = await exec(command, { env }); if (stderr) { From 7a271745b11a87190a04a9f85c0e16518dcf4d22 Mon Sep 17 00:00:00 2001 From: CeciliaAvila Date: Tue, 3 Dec 2024 10:45:44 -0300 Subject: [PATCH 5/6] Apply feedback --- .github/workflows/depcheck.yml | 2 +- libraries/botbuilder/package.json | 11 ++++++----- libraries/botbuilder/src/fileTranscriptStore.ts | 2 +- libraries/botframework-config/src/encrypt.ts | 6 ++---- .../botframework-config/tests/loadAndSave.test.js | 10 +++++----- package.json | 6 ++++-- 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/.github/workflows/depcheck.yml b/.github/workflows/depcheck.yml index 1ab4931686..f500606830 100644 --- a/.github/workflows/depcheck.yml +++ b/.github/workflows/depcheck.yml @@ -33,7 +33,7 @@ jobs: - uses: actions/cache@v2 with: path: ${{ steps.yarn-cache-dir.outputs.dir }} - key: ${{ runner.os }}-node20.x-yarn-${{ hashFiles('**/yarn.lock') }} + key: ${{ runner.os }}-node22.x-yarn-${{ hashFiles('**/yarn.lock') }} - name: yarn run: yarn --frozen-lockfile diff --git a/libraries/botbuilder/package.json b/libraries/botbuilder/package.json index 9411662f94..7d3bf49cfa 100644 --- a/libraries/botbuilder/package.json +++ b/libraries/botbuilder/package.json @@ -50,13 +50,13 @@ "node-mocks-http": "^1.16.0" }, "scripts": { - "build": "yarn prebuild && tsc -b", + "build": "tsc -b", "build-docs": "typedoc --theme markdown --entryPoint botbuilder --excludePrivate --includeDeclarations --ignoreCompilerErrors --module amd --out ..\\..\\doc\\botbuilder .\\lib\\index.d.ts ..\\botbuilder-core\\lib\\index.d.ts ..\\botframework-schema\\lib\\index.d.ts --hideGenerator --name \"Bot Builder SDK\" --readme none", "build:rollup": "yarn clean && yarn build && api-extractor run --verbose --local", - "clean": "rimraf _ts3.4 lib dist tsconfig.tsbuildinfo", + "clean": "rimraf _ts3.4 lib vendors tsconfig.tsbuildinfo", "depcheck": "depcheck --config ../../.depcheckrc", "lint": "eslint .", - "prebuild": "tsup ../../node_modules/filenamify/*.js --format cjs --dts --out-dir dist/filenamify --clean --sourcemap", + "prebuild": "tsup ./node_modules/filenamify/*.js --format cjs --dts --out-dir vendors/filenamify --clean --sourcemap", "postbuild": "downlevel-dts lib _ts3.4/lib --checksum", "test": "npm-run-all build test:mocha", "test:compat": "api-extractor run --verbose", @@ -70,6 +70,7 @@ "files": [ "_ts3.4", "lib", - "src" + "src", + "vendors" ] -} +} \ No newline at end of file diff --git a/libraries/botbuilder/src/fileTranscriptStore.ts b/libraries/botbuilder/src/fileTranscriptStore.ts index cc8106d2da..f57a8de62f 100644 --- a/libraries/botbuilder/src/fileTranscriptStore.ts +++ b/libraries/botbuilder/src/fileTranscriptStore.ts @@ -8,7 +8,7 @@ import { join, parse } from 'path'; import { mkdirp, pathExists, readdir, readFile, remove, writeFile } from 'fs-extra'; import { Activity, PagedResult, TranscriptInfo, TranscriptStore } from 'botbuilder-core'; -import filenamify from '../dist/filenamify/index'; +import filenamify from '../vendors/filenamify/index'; /** * @private diff --git a/libraries/botframework-config/src/encrypt.ts b/libraries/botframework-config/src/encrypt.ts index 73e9b06fdf..332d4cc8f1 100644 --- a/libraries/botframework-config/src/encrypt.ts +++ b/libraries/botframework-config/src/encrypt.ts @@ -101,7 +101,7 @@ export function decryptString(encryptedValue: string, secret: string): string { * @param secret */ export function legacyDecrypt(encryptedValue: string, secret: string): string { - const UNSUPPORTED_VERSION = '22.0.0'; + const UNSUPPORTED_VERSION = 'v22.0.0'; if (!isNodeCompatible(nodeVersion, UNSUPPORTED_VERSION)) { throw new Error(`This method is not available for Node.js versions over ${UNSUPPORTED_VERSION}.`); } else { @@ -122,7 +122,5 @@ export function legacyDecrypt(encryptedValue: string, secret: string): string { * @returns true if the current version of Node is lower than the unsupported version. */ function isNodeCompatible(currentVersion: string, minVersion: string): boolean { - const [currentMajor] = currentVersion.replace('v', '').split('.').map(Number); - const [minMajor] = minVersion.split('.').map(Number); - return currentMajor < minMajor; + return minVersion.localeCompare(currentVersion) > 0; } diff --git a/libraries/botframework-config/tests/loadAndSave.test.js b/libraries/botframework-config/tests/loadAndSave.test.js index 16080c4dc9..6ee274fdc2 100644 --- a/libraries/botframework-config/tests/loadAndSave.test.js +++ b/libraries/botframework-config/tests/loadAndSave.test.js @@ -8,7 +8,7 @@ const testBotPath = require.resolve('./test.bot'); const govTestBotPath = require.resolve('./govTest.bot'); const legacyBotPath = require.resolve('./legacy.bot'); const saveBotPath = testBotPath.replace('test.bot', 'save.bot'); -const [nodeVersion] = process.version.replace('v', '').split('.').map(Number); +const UNSUPPORTED_VERSION = 'v22.0.0'; describe('LoadAndSaveTests', function () { it('DeserializeBotFile', async function () { @@ -90,10 +90,10 @@ describe('LoadAndSaveTests', function () { const config = await bf.BotConfiguration.load(testBotPath); await config.saveAs(saveBotPath, secret); - if (nodeVersion >= 22) { + if (UNSUPPORTED_VERSION.localeCompare(process.version) < 1) { await assert.rejects( bf.BotConfiguration.load(saveBotPath), - new Error('This method is not available for Node.js versions over 22.0.0.'), + new Error(`This method is not available for Node.js versions over ${UNSUPPORTED_VERSION}.`), ); } else { await assert.rejects( @@ -362,10 +362,10 @@ describe('LoadAndSaveTests', function () { }); it('LegacyEncryption', async function () { - if (nodeVersion >= 22) { + if (!(UNSUPPORTED_VERSION.localeCompare(process.version) > 0)) { await assert.rejects( bf.BotConfiguration.load(legacyBotPath, 'password'), - new Error('This method is not available for Node.js versions over 22.0.0.'), + new Error(`This method is not available for Node.js versions over ${UNSUPPORTED_VERSION}.`), ); } else { let config = await bf.BotConfiguration.load(legacyBotPath, 'password'); diff --git a/package.json b/package.json index 8748f779d4..af9a04f6af 100644 --- a/package.json +++ b/package.json @@ -13,10 +13,12 @@ "generators/generator-botbuilder/generators/app/templates/*" ], "nohoist": [ - "**/@types/selenium-webdriver" + "**/@types/selenium-webdriver", + "botbuilder/filenamify" ], "nohoistComments": { - "**/@types/selenium-webdriver": "This package is excluded from the root @types folder as it requires ES2015+, whereas some BotBuilder libraries support ES5+." + "**/@types/selenium-webdriver": "This package is excluded from the root @types folder as it requires ES2015+, whereas some BotBuilder libraries support ES5+.", + "botbuilder/filenamify": "This package is excluded because it's compiled as CJS by tsup as it's ESM-only." } }, "scripts": { From 5f37415148107e7de588facc91c22847e4a67ca5 Mon Sep 17 00:00:00 2001 From: CeciliaAvila Date: Tue, 3 Dec 2024 10:49:20 -0300 Subject: [PATCH 6/6] Update unit tests --- libraries/botframework-config/tests/loadAndSave.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/botframework-config/tests/loadAndSave.test.js b/libraries/botframework-config/tests/loadAndSave.test.js index 6ee274fdc2..d7d83ffa66 100644 --- a/libraries/botframework-config/tests/loadAndSave.test.js +++ b/libraries/botframework-config/tests/loadAndSave.test.js @@ -362,7 +362,7 @@ describe('LoadAndSaveTests', function () { }); it('LegacyEncryption', async function () { - if (!(UNSUPPORTED_VERSION.localeCompare(process.version) > 0)) { + if (UNSUPPORTED_VERSION.localeCompare(process.version) < 1) { await assert.rejects( bf.BotConfiguration.load(legacyBotPath, 'password'), new Error(`This method is not available for Node.js versions over ${UNSUPPORTED_VERSION}.`),