Commit 3a84cbd5 authored by Ahmet Turan Koçak's avatar Ahmet Turan Koçak
Browse files

Initial commit

parents
/*! @azure/msal-common v9.0.1 2022-12-07 */
'use strict';
import { StringUtils } from '../utils/StringUtils.js';
import { Constants } from '../utils/Constants.js';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
/**
* Log message level.
*/
var LogLevel;
(function (LogLevel) {
LogLevel[LogLevel["Error"] = 0] = "Error";
LogLevel[LogLevel["Warning"] = 1] = "Warning";
LogLevel[LogLevel["Info"] = 2] = "Info";
LogLevel[LogLevel["Verbose"] = 3] = "Verbose";
LogLevel[LogLevel["Trace"] = 4] = "Trace";
})(LogLevel || (LogLevel = {}));
/**
* Class which facilitates logging of messages to a specific place.
*/
var Logger = /** @class */ (function () {
function Logger(loggerOptions, packageName, packageVersion) {
// Current log level, defaults to info.
this.level = LogLevel.Info;
var defaultLoggerCallback = function () {
return;
};
this.localCallback = loggerOptions.loggerCallback || defaultLoggerCallback;
this.piiLoggingEnabled = loggerOptions.piiLoggingEnabled || false;
this.level = typeof (loggerOptions.logLevel) === "number" ? loggerOptions.logLevel : LogLevel.Info;
this.correlationId = loggerOptions.correlationId || Constants.EMPTY_STRING;
this.packageName = packageName || Constants.EMPTY_STRING;
this.packageVersion = packageVersion || Constants.EMPTY_STRING;
}
/**
* Create new Logger with existing configurations.
*/
Logger.prototype.clone = function (packageName, packageVersion, correlationId) {
return new Logger({ loggerCallback: this.localCallback, piiLoggingEnabled: this.piiLoggingEnabled, logLevel: this.level, correlationId: correlationId || this.correlationId }, packageName, packageVersion);
};
/**
* Log message with required options.
*/
Logger.prototype.logMessage = function (logMessage, options) {
if ((options.logLevel > this.level) || (!this.piiLoggingEnabled && options.containsPii)) {
return;
}
var timestamp = new Date().toUTCString();
// Add correlationId to logs if set, correlationId provided on log messages take precedence
var logHeader;
if (!StringUtils.isEmpty(options.correlationId)) {
logHeader = "[" + timestamp + "] : [" + options.correlationId + "]";
}
else if (!StringUtils.isEmpty(this.correlationId)) {
logHeader = "[" + timestamp + "] : [" + this.correlationId + "]";
}
else {
logHeader = "[" + timestamp + "]";
}
var log = logHeader + " : " + this.packageName + "@" + this.packageVersion + " : " + LogLevel[options.logLevel] + " - " + logMessage;
// debug(`msal:${LogLevel[options.logLevel]}${options.containsPii ? "-Pii": Constants.EMPTY_STRING}${options.context ? `:${options.context}` : Constants.EMPTY_STRING}`)(logMessage);
this.executeCallback(options.logLevel, log, options.containsPii || false);
};
/**
* Execute callback with message.
*/
Logger.prototype.executeCallback = function (level, message, containsPii) {
if (this.localCallback) {
this.localCallback(level, message, containsPii);
}
};
/**
* Logs error messages.
*/
Logger.prototype.error = function (message, correlationId) {
this.logMessage(message, {
logLevel: LogLevel.Error,
containsPii: false,
correlationId: correlationId || Constants.EMPTY_STRING
});
};
/**
* Logs error messages with PII.
*/
Logger.prototype.errorPii = function (message, correlationId) {
this.logMessage(message, {
logLevel: LogLevel.Error,
containsPii: true,
correlationId: correlationId || Constants.EMPTY_STRING
});
};
/**
* Logs warning messages.
*/
Logger.prototype.warning = function (message, correlationId) {
this.logMessage(message, {
logLevel: LogLevel.Warning,
containsPii: false,
correlationId: correlationId || Constants.EMPTY_STRING
});
};
/**
* Logs warning messages with PII.
*/
Logger.prototype.warningPii = function (message, correlationId) {
this.logMessage(message, {
logLevel: LogLevel.Warning,
containsPii: true,
correlationId: correlationId || Constants.EMPTY_STRING
});
};
/**
* Logs info messages.
*/
Logger.prototype.info = function (message, correlationId) {
this.logMessage(message, {
logLevel: LogLevel.Info,
containsPii: false,
correlationId: correlationId || Constants.EMPTY_STRING
});
};
/**
* Logs info messages with PII.
*/
Logger.prototype.infoPii = function (message, correlationId) {
this.logMessage(message, {
logLevel: LogLevel.Info,
containsPii: true,
correlationId: correlationId || Constants.EMPTY_STRING
});
};
/**
* Logs verbose messages.
*/
Logger.prototype.verbose = function (message, correlationId) {
this.logMessage(message, {
logLevel: LogLevel.Verbose,
containsPii: false,
correlationId: correlationId || Constants.EMPTY_STRING
});
};
/**
* Logs verbose messages with PII.
*/
Logger.prototype.verbosePii = function (message, correlationId) {
this.logMessage(message, {
logLevel: LogLevel.Verbose,
containsPii: true,
correlationId: correlationId || Constants.EMPTY_STRING
});
};
/**
* Logs trace messages.
*/
Logger.prototype.trace = function (message, correlationId) {
this.logMessage(message, {
logLevel: LogLevel.Trace,
containsPii: false,
correlationId: correlationId || Constants.EMPTY_STRING
});
};
/**
* Logs trace messages with PII.
*/
Logger.prototype.tracePii = function (message, correlationId) {
this.logMessage(message, {
logLevel: LogLevel.Trace,
containsPii: true,
correlationId: correlationId || Constants.EMPTY_STRING
});
};
/**
* Returns whether PII Logging is enabled or not.
*/
Logger.prototype.isPiiLoggingEnabled = function () {
return this.piiLoggingEnabled || false;
};
return Logger;
}());
export { LogLevel, Logger };
//# sourceMappingURL=Logger.js.map
{"version":3,"file":"Logger.js","sources":["../../src/logger/Logger.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { StringUtils } from \"../utils/StringUtils\";\nimport { LoggerOptions } from \"../config/ClientConfiguration\";\nimport { Constants } from \"../utils/Constants\";\n\n/**\n * Options for logger messages.\n */\nexport type LoggerMessageOptions = {\n logLevel: LogLevel,\n containsPii?: boolean,\n context?: string,\n correlationId?: string\n};\n\n/**\n * Log message level.\n */\nexport enum LogLevel {\n Error,\n Warning,\n Info,\n Verbose,\n Trace\n}\n\n/**\n * Callback to send the messages to.\n */\nexport interface ILoggerCallback {\n (level: LogLevel, message: string, containsPii: boolean): void;\n}\n\n/**\n * Class which facilitates logging of messages to a specific place.\n */\nexport class Logger {\n\n // Correlation ID for request, usually set by user.\n private correlationId: string;\n\n // Current log level, defaults to info.\n private level: LogLevel = LogLevel.Info;\n\n // Boolean describing whether PII logging is allowed.\n private piiLoggingEnabled: boolean;\n\n // Callback to send messages to.\n private localCallback: ILoggerCallback;\n\n // Package name implementing this logger\n private packageName: string;\n\n // Package version implementing this logger\n private packageVersion: string;\n\n constructor(loggerOptions: LoggerOptions, packageName?: string, packageVersion?: string) {\n const defaultLoggerCallback = () => {\n return;\n };\n this.localCallback = loggerOptions.loggerCallback || defaultLoggerCallback;\n this.piiLoggingEnabled = loggerOptions.piiLoggingEnabled || false;\n this.level = typeof(loggerOptions.logLevel) === \"number\" ? loggerOptions.logLevel : LogLevel.Info;\n this.correlationId = loggerOptions.correlationId || Constants.EMPTY_STRING;\n\n this.packageName = packageName || Constants.EMPTY_STRING;\n this.packageVersion = packageVersion || Constants.EMPTY_STRING;\n }\n\n /**\n * Create new Logger with existing configurations.\n */\n public clone(packageName: string, packageVersion: string, correlationId?: string): Logger {\n return new Logger({loggerCallback: this.localCallback, piiLoggingEnabled: this.piiLoggingEnabled, logLevel: this.level, correlationId: correlationId || this.correlationId}, packageName, packageVersion);\n }\n\n /**\n * Log message with required options.\n */\n private logMessage(logMessage: string, options: LoggerMessageOptions): void {\n if ((options.logLevel > this.level) || (!this.piiLoggingEnabled && options.containsPii)) {\n return;\n }\n const timestamp = new Date().toUTCString();\n\n // Add correlationId to logs if set, correlationId provided on log messages take precedence\n let logHeader: string;\n if (!StringUtils.isEmpty(options.correlationId)) {\n logHeader = `[${timestamp}] : [${options.correlationId}]`;\n } else if (!StringUtils.isEmpty(this.correlationId)) {\n logHeader = `[${timestamp}] : [${this.correlationId}]`;\n } else {\n logHeader = `[${timestamp}]`;\n }\n\n const log = `${logHeader} : ${this.packageName}@${this.packageVersion} : ${LogLevel[options.logLevel]} - ${logMessage}`;\n // debug(`msal:${LogLevel[options.logLevel]}${options.containsPii ? \"-Pii\": Constants.EMPTY_STRING}${options.context ? `:${options.context}` : Constants.EMPTY_STRING}`)(logMessage);\n this.executeCallback(options.logLevel, log, options.containsPii || false);\n }\n\n /**\n * Execute callback with message.\n */\n executeCallback(level: LogLevel, message: string, containsPii: boolean): void {\n if (this.localCallback) {\n this.localCallback(level, message, containsPii);\n }\n }\n\n /**\n * Logs error messages.\n */\n error(message: string, correlationId?: string): void {\n this.logMessage(message, {\n logLevel: LogLevel.Error,\n containsPii: false,\n correlationId: correlationId || Constants.EMPTY_STRING\n });\n }\n\n /**\n * Logs error messages with PII.\n */\n errorPii(message: string, correlationId?: string): void {\n this.logMessage(message, {\n logLevel: LogLevel.Error,\n containsPii: true,\n correlationId: correlationId || Constants.EMPTY_STRING\n });\n }\n\n /**\n * Logs warning messages.\n */\n warning(message: string, correlationId?: string): void {\n this.logMessage(message, {\n logLevel: LogLevel.Warning,\n containsPii: false,\n correlationId: correlationId || Constants.EMPTY_STRING\n });\n }\n\n /**\n * Logs warning messages with PII.\n */\n warningPii(message: string, correlationId?: string): void {\n this.logMessage(message, {\n logLevel: LogLevel.Warning,\n containsPii: true,\n correlationId: correlationId || Constants.EMPTY_STRING\n });\n }\n\n /**\n * Logs info messages.\n */\n info(message: string, correlationId?: string): void {\n this.logMessage(message, {\n logLevel: LogLevel.Info,\n containsPii: false,\n correlationId: correlationId || Constants.EMPTY_STRING\n });\n }\n\n /**\n * Logs info messages with PII.\n */\n infoPii(message: string, correlationId?: string): void {\n this.logMessage(message, {\n logLevel: LogLevel.Info,\n containsPii: true,\n correlationId: correlationId || Constants.EMPTY_STRING\n });\n }\n\n /**\n * Logs verbose messages.\n */\n verbose(message: string, correlationId?: string): void {\n this.logMessage(message, {\n logLevel: LogLevel.Verbose,\n containsPii: false,\n correlationId: correlationId || Constants.EMPTY_STRING\n });\n }\n\n /**\n * Logs verbose messages with PII.\n */\n verbosePii(message: string, correlationId?: string): void {\n this.logMessage(message, {\n logLevel: LogLevel.Verbose,\n containsPii: true,\n correlationId: correlationId || Constants.EMPTY_STRING\n });\n }\n\n /**\n * Logs trace messages.\n */\n trace(message: string, correlationId?: string): void {\n this.logMessage(message, {\n logLevel: LogLevel.Trace,\n containsPii: false,\n correlationId: correlationId || Constants.EMPTY_STRING\n });\n }\n\n /**\n * Logs trace messages with PII.\n */\n tracePii(message: string, correlationId?: string): void {\n this.logMessage(message, {\n logLevel: LogLevel.Trace,\n containsPii: true,\n correlationId: correlationId || Constants.EMPTY_STRING\n });\n }\n\n /**\n * Returns whether PII Logging is enabled or not.\n */\n isPiiLoggingEnabled(): boolean {\n return this.piiLoggingEnabled || false;\n }\n}\n"],"names":[],"mappings":";;;;;AAAA;;;AAGG;AAgBH;;AAEG;IACS,SAMX;AAND,CAAA,UAAY,QAAQ,EAAA;AAChB,IAAA,QAAA,CAAA,QAAA,CAAA,OAAA,CAAA,GAAA,CAAA,CAAA,GAAA,OAAK,CAAA;AACL,IAAA,QAAA,CAAA,QAAA,CAAA,SAAA,CAAA,GAAA,CAAA,CAAA,GAAA,SAAO,CAAA;AACP,IAAA,QAAA,CAAA,QAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAI,CAAA;AACJ,IAAA,QAAA,CAAA,QAAA,CAAA,SAAA,CAAA,GAAA,CAAA,CAAA,GAAA,SAAO,CAAA;AACP,IAAA,QAAA,CAAA,QAAA,CAAA,OAAA,CAAA,GAAA,CAAA,CAAA,GAAA,OAAK,CAAA;AACT,CAAC,EANW,QAAQ,KAAR,QAAQ,GAMnB,EAAA,CAAA,CAAA,CAAA;AASD;;AAEG;AACH,IAAA,MAAA,kBAAA,YAAA;AAoBI,IAAA,SAAA,MAAA,CAAY,aAA4B,EAAE,WAAoB,EAAE,cAAuB,EAAA;;AAd/E,QAAA,IAAA,CAAA,KAAK,GAAa,QAAQ,CAAC,IAAI,CAAC;AAepC,QAAA,IAAM,qBAAqB,GAAG,YAAA;YAC1B,OAAO;AACX,SAAC,CAAC;QACF,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC,cAAc,IAAI,qBAAqB,CAAC;QAC3E,IAAI,CAAC,iBAAiB,GAAG,aAAa,CAAC,iBAAiB,IAAI,KAAK,CAAC;QAClE,IAAI,CAAC,KAAK,GAAG,QAAO,aAAa,CAAC,QAAQ,CAAC,KAAK,QAAQ,GAAG,aAAa,CAAC,QAAQ,GAAG,QAAQ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AAmB,GAAnB,YAAA;AACI,QAAA,OAAO,IAAI,CAAC,iBAAiB,IAAI,KAAK,CAAC;KAC1C,CAAA;IACL,OAAC,MAAA,CAAA;AAAD,CAAC,EAAA;;;;"}
\ No newline at end of file
{"version":3,"file":"INetworkModule.d.ts","sourceRoot":"","sources":["../../src/network/INetworkModule.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;GAEG;AACH,oBAAY,qBAAqB,GAAG;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,cAAc;IAE3B;;;;;OAKG;IACH,mBAAmB,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB,EAAE,iBAAiB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IAE9H;;;;;OAKG;IACH,oBAAoB,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;CACtG;AAED,eAAO,MAAM,oBAAoB,EAAE,cASlC,CAAC"}
\ No newline at end of file
/*! @azure/msal-common v9.0.1 2022-12-07 */
'use strict';
import { AuthError } from '../error/AuthError.js';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
var StubbedNetworkModule = {
sendGetRequestAsync: function () {
var notImplErr = "Network interface - sendGetRequestAsync() has not been implemented for the Network interface.";
return Promise.reject(AuthError.createUnexpectedError(notImplErr));
},
sendPostRequestAsync: function () {
var notImplErr = "Network interface - sendPostRequestAsync() has not been implemented for the Network interface.";
return Promise.reject(AuthError.createUnexpectedError(notImplErr));
}
};
export { StubbedNetworkModule };
//# sourceMappingURL=INetworkModule.js.map
{"version":3,"file":"INetworkModule.js","sources":["../../src/network/INetworkModule.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AuthError } from \"../error/AuthError\";\nimport { NetworkResponse } from \"./NetworkManager\";\n\n/**\n * Options allowed by network request APIs.\n */\nexport type NetworkRequestOptions = {\n headers?: Record<string, string>,\n body?: string;\n proxyUrl?: string;\n};\n\n/**\n * Client network interface to send backend requests.\n * @interface\n */\nexport interface INetworkModule {\n\n /**\n * Interface function for async network \"GET\" requests. Based on the Fetch standard: https://fetch.spec.whatwg.org/\n * @param url\n * @param requestParams\n * @param enableCaching\n */\n sendGetRequestAsync<T>(url: string, options?: NetworkRequestOptions, cancellationToken?: number): Promise<NetworkResponse<T>>;\n\n /**\n * Interface function for async network \"POST\" requests. Based on the Fetch standard: https://fetch.spec.whatwg.org/\n * @param url\n * @param requestParams\n * @param enableCaching\n */\n sendPostRequestAsync<T>(url: string, options?: NetworkRequestOptions): Promise<NetworkResponse<T>>;\n}\n\nexport const StubbedNetworkModule: INetworkModule = {\n sendGetRequestAsync: () => {\n const notImplErr = \"Network interface - sendGetRequestAsync() has not been implemented for the Network interface.\";\n return Promise.reject(AuthError.createUnexpectedError(notImplErr));\n },\n sendPostRequestAsync: () => {\n const notImplErr = \"Network interface - sendPostRequestAsync() has not been implemented for the Network interface.\";\n return Promise.reject(AuthError.createUnexpectedError(notImplErr));\n }\n};\n"],"names":[],"mappings":";;;;AAAA;;;AAGG;AAqCU,IAAA,oBAAoB,GAAmB;AAChD,IAAA,mBAAmB,EAAE,YAAA;QACjB,IAAM,UAAU,GAAG,+FAA+F,CAAC;QACnH,OAAO,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,CAAC;KACtE;AACD,IAAA,oBAAoB,EAAE,YAAA;QAClB,IAAM,UAAU,GAAG,gGAAgG,CAAC;QACpH,OAAO,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,CAAC;KACtE;;;;;"}
\ No newline at end of file
{"version":3,"file":"NetworkManager.d.ts","sourceRoot":"","sources":["../../src/network/NetworkManager.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAIrD,oBAAY,eAAe,CAAC,CAAC,IAAI;IAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,EAAE,CAAC,CAAC;IACR,MAAM,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,qBAAa,cAAc;IACvB,OAAO,CAAC,aAAa,CAAiB;IACtC,OAAO,CAAC,YAAY,CAAe;gBAEvB,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY;IAKrE;;;;;OAKG;IACG,eAAe,CAAC,CAAC,EAAE,UAAU,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;CAkB9I"}
\ No newline at end of file
/*! @azure/msal-common v9.0.1 2022-12-07 */
'use strict';
import { __awaiter, __generator } from '../_virtual/_tslib.js';
import { ThrottlingUtils } from './ThrottlingUtils.js';
import { AuthError } from '../error/AuthError.js';
import { ClientAuthError } from '../error/ClientAuthError.js';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
var NetworkManager = /** @class */ (function () {
function NetworkManager(networkClient, cacheManager) {
this.networkClient = networkClient;
this.cacheManager = cacheManager;
}
/**
* Wraps sendPostRequestAsync with necessary preflight and postflight logic
* @param thumbprint
* @param tokenEndpoint
* @param options
*/
NetworkManager.prototype.sendPostRequest = function (thumbprint, tokenEndpoint, options) {
return __awaiter(this, void 0, void 0, function () {
var response, e_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
ThrottlingUtils.preProcess(this.cacheManager, thumbprint);
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, this.networkClient.sendPostRequestAsync(tokenEndpoint, options)];
case 2:
response = _a.sent();
return [3 /*break*/, 4];
case 3:
e_1 = _a.sent();
if (e_1 instanceof AuthError) {
throw e_1;
}
else {
throw ClientAuthError.createNetworkError(tokenEndpoint, e_1);
}
case 4:
ThrottlingUtils.postProcess(this.cacheManager, thumbprint, response);
return [2 /*return*/, response];
}
});
});
};
return NetworkManager;
}());
export { NetworkManager };
//# sourceMappingURL=NetworkManager.js.map
{"version":3,"file":"NetworkManager.js","sources":["../../src/network/NetworkManager.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { INetworkModule, NetworkRequestOptions } from \"./INetworkModule\";\nimport { RequestThumbprint } from \"./RequestThumbprint\";\nimport { ThrottlingUtils } from \"./ThrottlingUtils\";\nimport { CacheManager } from \"../cache/CacheManager\";\nimport { AuthError } from \"../error/AuthError\";\nimport { ClientAuthError } from \"../error/ClientAuthError\";\n\nexport type NetworkResponse<T> = {\n headers: Record<string, string>;\n body: T;\n status: number;\n};\n\nexport class NetworkManager {\n private networkClient: INetworkModule;\n private cacheManager: CacheManager;\n\n constructor(networkClient: INetworkModule, cacheManager: CacheManager) {\n this.networkClient = networkClient;\n this.cacheManager = cacheManager;\n }\n\n /**\n * Wraps sendPostRequestAsync with necessary preflight and postflight logic\n * @param thumbprint\n * @param tokenEndpoint\n * @param options\n */\n async sendPostRequest<T>(thumbprint: RequestThumbprint, tokenEndpoint: string, options: NetworkRequestOptions): Promise<NetworkResponse<T>> {\n ThrottlingUtils.preProcess(this.cacheManager, thumbprint);\n\n let response;\n try {\n response = await this.networkClient.sendPostRequestAsync<T>(tokenEndpoint, options);\n } catch (e) {\n if (e instanceof AuthError) {\n throw e;\n } else {\n throw ClientAuthError.createNetworkError(tokenEndpoint, e);\n }\n }\n\n ThrottlingUtils.postProcess(this.cacheManager, thumbprint, response);\n\n return response;\n }\n}\n"],"names":[],"mappings":";;;;;;;AAAA;;;AAGG;AAeH,IAAA,cAAA,kBAAA,YAAA;IAII,SAAY,cAAA,CAAA,aAA6B,EAAE,YAA0B,EAAA;AACjE,QAAA,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;AACnC,QAAA,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;KACpC;AAED;;;;;AAKG;AACG,IAAA,cAAA,CAAA,SAAA,CAAA,eAAe,GAArB,UAAyB,UAA6B,EAAE,aAAqB,EAAE,OAA8B,EAAA;;;;;;wBACzG,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;;;;wBAI3C,OAAM,CAAA,CAAA,YAAA,IAAI,CAAC,aAAa,CAAC,oBAAoB,CAAI,aAAa,EAAE,OAAO,CAAC,CAAA,CAAA;;wBAAnF,QAAQ,GAAG,SAAwE,CAAC;;;;wBAEpF,IAAI,GAAC,YAAY,SAAS,EAAE;AACxB,4BAAA,MAAM,GAAC,CAAC;AACX,yBAAA;AAAM,6BAAA;4BACH,MAAM,eAAe,CAAC,kBAAkB,CAAC,aAAa,EAAE,GAAC,CAAC,CAAC;AAC9D,yBAAA;;wBAGL,eAAe,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;AAErE,wBAAA,OAAA,CAAA,CAAA,aAAO,QAAQ,CAAC,CAAA;;;;AACnB,KAAA,CAAA;IACL,OAAC,cAAA,CAAA;AAAD,CAAC,EAAA;;;;"}
\ No newline at end of file
{"version":3,"file":"RequestThumbprint.d.ts","sourceRoot":"","sources":["../../src/network/RequestThumbprint.ts"],"names":[],"m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BAAmB,CAAC,QAAQ,EAAE,eAAe,CAAC,gCAAgC,CAAC,GAAG,OAAO;IAIhG;;;OAGG;IACH,MAAM,CAAC,0BAA0B,CAAC,QAAQ,EAAE,eAAe,CAAC,gCAAgC,CAAC,GAAG,OAAO;IAOvG;;;OAGG;IACH,MAAM,CAAC,qBAAqB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM;IAU1D,MAAM,CAAC,cAAc,CAAC,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,qBAAqB,CAAC,EAAE,MAAM,GAAG,OAAO;CAiBzI"}
\ No newline at end of file
/*! @azure/msal-common v9.0.1 2022-12-07 */
'use strict';
import { ThrottlingConstants, CacheSchemaType, Constants, HeaderNames } from '../utils/Constants.js';
import { ServerError } from '../error/ServerError.js';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
var ThrottlingUtils = /** @class */ (function () {
function ThrottlingUtils() {
}
/**
* Prepares a RequestThumbprint to be stored as a key.
* @param thumbprint
*/
ThrottlingUtils.generateThrottlingStorageKey = function (thumbprint) {
return ThrottlingConstants.THROTTLING_PREFIX + "." + JSON.stringify(thumbprint);
};
/**
* Performs necessary throttling checks before a network request.
* @param cacheManager
* @param thumbprint
*/
ThrottlingUtils.preProcess = function (cacheManager, thumbprint) {
var _a;
var key = ThrottlingUtils.generateThrottlingStorageKey(thumbprint);
var value = cacheManager.getThrottlingCache(key);
if (value) {
if (value.throttleTime < Date.now()) {
cacheManager.removeItem(key, CacheSchemaType.THROTTLING);
return;
}
throw new ServerError(((_a = value.errorCodes) === null || _a === void 0 ? void 0 : _a.join(" ")) || Constants.EMPTY_STRING, value.errorMessage, value.subError);
}
};
/**
* Performs necessary throttling checks after a network request.
* @param cacheManager
* @param thumbprint
* @param response
*/
ThrottlingUtils.postProcess = function (cacheManager, thumbprint, response) {
if (ThrottlingUtils.checkResponseStatus(response) || ThrottlingUtils.checkResponseForRetryAfter(response)) {
var thumbprintValue = {
throttleTime: ThrottlingUtils.calculateThrottleTime(parseInt(response.headers[HeaderNames.RETRY_AFTER])),
error: response.body.error,
errorCodes: response.body.error_codes,
errorMessage: response.body.error_description,
subError: response.body.suberror
};
cacheManager.setThrottlingCache(ThrottlingUtils.generateThrottlingStorageKey(thumbprint), thumbprintValue);
}
};
/**
* Checks a NetworkResponse object's status codes against 429 or 5xx
* @param response
*/
ThrottlingUtils.checkResponseStatus = function (response) {
return response.status === 429 || response.status >= 500 && response.status < 600;
};
/**
* Checks a NetworkResponse object's RetryAfter header
* @param response
*/
ThrottlingUtils.checkResponseForRetryAfter = function (response) {
if (response.headers) {
return response.headers.hasOwnProperty(HeaderNames.RETRY_AFTER) && (response.status < 200 || response.status >= 300);
}
return false;
};
/**
* Calculates the Unix-time value for a throttle to expire given throttleTime in seconds.
* @param throttleTime
*/
ThrottlingUtils.calculateThrottleTime = function (throttleTime) {
var time = throttleTime <= 0 ? 0 : throttleTime;
var currentSeconds = Date.now() / 1000;
return Math.floor(Math.min(currentSeconds + (time || ThrottlingConstants.DEFAULT_THROTTLE_TIME_SECONDS), currentSeconds + ThrottlingConstants.DEFAULT_MAX_THROTTLE_TIME_SECONDS) * 1000);
};
ThrottlingUtils.removeThrottle = function (cacheManager, clientId, request, homeAccountIdentifier) {
var thumbprint = {
clientId: clientId,
authority: request.authority,
scopes: request.scopes,
homeAccountIdentifier: homeAccountIdentifier,
claims: request.claims,
authenticationScheme: request.authenticationScheme,
resourceRequestMethod: request.resourceRequestMethod,
resourceRequestUri: request.resourceRequestUri,
shrClaims: request.shrClaims,
sshKid: request.sshKid
};
var key = this.generateThrottlingStorageKey(thumbprint);
return cacheManager.removeItem(key, CacheSchemaType.THROTTLING);
};
return ThrottlingUtils;
}());
export { ThrottlingUtils };
//# sourceMappingURL=ThrottlingUtils.js.map
{"version":3,"file":"ThrottlingUtils.js","sources":["../../src/network/ThrottlingUtils.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { NetworkResponse } from \"./NetworkManager\";\nimport { ServerAuthorizationTokenResponse } from \"../response/ServerAuthorizationTokenResponse\";\nimport { HeaderNames, CacheSchemaType, ThrottlingConstants, Constants } from \"../utils/Constants\";\nimport { CacheManager } from \"../cache/CacheManager\";\nimport { ServerError } from \"../error/ServerError\";\nimport { RequestThumbprint } from \"./RequestThumbprint\";\nimport { ThrottlingEntity } from \"../cache/entities/ThrottlingEntity\";\nimport { BaseAuthRequest } from \"../request/BaseAuthRequest\";\n\nexport class ThrottlingUtils {\n\n /**\n * Prepares a RequestThumbprint to be stored as a key.\n * @param thumbprint\n */\n static generateThrottlingStorageKey(thumbprint: RequestThumbprint): string {\n return `${ThrottlingConstants.THROTTLING_PREFIX}.${JSON.stringify(thumbprint)}`;\n }\n\n /**\n * Performs necessary throttling checks before a network request.\n * @param cacheManager\n * @param thumbprint\n */\n static preProcess(cacheManager: CacheManager, thumbprint: RequestThumbprint): void {\n const key = ThrottlingUtils.generateThrottlingStorageKey(thumbprint);\n const value = cacheManager.getThrottlingCache(key);\n\n if (value) {\n if (value.throttleTime < Date.now()) {\n cacheManager.removeItem(key, CacheSchemaType.THROTTLING);\n return;\n }\n throw new ServerError(value.errorCodes?.join(\" \") || Constants.EMPTY_STRING, value.errorMessage, value.subError);\n }\n }\n\n /**\n * Performs necessary throttling checks after a network request.\n * @param cacheManager\n * @param thumbprint\n * @param response\n */\n static postProcess(cacheManager: CacheManager, thumbprint: RequestThumbprint, response: NetworkResponse<ServerAuthorizationTokenResponse>): void {\n if (ThrottlingUtils.checkResponseStatus(response) || ThrottlingUtils.checkResponseForRetryAfter(response)) {\n const thumbprintValue: ThrottlingEntity = {\n throttleTime: ThrottlingUtils.calculateThrottleTime(parseInt(response.headers[HeaderNames.RETRY_AFTER])),\n error: response.body.error,\n errorCodes: response.body.error_codes,\n errorMessage: response.body.error_description,\n subError: response.body.suberror\n };\n cacheManager.setThrottlingCache(\n ThrottlingUtils.generateThrottlingStorageKey(thumbprint),\n thumbprintValue\n );\n }\n }\n\n /**\n * Checks a NetworkResponse object's status codes against 429 or 5xx\n * @param response\n */\n static checkResponseStatus(response: NetworkResponse<ServerAuthorizationTokenResponse>): boolean {\n return response.status === 429 || response.status >= 500 && response.status < 600;\n }\n\n /**\n * Checks a NetworkResponse object's RetryAfter header\n * @param response\n */\n static checkResponseForRetryAfter(response: NetworkResponse<ServerAuthorizationTokenResponse>): boolean {\n if (response.headers) {\n return response.headers.hasOwnProperty(HeaderNames.RETRY_AFTER) && (response.status < 200 || response.status >= 300);\n }\n return false;\n }\n\n /**\n * Calculates the Unix-time value for a throttle to expire given throttleTime in seconds.\n * @param throttleTime\n */\n static calculateThrottleTime(throttleTime: number): number {\n const time = throttleTime <= 0 ? 0 : throttleTime;\n\n const currentSeconds = Date.now() / 1000;\n return Math.floor(Math.min(\n currentSeconds + (time || ThrottlingConstants.DEFAULT_THROTTLE_TIME_SECONDS),\n currentSeconds + ThrottlingConstants.DEFAULT_MAX_THROTTLE_TIME_SECONDS\n ) * 1000);\n }\n\n static removeThrottle(cacheManager: CacheManager, clientId: string, request: BaseAuthRequest, homeAccountIdentifier?: string): boolean {\n const thumbprint: RequestThumbprint = {\n clientId: clientId,\n authority: request.authority,\n scopes: request.scopes,\n homeAccountIdentifier: homeAccountIdentifier,\n claims: request.claims,\n authenticationScheme: request.authenticationScheme,\n resourceRequestMethod: request.resourceRequestMethod,\n resourceRequestUri: request.resourceRequestUri,\n shrClaims: request.shrClaims,\n sshKid: request.sshKid\n };\n\n const key = this.generateThrottlingStorageKey(thumbprint);\n return cacheManager.removeItem(key, CacheSchemaType.THROTTLING);\n }\n}\n"],"names":[],"mappings":";;;;;AAAA;;;AAGG;AAWH,IAAA,eAAA,kBAAA,YAAA;AAAA,IAAA,SAAA,eAAA,GAAA;KAoGC;AAlGG;;;AAGG;IACI,eAA4B,CAAA,4BAAA,GAAnC,UAAoC,UAA6B,EAAA;QA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b,CAAA;IAEM,eAAc,CAAA,cAAA,GAArB,UAAsB,YAA0B,EAAE,QAAgB,EAAE,OAAwB,EAAE,qBAA8B,EAAA;AACxH,QAAA,IAAM,UAAU,GAAsB;AAClC,YAAA,QAAQ,EAAE,QAAQ;YAClB,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,MAAM,EAAE,OAAO,CAAC,MAAM;AACtB,YAAA,qBAAqB,EAAE,qBAAqB;YAC5C,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,oBAAoB,EAAE,OAAO,CAAC,oBAAoB;YAClD,qBAAqB,EAAE,OAAO,CAAC,qBAAqB;YACpD,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;YAC9C,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,MAAM,EAAE,OAAO,CAAC,MAAM;SACzB,CAAC;QAEF,IAAM,GAAG,GAAG,IAAI,CAAC,4BAA4B,CAAC,UAAU,CAAC,CAAC;QAC1D,OAAO,YAAY,CAAC,UAAU,CAAC,GAAG,EAAE,eAAe,CAAC,UAAU,CAAC,CAAC;KACnE,CAAA;IACL,OAAC,eAAA,CAAA;AAAD,CAAC,EAAA;;;;"}
\ No newline at end of file
{"version":3,"file":"packageMetadata.d.ts","sourceRoot":"","sources":["../src/packageMetadata.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,IAAI,uBAAuB,CAAC;AACzC,eAAO,MAAM,OAAO,UAAU,CAAC"}
\ No newline at end of file
/*! @azure/msal-common v9.0.1 2022-12-07 */
'use strict';
/* eslint-disable header/header */
var name = "@azure/msal-common";
var version = "9.0.1";
export { name, version };
//# sourceMappingURL=packageMetadata.js.map
{"version":3,"file":"packageMetadata.js","sources":["../src/packageMetadata.ts"],"sourcesContent":["/* eslint-disable header/header */\nexport const name = \"@azure/msal-common\";\nexport const version = \"9.0.1\";\n"],"names":[],"mappings":";;AAAA;AACO,IAAM,IAAI,GAAG,qBAAqB;AAClC,IAAM,OAAO,GAAG;;;;"}
\ No newline at end of file
/**
* This is a helper class that parses supported HTTP response authentication headers to extract and return
* header challenge values that can be used outside the basic authorization flows.
*/
export declare class AuthenticationHeaderParser {
private headers;
constructor(headers: Record<string, string>);
/**
* This method parses the SHR nonce value out of either the Authentication-Info or WWW-Authenticate authentication headers.
* @returns
*/
getShrNonce(): string;
/**
* Parses an HTTP header's challenge set into a key/value map.
* @param header
* @returns
*/
private parseChallenges;
}
//# sourceMappingURL=AuthenticationHeaderParser.d.ts.map
\ No newline at end of file
{"version":3,"file":"AuthenticationHeaderParser.d.ts","sourceRoot":"","sources":["../../src/request/AuthenticationHeaderParser.ts"],"names":[],"mappings":"AAgBA;;;GAGG;AACH,qBAAa,0BAA0B;IACnC,OAAO,CAAC,OAAO,CAAyB;gBAE5B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAI3C;;;OAGG;IACH,WAAW,IAAI,MAAM;IAyBrB;;;;OAIG;IACH,OAAO,CAAC,eAAe;CAa1B"}
\ No newline at end of file
/*! @azure/msal-common v9.0.1 2022-12-07 */
'use strict';
import { ClientConfigurationError } from '../error/ClientConfigurationError.js';
import { HeaderNames, Constants } from '../utils/Constants.js';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
/**
* This is a helper class that parses supported HTTP response authentication headers to extract and return
* header challenge values that can be used outside the basic authorization flows.
*/
var AuthenticationHeaderParser = /** @class */ (function () {
function AuthenticationHeaderParser(headers) {
this.headers = headers;
}
/**
* This method parses the SHR nonce value out of either the Authentication-Info or WWW-Authenticate authentication headers.
* @returns
*/
AuthenticationHeaderParser.prototype.getShrNonce = function () {
// Attempt to parse nonce from Authentiacation-Info
var authenticationInfo = this.headers[HeaderNames.AuthenticationInfo];
if (authenticationInfo) {
var authenticationInfoChallenges = this.parseChallenges(authenticationInfo);
if (authenticationInfoChallenges.nextnonce) {
return authenticationInfoChallenges.nextnonce;
}
throw ClientConfigurationError.createInvalidAuthenticationHeaderError(HeaderNames.AuthenticationInfo, "nextnonce challenge is missing.");
}
// Attempt to parse nonce from WWW-Authenticate
var wwwAuthenticate = this.headers[HeaderNames.WWWAuthenticate];
if (wwwAuthenticate) {
var wwwAuthenticateChallenges = this.parseChallenges(wwwAuthenticate);
if (wwwAuthenticateChallenges.nonce) {
return wwwAuthenticateChallenges.nonce;
}
throw ClientConfigurationError.createInvalidAuthenticationHeaderError(HeaderNames.WWWAuthenticate, "nonce challenge is missing.");
}
// If neither header is present, throw missing headers error
throw ClientConfigurationError.createMissingNonceAuthenticationHeadersError();
};
/**
* Parses an HTTP header's challenge set into a key/value map.
* @param header
* @returns
*/
AuthenticationHeaderParser.prototype.parseChallenges = function (header) {
var schemeSeparator = header.indexOf(" ");
var challenges = header.substr(schemeSeparator + 1).split(",");
var challengeMap = {};
challenges.forEach(function (challenge) {
var _a = challenge.split("="), key = _a[0], value = _a[1];
// Remove escaped quotation marks (', ") from challenge string to keep only the challenge value
challengeMap[key] = unescape(value.replace(/['"]+/g, Constants.EMPTY_STRING));
});
return challengeMap;
};
return AuthenticationHeaderParser;
}());
export { AuthenticationHeaderParser };
//# sourceMappingURL=AuthenticationHeaderParser.js.map
{"version":3,"file":"AuthenticationHeaderParser.js","sources":["../../src/request/AuthenticationHeaderParser.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ClientConfigurationError } from \"../error/ClientConfigurationError\";\nimport { Constants, HeaderNames } from \"../utils/Constants\";\n\ntype WWWAuthenticateChallenges = {\n nonce?: string,\n};\n\ntype AuthenticationInfoChallenges = {\n nextnonce?: string\n};\n\n/**\n * This is a helper class that parses supported HTTP response authentication headers to extract and return\n * header challenge values that can be used outside the basic authorization flows.\n */\nexport class AuthenticationHeaderParser {\n private headers: Record<string, string>;\n\n constructor(headers: Record<string, string>) {\n this.headers = headers;\n }\n\n /**\n * This method parses the SHR nonce value out of either the Authentication-Info or WWW-Authenticate authentication headers.\n * @returns \n */\n getShrNonce(): string {\n // Attempt to parse nonce from Authentiacation-Info\n const authenticationInfo = this.headers[HeaderNames.AuthenticationInfo];\n if (authenticationInfo) {\n const authenticationInfoChallenges = this.parseChallenges<AuthenticationInfoChallenges>(authenticationInfo);\n if (authenticationInfoChallenges.nextnonce) {\n return authenticationInfoChallenges.nextnonce;\n }\n throw ClientConfigurationError.createInvalidAuthenticationHeaderError(HeaderNames.AuthenticationInfo, \"nextnonce challenge is missing.\");\n }\n\n // Attempt to parse nonce from WWW-Authenticate\n const wwwAuthenticate = this.headers[HeaderNames.WWWAuthenticate];\n if (wwwAuthenticate) {\n const wwwAuthenticateChallenges = this.parseChallenges<WWWAuthenticateChallenges>(wwwAuthenticate); \n if (wwwAuthenticateChallenges.nonce){\n return wwwAuthenticateChallenges.nonce;\n }\n throw ClientConfigurationError.createInvalidAuthenticationHeaderError(HeaderNames.WWWAuthenticate, \"nonce challenge is missing.\");\n }\n\n // If neither header is present, throw missing headers error\n throw ClientConfigurationError.createMissingNonceAuthenticationHeadersError();\n }\n\n /**\n * Parses an HTTP header's challenge set into a key/value map.\n * @param header \n * @returns \n */\n private parseChallenges<T>(header: string): T {\n const schemeSeparator = header.indexOf(\" \");\n const challenges = header.substr(schemeSeparator + 1).split(\",\");\n const challengeMap = {} as T;\n\n challenges.forEach((challenge: string) => {\n const [ key, value ] = challenge.split(\"=\");\n // Remove escaped quotation marks (', \") from challenge string to keep only the challenge value\n challengeMap[key] = unescape(value.replace(/['\"]+/g, Constants.EMPTY_STRING));\n });\n\n return challengeMap;\n }\n}\n"],"names":[],"mappings":";;;;;AAAA;;;AAGG;AAaH;;;AAGG;AACH,IAAA,0BAAA,kBAAA,YAAA;AAGI,IAAA,SAAA,0BAAA,CAAY,OAA+B,EAAA;AACvC,QAAA,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;KAC1B;AAED;;;AAGG;AACH,IAAA,0BAAA,CAAA,SAAA,CAAA,WAAW,GAAX,YAAA;;QAEI,IAAM,kBAAkB,GAAG,IAAI,CAAC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CAAA,EAAE,KAAK,QAAyB,CAAC;;AAE5C,YAAA,YAAY,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC;AAClF,SAAC,CAAC,CAAC;AAEH,QAAA,OAAO,YAAY,CAAC;KACvB,CAAA;IACL,OAAC,0BAAA,CAAA;AAAD,CAAC,EAAA;;;;"}
\ No newline at end of file
{"version":3,"file":"BaseAuthRequest.d.ts","sourceRoot":"","sources":["../../src/request/BaseAuthRequest.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE;;;;;;;;;;;;;;;GAeG;AACH,oBAAY,eAAe,GAAG;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACtB,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC"}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment