mirror of
https://gitcode.com/gitea/gitea.git
synced 2025-05-22 09:37:48 +08:00
Clean up WebAuthn javascript code and remove JQuery code (#22697)
There were several issues with the WebAuthn registration and testing code and the style was very old javascript with jquery callbacks. This PR uses async and fetch to replace the JQuery code. Ref #22651 Signed-off-by: Andrew Thornton <art27@cantab.net> --------- Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
import {encode, decode} from 'uint8-to-base64';
|
||||
|
||||
// transform /path/to/file.ext to file.ext
|
||||
export function basename(path = '') {
|
||||
return path ? path.replace(/^.*\//, '') : '';
|
||||
@ -135,3 +137,17 @@ export function toAbsoluteUrl(url) {
|
||||
return `${window.location.origin}${url}`;
|
||||
}
|
||||
|
||||
// Encode an ArrayBuffer into a URLEncoded base64 string.
|
||||
export function encodeURLEncodedBase64(arrayBuffer) {
|
||||
return encode(arrayBuffer)
|
||||
.replace(/\+/g, '-')
|
||||
.replace(/\//g, '_')
|
||||
.replace(/=/g, '');
|
||||
}
|
||||
|
||||
// Decode a URLEncoded base64 to an ArrayBuffer string.
|
||||
export function decodeURLEncodedBase64(base64url) {
|
||||
return decode(base64url
|
||||
.replace(/_/g, '/')
|
||||
.replace(/-/g, '+'));
|
||||
}
|
||||
|
Reference in New Issue
Block a user