Skip to main content
Version: 1.13.0

Function: createCantonAuthProvider()

createCantonAuthProvider(config: CantonAuthConfig, options?: OAuthRequestOptions): Promise<CantonAuthProvider>

Defined in: canton/authentication/index.ts:128

Build an AuthProvider from a discriminated AuthConfig.

This is the TS analogue of the Go commonconfig.AuthConfig.NewProvider(ctx) method. The type field selects the auth scheme; when omitted, "static" is assumed (backward compatible with the existing CantonConfig.jwt field).

Parameters

ParameterTypeDescription
configCantonAuthConfigAuth config (static, clientCredentials, or authorizationCode).
options?OAuthRequestOptionsOptional fetch override and abort signal.

Returns

Promise<CantonAuthProvider>

An AuthProvider whose tokenSource() yields valid JWTs.

Throws

CCIPError (CANTON_AUTH_ERROR) on invalid config or auth failure.

Example

TypeScript
const provider = await createAuthProvider({
type: AuthType.ClientCredentials,
authUrl: 'https://smartcontract.okta.com/oauth2/austsuml9q2WhPBMM5d7',
clientId: process.env.CANTON_CLIENT_ID!,
clientSecret: process.env.CANTON_CLIENT_SECRET!,
})