refactor(server): decrypt license with provided aes key (#12570)

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Added support for a new AES key for license management, improving license encryption and decryption processes.

- **Bug Fixes**
  - Improved error messages and handling when activating expired or invalid licenses.

- **Refactor**
  - Updated license decryption logic to use a fixed AES key instead of deriving one from the workspace ID.
  - Added validation for environment variable values to prevent invalid configurations.

- **Tests**
  - Enhanced license-related tests to cover new key usage and updated error messages.
  - Updated environment variable validation tests with clearer error messages.

- **Chores**
  - Updated environment variable handling for improved consistency.
  - Set production environment variable explicitly in build configuration.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
forehalo
2025-05-27 11:54:28 +00:00
parent 7175019a0a
commit dc7cd0487b
13 changed files with 74 additions and 19 deletions
+9 -1
View File
@@ -76,7 +76,7 @@ globalThis.readEnv = function readEnv<T>(
};
export class Env implements AppEnv {
NODE_ENV = readEnv('NODE_ENV', NodeEnv.Production, Object.values(NodeEnv));
NODE_ENV = (process.env.NODE_ENV ?? NodeEnv.Production) as NodeEnv;
NAMESPACE = readEnv(
'AFFINE_ENV',
Namespace.Production,
@@ -134,6 +134,14 @@ export class Env implements AppEnv {
get gcp() {
return this.platform === Platform.GCP;
}
constructor() {
if (!Object.values(NodeEnv).includes(this.NODE_ENV)) {
throw new Error(
`Invalid NODE_ENV environment. \`${this.NODE_ENV}\` is not a valid NODE_ENV value.`
);
}
}
}
export const createGlobalEnv = () => {