Skip to main content

InitConfig

Configuration interface for initializing an agent.
import { InitConfig } from '@credo-ts/core'

const config: InitConfig = {
  logger: new ConsoleLogger(LogLevel.info),
  autoUpdateStorageOnStartup: true,
  allowInsecureHttpUrls: false,
  validitySkewSeconds: 30,
}

Properties

logger
Logger
Custom logger instance. Defaults to ConsoleLogger with LogLevel.off.
import { ConsoleLogger, LogLevel } from '@credo-ts/core'

logger: new ConsoleLogger(LogLevel.info)
autoUpdateStorageOnStartup
boolean
default:"false"
Automatically update storage schema when starting agent if needed.
autoUpdateStorageOnStartup: true
allowInsecureHttpUrls
boolean
default:"false"
Allow insecure HTTP URLs in places where HTTPS is usually required.Use with caution - only for local development.
allowInsecureHttpUrls: true // Only for development!
validitySkewSeconds
number
default:"30"
Allowed time skew in seconds for validity checks of credentials and signed objects.Useful for mobile devices that may have slightly inaccurate clocks.Currently affects:
  • Token Status List
  • SD-JWT VC
  • W3C VCDM 1.1 and 2.0 with JWT/SD-JWT
Does not affect:
  • W3C VCDM 1.1 JSON-LD
  • mDOC
validitySkewSeconds: 60 // Allow 60 seconds of skew

AgentConfig

The AgentConfig class wraps InitConfig and provides access to configuration values.

Properties

logger

Logger instance configured for the agent.
agent.config.logger.info('Agent initialized')
Type: Logger

allowInsecureHttpUrls

Whether insecure HTTP URLs are allowed.
if (agent.config.allowInsecureHttpUrls) {
  // HTTP allowed
}
Type: boolean

autoUpdateStorageOnStartup

Whether to automatically update storage on startup.
const autoUpdate = agent.config.autoUpdateStorageOnStartup
Type: boolean

validitySkewSeconds

Allowed validity skew in seconds.
const skew = agent.config.validitySkewSeconds
Type: number

Methods

extend()

Create a new AgentConfig with updated values.
const newConfig = agent.config.extend({
  allowInsecureHttpUrls: true,
})
Parameters:
  • config: Partial<InitConfig> - Configuration values to update
Returns: AgentConfig

toJSON()

Serialize configuration to JSON.
const json = agent.config.toJSON()
console.log(json)
Returns: Object with serialized configuration

Example Usage

import { Agent, InitConfig, ConsoleLogger, LogLevel } from '@credo-ts/core'
import { agentDependencies } from '@credo-ts/node'

const config: InitConfig = {
  logger: new ConsoleLogger(LogLevel.debug),
  autoUpdateStorageOnStartup: true,
  allowInsecureHttpUrls: process.env.NODE_ENV === 'development',
  validitySkewSeconds: 60,
}

const agent = new Agent({
  config,
  dependencies: agentDependencies,
  modules: {
    // ... modules
  },
})

await agent.initialize()

// Access configuration
console.log('Skew allowed:', agent.config.validitySkewSeconds)
agent.config.logger.info('Agent started')

Build docs developers (and LLMs) love