botframework-connector
Version:
Bot Connector is autorest generated connector client.
49 lines • 1.64 kB
JavaScript
;
/**
* @module botframework-connector
*/
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.ClaimsIdentity = void 0;
/**
* Represents a claims-based identity.
*/
class ClaimsIdentity {
/**
* Initializes a new instance of the [ClaimsIdentity](xref:botframework-connector.ClaimsIdentity) class.
*
* @param {Claim[]} claims An array of [Claim](xref:botframework-connector.Claim).
* @param {string | boolean} authenticationType The type of auth for this set of claims, or boolean to override isAuthenticated
*/
constructor(claims, authenticationType) {
this.claims = claims;
this.authenticationType = authenticationType;
}
/**
* Returns authentication status.
*
* @returns True if is authenticated.
*/
get isAuthenticated() {
if (typeof this.authenticationType === 'boolean') {
return this.authenticationType;
}
return this.authenticationType != null;
}
/**
* Returns a claim value (if its present)
*
* @param {string} claimType The claim type to look for
* @returns {string|null} The claim value or null if not found
*/
getClaimValue(claimType) {
var _a;
const claim = this.claims.find((c) => c.type === claimType);
return (_a = claim === null || claim === void 0 ? void 0 : claim.value) !== null && _a !== void 0 ? _a : null;
}
}
exports.ClaimsIdentity = ClaimsIdentity;
//# sourceMappingURL=claimsIdentity.js.map