Configure analytics URL and obfuscate API key
Set the Horchposten backend URL in the shell data attribute and replace the plaintext key lookup with XOR-encoded byte arrays decoded at runtime, so the API key never appears as a readable string in source, HTML, or the compiled WASM binary.
This commit is contained in:
@@ -21,15 +21,20 @@ EM_JS(void, js_analytics_init, (), {
|
||||
Module._analyticsStartPending = null; /* Promise while start is in-flight */
|
||||
Module._analyticsLastStats = null; /* stashed for beforeunload fallback */
|
||||
|
||||
/* Runtime config: check for data attributes on the canvas container
|
||||
* first, then fall back to compiled-in defaults. */
|
||||
/* Runtime config: URL from data attribute, key decoded at runtime.
|
||||
* The key is XOR-encoded across two byte arrays so it never appears
|
||||
* as a plain string in the WASM binary, emitted JS, or HTML. */
|
||||
var container = document.getElementById('canvas-container');
|
||||
Module._analyticsUrl = (container && container.dataset.analyticsUrl)
|
||||
? container.dataset.analyticsUrl
|
||||
: (typeof ANALYTICS_URL !== 'undefined' ? ANALYTICS_URL : '');
|
||||
Module._analyticsKey = (container && container.dataset.analyticsKey)
|
||||
? container.dataset.analyticsKey
|
||||
: (typeof ANALYTICS_KEY !== 'undefined' ? ANALYTICS_KEY : '');
|
||||
var _a = [53,75,96,19,114,122,112,34,28,62,24,5,57,34,126,14,
|
||||
112,73,105,121,122,79,50,0,77,33,82,58,61,19,44,0];
|
||||
var _b = [82,15,4,95,36,32,29,18,95,14,87,95,115,70,12,76,
|
||||
55,5,4,12,28,30,65,78,4,72,26,92,84,90,70,54];
|
||||
var _k = '';
|
||||
for (var i = 0; i < _a.length; i++) _k += String.fromCharCode(_a[i] ^ _b[i]);
|
||||
Module._analyticsKey = _k;
|
||||
|
||||
if (!Module._analyticsUrl) {
|
||||
console.log('[analytics] No analytics URL configured — analytics disabled');
|
||||
|
||||
@@ -108,8 +108,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<div id="canvas-container"
|
||||
data-analytics-url=""
|
||||
data-analytics-key="">
|
||||
data-analytics-url="https://horchposten.schick-web.site">
|
||||
<canvas class="emscripten" id="canvas" tabindex="1"
|
||||
width="640" height="360"></canvas>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user