From 51b55a4cd19f03dbc6bc2c0f331fa21c8efa2e26 Mon Sep 17 00:00:00 2001 From: Damien Dudognon Date: Tue, 18 Feb 2025 08:28:31 +0100 Subject: [PATCH 1/2] fix(bitwarden): support European Cloud-Hosted instances (#13315) --- .../credentials/BitwardenApi.credentials.ts | 21 +++++++++++++++++++ .../nodes/Bitwarden/GenericFunctions.ts | 8 +++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/packages/nodes-base/credentials/BitwardenApi.credentials.ts b/packages/nodes-base/credentials/BitwardenApi.credentials.ts index f63e00230d..a432200afe 100644 --- a/packages/nodes-base/credentials/BitwardenApi.credentials.ts +++ b/packages/nodes-base/credentials/BitwardenApi.credentials.ts @@ -51,5 +51,26 @@ export class BitwardenApi implements ICredentialType { }, }, }, + { + displayName: 'Server Geographies', + name: 'serverLocation', + type: 'options', + default: 'bitwarden.com', + options: [ + { + name: 'United States', + value: 'bitwarden.com', + }, + { + name: 'European Union', + value: 'bitwarden.eu', + }, + ], + displayOptions: { + show: { + environment: ['cloudHosted'], + }, + }, + }, ]; } diff --git a/packages/nodes-base/nodes/Bitwarden/GenericFunctions.ts b/packages/nodes-base/nodes/Bitwarden/GenericFunctions.ts index 0bb12eac99..1def986a0d 100644 --- a/packages/nodes-base/nodes/Bitwarden/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Bitwarden/GenericFunctions.ts @@ -13,10 +13,10 @@ import { NodeApiError } from 'n8n-workflow'; * Return the access token URL based on the user's environment. */ async function getTokenUrl(this: IExecuteFunctions | ILoadOptionsFunctions) { - const { environment, domain } = await this.getCredentials('bitwardenApi'); + const { environment, domain, serverLocation } = await this.getCredentials('bitwardenApi'); return environment === 'cloudHosted' - ? 'https://identity.bitwarden.com/connect/token' + ? `https://identity.${serverLocation}/connect/token` : `${domain}/identity/connect/token`; } @@ -24,9 +24,9 @@ async function getTokenUrl(this: IExecuteFunctions | ILoadOptionsFunctions) { * Return the base API URL based on the user's environment. */ async function getBaseUrl(this: IExecuteFunctions | ILoadOptionsFunctions) { - const { environment, domain } = await this.getCredentials('bitwardenApi'); + const { environment, domain, serverLocation } = await this.getCredentials('bitwardenApi'); - return environment === 'cloudHosted' ? 'https://api.bitwarden.com' : `${domain}/api`; + return environment === 'cloudHosted' ? `https://api.${serverLocation}` : `${domain}/api`; } /** From 61c6ce72c83af305040204f75f5403fd6245cd46 Mon Sep 17 00:00:00 2001 From: Damien Dudognon Date: Wed, 5 Mar 2025 11:15:45 +0100 Subject: [PATCH 2/2] refactor(bitwarden): rename server location --- .../nodes-base/credentials/BitwardenApi.credentials.ts | 4 ++-- packages/nodes-base/nodes/Bitwarden/GenericFunctions.ts | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/nodes-base/credentials/BitwardenApi.credentials.ts b/packages/nodes-base/credentials/BitwardenApi.credentials.ts index a432200afe..f511f10789 100644 --- a/packages/nodes-base/credentials/BitwardenApi.credentials.ts +++ b/packages/nodes-base/credentials/BitwardenApi.credentials.ts @@ -52,8 +52,8 @@ export class BitwardenApi implements ICredentialType { }, }, { - displayName: 'Server Geographies', - name: 'serverLocation', + displayName: 'Region', + name: 'region', type: 'options', default: 'bitwarden.com', options: [ diff --git a/packages/nodes-base/nodes/Bitwarden/GenericFunctions.ts b/packages/nodes-base/nodes/Bitwarden/GenericFunctions.ts index 1def986a0d..f6c5ebc1d9 100644 --- a/packages/nodes-base/nodes/Bitwarden/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Bitwarden/GenericFunctions.ts @@ -13,10 +13,10 @@ import { NodeApiError } from 'n8n-workflow'; * Return the access token URL based on the user's environment. */ async function getTokenUrl(this: IExecuteFunctions | ILoadOptionsFunctions) { - const { environment, domain, serverLocation } = await this.getCredentials('bitwardenApi'); + const { environment, domain, region } = await this.getCredentials('bitwardenApi'); return environment === 'cloudHosted' - ? `https://identity.${serverLocation}/connect/token` + ? `https://identity.${region}/connect/token` : `${domain}/identity/connect/token`; } @@ -24,9 +24,9 @@ async function getTokenUrl(this: IExecuteFunctions | ILoadOptionsFunctions) { * Return the base API URL based on the user's environment. */ async function getBaseUrl(this: IExecuteFunctions | ILoadOptionsFunctions) { - const { environment, domain, serverLocation } = await this.getCredentials('bitwardenApi'); + const { environment, domain, region } = await this.getCredentials('bitwardenApi'); - return environment === 'cloudHosted' ? `https://api.${serverLocation}` : `${domain}/api`; + return environment === 'cloudHosted' ? `https://api.${region}` : `${domain}/api`; } /**