diff --git a/packages/core/src/test/index.spec.ts b/packages/core/src/test/index.spec.ts index fec00633..d82d5e3e 100644 --- a/packages/core/src/test/index.spec.ts +++ b/packages/core/src/test/index.spec.ts @@ -1,19 +1,8 @@ import { SDJwtInstance, SdJwtPayload } from '../index'; -import { DisclosureFrame, Signer, Verifier } from '@sd-jwt/types'; +import { Signer, Verifier } from '@sd-jwt/types'; import Crypto from 'node:crypto'; import { describe, expect, test } from 'vitest'; import { digest, generateSalt } from '@sd-jwt/crypto-nodejs'; -import exp from 'node:constants'; - -export class TestInstance extends SDJwtInstance { - protected type = 'sd-jwt'; - - protected validateReservedFields( - disclosureFrame: DisclosureFrame, - ): void { - return; - } -} export const createSignerVerifier = () => { const { privateKey, publicKey } = Crypto.generateKeyPairSync('ed25519'); @@ -34,13 +23,13 @@ export const createSignerVerifier = () => { describe('index', () => { test('create', async () => { - const sdjwt = new TestInstance(); + const sdjwt = new SDJwtInstance(); expect(sdjwt).toBeDefined(); }); test('kbJwt', async () => { const { signer, verifier } = createSignerVerifier(); - const sdjwt = new TestInstance({ + const sdjwt = new SDJwtInstance({ signer, signAlg: 'EdDSA', verifier, @@ -78,7 +67,7 @@ describe('index', () => { test('issue', async () => { const { signer, verifier } = createSignerVerifier(); - const sdjwt = new TestInstance({ + const sdjwt = new SDJwtInstance({ signer, signAlg: 'EdDSA', verifier, @@ -112,7 +101,7 @@ describe('index', () => { ); }; - const sdjwt = new TestInstance({ + const sdjwt = new SDJwtInstance({ signer, signAlg: 'EdDSA', verifier: failedverifier, @@ -150,7 +139,7 @@ describe('index', () => { Buffer.from(sig, 'base64url'), ); }; - const sdjwt = new TestInstance({ + const sdjwt = new SDJwtInstance({ signer, signAlg: 'EdDSA', verifier, @@ -192,7 +181,7 @@ describe('index', () => { test('verify with kbJwt', async () => { const { signer, verifier } = createSignerVerifier(); - const sdjwt = new TestInstance({ + const sdjwt = new SDJwtInstance({ signer, signAlg: 'EdDSA', verifier, @@ -230,7 +219,7 @@ describe('index', () => { }); test('Hasher not found', async () => { - const sdjwt = new TestInstance({}); + const sdjwt = new SDJwtInstance({}); try { const credential = await sdjwt.issue( { @@ -251,7 +240,7 @@ describe('index', () => { }); test('SaltGenerator not found', async () => { - const sdjwt = new TestInstance({ + const sdjwt = new SDJwtInstance({ hasher: digest, }); try { @@ -274,7 +263,7 @@ describe('index', () => { }); test('Signer not found', async () => { - const sdjwt = new TestInstance({ + const sdjwt = new SDJwtInstance({ hasher: digest, saltGenerator: generateSalt, }); @@ -299,7 +288,7 @@ describe('index', () => { test('Verifier not found', async () => { const { signer, verifier } = createSignerVerifier(); - const sdjwt = new TestInstance({ + const sdjwt = new SDJwtInstance({ signer, hasher: digest, saltGenerator: generateSalt, @@ -339,7 +328,7 @@ describe('index', () => { test('kbSigner not found', async () => { const { signer, verifier } = createSignerVerifier(); - const sdjwt = new TestInstance({ + const sdjwt = new SDJwtInstance({ signer, verifier, hasher: digest, @@ -377,7 +366,7 @@ describe('index', () => { test('kbVerifier not found', async () => { const { signer, verifier } = createSignerVerifier(); - const sdjwt = new TestInstance({ + const sdjwt = new SDJwtInstance({ signer, verifier, hasher: digest, @@ -417,7 +406,7 @@ describe('index', () => { test('kbSignAlg not found', async () => { const { signer, verifier } = createSignerVerifier(); - const sdjwt = new TestInstance({ + const sdjwt = new SDJwtInstance({ signer, verifier, hasher: digest, @@ -454,7 +443,7 @@ describe('index', () => { test('hasher is not found', async () => { const { signer } = createSignerVerifier(); - const sdjwt_create = new TestInstance({ + const sdjwt_create = new SDJwtInstance({ signer, hasher: digest, saltGenerator: generateSalt, @@ -471,7 +460,7 @@ describe('index', () => { _sd: ['foo'], }, ); - const sdjwt = new TestInstance({}); + const sdjwt = new SDJwtInstance({}); expect(sdjwt.keys('')).rejects.toThrow('Hasher not found'); expect(sdjwt.presentableKeys('')).rejects.toThrow('Hasher not found'); expect(sdjwt.getClaims('')).rejects.toThrow('Hasher not found'); @@ -483,7 +472,7 @@ describe('index', () => { test('presentableKeys', async () => { const { signer } = createSignerVerifier(); - const sdjwt = new TestInstance({ + const sdjwt = new SDJwtInstance({ signer, hasher: digest, saltGenerator: generateSalt, diff --git a/packages/core/test/app-e2e.spec.ts b/packages/core/test/app-e2e.spec.ts index a44ca89d..653522a3 100644 --- a/packages/core/test/app-e2e.spec.ts +++ b/packages/core/test/app-e2e.spec.ts @@ -6,16 +6,6 @@ import path from 'path'; import { describe, expect, test } from 'vitest'; import { digest, generateSalt } from '@sd-jwt/crypto-nodejs'; -export class TestInstance extends SDJwtInstance { - protected type = 'sd-jwt'; - - protected validateReservedFields( - disclosureFrame: DisclosureFrame, - ): void { - return; - } -} - export const createSignerVerifier = () => { const { privateKey, publicKey } = Crypto.generateKeyPairSync('ed25519'); const signer: Signer = async (data: string) => { @@ -36,7 +26,7 @@ export const createSignerVerifier = () => { describe('App', () => { test('Example', async () => { const { signer, verifier } = createSignerVerifier(); - const sdjwt = new TestInstance({ + const sdjwt = new SDJwtInstance({ signer, signAlg: 'EdDSA', verifier, @@ -202,7 +192,7 @@ describe('App', () => { async function JSONtest(filename: string) { const test = loadTestJsonFile(filename); const { signer, verifier } = createSignerVerifier(); - const sdjwt = new TestInstance({ + const sdjwt = new SDJwtInstance({ signer, signAlg: 'EdDSA', verifier,