Skip to content

fix: return uniform response envelope for internally and externally endorsed credential definitions #351

@coderabbitai

Description

@coderabbitai

Summary

The createCredentialDefinition endpoint in src/controllers/anoncreds/cred-def/CredentialDefinitionController.ts currently returns only credentialDefinitionState (dropping jobId, credentialDefinitionMetadata, and registrationMetadata) for internally endorsed credential definitions, while all other branches (Wait, Action, external endorsement) return the full RegisterCredentialDefinitionReturn wrapper.

This inconsistency makes the response shape dependent on the endorse flag, which breaks API contract uniformity.

Expected Behaviour

After computing and replacing the unqualified credentialDefinitionId via parseIndyCredentialDefinitionId and getUnqualifiedCredentialDefinitionId, the full registerCredentialDefinitionResult object should be returned (preserving jobId, credentialDefinitionMetadata, and registrationMetadata). The controller/type signature should then be simplified to a single RegisterCredentialDefinitionReturn return type and TSOA artifacts regenerated.

Current Behaviour

// In createCredentialDefinition (internal endorsement path)
return registerCredentialDefinitionResult.credentialDefinitionState  // ❌ drops envelope fields

Proposed Fix

return registerCredentialDefinitionResult  // ✅ preserves full envelope

Note: This change also requires platform-side handling to accommodate the updated response shape.

References

Requested by @GHkrishna

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions