### Running the Responder Source: https://github.com/openwallet-foundation/credo-ts/blob/main/samples/extension-module/README.md Start the responder component of the demo in one terminal after installing dependencies. Wait for the 'Responder listening...' log message. ```sh pnpm responder ``` -------------------------------- ### Copy ngrok Auth Example Source: https://github.com/openwallet-foundation/credo-ts/blob/main/demo-openid/README.md Copy the example ngrok authentication configuration file to enable ngrok proxy setup. ```sh cp ngrok.auth.example.yml ngrok.auth.yml ``` -------------------------------- ### Start ngrok Proxies Source: https://github.com/openwallet-foundation/credo-ts/blob/main/demo-openid/README.md Start the ngrok proxies to expose demo services publicly. This command should be run in a separate terminal. ```sh pnpm proxies ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/openwallet-foundation/credo-ts/blob/main/demo/README.md Install project dependencies using PNPM in one of the terminals. ```sh pnpm install ``` -------------------------------- ### Run Alice Agent Source: https://github.com/openwallet-foundation/credo-ts/blob/main/demo/README.md Start the Alice agent in the left terminal. ```sh pnpm alice ``` -------------------------------- ### Agent Setup and DRPC Usage Source: https://github.com/openwallet-foundation/credo-ts/blob/main/packages/drpc/README.md Demonstrates how to initialize an agent with the DRPC module and use its sendRequest and recvRequest methods. Includes sending a request and processing an incoming request with a response. ```typescript import { DrpcModule } from '@credo-ts/drpc' const agent = new Agent({ config: { /* config */ }, dependencies: agentDependencies, modules: { drpc: new DrpcModule(), /* other custom modules */ }, }) await agent.initialize() // Send a request to the specified connection const responseListener = await senderAgent.modules.drpc.sendRequest(connectionId, { jsonrpc: '2.0', method: 'hello', id: 1, }) // Listen for any incoming requests const { request, sendResponse } = await receiverAgent.modules.drpc.recvRequest() // Process the received request and create a response const result = request.method === 'hello' ? { jsonrpc: '2.0', result: 'Hello world!', id: request.id } : { jsonrpc: '2.0', error: { code: DrpcErrorCode.METHOD_NOT_FOUND, message: 'Method not found' } } // Send the response back await sendResponse(result) ``` -------------------------------- ### Running the Requester Source: https://github.com/openwallet-foundation/credo-ts/blob/main/samples/extension-module/README.md Start the requester component of the demo in a separate terminal. It will connect to the responder and exchange Dummy protocol messages. ```sh pnpm requester ``` -------------------------------- ### Start Docker Services for Testing Source: https://github.com/openwallet-foundation/credo-ts/blob/main/DEVREADME.md Command to quickly set up all necessary services (Postgres, Hyperledger Indy Ledger, Cheqd Ledger) for running tests. Use this for a standard x86_64 environment. ```sh docker compose up -d ``` -------------------------------- ### Instantiate HAIP Agent Source: https://github.com/openwallet-foundation/credo-ts/wiki/2024‐03‐14--‐-Credo-Meeting-Notes Example of how to instantiate a HAIP Agent with optional configuration overrides for config, modules, and dependencies. ```typescript import { HaipAgent } from '@credo-ts-profiles/haip' const haipAgent = new HaipAgent({ config: {}, // override defaults here modules: {}, // override defaults here dependencies: {} // same }) const issuer = agent.modules.haip.createIssuer() ``` -------------------------------- ### Implementing a REST Endpoint to Resolve AnonCreds Resources Source: https://github.com/openwallet-foundation/credo-ts/blob/main/packages/webvh/README.md Example implementation of a GET endpoint to retrieve attested resources based on a `resourceId`. It demonstrates fetching records from a generic storage layer. ```typescript @Get('/resources/:resourceId') async getWebVhResources(@Param('resourceId') resourceId: string, @Res() res: Response) { const agent = await this.agentService.getAgent() const resourcePath = `${agent.did}/resources/${resourceId}` agent.config.logger.debug(`Requested resource ${resourceId}`) if (!resourceId) { throw new HttpException('resourceId not found', HttpStatus.CONFLICT) } if (!agent.did) { throw new HttpException('Agent does not have any defined public DID', HttpStatus.NOT_FOUND) } const [record] = await agent.genericRecords.findAllByQuery({ attestedResourceId: resourcePath, type: 'AttestedResource', }) if (!record) { throw new HttpException('No entry found for resource', HttpStatus.NOT_FOUND) } res.send(record.content) } ``` -------------------------------- ### Run OpenID Provider Source: https://github.com/openwallet-foundation/credo-ts/blob/main/demo-openid/README.md Start the OpenID Provider service in a dedicated terminal. This is the first of the four demo components to run. ```sh pnpm provider ``` -------------------------------- ### Run Drizzle Migrations (Postgres) Source: https://github.com/openwallet-foundation/credo-ts/blob/main/packages/drizzle-storage/README.md Apply database migrations for Drizzle storage using the CLI for a PostgreSQL database. Ensure all necessary extension modules are installed. ```bash # or npm or yarn # Postgres pnpm drizzle-storage --bundle core --bundle didcomm --bundle action-menu --bundle anoncreds --bundle question-answer migrate --dialect postgres --database-url "postgresql://postgres:postgres@localhost:5432/postgres" ``` -------------------------------- ### Run Verifier Source: https://github.com/openwallet-foundation/credo-ts/blob/main/demo-openid/README.md Start the Verifier service in a dedicated terminal. This component requests and verifies presentations. ```sh pnpm verifier ``` -------------------------------- ### Run Drizzle Migrations (SQLite) Source: https://github.com/openwallet-foundation/credo-ts/blob/main/packages/drizzle-storage/README.md Apply database migrations for Drizzle storage using the CLI for a SQLite database. Ensure all necessary extension modules are installed. ```bash # SQL pnpm drizzle-storage --bundle core --bundle didcomm --bundle action-menu --bundle anoncreds --bundle question-answer migrate --dialect sqlite --database-url "file:./sqlite_agent.db" ``` -------------------------------- ### Start Docker Services for Testing on ARM Source: https://github.com/openwallet-foundation/credo-ts/blob/main/DEVREADME.md Command to set up necessary services for testing on ARM-based machines like Apple Silicon. It utilizes a specific Docker Compose file for ARM compatibility. ```sh docker compose -f docker-compose.arm.yml up -d ``` -------------------------------- ### Agent Setup and Action Menu Usage Source: https://github.com/openwallet-foundation/credo-ts/blob/main/packages/action-menu/README.md Demonstrates how to inject the ActionMenuModule into a Credo agent, initialize the agent, request a root menu, and perform an action from the menu. The menu response is received asynchronously. ```typescript import { Agent } from '@credo-ts/core' import { ActionMenuModule } from '@credo-ts/action-menu' // Assume agentDependencies and AgentConfig are defined elsewhere // const agentDependencies = { /* ... */ } const agent = new Agent({ config: { /* config */ }, dependencies: agentDependencies, modules: { actionMenu: new ActionMenuModule(), /* other custom modules */ }, }) await agent.initialize() // To request root menu to a given connection (menu will be received // asynchronously in a ActionMenuStateChangedEvent) await agent.modules.actionMenu.requestMenu({ connectionId }) // To select an option from the action menu await agent.modules.actionMenu.performAction({ connectionId, performedAction: { name: 'option-1' }, }) ``` -------------------------------- ### Run Holder Source: https://github.com/openwallet-foundation/credo-ts/blob/main/demo-openid/README.md Start the Holder service in a dedicated terminal. This component manages and presents credentials. ```sh pnpm holder ``` -------------------------------- ### Run Faber Agent Source: https://github.com/openwallet-foundation/credo-ts/blob/main/demo/README.md Start the Faber agent in the right terminal. ```sh pnpm faber ``` -------------------------------- ### Run Issuer Source: https://github.com/openwallet-foundation/credo-ts/blob/main/demo-openid/README.md Start the Issuer service in a dedicated terminal. This component is responsible for issuing credentials. ```sh pnpm issuer ``` -------------------------------- ### Run Drizzle Migrations with npx Source: https://github.com/openwallet-foundation/credo-ts/blob/main/packages/drizzle-storage/README.md Execute Drizzle storage migrations using npx, ensuring the version matches the runtime agent. This command requires all extension modules to be installed. ```bash # using npx npx @credo-ts/drizzle-storage@^x.x migrate ``` -------------------------------- ### Instantiate AIP 2.0 Agent Source: https://github.com/openwallet-foundation/credo-ts/wiki/2024‐03‐14--‐-Credo-Meeting-Notes Example of how to instantiate an AIP 2.0 Agent, which includes built-in didcomm and toplevel support for AIP 2.0 required formats. ```typescript import { Aip2Agent } from '@credo-ts-profiles/aip2' const aip2Agent = new Aip2Agent({ config: {}, // override defaults here modules: {}, // override defaults here dependencies: {} // same }) ``` -------------------------------- ### Run Issuer with Google Account API Source: https://github.com/openwallet-foundation/credo-ts/blob/main/demo-openid/README.md Configure and run the issuer service with Google Account API integration for fetching external data for credentials. Requires Google Cloud setup and ngrok proxy. ```sh ISSUER_HOST="" GOOGLE_CLIENT_ID="" GOOGLE_CLIENT_SECRET="" pnpm issuer ``` -------------------------------- ### Register WebVh Module with Agent Source: https://github.com/openwallet-foundation/credo-ts/blob/main/packages/webvh/README.md Register the WebVh module, AnonCreds registry, DID resolver, and DID registrar with your agent instance. This setup is necessary to utilize WebVh functionalities. ```typescript import { Agent, DidsModule, AnonCredsModule } from '@credo-ts/core' import { WebVhModule, WebVhAnonCredsRegistry, WebVhDidResolver, WebVhDidRegistrar } from '@credo-ts/webvh' const agent = new Agent({ config: options.config, dependencies: options.dependencies, modules: { anoncreds: new AnonCredsModule({ registries: [ new WebVhAnonCredsRegistry(), ], }), webvhSdk: new WebVhModule(), dids: new DidsModule({ resolvers: [ new WebVhDidResolver() ], registrars: [ new WebVhDidRegistrar() ], }), } }) await agent.initialize() ``` -------------------------------- ### Persist DID Record Metadata Source: https://github.com/openwallet-foundation/credo-ts/blob/main/packages/webvh/README.md Persist the created or updated DID as a record, including the DID document and its metadata. This example shows how to create a `DidRecord` and set its metadata and tags. ```typescript const didRecord = new DidRecord({ did: publicDid, didDocument, role: DidDocumentRole.Created, }) didRecord.metadata.set('log', log) didRecord.setTags({ domain }) ``` -------------------------------- ### Registering an AnonCreds Schema Source: https://github.com/openwallet-foundation/credo-ts/blob/main/packages/webvh/README.md Example of registering a schema using the AnonCreds module. This function returns the schema state and registration metadata. ```typescript const { schemaState, registrationMetadata: schemaMetadata } = await agent.modules.anoncreds.registerSchema({ schema: { attrNames: options.attributes, name: options.name, version: options.version, issuerId, }, options: {}, }) ``` -------------------------------- ### Persisting AnonCreds Registration Metadata Source: https://github.com/openwallet-foundation/credo-ts/blob/main/packages/webvh/README.md Example of saving registration metadata into generic records for later resolution. This is a demonstration and alternative storage mechanisms can be used. ```typescript await agent.genericRecords.save({ id: utils.uuid(), content: registrationMetadata, tags: { attestedResourceId: registrationMetadata.id as string, type: 'AttestedResource' }, }) ``` -------------------------------- ### Expose did.jsonl via API Endpoint Source: https://github.com/openwallet-foundation/credo-ts/blob/main/packages/webvh/README.md Retrieve the `did.jsonl` artifact from DID record metadata and serve it through an API endpoint. This example assumes an Express.js-like framework and retrieves the artifact from the metadata under the 'log' key. ```typescript @Get('/.well-known/did.jsonl') async getDidLog(@Res() res: Response) { const agent = await this.agentService.getAgent() const [didRecord] = await agent.dids.getCreatedDids({ did: agent.did }) const didLog = didRecord.metadata.get('log') as DIDLog[] | null if (didLog) { res.setHeader('Content-Type', 'text/jsonl; charset=utf-8') res.setHeader('Cache-Control', 'no-cache') res.send(didLog?.map(entry => JSON.stringify(entry)).join('\n')) } else { throw new HttpException('DID Log not found', HttpStatus.NOT_FOUND) } } ``` -------------------------------- ### Set Genesis Transaction Path in Dev Container Source: https://github.com/openwallet-foundation/credo-ts/blob/main/DEVREADME.md Example of setting the GENESIS_TXN_PATH environment variable within a Docker development container. Ensure the path is correct relative to the container's root directory. ```console GENESIS_TXN_PATH=/work/network/genesis/local-genesis.txn ``` -------------------------------- ### Build All Packages Source: https://github.com/openwallet-foundation/credo-ts/blob/main/CLAUDE.md Compile all packages within the repository. Execute from the repository root. ```bash pnpm build ``` -------------------------------- ### Navigate to Demo Directory Source: https://github.com/openwallet-foundation/credo-ts/blob/main/demo-openid/README.md Change the current directory to the demo-openid folder within the cloned repository. ```sh cd credo-ts/demo-openid ``` -------------------------------- ### Navigate to Demo Directory Source: https://github.com/openwallet-foundation/credo-ts/blob/main/demo/README.md Change directory into the demo folder of the cloned Credo repository. ```sh cd credo-ts/demo ``` -------------------------------- ### Create a Changeset Source: https://github.com/openwallet-foundation/credo-ts/blob/main/CLAUDE.md Generate a changeset file for documenting changes, typically for changelog entries. Execute from the repository root. ```bash pnpm changeset ``` -------------------------------- ### Initialize Agent with DrizzleStorageModule Source: https://github.com/openwallet-foundation/credo-ts/blob/main/packages/drizzle-storage/README.md Instantiate the Agent and include the DrizzleStorageModule, providing the database instance and bundles. ```typescript import { didcommDrizzleRecords } from "@credo-ts/drizzle-storage/didcomm"; const agent = new Agent({ modules: { drizzleStorage: new DrizzleStorageModule({ database, bundles, }), }, }); ``` -------------------------------- ### Navigating to Extension Module Directory Source: https://github.com/openwallet-foundation/credo-ts/blob/main/samples/extension-module/README.md Change the current directory to the 'extension-module' sample directory within the cloned Credo repository. ```sh cd credo-ts/samples/extension-module ``` -------------------------------- ### Test a File Source: https://github.com/openwallet-foundation/credo-ts/blob/main/CLAUDE.md Run tests for a specific file. Execute from the repository root. ```bash pnpm test ``` -------------------------------- ### Run Verifier with ngrok Proxy Source: https://github.com/openwallet-foundation/credo-ts/blob/main/demo-openid/README.md Run the verifier service using ngrok URLs for external accessibility. Ensure the ngrok proxies are running and configured. ```sh VERIFIER_HOST=https://1d91-123-123-123-123.ngrok-free.app pnpm verifier ``` -------------------------------- ### Run Provider with ngrok Proxy Source: https://github.com/openwallet-foundation/credo-ts/blob/main/demo-openid/README.md Run the provider service using ngrok URLs for external accessibility. Ensure the ngrok proxies are running and configured. ```sh PROVIDER_HOST=https://d404-123-123-123-123.ngrok-free.app ISSUER_HOST=https://d738-123-123-123-123.ngrok-free.app pnpm provider ``` -------------------------------- ### Run All Tests Source: https://github.com/openwallet-foundation/credo-ts/blob/main/DEVREADME.md Command to execute all available tests, including unit and end-to-end tests. ```sh pnpm test ``` -------------------------------- ### Lint and Format Code Source: https://github.com/openwallet-foundation/credo-ts/blob/main/CLAUDE.md Apply linting and formatting rules to fix code style issues. Execute from the repository root. ```bash pnpm style:fix ``` -------------------------------- ### Initialize Agent with QuestionAnswerModule Source: https://github.com/openwallet-foundation/credo-ts/blob/main/packages/question-answer/README.md Inject the QuestionAnswerModule into the agent configuration. This is necessary for the module to function and access agent capabilities. ```typescript import { QuestionAnswerModule } from '@credo-ts/question-answer' const agent = new Agent({ config: { /* config */ }, dependencies: agentDependencies, modules: { questionAnswer: new QuestionAnswerModule(), /* other custom modules */ }, }) await agent.initialize() ``` -------------------------------- ### Run Unit Tests Source: https://github.com/openwallet-foundation/credo-ts/blob/main/DEVREADME.md Command to execute all unit tests. These tests do not require external Docker services to be running. ```sh pnpm test:unit ``` -------------------------------- ### Registering DummyModule with Agent Source: https://github.com/openwallet-foundation/credo-ts/blob/main/samples/extension-module/README.md Register a custom extension module by adding it to the `modules` property of `AgentOptions`. Ensure the module and its dependencies are correctly initialized. ```typescript import { DummyModule } from './dummy' // Register the module with it's dependencies const agent = new Agent({ config: { /* config */ }, dependencies: agentDependencies, modules: { dummy: new DummyModule({ /* module config */ }), /* other custom modules */ }, }) await agent.initialize() ``` -------------------------------- ### Initialize Agent with Credo DIDComm Module Source: https://github.com/openwallet-foundation/credo-ts/blob/main/packages/didcomm/README.md This snippet shows how to initialize an agent with the Credo DIDComm Module, including registering inbound and outbound transports and creating an invitation. Ensure you have the necessary agent dependencies and configure the DIDComm module with your specific settings. ```typescript import type { DidCommModuleConfigOptions } from "@credo-ts/didcomm"; import { agentDependencies, DidCommHttpInboundTransport } from "@credo-ts/node"; import { DidCommModule, DidCommHttpOutboundTransport } from "@credo-ts/didcomm"; const agent = new Agent({ config: { /* config */ }, dependencies: agentDependencies, modules: { didcomm: new DidCommModule({ /* didcomm config */ connections: { /* Custom module settings */ }, proofs: { /* Custom module settings */ }, credentials: { /* Custom module settings */ }, // can also provide module config for: // mediator: {}, // mediationRecipient: {}, // messagePickup: {}, // discovery: {}, // basicMessages: {}, }), /* other custom modules */ }, }); // Register inbound and outbound transports for DIDComm agent.didcomm.registerInboundTransport( new DidCommHttpInboundTransport({ port }) ); agent.didcomm.registerOutboundTransport(new DidCommHttpOutboundTransport()); await agent.initialize(); // Create an invitation const outOfBand = await agent.didcomm.oob.createInvitation(); ``` -------------------------------- ### Run Issuer with ngrok Proxy Source: https://github.com/openwallet-foundation/credo-ts/blob/main/demo-openid/README.md Run the issuer service using ngrok URLs for external accessibility. Ensure the ngrok proxies are running and configured. ```sh PROVIDER_HOST=https://d404-123-123-123-123.ngrok-free.app ISSUER_HOST=https://d738-123-123-123-123.ngrok-free.app pnpm issuer ``` -------------------------------- ### Run Drizzle Storage Migration with NPX Source: https://github.com/openwallet-foundation/credo-ts/blob/main/packages/drizzle-storage/README.md Use this command to migrate your Drizzle storage when using Credo TS. ```bash npx @credo-ts/drizzle-storage@^x.x migrate ``` -------------------------------- ### Create a did:webvh DID Source: https://github.com/openwallet-foundation/credo-ts/blob/main/packages/webvh/README.md Create a new `did:webvh` DID using the agent's DID API. The resulting DID state, including the public DID and DID document, should be stored for future use. ```typescript const { didState } = await agent.dids.create({ method: 'webvh', domain }) const { did: publicDid, didDocument } = didState if (!publicDid || !didDocument) { if (didState.state === 'failed') { agent.config.logger.error(`Failed to create did:webvh record: ${didState.reason}`) } } ``` -------------------------------- ### PostgreSQL Database Connection with pg Source: https://github.com/openwallet-foundation/credo-ts/blob/main/packages/drizzle-storage/README.md Connect to a PostgreSQL database using the 'pg' driver for Drizzle ORM. ```typescript import { drizzle } from "drizzle-orm/node-postgres"; const database = drizzle( "postgresql://postgres:postgres@localhost:5432/postgres" ); ``` -------------------------------- ### SQLite Database Connection with libsql Source: https://github.com/openwallet-foundation/credo-ts/blob/main/packages/drizzle-storage/README.md Connect to a SQLite database using the 'libsql' driver for Drizzle ORM. ```typescript import { drizzle } from "drizzle-orm/libsql"; const database = drizzle("file:./database.db"); ``` -------------------------------- ### Configure Metro Bundler for React Native SQL Extension Source: https://github.com/openwallet-foundation/credo-ts/blob/main/packages/drizzle-storage/README.md Update your `metro.config.js` to include the `sql` extension in `sourceExts` for React Native projects. ```javascript const { getDefaultConfig } = require("expo/metro-config"); /** @type {import('expo/metro-config').MetroConfig} */ const config = getDefaultConfig(__dirname); config.resolver.sourceExts.push("sql"); // <--- add this module.exports = config; ``` -------------------------------- ### Send a Question Source: https://github.com/openwallet-foundation/credo-ts/blob/main/packages/question-answer/README.md Use this method to send a question to a specific connection. Provide the connection ID, the question text, and the valid response options. ```typescript // To send a question to a given connection await agent.modules.questionAnswer.sendQuestion(connectionId, { question: 'Do you want to play?', validResponses: [{ text: 'Yes' }, { text: 'No' }], }) ``` -------------------------------- ### Run End-to-End Tests Source: https://github.com/openwallet-foundation/credo-ts/blob/main/DEVREADME.md Command to execute all end-to-end tests. These tests typically require external services like ledgers and databases to be running. ```sh pnpm test:e2e ``` -------------------------------- ### Clone Credo Repository Source: https://github.com/openwallet-foundation/credo-ts/blob/main/demo/README.md Clone the Credo git repository to your local machine. ```sh git clone https://github.com/openwallet-foundation/credo-ts.git ``` -------------------------------- ### Interacting with Dummy Module API and Events Source: https://github.com/openwallet-foundation/credo-ts/blob/main/samples/extension-module/README.md Call custom module API methods via the agent's modules namespace and subscribe to module-specific events using the Agent's EventEmitter. ```typescript agent.events.on(DummyEventTypes.StateChanged, async (event: DummyStateChangedEvent) => { if (event.payload.dummyRecord.state === DummyState.RequestReceived) { await agent.modules.dummy.respond(event.payload.dummyRecord) } }) const record = await agent.modules.dummy.request(connection) ``` -------------------------------- ### Define Drizzle Storage Bundles Source: https://github.com/openwallet-foundation/credo-ts/blob/main/packages/drizzle-storage/README.md Define the bundles for an agent using specific extension modules. Ensure bundles are ordered to account for dependencies. ```typescript const bundles = [coreBundle, didcommBundle, actionMenuBundle, anoncredsBundle, questionAnswerBundle] as const; ``` -------------------------------- ### Apply React Native Drizzle Migrations Source: https://github.com/openwallet-foundation/credo-ts/blob/main/packages/drizzle-storage/README.md Set up and apply Drizzle migrations within your React Native application before initializing the Credo agent. Ensure your SQLite driver and records are correctly configured. ```typescript import { applyReactNativeMigrations } from "@credo-ts/drizzle-storage"; // or drizzle-orm/op-sqlite/migrator import { migrate } from "drizzle-orm/expo-sqlite/migrator"; // Uses the same database instance as provided to the agent import { database } from "./database"; // Import the SQLite migrations for all modules you're using // If you're using custom modules consult with the documentation of that modules // to determine where to import the SQLite migrations from. import coreMigrations from "@credo-ts/drizzle-storage/migrations/core/sqlite/migrations"; import didcommMigrations from "@credo-ts/drizzle-storage/migrations/didcomm/sqlite/migrations"; import anoncredsMigrations from "@credo-ts/drizzle-storage/migrations/anoncreds/sqlite/migrations"; // Execute this method in your code, before initializing the agent. You should do // this on every agent startup, or if you're sure the agent hasn't updated, you can // only do it when you have added new modules / updated the Credo version. If there // are no pending migration, this method will resolve quickly. export async function applyMyReactNativeMigrations() { return await applyReactNativeMigrations({ migrate, database, migrations: [coreMigrations, didcommMigrations, anoncredsMigrations], }); } ``` -------------------------------- ### Configure Babel for React Native SQL Imports Source: https://github.com/openwallet-foundation/credo-ts/blob/main/packages/drizzle-storage/README.md Add the `babel-plugin-inline-import` to your `babel.config.js` to allow inline imports of SQL files in React Native projects. ```javascript module.exports = function (api) { api.cache(true); return { presets: ["babel-preset-expo"], plugins: [["inline-import", { extensions: [".sql"] }]], // <-- add this }; }; ``` -------------------------------- ### Query for Existing did:webvh Records Source: https://github.com/openwallet-foundation/credo-ts/blob/main/packages/webvh/README.md Retrieve an existing `did:webvh` record from the repository by querying with its domain and method. This is useful for locating previously created DID records. ```typescript const webVhdDidRecord = await didRepository.findSingleByQuery(agentContext, { domain: parsed.id, method: 'webvh', }) ``` -------------------------------- ### Resolve DID-Linked Resources with WebVH API Source: https://github.com/openwallet-foundation/credo-ts/blob/main/packages/webvh/README.md Use the `resolveResource` method from the WebVh API to dereference a URL for a DID-linked resource, such as a schema or credential definition. Ensure the `webvhSdk` key matches the one used during module registration. ```typescript const result = await agent.modules.webvhSdk.resolveResource( `${publicDid}/resources/${resourceId}` ) if ('error' in result) { throw new Error(result.message) } // For JSON resources, result.content is the parsed object. // For non-JSON resources, result.content is text. const resourceContent = result.content ``` -------------------------------- ### Send an Answer Source: https://github.com/openwallet-foundation/credo-ts/blob/main/packages/question-answer/README.md Use this method to send an answer to a previously received question. Provide the record ID of the question and the chosen answer text. ```typescript // To send an answer related to a given question answer record await agent.modules.questionAnswer.sendAnswer(questionAnswerRecordId, 'Yes') ``` -------------------------------- ### SQLite Database Connection with expo-sqlite Source: https://github.com/openwallet-foundation/credo-ts/blob/main/packages/drizzle-storage/README.md Connect to a SQLite database using the 'expo-sqlite' driver for Drizzle ORM. This can be configured to use SQLCipher for encryption. ```typescript import { drizzle } from "drizzle-orm/expo-sqlite"; import { openDatabaseSync } from "expo-sqlite/next"; const expo = openDatabaseSync("database.db"); const database = drizzle(expo); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.