-
Notifications
You must be signed in to change notification settings - Fork 78
fix: allowed any dcql query support, fixed nested attribute's disclos… #1539
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -96,8 +96,8 @@ export type CredentialOfferPayload = BuiltCredentialOfferBase & | |
| ( | ||
| | { | ||
| preAuthorizedCodeFlowConfig: { | ||
| txCode: { description?: string; length: number; input_mode: 'numeric' | 'text' | 'alphanumeric' }; | ||
| authorizationServerUrl: string; | ||
| txCode: { description?: string; length: number; input_mode: 'numeric' | 'text' | 'alphanumeric' } | undefined; | ||
| authorizationServerUrl?: string; | ||
| }; | ||
| authorizationCodeFlowConfig?: never; | ||
| } | ||
|
Comment on lines
98
to
103
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. 🧩 Analysis chain🏁 Script executed: # First, let's examine the file to see the actual type definitions
cat -n apps/oid4vc-issuance/libs/helpers/credential-sessions.builder.ts | head -120 | tail -30Repository: credebl/platform Length of output: 1186 🏁 Script executed: # Search for preAuthorizedCodeFlowConfig usage
rg -n 'preAuthorizedCodeFlowConfig' --type=ts -C 2Repository: credebl/platform Length of output: 5938 🏁 Script executed: # Search for authorizationServerUrl usage
rg -n 'authorizationServerUrl' --type=ts -C 2Repository: credebl/platform Length of output: 9362 Type definition loosens constraints from input interface, creating inconsistency between contract and implementation. The input interface But the output type This type mismatch is problematic because:
Tighten the type definition to match actual requirements, and correct the misleading comment. 🤖 Prompt for AI Agents |
||
|
|
@@ -225,31 +225,32 @@ export function validatePayloadAgainstTemplate(template: any, payload: any): { v | |
|
|
||
| function buildDisclosureFrameFromTemplate(attributes: CredentialAttribute[]): DisclosureFrame { | ||
| const frame: DisclosureFrame = {}; | ||
| const rootSd: string[] = []; | ||
| const sd: string[] = []; | ||
|
|
||
| for (const attr of attributes) { | ||
| if (!attr.disclose) { | ||
| continue; | ||
| } | ||
|
|
||
| // Case 1: attribute has children → nested disclosure | ||
| if (attr.children && 0 < attr.children.length) { | ||
| const childSd = attr.children.filter((child) => child.disclose).map((child) => child.key); | ||
|
|
||
| if (0 < childSd.length) { | ||
| frame[attr.key] = { | ||
| _sd: childSd | ||
| }; | ||
| const childFrame = | ||
| attr.children && 0 < attr.children.length ? buildDisclosureFrameFromTemplate(attr.children) : undefined; | ||
|
|
||
| const hasChildDisclosure = | ||
| childFrame && (childFrame._sd?.length || Object.keys(childFrame).some((k) => '_sd' !== k)); | ||
|
|
||
| // Case 1: this attribute itself is disclosed | ||
| if (attr.disclose) { | ||
| // If it has children, children are handled separately | ||
| if (!attr.children || 0 === attr.children.length) { | ||
| sd.push(attr.key); | ||
| continue; | ||
| } | ||
| continue; | ||
| } | ||
|
|
||
| // Case 2: simple attribute → root SD | ||
| rootSd.push(attr.key); | ||
| // Case 2: attribute has disclosed children | ||
| if (hasChildDisclosure) { | ||
| frame[attr.key] = childFrame!; | ||
| } | ||
| } | ||
|
|
||
| if (0 < rootSd.length) { | ||
| frame._sd = rootSd; | ||
| if (0 < sd.length) { | ||
| frame._sd = sd; | ||
| } | ||
|
|
||
| return frame; | ||
|
|
@@ -491,7 +492,7 @@ export function buildCredentialOfferPayload( | |
| return { | ||
| ...baseEnvelope, | ||
| preAuthorizedCodeFlowConfig: { | ||
| txCode: DEFAULT_TXCODE, | ||
| txCode: DEFAULT_TXCODE, // Pass undefined to enable no auth implementation, TODO: Need to make it configuarble. | ||
RinkalBhojani marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| authorizationServerUrl: overrideAuthorizationServerUrl | ||
| } | ||
| }; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: credebl/platform
Length of output: 1825
🏁 Script executed:
Repository: credebl/platform
Length of output: 796
🏁 Script executed:
Repository: credebl/platform
Length of output: 607
🏁 Script executed:
Repository: credebl/platform
Length of output: 1826
🏁 Script executed:
Repository: credebl/platform
Length of output: 11588
🏁 Script executed:
Repository: credebl/platform
Length of output: 6613
🏁 Script executed:
Repository: credebl/platform
Length of output: 7643
🏁 Script executed:
Repository: credebl/platform
Length of output: 7550
🏁 Script executed:
Repository: credebl/platform
Length of output: 3343
🏁 Script executed:
Repository: credebl/platform
Length of output: 3311
🏁 Script executed:
Repository: credebl/platform
Length of output: 2387
🏁 Script executed:
Repository: credebl/platform
Length of output: 2598
Remove
unknowntype fromDcqlDto.queryand restore validation decorators.The
queryproperty lacks runtime type validation and transformation. While the parentPresentationRequestDtovalidates thatdcqlis aDcqlDtoinstance, the innerqueryfield accepts any structure without schema validation. This allows malformed or unexpected query structures to propagate to downstream microservices that may not safely handle untyped inputs.Restore the commented decorators (
@ValidateNested(),@Type(() => DcqlQueryDto),@ApiProperty()) to enforce the expected query schema, or if the DCQL specification genuinely requires flexible query structures, replaceunknownwith a union type defining valid alternatives and add explicit schema validation at the service layer.🤖 Prompt for AI Agents