mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
✨ Create scopes fetcher
This commit is contained in:
parent
94631f6fc2
commit
d70a5da262
|
@ -285,6 +285,33 @@ export class CredentialsHelper extends ICredentialsHelper {
|
||||||
return combineProperties;
|
return combineProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the scope of a credential type
|
||||||
|
*
|
||||||
|
* @param {string} type
|
||||||
|
* @returns {string[]}
|
||||||
|
* @memberof CredentialsHelper
|
||||||
|
*/
|
||||||
|
getScopes(type: string): string[] {
|
||||||
|
const scopeProperty = this.getCredentialsProperties(type).find(({ name }) => name === 'scope');
|
||||||
|
|
||||||
|
if (!scopeProperty?.default || typeof scopeProperty.default !== 'string') {
|
||||||
|
const errorMessage = `No \`scope\` property found for credential type: ${type}`;
|
||||||
|
|
||||||
|
Logger.error(errorMessage);
|
||||||
|
|
||||||
|
throw new Error(errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { default: scopeDefault } = scopeProperty;
|
||||||
|
|
||||||
|
if (/ /.test(scopeDefault)) return scopeDefault.split(' ');
|
||||||
|
|
||||||
|
if (/,/.test(scopeDefault)) return scopeDefault.split(',');
|
||||||
|
|
||||||
|
return [scopeDefault];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the decrypted credential data with applied overwrites
|
* Returns the decrypted credential data with applied overwrites
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue