COVID-19-electronic-health-system / Corona-tracker

An easy-to-use PWA to monitor the user's wellness and learn about COVID-19.
https://coronatracker.me/
MIT License
236 stars 101 forks source link

Unhandled Rejection (TypeError): First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object. #100

Closed jchen42703 closed 4 years ago

jchen42703 commented 4 years ago

To reproduce: Follow the normal installation with MongoDB and radiks but with yarn:

Clone this repo git clone https://github.com/COVID-19-electronic-health-system/Corona-tracker
cd Corona-tracker/client
npm i
Ensure MongoDB is running (see Prerequisites)
yarn radiks-server - start the local radiks server
yarn start

I also get this error when I just do:

radiks-server
npm run install

Traceback:

×
Unhandled Rejection (TypeError): First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.
▼ 3 stack frames were expanded.
fromObject
C:/Users/jchen/website_projects/Forks/Corona-tracker/client/node_modules/buffer/index.js:311
from
C:/Users/jchen/website_projects/Forks/Corona-tracker/client/node_modules/buffer/index.js:137
Function.push../node_modules/buffer/index.js.Buffer.from
C:/Users/jchen/website_projects/Forks/Corona-tracker/client/node_modules/buffer/index.js:149
▲ 3 stack frames were expanded.
getPublicKeyFromPrivate
C:/Users/jchen/website_projects/Forks/Corona-tracker/src/keys.ts:44
  41 | /**
  42 | * @ignore
  43 | */
> 44 | function getPublicKeyFromPrivate(privateKey) {
  45 |     const keyPair = bitcoinjs_lib_1.ECPair.fromPrivateKey(Buffer.from(privateKey, 'hex'));
  46 |     return keyPair.publicKey.toString('hex');
  47 | }
View compiled
signECDSA
C:/Users/jchen/website_projects/Forks/src/encryption/ec.ts:194
  191 |     const contentHash = crypto.createHash('sha256').update(contentBuffer).digest();
  192 |     return ecPublic.verify(contentHash, signature);
  193 | }
> 194 | exports.verifyECDSA = verifyECDSA;
  195 | //# sourceMappingURL=ec.js.map
View compiled
Patient.sign
C:/Users/jchen/website_projects/Forks/Corona-tracker/src/model.ts:211
  208 |   if (this.attrs.updatedAt) {
  209 |     contentToSign.push(this.attrs.updatedAt);
  210 |   }
> 211 |   const { signature } = signECDSA(privateKey, contentToSign.join('-'));
      | ^  212 |   this.attrs.radiksSignature = signature;
  213 |   return this;
  214 | }
View compiled
(anonymous function)
C:/Users/jchen/website_projects/Forks/Corona-tracker/src/model.ts:131
  128 | this.attrs.updatedAt = now;
  129 | this.attrs.createdAt = this.attrs.createdAt || now;
  130 | this.attrs.updatedAt = now;
> 131 | await this.sign();
      | ^  132 | const encrypted = await this.encrypted();
  133 | const gaiaURL = await this.saveFile(encrypted);
  134 | await sendNewGaiaUrl(gaiaURL);

I'm running MongoDB on windows. I think this is an issue on my end because radiks opened on http://localhost:1260/ and React opened on http://localhost:3000/. Will update as I double check my MongoDB installation paths and environment variables.

friedger commented 4 years ago

This is usually an indication that User.createWithCurrentUser was not called (I think)

friedger commented 4 years ago

Should be fixed by #96

SomeMoosery commented 4 years ago

@jchen42703 let us know when you can if this is fixed by fixes made by @friedger - if so we'll go ahead and close this!

jchen42703 commented 4 years ago

It works!