Skip to content

Commit f148b5d

Browse files
committed
chore: format
Signed-off-by: Mirko Mollik <mirko.mollik@eudi.sprind.org>
1 parent a9c008e commit f148b5d

File tree

5 files changed

+33
-22
lines changed

5 files changed

+33
-22
lines changed

packages/core/src/index.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,7 @@ export class SDJwtInstance<ExtendedPayload extends SdJwtPayload> {
196196
// This function is for verifying the SD JWT
197197
// If requiredClaimKeys is provided, it will check if the required claim keys are presentation in the SD JWT
198198
// If requireKeyBindings is true, it will check if the key binding JWT is presentation and verify it
199-
public async verify(
200-
encodedSDJwt: string,
201-
options?: VerifierOptions,
202-
) {
199+
public async verify(encodedSDJwt: string, options?: VerifierOptions) {
203200
if (!this.userConfig.hasher) {
204201
throw new SDJWTException('Hasher not found');
205202
}
@@ -213,7 +210,9 @@ export class SDJwtInstance<ExtendedPayload extends SdJwtPayload> {
213210

214211
if (options?.requiredClaimKeys) {
215212
const keys = await sdjwt.keys(hasher);
216-
const missingKeys = options.requiredClaimKeys.filter((k) => !keys.includes(k));
213+
const missingKeys = options.requiredClaimKeys.filter(
214+
(k) => !keys.includes(k),
215+
);
217216
if (missingKeys.length > 0) {
218217
throw new SDJWTException(
219218
`Missing required claim keys: ${missingKeys.join(', ')}`,
@@ -522,10 +521,7 @@ export class SDJwtGeneralJSONInstance<ExtendedPayload extends SdJwtPayload> {
522521
// This function is for verifying the SD JWT
523522
// If requiredClaimKeys is provided, it will check if the required claim keys are presentation in the SD JWT
524523
// If requireKeyBindings is true, it will check if the key binding JWT is presentation and verify it
525-
public async verify(
526-
generalJSON: GeneralJSON,
527-
options?: VerifierOptions,
528-
) {
524+
public async verify(generalJSON: GeneralJSON, options?: VerifierOptions) {
529525
if (!this.userConfig.hasher) {
530526
throw new SDJWTException('Hasher not found');
531527
}
@@ -541,7 +537,9 @@ export class SDJwtGeneralJSONInstance<ExtendedPayload extends SdJwtPayload> {
541537

542538
if (options?.requiredClaimKeys) {
543539
const keys = await sdjwt.keys(hasher);
544-
const missingKeys = options?.requiredClaimKeys.filter((k) => !keys.includes(k));
540+
const missingKeys = options?.requiredClaimKeys.filter(
541+
(k) => !keys.includes(k),
542+
);
545543
if (missingKeys.length > 0) {
546544
throw new SDJWTException(
547545
`Missing required claim keys: ${missingKeys.join(', ')}`,
@@ -562,7 +560,7 @@ export class SDJwtGeneralJSONInstance<ExtendedPayload extends SdJwtPayload> {
562560
const kb = await sdjwt.kbJwt.verifyKB({
563561
verifier: this.userConfig.kbVerifier,
564562
payload: payload as JwtPayload,
565-
nonce: options.keyBindingNonce as string
563+
nonce: options.keyBindingNonce as string,
566564
});
567565
if (!kb) {
568566
throw new Error('signature is not valid');

packages/core/src/jwt.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ export type VerifierOptions = {
3030
* required claim keys for the payload.
3131
* If the payload does not contain these keys, the verification will fail.
3232
*/
33-
requiredClaimKeys?: string[],
33+
requiredClaimKeys?: string[];
3434

3535
/**
3636
* nonce used to verify the key binding jwt to prevent replay attacks.
3737
*/
38-
keyBindingNonce?: string,
38+
keyBindingNonce?: string;
3939
};
4040

4141
// This class is used to create and verify JWT

packages/core/src/kbjwt.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ export class KBJwt<
1414
> extends Jwt<Header, Payload> {
1515
// Checking the validity of the key binding jwt
1616
// the type unknown is not good, but we don't know at this point how to get the public key of the signer, this is defined in the kbVerifier
17-
public async verifyKB(values: { verifier: KbVerifier; payload: JwtPayload, nonce: string }) {
17+
public async verifyKB(values: {
18+
verifier: KbVerifier;
19+
payload: JwtPayload;
20+
nonce: string;
21+
}) {
1822
if (!this.header || !this.payload || !this.signature) {
1923
throw new SDJWTException('Verify Error: Invalid JWT');
2024
}
@@ -45,7 +49,7 @@ export class KBJwt<
4549
if (!verified) {
4650
throw new SDJWTException('Verify Error: Invalid JWT Signature');
4751
}
48-
if(this.payload.nonce !== values.nonce) {
52+
if (this.payload.nonce !== values.nonce) {
4953
throw new SDJWTException('Verify Error: Invalid Nonce');
5054
}
5155

packages/core/src/test/kbjwt.spec.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,11 @@ describe('KB JWT', () => {
178178
const encodedKbJwt = await kbJwt.sign(testSigner);
179179
const decoded = KBJwt.fromKBEncode(encodedKbJwt);
180180
try {
181-
await decoded.verifyKB({ verifier: testVerifier, payload, nonce: 'nonce' });
181+
await decoded.verifyKB({
182+
verifier: testVerifier,
183+
payload,
184+
nonce: 'nonce',
185+
});
182186
} catch (e: unknown) {
183187
const error = e as SDJWTException;
184188
expect(error.message).toBe('Invalid Key Binding Jwt');
@@ -223,7 +227,11 @@ describe('KB JWT', () => {
223227
const encodedKbJwt = await kbJwt.sign(testSigner);
224228
const decoded = KBJwt.fromKBEncode(encodedKbJwt);
225229
try {
226-
await decoded.verifyKB({ verifier: testVerifier, payload, nonce: 'nonce' });
230+
await decoded.verifyKB({
231+
verifier: testVerifier,
232+
payload,
233+
nonce: 'nonce',
234+
});
227235
} catch (e: unknown) {
228236
const error = e as SDJWTException;
229237
expect(error.message).toBe('Verify Error: Invalid JWT Signature');
@@ -269,7 +277,11 @@ describe('KB JWT', () => {
269277
const decoded = KBJwt.fromKBEncode(encodedKbJwt);
270278
decoded.signature = undefined;
271279
try {
272-
await decoded.verifyKB({ verifier: testVerifier, payload, nonce: 'nonce' });
280+
await decoded.verifyKB({
281+
verifier: testVerifier,
282+
payload,
283+
nonce: 'nonce',
284+
});
273285
} catch (e: unknown) {
274286
const error = e as SDJWTException;
275287
expect(error.message).toBe('Verify Error: Invalid JWT');

packages/sd-jwt-vc/src/sd-jwt-vc-instance.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,7 @@ export class SDJwtVcInstance extends SDJwtInstance<SdJwtVcPayload> {
108108
* Verifies the SD-JWT-VC. It will validate the signature, the keybindings when required, the status, and the VCT.
109109
* @param currentDate current time in seconds
110110
*/
111-
async verify(
112-
encodedSDJwt: string,
113-
options?: VerifierOptions,
114-
) {
111+
async verify(encodedSDJwt: string, options?: VerifierOptions) {
115112
// Call the parent class's verify method
116113
const result: VerificationResult = await super
117114
.verify(encodedSDJwt, options)

0 commit comments

Comments
 (0)