1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-06-28 15:27:43 +00:00
* Changed: When rendering link previews for tweets with multiple images, arrange them the same way that they're arranged on Twitter itself.
* Fixed: Certain emotes not appearing correctly when using Firefox.
* Experiments Changed: Update to a new PubSub provider, for seeing if this can scale acceptably.
This commit is contained in:
SirStendec 2023-10-29 14:30:34 -04:00
parent 60e4edf7c2
commit f1be0ea60c
10 changed files with 694 additions and 163 deletions

View file

@ -864,4 +864,49 @@ export class SourcedSet {
old_val.splice(idx, 1);
this._rebuild();
}
}
}
export function b64ToArrayBuffer(input) {
const bin = atob(input),
len = bin.length,
buffer = new ArrayBuffer(len),
view = new Uint8Array(buffer);
for(let i = 0, len = bin.length; i < len; i++)
view[i] = bin.charCodeAt(i);
return buffer;
}
const PEM_HEADER = /-----BEGIN (.+?) KEY-----/,
PEM_FOOTER = /-----END (.+?) KEY-----/;
export function importRsaKey(pem, uses = ['verify']) {
const start_match = PEM_HEADER.exec(pem),
end_match = PEM_FOOTER.exec(pem);
if ( ! start_match || ! end_match || start_match[1] !== end_match[1] )
throw new Error('invalid key');
const is_private = /\bPRIVATE\b/i.test(start_match[1]),
start = start_match.index + start_match[0].length,
end = end_match.index;
const content = pem.slice(start, end).replace(/\n/g, '').trim();
//console.debug('content', JSON.stringify(content));
const buffer = b64ToArrayBuffer(content);
return crypto.subtle.importKey(
is_private ? 'pkcs8' : 'spki',
buffer,
{
name: "RSA-PSS",
hash: "SHA-256"
},
true,
uses
);
}