Options
All
  • Public
  • Public/Protected
  • All
Menu

Handles persistence and fetching of user authentication information using JWT, OAuth, or refresh tokens. Sets up the refresh flows that jsForce will use to keep tokens active. An AuthInfo can also be created with an access token, but AuthInfos created with access tokens can't be persisted to disk.

example

// Creating a new authentication file. const authInfo = await AuthInfo.create(myAdminUsername, { loginUrl, authCode, clientId, clientSecret }); authInfo.save();

// Creating an authorization info with an access token. const authInfo = await AuthInfo.create(accessToken);

// Using an existing authentication file. const authInfo = await AuthInfo.create(myAdminUsername);

// Using the AuthInfo const connection = await Connection.create(authInfo);

see

https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_auth.htm

see

https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_cli_usernames_orgs.htm

Hierarchy

  • AsyncCreatable<AuthInfoOptions>
    • AuthInfo

Index

Methods

getConnectionOptions

  • Get the auth fields (decrypted) needed to make a connection.

    Returns ConnectionOptions

getFields

  • Get the authorization fields.

    Returns AuthFields

getSfdxAuthUrl

  • getSfdxAuthUrl(): string

getUsername

  • getUsername(): Optional<string>
  • Get the username.

    Returns Optional<string>

init

  • init(): Promise<void>
  • Initializes an instance of the AuthInfo class.

    Returns Promise<void>

isAccessTokenFlow

  • isAccessTokenFlow(): boolean
  • Returns true if this is using an access token flow.

    Returns boolean

isJwt

  • isJwt(): boolean
  • Returns true if this is using the JWT flow.

    Returns boolean

isOauth

  • isOauth(): boolean
  • Returns true if this is using the oauth flow.

    Returns boolean

isRefreshTokenFlow

  • isRefreshTokenFlow(): boolean
  • Returns true if this is using the refresh token flow.

    Returns boolean

isUsingAccessToken

  • isUsingAccessToken(): boolean
  • Returns true if this org is using access token auth.

    Returns boolean

save

  • Updates the cache and persists the authentication fields (encrypted).

    Parameters

    Returns Promise<AuthInfo>

update

  • Update the authorization fields, encrypting sensitive fields, but do not persist.

    Parameters

    • Optional authData: AuthFields

      Authorization fields to update.

    • Default value encrypt: boolean = true

      Encrypt the fields.

    Returns AuthInfo

    For convenience this object is returned.

Static clearCache

  • clearCache(username: string): boolean
  • Forces the auth file to be re-read from disk for a given user.

    Parameters

    • username: string

      The username for the auth info to re-read.

    Returns boolean

    True if a value was removed.

Static create

  • create<P, T>(this: object, options: P): Promise<T>
  • Asynchronously constructs and initializes a new instance of a concrete subclass with the provided options.

    Type parameters

    • P

    • T: AsyncCreatable<P>

    Parameters

    • this: object
    • options: P

      An options object providing initialization params to the async constructor.

    Returns Promise<T>

Static getAuthorizationUrl

  • getAuthorizationUrl(options: OAuth2Options): string
  • Get the authorization URL.

    Parameters

    • options: OAuth2Options

      The options to generate the URL.

    Returns string

Static hasAuthentications

  • hasAuthentications(): Promise<boolean>
  • Returns true if one or more authentications are persisted.

    Returns Promise<boolean>

Static listAllAuthFiles

  • listAllAuthFiles(): Promise<string[]>
  • Get a list of all auth files stored in the global directory.

    Returns Promise<string[]>