This commit is contained in:
Damien Dudognon 2025-03-05 16:04:36 +00:00 committed by GitHub
commit bde1b5bf11
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 25 additions and 4 deletions

View file

@ -51,5 +51,26 @@ export class BitwardenApi implements ICredentialType {
},
},
},
{
displayName: 'Region',
name: 'region',
type: 'options',
default: 'bitwarden.com',
options: [
{
name: 'United States',
value: 'bitwarden.com',
},
{
name: 'European Union',
value: 'bitwarden.eu',
},
],
displayOptions: {
show: {
environment: ['cloudHosted'],
},
},
},
];
}

View file

@ -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, region } = await this.getCredentials('bitwardenApi');
return environment === 'cloudHosted'
? 'https://identity.bitwarden.com/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 } = await this.getCredentials('bitwardenApi');
const { environment, domain, region } = await this.getCredentials('bitwardenApi');
return environment === 'cloudHosted' ? 'https://api.bitwarden.com' : `${domain}/api`;
return environment === 'cloudHosted' ? `https://api.${region}` : `${domain}/api`;
}
/**