@@ -7,7 +7,6 @@ const constants = require('./constants');
77const jsonld = require ( 'jsonld' ) ;
88const { extendContextLoader, strictDocumentLoader} = require ( './documentLoader' ) ;
99const { serializeError} = require ( 'serialize-error' ) ;
10- const strictExpansionMap = require ( './expansionMap' ) ;
1110
1211module . exports = class ProofSet {
1312 /**
@@ -35,16 +34,11 @@ module.exports = class ProofSet {
3534 *
3635 * @param [documentLoader] {function} a custom document loader,
3736 * `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.
4337 *
4438 * @return {Promise<object> } resolves with the signed document, with
4539 * the signature in the top-level `proof` property.
4640 */
47- async add ( document , { suite, purpose, documentLoader, expansionMap } = { } ) {
41+ async add ( document , { suite, purpose, documentLoader} = { } ) {
4842 if ( ! suite ) {
4943 throw new TypeError ( '"options.suite" is required.' ) ;
5044 }
@@ -57,9 +51,6 @@ module.exports = class ProofSet {
5751 } else {
5852 documentLoader = strictDocumentLoader ;
5953 }
60- if ( expansionMap !== false ) {
61- expansionMap = strictExpansionMap ;
62- }
6354
6455 // preprocess document to prepare to remove existing proofs
6556 // let input;
@@ -71,7 +62,7 @@ module.exports = class ProofSet {
7162 // create the new proof (suites MUST output a proof using the security-v2
7263 // `@context`)
7364 const proof = await suite . createProof ( {
74- document : input , purpose, documentLoader, expansionMap
65+ document : input , purpose, documentLoader
7566 } ) ;
7667
7768 jsonld . addValue ( document , 'proof' , proof ) ;
@@ -101,19 +92,14 @@ module.exports = class ProofSet {
10192 *
10293 * @param {function } [documentLoader] a custom document loader,
10394 * `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.
10995 *
11096 * @return {Promise<{verified: boolean, results: Array, error: *}> } resolves
11197 * with an object with a `verified`boolean property that is `true` if at
11298 * least one proof matching the given purpose and suite verifies and `false`
11399 * otherwise; a `results` property with an array of detailed results;
114100 * if `false` an `error` property will be present.
115101 */
116- async verify ( document , { suite, purpose, documentLoader, expansionMap } = { } ) {
102+ async verify ( document , { suite, purpose, documentLoader} = { } ) {
117103 if ( ! suite ) {
118104 throw new TypeError ( '"options.suite" is required.' ) ;
119105 }
@@ -130,23 +116,20 @@ module.exports = class ProofSet {
130116 } else {
131117 documentLoader = strictDocumentLoader ;
132118 }
133- if ( expansionMap !== false ) {
134- expansionMap = strictExpansionMap ;
135- }
136119
137120 try {
138121 // shallow copy to allow for removal of proof set prior to canonize
139122 document = { ...document } ;
140123
141124 // get proofs from document
142125 const { proofSet, document : doc } = await _getProofs ( {
143- document, documentLoader, expansionMap
126+ document, documentLoader
144127 } ) ;
145128 document = doc ;
146129
147130 // verify proofs
148131 const results = await _verify ( {
149- document, suites, proofSet, purpose, documentLoader, expansionMap
132+ document, suites, proofSet, purpose, documentLoader
150133 } ) ;
151134 if ( results . length === 0 ) {
152135 const error = new Error (
@@ -197,7 +180,7 @@ async function _getProofs({document}) {
197180}
198181
199182async function _verify ( {
200- document, suites, proofSet, purpose, documentLoader, expansionMap
183+ document, suites, proofSet, purpose, documentLoader
201184} ) {
202185 // map each purpose to at least one proof to verify
203186 const purposes = Array . isArray ( purpose ) ? purpose : [ purpose ] ;
@@ -206,7 +189,7 @@ async function _verify({
206189 const suiteMatchQueue = new Map ( ) ;
207190 await Promise . all ( purposes . map ( purpose => _matchProofSet ( {
208191 purposeToProofs, proofToSuite, purpose, proofSet, suites,
209- suiteMatchQueue, document, documentLoader, expansionMap
192+ suiteMatchQueue, document, documentLoader
210193 } ) ) ) ;
211194
212195 // every purpose must have at least one matching proof or verify will fail
@@ -230,7 +213,7 @@ async function _verify({
230213 }
231214 } ;
232215 const { verified, verificationMethod, error} = await suite . verifyProof ( {
233- proof, document, purpose, documentLoader, expansionMap
216+ proof, document, purpose, documentLoader
234217 } ) ;
235218 if ( ! vm ) {
236219 vm = verificationMethod ;
@@ -264,7 +247,7 @@ async function _verify({
264247 let purposeResult ;
265248 try {
266249 purposeResult = await purpose . validate ( proof , {
267- document, suite, verificationMethod, documentLoader, expansionMap
250+ document, suite, verificationMethod, documentLoader
268251 } ) ;
269252 } catch ( error ) {
270253 purposeResult = { valid : false , error} ;
@@ -312,11 +295,11 @@ function _makeSerializable(error) {
312295
313296async function _matchProofSet ( {
314297 purposeToProofs, proofToSuite, purpose, proofSet, suites,
315- suiteMatchQueue, document, documentLoader, expansionMap
298+ suiteMatchQueue, document, documentLoader
316299} ) {
317300 for ( const proof of proofSet ) {
318301 // 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} ) ) {
320303 continue ;
321304 }
322305
@@ -335,7 +318,7 @@ async function _matchProofSet({
335318 }
336319 let promise = matchingProofs . get ( proof ) ;
337320 if ( ! promise ) {
338- promise = s . matchProof ( { proof, document, documentLoader, expansionMap } ) ;
321+ promise = s . matchProof ( { proof, document, documentLoader} ) ;
339322 matchingProofs . set ( proof , promise ) ;
340323 }
341324 if ( await promise ) {
0 commit comments