|
1 | 1 | // Mirrors evolution-go/pkg/core/endpoint.go |
2 | | -// In release builds, set LICENSE_ENDPOINT_ENCODED + LICENSE_ENDPOINT_XOR_KEY (hex). |
3 | | -// In dev, the URL is reconstructed from a parts array — same technique as the Go version. |
| 2 | +// |
| 3 | +// The licensing URL is **build-time only** — it gets baked into the bundle by |
| 4 | +// tsup's `define` so the operator cannot point the running service at a |
| 5 | +// different licensing server via env vars. |
| 6 | +// |
| 7 | +// In release builds the Dockerfile passes: |
| 8 | +// LICENSE_ENDPOINT_ENCODED=<hex> (XOR-encoded URL) |
| 9 | +// LICENSE_ENDPOINT_XOR_KEY=<hex> (XOR key) |
| 10 | +// |
| 11 | +// Use `node tools/encode-url.js https://license.evolutionfoundation.com.br` |
| 12 | +// to generate the pair. |
| 13 | +// |
| 14 | +// In dev (vars empty), the URL is reconstructed from a parts array — same |
| 15 | +// technique as evolution-go. |
4 | 16 |
|
5 | | -const encodedEP = process.env.LICENSE_ENDPOINT_ENCODED ?? ''; |
6 | | -const xorKey = process.env.LICENSE_ENDPOINT_XOR_KEY ?? ''; |
| 17 | +// These two identifiers are replaced at bundle time by tsup `define`. |
| 18 | +// Do NOT inline them or read them from process.env — see tsup.config.ts. |
| 19 | +declare const __LICENSE_ENDPOINT_ENCODED__: string; |
| 20 | +declare const __LICENSE_ENDPOINT_XOR_KEY__: string; |
| 21 | + |
| 22 | +const encodedEP = |
| 23 | + typeof __LICENSE_ENDPOINT_ENCODED__ === 'string' ? __LICENSE_ENDPOINT_ENCODED__ : ''; |
| 24 | +const xorKey = |
| 25 | + typeof __LICENSE_ENDPOINT_XOR_KEY__ === 'string' ? __LICENSE_ENDPOINT_XOR_KEY__ : ''; |
7 | 26 |
|
8 | 27 | export function resolveEndpoint(): string { |
9 | 28 | if (encodedEP && xorKey) { |
|
0 commit comments