Skip to content

Commit

Permalink
feat: added issuer callback to arguments of the issuer builder
Browse files Browse the repository at this point in the history
Signed-off-by: sksadjad <[email protected]>
  • Loading branch information
sksadjad committed Apr 6, 2023
1 parent cd55d8e commit ed4fe7c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 3 additions & 2 deletions packages/issuer/lib/VcIssuer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ export class VcIssuer {
_userPinRequired?: boolean
_issuerCallback?: CredentialIssuerCallback

constructor(issuerMetadata: IssuerMetadata, userPinRequired?: boolean) {
constructor(issuerMetadata: IssuerMetadata, args?: { userPinRequired?: boolean; callback?: CredentialIssuerCallback }) {
this._issuerMetadata = issuerMetadata
this._userPinRequired = userPinRequired
this._userPinRequired = args && args.userPinRequired ? args.userPinRequired : false
this._issuerCallback = args && args.callback ? args.callback : undefined
}

public getIssuerMetadata() {
Expand Down
10 changes: 8 additions & 2 deletions packages/issuer/lib/builder/VcIssuerBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CredentialSupported, Display, IssuerMetadata, TokenErrorResponse } from '@sphereon/openid4vci-common'
import { CredentialIssuerCallback, CredentialSupported, Display, IssuerMetadata, TokenErrorResponse } from '@sphereon/openid4vci-common'

import { VcIssuer } from '../VcIssuer'

Expand All @@ -11,6 +11,7 @@ export class VcIssuerBuilder {
issuerDisplay?: Display[]
credentialsSupported?: CredentialSupported[]
userPinRequired?: boolean
issuerCallback?: CredentialIssuerCallback

public withCredentialIssuer(issuer: string): VcIssuerBuilder {
this.credentialIssuer = issuer
Expand Down Expand Up @@ -68,6 +69,11 @@ export class VcIssuerBuilder {
return this
}

withIssuerCallback(cb: CredentialIssuerCallback): VcIssuerBuilder {
this.issuerCallback = cb
return this
}

public build(): VcIssuer {
if (!this.credentialEndpoint || !this.credentialIssuer || !this.credentialsSupported) {
throw new Error(TokenErrorResponse.invalid_request)
Expand All @@ -92,6 +98,6 @@ export class VcIssuerBuilder {
if (this.tokenEndpoint) {
metadata.token_endpoint = this.tokenEndpoint
}
return new VcIssuer(metadata, this.userPinRequired)
return new VcIssuer(metadata, { userPinRequired: this.userPinRequired, callback: this.issuerCallback })
}
}

0 comments on commit ed4fe7c

Please sign in to comment.