From a936d282bdd55289f5f5ed569a481373ed123813 Mon Sep 17 00:00:00 2001
From: Aaron Reed <aaronr@us.ibm.com>
Date: Thu, 14 May 2020 17:26:55 -0400
Subject: [PATCH] added support for querying proof schemas using query object. 
 Bug IBM-Blockchain-Identity/openssi-websdk#10

---
 nodejs/sdk.js       |  7 ++++---
 nodejs/test/test.js | 11 +++++++++++
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/nodejs/sdk.js b/nodejs/sdk.js
index 08121b0..1d19197 100644
--- a/nodejs/sdk.js
+++ b/nodejs/sdk.js
@@ -773,9 +773,10 @@ class Agent {
 
 		this.logger.info('Getting proof schemas');
 		this.logger.info(`Getting proof schemas that match: ${query}`);
-		let r = await this.request('proof_schemas');
+		let r = await this.request(`proof_schemas${query}`);
+this.logger.info(`r: ${JSON.stringify(r)}`);
 		if (r.items) r = r.items;
-		this.logger.info(`Got ${r.length} credential definitions`);
+		this.logger.info(`Got ${r.length} proof schemas`);
 		this.logger.debug('Result from getProofSchemas: '+jsonPrint(r));
 		return r;
 	}
@@ -1874,4 +1875,4 @@ class Agent {
 
 module.exports = {
 	Agent: Agent
-};
\ No newline at end of file
+};
diff --git a/nodejs/test/test.js b/nodejs/test/test.js
index 9cfca36..73451ce 100644
--- a/nodejs/test/test.js
+++ b/nodejs/test/test.js
@@ -196,6 +196,17 @@ describe('sdk', () => {
 		expect(proofSchema).to.not.be.undefined;
 	});
 
+	it(`should get proof schemas from '${verifierName}'`, async () => {
+		let foundProofSchemaArray = await verifier.verifierGetProofSchemas();
+		expect(foundProofSchemaArray).to.not.be.undefined;
+		expect(foundProofSchemaArray.length).to.be.greaterThan(0);
+
+		foundProofSchemaArray = await verifier.verifierGetProofSchemas({id: proofSchema.id});
+		expect(foundProofSchemaArray).to.not.be.undefined;
+		expect(foundProofSchemaArray.length).to.be.equal(1);
+		expect(foundProofSchemaArray[0].id).to.be.equal(proofSchema.id);
+	});
+
 	it(`should connect '${holderName}' to '${verifierName}'`, async () => {
 		pairwiseDid = await connect(holder, holderIdentity, verifier, verifierIdentity);
 	});