Skip to content
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

fix: partial matches #187

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading