Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Generate a capabilityInvocation key, to base the DID URI on
const invokeKey = await LDKeyPair.generate(keyOptions);
const did = this.generateId({keyPair: invokeKey, didType, env});
this.doc.id = did;
// Generate an authentication key pair and suite
const authKey = await LDKeyPair.generate(keyOptions);
authKey.id = `${did}#authn-key-1`;
this.doc[constants.SUITES.authentication] = [
this.generateSuite({key: authKey, suiteId: `${did}#auth-suite-1`})
];
this.keys[authKey.id] = authKey;
// Generate a capabilityDelegation key pair and suite
const delegateKey = await LDKeyPair.generate(keyOptions);
delegateKey.id = `${did}#ocap-delegate-key-1`;
this.doc[constants.SUITES.capabilityDelegation] = [
this.generateSuite({key: delegateKey, suiteId: `${did}#delegate-suite-1`})
];
this.keys[delegateKey.id] = delegateKey;
// Generate a capabilityInvocation suite (from an earlier generated key)
invokeKey.id = `${did}#ocap-invoke-key-1`;
this.doc[constants.SUITES.capabilityInvocation] = [
this.generateSuite({key: invokeKey, suiteId: `${did}#invoke-suite-1`})
];
this.keys[invokeKey.id] = invokeKey;
}
it('should generate a nym type did', async () => {
const didDoc = new VeresOneDidDoc({keyType, didType: 'nym', injector});
const keyOptions = {
type: keyType, injector: didDoc.injector, passphrase: null
};
const keyPair = await LDKeyPair.generate(keyOptions);
const did = didDoc.generateId({keyPair, env: 'dev'});
expect(did).to.match(/^did:v1:test:nym:.*/);
});
});