Skip to content

Commit 0e33a6b

Browse files
authored
chore: upgrade typescript and old dependencies (#316)
* chore: remove jest-fetch-mock dependency * chore: remove jsdoc since the docs are generated from typedoc * chore: run npm audit * chore: remove unused dependency * upgrade typescript * chore: upgrade typescript * upgrade eslint * add coverate dependency * remove commonjs build, it does not work anyway * remove esm subdir **Note** this only outputs esm output. It should be easy enough to add CJS output if anyone actually needs it.
1 parent f59a9ba commit 0e33a6b

File tree

126 files changed

+3669
-11807
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+3669
-11807
lines changed

.eslintrc

Lines changed: 0 additions & 32 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
strategy:
1818
matrix:
1919
os: [macOS-latest, ubuntu-latest]
20-
node-version: ['18', '20']
20+
node-version: ['18', '20', '22']
2121

2222
steps:
2323
- name: Checkout repo
@@ -39,12 +39,12 @@ jobs:
3939

4040
- name: Lint
4141
run: npm run lint
42-
43-
- name: Test
44-
run: npm test -- --coverage=true
45-
42+
4643
- name: Build
4744
run: npm run build
45+
46+
- name: Test
47+
run: npm test -- --coverage=true
4848

4949
- name: Upload coverage reports to Codecov
5050
uses: codecov/codecov-action@v4

.jsdoc.json

Lines changed: 0 additions & 25 deletions
This file was deleted.

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,22 @@ encoded strings for the initial implementation. Support for binary CESR can be a
3030

3131
The code is built using Typescript and running code locally requires a Mac or Linux OS.
3232

33-
- Install [Node.js](https://nodejs.org)
33+
- Install [Node.js](https://nodejs.org)
3434

35-
- Install dependencies:
35+
- Install dependencies:
3636
```bash
3737
npm install
3838
```
3939

4040
Typescript source files needs to be transpiled before running scripts or integration tests
4141

42-
- Build:
42+
- Build:
4343

4444
```bash
4545
npm run build
4646
```
4747

48-
- ready() must be called before library is useable. Example minimum viable client code.
48+
- ready() must be called before library is useable. Example minimum viable client code.
4949

5050
```javascript
5151
import { randomPasscode, ready, SignifyClient, Tier } from 'signify-ts';
@@ -120,16 +120,16 @@ Use the npm script "test:integration" to run all integration tests in sequence:
120120
npm run test:integration
121121
```
122122
123-
Or, use execute `jest` directly to run a specific integration test, for example:
123+
To execute a specific integration test, you can use:
124124
125125
```bash
126-
npx jest examples/integration-scripts/credentials.test.ts
126+
npm run test:integration -- credentials.test.ts
127127
```
128128
129129
It is also possible to run the tests using local instances of vLEI, Keria, and witness network. Set the environment variable `TEST_ENVIRONMENT` to `local`, e.g:
130130
131131
```
132-
TEST_ENVIRONMENT=local npx jest examples/integration-scripts/credentials.test.ts
132+
TEST_ENVIRONMENT=local npm run test:integration credentials.test.ts
133133
```
134134
135135
This changes the discovery urls to use `localhost` instead of the hostnames inside the docker network.

eslint.config.mjs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// @ts-check
2+
3+
import eslint from '@eslint/js';
4+
import tseslint from 'typescript-eslint';
5+
import prettier from 'eslint-config-prettier';
6+
7+
export default tseslint.config(
8+
eslint.configs.recommended,
9+
tseslint.configs.recommended,
10+
{ rules: prettier.rules },
11+
{
12+
// These are files with more lenient lint config because they have not been "fixed" yet
13+
// Once a directory here is fixed, it should be removed from here so the strict rules applies
14+
files: [
15+
'src/keri/app/**',
16+
'src/keri/core/**',
17+
'examples/integration-scripts/**',
18+
],
19+
rules: {
20+
'prefer-const': 'warn',
21+
'no-var': 'warn',
22+
'no-self-assign': 'warn',
23+
'no-case-declarations': 'warn',
24+
'no-constant-condition': 'warn',
25+
'no-empty': 'warn',
26+
'@typescript-eslint/no-non-null-asserted-optional-chain': 'warn',
27+
'@typescript-eslint/no-explicit-any': 'warn',
28+
'@typescript-eslint/no-namespace': 'warn',
29+
// '@typescript-eslint/ban-types': 'warn',
30+
'@typescript-eslint/no-unused-vars': 'warn',
31+
},
32+
}
33+
);

examples/integration-scripts/challenge.test.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { strict as assert } from 'assert';
1+
import { assert, test } from 'vitest';
22
import signify, { Serder } from 'signify-ts';
3-
import { resolveEnvironment } from './utils/resolve-env';
3+
import { resolveEnvironment } from './utils/resolve-env.ts';
44
import {
55
assertOperations,
66
resolveOobi,
77
waitOperation,
8-
} from './utils/test-util';
8+
} from './utils/test-util.ts';
99

1010
const { url, bootUrl } = resolveEnvironment();
1111

@@ -98,8 +98,9 @@ test('challenge', async () => {
9898
// List Client 1 contacts
9999
let contacts1 = await client1.contacts().list();
100100
let bobContact = contacts1.find((contact) => contact.alias === 'bob');
101-
expect(bobContact?.alias).toEqual('bob');
102-
expect(bobContact?.challenges).toHaveLength(0);
101+
assert.equal(bobContact?.alias, 'bob');
102+
assert(Array.isArray(bobContact?.challenges));
103+
assert.strictEqual(bobContact.challenges.length, 0);
103104

104105
// Bob responds to Alice challenge
105106
await client2.challenges().respond('bob', aid1.i, challenge1_small.words);
@@ -126,7 +127,7 @@ test('challenge', async () => {
126127
bobContact = contacts1.find((contact) => contact.alias === 'bob');
127128

128129
assert(Array.isArray(bobContact?.challenges));
129-
expect(bobContact?.challenges[0].authenticated).toBe(true);
130+
assert.strictEqual(bobContact?.challenges[0].authenticated, true);
130131

131132
await assertOperations(client1, client2);
132133
}, 30000);

examples/integration-scripts/credentials.test.ts

Lines changed: 45 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { strict as assert } from 'assert';
1+
import { assert, beforeAll, afterAll, test, expect } from 'vitest';
22
import { Ilks, Saider, Serder, SignifyClient } from 'signify-ts';
3-
import { resolveEnvironment } from './utils/resolve-env';
3+
import { resolveEnvironment } from './utils/resolve-env.ts';
44
import {
55
assertNotifications,
66
assertOperations,
@@ -11,10 +11,10 @@ import {
1111
resolveOobi,
1212
waitForNotifications,
1313
waitOperation,
14-
} from './utils/test-util';
15-
import { retry } from './utils/retry';
16-
import { randomUUID } from 'crypto';
17-
import { step } from './utils/test-step';
14+
} from './utils/test-util.ts';
15+
import { retry } from './utils/retry.ts';
16+
import { randomUUID } from 'node:crypto';
17+
import { step } from './utils/test-step.ts';
1818

1919
const { vleiServerUrl } = resolveEnvironment();
2020

@@ -90,7 +90,7 @@ afterAll(async () => {
9090
);
9191
});
9292

93-
test('single signature credentials', async () => {
93+
test('single signature credentials', { timeout: 90000 }, async () => {
9494
await step('Resolve schema oobis', async () => {
9595
await Promise.all([
9696
resolveOobi(issuerClient, QVI_SCHEMA_URL),
@@ -174,44 +174,55 @@ test('single signature credentials', async () => {
174174
assert.equal(issuerCredentials[0].status.s, '0');
175175
});
176176

177+
function assertLength(obj: unknown, length: number) {
178+
assert(obj);
179+
assert(typeof obj === 'object');
180+
assert('length' in obj);
181+
assert.strictEqual(obj.length, length);
182+
}
177183
await step('issuer list credentials with filter', async () => {
178-
expect(
184+
assertLength(
179185
await issuerClient
180186
.credentials()
181-
.list({ filter: { '-i': issuerAid.prefix } })
182-
).toHaveLength(1);
187+
.list({ filter: { '-i': issuerAid.prefix } }),
188+
1
189+
);
183190

184-
expect(
191+
assertLength(
185192
await issuerClient
186193
.credentials()
187-
.list({ filter: { '-s': QVI_SCHEMA_SAID } })
188-
).toHaveLength(1);
194+
.list({ filter: { '-s': QVI_SCHEMA_SAID } }),
195+
1
196+
);
189197

190-
expect(
198+
assertLength(
191199
await issuerClient
192200
.credentials()
193-
.list({ filter: { '-a-i': holderAid.prefix } })
194-
).toHaveLength(1);
201+
.list({ filter: { '-a-i': holderAid.prefix } }),
202+
1
203+
);
195204

196-
expect(
205+
assertLength(
197206
await issuerClient.credentials().list({
198207
filter: {
199208
'-i': issuerAid.prefix,
200209
'-s': QVI_SCHEMA_SAID,
201210
'-a-i': holderAid.prefix,
202211
},
203-
})
204-
).toHaveLength(1);
212+
}),
213+
1
214+
);
205215

206-
expect(
216+
assertLength(
207217
await issuerClient.credentials().list({
208218
filter: {
209219
'-i': randomUUID(),
210220
'-s': QVI_SCHEMA_SAID,
211221
'-a-i': holderAid.prefix,
212222
},
213-
})
214-
).toHaveLength(0);
223+
}),
224+
0
225+
);
215226
});
216227

217228
await step('issuer get credential by id', async () => {
@@ -331,13 +342,13 @@ test('single signature credentials', async () => {
331342
const apply = await holderClient.exchanges().get(holderApplyNote.a.d);
332343
applySaid = apply.exn.d;
333344

334-
let filter: { [x: string]: any } = { '-s': apply.exn.a.s };
345+
const filter: { [x: string]: any } = { '-s': apply.exn.a.s };
335346
for (const key in apply.exn.a.a) {
336347
filter[`-a-${key}`] = apply.exn.a.a[key];
337348
}
338349

339350
const matchingCreds = await holderClient.credentials().list({ filter });
340-
expect(matchingCreds).toHaveLength(1);
351+
assert.strictEqual(matchingCreds.length, 1);
341352

342353
await markAndRemoveNotification(holderClient, holderNotifications[0]);
343354

@@ -371,8 +382,8 @@ test('single signature credentials', async () => {
371382
.get(verifierOfferNote.a.d);
372383
offerSaid = offer.exn.d;
373384

374-
expect(offer.exn.p).toBe(applySaid);
375-
expect(offer.exn.e.acdc.a.LEI).toBe('5493001KJTIIGC8Y1R17');
385+
assert.strictEqual(offer.exn.p, applySaid);
386+
assert.strictEqual(offer.exn.e.acdc.a.LEI, '5493001KJTIIGC8Y1R17');
376387

377388
await markAndRemoveNotification(verifierClient, verifierOfferNote);
378389

@@ -401,7 +412,7 @@ test('single signature credentials', async () => {
401412
const agree = await holderClient.exchanges().get(holderAgreeNote.a.d);
402413
agreeSaid = agree.exn.d;
403414

404-
expect(agree.exn.p).toBe(offerSaid);
415+
assert.strictEqual(agree.exn.p, offerSaid);
405416

406417
await markAndRemoveNotification(holderClient, holderAgreeNote);
407418

@@ -440,7 +451,7 @@ test('single signature credentials', async () => {
440451
assert(verifierGrantNote.a.d);
441452

442453
const grant = await holderClient.exchanges().get(verifierGrantNote.a.d);
443-
expect(grant.exn.p).toBe(agreeSaid);
454+
assert.strictEqual(grant.exn.p, agreeSaid);
444455

445456
const [admit3, sigs3, aend3] = await verifierClient.ipex().admit({
446457
senderName: verifierAid.name,
@@ -619,15 +630,12 @@ test('single signature credentials', async () => {
619630

620631
await step('Holder deletes LE credential', async () => {
621632
await holderClient.credentials().delete(leCredentialId);
622-
await assert.rejects(
623-
async () => {
624-
await holderClient.credentials().get(leCredentialId);
625-
},
626-
{
627-
name: 'Error',
628-
message: `HTTP GET /credentials/${leCredentialId} - 404 Not Found - {"title": "404 Not Found", "description": "credential for said ${leCredentialId} not found."}`,
629-
}
633+
await expect(async () => {
634+
await holderClient.credentials().get(leCredentialId);
635+
}).rejects.toThrowError(
636+
`HTTP GET /credentials/${leCredentialId} - 404 Not Found - {"title": "404 Not Found", "description": "credential for said ${leCredentialId} not found."}`
630637
);
638+
631639
assert.equal((await holderClient.credentials().list()).length, 1);
632640
});
633-
}, 90000);
641+
});

examples/integration-scripts/delegation-multisig.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { strict as assert } from 'assert';
1+
import { assert, test } from 'vitest';
22
import signify from 'signify-ts';
33
import {
44
assertNotifications,
@@ -12,14 +12,14 @@ import {
1212
waitAndMarkNotification,
1313
waitForNotifications,
1414
waitOperation,
15-
} from './utils/test-util';
15+
} from './utils/test-util.ts';
1616
import {
1717
acceptMultisigIncept,
1818
addEndRoleMultisig,
1919
delegateMultisig,
2020
startMultisigIncept,
21-
} from './utils/multisig-utils';
22-
import { step } from './utils/test-step';
21+
} from './utils/multisig-utils.ts';
22+
import { step } from './utils/test-step.ts';
2323

2424
const delegatorGroupName = 'delegator_group';
2525
const delegateeGroupName = 'delegatee_group';

0 commit comments

Comments
 (0)