How jolocom/jolocom-lib works
And Isolate the Major Components
• Core Identity Modules: Look at the directories “js/identity” and “ts/identity” which include the construction and management of DID documents. Also note the “js/identityWallet” and “ts/identityWallet” folders for handling identity wallets.
• Credential Management: The “credentials” and “signedCredential” folders (found under both “js” and “ts”) handle the creation and operations on credentials and signed credentials.
• DID Methods: There are dedicated directories for “didMethods” with sub-folders for different DID method implementations (e.g., “jolo” and “local”). These modules encapsulate the logic for DID registration, recovery, and resolution.
• Interaction Tokens: Multiple folders (“js/interactionTokens” and “ts/interactionTokens”) contain modules for constructing and parsing various tokens such as authentication tokens, credential offer/response tokens, and credentials receive tokens, often built upon the JSON Web Token standard.
• Linked Data and Cryptographic Signatures: Directories like “js/linkedData”, “js/linkedDataSignature”, and their TypeScript equivalents provide functionality for linked data signatures and handling cryptographic signature suites.
• Utilities and Error Handling: The “js/utils” and “ts/utils” directories include functions for data validation, cryptographic helpers, and context management. The “js/errors” and “ts/errors” directories manage error definitions across the library.
• Testing: The “tests” directory (with subdirectories for each thematic area such as “credential”, “didMethods”, “identity”, “interactionTokens”, etc.) reflects an emphasis on unit and integration testing, ensuring that the interactions between these components are covered.
Understand Component Relationships and Data Flow
• The Identity and DID Document modules form the backbone, providing the core representation of identities.
• The DID Methods modules interact closely with identity functionality – they perform critical tasks like resolution, registration, and recovery which are necessary for managing decentralized identities.
• Credential modules (both issuance and verification of credentials and signed credentials) depend upon identity information and are often wrapped in interaction tokens.
• Interaction tokens serve as a communication layer, wrapping data (often using JSON Web Tokens) to support operations like authentication and credential exchange.
• Utility and helper methods support all core processes, and error handling is integrated across the system to ensure robustness.
• The library is designed to be modular; each component (identity, credentials, interaction tokens, DID methods, linked data) is separately maintained but interacts via well-defined interfaces.
Architectural Patterns and Design Principles
• Modularity and Separation of Concerns: The clear division into directories (credentials, didMethods, identity, interactionTokens) shows an architectural emphasis on loosely coupled modules.
• Interface and Type Definitions: With TypeScript’s heavy presence (evidenced by the “ts” and “js” folders containing type definition files), the design leverages strict typing and clearly defined interfaces for predictable interactions between modules.
• Extensibility: The separation between different DID methods (e.g., “jolo” versus “local”) indicates an architectural choice to support interchangeable implementations.
• Test-Driven Development: A comprehensive test suite indicates that unit and integration test components help validate interactions among modules.