Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
createUser(args: { userId: string, parentDevice?: GeneratorDevice, userKeys: tcrypto.SodiumKeyPair, nature: Nature}): CreateUserResult {
const ephemeralKeys = tcrypto.makeSignKeyPair();
const signKeys = tcrypto.makeSignKeyPair();
const encryptionKeys = tcrypto.makeEncryptionKeyPair();
const obfuscatedUserId = obfuscateUserId(this.trustchainId, args.userId);
const delegationBuffer = utils.concatArrays(ephemeralKeys.publicKey, obfuscatedUserId);
let authorPrivateKey = this.appSignKeys.privateKey;
let author = this.root.entry.hash;
if (args.parentDevice) {
// A parent device exists so we are in the add Device case
authorPrivateKey = args.parentDevice.signKeys.privateKey;
author = args.parentDevice.id;
}
let userKeyPair = null;
if (args.nature === NATURE.device_creation_v3) {
userKeyPair = {
public_encryption_key: args.userKeys.publicKey,
encrypted_private_encryption_key: new Uint8Array(SEALED_KEY_SIZE),
};
}
userId(userName: string): Uint8Array {
return obfuscateUserId(this.trustchainId, userName);
}
}