There are some code parts using our custom implementations which can be replaced with modern built-in browser APIs: - [fromUtfStr](https://github.com/FlowCrypt/flowcrypt-browser/blob/2585a8feedc77b999658cac96910532c1a713e92/extension/js/common/core/buf.ts#L41) manually handles Unicode and can be replaced with `TextEncoder` which is widely supported (https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder) - `Promise` in [readAttachmentDataAsUint8](https://github.com/FlowCrypt/flowcrypt-browser/blob/2585a8feedc77b999658cac96910532c1a713e92/extension/js/common/ui/attachment-ui.ts#L186) handles only `onload`, an asynchronous read failure leaves it pending indefinitely. This can become `return new Uint8Array(await this.attachedFiles[uploadFileId].arrayBuffer())` which removes callback plumbing and propagates failures naturally (https://developer.mozilla.org/en-US/docs/Web/API/Blob/arrayBuffer) - use native `Uint8Array.fromBase64()` and `toBase64()` APIs which appeared in Chrome 140 instead of `base64decode` and `base64encode`
There are some code parts using our custom implementations which can be replaced with modern built-in browser APIs:
TextEncoderwhich is widely supported (https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder)Promisein readAttachmentDataAsUint8 handles onlyonload, an asynchronous read failure leaves it pending indefinitely. This can becomereturn new Uint8Array(await this.attachedFiles[uploadFileId].arrayBuffer())which removes callback plumbing and propagates failures naturally (https://developer.mozilla.org/en-US/docs/Web/API/Blob/arrayBuffer)Uint8Array.fromBase64()andtoBase64()APIs which appeared in Chrome 140 instead ofbase64decodeandbase64encode