Skip to content

Commit 7722000

Browse files
committed
chore: add biome
1 parent 7e52547 commit 7722000

26 files changed

Lines changed: 3749 additions & 5360 deletions

File tree

.github/workflows/build-test-on-pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
node-version: '20.x'
2626
- uses: pnpm/action-setup@v4
2727
with:
28-
version: 9.15.3 # TODO remove later, we are temporary dealing with a broken pnpm version in the CI container
28+
version: 10.8.1
2929
- run: pnpm install
3030
- run: pnpm build
3131
- name: run CI tests

.github/workflows/build-test-publish-on-push.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
node-version: '20.x'
4040
- uses: pnpm/action-setup@v4
4141
with:
42-
version: 9.15.3 # TODO remove later, we are temporary dealing with a broken pnpm version in the CI container
42+
version: 10.8.1
4343
- run: pnpm install
4444
- run: pnpm build
4545
- name: run integration tests

biome.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
3+
"vcs": { "enabled": false, "clientKind": "git", "useIgnoreFile": false },
4+
"files": { "ignoreUnknown": false, "ignore": [] },
5+
"formatter": {
6+
"enabled": true,
7+
"useEditorconfig": true,
8+
"formatWithErrors": false,
9+
"indentStyle": "space",
10+
"indentWidth": 2,
11+
"lineEnding": "lf",
12+
"lineWidth": 150,
13+
"attributePosition": "auto",
14+
"bracketSpacing": true,
15+
"ignore": [
16+
"**/dist",
17+
"**/coverage",
18+
"**/*/node_modules",
19+
"packages/siop-oid4vp/lib/schemas"
20+
]
21+
},
22+
"organizeImports": { "enabled": true },
23+
"linter": {
24+
"enabled": true,
25+
"rules": { "recommended": false },
26+
"ignore": ["**/node_modules", "**/dist", "**/coverage", "**/jest.js"]
27+
},
28+
"javascript": {
29+
"formatter": {
30+
"jsxQuoteStyle": "double",
31+
"quoteProperties": "asNeeded",
32+
"trailingCommas": "all",
33+
"semicolons": "asNeeded",
34+
"arrowParentheses": "always",
35+
"bracketSameLine": false,
36+
"quoteStyle": "single",
37+
"attributePosition": "auto",
38+
"bracketSpacing": true
39+
},
40+
"globals": ["BigInt", "vitest", "WebAssembly", "console"]
41+
},
42+
"overrides": [
43+
{
44+
"include": ["**/__tests__/**/*.ts"],
45+
"linter": { "rules": { "style": { "noNonNullAssertion": "off" } } }
46+
}
47+
]
48+
}

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"author": "Sphereon",
66
"license": "Apache-2.0",
77
"private": true,
8-
"packageManager": "pnpm@9.15.3",
8+
"packageManager": "pnpm@10.8.1",
99
"workspaces": [
1010
"packages/*"
1111
],
@@ -18,7 +18,7 @@
1818
"test:ci": "vitest run --config ./vitest.config.ts --coverage",
1919
"test": "turbo run test:vitest",
2020
"test:vitest": "vitest run --config ./vitest.config.ts --coverage",
21-
"clean": "rimraf --glob **/dist **/coverage **/pnpm-lock.yaml packages/**/node_modules node_modules packages/**/tsconfig.tsbuildinfo",
21+
"clean": "rimraf --glob **/dist **/.turbo **/.tsup **/coverage **/pnpm-lock.yaml packages/**/node_modules node_modules packages/**/tsconfig.tsbuildinfo",
2222
"publish:latest": "lerna publish --conventional-commits --include-merged-tags --create-release github --yes --dist-tag latest --registry https://registry.npmjs.org",
2323
"publish:next": "lerna publish --conventional-prerelease --force-publish --canary --no-git-tag-version --include-merged-tags --preid next --pre-dist-tag next --yes --registry https://registry.npmjs.org",
2424
"publish:unstable": "lerna publish --conventional-prerelease --force-publish --canary --no-git-tag-version --include-merged-tags --preid unstable --pre-dist-tag unstable --yes --registry https://registry.npmjs.org"
@@ -44,13 +44,12 @@
4444
"@types/node": "^20.17.30",
4545
"@vitest/coverage-v8": "^3.1.1",
4646
"npm-run-all": "^4.1.5",
47+
"@biomejs/biome": "^1.9.4",
4748
"prettier": "^3.3.2",
4849
"rimraf": "^5.0.8",
4950
"lerna": "^8.2.2",
5051
"tsup": "^8.4.0",
5152
"turbo": "^2.5.0",
52-
"auto": "^11.3.0",
53-
"@auto-it/conventional-commits": "^11.3.0",
5453
"typescript": "5.8.3",
5554
"vitest": "^3.1.1"
5655
},

