@digitalbazaar/oid4-client 5.6.0 → 5.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -43,21 +43,38 @@ export function vprGroupsToPresentationDefinition({
43
43
  input_descriptors
44
44
  };
45
45
 
46
+ // if there is more than one group, create submission requirements that will
47
+ // be populated for each group
48
+ let defaultGroupId;
49
+ let submission_requirements;
50
+ if(groupMap.size > 1) {
51
+ defaultGroupId = crypto.randomUUID();
52
+ submission_requirements = [];
53
+ }
54
+
46
55
  let acceptsVpJwt = false;
47
56
  let acceptsVcJwt = false;
48
57
 
49
58
  const ldpVpProofTypes = new Set();
50
59
  const ldpVcProofTypes = new Set();
51
60
  // note: same group ID is logical "AND" and different group ID is "OR"
52
- const groups = [...groupMap.values()];
53
- for(const queries of groups) {
61
+ for(const [groupId, queries] of groupMap.entries()) {
62
+ // add to submission_requirements if present
63
+ if(submission_requirements) {
64
+ submission_requirements.push({
65
+ rule: 'pick',
66
+ count: 1,
67
+ from: groupId ?? defaultGroupId
68
+ });
69
+ }
70
+
54
71
  const queryByExamples = queries.get('QueryByExample');
55
72
 
56
73
  // for each `QueryByExample`, add another input descriptor (for every
57
74
  // "credentialQuery" within it
58
75
  for(const queryByExample of queryByExamples) {
59
76
  // should only be one `credentialQuery` but handle each one as a new
60
- // set of input descriptors
77
+ // input descriptor
61
78
  const all = Array.isArray(queryByExample.credentialQuery) ?
62
79
  queryByExample.credentialQuery : [queryByExample.credentialQuery];
63
80
  for(const credentialQuery of all) {
@@ -87,6 +104,10 @@ export function vprGroupsToPresentationDefinition({
87
104
  }
88
105
  }
89
106
 
107
+ if(submission_requirements) {
108
+ inputDescriptor.group = [submission_requirements.at(-1).from];
109
+ }
110
+
90
111
  input_descriptors.push(inputDescriptor);
91
112
  }
92
113
  }
@@ -108,6 +129,11 @@ export function vprGroupsToPresentationDefinition({
108
129
  }
109
130
  }
110
131
 
132
+ // add `submission_requirements` if
133
+ if(submission_requirements) {
134
+ presentationDefinition.submission_requirements = submission_requirements;
135
+ }
136
+
111
137
  const shouldAddFormat = acceptsVcJwt || acceptsVpJwt ||
112
138
  ldpVcProofTypes.size > 0 || ldpVpProofTypes.size > 0;
113
139
  if(shouldAddFormat && !presentationDefinition.format) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitalbazaar/oid4-client",
3
- "version": "5.6.0",
3
+ "version": "5.6.1",
4
4
  "description": "An OID4 (VC + VP) client",
5
5
  "homepage": "https://github.com/digitalbazaar/oid4-client",
6
6
  "author": {