You've already forked Nitro_Render_V3
mirror of
https://github.com/duckietm/Nitro_Render_V3.git
synced 2026-06-20 07:26:18 +00:00
TS 5.7+ ArrayBuffer drift: cast where ArrayBufferLike leaked
TypeScript 5.7 split ArrayBuffer / SharedArrayBuffer at the type level (ArrayBuffer now exposes resizable/transfer/detached etc; SharedArrayBuffer doesn't), and parametrized the typed-array constructors so plain Uint8Array became Uint8Array<ArrayBufferLike>. The renderer never uses SharedArrayBuffer, so this is type-level only — narrowing back to ArrayBuffer at the boundaries: - BinaryReader.readBytes() / .toArrayBuffer() return the underlying DataView buffer; cast to ArrayBuffer. - BinaryWriter.getBuffer() same shape. - WsSessionCrypto.randomNonce() now returns Uint8Array<ArrayBuffer> (it's always backed by a plain ArrayBuffer); aesGcmEncrypt/Decrypt nonce parameter retyped accordingly so SubtleCrypto.encrypt accepts it as BufferSource. - ArrayBufferToBase64 now accepts Uint8Array | ArrayBufferLike directly (pako/inflate hands back Uint8Array<ArrayBuffer> which the old ArrayBuffer-only signature rejected).
This commit is contained in:
@@ -38,17 +38,17 @@ export async function deriveAesKey(sharedSecret: ArrayBuffer): Promise<CryptoKey
|
||||
);
|
||||
}
|
||||
|
||||
export async function aesGcmEncrypt(key: CryptoKey, nonce: Uint8Array, plaintext: ArrayBuffer): Promise<ArrayBuffer>
|
||||
export async function aesGcmEncrypt(key: CryptoKey, nonce: Uint8Array<ArrayBuffer>, plaintext: ArrayBuffer): Promise<ArrayBuffer>
|
||||
{
|
||||
return window.crypto.subtle.encrypt({ name: 'AES-GCM', iv: nonce, tagLength: GCM_TAG_LEN * 8 }, key, plaintext);
|
||||
}
|
||||
|
||||
export async function aesGcmDecrypt(key: CryptoKey, nonce: Uint8Array, ciphertextWithTag: ArrayBuffer): Promise<ArrayBuffer>
|
||||
export async function aesGcmDecrypt(key: CryptoKey, nonce: Uint8Array<ArrayBuffer>, ciphertextWithTag: ArrayBuffer): Promise<ArrayBuffer>
|
||||
{
|
||||
return window.crypto.subtle.decrypt({ name: 'AES-GCM', iv: nonce, tagLength: GCM_TAG_LEN * 8 }, key, ciphertextWithTag);
|
||||
}
|
||||
|
||||
export function randomNonce(): Uint8Array
|
||||
export function randomNonce(): Uint8Array<ArrayBuffer>
|
||||
{
|
||||
const n = new Uint8Array(NONCE_LEN);
|
||||
window.crypto.getRandomValues(n);
|
||||
|
||||
Reference in New Issue
Block a user