mirror of
https://github.com/morten-olsen/parcel.git
synced 2026-02-08 01:36:24 +01:00
workbox
This commit is contained in:
@@ -22,7 +22,7 @@ const DecryptionContext = createContext<DecryptionContextType>({
|
||||
|
||||
const decrypt = async (privateKey: string, keys: string[], content: string) => {
|
||||
const armoredKeys = await Promise.all(keys.map(openpgp.key.readArmored));
|
||||
const message = openpgp.message.fromText(content);
|
||||
const message = openpgp.message.fromBinary(content);
|
||||
const encrypted = await openpgp.decrypt({
|
||||
message,
|
||||
privateKeys: [...(await openpgp.key.readArmored(privateKey)).keys],
|
||||
@@ -82,11 +82,12 @@ const DecryptionProvider: React.FC = ({
|
||||
reader.onabort = addedFile.setFailed,
|
||||
reader.onerror = addedFile.setFailed,
|
||||
reader.onload = () => {
|
||||
console.log('read');
|
||||
addedFile.setContent(
|
||||
decrypt(privateKey, keys, reader.result as string),
|
||||
);
|
||||
}
|
||||
reader.readAsText(file)
|
||||
reader.readAsBinaryString(file);
|
||||
}, [keys, username]);
|
||||
|
||||
return (
|
||||
|
||||
@@ -41,6 +41,7 @@ export const createFile = (setFiles: SetFilesType, name: string) => {
|
||||
}
|
||||
|
||||
const setFailed = (err: any) => {
|
||||
console.error(err);
|
||||
setFiles((files) => ({
|
||||
...files,
|
||||
[id]: {
|
||||
|
||||
@@ -1,33 +1,15 @@
|
||||
import OfflinePluginRuntime from 'offline-plugin/runtime';
|
||||
import { notification } from 'antd';
|
||||
import React from 'react';
|
||||
import 'antd/dist/antd.css';
|
||||
import { render } from 'react-dom';
|
||||
import App from './App';
|
||||
|
||||
if (!__DEV__) {
|
||||
OfflinePluginRuntime.install({
|
||||
onUpdating: () => {
|
||||
console.log('SW Event:', 'onUpdating');
|
||||
},
|
||||
onUpdateReady: () => {
|
||||
console.log('SW Event:', 'onUpdateReady');
|
||||
OfflinePluginRuntime.applyUpdate();
|
||||
},
|
||||
onUpdated: () => {
|
||||
notification.success({
|
||||
message: 'Your app has been updated',
|
||||
});
|
||||
},
|
||||
onUpdateFailed: () => {
|
||||
notification.warn({
|
||||
message: 'Could not update to the latest version',
|
||||
});
|
||||
console.log('SW Event:', 'onUpdateFailed');
|
||||
}
|
||||
if ('serviceWorker' in navigator) {
|
||||
window.addEventListener('load', () => {
|
||||
navigator.serviceWorker.register('/sw.js');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
const root = document.createElement('div');
|
||||
root.style.height = '100%';
|
||||
document.body.appendChild(root);
|
||||
|
||||
@@ -19,9 +19,11 @@ const SetupKey: React.FC = () => {
|
||||
const [email, setEmail] = useState('');
|
||||
|
||||
const downloadPublicKey = useCallback(() => {
|
||||
const publicKeyBlob = new Blob([publicKey!]);
|
||||
const publicKeyBlob = new Blob([publicKey + ''], {
|
||||
type: 'text/text',
|
||||
});
|
||||
downloadLink('public-key.asc', publicKeyBlob);
|
||||
}, []);
|
||||
}, [publicKey]);
|
||||
|
||||
const setupKey = useCallback(() => {
|
||||
createKey(name, email);
|
||||
|
||||
Reference in New Issue
Block a user