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I,GAAG,MAAM,KAAK,IAAI,YAAc,EAAI,SAChD,WAAW,KACT,CAEV,CAEA,SAAS,YAAY,GACjB,IAAI,EAAI,EACR,IAAK,IAAI,KAAK,EACV,QAAQ,IAAI,KAAK,MAAM,KAAK,OAAO,aAAe,EAAI,SACtD,WAAW,KACT,CAEV,CAEA,SAAS,SAAS,GACd,IAAK,IAAI,KAAK,EACV,QAAQ,IAAI,KAAK,MAAM,KAAK,KAAK,iCACjC,WAAW,EAEnB,CAGA,SAAS,WAAW,GAChB,QAAQ,IAAS,EAAI,MAAQ,KAAO,EAAI,OAAS,WAAa,EAAI,KAAO,KACrE,EAAI,MACJ,QAAQ,IAAI,gBAAkB,EAAI,MAElC,EAAI,MACJ,QAAQ,IAAI,aAAe,EAAI,MAE/B,EAAI,QACJ,QAAQ,IAAI,eAAiB,EAAI,OAEzC,CACA,SAAS,oBAAoB,GACzB,GAAI,EAAI,OAAS,EAAG,CAChB,IAAI,EAAU,GACd,WAAW,EAAK,GAChB,IAAI,EAAS,IAAI,IAAI,IAAI,IACzB,QAAQ,IAAI,+LACZ,IAAK,IAAI,KAAK,EACV,QAAQ,IAAI,OAAS,GAEzB,QAAQ,IAAI,kVACZ,QAAQ,IAAI,yGAChB,CACJ,CACA,SAAS,WAAW,EAAO,GACvB,IAAK,IAAI,KAAK,EAAO,CACjB,IAAI,EAAY,EAAE,MAClB,EAAO,KAAK,EAChB,CACJ,CArGA,QAAQ,iBAAmB","file":"/npm/office-addin-validator@1.0.5/app/util.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/office-addin-validator@1.0.5/app/util.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n * See LICENSE in the project root for license information.\r\n */\r\n\"use strict\";\r\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\r\n    return new (P || (P = Promise))(function (resolve, reject) {\r\n        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n        function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n        function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\r\n        step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n    });\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nconst fs = require(\"fs\");\r\nconst rp = require(\"request-promise\");\r\nconst chalk = require(\"chalk\");\r\nlet baseUri = 'https://verificationservice.osi.office.net/ova/addincheckingagent.svc/api/addincheck';\r\nlet options = {\r\n    uri: baseUri,\r\n    method: 'POST',\r\n    headers: {\r\n        'Content-Type': 'application/xml'\r\n    },\r\n    resolveWithFullResponse: true\r\n};\r\nfunction validateManifest(manifest) {\r\n    return __awaiter(this, void 0, void 0, function* () {\r\n        try {\r\n            console.log('Calling validation service. This might take a moment...');\r\n            let response = yield callOmexService(manifest, options);\r\n            if (response.statusCode === 200) {\r\n                let formattedBody = JSON.parse(response.body.trim());\r\n                let validationReport = formattedBody.checkReport.validationReport;\r\n                let validationResult = validationReport.result;\r\n                console.log('-------------------------------------');\r\n                switch (validationResult) {\r\n                    case 'Passed':\r\n                        // supported products only exist when manifest is valid\r\n                        let supportedProducts = formattedBody.checkReport.details.supportedProducts;\r\n                        console.log(`${chalk.bold('Validation: ')}${chalk.bold.green('Passed')}`);\r\n                        logValidationReport(validationReport.warnings, 'warning');\r\n                        logValidationReport(validationReport.infos, 'info');\r\n                        logSupportedProduct(supportedProducts);\r\n                        break;\r\n                    case 'Failed':\r\n                        console.log(`${chalk.bold('Validation: ')}${chalk.bold.red('Failed')}`);\r\n                        logValidationReport(validationReport.errors, 'error');\r\n                        logValidationReport(validationReport.warnings, 'warning');\r\n                        logValidationReport(validationReport.infos, 'info');\r\n                        break;\r\n                }\r\n                console.log('-------------------------------------');\r\n                return validationResult;\r\n            }\r\n            else {\r\n                logError(response.statusCode);\r\n                return 'Error';\r\n            }\r\n        }\r\n        catch (err) {\r\n            if (err.name === 'RequestError') {\r\n                console.log('-------------------------------------');\r\n                console.log('Error: Cannot reach service.');\r\n                console.log('-------------------------------------');\r\n            }\r\n            else if (err.name === 'StatusCodeError') {\r\n                let statusCode = err.statusCode;\r\n                logError(statusCode);\r\n            }\r\n            else {\r\n                console.log('-------------------------------------');\r\n                console.log('Error: Unexpected error.');\r\n                console.log('-------------------------------------');\r\n            }\r\n            return 'Error';\r\n        }\r\n    });\r\n}\r\nexports.validateManifest = validateManifest;\r\nfunction callOmexService(file, options) {\r\n    return __awaiter(this, void 0, void 0, function* () {\r\n        let fileStream = fs.createReadStream(file);\r\n        let response = yield fileStream.pipe(rp(options));\r\n        return response;\r\n    });\r\n}\r\nfunction logError(statusCode) {\r\n    console.log('-------------------------------------');\r\n    console.log(`${chalk.bold('Validation: ')}${chalk.bold.red('Failed')}`);\r\n    console.log('  Error Code: ' + statusCode);\r\n    console.log(`  ${chalk.bold.red('Error(s): ')}`);\r\n    switch (statusCode) {\r\n        case 400:\r\n            console.log('  Request body does not contain a valid XML document, and/or is too large (capped at 256kb).');\r\n            break;\r\n        case 415:\r\n            console.log('  Content-Type is not set to application/xml.');\r\n            break;\r\n        case 500:\r\n            console.log('  Unexpected error.');\r\n            break;\r\n        case 503:\r\n            console.log('  Service unavailable; API processing has been disabled via BRS.');\r\n            break;\r\n    }\r\n    console.log('-------------------------------------');\r\n}\r\nfunction logValidationReport(obj, name) {\r\n    if (obj.length > 0) {\r\n        switch (name) {\r\n            case 'error':\r\n                logErrors(obj);\r\n                break;\r\n            case 'warning':\r\n                logWarnings(obj);\r\n                break;\r\n            case 'info':\r\n                logInfos(obj);\r\n                break;\r\n        }\r\n    }\r\n}\r\n// Provide detailed error information provided in the validationReport.errors object.\r\nfunction logErrors(errors) {\r\n    let n = 1;\r\n    for (let e of errors) {\r\n        console.log(`${chalk.bold.red('\\nError #' + n + ': ')}`);\r\n        logDetails(e);\r\n        ++n;\r\n    }\r\n}\r\n// Provide detailed warning information provided in the validationReport.warnings object.\r\nfunction logWarnings(warnings) {\r\n    let n = 1;\r\n    for (let w of warnings) {\r\n        console.log(`  ${chalk.bold.yellow('Warning  #' + n + ': ')}`);\r\n        logDetails(w);\r\n        ++n;\r\n    }\r\n}\r\n// Provide detailed additional information provided in the validationReport.infos object.\r\nfunction logInfos(infos) {\r\n    for (let i of infos) {\r\n        console.log(`  ${chalk.bold.blue('  Additional information: ')}`);\r\n        logDetails(i);\r\n    }\r\n}\r\n// Logs out the Code, Column, and/or Line value returned from the validation service.\r\n// param: obj - either an validationReport.errors[x], validationReport.warnings[x], or validationReport.infos[x] object.\r\nfunction logDetails(obj) {\r\n    console.log('' + obj.title + ': ' + obj.detail + ' (link: ' + obj.link + ')');\r\n    if (obj.code) {\r\n        console.log('  - Details: ' + obj.code);\r\n    }\r\n    if (obj.line) {\r\n        console.log('  - Line: ' + obj.line);\r\n    }\r\n    if (obj.column) {\r\n        console.log('  - Column: ' + obj.column);\r\n    }\r\n}\r\nfunction logSupportedProduct(obj) {\r\n    if (obj.length > 0) {\r\n        let product = [];\r\n        getProduct(obj, product);\r\n        let unique = [...new Set(product)];\r\n        console.log(`Based on the requirements specified in your manifest, your add-in can run on the following platforms; your add-in will be tested on these platforms when you submit it to the Office Store:`);\r\n        for (let i of unique) {\r\n            console.log('  - ' + i);\r\n        }\r\n        console.log(`Important: This analysis is based on the requirements specified in your manifest and does not account for any runtime JavaScript calls within your add-in. For information about which API sets and features are supported on each platform, see Office Add-in host and platform availability. (https://dev.office.com/add-in-availability).\\n`);\r\n        console.log(`*This does not include mobile apps. You can opt-in to support mobile apps when you submit your add-in.`);\r\n    }\r\n}\r\nfunction getProduct(array, result) {\r\n    for (let i of array) {\r\n        let itemTitle = i.title;\r\n        result.push(itemTitle);\r\n    }\r\n}\r\n"]}