UNPKG

10.1 kBJavaScriptView Raw
1"use strict";
2/*
3 * Copyright (c) Microsoft Corporation. All rights reserved.
4 * Licensed under the MIT License.
5 */
6Object.defineProperty(exports, "__esModule", { value: true });
7exports.ClientConfigurationError = exports.ClientConfigurationErrorMessage = void 0;
8var tslib_1 = require("tslib");
9var ClientAuthError_1 = require("./ClientAuthError");
10exports.ClientConfigurationErrorMessage = {
11 configurationNotSet: {
12 code: "no_config_set",
13 desc: "Configuration has not been set. Please call the UserAgentApplication constructor with a valid Configuration object."
14 },
15 storageNotSupported: {
16 code: "storage_not_supported",
17 desc: "The value for the cacheLocation is not supported."
18 },
19 noRedirectCallbacksSet: {
20 code: "no_redirect_callbacks",
21 desc: "No redirect callbacks have been set. Please call handleRedirectCallback() with the appropriate function arguments before continuing. " +
22 "More information is available here: https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics."
23 },
24 invalidCallbackObject: {
25 code: "invalid_callback_object",
26 desc: "The object passed for the callback was invalid. " +
27 "More information is available here: https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics."
28 },
29 scopesRequired: {
30 code: "scopes_required",
31 desc: "Scopes are required to obtain an access token."
32 },
33 emptyScopes: {
34 code: "empty_input_scopes_error",
35 desc: "Scopes cannot be passed as empty array."
36 },
37 nonArrayScopes: {
38 code: "nonarray_input_scopes_error",
39 desc: "Scopes cannot be passed as non-array."
40 },
41 invalidPrompt: {
42 code: "invalid_prompt_value",
43 desc: "Supported prompt values are 'login', 'select_account', 'consent' and 'none'",
44 },
45 invalidAuthorityType: {
46 code: "invalid_authority_type",
47 desc: "The given authority is not a valid type of authority supported by MSAL. Please see here for valid authorities: <insert URL here>."
48 },
49 authorityUriInsecure: {
50 code: "authority_uri_insecure",
51 desc: "Authority URIs must use https."
52 },
53 authorityUriInvalidPath: {
54 code: "authority_uri_invalid_path",
55 desc: "Given authority URI is invalid."
56 },
57 unsupportedAuthorityValidation: {
58 code: "unsupported_authority_validation",
59 desc: "The authority validation is not supported for this authority type."
60 },
61 untrustedAuthority: {
62 code: "untrusted_authority",
63 desc: "The provided authority is not a trusted authority. Please include this authority in the knownAuthorities config parameter or set validateAuthority=false."
64 },
65 b2cAuthorityUriInvalidPath: {
66 code: "b2c_authority_uri_invalid_path",
67 desc: "The given URI for the B2C authority is invalid."
68 },
69 b2cKnownAuthoritiesNotSet: {
70 code: "b2c_known_authorities_not_set",
71 desc: "Must set known authorities when validateAuthority is set to True and using B2C"
72 },
73 claimsRequestParsingError: {
74 code: "claims_request_parsing_error",
75 desc: "Could not parse the given claims request object."
76 },
77 emptyRequestError: {
78 code: "empty_request_error",
79 desc: "Request object is required."
80 },
81 invalidCorrelationIdError: {
82 code: "invalid_guid_sent_as_correlationId",
83 desc: "Please set the correlationId as a valid guid"
84 },
85 telemetryConfigError: {
86 code: "telemetry_config_error",
87 desc: "Telemetry config is not configured with required values"
88 },
89 ssoSilentError: {
90 code: "sso_silent_error",
91 desc: "request must contain either sid or login_hint"
92 },
93 invalidAuthorityMetadataError: {
94 code: "authority_metadata_error",
95 desc: "Invalid authorityMetadata. Must be a JSON object containing authorization_endpoint, end_session_endpoint, and issuer fields."
96 }
97};
98/**
99 * Error thrown when there is an error in configuration of the .js library.
100 */
101var ClientConfigurationError = /** @class */ (function (_super) {
102 tslib_1.__extends(ClientConfigurationError, _super);
103 function ClientConfigurationError(errorCode, errorMessage) {
104 var _this = _super.call(this, errorCode, errorMessage) || this;
105 _this.name = "ClientConfigurationError";
106 Object.setPrototypeOf(_this, ClientConfigurationError.prototype);
107 return _this;
108 }
109 ClientConfigurationError.createNoSetConfigurationError = function () {
110 return new ClientConfigurationError(exports.ClientConfigurationErrorMessage.configurationNotSet.code, "" + exports.ClientConfigurationErrorMessage.configurationNotSet.desc);
111 };
112 ClientConfigurationError.createStorageNotSupportedError = function (givenCacheLocation) {
113 return new ClientConfigurationError(exports.ClientConfigurationErrorMessage.storageNotSupported.code, exports.ClientConfigurationErrorMessage.storageNotSupported.desc + " Given location: " + givenCacheLocation);
114 };
115 ClientConfigurationError.createRedirectCallbacksNotSetError = function () {
116 return new ClientConfigurationError(exports.ClientConfigurationErrorMessage.noRedirectCallbacksSet.code, exports.ClientConfigurationErrorMessage.noRedirectCallbacksSet.desc);
117 };
118 ClientConfigurationError.createInvalidCallbackObjectError = function (callbackObject) {
119 return new ClientConfigurationError(exports.ClientConfigurationErrorMessage.invalidCallbackObject.code, exports.ClientConfigurationErrorMessage.invalidCallbackObject.desc + " Given value for callback function: " + callbackObject);
120 };
121 ClientConfigurationError.createEmptyScopesArrayError = function (scopesValue) {
122 return new ClientConfigurationError(exports.ClientConfigurationErrorMessage.emptyScopes.code, exports.ClientConfigurationErrorMessage.emptyScopes.desc + " Given value: " + scopesValue + ".");
123 };
124 ClientConfigurationError.createScopesNonArrayError = function (scopesValue) {
125 return new ClientConfigurationError(exports.ClientConfigurationErrorMessage.nonArrayScopes.code, exports.ClientConfigurationErrorMessage.nonArrayScopes.desc + " Given value: " + scopesValue + ".");
126 };
127 ClientConfigurationError.createScopesRequiredError = function (scopesValue) {
128 return new ClientConfigurationError(exports.ClientConfigurationErrorMessage.scopesRequired.code, exports.ClientConfigurationErrorMessage.scopesRequired.desc + " Given value: " + scopesValue);
129 };
130 ClientConfigurationError.createInvalidPromptError = function (promptValue) {
131 return new ClientConfigurationError(exports.ClientConfigurationErrorMessage.invalidPrompt.code, exports.ClientConfigurationErrorMessage.invalidPrompt.desc + " Given value: " + promptValue);
132 };
133 ClientConfigurationError.createClaimsRequestParsingError = function (claimsRequestParseError) {
134 return new ClientConfigurationError(exports.ClientConfigurationErrorMessage.claimsRequestParsingError.code, exports.ClientConfigurationErrorMessage.claimsRequestParsingError.desc + " Given value: " + claimsRequestParseError);
135 };
136 ClientConfigurationError.createEmptyRequestError = function () {
137 var _a = exports.ClientConfigurationErrorMessage.emptyRequestError, code = _a.code, desc = _a.desc;
138 return new ClientConfigurationError(code, desc);
139 };
140 ClientConfigurationError.createInvalidCorrelationIdError = function () {
141 return new ClientConfigurationError(exports.ClientConfigurationErrorMessage.invalidCorrelationIdError.code, exports.ClientConfigurationErrorMessage.invalidCorrelationIdError.desc);
142 };
143 ClientConfigurationError.createKnownAuthoritiesNotSetError = function () {
144 return new ClientConfigurationError(exports.ClientConfigurationErrorMessage.b2cKnownAuthoritiesNotSet.code, exports.ClientConfigurationErrorMessage.b2cKnownAuthoritiesNotSet.desc);
145 };
146 ClientConfigurationError.createInvalidAuthorityTypeError = function () {
147 return new ClientConfigurationError(exports.ClientConfigurationErrorMessage.invalidAuthorityType.code, exports.ClientConfigurationErrorMessage.invalidAuthorityType.desc);
148 };
149 ClientConfigurationError.createUntrustedAuthorityError = function (host) {
150 return new ClientConfigurationError(exports.ClientConfigurationErrorMessage.untrustedAuthority.code, exports.ClientConfigurationErrorMessage.untrustedAuthority.desc + " Provided Authority: " + host);
151 };
152 ClientConfigurationError.createTelemetryConfigError = function (config) {
153 var _a = exports.ClientConfigurationErrorMessage.telemetryConfigError, code = _a.code, desc = _a.desc;
154 var requiredKeys = {
155 applicationName: "string",
156 applicationVersion: "string",
157 telemetryEmitter: "function"
158 };
159 var missingKeys = Object.keys(requiredKeys)
160 .reduce(function (keys, key) {
161 return config[key] ? keys : keys.concat([key + " (" + requiredKeys[key] + ")"]);
162 }, []);
163 return new ClientConfigurationError(code, desc + " mising values: " + missingKeys.join(","));
164 };
165 ClientConfigurationError.createSsoSilentError = function () {
166 return new ClientConfigurationError(exports.ClientConfigurationErrorMessage.ssoSilentError.code, exports.ClientConfigurationErrorMessage.ssoSilentError.desc);
167 };
168 ClientConfigurationError.createInvalidAuthorityMetadataError = function () {
169 return new ClientConfigurationError(exports.ClientConfigurationErrorMessage.invalidAuthorityMetadataError.code, exports.ClientConfigurationErrorMessage.invalidAuthorityMetadataError.desc);
170 };
171 return ClientConfigurationError;
172}(ClientAuthError_1.ClientAuthError));
173exports.ClientConfigurationError = ClientConfigurationError;
174//# sourceMappingURL=ClientConfigurationError.js.map
\No newline at end of file