"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const src_1 = require("../../src");
const composite_client_1 = require("../../src/clients/composite-client");
describe('CompositeClient', () => {
    describe('validateAuthenticators', () => {
        const network = src_1.Network.staging();
        it('Validates top level AnyOf authenticators', async () => {
            const client = await composite_client_1.CompositeClient.connect(network);
            const auth = {
                type: src_1.AuthenticatorType.ANY_OF,
                config: [
                    { type: src_1.AuthenticatorType.SIGNATURE_VERIFICATION, config: "" },
                    { type: src_1.AuthenticatorType.SIGNATURE_VERIFICATION, config: "" },
                ],
            };
            expect(client.validateAuthenticator(auth)).toEqual(true);
        });
        it('Fails top level AnyOf authenticators with non-signature nested authenticator', async () => {
            const client = await composite_client_1.CompositeClient.connect(network);
            const auth = {
                type: src_1.AuthenticatorType.ANY_OF,
                config: [
                    { type: src_1.AuthenticatorType.SIGNATURE_VERIFICATION, config: "" },
                    { type: src_1.AuthenticatorType.MESSAGE_FILTER, config: "" },
                ],
            };
            expect(client.validateAuthenticator(auth)).toEqual(false);
        });
        it('Validates top level AllOf authenticators', async () => {
            const client = await composite_client_1.CompositeClient.connect(network);
            const auth = {
                type: src_1.AuthenticatorType.ALL_OF,
                config: [
                    { type: src_1.AuthenticatorType.SIGNATURE_VERIFICATION, config: "" },
                    { type: src_1.AuthenticatorType.MESSAGE_FILTER, config: "" },
                ],
            };
            expect(client.validateAuthenticator(auth)).toEqual(true);
        });
        it('Fails top level AllOf authenticators, without signature verification', async () => {
            const client = await composite_client_1.CompositeClient.connect(network);
            const auth = {
                type: src_1.AuthenticatorType.ALL_OF,
                config: [
                    { type: src_1.AuthenticatorType.MESSAGE_FILTER, config: "" },
                    { type: src_1.AuthenticatorType.MESSAGE_FILTER, config: "" },
                ],
            };
            expect(client.validateAuthenticator(auth)).toEqual(false);
        });
        it('Validates nested anyOf authenticators', async () => {
            const client = await composite_client_1.CompositeClient.connect(network);
            const nestedAnyOf = {
                type: src_1.AuthenticatorType.ANY_OF,
                config: [
                    { type: src_1.AuthenticatorType.MESSAGE_FILTER, config: "" },
                    { type: src_1.AuthenticatorType.MESSAGE_FILTER, config: "" },
                ]
            };
            const signatureVerification = {
                type: src_1.AuthenticatorType.SIGNATURE_VERIFICATION,
                config: ""
            };
            const auth = {
                type: src_1.AuthenticatorType.ALL_OF,
                config: [signatureVerification, nestedAnyOf],
            };
            expect(client.validateAuthenticator(auth)).toEqual(true);
        });
        it('Validates nested allOf authenticators', async () => {
            const client = await composite_client_1.CompositeClient.connect(network);
            const nestedAllOf = {
                type: src_1.AuthenticatorType.ALL_OF,
                config: [
                    { type: src_1.AuthenticatorType.SIGNATURE_VERIFICATION, config: "" },
                    { type: src_1.AuthenticatorType.SIGNATURE_VERIFICATION, config: "" },
                ]
            };
            const messageVerification = {
                type: src_1.AuthenticatorType.MESSAGE_FILTER,
                config: ""
            };
            const auth = {
                type: src_1.AuthenticatorType.ALL_OF,
                config: [messageVerification, nestedAllOf],
            };
            expect(client.validateAuthenticator(auth)).toEqual(true);
        });
        it('Fails nested anyOf signatureVerification authenticators', async () => {
            const client = await composite_client_1.CompositeClient.connect(network);
            const nestedAnyOf = {
                type: src_1.AuthenticatorType.ANY_OF,
                config: [
                    { type: src_1.AuthenticatorType.MESSAGE_FILTER, config: "" },
                    { type: src_1.AuthenticatorType.SIGNATURE_VERIFICATION, config: "" },
                ]
            };
            const messageVerification = {
                type: src_1.AuthenticatorType.MESSAGE_FILTER,
                config: ""
            };
            const auth = {
                type: src_1.AuthenticatorType.ALL_OF,
                config: [messageVerification, nestedAnyOf],
            };
            expect(client.validateAuthenticator(auth)).toEqual(false);
        });
        it('Fails nested anyOf authenticators', async () => {
            const client = await composite_client_1.CompositeClient.connect(network);
            const nestedAnyOf = {
                type: src_1.AuthenticatorType.ANY_OF,
                config: [
                    { type: src_1.AuthenticatorType.MESSAGE_FILTER, config: "" },
                    { type: src_1.AuthenticatorType.SIGNATURE_VERIFICATION, config: "" },
                ]
            };
            const messageVerification = {
                type: src_1.AuthenticatorType.MESSAGE_FILTER,
                config: ""
            };
            const auth = {
                type: src_1.AuthenticatorType.ANY_OF,
                config: [messageVerification, nestedAnyOf],
            };
            expect(client.validateAuthenticator(auth)).toEqual(false);
        });
    });
});
//# sourceMappingURL=data:application/json;base64, 