packages/callback-example/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "@sphereon/callback",
33
"version": "0.18.2",
44
"description": "OpenID 4 Verifiable Credential Issuance issuer callback example",
5+
"source": "./src/index.ts",
56
"type": "module",
67
"main": "./dist/index.cjs",
78
"module": "./dist/index.js",
@@ -46,7 +47,10 @@
4647
"node": ">=20.6"
4748
},
4849
"files": [
49-
"dist"
50+
"src",
51+
"dist",
52+
"README.md",
53+
"LICENSE.md"
5054
],
5155
"keywords": [
5256
"Sphereon",

packages/client/lib/__tests__/EBSIE2E.spec.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { from } from '@trust/keyto';
77
import { fetch } from 'cross-fetch';
88
import debug from 'debug';
99
import { base64url, importJWK, JWK, SignJWT } from 'jose';
10-
import * as u8a from 'uint8arrays';
10+
import { fromString, toString } from 'uint8arrays';
1111
import { describe, expect, it } from 'vitest';
1212

1313
import { OpenID4VCIClientV1_0_11 } from '..';
@@ -33,7 +33,7 @@ const privateKey = from(jwk, 'jwk').toString('blk', 'private');
3333
const publicKey = from(jwk, 'jwk').toString('blk', 'public');
3434
console.log(`Private key: ${privateKey}`);
3535
console.log(`Public key: ${publicKey}`);
36-
console.log(`Private key (b64): ${base64url.encode(u8a.fromString(privateKey, 'base16'))}`);
36+
console.log(`Private key (b64): ${base64url.encode(fromString(privateKey, 'base16'))}`);
3737
console.log(`JWK (private 2) ${JSON.stringify(toJwk(privateKey, 'Secp256r1', { isPrivateKey: true }))}`);
3838
console.log(`JWK (public 2) ${JSON.stringify(toJwk(publicKey, 'Secp256r1', { isPrivateKey: false }))}`);
3939

packages/client/package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "@sphereon/oid4vci-client",
33
"version": "0.18.2",
44
"description": "OpenID for Verifiable Credential Issuance (OpenID4VCI) client",
5+
"source": "./src/index.ts",
56
"type": "module",
67
"main": "./dist/index.cjs",
78
"module": "./dist/index.js",
@@ -29,8 +30,8 @@
2930
"@sphereon/oid4vc-common": "workspace:*",
3031
"@sphereon/oid4vci-common": "workspace:*",
3132
"@sphereon/ssi-types": "^0.33",
32-
"cross-fetch": "^3.1.8",
33-
"debug": "^4.3.5"
33+
"cross-fetch": "^4.1.0",
34+
"debug": "^4.4.0"
3435
},
3536
"devDependencies": {
3637
"@sphereon/ssi-sdk-ext.key-utils": "^0.23.0",
@@ -45,23 +46,24 @@
4546
"eslint-config-prettier": "^9.1.0",
4647
"eslint-plugin-eslint-comments": "^3.2.0",
4748
"eslint-plugin-import": "^2.29.1",
48-
"jest": "^29.7.0",
49-
"jest-junit": "^16.0.0",
5049
"jose": "^4.15.9",
5150
"nock": "^13.5.4",
5251
"npm-run-all": "^4.1.5",
5352
"open-cli": "^7.2.0",
5453
"ts-node": "^10.9.2",
5554
"typescript": "5.8.3",
56-
"uint8arrays": "3.1.1",
55+
"uint8arrays": "^5.1.0",
5756
"uuid": "^9.0.1",
5857
"vitest": "^3.1.1"
5958
},
6059
"engines": {
6160
"node": ">=20"
6261
},
6362
"files": [
64-
"dist"
63+
"src",
64+
"dist",
65+
"README.md",
66+
"LICENSE.md"
6567
],
6668
"prettier": {
6769
"singleQuote": true,

packages/common/lib/dpop/DPoP.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { jwtDecode } from 'jwt-decode';
22
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
33
// @ts-ignore
4-
import * as u8a from 'uint8arrays';
4+
import { fromString, toString } from 'uint8arrays';
55
import { v4 as uuidv4 } from 'uuid';
66

77
import { defaultHasher } from '../hasher';
@@ -70,7 +70,7 @@ export async function createDPoP(options: CreateDPoPOpts): Promise<string> {
7070
throw new Error('expected access token without scheme');
7171
}
7272

73-
const ath = jwtPayloadProps.accessToken ? u8a.toString(defaultHasher(jwtPayloadProps.accessToken, 'sha256'), 'base64url') : undefined;
73+
const ath = jwtPayloadProps.accessToken ? toString(defaultHasher(jwtPayloadProps.accessToken, 'sha256'), 'base64url') : undefined;
7474
return createJwtCallback(
7575
{ method: 'jwk', type: 'dpop', alg: jwtIssuer.alg, jwk: jwtIssuer.jwk, dPoPSigningAlgValuesSupported },
7676
{
@@ -197,7 +197,7 @@ export async function verifyDPoP(
197197
}
198198

199199
const accessToken = authorizationHeader.replace('DPoP ', '');
200-
const expectedAth = u8a.toString(defaultHasher(accessToken, 'sha256'), 'base64url');
200+
const expectedAth = toString(defaultHasher(accessToken, 'sha256'), 'base64url');
201201
if (dPoPPayload.ath !== expectedAth) {
202202
throw new Error('invalid_dpop_proof. Invalid ath claim');
203203
}

packages/common/lib/hasher.ts

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,5 @@
1-
import { HasherSync } from '@sphereon/ssi-types';
2-
import sha from 'sha.js';
3-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
4-
// @ts-ignore
5-
import * as u8a from 'uint8arrays';
1+
import { HasherSync, shaHasher } from '@sphereon/ssi-types';
62

7-
const supportedAlgorithms = ['sha256', 'sha384', 'sha512'] as const;
8-
type SupportedAlgorithms = (typeof supportedAlgorithms)[number];
9-
10-
export const defaultHasher: HasherSync = (data, algorithm) => {
11-
const sanitizedAlgorithm = algorithm.toLowerCase().replace(/[-_]/g, '');
12-
if (!supportedAlgorithms.includes(sanitizedAlgorithm as SupportedAlgorithms)) {
13-
throw new Error(`Unsupported hashing algorithm ${algorithm}`);
14-
}
15-
16-
return new Uint8Array(
17-
sha(sanitizedAlgorithm as SupportedAlgorithms)
18-
.update(typeof data === 'string' ? u8a.fromString(data) : data)
19-
.digest(),
20-
);
3+
export const defaultHasher: HasherSync = (data: string | ArrayBuffer, algorithm: string) => {
4+
return shaHasher(data, algorithm);
215
};

packages/common/lib/jwt/JwkThumbprint.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
2-
// @ts-ignore
3-
import * as u8a from 'uint8arrays';
1+
import { toString } from 'uint8arrays';
42

53
import { defaultHasher } from '../hasher';
64
import { DigestAlgorithm } from '../types';
@@ -46,7 +44,7 @@ export async function calculateJwkThumbprint(jwk: JWK, digestAlgorithm?: DigestA
4644
default:
4745
throw Error('"kty" (Key Type) Parameter missing or unsupported');
4846
}
49-
return u8a.toString(defaultHasher(JSON.stringify(components), algorithm), 'base64url');
47+
return toString(defaultHasher(JSON.stringify(components), algorithm), 'base64url');
5048
}
5149

5250
export async function getDigestAlgorithmFromJwkThumbprintUri(uri: string): Promise<DigestAlgorithm> {

0 commit comments

Comments
 (0)