Skip to content

Add optional secret to websocket communication#99

Open
dafenix wants to merge 2 commits intoliriliri:masterfrom
dafenix:feature/addSecretToWsCommunication
Open

Add optional secret to websocket communication#99
dafenix wants to merge 2 commits intoliriliri:masterfrom
dafenix:feature/addSecretToWsCommunication

Conversation

@dafenix
Copy link

@dafenix dafenix commented Aug 29, 2025

This change allows you to specify a secret that is checked when establishing a WebSocket connection. With this change, a client can only establish a connection if it specifies the correct secret. If no secret is specified, the application behaves as before.

How to test.

  • Start server npm run build && bin/chii.js start --secrets 333,444
  • Connect to it

With valid secret:

(function () {
 var script = document.createElement('script');
 script.type = 'text/javascript';
 script.src = 'http://localhost:8080/target.js'; 
 script.setAttribute('secret', '333');
 document.getElementsByTagName('head')[0].appendChild(script);
})();

(function () {
 var script = document.createElement('script');
 script.type = 'text/javascript';
 script.src = 'http://localhost:8080/target.js'; 
 script.setAttribute('secret', '444');
 document.getElementsByTagName('head')[0].appendChild(script);
})();

With invalid secret:

(function () {
 var script = document.createElement('script');
 script.type = 'text/javascript';
 script.src = 'http://localhost:8080/target.js'; 
 script.setAttribute('secret', '999');
 document.getElementsByTagName('head')[0].appendChild(script);
})();

With no secret:

(function () {
 var script = document.createElement('script');
 script.type = 'text/javascript';
 script.src = 'http://localhost:8080/target.js'; 
 document.getElementsByTagName('head')[0].appendChild(script);
})();

@dafenix
Copy link
Author

dafenix commented Feb 18, 2026

@surunzi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant