From 4732b16860737c574d34ac0b66e934b4514e534c Mon Sep 17 00:00:00 2001 From: Poonam Ghewande Date: Mon, 15 Apr 2024 15:48:01 +0530 Subject: [PATCH] add w3c signedCredentail & storedCredential Signed-off-by: Poonam Ghewande --- packages/ssi/src/index.ts | 1 + packages/ssi/src/w3cCredentials/index.ts | 1 + .../ssi/src/w3cCredentials/w3cCredentials.ts | 25 +++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 packages/ssi/src/w3cCredentials/index.ts create mode 100644 packages/ssi/src/w3cCredentials/w3cCredentials.ts diff --git a/packages/ssi/src/index.ts b/packages/ssi/src/index.ts index 3a1ecbd..064bc37 100644 --- a/packages/ssi/src/index.ts +++ b/packages/ssi/src/index.ts @@ -117,6 +117,7 @@ export * from './basicMessages' export * from './pushNotifications' export * from './genericRecords' export * from './questionAnswer' +export * from './w3cCredentials' // Core export { LogLevel, diff --git a/packages/ssi/src/w3cCredentials/index.ts b/packages/ssi/src/w3cCredentials/index.ts new file mode 100644 index 0000000..d6f4d6b --- /dev/null +++ b/packages/ssi/src/w3cCredentials/index.ts @@ -0,0 +1 @@ +export * from './w3cCredentials' diff --git a/packages/ssi/src/w3cCredentials/w3cCredentials.ts b/packages/ssi/src/w3cCredentials/w3cCredentials.ts new file mode 100644 index 0000000..fc57a26 --- /dev/null +++ b/packages/ssi/src/w3cCredentials/w3cCredentials.ts @@ -0,0 +1,25 @@ +import type { Agent, StoreCredentialOptions, W3cJsonLdSignCredentialOptions } from '@credo-ts/core' + +// W3C Credential + +/** + * Signed a W3C credential. + * + * @param agent The agent instance to use for retrieving the credential record. + * @param W3cJsonLdSignCredentialOptions The format of the credential to be signed. + * @returns A Promise that resolves to signed w3c credential . + */ +export const signCredential = async (agent: Agent, options: W3cJsonLdSignCredentialOptions) => { + return await agent.w3cCredentials.signCredential(options) +} + +/** + * Store a W3C credential. + * + * @param agent The agent instance to use for retrieving the credential record. + * @param StoreCredentialOptions The format of the credential to be stored. + * @returns A Promise that resolves to stored w3c credential. + */ +export const storeCredential = async (agent: Agent, options: StoreCredentialOptions) => { + return await agent.w3cCredentials.storeCredential(options) +}