Use combined username link API

This commit is contained in:
Fedor Indutny 2023-07-21 01:19:32 +02:00 committed by GitHub
parent 82e058f2b8
commit 13193649d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 63 additions and 42 deletions

View file

@ -222,18 +222,15 @@ describe('pnp/username', function needsName() {
const linkUuid = bufferToUuid(Buffer.from(usernameLink.serverId));
const encryptedLinkBase64 = await server.lookupByUsernameLink(linkUuid);
if (!encryptedLinkBase64) {
const encryptedLink = await server.lookupByUsernameLink(linkUuid);
if (!encryptedLink) {
throw new Error('Could not find link on the sever');
}
const encryptedLink = Buffer.from(encryptedLinkBase64, 'base64');
const link = new usernames.UsernameLink(
Buffer.from(usernameLink.entropy),
encryptedLink
);
const linkUsername = link.decryptUsername();
const linkUsername = usernames.decryptUsernameLink({
entropy: Buffer.from(usernameLink.entropy),
encryptedUsername: encryptedLink,
});
assert.strictEqual(linkUsername, username);
state = newState;