Radiks : problem while saving models

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”.

And if I try the normal getFile() and putFile() methods without using radiks, that works perfectly, but I really need to use radiks in order for my app to work…

Can you please help me ? I really don’t know what to do :sweat:

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)

Do you know how I can fix this ? :disappointed:

1 Like

Hey there, this sounds like it is possibly a bug. Could you post it over on Github here: https://github.com/blockstack/radiks

Thank you

Just Did :slightly_smiling_face:

Thank you

1 Like

great thank you Brice!

1 Like