@@ -7,7 +7,6 @@ const constants = require('./constants');
7
7
const jsonld = require ( '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,20 @@ module.exports = class ProofSet {
130
116
} else {
131
117
documentLoader = strictDocumentLoader ;
132
118
}
133
- if ( expansionMap !== false ) {
134
- expansionMap = strictExpansionMap ;
135
- }
136
119
137
120
try {
138
121
// shallow copy to allow for removal of proof set prior to canonize
139
122
document = { ...document } ;
140
123
141
124
// get proofs from document
142
125
const { proofSet, document : doc } = await _getProofs ( {
143
- document, documentLoader, expansionMap
126
+ document, documentLoader
144
127
} ) ;
145
128
document = doc ;
146
129
147
130
// verify proofs
148
131
const results = await _verify ( {
149
- document, suites, proofSet, purpose, documentLoader, expansionMap
132
+ document, suites, proofSet, purpose, documentLoader
150
133
} ) ;
151
134
if ( results . length === 0 ) {
152
135
const error = new Error (
@@ -197,7 +180,7 @@ async function _getProofs({document}) {
197
180
}
198
181
199
182
async function _verify ( {
200
- document, suites, proofSet, purpose, documentLoader, expansionMap
183
+ document, suites, proofSet, purpose, documentLoader
201
184
} ) {
202
185
// map each purpose to at least one proof to verify
203
186
const purposes = Array . isArray ( purpose ) ? purpose : [ purpose ] ;
@@ -206,7 +189,7 @@ async function _verify({
206
189
const suiteMatchQueue = new Map ( ) ;
207
190
await Promise . all ( purposes . map ( purpose => _matchProofSet ( {
208
191
purposeToProofs, proofToSuite, purpose, proofSet, suites,
209
- suiteMatchQueue, document, documentLoader, expansionMap
192
+ suiteMatchQueue, document, documentLoader
210
193
} ) ) ) ;
211
194
212
195
// every purpose must have at least one matching proof or verify will fail
@@ -230,7 +213,7 @@ async function _verify({
230
213
}
231
214
} ;
232
215
const { verified, verificationMethod, error} = await suite . verifyProof ( {
233
- proof, document, purpose, documentLoader, expansionMap
216
+ proof, document, purpose, documentLoader
234
217
} ) ;
235
218
if ( ! vm ) {
236
219
vm = verificationMethod ;
@@ -264,7 +247,7 @@ async function _verify({
264
247
let purposeResult ;
265
248
try {
266
249
purposeResult = await purpose . validate ( proof , {
267
- document, suite, verificationMethod, documentLoader, expansionMap
250
+ document, suite, verificationMethod, documentLoader
268
251
} ) ;
269
252
} catch ( error ) {
270
253
purposeResult = { valid : false , error} ;
@@ -312,11 +295,11 @@ function _makeSerializable(error) {
312
295
313
296
async function _matchProofSet ( {
314
297
purposeToProofs, proofToSuite, purpose, proofSet, suites,
315
- suiteMatchQueue, document, documentLoader, expansionMap
298
+ suiteMatchQueue, document, documentLoader
316
299
} ) {
317
300
for ( const proof of proofSet ) {
318
301
// first check if the proof matches the purpose; if it doesn't continue
319
- if ( ! await purpose . match ( proof , { document, documentLoader, expansionMap } ) ) {
302
+ if ( ! await purpose . match ( proof , { document, documentLoader} ) ) {
320
303
continue ;
321
304
}
322
305
@@ -335,7 +318,7 @@ async function _matchProofSet({
335
318
}
336
319
let promise = matchingProofs . get ( proof ) ;
337
320
if ( ! promise ) {
338
- promise = s . matchProof ( { proof, document, documentLoader, expansionMap } ) ;
321
+ promise = s . matchProof ( { proof, document, documentLoader} ) ;
339
322
matchingProofs . set ( proof , promise ) ;
340
323
}
341
324
if ( await promise ) {
0 commit comments