2024-03-28 02:15:58 -07:00
|
|
|
import type { SecretsHelpersBase } from 'n8n-workflow';
|
2023-08-25 01:33:46 -07:00
|
|
|
import { Service } from 'typedi';
|
2024-09-12 09:07:18 -07:00
|
|
|
|
2024-08-22 02:10:37 -07:00
|
|
|
import { ExternalSecretsManager } from './external-secrets/external-secrets-manager.ee';
|
2023-08-25 01:33:46 -07:00
|
|
|
|
|
|
|
@Service()
|
|
|
|
export class SecretsHelper implements SecretsHelpersBase {
|
|
|
|
constructor(private service: ExternalSecretsManager) {}
|
|
|
|
|
|
|
|
async update() {
|
|
|
|
if (!this.service.initialized) {
|
|
|
|
await this.service.init();
|
|
|
|
}
|
|
|
|
await this.service.updateSecrets();
|
|
|
|
}
|
|
|
|
|
|
|
|
async waitForInit() {
|
|
|
|
if (!this.service.initialized) {
|
|
|
|
await this.service.init();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-28 02:15:58 -07:00
|
|
|
getSecret(provider: string, name: string) {
|
2023-08-25 01:33:46 -07:00
|
|
|
return this.service.getSecret(provider, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
hasSecret(provider: string, name: string): boolean {
|
|
|
|
return this.service.hasSecret(provider, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
hasProvider(provider: string): boolean {
|
|
|
|
return this.service.hasProvider(provider);
|
|
|
|
}
|
|
|
|
|
|
|
|
listProviders(): string[] {
|
|
|
|
return this.service.getProviderNames() ?? [];
|
|
|
|
}
|
|
|
|
|
|
|
|
listSecrets(provider: string): string[] {
|
|
|
|
return this.service.getSecretNames(provider) ?? [];
|
|
|
|
}
|
|
|
|
}
|