AlviereCore API

AlviereCore is the central class of the SDK. It manages configuration, authentication state, the request cache, and acts as a factory for all service instances.

import { AlviereCore } from '@alviere/core';

const core = new AlviereCore(config?: AlviereCoreConfig);

Instance methods

configure

core.configure(config: Partial<AlviereCoreConfig>): this

Merges the provided fields into the current configuration. Changing jwt clears the internal cache. Returns this for chaining.


generateScopedToken

core.generateScopedToken(accountUuid: string, autoUpdate?: boolean): Promise<string>

Downgrades the current business-level JWT to a consumer-scoped token for accountUuid. This is the standard step before making account-level service calls.

Parameter Type Default Description
accountUuid string UUID of the consumer account to scope to
autoUpdate boolean true When true, also calls configure({ jwt }) with the returned token

Returns the scoped JWT string.


getAccountUuid

core.getAccountUuid(): string

Returns the sub claim from the current JWT. This is the UUID of the account associated with the active token.


getBusinessUuid

core.getBusinessUuid(): string

Returns the business_uuid set in configuration.


isFirstTimeUser

core.isFirstTimeUser(): boolean

Returns true if the account UUID from the JWT matches the business_uuid. Used to detect first-time-user flows where no consumer account exists yet.


isScopedToPayee

core.isScopedToPayee(): boolean

Returns true if the current JWT is scoped to an account UUID that differs from the business_uuid.


clearCache

core.clearCache(): void

Clears the internal request cache. Called automatically when jwt changes via configure(). Call manually to force fresh responses.


getLogger

core.getLogger(): Logger

Returns the internal Logger instance. Useful for integrating SDK log output with your application's logging system.


getCryptor

core.getCryptor(): Cryptor

Returns the internal Cryptor instance. See Utilities for the encryption API.


Service factory methods

Each factory method returns a new service instance bound to the current core configuration. Call them after configuring the JWT.

Method Returns
createAccountsService() AccountsApiService
createPaymentsService() PaymentProcessor
createPaymentsGateway() PaymentsGateway
createPaymentInstrumentsService() PaymentInstrumentsApiService
createWalletsService() WalletsApiService
createBankInfoService() BankInfoApiService
createLegalTextsService() LegalTextsApiService
createAuthGateway() AuthGateway

See Services for method-level documentation for each service.

Static methods

Static methods create standalone utility instances that do not require an AlviereCore instance.

AlviereCore.createValidator

AlviereCore.createValidator(debug?: boolean): Validator

Returns a Validator instance. Pass debug: true to enable validator logging.

AlviereCore.createLogger

AlviereCore.createLogger(debug?: boolean): Logger

Returns a Logger instance.

AlviereCore.createCryptor

AlviereCore.createCryptor(logger?: Logger): Cryptor

Returns a Cryptor instance. The cryptor must have a public certificate loaded before it can encrypt. See Utilities for details.