mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-15 09:35:37 +00:00
Refactor EE secret versioning/snapshot access
This commit is contained in:
@@ -1,22 +1,19 @@
|
||||
import { LICENSE_KEY } from '../../config';
|
||||
|
||||
/**
|
||||
* Class to handle Enterprise Edition license actions
|
||||
*/
|
||||
class EELicenseService {
|
||||
/**
|
||||
* Check if license key [licenseKey] corresponds to a
|
||||
* valid Infisical Enterprise Edition license.
|
||||
* @param {Object} obj
|
||||
* @param {Object} obj.licenseKey
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
static async checkLicense({
|
||||
licenseKey
|
||||
}: {
|
||||
licenseKey: string;
|
||||
}) {
|
||||
// TODO
|
||||
return true;
|
||||
|
||||
private readonly _isLicenseValid: boolean;
|
||||
|
||||
constructor(licenseKey: string) {
|
||||
this._isLicenseValid = true;
|
||||
}
|
||||
|
||||
public get isLicenseValid(): boolean {
|
||||
return this._isLicenseValid;
|
||||
}
|
||||
}
|
||||
|
||||
export default EELicenseService;
|
||||
export default new EELicenseService(LICENSE_KEY);
|
||||
@@ -1,4 +1,8 @@
|
||||
import { takeSecretSnapshotHelper } from '../helpers/secret';
|
||||
import { ISecretVersion } from '../models';
|
||||
import {
|
||||
takeSecretSnapshotHelper,
|
||||
addSecretVersionsHelper
|
||||
} from '../helpers/secret';
|
||||
import EELicenseService from './EELicenseService';
|
||||
|
||||
/**
|
||||
@@ -21,9 +25,25 @@ class EESecretService {
|
||||
licenseKey: string;
|
||||
workspaceId: string;
|
||||
}) {
|
||||
EELicenseService.checkLicense({ licenseKey });
|
||||
if (!EELicenseService.isLicenseValid) return;
|
||||
await takeSecretSnapshotHelper({ workspaceId });
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds secret versions [secretVersions] to the SecretVersion collection.
|
||||
* @param {Object} obj
|
||||
* @param {SecretVersion} obj.secretVersions
|
||||
*/
|
||||
static async addSecretVersions({
|
||||
secretVersions
|
||||
}: {
|
||||
secretVersions: ISecretVersion[];
|
||||
}) {
|
||||
if (!EELicenseService.isLicenseValid) return;
|
||||
await addSecretVersionsHelper({
|
||||
secretVersions
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default EESecretService;
|
||||
Reference in New Issue
Block a user