Skip to content

Commit

Permalink
fix: added schema export for oid4vci-issuer-rest-client and some docs
Browse files Browse the repository at this point in the history
  • Loading branch information
sksadjad committed Jun 15, 2023
1 parent a57e202 commit 7db9c1b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,27 @@ import { IAgentPlugin } from '@veramo/core'
const debug = Debug('sphereon:ssi-sdk.oid4vci-issuer-rest-client')

/**
* @beta
* {@inheritDoc IOID4VCIRestClient}
*/
export class OID4VCIRestClient implements IAgentPlugin {
readonly methods: IOID4VCIRestClient = {
vciClientCreateOfferUri: this.vciClientCreateOfferUri.bind(this),
}

private readonly agentBaseURL?: string
private readonly agentBaseUrl?: string

constructor(args?: { baseUrl?: string }) {
if (args?.baseUrl) {
this.agentBaseURL = args.baseUrl
this.agentBaseUrl = args.baseUrl
}
}

/** {@inheritDoc IOID4VCIRestClient.vciClientCreateOfferUri} */
private async vciClientCreateOfferUri(args: IVCIClientCreateOfferUriRequestArgs): Promise<IVCIClientCreateOfferUriResponse> {
if (!args.credentials || !args.grants) {
return Promise.reject(Error("Can't generate the credential offer url without credentials and grants params present."))
}
const baseUrl = args.baseUrl || this.agentBaseURL
const baseUrl = args.baseUrl || this.agentBaseUrl
if (!baseUrl) {
return Promise.reject(Error('No base url has been provided'))
}
Expand All @@ -54,7 +55,7 @@ export class OID4VCIRestClient implements IAgentPlugin {
return await origResponse.json()
} catch (e) {
debug(`Error on posting to url ${url}: ${e}`)
throw e
return Promise.reject(Error(`request to ${url} returned ${e}`));
}
}

Expand Down
5 changes: 5 additions & 0 deletions packages/oid4vci-issuer-rest-client/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
/**
* @public
*/
const schema = require('../plugin.schema.json')
export { schema }
export { OID4VCIRestClient } from './agent/OID4VCIRestClient'
export * from './types/IOID4VCIRestClient'

0 comments on commit 7db9c1b

Please sign in to comment.