don't use blob

This commit is contained in:
2023-04-27 19:01:26 +02:00
parent be0d523d90
commit 55b6e9ea51
8 changed files with 27 additions and 112 deletions

View File

@@ -15,14 +15,15 @@ class CryptTextAdapter implements CryptAdapter<string> {
}
}
class CryptBlobAdapter implements CryptAdapter<Blob> {
async encrypt(plaintext: Blob, key: TypedArray) {
return await AES.encrypt(new Uint8Array(await plaintext.arrayBuffer()), key)
class CryptBlobAdapter implements CryptAdapter<TypedArray> {
async encrypt(plaintext: TypedArray, key: TypedArray) {
return await AES.encrypt(plaintext, key)
}
async decrypt(ciphertext: string, key: TypedArray) {
const plaintext = await AES.decrypt(ciphertext, key)
return new Blob([plaintext], { type: 'application/octet-stream' })
return await AES.decrypt(ciphertext, key)
// const plaintext = await AES.decrypt(ciphertext, key)
// return new Blob([plaintext], { type: 'application/octet-stream' })
}
}

View File

@@ -1,3 +1,5 @@
import type { TypedArray } from 'occulto'
export type NoteMeta = { type: 'text' | 'file' }
export type Note = {
@@ -11,7 +13,7 @@ export type NotePublic = Pick<Note, 'contents' | 'meta'>
export type NoteCreate = Omit<Note, 'meta'> & { meta: string }
export type FileDTO = Pick<File, 'name' | 'size' | 'type'> & {
contents: Blob
contents: TypedArray
}
export type EncryptedFileDTO = Omit<FileDTO, 'contents'> & {