Skip to content

Commit 06f65e9

Browse files
committed
style(licensing): apply prettier/eslint autofix and hoist DOCS_URL
The autofix from the pre-push hook reorders imports, normalizes line breaks and reformats the constructor signature. Also moves DOCS_URL to the top of the module so the auto-detect error path can reference it without hitting the temporal dead zone.
1 parent 8651138 commit 06f65e9

5 files changed

Lines changed: 42 additions & 13 deletions

File tree

src/licensing/endpoint.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,29 @@ export function resolveEndpoint(): string {
1010
return decodeXOR(encodedEP, xorKey);
1111
}
1212
// Dev fallback — assembled at runtime, not a single string literal.
13-
const parts = ['h', 'tt', 'ps', '://', 'li', 'ce', 'nse', '.', 'ev', 'ol', 'ut', 'io', 'nf', 'ou', 'nd', 'at', 'io', 'n.', 'co', 'm.', 'br'];
13+
const parts = [
14+
'h',
15+
'tt',
16+
'ps',
17+
'://',
18+
'li',
19+
'ce',
20+
'nse',
21+
'.',
22+
'ev',
23+
'ol',
24+
'ut',
25+
'io',
26+
'nf',
27+
'ou',
28+
'nd',
29+
'at',
30+
'io',
31+
'n.',
32+
'co',
33+
'm.',
34+
'br',
35+
];
1436
return parts.join('');
1537
}
1638

src/licensing/integrity.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,8 @@ export function computeSessionSeed(instanceName: string, rc: RuntimeContext): Bu
2424

2525
export function deriveInstanceToken(instanceID: string, rc: RuntimeContext): string {
2626
if (!rc || !rc.isActive()) return '';
27-
return createHash('sha256').update(instanceID + rc.apiKey).digest('hex').slice(0, 16);
27+
return createHash('sha256')
28+
.update(instanceID + rc.apiKey)
29+
.digest('hex')
30+
.slice(0, 16);
2831
}

src/licensing/runtime.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { postSigned, postUnsigned, readErrorMessage } from './transport';
2020
const logger = new Logger('Licensing');
2121

2222
const HEARTBEAT_INTERVAL_MS = 30 * 60 * 1000; // 30 minutes — same as Go.
23+
const DOCS_URL = 'https://docs.evolutionfoundation.com.br/licensing';
2324

2425
interface InitializeOptions {
2526
tier?: string;
@@ -44,7 +45,11 @@ export class RuntimeContext {
4445
private msgSent = 0;
4546
private msgRecv = 0;
4647

47-
constructor(public readonly globalApiKey: string, tier: string, version: string) {
48+
constructor(
49+
public readonly globalApiKey: string,
50+
tier: string,
51+
version: string,
52+
) {
4853
this.tier = tier;
4954
this.version = version;
5055
}
@@ -62,7 +67,9 @@ export class RuntimeContext {
6267
}
6368

6469
recomputeContextHash(): void {
65-
this.ctxHash = createHash('sha256').update(this.apiKey + this.instanceId).digest();
70+
this.ctxHash = createHash('sha256')
71+
.update(this.apiKey + this.instanceId)
72+
.digest();
6673
}
6774

6875
trackMessageSent(): void {
@@ -184,8 +191,6 @@ export async function initializeRuntime(opts: InitializeOptions = {}): Promise<R
184191
return rc;
185192
}
186193

187-
const DOCS_URL = 'https://docs.evolutionfoundation.com.br/licensing';
188-
189194
function printRegistrationBanner(rc?: RuntimeContext): void {
190195
logger.warn('╔══════════════════════════════════════════════════════════╗');
191196
logger.warn('║ License Registration Required ║');
@@ -213,7 +218,9 @@ export function validateContext(rc: RuntimeContext | null): [boolean, string] {
213218
if (!rc) return [false, ''];
214219
if (!rc.isActive()) return [false, rc.registerUrl];
215220
// Verify hash integrity.
216-
const expected = createHash('sha256').update(rc.apiKey + rc.instanceId).digest();
221+
const expected = createHash('sha256')
222+
.update(rc.apiKey + rc.instanceId)
223+
.digest();
217224
const actual = rc.contextHash();
218225
if (!expected.equals(actual)) return [false, ''];
219226
return [true, ''];

src/licensing/transport.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ export async function postSigned<T = unknown>(
2828
});
2929
}
3030

31-
export async function postUnsigned<T = unknown>(
32-
path: string,
33-
payload: unknown,
34-
): Promise<AxiosResponse<T>> {
31+
export async function postUnsigned<T = unknown>(path: string, payload: unknown): Promise<AxiosResponse<T>> {
3532
return httpClient.post<T>(resolveEndpoint() + path, payload, {
3633
headers: { 'Content-Type': 'application/json' },
3734
});

src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ import {
1616
Sentry as SentryConfig,
1717
Webhook,
1818
} from '@config/env.config';
19-
import { gateMiddleware, initializeRuntime, shutdown, startHeartbeat } from '@licensing/runtime';
20-
import { setDB } from '@licensing/store';
2119
import { onUnexpectedError } from '@config/error.config';
2220
import { Logger } from '@config/logger.config';
2321
import { ROOT_DIR } from '@config/path.config';
22+
import { gateMiddleware, initializeRuntime, shutdown, startHeartbeat } from '@licensing/runtime';
23+
import { setDB } from '@licensing/store';
2424
import * as Sentry from '@sentry/node';
2525
import { ServerUP } from '@utils/server-up';
2626
import axios from 'axios';

0 commit comments

Comments
 (0)