Browse Source

crypto: use application/vnd namespace instead of binary/

master
Peter Cai 2 years ago
parent
commit
324903108b
  1. 6
      src/crypto.coffee
  2. 2
      src/index.coffee

6
src/crypto.coffee

@ -44,7 +44,7 @@ encryptFile = (file) ->
# Encrypt
encrypted = await crypto.subtle.encrypt algoParams, key, await file.arrayBuffer()
name = hex await crypto.subtle.encrypt algoParams, key, utf8Bytes file.name
mime = 'binary/' + hex await crypto.subtle.encrypt algoParams, key, utf8Bytes file.type
mime = 'application/vnd.angry.paste+' + hex await crypto.subtle.encrypt algoParams, key, utf8Bytes file.type
exportedKey = hex await crypto.subtle.exportKey 'raw', key
[exportedKey, hex(iv), name, mime, encrypted]
@ -63,7 +63,7 @@ importKeyAndIv = (key, iv) ->
decryptMetadata = (key, iv, name, mime) ->
[key, algoParams] = await importKeyAndIv key, iv
name = fromUtf8Bytes await crypto.subtle.decrypt algoParams, key, fromHex name
mime = fromHex mime.replace /^binary\//, ""
mime = fromHex mime.replace /^application\/vnd\.angry\.paste\+/, ""
mime = fromUtf8Bytes await crypto.subtle.decrypt algoParams, key, mime
[name, mime]
@ -80,4 +80,4 @@ export {
encryptFile,
decryptMetadata,
decryptFile
}
}

2
src/index.coffee

@ -231,4 +231,4 @@ handleRemoteFetch = (req) ->
new Response "/paste/" + id,
status: 200
export default main
export default main

Loading…
Cancel
Save