Skip to content

Commit

Permalink
Addressing PR review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Hinek <[email protected]>
  • Loading branch information
frankhinek committed Aug 18, 2023
1 parent 4fd0e65 commit d662236
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 25 deletions.
2 changes: 1 addition & 1 deletion packages/agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"require": "./dist/cjs/index.js"
}
},
"react-native": "./dist/esm/index.mjs",
"react-native": "./dist/esm/index.js",
"keywords": [
"decentralized",
"decentralized-applications",
Expand Down
27 changes: 10 additions & 17 deletions packages/agent/src/app-data-store.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import type { Web5Crypto } from '@web5/crypto';
import type { DidKeySet } from '@web5/dids';
import type { KeyValueStore } from '@web5/common';
import type { JweHeaderParams, PublicKeyJwk, Web5Crypto } from '@web5/crypto';

import { DidKeyMethod } from '@web5/dids';
import { hkdf } from '@noble/hashes/hkdf';
import { sha256 } from '@noble/hashes/sha256';
import { sha512 } from '@noble/hashes/sha512';
import { pbkdf2Async } from '@noble/hashes/pbkdf2';
import { Convert, MemoryStore } from '@web5/common';
import { CryptoKey, randomBytes, XChaCha20Poly1305 } from '@web5/crypto';

import type { DidKeySet } from '@web5/dids';
import type { JweHeaderParams, PublicKeyJwk } from '@web5/crypto';

import { Jose } from '@web5/crypto';
import { DidKeyMethod } from '@web5/dids';
import { CryptoKey, Jose, randomBytes, XChaCha20Poly1305 } from '@web5/crypto';

export type AppDataBackup = {
/**
Expand Down Expand Up @@ -132,14 +128,12 @@ export class AppDataVault implements AppDataStore {
this._store = options?.store ?? new MemoryStore();
}

async backup(options: { passphrase: string }): Promise<AppDataBackup> {
console.log(options);
return null as any;
async backup(_options: { passphrase: string }): Promise<AppDataBackup> {
throw new Error ('Not implemented');
}

async changePassphrase(options: { oldPassphrase: string, newPassphrase: string }): Promise<boolean> {
console.log(options);
return null as any;
async changePassphrase(_options: { oldPassphrase: string, newPassphrase: string }): Promise<boolean> {
throw new Error ('Not implemented');
}

private async generateVaultUnlockKey(options: {
Expand Down Expand Up @@ -333,9 +327,8 @@ export class AppDataVault implements AppDataStore {
this._vaultUnlockKey = new Uint8Array();
}

async restore(options: { backup: AppDataBackup, passphrase: string }): Promise<boolean> {
console.log(options);
return null as any;
async restore(_options: { backup: AppDataBackup, passphrase: string }): Promise<boolean> {
throw new Error ('Not implemented');
}

async setStatus(options: Partial<AppDataStatus>): Promise<boolean> {
Expand Down
9 changes: 2 additions & 7 deletions packages/agent/src/store-managed-did.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ export class DidStoreDwn implements ManagedDidStore {
// Encode the ManagedDid as bytes.
const importDidU8A = Convert.object(importDid).toUint8Array();

const writeReply = await agent.dwnManager.processRequest({
// const { reply: { status } } = await agent.dwnManager.processRequest({
const { reply: { status } } = await agent.dwnManager.processRequest({
author : authorDid,
target : authorDid,
messageType : 'RecordsWrite',
Expand All @@ -165,11 +164,7 @@ export class DidStoreDwn implements ManagedDidStore {
});

// If the write fails, throw an error.
if (writeReply.reply.status.code !== 202) {
// if (status.code !== 202) {
console.log('AUTHOR:', authorDid);
console.log(JSON.stringify(writeReply.message, null, 2));
console.log(JSON.stringify(writeReply.reply, null, 2));
if (status.code !== 202) {
throw new Error('DidStoreDwn: Failed to write imported DID to store.');
}
}
Expand Down

0 comments on commit d662236

Please sign in to comment.