How to use the fabric-common/lib/impl/CryptoKeyStore.js function in fabric-common

To help you get started, we’ve selected a few fabric-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hyperledger / fabric-sdk-node / test / unit / crypto-key-store.js View on Github external
const couchdb = CouchdbMock.createServer();
	couchdb.listen(5985);

	// override t.end function so it'll always disconnect the event hub
	t.end = ((context, mockdb, f) => {
		return function() {
			if (mockdb) {
				t.comment('Disconnecting the mock couchdb server');
				mockdb.close();
			}

			f.apply(context, arguments);
		};
	})(t, couchdb, t.end);

	const store = CKS({name: dbname, url: 'http://localhost:5985'});
	store.initialize()
		.then(() => {
			return testKeyStore(store, t);
		}).catch((err) => {
			t.fail(err.stack ? err.stack : err);
			t.end();
		}).then(() => {
			t.end();
		});
});
github hyperledger / fabric-sdk-node / test / unit / crypto-key-store.js View on Github external
const couchdb = CouchdbMock.createServer();
	couchdb.listen(5985);

	// override t.end function so it'll always disconnect the event hub
	t.end = ((context, mockdb, f) => {
		return function() {
			if (mockdb) {
				t.comment('Disconnecting the mock couchdb server');
				mockdb.close();
			}

			f.apply(context, arguments);
		};
	})(t, couchdb, t.end);

	const store = CKS(CouchDBKeyValueStore, {name: dbname, url: 'http://localhost:5985'});
	store.initialize()
		.then(() => {
			return testKeyStore(store, t);
		}).catch((err) => {
			t.fail(err.stack ? err.stack : err);
			t.end();
		}).then(() => {
			t.end();
		});
});
github hyperledger / fabric-sdk-node / test / unit / crypto-key-store.js View on Github external
test('\n\n** CryptoKeyStore tests **\n\n', (t) => {
	testutil.resetDefaults();

	const keystorePath = path.join(testutil.getTempDir(), 'crypto-key-store');

	const store = CKS({path: keystorePath});
	return store.initialize().then(() => {
		store.putKey(testPrivKey).then(() => {
			t.pass('Successfully saved private key in store');

			t.equal(fs.existsSync(path.join(keystorePath, testPrivKey.getSKI() + '-priv')), true,
				'Check that the private key has been saved with the proper -priv index');

			return store.getKey(testPrivKey.getSKI());
		}).then((recoveredKey) => {
			t.notEqual(recoveredKey, null, 'Successfully read private key from store using SKI');
			t.equal(recoveredKey.isPrivate(), true, 'Test if the recovered key is a private key');

			return store.putKey(testPubKey);
		}).then(() => {
			t.equal(fs.existsSync(path.join(keystorePath, testPrivKey.getSKI() + '-pub')), true,
				'Check that the public key has been saved with the proper -pub index');