Skip to content

Commit

Permalink
Bump dwn-sdk-js to version 0.2.10 (#370)
Browse files Browse the repository at this point in the history
  • Loading branch information
LiranCohen authored Jan 10, 2024
2 parents dbe2708 + 16a734a commit b1b9b7d
Show file tree
Hide file tree
Showing 13 changed files with 289 additions and 141 deletions.
44 changes: 24 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"devDependencies": {
"@npmcli/package-json": "5.0.0",
"@typescript-eslint/eslint-plugin": "6.4.0",
"@web5/dwn-server": "0.1.7",
"@web5/dwn-server": "0.1.9",
"eslint-plugin-mocha": "10.1.0"
}
}
5 changes: 3 additions & 2 deletions packages/agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,14 @@
"node": ">=18.0.0"
},
"dependencies": {
"@tbd54566975/dwn-sdk-js": "0.2.8",
"@tbd54566975/dwn-sdk-js": "0.2.10",
"@web5/common": "0.2.2",
"@web5/crypto": "0.2.2",
"@web5/dids": "0.2.4",
"level": "8.0.0",
"readable-stream": "4.4.2",
"readable-web-to-node-stream": "3.0.2"
"readable-web-to-node-stream": "3.0.2",
"ulidx": "2.1.0"
},
"devDependencies": {
"@playwright/test": "1.40.1",
Expand Down
31 changes: 3 additions & 28 deletions packages/agent/src/dwn-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,11 @@ export class DwnManager {

const result: MessagesGetReply = await this._dwn.processMessage(author, messagesGet.message);

if (!(result.messages && result.messages.length === 1)) {
if (!(result.entries && result.entries.length === 1)) {
throw new Error('TODO: figure out error message');
}

const [ messageEntry ] = result.messages;
const [ messageEntry ] = result.entries;

let { message } = messageEntry;
if (!message) {
Expand Down Expand Up @@ -421,22 +421,6 @@ export class DwnManager {
return dwnMessage;
}

/**
* Writes a pruned initial `RecordsWrite` to a DWN without needing to supply associated data.
* Note: This method should ONLY be used by a {@link SyncManager} implementation.
*
* @param options.targetDid - DID of the DWN tenant to write the pruned RecordsWrite to.
* @returns DWN reply containing the status of processing request.
*/
public async writePrunedRecord(options: {
targetDid: string,
message: RecordsWriteMessage
}): Promise<GenericMessageReply> {
const { targetDid, message } = options;

return await this._dwn.synchronizePrunedInitialRecordsWrite(targetDid, message);
}

public async processMessage(options: {
targetDid: string,
message: GenericMessage,
Expand All @@ -446,13 +430,4 @@ export class DwnManager {

return await this._dwn.processMessage(targetDid, message, dataStream);
}
}

type GenericMessageReply = {
status: Status;
};

type Status = {
code: number
detail: string
};
}
10 changes: 5 additions & 5 deletions packages/agent/src/store-managed-did.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { RecordsWriteMessage } from '@tbd54566975/dwn-sdk-js';
import type { RecordsQueryReply, RecordsWriteMessage } from '@tbd54566975/dwn-sdk-js';

import { Convert } from '@web5/common';

Expand Down Expand Up @@ -45,7 +45,7 @@ export class DidStoreDwn implements ManagedDidStore {

// Loop through all of the entries and try to find a match.
let matchingRecordId: string | undefined;
for (const record of queryReply.entries ?? []) {
for (const record of (queryReply as RecordsQueryReply).entries ?? []) {
if (record.encodedData) {
const storedDid = Convert.base64Url(record.encodedData).toObject() as ManagedDid;
if (storedDid && storedDid.did === did) {
Expand Down Expand Up @@ -94,7 +94,7 @@ export class DidStoreDwn implements ManagedDidStore {
});

// Loop through all of the entries and return a match, if found.
for (const record of queryReply.entries ?? []) {
for (const record of (queryReply as RecordsQueryReply).entries ?? []) {
if (record.encodedData) {
const storedDid = Convert.base64Url(record.encodedData).toObject() as ManagedDid;
if (storedDid && storedDid.did === did) return storedDid;
Expand Down Expand Up @@ -125,7 +125,7 @@ export class DidStoreDwn implements ManagedDidStore {
});

// Loop through all of the entries and return a match, if found.
for (const record of queryReply.entries ?? []) {
for (const record of (queryReply as RecordsQueryReply).entries ?? []) {
if (record.encodedData) {
const storedDid = Convert.base64Url(record.encodedData).toObject() as ManagedDid;
if (storedDid && storedDid.did === did) return storedDid;
Expand Down Expand Up @@ -190,7 +190,7 @@ export class DidStoreDwn implements ManagedDidStore {

// Loop through all of the entries and accumulate the DID objects.
let storedDids: ManagedDid[] = [];
for (const record of queryReply.entries ?? []) {
for (const record of (queryReply as RecordsQueryReply).entries ?? []) {
if (record.encodedData) {
const storedDid = Convert.base64Url(record.encodedData).toObject() as ManagedDid;
storedDids.push(storedDid);
Expand Down
8 changes: 4 additions & 4 deletions packages/agent/src/store-managed-identity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Convert } from '@web5/common';

import type { Web5ManagedAgent } from './types/agent.js';
import type { ManagedIdentity } from './identity-manager.js';
import type { RecordsWriteMessage } from '@tbd54566975/dwn-sdk-js';
import type { RecordsQueryReply, RecordsWriteMessage } from '@tbd54566975/dwn-sdk-js';

export interface ManagedIdentityStore {
deleteIdentity(options: { did: string, agent?: Web5ManagedAgent, context?: string }): Promise<boolean>
Expand Down Expand Up @@ -42,7 +42,7 @@ export class IdentityStoreDwn implements ManagedIdentityStore {

// Loop through all of the entries and try to find a match.
let matchingRecordId: string | undefined;
for (const record of queryReply.entries ?? []) {
for (const record of (queryReply as RecordsQueryReply).entries ?? []) {
if (record.encodedData) {
const storedIdentity = Convert.base64Url(record.encodedData).toObject() as ManagedIdentity;
if (storedIdentity && storedIdentity.did === did) {
Expand Down Expand Up @@ -91,7 +91,7 @@ export class IdentityStoreDwn implements ManagedIdentityStore {
});

// Loop through all of the entries and return a match, if found.
for (const record of queryReply.entries ?? []) {
for (const record of (queryReply as RecordsQueryReply).entries ?? []) {
if (record.encodedData) {
const storedIdentity = Convert.base64Url(record.encodedData).toObject() as ManagedIdentity;
if (storedIdentity && storedIdentity.did === did) return storedIdentity;
Expand Down Expand Up @@ -156,7 +156,7 @@ export class IdentityStoreDwn implements ManagedIdentityStore {

// Loop through all of the entries and accumulate the Identity objects.
let storedIdentities: ManagedIdentity[] = [];
for (const record of queryReply.entries ?? []) {
for (const record of (queryReply as RecordsQueryReply).entries ?? []) {
if (record.encodedData) {
const storedIdentity = Convert.base64Url(record.encodedData).toObject() as ManagedIdentity;
storedIdentities.push(storedIdentity);
Expand Down
18 changes: 9 additions & 9 deletions packages/agent/src/store-managed-key.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { RecordsWriteMessage, RecordsWriteOptions } from '@tbd54566975/dwn-sdk-js';
import type { RecordsQueryReply, RecordsWriteMessage, RecordsWriteOptions } from '@tbd54566975/dwn-sdk-js';

import { utils as cryptoUtils } from '@web5/crypto';
import { Convert, removeEmptyObjects, removeUndefinedProperties } from '@web5/common';
Expand Down Expand Up @@ -63,7 +63,7 @@ export class KeyStoreDwn implements ManagedKeyStore<string, ManagedKey | Managed

// Loop through all of the entries and try to find a match.
let matchingRecordId: string | undefined;
for (const record of queryReply.entries ?? []) {
for (const record of (queryReply as RecordsQueryReply).entries ?? []) {
if (record.encodedData) {
const storedKey = this.decodeKey(record.encodedData);
const storedKeyId = isManagedKeyPair(storedKey) ? storedKey.publicKey.id : storedKey.id;
Expand Down Expand Up @@ -103,7 +103,7 @@ export class KeyStoreDwn implements ManagedKeyStore<string, ManagedKey | Managed
const { reply: queryReply} = await this.getKeyRecords(agent, context);

// Loop through all of the entries and return a match, if found.
for (const record of queryReply.entries ?? []) {
for (const record of (queryReply as RecordsQueryReply).entries ?? []) {
if (record.encodedData) {
const storedKey = this.decodeKey(record.encodedData);
if (isManagedKeyPair(storedKey)) {
Expand Down Expand Up @@ -131,7 +131,7 @@ export class KeyStoreDwn implements ManagedKeyStore<string, ManagedKey | Managed
const { reply: queryReply} = await this.getKeyRecords(agent, context);

// Loop through all of the entries and return a match, if found.
for (const record of queryReply.entries ?? []) {
for (const record of (queryReply as RecordsQueryReply).entries ?? []) {
if (record.encodedData) {
const storedKey = this.decodeKey(record.encodedData);
const storedKeyId = isManagedKeyPair(storedKey) ? storedKey.publicKey.id : storedKey.id;
Expand Down Expand Up @@ -200,7 +200,7 @@ export class KeyStoreDwn implements ManagedKeyStore<string, ManagedKey | Managed

// Loop through all of the entries and accumulate the key objects.
let storedKeys: (ManagedKey | ManagedKeyPair)[] = [];
for (const record of queryReply.entries ?? []) {
for (const record of (queryReply as RecordsQueryReply).entries ?? []) {
if (record.encodedData) {
const storedKey = this.decodeKey(record.encodedData);
storedKeys.push(storedKey);
Expand All @@ -226,7 +226,7 @@ export class KeyStoreDwn implements ManagedKeyStore<string, ManagedKey | Managed
// Confirm the key being updated is already present in the store.
let keyToUpdate: ManagedKey | ManagedKeyPair | undefined;
let recordToUpdate: RecordsWriteMessage | undefined;
for (const entry of queryReply.entries ?? []) {
for (const entry of (queryReply as RecordsQueryReply).entries ?? []) {
const { encodedData, ...record } = entry;
if (encodedData) {
const storedKey = this.decodeKey(encodedData);
Expand Down Expand Up @@ -518,7 +518,7 @@ export class PrivateKeyStoreDwn implements ManagedKeyStore<string, ManagedPrivat

// Loop through all of the entries and try to find a match.
let matchingRecordId: string | undefined;
for (const record of queryReply.entries ?? []) {
for (const record of (queryReply as RecordsQueryReply).entries ?? []) {
if (record.encodedData) {
const storedKey = this.decodeKey(record.encodedData);
if (storedKey && storedKey.id === id) {
Expand Down Expand Up @@ -563,7 +563,7 @@ export class PrivateKeyStoreDwn implements ManagedKeyStore<string, ManagedPrivat
const { reply: queryReply} = await this.getKeyRecords(agent, context);

// Loop through all of the entries and return a match, if found.
for (const record of queryReply.entries ?? []) {
for (const record of (queryReply as RecordsQueryReply).entries ?? []) {
if (record.encodedData) {
const storedKey = this.decodeKey(record.encodedData);
if (storedKey.id === id) return storedKey;
Expand Down Expand Up @@ -618,7 +618,7 @@ export class PrivateKeyStoreDwn implements ManagedKeyStore<string, ManagedPrivat

// Loop through all of the entries and accumulate the key objects.
let storedKeys: ManagedPrivateKey[] = [];
for (const record of queryReply.entries ?? []) {
for (const record of (queryReply as RecordsQueryReply).entries ?? []) {
if (record.encodedData) {
const storedKey = this.decodeKey(record.encodedData);
storedKeys.push(storedKey);
Expand Down
Loading

0 comments on commit b1b9b7d

Please sign in to comment.