crypto: use application/vnd namespace instead of binary/
This commit is contained in:
parent
cb41215ec9
commit
324903108b
|
@ -44,7 +44,7 @@ encryptFile = (file) ->
|
||||||
# Encrypt
|
# Encrypt
|
||||||
encrypted = await crypto.subtle.encrypt algoParams, key, await file.arrayBuffer()
|
encrypted = await crypto.subtle.encrypt algoParams, key, await file.arrayBuffer()
|
||||||
name = hex await crypto.subtle.encrypt algoParams, key, utf8Bytes file.name
|
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 await crypto.subtle.exportKey 'raw', key
|
||||||
[exportedKey, hex(iv), name, mime, encrypted]
|
[exportedKey, hex(iv), name, mime, encrypted]
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ importKeyAndIv = (key, iv) ->
|
||||||
decryptMetadata = (key, iv, name, mime) ->
|
decryptMetadata = (key, iv, name, mime) ->
|
||||||
[key, algoParams] = await importKeyAndIv key, iv
|
[key, algoParams] = await importKeyAndIv key, iv
|
||||||
name = fromUtf8Bytes await crypto.subtle.decrypt algoParams, key, fromHex name
|
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
|
mime = fromUtf8Bytes await crypto.subtle.decrypt algoParams, key, mime
|
||||||
[name, mime]
|
[name, mime]
|
||||||
|
|
||||||
|
@ -80,4 +80,4 @@ export {
|
||||||
encryptFile,
|
encryptFile,
|
||||||
decryptMetadata,
|
decryptMetadata,
|
||||||
decryptFile
|
decryptFile
|
||||||
}
|
}
|
||||||
|
|
|
@ -231,4 +231,4 @@ handleRemoteFetch = (req) ->
|
||||||
new Response "/paste/" + id,
|
new Response "/paste/" + id,
|
||||||
status: 200
|
status: 200
|
||||||
|
|
||||||
export default main
|
export default main
|
||||||
|
|
Loading…
Reference in New Issue