fix:badge issuance error due to image data being removed from payload#401
fix:badge issuance error due to image data being removed from payload#401sujitaw wants to merge 1 commit into
Conversation
Signed-off-by: sujitaw <sujit.sutar@ayanworks.com>
📝 WalkthroughWalkthroughThe ChangesW3C Credential Type Flexibility
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/controllers/types.ts (1)
467-474: ⚡ Quick winConsider documenting expected additional properties or defining known fields explicitly.
The index signature
[key: string]: unknownon line 471 successfully allows arbitrary properties (such as image data) to be included in the credential object, which addresses the badge issuance issue. However, this reduces type safety by permitting any property without compile-time validation.If the set of additional properties is known and limited (e.g.,
image,badgeClass, etc.), consider defining them explicitly as optional properties alongside the index signature. This would provide better IntelliSense support and catch typos at compile time while still allowing future extensions.Alternatively, add a JSDoc comment documenting which additional properties are expected or commonly used.
📝 Example: Explicit property definition approach
export type CustomW3cJsonLdSignCredentialOptions = Omit<W3cJsonLdSignCredentialOptions, 'format' | 'credential'> & { credential: Omit<W3cCredential, 'context' | 'credentialSubject'> & { '`@context`': Array<string | Record<string, unknown>> credentialSubject: SingleOrArray<JsonObject> + // Badge/image-related properties + image?: string | JsonObject + // Allow any other additional properties for extensibility [key: string]: unknown } [key: string]: unknown }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/controllers/types.ts` around lines 467 - 474, The CustomW3cJsonLdSignCredentialOptions type currently uses a broad index signature that weakens type safety; update the type definition for CustomW3cJsonLdSignCredentialOptions (and its nested credential property derived from W3cCredential) to explicitly declare expected optional fields (e.g., image?: string | JsonObject, badgeClass?: string, etc.) alongside the existing '`@context`' and credentialSubject properties, keeping the index signature for forward compatibility; also add a brief JSDoc on CustomW3cJsonLdSignCredentialOptions listing commonly used extra fields so editors surface IntelliSense and typos are caught at compile time.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/controllers/types.ts`:
- Around line 467-474: The CustomW3cJsonLdSignCredentialOptions type currently
uses a broad index signature that weakens type safety; update the type
definition for CustomW3cJsonLdSignCredentialOptions (and its nested credential
property derived from W3cCredential) to explicitly declare expected optional
fields (e.g., image?: string | JsonObject, badgeClass?: string, etc.) alongside
the existing '`@context`' and credentialSubject properties, keeping the index
signature for forward compatibility; also add a brief JSDoc on
CustomW3cJsonLdSignCredentialOptions listing commonly used extra fields so
editors surface IntelliSense and typos are caught at compile time.



What
Summary by CodeRabbit