How openwallet-foundation/credo-ts works
Project Type and Purpose
• This is a large TypeScript monorepo (managed with pnpm) providing a modular framework for building decentralized-identity solutions.
• It exposes a core “Agent” abstraction plus pluggable packages for DIDComm messaging, credential issuance/presentation (AnonCreds, W3C VCs, SD-JWT), ledger integrations (Indy-VDR, Cheqd), OpenID4VC flows, multi-tenant support, transports (HTTP/WS), storage layers (Askar, in-memory, filesystem), and platform runtimes (Node, React Native).
High-Level Architecture Components
a. Runtime Environments
• Node.js (@credo-ts/node)
• React Native (@credo-ts/react-native)
b. Application Layer
• Consumer application instantiates one or more Agents via @credo-ts/core (BaseAgent, AgentConfig, AgentModules).
• Optional multi-tenant layer (@credo-ts/tenants) coordinates multiple logical Agent contexts.
c. Core Agent
• Event bus and dependency manager
• Module registry (didcomm, credentials, proofs, connections, cache, generic-records, mdoc, sd-jwt-vc, vc, x509, question-answer, action-menu, drpc, etc.)
• Transport orchestration (inbound/outbound HTTP & WebSocket)
d. Protocol Modules
• DIDComm (message envelope, decorators, dispatcher, handlers)
• Connections (DID exchange state machine)
• Credentials & Proofs (formats, protocols v1/v2, handlers, services)
• OpenID4VC (issuer, holder, verifier modules, express routers)
• AnonCreds (Rust core via FFI, holder/issuer/verifier services)
• Ledger integrations (Indy-VDR, Cheqd registry services)
e. Crypto Layer
• JWS, JOSE key management, hashing, multibase/varint encoders
• Native/subtle implementations (CredoWebCrypto, CredoSubtle)
• BBS+ signature suites, SD-JWT
f. Storage Layer
• Askar wallet & storage module (supports SQLite, Postgres, in-memory)
• Generic repository API (records, migrations)
• Single-context LRU cache
g. Transports
• HTTP/WS outbound/inbound transports
• pluggable custom transports
h. External Systems
• DID registries & resolvers (did:web, did:key, did:jwk, did:peer, did:sov, did:indy, did:cheqd)
• Ledger pools (Indy-VDR, Cheqd nodes)
• OpenID4VC endpoints (oauth2/token, credential, metadata)
How Components Interact (Data Flows)
• Consumer invokes Agent API → Agent routes call to specific Module Service
• Module constructs a protocol message → Crypto layer signs/encrypts → Transport layer sends over HTTP/WS
• Inbound transport receives message → Agent dispatches via DIDComm dispatcher → Protocol handler updates state in repository → Emits events back to consumer
• Credential issuance: Agent + AnonCreds & Indy-VDR modules coordinate ledger writes, tails file service, key-correctness proofs
• OpenID4VC issuance: Express router → OpenID4VC module services → storage & crypto → responses
Architectural Patterns & Principles
• Modular plugin architecture: each feature is a self-contained npm package that registers with the core Agent via a dependency manager.
• Dependency inversion: core defines interfaces, modules implement them.
• Event-driven: modules emit/consume events via central EventEmitter.
• Repository pattern + migrations for storage.
• Strategy pattern for transports, signature suites, credential/proof formats.
• Adapter pattern for ledger integrations and crypto backends.
Technologies & Frameworks
• TypeScript & Node.js / React Native
• pnpm workspaces
• jest for testing
• express (for OpenID4VC REST endpoints)
• indy-vdr / indy-sdk-to-askar migration
• asark-ffi wallet backends
Essential Elements
• Clear component names matching npm packages or class names
• Annotations for key patterns (e.g., “EventEmitter publishes ‘message-received’”)