Options
All
  • Public
  • Public/Protected
  • All
Menu

@azure/identity

Package version

Index

Enumerations

Classes

Interfaces

Type aliases

Variables

Functions

Object literals

Type aliases

BrowserLoginStyle

BrowserLoginStyle: "redirect" | "popup"

(Browser-only feature) The "login style" to use in the authentication flow:

  • "redirect" redirects the user to the authentication page and then redirects them back to the page once authentication is completed.
  • "popup" opens a new browser window through with the redirect flow is initiated. The user's existing browser window does not leave the current page

DeviceCodePromptCallback

DeviceCodePromptCallback: (deviceCodeInfo: DeviceCodeInfo) => void

Defines the signature of a callback which will be passed to DeviceCodeCredential for the purpose of displaying authentication details to the user.

Type declaration

IdentityExtension

IdentityExtension: (context: unknown) => void

The type of an Azure Identity Extension, a function accepting an extension context.

Type declaration

    • (context: unknown): void
    • Parameters

      • context: unknown

      Returns void

MSIExpiresInParser

MSIExpiresInParser: (requestBody: any) => number

Type declaration

    • (requestBody: any): number
    • Parameters

      • requestBody: any

      Returns number

VSCodeCloudNames

VSCodeCloudNames: "AzureCloud" | "AzureChina" | "AzureGermanCloud" | "AzureUSGovernment"

Variables

Const AggregateAuthenticationErrorName

AggregateAuthenticationErrorName: "AggregateAuthenticationError" = "AggregateAuthenticationError"

The Error.name value of an AggregateAuthenticationError

Const AuthenticationErrorName

AuthenticationErrorName: "AuthenticationError" = "AuthenticationError"

The Error.name value of an AuthenticationError

Const AzureAccountClientId

AzureAccountClientId: "aebc6443-996d-45c2-90f0-388ff96faa56" = "aebc6443-996d-45c2-90f0-388ff96faa56"

Const BrowserNotSupportedError

BrowserNotSupportedError: any = new Error("getAuthorityHostEnvironment is not supported in the browser.")

Const CommonTenantId

CommonTenantId: "common" = "common"

Const CredentialUnavailableErrorName

CredentialUnavailableErrorName: "CredentialUnavailableError" = "CredentialUnavailableError"

The Error.name value of an CredentialUnavailable

Const DefaultAuthorityHost

DefaultAuthorityHost: AzurePublicCloud = AzureAuthorityHosts.AzurePublicCloud

The default authority host.

Const DefaultScopeSuffix

DefaultScopeSuffix: "/.default" = "/.default"

Const azureArcAPIVersion

azureArcAPIVersion: "2019-11-01" = "2019-11-01"

Const azureFabricVersion

azureFabricVersion: "2019-07-01-preview" = "2019-07-01-preview"

Const defaultCredentials

defaultCredentials: DefaultCredentialConstructor[] = [EnvironmentCredential,DefaultManagedIdentityCredential,VisualStudioCodeCredential,AzureCliCredential,AzurePowerShellCredential]

Const expiresInParser

  • expiresInParser(requestBody: any): number

Let findCredentials

findCredentials: VSCodeCredentialFinder | undefined = undefined

Const imdsApiVersion

imdsApiVersion: "2018-02-01" = "2018-02-01"

Const imdsEndpoint

imdsEndpoint: "http://169.254.169.254/metadata/identity/oauth2/token" = "http://169.254.169.254/metadata/identity/oauth2/token"

Const isWindows

isWindows: boolean = process.platform === "win32"

Const noCorrelationId

noCorrelationId: "noCorrelationId" = "noCorrelationId"

Const redirectHash

redirectHash: string = self.location.hash

Functions

checkTenantId

checkUnsupportedTenant

  • checkUnsupportedTenant(tenantId: string): void

convertOAuthErrorResponseToErrorResponse

  • convertOAuthErrorResponseToErrorResponse(errorBody: OAuthErrorResponse): ErrorResponse

