How to use the @tanker/identity.obfuscateUserId function in @tanker/identity

To help you get started, we’ve selected a few @tanker/identity 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 TankerHQ / sdk-js / packages / core / src / __tests__ / Generator.js View on Github external
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),
      };
    }
github TankerHQ / sdk-js / packages / core / src / __tests__ / Generator.js View on Github external
userId(userName: string): Uint8Array {
    return obfuscateUserId(this.trustchainId, userName);
  }
}