From 6a144ef998ee16287e7194e93f4ea1178467efc6 Mon Sep 17 00:00:00 2001 From: Liran Cohen Date: Wed, 4 Sep 2024 18:24:41 -0400 Subject: [PATCH] backward compatiblity for registered identities --- packages/agent/src/sync-engine-level.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/agent/src/sync-engine-level.ts b/packages/agent/src/sync-engine-level.ts index eb922406e..f73b67af9 100644 --- a/packages/agent/src/sync-engine-level.ts +++ b/packages/agent/src/sync-engine-level.ts @@ -536,7 +536,16 @@ export class SyncEngineLevel implements SyncEngine { // iterate over all registered identities for await (const [ did, options ] of this._db.sublevel('registeredIdentities').iterator()) { - const { protocols, delegateDid } = JSON.parse(options) as SyncIdentityOptions; + + const { protocols, delegateDid } = await new Promise((resolve) => { + try { + const { protocols, delegateDid } = JSON.parse(options) as SyncIdentityOptions; + resolve({ protocols, delegateDid }); + } catch(error: any) { + resolve({ protocols: [] }); + } + }); + // First, confirm the DID can be resolved and extract the DWN service endpoint URLs. const dwnEndpointUrls = await getDwnServiceEndpointUrls(did, this.agent.did); if (dwnEndpointUrls.length === 0) {