vincenzoAiello / DArchive

3 stars 4 forks source link

Errors while trying to upload #2

Closed alexanderbkl closed 2 years ago

alexanderbkl commented 2 years ago

I configured firebase and web3.storage api's but I get this error when trying to upload an encrypted file:

TypeError: Cannot read properties of undefined (reading 'digest')
    at Hasher.encode (sha2-browser.js:7:1)
    at Hasher.digest (hasher.js:16:1)
    at persist (persist.js:40:1)
    at buffer-importer.js:54:1
    at index.js:32:1
    at Array.map (<anonymous>)
    at Object.parallelBatch [as default] (index.js:27:1)
    at async buildFileBatch (index.js:53:1)
    at async Object.batch [as default] (index.js:20:1)
    at async reduceToParents (balanced.js:14:1)
    at async Object.parallelBatch [as default] (index.js:36:1)
    at async treeBuilder (tree-builder.js:61:1)
    at async importer (index.js:34:1)
    at async last (index.js:13:1)

And when trying to upload without encrypting the file, I get this:

Home copy.js:257 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'importKey')
    at openImagePickerAsync$ (Home copy.js:257:1)
    at tryCatch (regeneratorRuntime.js:86:1)
    at Generator._invoke (regeneratorRuntime.js:66:1)
    at Generator.next (regeneratorRuntime.js:117:1)
    at tryCatch (regeneratorRuntime.js:86:1)
    at invoke (regeneratorRuntime.js:124:1)
    at regeneratorRuntime.js:148:1
    at new Promise (<anonymous>)
    at callInvokeWithMethodAndArg (regeneratorRuntime.js:147:1)
    at AsyncIterator._invoke (regeneratorRuntime.js:152:1)
    at AsyncIterator.next (regeneratorRuntime.js:117:1)
    at exports.async (regeneratorRuntime.js:238:1)
    at openImagePickerAsync (Home copy.js:257:1)
    at _callee7$ (Home copy.js:1432:1)
    at tryCatch (regeneratorRuntime.js:86:1)
    at Generator._invoke (regeneratorRuntime.js:66:1)
    at Generator.next (regeneratorRuntime.js:117:1)
    at tryCatch (regeneratorRuntime.js:86:1)
    at invoke (regeneratorRuntime.js:124:1)
    at regeneratorRuntime.js:148:1
    at new Promise (<anonymous>)
    at callInvokeWithMethodAndArg (regeneratorRuntime.js:147:1)
    at AsyncIterator._invoke (regeneratorRuntime.js:152:1)
    at AsyncIterator.next (regeneratorRuntime.js:117:1)
    at exports.async (regeneratorRuntime.js:238:1)
    at _callee7 (Home copy.js:1432:1)
    at HTMLUnknownElement.callCallback (react-dom.development.js:3945:1)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:3994:1)
    at invokeGuardedCallback (react-dom.development.js:4056:1)
    at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4070:1)
    at executeDispatch (react-dom.development.js:8243:1)
    at processDispatchQueueItemsInOrder (react-dom.development.js:8275:1)
    at processDispatchQueue (react-dom.development.js:8288:1)
    at dispatchEventsForPlugins (react-dom.development.js:8299:1)
    at react-dom.development.js:8508:1
    at batchedEventUpdates$1 (react-dom.development.js:22396:1)
    at batchedEventUpdates (react-dom.development.js:3745:1)
    at dispatchEventForPluginEventSystem (react-dom.development.js:8507:1)
    at attemptToDispatchEvent (react-dom.development.js:6005:1)
    at dispatchEvent (react-dom.development.js:5924:1)
    at unstable_runWithPriority (scheduler.development.js:468:1)
    at runWithPriority$1 (react-dom.development.js:11276:1)
    at discreteUpdates$1 (react-dom.development.js:22413:1)
    at discreteUpdates (react-dom.development.js:3756:1)
    at dispatchDiscreteEvent (react-dom.development.js:5889:1)
vincenzoAiello commented 2 years ago

Hi, do you have this error in localhost or on a server? Beacuse i think there is a problem with windows.crypto. Chrome restricts the usage of WebCryptographyApi to secure origins. It means 'https'. localhost should be ok. Therefore, to use WebCrypto in a real environment you need to setup a SSL/TLS server

alexbkl commented 2 years ago

Solved by using SSL certificate. Thank you very much Vincenzo!