From 5a01075c72183a03b00a0906f8900c70e2dc7a60 Mon Sep 17 00:00:00 2001 From: Daniel Bluhm Date: Wed, 11 Sep 2024 14:43:01 -0400 Subject: [PATCH 1/3] fix: handling of diddoc content as string Signed-off-by: Daniel Bluhm --- packages/indy-vdr/src/dids/didIndyUtil.ts | 13 +++++++++++-- packages/indy-vdr/src/dids/didSovUtil.ts | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/indy-vdr/src/dids/didIndyUtil.ts b/packages/indy-vdr/src/dids/didIndyUtil.ts index ebdfbd98ae..741c3e026e 100644 --- a/packages/indy-vdr/src/dids/didIndyUtil.ts +++ b/packages/indy-vdr/src/dids/didIndyUtil.ts @@ -271,7 +271,16 @@ export async function buildDidDocument(agentContext: AgentContext, pool: IndyVdr } return builder.build() } else { - // Combine it with didDoc (TODO: Check if diddocContent is returned as a JSON object or a string) - return combineDidDocumentWithJson(builder.build(), nym.diddocContent) + // Combine it with didDoc + let diddocContent + try { + diddocContent = JSON.parse(nym.diddocContent) as Record + } catch (error) { + agentContext.config.logger.error( + `Nym diddocContent is not a valid json string: ${diddocContent}` + ) + throw new IndyVdrError(`Nym diddocContent failed to parse as JSON: ${error}`) + } + return combineDidDocumentWithJson(builder.build(), diddocContent) } } diff --git a/packages/indy-vdr/src/dids/didSovUtil.ts b/packages/indy-vdr/src/dids/didSovUtil.ts index aa52580bb2..8cc4297a3c 100644 --- a/packages/indy-vdr/src/dids/didSovUtil.ts +++ b/packages/indy-vdr/src/dids/didSovUtil.ts @@ -25,7 +25,7 @@ export interface GetNymResponseData { verkey: string role: string alias?: string - diddocContent?: Record + diddocContent?: string } export const FULL_VERKEY_REGEX = /^[1-9A-HJ-NP-Za-km-z]{43,44}$/ From 018ae7a6573ea6614531d2367ef266176c559057 Mon Sep 17 00:00:00 2001 From: Daniel Bluhm Date: Wed, 11 Sep 2024 14:54:27 -0400 Subject: [PATCH 2/3] fix: indy resolver test failure Signed-off-by: Daniel Bluhm --- .../indy-vdr/src/dids/__tests__/IndyVdrIndyDidResolver.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/indy-vdr/src/dids/__tests__/IndyVdrIndyDidResolver.test.ts b/packages/indy-vdr/src/dids/__tests__/IndyVdrIndyDidResolver.test.ts index 194ebfd9a6..c027d083d7 100644 --- a/packages/indy-vdr/src/dids/__tests__/IndyVdrIndyDidResolver.test.ts +++ b/packages/indy-vdr/src/dids/__tests__/IndyVdrIndyDidResolver.test.ts @@ -34,7 +34,7 @@ describe('IndyVdrIndyDidResolver', () => { did: 'LjgpST2rjsoxYegQDRm7EL', verkey: 'E6D1m3eERqCueX4ZgMCY14B4NceAr6XP2HyVqt55gDhu', role: 'ENDORSER', - diddocContent: didIndyLjgpST2rjsoxYegQDRm7ELdiddocContent, + diddocContent: JSON.stringify(didIndyLjgpST2rjsoxYegQDRm7ELdiddocContent), }), }, } From a58cc9a9554b0799b80c877871779419f703912b Mon Sep 17 00:00:00 2001 From: Daniel Bluhm Date: Wed, 11 Sep 2024 15:01:37 -0400 Subject: [PATCH 3/3] stlye: fix prettier errors Signed-off-by: Daniel Bluhm --- packages/indy-vdr/src/dids/didIndyUtil.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/indy-vdr/src/dids/didIndyUtil.ts b/packages/indy-vdr/src/dids/didIndyUtil.ts index 741c3e026e..57d2aa0c45 100644 --- a/packages/indy-vdr/src/dids/didIndyUtil.ts +++ b/packages/indy-vdr/src/dids/didIndyUtil.ts @@ -276,9 +276,7 @@ export async function buildDidDocument(agentContext: AgentContext, pool: IndyVdr try { diddocContent = JSON.parse(nym.diddocContent) as Record } catch (error) { - agentContext.config.logger.error( - `Nym diddocContent is not a valid json string: ${diddocContent}` - ) + agentContext.config.logger.error(`Nym diddocContent is not a valid json string: ${diddocContent}`) throw new IndyVdrError(`Nym diddocContent failed to parse as JSON: ${error}`) } return combineDidDocumentWithJson(builder.build(), diddocContent)