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

IdentityPlugin

IdentityPlugin: (context: unknown) => void

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

Type declaration

    • (context: unknown): void
    • Parameters

      • context: unknown

      Returns void

VSCodeCloudNames

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

Variables

Const AggregateAuthenticationErrorName

AggregateAuthenticationErrorName: "AggregateAuthenticationError" = "AggregateAuthenticationError"

The Error.name value of an AggregateAuthenticationError

Const ApplicationCredentials

ApplicationCredentials: ApplicationCredentialConstructor[] = [EnvironmentCredential,DefaultManagedIdentityCredential]

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 credentialName

credentialName: "OnBehalfOfCredential" = "OnBehalfOfCredential"

Const defaultCredentials

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

Let findCredentials

findCredentials: VSCodeCredentialFinder | undefined = undefined

Const imdsApiVersion

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

Const imdsEndpointPath

imdsEndpointPath: "/metadata/identity/oauth2/token" = "/metadata/identity/oauth2/token"

Const imdsHost

imdsHost: "http://169.254.169.254" = "http://169.254.169.254"

Const isWindows

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

Const msiName

msiName: "ManagedIdentityCredential - Fabric MSI" = "ManagedIdentityCredential - Fabric MSI"

Const noCorrelationId

noCorrelationId: "noCorrelationId" = "noCorrelationId"

Const readFileAsync

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

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.

Const expiresInParser

  • expiresInParser(requestBody: any): number

filePathRequest

  • filePathRequest(identityClient: IdentityClient, requestPrepareOptions: PipelineRequestOptions): 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 | undefined
  • Most MSIs send requests to the IMDS endpoint, or a similar endpoint. These are GET requests that require sending a resource parameter on the query. This resource can be derived from the scopes received through the getToken call, as long as only one scope is received. Multiple scopes assume that the resulting token will have access to multiple resources, which won't be the case.

    For that reason, when we encounter multiple scopes, we return undefined. It's up to the individual MSI implementations to throw the errors (which helps us provide less generic errors).

    Parameters

    • scopes: string | string[]

    Returns string | undefined

msalToPublic

msiGenericGetToken

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

prepareRequestOptions

  • prepareRequestOptions(scopes: string | string[], clientId?: undefined | string): PipelineRequestOptions

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

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

tokenExchangeMsi

  • tokenExchangeMsi(): MSI

useIdentityPlugin

  • Extend Azure Identity with additional functionality. Pass a plugin from a plugin package, such as:

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

    Example:

    import { cachePersistencePlugin } from "@azure/identity-cache-persistence";
    
    import { useIdentityPlugin, DefaultAzureCredential } from "@azure/identity";
    useIdentityPlugin(cachePersistencePlugin);
    
    // The plugin 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

    Returns void

Object literals

Const appServiceMsi2017

appServiceMsi2017: object

getToken

  • getToken(configuration: MSIConfiguration, getTokenOptions?: GetTokenOptions): Promise<AccessToken | null>

isAvailable

  • isAvailable(scopes: string | Object): Promise<boolean>

Const arcMsi

arcMsi: object

getToken

  • getToken(configuration: MSIConfiguration, getTokenOptions?: GetTokenOptions): Promise<AccessToken | null>

isAvailable

  • isAvailable(scopes: string | Object): Promise<boolean>

Const cloudShellMsi

cloudShellMsi: object

getToken

  • getToken(configuration: MSIConfiguration, getTokenOptions?: GetTokenOptions): Promise<AccessToken | null>

isAvailable

  • isAvailable(scopes: string | Object): Promise<boolean>

Const fabricMsi

fabricMsi: object

getToken

  • getToken(configuration: MSIConfiguration, getTokenOptions?: GetTokenOptions): Promise<AccessToken | null>

isAvailable

  • isAvailable(scopes: string | Object): Promise<boolean>

Const imdsMsi

imdsMsi: object

getToken

  • getToken(configuration: MSIConfiguration, getTokenOptions?: GetTokenOptions): Promise<AccessToken | null>

isAvailable

  • isAvailable(scopes: string | string[], identityClient: IdentityClient, 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