Skip to content

Commit e3a6444

Browse files
authored
Merge pull request #306 from Sphereon-Opensource/fix/IATAB2B-47
fix/IATAB2B-47
2 parents ba20527 + 61781f4 commit e3a6444

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

packages/oid4vci-issuer/src/functions.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,14 @@ export function getJwtVerifyCallback({ verifyOpts }: { verifyOpts?: JWTVerifyOpt
5151

5252
const header = jwtDecode<JWTHeader>(args.jwt, { header: true })
5353
const payload = jwtDecode<JWTPayload>(args.jwt, { header: false })
54+
const kid = args.kid ?? header.kid
55+
const jwk = !kid ? jwkInfo.jwk : undefined // TODO double-check if this is correct
5456
return {
5557
alg,
5658
...identifier,
5759
jwt: { header, payload },
60+
...(kid && { kid }),
61+
...(jwk && { jwk }),
5862
} as JwtVerifyResult<DIDDocument>
5963
}
6064

@@ -326,20 +330,19 @@ export async function createVciIssuer(
326330
).build()
327331
}
328332

329-
export async function createAuthRequestUriCallback(opts: { path: string, presentationDefinitionId: string }): Promise<() => Promise<string>> {
333+
export async function createAuthRequestUriCallback(opts: { path: string; presentationDefinitionId: string }): Promise<() => Promise<string>> {
330334
async function authRequestUriCallback(): Promise<string> {
331335
const path = opts.path.replace(':definitionId', opts.presentationDefinitionId)
332336
return fetch(path, {
333337
method: 'POST',
334338
headers: {
335339
'Content-Type': 'application/json',
336-
}
337-
})
338-
.then(async (response): Promise<string> => {
340+
},
341+
}).then(async (response): Promise<string> => {
339342
if (response.status >= 400) {
340343
return Promise.reject(Error(await response.text()))
341344
} else {
342-
const responseData = await response.json();
345+
const responseData = await response.json()
343346

344347
if (!responseData.authRequestURI) {
345348
return Promise.reject(Error('Missing auth request uri in response body'))
@@ -348,26 +351,27 @@ export async function createAuthRequestUriCallback(opts: { path: string, present
348351
return responseData.authRequestURI
349352
}
350353
})
351-
352354
}
353355

354356
return authRequestUriCallback
355357
}
356358

357-
export async function createVerifyAuthResponseCallback(opts: { path: string, presentationDefinitionId: string }): Promise<(correlationId: string) => Promise<boolean>> {
359+
export async function createVerifyAuthResponseCallback(opts: {
360+
path: string
361+
presentationDefinitionId: string
362+
}): Promise<(correlationId: string) => Promise<boolean>> {
358363
async function verifyAuthResponseCallback(correlationId: string): Promise<boolean> {
359364
return fetch(opts.path, {
360365
method: 'POST',
361366
headers: {
362367
'Content-Type': 'application/json',
363368
},
364369
body: JSON.stringify({ definitionId: opts.presentationDefinitionId, correlationId }),
365-
})
366-
.then(async (response): Promise<boolean> => {
370+
}).then(async (response): Promise<boolean> => {
367371
if (response.status >= 400) {
368372
return Promise.reject(Error(await response.text()))
369373
} else {
370-
const responseData = await response.json();
374+
const responseData = await response.json()
371375

372376
if (!responseData.status) {
373377
return Promise.reject(Error('Missing status in response body'))

0 commit comments

Comments
 (0)