|
1 | | -import { epochTime, uuidv4 } from '@sphereon/oid4vc-common' |
| 1 | +import { uuidv4 } from '@sphereon/oid4vc-common' |
2 | 2 | import { |
3 | 3 | ACCESS_TOKEN_ISSUER_REQUIRED_ERROR, |
4 | 4 | AccessTokenRequest, |
@@ -434,46 +434,18 @@ export function nonceEndpoint(router: Router, issuer: VcIssuer, opts: INonceEndp |
434 | 434 |
|
435 | 435 | router.post(path, async (request: Request, response: Response) => { |
436 | 436 | try { |
437 | | - let preAuthorizedCode: string | undefined |
438 | | - let issuerState: string | undefined |
439 | | - |
440 | | - // Verify access token if present (optional per spec) |
441 | | - // If not present, the nonce will be unbound to any session |
442 | | - if (request.header('Authorization')) { |
443 | | - try { |
444 | | - const jwt = extractBearerToken(request.header('Authorization')) |
445 | | - const jwtResult = await validateJWT(jwt, { |
446 | | - accessTokenVerificationCallback: issuer.jwtVerifyCallback |
447 | | - }) |
448 | | - |
449 | | - // Extract session info from access token |
450 | | - const accessToken = jwtResult.jwt.payload as AccessTokenRequest |
451 | | - preAuthorizedCode = accessToken['pre-authorized_code'] |
452 | | - } catch (e) { |
453 | | - LOG.warning(e) |
454 | | - return sendErrorResponse(response, 400, { |
455 | | - error: 'invalid_token' |
456 | | - }) |
457 | | - } |
458 | | - } |
459 | | - |
460 | 437 | const cNonce = uuidv4() |
461 | 438 | const cNonceExpiresIn = issuer.cNonceExpiresIn || 300 |
462 | 439 |
|
463 | | - const createdAt = epochTime() |
| 440 | + const createdAt = +Date.now() |
| 441 | + const expiresAt = createdAt + Math.abs(cNonceExpiresIn) * 1000 |
| 442 | + |
464 | 443 |
|
465 | 444 | // Create nonce state - only include session identifiers if available |
466 | 445 | const cNonceState: any = { |
467 | 446 | cNonce, |
468 | | - createdAt: createdAt, |
469 | | - expiresAt: createdAt + cNonceExpiresIn |
470 | | - } |
471 | | - |
472 | | - if (preAuthorizedCode) { |
473 | | - cNonceState.preAuthorizedCode = preAuthorizedCode |
474 | | - } |
475 | | - if (issuerState) { |
476 | | - cNonceState.issuerState = issuerState |
| 447 | + createdAt, |
| 448 | + expiresAt |
477 | 449 | } |
478 | 450 |
|
479 | 451 | await issuer.cNonces.set(cNonce, cNonceState) |
|
0 commit comments