remove debug and change sign delimiter

prod-hotfix
Thibault Duplessis 2021-01-28 20:36:57 +01:00
parent 7ef275d61d
commit a9cfaa1636
2 changed files with 4 additions and 7 deletions

View File

@ -48,10 +48,7 @@ export default class StormCtrl {
this.promotion = makePromotion(this.withGround, this.makeCgOpts, this.redraw);
this.checkDupTab();
setTimeout(this.hotkeys, 1000);
if (this.data.key) setTimeout(() => sign(this.data.key!).then(v => {
console.log(v, 'received');
this.vm.signed(v);
}), 1000 * 5);
if (this.data.key) setTimeout(() => sign(this.data.key!).then(this.vm.signed), 1000 * 40);
}
clockMillis = (): number | undefined =>

View File

@ -1,7 +1,6 @@
export default function(serverKey: string): Promise<string> {
const otp = randomAscii(64);
lichess.socket.send('sk1', `${serverKey}:${otp}`);
console.log(`${serverKey}:${otp}`, 'sent');
lichess.socket.send('sk1', `${serverKey}!${otp}`);
return new Promise(solve =>
lichess.pubsub.on('socket.in.sk1', encrypted => solve(xor(encrypted, otp)))
);
@ -16,6 +15,7 @@ function xor(a: string, b: string) {
function randomAscii(length: number) {
const result = [];
for (let i = 0; i < length; i++) result.push(String.fromCharCode(Math.floor(Math.random() * 128)));
// start after '!' which is used as delimiter
for (let i = 0; i < length; i++) result.push(String.fromCharCode(34 + Math.floor(Math.random() * 92)));
return result.join('');
}