-
Notifications
You must be signed in to change notification settings - Fork 86
feat: changes to the OID4VC issuance workflow required for Credo-0.6.x #1548
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
Merged
shitrerohit
merged 7 commits into
feat/credo6.1-version-upgradation
from
feat/credo6.1-version-upgradation-changes
Jan 31, 2026
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
222631e
WIP:issuance changes
shitrerohit 4704a38
WIP:changes required for SD-JWT issuance
shitrerohit 3a4cc34
fix/removed console log
shitrerohit cc91e3f
fix/resolved code rabbit ai comments
shitrerohit 0e13a81
fix:removed unused variables
shitrerohit 3cc2bb9
feat: update codebase for Credo 6.1 compatibility
shitrerohit 5c7c828
Merge pull request #1553 from credebl/feat/credo6.1-verification-changes
shitrerohit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,12 +3,7 @@ import { oidc_issuer, Prisma } from '@prisma/client'; | |
| import { batchCredentialIssuanceDefault } from '../../constant/issuance'; | ||
| import { CreateOidcCredentialOffer } from '../../interfaces/oid4vc-issuer-sessions.interfaces'; | ||
| import { IssuerResponse } from 'apps/oid4vc-issuance/interfaces/oid4vc-issuance.interfaces'; | ||
| import { | ||
| Claim, | ||
| CredentialAttribute, | ||
| MdocTemplate, | ||
| SdJwtTemplate | ||
| } from 'apps/oid4vc-issuance/interfaces/oid4vc-template.interfaces'; | ||
| import { Claim, MdocTemplate, SdJwtTemplate } from 'apps/oid4vc-issuance/interfaces/oid4vc-template.interfaces'; | ||
| import { CredentialFormat } from '@credebl/enum/enum'; | ||
|
|
||
| type AttributeDisplay = { name: string; locale: string }; | ||
|
|
@@ -44,19 +39,25 @@ type CredentialConfig = { | |
| vct?: string; | ||
| scope: string; | ||
| doctype?: string; | ||
| claims: Claim[]; | ||
| credential_signing_alg_values_supported: string[]; | ||
|
|
||
| credential_signing_alg_values_supported: string[] | number[]; | ||
| cryptographic_binding_methods_supported: string[]; | ||
| display: { name: string; description?: string; locale?: string }[]; | ||
|
|
||
| credential_metadata: { | ||
| claims: Claim[]; | ||
| display: CredentialDisplayItem[]; | ||
| }; | ||
| }; | ||
|
|
||
| type CredentialConfigurationsSupported = { | ||
| credentialConfigurationsSupported: Record<string, CredentialConfig>; | ||
| }; | ||
|
|
||
| // ---- Static Lists (as requested) ---- | ||
| const STATIC_CREDENTIAL_ALGS = ['ES256', 'EdDSA'] as const; | ||
| const STATIC_BINDING_METHODS = ['did:key'] as const; | ||
| const STATIC_CREDENTIAL_ALGS_FOR_SDJWT = ['ES256', 'EdDSA'] as const; | ||
| const STATIC_CREDENTIAL_ALGS_FOR_MDOC = [-7, -9] as const; | ||
| const STATIC_BINDING_METHODS_FOR_SDJWT = ['jwk'] as const; | ||
| const STATIC_BINDING_METHODS_FOR_MDOC = ['cose_key'] as const; // We need to test 'did:key', 'did:web', 'did:jwk', 'jwk', | ||
|
|
||
| // Safe coercion helpers | ||
| function coerceJsonObject<T>(v: Prisma.JsonValue): T | null { | ||
|
|
@@ -243,61 +244,118 @@ export function encodeIssuerPublicId(publicIssuerId: string): string { | |
| /** | ||
| * Recursively builds a nested claims object from a list of attributes. | ||
| */ | ||
| function buildNestedClaims(attributes: CredentialAttribute[]): Record<string, Claim> { | ||
| const claims: Record<string, Claim> = {}; | ||
| // function buildNestedClaims(attributes: CredentialAttribute[]): Record<string, Claim> { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we remove this commented code? |
||
| // const claims: Record<string, Claim> = {}; | ||
|
|
||
| // for (const attr of attributes) { | ||
| // const node: Claim = {}; | ||
|
|
||
| // // ✅ include display info | ||
| // if (attr.display?.length) { | ||
| // node.display = attr.display.map((d) => ({ | ||
| // name: d.name, | ||
| // locale: d.locale | ||
| // })); | ||
| // } | ||
|
|
||
| // // ✅ include mandatory flag | ||
| // if (attr.mandatory) { | ||
| // node.mandatory = true; | ||
| // } | ||
|
|
||
| // // ✅ handle nested children recursively | ||
| // if (attr.children?.length) { | ||
| // const childClaims = buildNestedClaims(attr.children); | ||
| // Object.assign(node, childClaims); // merge children into current node | ||
| // } | ||
|
|
||
| // claims[attr.key] = node; | ||
| // } | ||
|
|
||
| // return claims; | ||
| // } | ||
| // function generateObjects( | ||
| // namespace: string, | ||
| // attributes: any[], | ||
| // parentPath: string[] = [] | ||
| // ): any[] { | ||
| // const result: any[] = []; | ||
|
|
||
| // for (const attr of attributes) { | ||
| // const currentPath = [...parentPath, attr.key]; | ||
|
|
||
| // // If display exists, create object | ||
| // if (attr.display) { | ||
| // result.push({ | ||
| // path: [namespace, ...currentPath], | ||
| // display: attr.display | ||
| // }); | ||
| // } | ||
|
|
||
| // // Recurse into children | ||
| // if (attr.children?.length) { | ||
| // result.push( | ||
| // ...generateObjects(namespace, attr.children, currentPath) | ||
| // ); | ||
| // } | ||
| // } | ||
| // console.log('generateObjects - result', JSON.stringify(result), '\n\n\n'); | ||
| // return result; | ||
| // } | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| function generateClaims(attributes: any[], namespace?: string, parentPath: string[] = []): Claim[] { | ||
| const result: Claim[] = []; | ||
|
|
||
| for (const attr of attributes) { | ||
| const node: Claim = {}; | ||
|
|
||
| // ✅ include display info | ||
| if (attr.display?.length) { | ||
| node.display = attr.display.map((d) => ({ | ||
| name: d.name, | ||
| locale: d.locale | ||
| })); | ||
| const currentPath = [...parentPath, attr.key]; | ||
|
|
||
| const path = namespace ? [namespace, ...currentPath] : currentPath; | ||
|
|
||
| const claim: Claim = { path }; | ||
|
|
||
| if (attr.display) { | ||
| claim.display = attr.display; | ||
| } | ||
|
|
||
| // ✅ include mandatory flag | ||
| if (attr.mandatory) { | ||
| node.mandatory = true; | ||
| if (true === attr.mandatory) { | ||
| claim.mandatory = true; | ||
| } | ||
|
|
||
| // ✅ handle nested children recursively | ||
| // Always push the claim (even if it only has path) | ||
| result.push(claim); | ||
|
|
||
| // Handle nested children | ||
| if (attr.children?.length) { | ||
| const childClaims = buildNestedClaims(attr.children); | ||
| Object.assign(node, childClaims); // merge children into current node | ||
| result.push(...generateClaims(attr.children, namespace, currentPath)); | ||
| } | ||
|
|
||
| claims[attr.key] = node; | ||
| } | ||
|
|
||
| return claims; | ||
| return result; | ||
| } | ||
|
|
||
| /** | ||
| * Builds claims object for both SD-JWT and MDOC credential templates. | ||
| */ | ||
| //TODO: Remove any type | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| function buildClaimsFromTemplate(template: SdJwtTemplate | MdocTemplate): Record<string, any> { | ||
| function buildClaimsFromTemplate(template: SdJwtTemplate | MdocTemplate): Record<string, Claim> | Claim[] { | ||
| // ✅ MDOC case — handle namespaces | ||
| if ((template as MdocTemplate).namespaces) { | ||
| const mdocTemplate = template as MdocTemplate; | ||
|
|
||
| //TODO: Remove any type | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| const claims: Record<string, any> = {}; | ||
|
|
||
| const claims: Claim[] = []; | ||
| for (const ns of mdocTemplate.namespaces) { | ||
| claims[ns.namespace] = buildNestedClaims(ns.attributes); | ||
| } | ||
| const generated = generateClaims(ns.attributes, ns.namespace); | ||
|
|
||
| claims.push(...generated); | ||
| } | ||
| return claims; | ||
| } | ||
|
|
||
| // ✅ SD-JWT case — flat attributes | ||
| const sdjwtTemplate = template as SdJwtTemplate; | ||
| return buildNestedClaims(sdjwtTemplate.attributes); | ||
| const claims = generateClaims(sdjwtTemplate.attributes); | ||
| return claims; | ||
| } | ||
|
|
||
| //TODO: Fix this eslint issue | ||
|
|
@@ -316,14 +374,17 @@ export function buildSdJwtCredentialConfig(name: string, template: SdJwtTemplate | |
| format: CredentialFormat.SdJwtVc, | ||
| scope: credentialScope, | ||
| vct: template.vct, | ||
| credential_signing_alg_values_supported: [...STATIC_CREDENTIAL_ALGS], | ||
| cryptographic_binding_methods_supported: [...STATIC_BINDING_METHODS], | ||
| // proof_types_supported: { | ||
| // jwt: { | ||
| // proof_signing_alg_values_supported: ['ES256'] | ||
| // } | ||
| // }, | ||
| claims | ||
| credential_signing_alg_values_supported: [...STATIC_CREDENTIAL_ALGS_FOR_SDJWT], | ||
| cryptographic_binding_methods_supported: [...STATIC_BINDING_METHODS_FOR_SDJWT], | ||
| proof_types_supported: { | ||
| jwt: { | ||
| proof_signing_alg_values_supported: ['ES256', 'EdDSA'] | ||
| } | ||
| }, | ||
| credential_metadata: { | ||
| claims, | ||
| display: [] | ||
| } | ||
| } | ||
| }; | ||
| } | ||
|
|
@@ -339,7 +400,6 @@ export function buildMdocCredentialConfig(name: string, template: MdocTemplate) | |
| const credentialScope = `openid4vc:${template.doctype}-${formatSuffix}`; | ||
|
|
||
| const claims = buildClaimsFromTemplate(template); | ||
|
|
||
| // for (const ns of template.namespaces) { | ||
| // claims.push(...buildClaimsFromAttributes(ns.attributes, [ns.namespace])); | ||
| // } | ||
|
|
@@ -349,9 +409,17 @@ export function buildMdocCredentialConfig(name: string, template: MdocTemplate) | |
| format: CredentialFormat.Mdoc, | ||
| scope: credentialScope, | ||
| doctype: template.doctype, | ||
| credential_signing_alg_values_supported: [...STATIC_CREDENTIAL_ALGS], | ||
| cryptographic_binding_methods_supported: [...STATIC_BINDING_METHODS], | ||
| claims | ||
| credential_signing_alg_values_supported: [...STATIC_CREDENTIAL_ALGS_FOR_MDOC], | ||
| cryptographic_binding_methods_supported: [...STATIC_BINDING_METHODS_FOR_MDOC], | ||
| proof_types_supported: { | ||
| jwt: { | ||
| proof_signing_alg_values_supported: ['ES256', 'EdDSA'] | ||
| } | ||
| }, | ||
| credential_metadata: { | ||
| claims, | ||
| display: [] | ||
| } | ||
| } | ||
| }; | ||
| } | ||
|
|
@@ -387,7 +455,6 @@ export function buildCredentialConfigurationsSupported(templateRows: any): Recor | |
| templateToBuild, | ||
| format === CredentialFormat.Mdoc ? CredentialFormat.Mdoc : CredentialFormat.SdJwtVc | ||
| ); | ||
|
|
||
| const appearanceJson = coerceJsonObject<unknown>(templateRow.appearance); | ||
|
|
||
| // Prepare the display configuration | ||
|
|
@@ -406,12 +473,11 @@ export function buildCredentialConfigurationsSupported(templateRows: any): Recor | |
|
|
||
| // eslint-disable-next-line prefer-destructuring | ||
| const dynamicKey = Object.keys(credentialConfig)[0]; | ||
| Object.assign(credentialConfig[dynamicKey], { | ||
| Object.assign(credentialConfig[dynamicKey].credential_metadata, { | ||
| display: displayConfigurations | ||
| }); | ||
|
|
||
| Object.assign(credentialConfigMap, credentialConfig); | ||
| } | ||
|
|
||
| return credentialConfigMap; // ✅ Return flat map, not nested object | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.