Skip to content

Commit 9513525

Browse files
committed
chore: made tests pass again
1 parent 5674698 commit 9513525

2 files changed

Lines changed: 12 additions & 16 deletions

File tree

packages/callback-example/lib/__tests__/issuerCallback.spec.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import { KeyObject } from 'crypto'
22

33
import { uuidv4 } from '@sphereon/oid4vc-common'
4-
import {
5-
CredentialRequestClientBuilder,
6-
CredentialRequestClientBuilderV1_0_15,
7-
ProofOfPossessionBuilder
8-
} from '@sphereon/oid4vci-client'
4+
import { CredentialRequestClientBuilderV1_0_15, ProofOfPossessionBuilder } from '@sphereon/oid4vci-client'
95
import {
106
Alg,
117
CNonceState,
@@ -21,7 +17,6 @@ import {
2117
} from '@sphereon/oid4vci-common'
2218
import {
2319
AuthorizationServerMetadataBuilder,
24-
CredentialDataSupplierResult,
2520
CredentialSupportedBuilderV1_15,
2621
MemoryStates,
2722
VcIssuer,
@@ -172,7 +167,7 @@ describe('issuerCallback', () => {
172167
})
173168

174169
const nonces = new MemoryStates<CNonceState>()
175-
await nonces.set('test_value', { cNonce: 'test_value', createdAt: +new Date(), issuerState: 'existing-state' })
170+
await nonces.set('test_value', { cNonce: 'test_value', createdAt: +new Date() })
176171
vcIssuer = new VcIssuerBuilder()
177172
.withAuthorizationServers('https://authorization-server')
178173
.withCredentialEndpoint('https://credential-endpoint')
@@ -309,6 +304,10 @@ describe('issuerCallback', () => {
309304

310305
const credentialResponse = await vcIssuer.issueCredential({
311306
credentialRequest: credentialRequest,
307+
issuerCorrelation: {
308+
preAuthorizedCode: 'test_code',
309+
issuerState: 'existing-state'
310+
},
312311
credential,
313312
responseCNonce: state,
314313
credentialSignerCallback: getIssuerCallbackV1_0_15(credential, credentialRequest, didKey.keyPairs, didKey.didDocument.verificationMethod[0].id)

packages/issuer/lib/VcIssuer.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -691,24 +691,21 @@ export class VcIssuer {
691691
const issuer_state = 'issuer_state' in credentialRequest && credentialRequest.issuer_state
692692
? credentialRequest.issuer_state : issuerCorrelation.issuerState
693693
if (!nonce && !issuer_state) {
694-
throw Error('No nonce was found in the Proof of Possession')
694+
throw Error('No nonce or issuer_state was found in the Proof of Possession')
695695
}
696-
let createdAt: number
696+
697+
let createdAt: number = +new Date()
697698
let cNonceState: CNonceState | undefined
698699
if (nonce) {
699700
cNonceState = await this.cNonces.getAsserted(nonce)
700-
/*
701-
preAuthorizedCode = cNonceState.preAuthorizedCode
702-
issuerState = cNonceState.issuerState
703-
*/
704701
createdAt = cNonceState.createdAt
705-
} else if (issuer_state) {
702+
}
703+
if (issuer_state) {
706704
const session = await this._credentialOfferSessions.getAsserted(issuer_state as string)
707705
issuerState = issuer_state as string | undefined
708706
createdAt = session.createdAt
709-
} else {
710-
throw Error('No nonce or issuer_state was found in the Proof of Possession')
711707
}
708+
712709
// The verify callback should set the correct values, but let's look at the JWT ourselves to to be sure
713710
const alg = jwtVerifyResult.alg ?? header.alg
714711
const kid = jwtVerifyResult.kid ?? header.kid

0 commit comments

Comments
 (0)