fix(irc): urlencode SSEKey for SSE streams (#990)

apply RFC4648 to base64 sseKey to fix urlEncoding
This commit is contained in:
Fabricio Silva 2023-06-17 13:44:20 +01:00 committed by GitHub
parent ecc84f5f2d
commit 8721ab65ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View file

@ -654,5 +654,5 @@ func (s *service) removeSSEStream(networkId int64, channel string) {
} }
func genSSEKey(networkId int64, channel string) string { func genSSEKey(networkId int64, channel string) string {
return base64.URLEncoding.EncodeToString([]byte(fmt.Sprintf("%d%s", networkId, strings.ToLower(channel)))) return base64.RawURLEncoding.EncodeToString([]byte(fmt.Sprintf("%d%s", networkId, strings.ToLower(channel))))
} }

View file

@ -629,7 +629,11 @@ export const Events = ({ network, channel }: EventsProps) => {
}; };
useEffect(() => { useEffect(() => {
const key = btoa(`${network.id}${channel.toLowerCase()}`); // Following RFC4648
const key = window.btoa(`${network.id}${channel.toLowerCase()}`)
.replaceAll("+", "-")
.replaceAll("/", "_")
.replaceAll("=", "");
const es = APIClient.irc.events(key); const es = APIClient.irc.events(key);
es.onmessage = (event) => { es.onmessage = (event) => {