Skip to content

Commit

Permalink
fix: handling of diddoc content as string (#2028)
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Bluhm <dbluhm@pm.me>
  • Loading branch information
dbluhm authored Sep 12, 2024
1 parent 4c1108c commit de7d359
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('IndyVdrIndyDidResolver', () => {
did: 'LjgpST2rjsoxYegQDRm7EL',
verkey: 'E6D1m3eERqCueX4ZgMCY14B4NceAr6XP2HyVqt55gDhu',
role: 'ENDORSER',
diddocContent: didIndyLjgpST2rjsoxYegQDRm7ELdiddocContent,
diddocContent: JSON.stringify(didIndyLjgpST2rjsoxYegQDRm7ELdiddocContent),
}),
},
}
Expand Down
11 changes: 9 additions & 2 deletions packages/indy-vdr/src/dids/didIndyUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,14 @@ 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<string, unknown>
} 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)
}
}
2 changes: 1 addition & 1 deletion packages/indy-vdr/src/dids/didSovUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface GetNymResponseData {
verkey: string
role: string
alias?: string
diddocContent?: Record<string, unknown>
diddocContent?: string
}

export const FULL_VERKEY_REGEX = /^[1-9A-HJ-NP-Za-km-z]{43,44}$/
Expand Down

0 comments on commit de7d359

Please sign in to comment.