Skip to content

Commit

Permalink
test/browser/connection: fix hmac extraction
Browse files Browse the repository at this point in the history
Relax the connectionKey hmac extraction and account for
the possibilities of multiple - characters.

RAR-655
  • Loading branch information
Zariel committed Jan 7, 2025
1 parent 1d6483a commit 1c3d568
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions test/browser/connection.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,12 @@ define(['shared_helper', 'chai'], function (Helper, chai) {
// strip instanceID and handleID from connectionKey */
function connectionHmac(key) {
/* connectionKey has the form <instanceID>!<hmac>-<handleID> */

/* remove the handleID from the end of key */
let k = key.split('-')[0];

/* skip the server instanceID if present, as reconnects may be routed to different frontends */
if (k.includes('!')) {
k = k.split('!')[1];
let end = key.lastIndexOf('-');
if (end < 0) {
end = key.length;
}
return k;
let start = key.indexOf('!');
return key.substring(start+1, end);
}

/* uses internal realtime knowledge of the format of the connection key to
Expand Down

0 comments on commit 1c3d568

Please sign in to comment.