refactor(server): license key env (#13162)

This commit is contained in:
Jason Rasmussen 2024-10-03 15:45:37 -04:00 committed by GitHub
parent 2c8c3651de
commit 3ddb5b8733
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 37 additions and 41 deletions

View file

@ -1,6 +1,5 @@
import { BadRequestException, Injectable, NotFoundException } from '@nestjs/common';
import { DateTime } from 'luxon';
import { getClientLicensePublicKey, getServerLicensePublicKey } from 'src/config';
import { SALT_ROUNDS } from 'src/constants';
import { StorageCore } from 'src/cores/storage.core';
import { AuthDto } from 'src/dtos/auth.dto';
@ -133,16 +132,18 @@ export class UserService extends BaseService {
throw new BadRequestException('Invalid license key');
}
const { licensePublicKey } = this.configRepository.getEnv();
const clientLicenseValid = this.cryptoRepository.verifySha256(
license.licenseKey,
license.activationKey,
getClientLicensePublicKey(),
licensePublicKey.client,
);
const serverLicenseValid = this.cryptoRepository.verifySha256(
license.licenseKey,
license.activationKey,
getServerLicensePublicKey(),
licensePublicKey.server,
);
if (!clientLicenseValid && !serverLicenseValid) {