Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handling of diddoc content as string #2028

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading