Some checks failed
CI/CD Pipeline / Solidity Contracts (push) Failing after 1m12s
CI/CD Pipeline / Security Scanning (push) Successful in 2m21s
CI/CD Pipeline / Lint and Format (push) Failing after 36s
CI/CD Pipeline / Terraform Validation (push) Failing after 22s
CI/CD Pipeline / Kubernetes Validation (push) Successful in 25s
HYBX OMNL TypeScript & anchor / token-aggregation build + reconcile artifact (push) Failing after 23s
Validation / validate-genesis (push) Successful in 26s
Validation / validate-terraform (push) Failing after 21s
Validation / validate-kubernetes (push) Failing after 9s
Validation / validate-smart-contracts (push) Failing after 8s
Validation / validate-security (push) Failing after 1m15s
Validation / validate-documentation (push) Failing after 15s
OMNL reconcile anchor / Run omnl:reconcile and upload artifacts (push) Failing after 26s
Verify Deployment / Verify Deployment (push) Failing after 56s
Add operator settlement terminal UI/API, swift-listener service, compliance idempotency gates, GRU reserve dashboards, and @dbis/integration-foundation for typed HYBX/ISO adapter contracts. Co-authored-by: Cursor <cursoragent@cursor.com>
67 lines
2.7 KiB
JavaScript
67 lines
2.7 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.loadHybxConfig = loadHybxConfig;
|
|
exports.validateHybxConfigForLocalTest = validateHybxConfigForLocalTest;
|
|
const PLACEHOLDER_PATTERNS = /^(placeholder|changeme|example|test|dummy|xxx*)$/i;
|
|
const PRODUCTION_URL_PATTERNS = /hybxfinance\.io|hybx\.(prod|production)/i;
|
|
function requireEnv(name, value) {
|
|
if (!value || value.trim() === '') {
|
|
throw new Error(`Missing required environment variable: ${name}`);
|
|
}
|
|
return value.trim();
|
|
}
|
|
function parseEnvironment(raw) {
|
|
const v = (raw ?? 'sandbox').toLowerCase();
|
|
if (v === 'sandbox' || v === 'staging' || v === 'production')
|
|
return v;
|
|
throw new Error(`Invalid HYBX_ENVIRONMENT: ${raw}`);
|
|
}
|
|
function loadHybxConfig(options = {}) {
|
|
const env = options.env ?? process.env;
|
|
const environment = parseEnvironment(env.HYBX_ENVIRONMENT);
|
|
const baseUrl = requireEnv('HYBX_BASE_URL', env.HYBX_BASE_URL);
|
|
if (options.testMode && PRODUCTION_URL_PATTERNS.test(baseUrl)) {
|
|
throw new Error('HYBX_BASE_URL appears production-like; use sandbox URL in test mode');
|
|
}
|
|
if (environment === 'production' && options.testMode) {
|
|
throw new Error('HYBX_ENVIRONMENT=production is not allowed in test mode');
|
|
}
|
|
const clientId = requireEnv('HYBX_CLIENT_ID', env.HYBX_CLIENT_ID);
|
|
const clientSecret = requireEnv('HYBX_CLIENT_SECRET', env.HYBX_CLIENT_SECRET);
|
|
const apiKey = requireEnv('HYBX_API_KEY', env.HYBX_API_KEY);
|
|
const webhookSecret = requireEnv('HYBX_WEBHOOK_SECRET', env.HYBX_WEBHOOK_SECRET);
|
|
for (const [key, val] of [
|
|
['HYBX_CLIENT_ID', clientId],
|
|
['HYBX_CLIENT_SECRET', clientSecret],
|
|
['HYBX_API_KEY', apiKey],
|
|
['HYBX_WEBHOOK_SECRET', webhookSecret],
|
|
]) {
|
|
if (!PLACEHOLDER_PATTERNS.test(val) && options.testMode && environment === 'sandbox') {
|
|
// Allow non-placeholder values in sandbox test mode but warn via validation helper
|
|
void key;
|
|
}
|
|
}
|
|
return {
|
|
environment,
|
|
baseUrl: baseUrl.replace(/\/$/, ''),
|
|
clientId,
|
|
clientSecret,
|
|
apiKey,
|
|
mtlsCertPath: env.HYBX_MTLS_CERT_PATH?.trim() || undefined,
|
|
mtlsKeyPath: env.HYBX_MTLS_KEY_PATH?.trim() || undefined,
|
|
webhookSecret,
|
|
requestTimeoutMs: Number(env.HYBX_REQUEST_TIMEOUT_MS ?? 30_000),
|
|
maxRetries: Number(env.HYBX_MAX_RETRIES ?? 3),
|
|
};
|
|
}
|
|
function validateHybxConfigForLocalTest(config) {
|
|
const warnings = [];
|
|
if (config.baseUrl.startsWith('http://')) {
|
|
warnings.push('HYBX_BASE_URL uses plain HTTP');
|
|
}
|
|
if (config.environment === 'production') {
|
|
warnings.push('HYBX_ENVIRONMENT is production');
|
|
}
|
|
return warnings;
|
|
}
|