Skip to content

Commit

Permalink
fix: partial matches
Browse files Browse the repository at this point in the history
Signed-off-by: Timo Glastra <[email protected]>
  • Loading branch information
TimoGlastra committed Nov 23, 2024
1 parent cae72f8 commit 12d8eb4
Show file tree
Hide file tree
Showing 15 changed files with 1,396 additions and 935 deletions.
57 changes: 47 additions & 10 deletions lib/evaluation/core/submissionRequirementMatch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Rules } from '@sphereon/pex-models';
import { Status } from '../../ConstraintUtils';

export enum SubmissionRequirementMatchType {
/**
Expand All @@ -20,19 +20,56 @@ export enum SubmissionRequirementMatchType {
* if no submission_requirements are present in the presentation definition. If the match type
* is `InputDescriptor` the {@link SubmissionRequirementMatch.id} property refers to the `id`
* of the `input_descriptors` entry in the presentation definition.
*
* You need to select exactly ONE of the vcs from vc_path in this case for the submission
*/
InputDescriptor = 'InputDescriptor',
}

export interface SubmissionRequirementMatch {
type: SubmissionRequirementMatchType;
id: string | number;
export interface SubmissionRequirementMatchFromNested extends SubmissionRequirementMatchFromBase {
from_nested: Array<SubmissionRequirementMatchFromNested | SubmissionRequirementMatchFrom>;

// Helps with type narrowing
from?: never;
}

export interface SubmissionRequirementMatchFrom extends SubmissionRequirementMatchFromBase {
from: string;

input_descriptors: SubmissionRequirementMatchInputDescriptor[];

// Helps with type narrowing
from_nested?: never;
}

export interface SubmissionRequirementMatchFromBase {
areRequiredCredentialsPresent: Status;
type: SubmissionRequirementMatchType.SubmissionRequirement;
id: number;
name?: string;

rule:
| {
type: 'pick';
count?: number;
min?: number;
max?: number;
}
| {
type: 'all';
count: number;
};
}

export interface SubmissionRequirementMatchInputDescriptor {
areRequiredCredentialsPresent: Status;
id: string;
name?: string;
rule: Rules;
min?: number;
count?: number;
max?: number;
type: SubmissionRequirementMatchType.InputDescriptor;
vc_path: string[];
from?: string;
from_nested?: SubmissionRequirementMatch[];
}

export type SubmissionRequirementMatch =
| SubmissionRequirementMatchFrom
| SubmissionRequirementMatchFromNested
| SubmissionRequirementMatchInputDescriptor;
Loading

0 comments on commit 12d8eb4

Please sign in to comment.