ts-mls
Version:
[](https://github.com/LukaJCB/ts-mls/actions/workflows/ci.yml) [](https://badge.fury.io/js/ts-mls) [) {
test(`Custom Extensions ${cs}`, async () => {
await customExtensionTest(cs);
});
}
async function customExtensionTest(cipherSuite) {
const impl = await getCiphersuiteImpl(getCiphersuiteFromName(cipherSuite));
const customExtensionType = 7;
const capabilities = {
extensions: [customExtensionType],
credentials: ["basic"],
proposals: [],
versions: ["mls10"],
ciphersuites: [cipherSuite],
};
const aliceCredential = { credentialType: "basic", identity: new TextEncoder().encode("alice") };
const alice = await generateKeyPackage(aliceCredential, capabilities, defaultLifetime, [], impl);
const groupId = new TextEncoder().encode("group1");
const extensionData = new TextEncoder().encode("custom extension data");
const customExtension = {
extensionType: customExtensionType,
extensionData: extensionData,
};
let aliceGroup = await createGroup(groupId, alice.publicPackage, alice.privatePackage, [customExtension], impl);
const bobCredential = { credentialType: "basic", identity: new TextEncoder().encode("bob") };
const bob = await generateKeyPackage(bobCredential, capabilities, defaultLifetime, [], impl);
const addBobProposal = {
proposalType: "add",
add: {
keyPackage: bob.publicPackage,
},
};
const addBobCommitResult = await createCommit(aliceGroup, emptyPskIndex, false, [addBobProposal], impl);
aliceGroup = addBobCommitResult.newState;
let bobGroup = await joinGroup(addBobCommitResult.welcome, bob.publicPackage, bob.privatePackage, emptyPskIndex, impl, aliceGroup.ratchetTree);
expect(bobGroup.groupContext.extensions.find((e) => e.extensionType === customExtensionType)).toStrictEqual(customExtension);
//Charlie doesn't support the custom extension
const charlieCredential = { credentialType: "basic", identity: new TextEncoder().encode("charlie") };
const charlie = await generateKeyPackage(charlieCredential, defaultCapabilities(), defaultLifetime, [], impl);
const addCharlieProposal = {
proposalType: "add",
add: {
keyPackage: charlie.publicPackage,
},
};
await expect(createCommit(aliceGroup, emptyPskIndex, false, [addCharlieProposal], impl)).rejects.toThrow(ValidationError);
}
//# sourceMappingURL=customExtensions.test.js.map