@@ -7,7 +7,6 @@ const constants = require('./constants');
7
7
const jsonld = require ( '@digitalcredentials/jsonld' ) ;
8
8
const { extendContextLoader, strictDocumentLoader} = require ( './documentLoader' ) ;
9
9
const { serializeError} = require ( 'serialize-error' ) ;
10
- const strictExpansionMap = require ( './expansionMap' ) ;
11
10
12
11
module . exports = class ProofSet {
13
12
/**
@@ -35,16 +34,11 @@ module.exports = class ProofSet {
35
34
*
36
35
* @param [documentLoader] {function} a custom document loader,
37
36
* `Promise<RemoteDocument> documentLoader(url)`.
38
- * @param [expansionMap] {function} A custom expansion map that is
39
- * passed to the JSON-LD processor; by default a function that will throw
40
- * an error when unmapped properties are detected in the input, use `false`
41
- * to turn this off and allow unmapped properties to be dropped or use a
42
- * custom function.
43
37
*
44
38
* @return {Promise<object> } resolves with the signed document, with
45
39
* the signature in the top-level `proof` property.
46
40
*/
47
- async add ( document , { suite, purpose, documentLoader, expansionMap } = { } ) {
41
+ async add ( document , { suite, purpose, documentLoader} = { } ) {
48
42
if ( ! suite ) {
49
43
throw new TypeError ( '"options.suite" is required.' ) ;
50
44
}
@@ -57,9 +51,6 @@ module.exports = class ProofSet {
57
51
} else {
58
52
documentLoader = strictDocumentLoader ;
59
53
}
60
- if ( expansionMap !== false ) {
61
- expansionMap = strictExpansionMap ;
62
- }
63
54
64
55
// preprocess document to prepare to remove existing proofs
65
56
// let input;
@@ -71,7 +62,7 @@ module.exports = class ProofSet {
71
62
// create the new proof (suites MUST output a proof using the security-v2
72
63
// `@context`)
73
64
const proof = await suite . createProof ( {
74
- document : input , purpose, documentLoader, expansionMap
65
+ document : input , purpose, documentLoader
75
66
} ) ;
76
67
77
68
jsonld . addValue ( document , 'proof' , proof ) ;
@@ -101,19 +92,14 @@ module.exports = class ProofSet {
101
92
*
102
93
* @param {function } [documentLoader] a custom document loader,
103
94
* `Promise<RemoteDocument> documentLoader(url)`.
104
- * @param {function } [expansionMap] - A custom expansion map that is
105
- * passed to the JSON-LD processor; by default a function that will throw
106
- * an error when unmapped properties are detected in the input, use `false`
107
- * to turn this off and allow unmapped properties to be dropped or use a
108
- * custom function.
109
95
*
110
96
* @return {Promise<{verified: boolean, results: Array, error: *}> } resolves
111
97
* with an object with a `verified`boolean property that is `true` if at
112
98
* least one proof matching the given purpose and suite verifies and `false`
113
99
* otherwise; a `results` property with an array of detailed results;
114
100
* if `false` an `error` property will be present.
115
101
*/
116
- async verify ( document , { suite, purpose, documentLoader, expansionMap } = { } ) {
102
+ async verify ( document , { suite, purpose, documentLoader} = { } ) {
117
103
if ( ! suite ) {
118
104
throw new TypeError ( '"options.suite" is required.' ) ;
119
105
}
@@ -130,23 +116,19 @@ module.exports = class ProofSet {
130
116
} else {
131
117
documentLoader = strictDocumentLoader ;
132
118
}
133
- if ( expansionMap !== false ) {
134
- expansionMap = strictExpansionMap ;
135
- }
136
-
137
119
try {
138
120
// shallow copy to allow for removal of proof set prior to canonize
139
121
document = { ...document } ;
140
122
141
123
// get proofs from document
142
124
const { proofSet, document : doc } = await _getProofs ( {
143
- document, documentLoader, expansionMap
125
+ document, documentLoader
144
126
} ) ;
145
127
document = doc ;
146
128
147
129
// verify proofs
148
130
const results = await _verify ( {
149
- document, suites, proofSet, purpose, documentLoader, expansionMap
131
+ document, suites, proofSet, purpose, documentLoader
150
132
} ) ;
151
133
if ( results . length === 0 ) {
152
134
const error = new Error (
@@ -197,7 +179,7 @@ async function _getProofs({document}) {
197
179
}
198
180
199
181
async function _verify ( {
200
- document, suites, proofSet, purpose, documentLoader, expansionMap
182
+ document, suites, proofSet, purpose, documentLoader
201
183
} ) {
202
184
// map each purpose to at least one proof to verify
203
185
const purposes = Array . isArray ( purpose ) ? purpose : [ purpose ] ;
@@ -206,7 +188,7 @@ async function _verify({
206
188
const suiteMatchQueue = new Map ( ) ;
207
189
await Promise . all ( purposes . map ( purpose => _matchProofSet ( {
208
190
purposeToProofs, proofToSuite, purpose, proofSet, suites,
209
- suiteMatchQueue, document, documentLoader, expansionMap
191
+ suiteMatchQueue, document, documentLoader
210
192
} ) ) ) ;
211
193
212
194
// every purpose must have at least one matching proof or verify will fail
@@ -230,7 +212,7 @@ async function _verify({
230
212
}
231
213
} ;
232
214
const { verified, verificationMethod, error} = await suite . verifyProof ( {
233
- proof, document, purpose, documentLoader, expansionMap
215
+ proof, document, purpose, documentLoader
234
216
} ) ;
235
217
if ( ! vm ) {
236
218
vm = verificationMethod ;
@@ -264,7 +246,7 @@ async function _verify({
264
246
let purposeResult ;
265
247
try {
266
248
purposeResult = await purpose . validate ( proof , {
267
- document, suite, verificationMethod, documentLoader, expansionMap
249
+ document, suite, verificationMethod, documentLoader
268
250
} ) ;
269
251
} catch ( error ) {
270
252
purposeResult = { valid : false , error} ;
@@ -312,11 +294,11 @@ function _makeSerializable(error) {
312
294
313
295
async function _matchProofSet ( {
314
296
purposeToProofs, proofToSuite, purpose, proofSet, suites,
315
- suiteMatchQueue, document, documentLoader, expansionMap
297
+ suiteMatchQueue, document, documentLoader
316
298
} ) {
317
299
for ( const proof of proofSet ) {
318
300
// first check if the proof matches the purpose; if it doesn't continue
319
- if ( ! await purpose . match ( proof , { document, documentLoader, expansionMap } ) ) {
301
+ if ( ! await purpose . match ( proof , { document, documentLoader} ) ) {
320
302
continue ;
321
303
}
322
304
@@ -335,7 +317,7 @@ async function _matchProofSet({
335
317
}
336
318
let promise = matchingProofs . get ( proof ) ;
337
319
if ( ! promise ) {
338
- promise = s . matchProof ( { proof, document, documentLoader, expansionMap } ) ;
320
+ promise = s . matchProof ( { proof, document, documentLoader} ) ;
339
321
matchingProofs . set ( proof , promise ) ;
340
322
}
341
323
if ( await promise ) {
0 commit comments