Function: createCantonAuthProvider()
createCantonAuthProvider(
config:CantonAuthConfig,options?:OAuthRequestOptions):Promise<CantonAuthProvider>
Defined in: canton/authentication/index.ts:152
Build an AuthProvider from a discriminated AuthConfig.
Supports the static and clientCredentials schemes — both are fully
runtime-agnostic (pure fetch + WebCrypto). The authorizationCode scheme
is not handled here because it requires environment-specific
orchestration (callback server, browser); use the protocol helpers exported
from this package (buildAuthorizationRequest,
validateAuthorizationCallback, exchangeAuthorizationCode,
createAuthorizationCodeProvider) to compose it with your own
callback handling.
The type field selects the auth scheme; when omitted, "static"
is assumed (backward compatible with the existing CantonConfig.jwt field).
Parameters
| Parameter | Type | Description |
|---|---|---|
config | CantonAuthConfig | Auth config (static or clientCredentials). |
options? | OAuthRequestOptions | Optional fetch override and abort signal. |
Returns
Promise<CantonAuthProvider>
An AuthProvider whose token() yields valid JWTs.
Throws
CCIPError (CANTON_AUTH_ERROR) on invalid config or auth failure.
Example
const provider = await createAuthProvider({
type: AuthType.ClientCredentials,
authUrl: 'https://smartcontract.okta.com/oauth2/austsuml9q2WhPBMM5d7',
clientId: 'my-client-id',
clientSecret: 'my-client-secret',
})