credentialLogger

  • Generates a CredentialLogger, which is a logger declared at the credential's constructor, and used at any point in the credential. It has all the properties of a CredentialLoggerInstance, plus other logger instances, one per method.

    It logs with the format:

    [title] => [message] [title] => getToken() => [message]

    Parameters

    • title: string
    • Default value log: AzureLogger = logger

    Returns CredentialLogger

credentialLoggerInstance

defaultDeviceCodePromptCallback

  • defaultDeviceCodePromptCallback(deviceCodeInfo: DeviceCodeInfo): void

deserializeAuthenticationRecord

  • Deserializes a previously serialized authentication record from a string into an object.

    The input string must contain the following properties:

    • "authority"
    • "homeAccountId"
    • "clientId"
    • "tenantId"
    • "username"
    • "version"

    If the version we receive is unsupported, an error will be thrown.

    At the moment, the only available version is: "1.0", which is always set when the authentication record is serialized.

    Parameters

    • serializedRecord: string

      Authentication record previously serialized into string.

    Returns AuthenticationRecord

    AuthenticationRecord.

filePathRequest

  • filePathRequest(identityClient: IdentityClient, requestPrepareOptions: RequestPrepareOptions): Promise<string | undefined>

formatError

  • formatError(scope: string | string[] | undefined, error: Error | string): string
  • Formatting the success event on the credentials

    Parameters

    • scope: string | string[] | undefined
    • error: Error | string

    Returns string

formatSuccess

  • formatSuccess(scope: string | string[]): string
  • Formatting the success event on the credentials

    Parameters

    • scope: string | string[]

    Returns string

getAuthorityHostEnvironment

  • getAuthorityHostEnvironment(): { authorityHost: string } | undefined

getDefaultAzureCredential

  • getDefaultAzureCredential(): TokenCredential

getIdentityTokenEndpointSuffix

  • getIdentityTokenEndpointSuffix(tenantId: string): string

getPropertyFromVSCode

  • getPropertyFromVSCode(property: string): string | undefined
  • Attempts to load a specific property from the VSCode configurations of the current OS. If it fails at any point, returns undefined.

    Parameters

    • property: string

    Returns string | undefined

isErrorResponse

  • isErrorResponse(errorResponse: any): errorResponse is OAuthErrorResponse
  • Parameters

    • errorResponse: any

    Returns errorResponse is OAuthErrorResponse

Const isLoginError

  • isLoginError(err: Error): any

Const isNotInstalledError

  • isNotInstalledError(err: Error): any

logEnvVars

  • logEnvVars(credentialName: string, supportedEnvVars: string[]): void
  • Based on a given list of environment variable names, logs the environment variables currently assigned during the usage of a credential that goes by the given name.

    Parameters

    • credentialName: string

      Name of the credential in use

    • supportedEnvVars: string[]

      List of environment variables supported by that credential

    Returns void

mapScopesToResource

  • mapScopesToResource(scopes: string | string[]): string

msalToPublic

msiGenericGetToken

  • msiGenericGetToken(identityClient: IdentityClient, requestOptions: RequestPrepareOptions, expiresInParser: MSIExpiresInParser | undefined, getTokenOptions?: GetTokenOptions): Promise<AccessToken | null>

prepareRequestOptions

  • prepareRequestOptions(resource: string, clientId?: undefined | string): RequestPrepareOptions

processEnvVars

  • Separates a list of environment variable names into a plain object with two arrays: an array of missing environment variables and another array with assigned environment variables.

    Parameters

    • supportedEnvVars: string[]

      List of environment variable names

    Returns EnvironmentAccumulator

publicToMsal

readFileAsync

  • readFileAsync(path: string, options: { encoding: string }): Promise<string>

resolveTenantId

  • resolveTenantId(logger: CredentialLogger, tenantId?: undefined | string, clientId?: undefined | string): string

