3.76 kBTypeScriptView Raw
1import type { AuthenticationRecord, MsalAccountInfo, MsalToken, ValidMsalToken } from "./types.js";
2import type { CredentialLogger } from "../util/logging.js";
3import type { AzureLogLevel } from "@azure/logger";
4import type { GetTokenOptions } from "@azure/core-auth";
5import { msalCommon } from "./msal.js";
6export interface ILoggerCallback {
7 (level: msalCommon.LogLevel, message: string, containsPii: boolean): void;
8}
9/**
10 * Ensures the validity of the MSAL token
11 * @internal
12 */
13export declare function ensureValidMsalToken(scopes: string | string[], msalToken?: MsalToken | null, getTokenOptions?: GetTokenOptions): asserts msalToken is ValidMsalToken;
14/**
15 * Returns the authority host from either the options bag or the AZURE_AUTHORITY_HOST environment variable.
16 *
17 * Defaults to {@link DefaultAuthorityHost}.
18 * @internal
19 */
20export declare function getAuthorityHost(options?: {
21 authorityHost?: string;
22}): string;
23/**
24 * Generates a valid authority by combining a host with a tenantId.
25 * @internal
26 */
27export declare function getAuthority(tenantId: string, host?: string): string;
28/**
29 * Generates the known authorities.
30 * If the Tenant Id is `adfs`, the authority can't be validated since the format won't match the expected one.
31 * For that reason, we have to force MSAL to disable validating the authority
32 * by sending it within the known authorities in the MSAL configuration.
33 * @internal
34 */
35export declare function getKnownAuthorities(tenantId: string, authorityHost: string, disableInstanceDiscovery?: boolean): string[];
36/**
37 * Generates a logger that can be passed to the MSAL clients.
38 * @param credLogger - The logger of the credential.
39 * @internal
40 */
41export declare const defaultLoggerCallback: (logger: CredentialLogger, platform?: "Node" | "Browser") => ILoggerCallback;
42/**
43 * @internal
44 */
45export declare function getMSALLogLevel(logLevel: AzureLogLevel | undefined): msalCommon.LogLevel;
46/**
47 * Wraps core-util's randomUUID in order to allow for mocking in tests.
48 * This prepares the library for the upcoming core-util update to ESM.
49 *
50 * @internal
51 * @returns A string containing a random UUID
52 */
53export declare function randomUUID(): string;
54/**
55 * Handles MSAL errors.
56 */
57export declare function handleMsalError(scopes: string[], error: Error, getTokenOptions?: GetTokenOptions): Error;
58export declare function publicToMsal(account: AuthenticationRecord): msalCommon.AccountInfo;
59export declare function msalToPublic(clientId: string, account: MsalAccountInfo): AuthenticationRecord;
60/**
61 * Serializes an `AuthenticationRecord` into a string.
62 *
63 * The output of a serialized authentication record will contain the following properties:
64 *
65 * - "authority"
66 * - "homeAccountId"
67 * - "clientId"
68 * - "tenantId"
69 * - "username"
70 * - "version"
71 *
72 * To later convert this string to a serialized `AuthenticationRecord`, please use the exported function `deserializeAuthenticationRecord()`.
73 */
74export declare function serializeAuthenticationRecord(record: AuthenticationRecord): string;
75/**
76 * Deserializes a previously serialized authentication record from a string into an object.
77 *
78 * The input string must contain the following properties:
79 *
80 * - "authority"
81 * - "homeAccountId"
82 * - "clientId"
83 * - "tenantId"
84 * - "username"
85 * - "version"
86 *
87 * If the version we receive is unsupported, an error will be thrown.
88 *
89 * At the moment, the only available version is: "1.0", which is always set when the authentication record is serialized.
90 *
91 * @param serializedRecord - Authentication record previously serialized into string.
92 * @returns AuthenticationRecord.
93 */
94export declare function deserializeAuthenticationRecord(serializedRecord: string): AuthenticationRecord;
95//# sourceMappingURL=utils.d.ts.map
\No newline at end of file