Skip to content
This repository was archived by the owner on Aug 1, 2023. It is now read-only.
This repository was archived by the owner on Aug 1, 2023. It is now read-only.

Radiks : problem with encryption while saving models #97

Description

@bricemacias

Hi, I just started using radiks and my own radiks-server on my Dapp.

I know my radiks-server is working because I can fetch radiks User or Model with fetchList(), even if I get an empty array because nothing is saved yet. If I change the apiServer in radiks configure, the fetchList() method fails. That way, when I put back the correct apiServer url in configure and I get empty array, at least I know my radiks server is up and running.

The problem is when I try to save anything with the save() method.

If I use the example given in the documentation with the simple Todo Model :

class Todo extends Model {
  static className = 'Todo';
  static schema = {
// all fields are encrypted by default
title: String,
completed: Boolean,
  };
}

If I create a new Todo model, and then try to use save(), I get the following error :

index.js:311 
Uncaught (in promise) TypeError: First argument must be a string, Buffer, ArrayBuffer, 
     Array, or array-like object.
        at fromObject (index.js:311)
        at from (index.js:137)
        at Function.push.../node_modules/buffer/index.js.Buffer.from (index.js:149)
        at Object.getPublicKeyFromPrivate (keys.ts:43)
        at signECDSA (ec.ts:377)
        at Todo.sign (model.ts:211)
        at model.ts:131 

Same, if y create a user with the method User.currentUser() , and then try to save it, I get the following error :

fetchUtil.ts:12 
   POST https://hub.blockstack.org/store/{adressId}/BlockstackUser/{myBlockstackUserId}
   with server error 500

and

 utils.ts:401 
 Uncaught (in promise) Error: Error when uploading to Gaia hub.
         at Object.<anonymous> (utils.ts:401)
         at Generator.next (<anonymous>)
         at fulfilled (tslib.es6.js:71)

Finally, if this time I try to create User with the method User.createWithCurrentUser() method, I get the following error :

 aesCipher.ts:90 
 Uncaught (in promise) TypeError: Failed to execute 'encrypt' on 'SubtleCrypto': The provided value is 
   not of type '(ArrayBuffer or ArrayBufferView)'
      at WebCryptoAesCipher.<anonymous> (aesCipher.ts:90)
      at Generator.next (<anonymous>)
      at fulfilled (tslib.es6.js:71)

With another 500 error after that, saying

“Error When Uploading to Gaia Hub”.

💡NB : If I try the normal getFile() and putFile() methods without using radiks, that works perfectly though

After some tries, I managed to save a Todo, but apparently it’s an encryption problem. When I get the list of Todos I created, inside of the attributes of the object I get a blockstack error saying :

“Unable to get public key from cipher object. You might be trying to decrypt an unencrypted object.”

and when I create a Todo, I get the following error :

Uncaught (in promise) TypeError: Failed to execute 'encrypt' on 'SubtleCrypto': The provided value is not of type '(ArrayBuffer or ArrayBufferView)'
    at WebCryptoAesCipher.<anonymous> (aesCipher.ts:90)
    at Generator.next (<anonymous>)
    at fulfilled (tslib.es6.js:71)

And if I create a Todo, but this time whitout encryption, everything works perfectly.

I really don't know if this is related to me or to radiks itself...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions