"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.assertDfnsStaffIdentity = exports.assertOrgApiKeyIdentity = exports.assertOrgEmployeeIdentity = exports.isDfnsStaffIdentity = exports.isOrgApiKeyIdentity = exports.isOrgEmployeeIdentity = void 0;
const types_1 = require("../types");
const isOrgEmployeeIdentity = (identity) => identity.kind === types_1.AuthIdentityKind.OrgEmployee;
exports.isOrgEmployeeIdentity = isOrgEmployeeIdentity;
const isOrgApiKeyIdentity = (identity) => identity.kind === types_1.AuthIdentityKind.OrgApiKey;
exports.isOrgApiKeyIdentity = isOrgApiKeyIdentity;
const isDfnsStaffIdentity = (identity) => identity.kind === types_1.AuthIdentityKind.DfnsStaff;
exports.isDfnsStaffIdentity = isDfnsStaffIdentity;
const assertOrgEmployeeIdentity = (identity) => {
    if (!(0, exports.isOrgEmployeeIdentity)(identity)) {
        throwBecauseNotAuthIdentityKind(types_1.AuthIdentityKind.OrgEmployee);
    }
};
exports.assertOrgEmployeeIdentity = assertOrgEmployeeIdentity;
const assertOrgApiKeyIdentity = (identity) => {
    if (!(0, exports.isOrgApiKeyIdentity)(identity)) {
        throwBecauseNotAuthIdentityKind(types_1.AuthIdentityKind.OrgApiKey);
    }
};
exports.assertOrgApiKeyIdentity = assertOrgApiKeyIdentity;
const assertDfnsStaffIdentity = (identity) => {
    if (!(0, exports.isDfnsStaffIdentity)(identity)) {
        throwBecauseNotAuthIdentityKind(types_1.AuthIdentityKind.DfnsStaff);
    }
};
exports.assertDfnsStaffIdentity = assertDfnsStaffIdentity;
const throwBecauseNotAuthIdentityKind = (identityKind) => {
    throw Error(`Auth identity is not of kind ${identityKind}`);
};
//# sourceMappingURL=auth-identity.js.map