Kysoql
API reference

Auth API reference

Generated API reference for Salesforce authentication, OAuth flows, token storage, and refresh management in @kysoql/auth.

Functions

FunctionDescription
createCodeCredentialsAuthorizationRequestBuilds the POST used by Salesforce Headless Identity's Authorization Code and Credentials flow. The returned request uses redirect: "manual" so credentials aren't automatically forwarded through a redirect by fetch.
createHeadlessGuestAuthorizationRequestBuilds the authorization request for Salesforce Headless Identity's guest variation of Authorization Code and Credentials. Salesforce requires the UVID/JWT prefix during authorization; the later token exchange uses the raw value through exchangeAuthorizationCode({ authRequestType: "guest", ... }).
requestFirstPartyAuthorizationChallengeCalls the OAuth 2.0 for First-Party Applications authorization-challenge endpoint. The generic parameter bag intentionally follows Salesforce because login, passwordless, registration, reCAPTCHA, and continuation steps require different documented fields.
createJwtBearerAssertionCreates an RS256 JWT bearer assertion for Salesforce server-to-server authentication.
createOAuthClientAssertionCreates the private_key_jwt client assertion accepted by Salesforce token endpoints.
createStoredRefreshTokenAuthCreates a refresh-token-backed access-token manager with single-flight refreshes.
authenticateClientCredentialsOAuth 2.0 client-credentials grant. Use a configured Salesforce My Domain.
authenticateJwtBearerOAuth 2.0 JWT bearer token exchange. The assertion can be created with createJwtBearerAssertion.
authenticateSamlAssertionSalesforce SAML assertion flow for API access.
authenticateSamlBearerOAuth 2.0 SAML bearer assertion exchange.
createAuthorizationUrlBuilds a validated Salesforce OAuth authorization URL without making a network request.
exchangeAuthorizationCodeOAuth 2.0 web-server authorization-code exchange, including PKCE and headless code exchanges.
exchangeHybridAuthorizationCodeOAuth 2.0 hybrid web-server authorization-code exchange.
exchangeTokenOAuth 2.0 token exchange using one of Salesforce's supported subject-token types.
pollDeviceAuthorizationPerforms one device-flow polling exchange. Handle authorization_pending or slow_down and poll again.
refreshAccessTokenOAuth 2.0 refresh-token exchange. Rotated refresh tokens are persisted when a store is supplied.
refreshHybridAccessTokenHybrid-app refresh exchange for a refresh token obtained by a supported hybrid/web-server flow.
requestDeviceAuthorizationStarts Salesforce's OAuth 2.0 device flow.
createPkceChallengeDerives an S256 PKCE code challenge from a verifier.
generatePkcePairGenerates a cryptographically random PKCE verifier and its S256 challenge.
createLocalStorageRefreshTokenStoreCreates a refresh-token store backed by a provided Web Storage implementation.
createMemoryRefreshTokenStoreCreates an in-memory refresh-token store for short-lived processes and tests.
createRedisRefreshTokenStoreCreates a refresh-token store backed by a Redis-compatible client.

Classes

ClassDescription
SalesforceOAuthErrorOAuth endpoint rejection without credential-bearing server descriptions in the message.
SalesforceOAuthResponseErrorSalesforce returned a successful response that does not match the documented contract.
SalesforceAuthBound Salesforce OAuth client.

Interfaces

InterfaceDescription
CodeCredentialsNamedUserOptionsOptions for headless authorization with an explicit Salesforce username and password.
CodeCredentialsUserDiscoveryOptionsOptions for headless authorization that discovers the Salesforce user from a login hint.
FirstPartyAuthorizationChallengeOptionsOptions for requesting a first-party Salesforce authorization challenge.
HeadlessAuthorizationRequestFetch-compatible request data for a Salesforce Headless Identity authorization call.
OAuthRequestOptionsShared transport options for Salesforce OAuth requests.
JwtBearerAssertionOptionsOptions for creating a Salesforce JWT bearer assertion.
OAuthClientAssertionOptionsOptions for creating a private_key_jwt client assertion for Salesforce OAuth.
AccessTokenRequestDescribes whether an access-token provider should force a token refresh.
StoredRefreshTokenAuthAccess-token manager that refreshes and persists rotated Salesforce refresh tokens.
StoredRefreshTokenAuthOptionsOptions for access-token management backed by a persistent refresh-token store.
AuthorizationCodeOptionsOptions for exchanging a Salesforce authorization code for tokens.
AuthorizationUrlOptionsOptions for building a Salesforce OAuth authorization URL.
ClientCredentialsOptionsOptions for the Salesforce OAuth client-credentials grant.
DeviceAuthorizationDevice-code response returned when starting Salesforce device authorization.
DeviceAuthorizationOptionsOptions for starting the Salesforce device authorization flow.
DeviceTokenOptionsOptions for polling Salesforce for completion of device authorization.
JwtBearerOptionsOptions for the Salesforce JWT bearer token grant.
RefreshTokenOptionsOptions for exchanging a Salesforce refresh token for a new session.
SalesforceOAuthSessionTokens and instance metadata returned by a Salesforce OAuth exchange.
SamlAssertionOptionsOptions for the Salesforce SAML assertion token grant.
SamlBearerOptionsOptions for the Salesforce SAML bearer token grant.
TokenExchangeOptionsOptions for Salesforce OAuth 2.0 token exchange.
PkcePairPKCE verifier and matching S256 challenge.
SalesforceAuthOptionsOptions for the high-level Salesforce authentication helper.
SalesforceJwtBearerOptionsJWT bearer credentials accepted by SalesforceAuth.
LocalStorageRefreshTokenStoreOptionsOptions for a refresh-token store backed by Web Storage.
RedisLikeMinimal Redis interface required by the Redis refresh-token store.
RedisRefreshTokenStoreOptionsOptions for a refresh-token store backed by Redis.
RefreshTokenStoreMinimal async store used to load and persist Salesforce refresh tokens.
StorageLikeSubset of the Web Storage API required by the local-storage token store.

Type Aliases

Type AliasDescription
CodeCredentialsAuthorizationOptionsOptions accepted by the Headless Identity authorization-code-and-credentials flow.
FirstPartyAuthorizationChallengeResult of a first-party Salesforce authorization challenge request.
FirstPartyAuthorizationValueSerializable value accepted in first-party authorization challenge parameters.
HeadlessGuestAuthorizationOptionsOptions for the guest variant of Salesforce Headless Identity authorization.
PrivateKeyInputSupported sources for the RSA private key used to sign Salesforce JWT assertions.
AccessTokenProviderProvides an access token, optionally forcing refresh for an authentication retry.
ClientAssertionProviderCreates a client assertion, typically regenerated for each token refresh.
TokenExchangeSubjectTokenTypeSubject-token types supported by Salesforce OAuth token exchange.
SalesforceClientAssertionOptionsClient-assertion credentials accepted by SalesforceAuth.

On this page