UNPKG

@microsoft/useragent-sdk

Version:

SDK for building decentralized identity wallets and enterprise agents.

56 lines 2.5 kB
"use strict"; /*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ Object.defineProperty(exports, "__esModule", { value: true }); const node_fetch_1 = require("node-fetch"); const UserAgentError_1 = require("../UserAgentError"); /** * Class containing data for displaying an approval prompt in User Agent app. */ class ClaimUIAttributes { /** * Private Constructor for collecting PromptData. * @param claimUIAttributes */ constructor(claimUIAttributes) { this.hexBackgroundColor = claimUIAttributes.hexBackgroundColor; this.hexFontColor = claimUIAttributes.hexFontColor; this.claimName = claimUIAttributes.claimName; this.issuerName = claimUIAttributes.issuerName; this.claimDescriptions = claimUIAttributes.claimDescriptions; this.logo = claimUIAttributes.logo; } /** * Gets prompt data from claimObject in OidcRequest. * note: think about whether this should take in an Claim Object instead. * @param {ClaimObject} claimObject claimObject used to construct PromptData Object. * @returns {PromptData} */ static async create(claimObject) { const claimClass = await this.fetchClaimClass(claimObject.claimClass); const attributes = { hexBackgroundColor: claimClass.hexBackgroundColor, hexFontColor: claimClass.hexFontColor, claimName: claimClass.claimName, issuerName: claimClass.issuerName, claimDescriptions: claimObject.claimDescriptions, logo: claimClass.claimLogo }; return new ClaimUIAttributes(attributes); } /** * Get Claim Class from Endpoint. * @param {string} claimClassUrl url that contains claim class. */ static async fetchClaimClass(claimClassUrl) { const response = await node_fetch_1.default(claimClassUrl); if (response.status !== 200) { throw new UserAgentError_1.default(`Failed to GET claim class at: ${claimClassUrl}`); } return response.json(); } } exports.default = ClaimUIAttributes; //# sourceMappingURL=ClaimUIAttributes.js.map