Skip to content

Commit

Permalink
fix: changed the accepting type in VcIssuer
Browse files Browse the repository at this point in the history
  • Loading branch information
sksadjad committed May 23, 2024
1 parent b24d1ac commit 125cb81
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
5 changes: 2 additions & 3 deletions packages/client/lib/__tests__/SdJwt.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
// @ts-ignore
import nock from 'nock';

import { OpenID4VCIClient } from '..';
import { OpenID4VCIClient } from '..'
import { createAccessTokenResponse, IssuerMetadataBuilderV1_13, VcIssuerBuilder } from '../../../issuer';

export const UNIT_TEST_TIMEOUT = 30000;
Expand Down Expand Up @@ -126,12 +126,11 @@ describe('sd-jwt vc', () => {
});

await client.acquireAccessToken({ pin: '123' });

nock(issuerMetadata.credential_endpoint as string)
.post('/')
.reply(200, async (_, body) =>
vcIssuer.issueCredential({
credentialRequest: body as CredentialRequestV1_0_13,
credentialRequest: { ...(body as CredentialRequestV1_0_13), credential_identifier: offered.vct },
credential: {
vct: 'Hello',
iss: 'did:example:123',
Expand Down
14 changes: 9 additions & 5 deletions packages/issuer/lib/VcIssuer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
CredentialDataSupplierInput,
CredentialOfferPayloadV1_0_13,
CredentialOfferSession,
CredentialOfferV1_0_13,
CredentialOfferV1_0_13, CredentialRequest,
CredentialRequestV1_0_13,
CredentialResponse,
DID_NO_DIDDOC_ERROR,
Expand All @@ -32,7 +32,7 @@ import {
TxCode,
TYP_ERROR,
UniformCredentialRequest,
URIState,
URIState
} from '@sphereon/oid4vci-common'
import { CredentialIssuerMetadataOptsV1_0_13 } from '@sphereon/oid4vci-common/dist/types/v1_0_13.types'
import { CompactSdJwtVc, CredentialMapper, W3CVerifiableCredential } from '@sphereon/ssi-types'
Expand Down Expand Up @@ -222,7 +222,7 @@ export class VcIssuer<DIDDoc extends object> {
* - cNonce an existing c_nonce
*/
public async issueCredential(opts: {
credentialRequest: CredentialRequestV1_0_13
credentialRequest: CredentialRequest
credential?: CredentialIssuanceInput
credentialDataSupplier?: CredentialDataSupplier
credentialDataSupplierInput?: CredentialDataSupplierInput
Expand All @@ -233,6 +233,10 @@ export class VcIssuer<DIDDoc extends object> {
credentialSignerCallback?: CredentialSignerCallback<DIDDoc>
responseCNonce?: string
}): Promise<CredentialResponse> {
if (!('credential_identifier' in opts.credentialRequest)) {
throw new Error('credential request should be of spec version 1.0.13 or above')
}
const credentialRequest: CredentialRequestV1_0_13 = opts.credentialRequest
let preAuthorizedCode: string | undefined
let issuerState: string | undefined
try {
Expand Down Expand Up @@ -262,7 +266,7 @@ export class VcIssuer<DIDDoc extends object> {
throw Error(`Either a credential needs to be supplied or a credentialDataSupplier`)
}
let credential: CredentialIssuanceInput | undefined
let format: OID4VCICredentialFormat = opts.credentialRequest.format
let format: OID4VCICredentialFormat = credentialRequest.format
let signerCallback: CredentialSignerCallback<DIDDoc> | undefined = opts.credentialSignerCallback
if (opts.credential) {
credential = opts.credential
Expand Down Expand Up @@ -413,7 +417,7 @@ export class VcIssuer<DIDDoc extends object> {
jwtVerifyCallback,
tokenExpiresIn,
}: {
credentialRequest: UniformCredentialRequest
credentialRequest: CredentialRequest
tokenExpiresIn: number // expiration duration in seconds
// grants?: Grant,
clientId?: string
Expand Down

0 comments on commit 125cb81

Please sign in to comment.