serializeAuthenticationRecord

  • Serializes an AuthenticationRecord into a string.

    The output of a serialized authentication record will contain the following properties:

    • "authority"
    • "homeAccountId"
    • "clientId"
    • "tenantId"
    • "username"
    • "version"

    To later convert this string to a serialized AuthenticationRecord, please use the exported function deserializeAuthenticationRecord().

    Parameters

    Returns string

useIdentityExtension

  • useIdentityExtension(_extension: unknown): void
  • Extend Azure Identity with additional functionality. Pass an extension from an extension package, such as:

    • @azure/identity-cache-persistence: provides persistent token caching
    • @azure/identity-vscode: provides the dependencies of VisualStudioCodeCredential and enables it

    Example:

    import { cachePersistenceExtension } from "@azure/identity-cache-persistence";
    
    import { useIdentityExtension, DefaultAzureCredential } from "@azure/identity";
    useIdentityExtension(persistence);
    
    // The extension has the capability to extend `DefaultAzureCredential` and to
    // add middleware to the underlying credentials, such as persistence.
    const credential = new DefaultAzureCredential({
      tokenCachePersistenceOptions: {
        enabled: true
      }
    });

    Parameters

    • _extension: unknown

    Returns void

Object literals

Const appServiceMsi2017

appServiceMsi2017: object

getToken

  • getToken(identityClient: IdentityClient, resource: string, clientId?: undefined | string, getTokenOptions?: GetTokenOptions): Promise<AccessToken | null>

isAvailable

  • isAvailable(): Promise<boolean>

Const arcMsi

arcMsi: object

getToken

  • getToken(identityClient: IdentityClient, resource?: undefined | string, clientId?: undefined | string, getTokenOptions?: GetTokenOptions): Promise<AccessToken | null>

isAvailable

  • isAvailable(): Promise<boolean>

Const cloudShellMsi

cloudShellMsi: object

getToken

  • getToken(identityClient: IdentityClient, resource: string, clientId?: undefined | string, getTokenOptions?: GetTokenOptions): Promise<AccessToken | null>

isAvailable

  • isAvailable(): Promise<boolean>

Const fabricMsi

fabricMsi: object

getToken

  • getToken(identityClient: IdentityClient, resource: string, clientId?: undefined | string, getTokenOptions?: GetTokenOptions): Promise<AccessToken | null>

isAvailable

  • isAvailable(): Promise<boolean>

Const imdsMsi

imdsMsi: object

getToken

  • getToken(identityClient: IdentityClient, resource: string, clientId?: undefined | string, getTokenOptions?: GetTokenOptions): Promise<AccessToken | null>

isAvailable

  • isAvailable(identityClient: IdentityClient, resource: string, clientId?: undefined | string, getTokenOptions?: GetTokenOptions): Promise<boolean>

Const imdsMsiRetryConfig

imdsMsiRetryConfig: object

intervalIncrement

intervalIncrement: number = 2

maxRetries

maxRetries: number = 3

startDelayInMs

startDelayInMs: number = 800

Const mapVSCodeAuthorityHosts

mapVSCodeAuthorityHosts: object

AzureChina

AzureChina: AzureAuthorityHosts = AzureAuthorityHosts.AzureChina

AzureCloud

AzureCloud: AzureAuthorityHosts = AzureAuthorityHosts.AzurePublicCloud

AzureGermanCloud

AzureGermanCloud: AzureAuthorityHosts = AzureAuthorityHosts.AzureGermany

AzureUSGovernment

AzureUSGovernment: AzureAuthorityHosts = AzureAuthorityHosts.AzureGovernment

Const unsupportedTenantIds

unsupportedTenantIds: object

adfs

adfs: string = "The VisualStudioCodeCredential does not support authentication with ADFS tenants."

Const vsCodeCredentialControl

vsCodeCredentialControl: object

setVsCodeCredentialFinder

  • setVsCodeCredentialFinder(finder: VSCodeCredentialFinder): void

vsCodeCredentialFinder

  • set vsCodeCredentialFinder(_finder: never): void

Generated using TypeDoc