ts-mls
Version:
[](https://github.com/LukaJCB/ts-mls/actions/workflows/ci.yml) [](https://badge.fury.io/js/ts-mls) [) {
test(`External PSK Join ${cs}`, async () => {
await externalPskJoin(cs);
});
}
async function externalPskJoin(cipherSuite) {
const impl = await getCiphersuiteImpl(getCiphersuiteFromName(cipherSuite));
const aliceCredential = { credentialType: "basic", identity: new TextEncoder().encode("alice") };
const alice = await generateKeyPackage(aliceCredential, defaultCapabilities(), defaultLifetime, [], impl);
const groupId = new TextEncoder().encode("group1");
let aliceGroup = await createGroup(groupId, alice.publicPackage, alice.privatePackage, [], impl);
const bobCredential = { credentialType: "basic", identity: new TextEncoder().encode("bob") };
const bob = await generateKeyPackage(bobCredential, defaultCapabilities(), defaultLifetime, [], impl);
const addBobProposal = {
proposalType: "add",
add: {
keyPackage: bob.publicPackage,
},
};
const pskSecret = impl.rng.randomBytes(impl.kdf.size);
const pskNonce = impl.rng.randomBytes(impl.kdf.size);
const pskId = new TextEncoder().encode("psk-1");
const pskProposal = {
proposalType: "psk",
psk: {
preSharedKeyId: {
psktype: "external",
pskId,
pskNonce,
},
},
};
const base64PskId = bytesToBase64(pskId);
const sharedPsks = { [base64PskId]: pskSecret };
const commitResult = await createCommit(aliceGroup, makePskIndex(aliceGroup, sharedPsks), false, [addBobProposal, pskProposal], impl);
aliceGroup = commitResult.newState;
let bobGroup = await joinGroup(commitResult.welcome, bob.publicPackage, bob.privatePackage, makePskIndex(undefined, sharedPsks), impl, aliceGroup.ratchetTree);
await testEveryoneCanMessageEveryone([aliceGroup, bobGroup], impl);
await checkHpkeKeysMatch(aliceGroup, impl);
await checkHpkeKeysMatch(bobGroup, impl);
}
//# sourceMappingURL=externalPskJoin.test.js.map