Skip to content

Commit 5d63db1

Browse files
authored
Merge pull request #100 from Sphereon-Opensource/develop
new release
2 parents 05e8ea5 + 1ee1261 commit 5d63db1

8 files changed

Lines changed: 16 additions & 17 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ describe('issuerCallback', () => {
267267

268268
expect(credentialResponse).toEqual({
269269
c_nonce: expect.any(String),
270-
c_nonce_expires_in: 300000,
270+
c_nonce_expires_in: 300,
271271
credential: {
272272
'@context': ['https://www.w3.org/2018/credentials/v1', 'https://w3id.org/security/suites/ed25519-2020/v1'],
273273
credentialSubject: {

packages/client/lib/__tests__/SdJwt.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ describe('sd-jwt vc', () => {
153153

154154
expect(credentials).toEqual({
155155
c_nonce: 'new-c-nonce',
156-
c_nonce_expires_in: 300000,
156+
c_nonce_expires_in: 300,
157157
credential: 'sd-jwt',
158158
format: 'vc+sd-jwt',
159159
});

packages/issuer-rest/lib/__tests__/ClientIssuerIT.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ describe('VcIssuer', () => {
327327
proofCallbacks: { signCallback: proofOfPossessionCallbackFunction },
328328
})
329329
expect(credentialResponse).toMatchObject({
330-
c_nonce_expires_in: 300000,
330+
c_nonce_expires_in: 300,
331331
credential: {
332332
'@context': ['https://www.w3.org/2018/credentials/v1'],
333333
credentialSubject: {},

packages/issuer-rest/lib/__tests__/IssuerTokenServer.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ describe('OID4VCIServer', () => {
148148
accessTokenSignerCallback: signerCallback,
149149
accessTokenIssuer: 'https://www.example.com',
150150
preAuthorizedCodeExpirationDuration: 2000,
151-
tokenExpiresIn: 300000,
151+
tokenExpiresIn: 300,
152152
},
153153
},
154154
})
@@ -172,11 +172,11 @@ describe('OID4VCIServer', () => {
172172
expect(actual).toEqual({
173173
access_token: expect.stringContaining('eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiJ9.eyJpYXQi'),
174174
token_type: 'bearer',
175-
expires_in: 300000,
175+
expires_in: 300,
176176
c_nonce: expect.any(String),
177-
c_nonce_expires_in: 300000,
177+
c_nonce_expires_in: 300,
178178
authorization_pending: false,
179-
interval: 300000,
179+
interval: 300,
180180
})
181181
})
182182
it('should return http code 400 with message User pin is required', async () => {

packages/issuer-rest/lib/oid4vci-api-functions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ export function accessTokenEndpoint<DIDDoc extends object>(
7979
const accessTokenIssuer = opts?.accessTokenIssuer ?? process.env.ACCESS_TOKEN_ISSUER ?? issuer.issuerMetadata.credential_issuer
8080

8181
const preAuthorizedCodeExpirationDuration =
82-
opts?.preAuthorizedCodeExpirationDuration ?? getNumberOrUndefined(process.env.PRE_AUTHORIZED_CODE_EXPIRATION_DURATION) ?? 300000
83-
const interval = opts?.interval ?? getNumberOrUndefined(process.env.INTERVAL) ?? 300000
82+
opts?.preAuthorizedCodeExpirationDuration ?? getNumberOrUndefined(process.env.PRE_AUTHORIZED_CODE_EXPIRATION_DURATION) ?? 300
83+
const interval = opts?.interval ?? getNumberOrUndefined(process.env.INTERVAL) ?? 300
8484
const tokenExpiresIn = opts?.tokenExpiresIn ?? 300
8585

8686
// todo: this means we cannot sign JWTs or issue access tokens when configured from env vars!

packages/issuer/lib/VcIssuer.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ import { assertValidPinNumber, createCredentialOfferObject, createCredentialOffe
4141
import { LookupStateManager } from './state-manager'
4242
import { CredentialDataSupplier, CredentialDataSupplierArgs, CredentialIssuanceInput, CredentialSignerCallback } from './types'
4343

44-
const SECOND = 1000
45-
4644
export class VcIssuer<DIDDoc extends object> {
4745
private readonly _issuerMetadata: CredentialIssuerMetadataOpts
4846
private readonly _userPinRequired: boolean
@@ -79,8 +77,7 @@ export class VcIssuer<DIDDoc extends object> {
7977
this._credentialSignerCallback = args?.credentialSignerCallback
8078
this._jwtVerifyCallback = args?.jwtVerifyCallback
8179
this._credentialDataSupplier = args?.credentialDataSupplier
82-
this._cNonceExpiresIn =
83-
((args?.cNonceExpiresIn ?? (process.env.C_NONCE_EXPIRES_IN ? parseInt(process.env.C_NONCE_EXPIRES_IN) : 300)) as number) * SECOND
80+
this._cNonceExpiresIn = (args?.cNonceExpiresIn ?? (process.env.C_NONCE_EXPIRES_IN ? parseInt(process.env.C_NONCE_EXPIRES_IN) : 300)) as number
8481
}
8582

8683
public getCredentialOfferSessionById(id: string): Promise<CredentialOfferSession> {
@@ -247,7 +244,7 @@ export class VcIssuer<DIDDoc extends object> {
247244
}
248245
const validated = await this.validateCredentialRequestProof({
249246
...opts,
250-
tokenExpiresIn: opts.tokenExpiresIn ?? 180000,
247+
tokenExpiresIn: opts.tokenExpiresIn ?? 180,
251248
})
252249
preAuthorizedCode = validated.preAuthorizedCode
253250
issuerState = validated.issuerState

packages/issuer/lib/__tests__/VcIssuer.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ describe('VcIssuer', () => {
362362
}),
363363
).resolves.toEqual({
364364
c_nonce: 'new-test-nonce',
365-
c_nonce_expires_in: 300000,
365+
c_nonce_expires_in: 300,
366366
credential: {
367367
'@context': ['https://www.w3.org/2018/credentials/v1'],
368368
credentialSubject: {},

packages/issuer/lib/tokens/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,14 @@ export const generateAccessToken = async (
4343
},
4444
): Promise<string> => {
4545
const { accessTokenIssuer, alg, accessTokenSignerCallback, tokenExpiresIn, preAuthorizedCode } = opts
46-
const iat = new Date().getTime()
46+
// JWT uses seconds for iat and exp
47+
const iat = new Date().getTime() / 1000
48+
const exp = iat + tokenExpiresIn
4749
const jwt: Jwt = {
4850
header: { typ: 'JWT', alg: alg ?? Alg.ES256K },
4951
payload: {
5052
iat,
51-
exp: tokenExpiresIn,
53+
exp,
5254
iss: accessTokenIssuer,
5355
...(preAuthorizedCode && { preAuthorizedCode }),
5456
},

0 commit comments

Comments
 (0)