Skip to content
Permalink
Browse files

fix: fix backup seed not being correctyl serialized

  • Loading branch information...
satazor committed Jun 21, 2019
1 parent 9851ce7 commit aa234f1ef1dfa6fb9a4188fe5bac5c33d62a32e0
Showing with 13 additions and 2 deletions.
  1. +13 −2 src/identities/identity/backup.js
@@ -1,3 +1,4 @@
import hexarray from 'hex-array';
import { getBackupKey } from './utils/storage-keys';

class Backup {
@@ -32,14 +33,24 @@ class Backup {

export const createBackup = async (data, identityDescriptor, storage) => {
if (data) {
await storage.set(getBackupKey(identityDescriptor.id), data, { encrypt: true });
const serializedData = {
...data,
seed: hexarray.toString(data.seed, { uppercase: false }),
};

await storage.set(getBackupKey(identityDescriptor.id), serializedData, { encrypt: true });
}

return new Backup(data, identityDescriptor, storage);
};

export const restoreBackup = async (identityDescriptor, storage) => {
const data = await storage.get(getBackupKey(identityDescriptor.id));
const serializedData = await storage.get(getBackupKey(identityDescriptor.id));

const data = serializedData && {
...serializedData,
seed: hexarray.fromString(serializedData.seed),
};

return new Backup(data, identityDescriptor, storage);
};

0 comments on commit aa234f1

Please sign in to comment.
You can’t perform that action at this time.