diff --git a/desktop-node-react/package.json b/desktop-node-react/package.json
index c3194a4..9d555f1 100644
--- a/desktop-node-react/package.json
+++ b/desktop-node-react/package.json
@@ -12,6 +12,8 @@
},
"dependencies": {
"@socketsupply/ssc-node": "1.7.1",
+ "@w3ui/react-keyring": "^1.0.1",
+ "@w3ui/react-uploader": "^2.1.2",
"react": "^18.1.0",
"react-dom": "^18.1.0"
}
diff --git a/desktop-node-react/src/render/App.jsx b/desktop-node-react/src/render/App.jsx
index 12fa245..f032b16 100644
--- a/desktop-node-react/src/render/App.jsx
+++ b/desktop-node-react/src/render/App.jsx
@@ -1,5 +1,7 @@
-import React, { useEffect, useState } from 'react';
-import './App.css';
+import React, { useEffect, useState } from "react";
+import { AuthProvider, useAuth, AuthStatus } from "@w3ui/react-keyring";
+import { UploaderProvider, useUploader } from "@w3ui/react-uploader";
+import "./App.css";
function useEvent(event, handler, passive = false) {
useEffect(() => {
@@ -29,13 +31,131 @@ function App() {
})
return (
<>
-
Messages sent from the main process: {messageCounter} ({clickCounter} clicks, {timerCounter} automatic (once per 5 seconds))
-
+
+
+
+
+
+
+
+
+ Messages sent from the main process: {messageCounter} ({clickCounter}{" "}
+ clicks, {timerCounter} automatic (once per 5 seconds))
+
+
>
);
}
+function MyUploader() {
+ const [{ uploadedCarChunks }, uploader] = useUploader();
+ const [file, setFile] = useState(null);
+ const [dataCid, setDataCid] = useState('')
+ const [status, setStatus] = useState("");
+ const [error, setError] = useState(null);
+
+ if (!uploader) return null;
+
+ const handleUploadSubmit = async (e) => {
+ e.preventDefault();
+ try {
+ setStatus("uploading");
+ const cid = await uploader.uploadFile(file);
+ setDataCid(cid);
+ } catch (err) {
+ console.error(err);
+ setError(err);
+ } finally {
+ setStatus("done");
+ }
+ };
+
+ return (
+
+ );
+}
+
+const Uploader = withIdentity(MyUploader);
+
+export function withIdentity (Component) {
+ return props => (
+
+
+
+ )
+}
+
+function Authenticator ({ children }) {
+ const { authStatus, identity, registerAndStoreIdentity, cancelRegisterAndStoreIdentity } = useAuth()
+ const [email, setEmail] = useState('')
+
+ if (authStatus === AuthStatus.SignedIn) {
+ return children
+ }
+
+ if (authStatus === AuthStatus.EmailVerification) {
+ return (
+
+
Verify your email address!
+
Click the link in the email we sent to {identity && identity.email} to sign in.
+
+
+ )
+ }
+
+ const handleRegisterSubmit = async e => {
+ e.preventDefault()
+ try {
+ await registerAndStoreIdentity(email)
+ } catch (err) {
+ throw new Error('failed to register', { cause: err })
+ }
+ }
+
+ return (
+
+ )
+}
+
+function IdentityLoader({ children }) {
+ const { loadDefaultIdentity } = useAuth();
+ // eslint-disable-next-line
+ useEffect(() => {
+ loadDefaultIdentity();
+ }, []); // try load default identity - once.
+ return children;
+}
+
export default App;