fix(api): ошибки типов, скрытые отсутствием typecheck

- jose v6 не экспортирует KeyLike → CryptoKey
- SimpleWebAuthn v13 требует Uint8Array<ArrayBuffer>
- targetType 'credential' в AUDIT_TARGET_TYPES (писался в аудит passkey-ов)
- target-app: начальные значения host/path/search никогда не читались
This commit is contained in:
Denozordec
2026-09-23 14:51:38 +07:00
parent e107af8e43
commit c48132e89e
3 changed files with 12 additions and 12 deletions
+5 -7
View File
@@ -5,17 +5,15 @@ export function targetAppFromReturnTo(
returnTo: string | undefined | null,
): AuditSourceApp {
if (!returnTo) return 'portal'
let host = ''
let path = ''
let search = ''
let u: URL
try {
const u = new URL(returnTo)
host = u.hostname.toLowerCase()
path = u.pathname.toLowerCase()
search = u.search
u = new URL(returnTo)
} catch {
return 'portal'
}
const host = u.hostname.toLowerCase()
const path = u.pathname.toLowerCase()
const search = u.search
// Portal OIDC authorize as return_to → map via client's redirect_uri
if (path === '/oauth/authorize' || path.endsWith('/oauth/authorize')) {
+6 -5
View File
@@ -14,16 +14,17 @@ export function webauthnRelyingParty(app: FastifyInstance): {
}
}
export function userIdToBytes(userId: string): Uint8Array {
return isoUint8Array.fromUTF8String(userId)
export function userIdToBytes(userId: string): Uint8Array<ArrayBuffer> {
// Копия через конструктор даёт Uint8Array<ArrayBuffer>, которого требует SimpleWebAuthn v13.
return new Uint8Array(isoUint8Array.fromUTF8String(userId))
}
export function encodePublicKey(publicKey: Uint8Array): string {
export function encodePublicKey(publicKey: Uint8Array<ArrayBuffer>): string {
return isoBase64URL.fromBuffer(publicKey)
}
export function decodePublicKey(stored: string): Uint8Array {
return isoBase64URL.toBuffer(stored)
export function decodePublicKey(stored: string): Uint8Array<ArrayBuffer> {
return new Uint8Array(isoBase64URL.toBuffer(stored))
}
export function asTransports(