Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const walletPromise = (async () => {
const wallet = await Wallets.newInMemoryWallet();
const hsmOptions = {
lib: pkcsLibPath,
pin: PKCS11_PIN,
slot: PKCS11_SLOT
};
const hsmProvider = new HsmX509Provider(hsmOptions);
wallet.getProviderRegistry().addProvider(hsmProvider);
const idManager = new IDManager(JSON.parse(ccp.toString()), hsmOptions);
await idManager.initialize();
const adminEnrollment = await idManager.enroll(adminUser, adminSecret);
const adminIdentity = {
credentials: {
certificate: adminEnrollment.certificate,
privateKey: adminEnrollment.key.toBytes()
},
mspId,
type: 'X.509'
};
await wallet.put(adminUser, adminIdentity);