mirror of
https://github.com/go-gitea/gitea
synced 2025-12-07 13:28:25 +00:00
Enable TypeScript strictNullChecks (#35843)
A big step towards enabling strict mode in Typescript. There was definitely a good share of potential bugs while refactoring this. When in doubt, I opted to keep the potentially broken behaviour. Notably, the `DOMEvent` type is gone, it was broken and we're better of with type assertions on `e.target`. --------- Signed-off-by: silverwind <me@silverwind.io> Signed-off-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
@@ -13,7 +13,7 @@ export async function initUserAuthWebAuthn() {
|
||||
|
||||
// webauthn is only supported on secure contexts
|
||||
if (!window.isSecureContext) {
|
||||
hideElem(elSignInPasskeyBtn);
|
||||
if (elSignInPasskeyBtn) hideElem(elSignInPasskeyBtn);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ async function loginPasskey() {
|
||||
const clientDataJSON = new Uint8Array(credResp.clientDataJSON);
|
||||
const rawId = new Uint8Array(credential.rawId);
|
||||
const sig = new Uint8Array(credResp.signature);
|
||||
const userHandle = new Uint8Array(credResp.userHandle);
|
||||
const userHandle = new Uint8Array(credResp.userHandle ?? []);
|
||||
|
||||
const res = await POST(`${appSubUrl}/user/webauthn/passkey/login`, {
|
||||
data: {
|
||||
@@ -183,7 +183,7 @@ async function webauthnRegistered(newCredential: any) { // TODO: Credential type
|
||||
}
|
||||
|
||||
function webAuthnError(errorType: string, message:string = '') {
|
||||
const elErrorMsg = document.querySelector(`#webauthn-error-msg`);
|
||||
const elErrorMsg = document.querySelector(`#webauthn-error-msg`)!;
|
||||
|
||||
if (errorType === 'general') {
|
||||
elErrorMsg.textContent = message || 'unknown error';
|
||||
@@ -228,7 +228,7 @@ export function initUserAuthWebAuthnRegister() {
|
||||
}
|
||||
|
||||
async function webAuthnRegisterRequest() {
|
||||
const elNickname = document.querySelector<HTMLInputElement>('#nickname');
|
||||
const elNickname = document.querySelector<HTMLInputElement>('#nickname')!;
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('name', elNickname.value);
|
||||
@@ -246,7 +246,7 @@ async function webAuthnRegisterRequest() {
|
||||
}
|
||||
|
||||
const options = await res.json();
|
||||
elNickname.closest('div.field').classList.remove('error');
|
||||
elNickname.closest('div.field')!.classList.remove('error');
|
||||
|
||||
options.publicKey.challenge = decodeURLEncodedBase64(options.publicKey.challenge);
|
||||
options.publicKey.user.id = decodeURLEncodedBase64(options.publicKey.user.id);
|
||||
|
||||
Reference in New Issue
Block a user