diff --git a/packages/ssi/src/credentials/credentials.ts b/packages/ssi/src/credentials/credentials.ts index 56e297f..27aa8a8 100644 --- a/packages/ssi/src/credentials/credentials.ts +++ b/packages/ssi/src/credentials/credentials.ts @@ -4,6 +4,7 @@ import type { CredentialExchangeRecord, CredentialProtocol, DeleteCredentialOptions, + ProposeCredentialOptions, SendCredentialProblemReportOptions } from '@aries-framework/core' @@ -28,6 +29,17 @@ export const getFormattedCredentialData = async (agent: Agent, credentialRecordI return agent.credentials.getFormatData(credentialRecordId) } +/** + * Propose a credential to connection. + * + * @param agent The agent instance to use for accepting the credential offer. + * @param options - The options for proposing the credential. + * @returns A promise that resolves with the proposed credential. + */ +export const proposeCredential = async (agent: Agent, options: ProposeCredentialOptions<[]>) => { + return agent.credentials.proposeCredential(options) +} + /** * Accepts a credential offer. * diff --git a/packages/ssi/src/genericRecords/genericRecords.ts b/packages/ssi/src/genericRecords/genericRecords.ts new file mode 100644 index 0000000..85c739b --- /dev/null +++ b/packages/ssi/src/genericRecords/genericRecords.ts @@ -0,0 +1,79 @@ +import type { Agent, Query } from '@aries-framework/core' +import type { + GenericRecord, + SaveGenericRecordOption +} from '@aries-framework/core/build/modules/generic-records/repository/GenericRecord' + +/** + * Retrieves all credential exchange records from the agent. + * + * @param agent The agent instance to use for retrieving the credential exchange records. + * @returns A promise that resolves to an array of credential exchange records. + */ +export const addWalletRecord = async (agent: Agent, options: SaveGenericRecordOption) => { + return agent.genericRecords.save(options) +} + +/** + * Retrieves the generic record for a given record ID. + * @param agent The agent instance to use for retrieving the generic record. + * @param id The ID of the generic record to retrieve. + * @returns A Promise that resolves with the generic record for the given ID. + */ +export const findWalletRecordById = async (agent: Agent, id: string) => { + return agent.genericRecords.findById(id) +} + +/** + * Retrieves all generic records from the agent. + * + * @param agent The agent instance to use for retrieving the generic records. + * @returns A promise that resolves to an array of generic records. + */ +export const getAllWalletRecords = async (agent: Agent) => { + return agent.genericRecords.getAll() +} + +/** + * Updates a generic record. + * + * @param agent The agent instance to use for updating the generic record. + * @param record The generic record to update. + * @returns A promise that resolves with the updated generic record. + */ +export const updateWalletRecord = async (agent: Agent, record: GenericRecord) => { + return agent.genericRecords.update(record) +} + +/** + * Deletes a generic record. + * + * @param agent The agent instance to use for deleting the generic record. + * @param record The generic record to delete. + * @returns A promise that resolves with the deleted generic record. + */ +export const deleteWalletRecord = async (agent: Agent, record: GenericRecord) => { + return agent.genericRecords.delete(record) +} + +/** + * Deletes a generic record by ID. + * + * @param agent The agent instance to use for deleting the generic record. + * @param id The ID of the generic record to delete. + * @returns A promise that resolves with the deleted generic record. + */ +export const deleteWalletRecordById = async (agent: Agent, id: string) => { + return agent.genericRecords.deleteById(id) +} + +/** + * Retrieves all generic records from the agent that match the given query. + * + * @param agent The agent instance to use for retrieving the generic records. + * @param query The query to use for retrieving the generic records. + * @returns A promise that resolves to an array of generic records. + */ +export const findWalletRecordsByQuery = async (agent: Agent, query: Query) => { + return agent.genericRecords.findAllByQuery(query) +} diff --git a/packages/ssi/src/genericRecords/index.ts b/packages/ssi/src/genericRecords/index.ts new file mode 100644 index 0000000..9bfe697 --- /dev/null +++ b/packages/ssi/src/genericRecords/index.ts @@ -0,0 +1 @@ +export * from './genericRecords' diff --git a/packages/ssi/src/index.ts b/packages/ssi/src/index.ts index dd7bc72..47905bc 100644 --- a/packages/ssi/src/index.ts +++ b/packages/ssi/src/index.ts @@ -91,6 +91,7 @@ export * from './credentials' export * from './proofs' export * from './basicMessages' export * from './pushNotifications' +export * from './genericRecords' // Core export { LogLevel, diff --git a/packages/ssi/src/proofs/proofs.ts b/packages/ssi/src/proofs/proofs.ts index 7a32266..0afe922 100644 --- a/packages/ssi/src/proofs/proofs.ts +++ b/packages/ssi/src/proofs/proofs.ts @@ -7,6 +7,7 @@ import type { GetCredentialsForProofRequestOptions, ProofExchangeRecord, ProofProtocol, + ProposeProofOptions, RequestProofOptions, SelectCredentialsForProofRequestOptions, SendProofProblemReportOptions @@ -62,6 +63,17 @@ export const getProofRequestAgentMessage = async (agent: Agent, proofRecordId: s return agent.proofs.findRequestMessage(proofRecordId) } +/** + * Propose a proof to connection. + * + * @param agent The agent instance to use for proposing the proof. + * @param options - The options for proposing the proof. + * @returns A promise that resolves with the proposed proof. + */ +export const proposeProof = async (agent: Agent, options: ProposeProofOptions) => { + return agent.proofs.proposeProof(options) +} + /** * Creates a proof request. *