From 997def94e27ba7dd932d9d7895509ad943581b05 Mon Sep 17 00:00:00 2001 From: Arthur Schreiber Date: Sat, 9 Jul 2022 07:00:59 +0000 Subject: [PATCH 1/4] chore!: drop support for Node.js 12 --- .github/workflows/nodejs.yml | 16 ++++++++-------- .github/workflows/release.yml | 6 +++--- appveyor.yml | 1 - package.json | 4 ++-- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 34085a3e8..89b6a8a54 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -16,10 +16,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - - name: Use Node.js 12 + - name: Use Node.js 14 uses: actions/setup-node@v1 with: - node-version: 12 + node-version: 14 - name: Determine npm cache directory id: npm-cache @@ -63,7 +63,7 @@ jobs: strategy: matrix: - node-version: [12.x, 14.x, 16.x, 18.x] + node-version: [14.x, 16.x, 18.x] fail-fast: false services: @@ -175,7 +175,7 @@ jobs: token: ${{ secrets.CODECOV_TOKEN }} azure: - name: Azure SQL Server / Node.js 12.x + name: Azure SQL Server / Node.js 14.x runs-on: ubuntu-latest # Only run these tests if we have access to the secrets @@ -183,10 +183,10 @@ jobs: steps: - uses: actions/checkout@v1 - - name: Use Node.js 12 + - name: Use Node.js 14 uses: actions/setup-node@v1 with: - node-version: 12 + node-version: 14 - name: Determine npm cache directory id: npm-cache @@ -292,10 +292,10 @@ jobs: steps: - uses: actions/checkout@v1 - - name: Use Node.js 12 + - name: Use Node.js 14 uses: actions/setup-node@v1 with: - node-version: 12 + node-version: 14 - name: Determine npm cache directory id: npm-cache diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3a63561e1..a561321d4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,15 +10,15 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - - name: Use Node.js 12 + - name: Use Node.js 14 uses: actions/setup-node@v1 with: - node-version: 12 + node-version: 14 - name: Tag latest release run: | echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc - + read next latest <<< $(npm info tedious --json | jq -r '."dist-tags".next, ."dist-tags".latest') if [ "$(printf '%s\n' "$latest" "$next" | sort -V | tail -n 1)" != "$latest" ]; then date_format="%Y-%m-%dT%H:%M:%SZ" diff --git a/appveyor.yml b/appveyor.yml index e7c4af978..96d9b6d53 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,7 +2,6 @@ version: "{build}" environment: matrix: - - nodejs_version: "12" - nodejs_version: "14" - nodejs_version: "16" - nodejs_version: "18" diff --git a/package.json b/package.json index 779c20af2..f68841538 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "url": "https://github.com/tediousjs/tedious.git" }, "engines": { - "node": ">=12.3.0" + "node": ">=14" }, "publishConfig": { "tag": "next" @@ -109,7 +109,7 @@ "@babel/preset-env", { "targets": { - "node": 12 + "node": 14 } } ], From f5461023684a145018a735f6d8dadc94e442017b Mon Sep 17 00:00:00 2001 From: Arthur Schreiber Date: Sun, 10 Jul 2022 15:15:53 +0000 Subject: [PATCH 2/4] feat!: change default value for `trustServerCertificate` option to `false` --- src/connection.ts | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/connection.ts b/src/connection.ts index 2412e5de5..5ebf05a69 100644 --- a/src/connection.ts +++ b/src/connection.ts @@ -49,15 +49,6 @@ import { version } from '../package.json'; import { URL } from 'url'; import { AttentionTokenHandler, InitialSqlTokenHandler, Login7TokenHandler, RequestTokenHandler, TokenHandler } from './token/handler'; -let trustServerWarningEmitted = false; - -const emitTrustServerCertificateWarning = () => { - if (!trustServerWarningEmitted) { - trustServerWarningEmitted = true; - process.emitWarning('`config.options.trustServerCertificate` will default to false in the future. To silence this message, specify a value explicitly in the config options'); - } -}; - let domainRenameToTenantIdWarningEmitted = false; const emitDomainRenameToTenantIdWarning = () => { if (!domainRenameToTenantIdWarningEmitted) { @@ -1290,7 +1281,7 @@ class Connection extends EventEmitter { tdsVersion: DEFAULT_TDS_VERSION, textsize: DEFAULT_TEXTSIZE, trustedServerNameAE: undefined, - trustServerCertificate: true, + trustServerCertificate: false, useColumnNames: false, useUTC: true, workstationId: undefined, @@ -1675,8 +1666,6 @@ class Connection extends EventEmitter { } this.config.options.trustServerCertificate = config.options.trustServerCertificate; - } else { - emitTrustServerCertificateWarning(); } if (config.options.useColumnNames !== undefined) { From 438986efed524e18118eb31de0b0fa7f6f5b3d93 Mon Sep 17 00:00:00 2001 From: Arthur Schreiber Date: Sun, 10 Jul 2022 15:17:17 +0000 Subject: [PATCH 3/4] feat: remove default value for `clientId` option of `azure-active-directory-password` authentication BREAKING CHANGE: Using the `azure-active-directory-password` authentication type now requires specifying the `clientId` option of an Azure Application. The application has to have public client flows enabled and has to have `user_impersonation` permissions for Azure SQL Database. The user account that is being used also has to be assigned to the application, and has to grant consent (either explicitly or via admin consent). --- .github/workflows/nodejs.yml | 1 + src/connection.ts | 28 +++++----------------------- 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 89b6a8a54..7f5eec74e 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -238,6 +238,7 @@ jobs: "authentication": { "type": "azure-active-directory-password", "options": { + "clientId": "${{ secrets.AZURE_AD_SP_CLIENT_ID }}", "domain": "${{ secrets.AZURE_AD_TENANT_ID }}", "userName": "${{ secrets.AZURE_AD_USERNAME }}", "password": "${{ secrets.AZURE_AD_PASSWORD }}" diff --git a/src/connection.ts b/src/connection.ts index 5ebf05a69..e1dbe4a4c 100644 --- a/src/connection.ts +++ b/src/connection.ts @@ -1103,6 +1103,10 @@ class Connection extends EventEmitter { } }; } else if (type === 'azure-active-directory-password') { + if (typeof options.clientId !== 'string') { + throw new TypeError('The "config.authentication.options.clientId" property must be of type string.'); + } + if (options.userName !== undefined && typeof options.userName !== 'string') { throw new TypeError('The "config.authentication.options.userName" property must be of type string.'); } @@ -1111,12 +1115,6 @@ class Connection extends EventEmitter { throw new TypeError('The "config.authentication.options.password" property must be of type string.'); } - if (options.clientId !== undefined && typeof options.clientId !== 'string') { - throw new TypeError('The "config.authentication.options.clientId" property must be of type string.'); - } else if (options.clientId === undefined) { - emitAzureADPasswordClientIdDeprecationWarning(); - } - if (options.domain !== undefined && typeof options.domain !== 'string') { throw new TypeError('The "config.authentication.options.domain" property must be of type string.'); } else if (options.domain !== undefined) { @@ -1133,7 +1131,7 @@ class Connection extends EventEmitter { userName: options.userName, password: options.password, tenantId: options.tenantId ?? options.domain, - clientId: options.clientId ?? '7f98cb04-cd1e-40df-9140-3bf7e2cea4db' + clientId: options.clientId } }; } else if (type === 'azure-active-directory-access-token') { @@ -3127,22 +3125,6 @@ class Connection extends EventEmitter { } } -let azureADPasswordClientIdDeprecationWarningEmitted = false; -function emitAzureADPasswordClientIdDeprecationWarning() { - if (azureADPasswordClientIdDeprecationWarningEmitted) { - return; - } - - azureADPasswordClientIdDeprecationWarningEmitted = true; - - process.emitWarning( - 'When using the `azure-active-directory-password` authentication method, please provide a value for the `clientId` option. ' + - 'This option will be required in a future release.', - 'DeprecationWarning', - Connection.prototype.on - ); -} - function isTransientError(error: AggregateError | ConnectionError): boolean { if (error instanceof AggregateError) { error = error.errors[0]; From a6dc9fa4eaaa2097e036cbce7e2cdfd4011095a2 Mon Sep 17 00:00:00 2001 From: Arthur Schreiber Date: Sun, 10 Jul 2022 22:20:16 +0000 Subject: [PATCH 4/4] feat: remove `domain` option for `azure-active-directory-password` authentication BREAKING CHANGE: The `domain` option was replaced by the `tenantId` option. --- .github/workflows/nodejs.yml | 2 +- src/connection.ts | 18 +----------------- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 7f5eec74e..6cbef0214 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -239,7 +239,7 @@ jobs: "type": "azure-active-directory-password", "options": { "clientId": "${{ secrets.AZURE_AD_SP_CLIENT_ID }}", - "domain": "${{ secrets.AZURE_AD_TENANT_ID }}", + "tenantId": "${{ secrets.AZURE_AD_TENANT_ID }}", "userName": "${{ secrets.AZURE_AD_USERNAME }}", "password": "${{ secrets.AZURE_AD_PASSWORD }}" } diff --git a/src/connection.ts b/src/connection.ts index e1dbe4a4c..0b25f9e21 100644 --- a/src/connection.ts +++ b/src/connection.ts @@ -49,16 +49,6 @@ import { version } from '../package.json'; import { URL } from 'url'; import { AttentionTokenHandler, InitialSqlTokenHandler, Login7TokenHandler, RequestTokenHandler, TokenHandler } from './token/handler'; -let domainRenameToTenantIdWarningEmitted = false; -const emitDomainRenameToTenantIdWarning = () => { - if (!domainRenameToTenantIdWarningEmitted) { - domainRenameToTenantIdWarningEmitted = true; - process.emitWarning('`When using authentication type `azure-active-directory-password`,' + - ' config.authentication.options.domain` will be renamed to config.authentications.options.tenantId`' + - ' in the future. Rename `domain` to `tenantId` to silence this message.'); - } -}; - type BeginTransactionCallback = /** * The callback is called when the request to start the transaction has completed, @@ -1115,12 +1105,6 @@ class Connection extends EventEmitter { throw new TypeError('The "config.authentication.options.password" property must be of type string.'); } - if (options.domain !== undefined && typeof options.domain !== 'string') { - throw new TypeError('The "config.authentication.options.domain" property must be of type string.'); - } else if (options.domain !== undefined) { - emitDomainRenameToTenantIdWarning(); - } - if (options.tenantId !== undefined && typeof options.tenantId !== 'string') { throw new TypeError('The "config.authentication.options.tenantId" property must be of type string.'); } @@ -1130,7 +1114,7 @@ class Connection extends EventEmitter { options: { userName: options.userName, password: options.password, - tenantId: options.tenantId ?? options.domain, + tenantId: options.tenantId, clientId: options.clientId } };