From 9baa93efb612ee2fe73c5872766cbc37e541c4dc Mon Sep 17 00:00:00 2001 From: "Lukas.J.Han" Date: Sun, 10 Mar 2024 08:39:38 +0900 Subject: [PATCH] feat: make _digest value public in disclosure (#151) Signed-off-by: Lukas.J.Han Signed-off-by: Mirko Mollik Co-authored-by: Mirko Mollik --- .../build-test-publish-on-push-cached.yaml | 9 +-- examples/sd-jwt-example/all.ts | 2 +- examples/sd-jwt-example/basic.ts | 2 +- examples/sd-jwt-example/custom.ts | 2 +- examples/sd-jwt-example/custom_header.ts | 2 +- examples/sd-jwt-example/decoy.ts | 2 +- examples/sd-jwt-example/kb.ts | 2 +- examples/sd-jwt-example/sdjwtobject.ts | 2 +- examples/sd-jwt-vc-example/all.ts | 2 +- examples/sd-jwt-vc-example/basic.ts | 2 +- examples/sd-jwt-vc-example/custom.ts | 2 +- examples/sd-jwt-vc-example/custom_header.ts | 2 +- examples/sd-jwt-vc-example/decoy.ts | 2 +- examples/sd-jwt-vc-example/kb.ts | 2 +- examples/sd-jwt-vc-example/sdjwtobject.ts | 2 +- package.json | 9 +-- packages/browser-crypto/package.json | 15 +---- .../browser-crypto/src/test/crypto.spec.ts | 2 +- packages/core/package.json | 15 +---- packages/core/src/decoy.ts | 2 +- packages/core/src/index.ts | 14 ++--- packages/core/src/jwt.ts | 2 +- packages/core/src/kbjwt.ts | 8 +-- packages/core/src/sdjwt.ts | 18 +++--- packages/core/src/test/index.spec.ts | 8 +-- packages/core/src/test/jwt.spec.ts | 2 +- packages/core/src/test/kbjwt.spec.ts | 12 ++-- packages/core/src/test/sdjwt.spec.ts | 2 +- packages/core/test/app-e2e.spec.ts | 8 +-- packages/decode/package.json | 15 +---- packages/decode/src/decode.ts | 6 +- packages/hash/package.json | 15 +---- packages/node-crypto/package.json | 15 +---- packages/node-crypto/src/crypto.ts | 2 +- packages/node-crypto/src/test/crypto.spec.ts | 2 +- packages/present/package.json | 15 +---- packages/present/src/present.ts | 10 +++- packages/present/src/test/present.spec.ts | 2 +- packages/sd-jwt-vc/package.json | 15 +---- packages/sd-jwt-vc/src/index.ts | 4 +- packages/sd-jwt-vc/src/sd-jwt-vc-payload.ts | 2 +- packages/sd-jwt-vc/src/test/index.spec.ts | 4 +- packages/sd-jwt-vc/test/app-e2e.spec.ts | 6 +- packages/types/package.json | 15 +---- packages/types/src/test/type.spec.ts | 4 +- packages/utils/package.json | 15 +---- packages/utils/src/disclosure.ts | 8 ++- packages/utils/src/test/disclosure.spec.ts | 2 +- pnpm-lock.yaml | 60 +++++++++---------- 49 files changed, 146 insertions(+), 225 deletions(-) diff --git a/.github/workflows/build-test-publish-on-push-cached.yaml b/.github/workflows/build-test-publish-on-push-cached.yaml index 4ea39109..e04eac26 100644 --- a/.github/workflows/build-test-publish-on-push-cached.yaml +++ b/.github/workflows/build-test-publish-on-push-cached.yaml @@ -107,12 +107,9 @@ jobs: with: node-version: 20 cache: 'pnpm' - - name: Setup Biome - uses: biomejs/setup-biome@v2 - with: - version: latest - - name: Run Biome - run: biome ci . + # we are not using the github action for biome, but the package.json script. this makes sure we are using the same versions. + - name: Run Biome + run: pnpm run biome:ci # Only run this job when the push is on main, next or unstable publish: diff --git a/examples/sd-jwt-example/all.ts b/examples/sd-jwt-example/all.ts index 97609cd3..e3cec1c8 100644 --- a/examples/sd-jwt-example/all.ts +++ b/examples/sd-jwt-example/all.ts @@ -1,5 +1,5 @@ import { SDJwtInstance } from '@sd-jwt/core'; -import { DisclosureFrame } from '@sd-jwt/types'; +import type { DisclosureFrame } from '@sd-jwt/types'; import { createSignerVerifier, digest, generateSalt } from './utils'; (async () => { diff --git a/examples/sd-jwt-example/basic.ts b/examples/sd-jwt-example/basic.ts index e22a4148..b901c5ef 100644 --- a/examples/sd-jwt-example/basic.ts +++ b/examples/sd-jwt-example/basic.ts @@ -1,5 +1,5 @@ import { SDJwtInstance } from '@sd-jwt/core'; -import { DisclosureFrame } from '@sd-jwt/types'; +import type { DisclosureFrame } from '@sd-jwt/types'; import { createSignerVerifier, digest, generateSalt } from './utils'; (async () => { diff --git a/examples/sd-jwt-example/custom.ts b/examples/sd-jwt-example/custom.ts index 71cf8146..ecd27954 100644 --- a/examples/sd-jwt-example/custom.ts +++ b/examples/sd-jwt-example/custom.ts @@ -1,5 +1,5 @@ import { SDJwtInstance } from '@sd-jwt/core'; -import { DisclosureFrame } from '@sd-jwt/types'; +import type { DisclosureFrame } from '@sd-jwt/types'; import { createSignerVerifier, digest, generateSalt } from './utils'; (async () => { diff --git a/examples/sd-jwt-example/custom_header.ts b/examples/sd-jwt-example/custom_header.ts index c01c96ca..5dcaece3 100644 --- a/examples/sd-jwt-example/custom_header.ts +++ b/examples/sd-jwt-example/custom_header.ts @@ -1,5 +1,5 @@ import { SDJwtInstance } from '@sd-jwt/core'; -import { DisclosureFrame } from '@sd-jwt/types'; +import type { DisclosureFrame } from '@sd-jwt/types'; import { createSignerVerifier, digest, generateSalt } from './utils'; (async () => { diff --git a/examples/sd-jwt-example/decoy.ts b/examples/sd-jwt-example/decoy.ts index e146d7e0..cda6e11d 100644 --- a/examples/sd-jwt-example/decoy.ts +++ b/examples/sd-jwt-example/decoy.ts @@ -1,5 +1,5 @@ import { SDJwtInstance } from '@sd-jwt/core'; -import { DisclosureFrame } from '@sd-jwt/types'; +import type { DisclosureFrame } from '@sd-jwt/types'; import { createSignerVerifier, digest, generateSalt } from './utils'; (async () => { diff --git a/examples/sd-jwt-example/kb.ts b/examples/sd-jwt-example/kb.ts index 6f6c6f67..ccf44878 100644 --- a/examples/sd-jwt-example/kb.ts +++ b/examples/sd-jwt-example/kb.ts @@ -1,5 +1,5 @@ import { SDJwtInstance } from '@sd-jwt/core'; -import { DisclosureFrame } from '@sd-jwt/types'; +import type { DisclosureFrame } from '@sd-jwt/types'; import { createSignerVerifier, digest, generateSalt } from './utils'; (async () => { diff --git a/examples/sd-jwt-example/sdjwtobject.ts b/examples/sd-jwt-example/sdjwtobject.ts index 3535134c..6f565b41 100644 --- a/examples/sd-jwt-example/sdjwtobject.ts +++ b/examples/sd-jwt-example/sdjwtobject.ts @@ -1,5 +1,5 @@ import { SDJwtInstance } from '@sd-jwt/core'; -import { DisclosureFrame } from '@sd-jwt/types'; +import type { DisclosureFrame } from '@sd-jwt/types'; import { createSignerVerifier, digest, generateSalt } from './utils'; (async () => { diff --git a/examples/sd-jwt-vc-example/all.ts b/examples/sd-jwt-vc-example/all.ts index 97948be0..faee9054 100644 --- a/examples/sd-jwt-vc-example/all.ts +++ b/examples/sd-jwt-vc-example/all.ts @@ -1,5 +1,5 @@ import { SDJwtVcInstance } from '@sd-jwt/sd-jwt-vc'; -import { DisclosureFrame } from '@sd-jwt/types'; +import type { DisclosureFrame } from '@sd-jwt/types'; import { createSignerVerifier, digest, generateSalt } from './utils'; (async () => { diff --git a/examples/sd-jwt-vc-example/basic.ts b/examples/sd-jwt-vc-example/basic.ts index 51d45769..2b8531a4 100644 --- a/examples/sd-jwt-vc-example/basic.ts +++ b/examples/sd-jwt-vc-example/basic.ts @@ -1,5 +1,5 @@ import { SDJwtVcInstance } from '@sd-jwt/sd-jwt-vc'; -import { DisclosureFrame } from '@sd-jwt/types'; +import type { DisclosureFrame } from '@sd-jwt/types'; import { createSignerVerifier, digest, generateSalt } from './utils'; (async () => { diff --git a/examples/sd-jwt-vc-example/custom.ts b/examples/sd-jwt-vc-example/custom.ts index 65249d41..88600239 100644 --- a/examples/sd-jwt-vc-example/custom.ts +++ b/examples/sd-jwt-vc-example/custom.ts @@ -1,5 +1,5 @@ import { SDJwtVcInstance } from '@sd-jwt/sd-jwt-vc'; -import { DisclosureFrame } from '@sd-jwt/types'; +import type { DisclosureFrame } from '@sd-jwt/types'; import { createSignerVerifier, digest, generateSalt } from './utils'; (async () => { diff --git a/examples/sd-jwt-vc-example/custom_header.ts b/examples/sd-jwt-vc-example/custom_header.ts index 0e7cdaf3..24dccc85 100644 --- a/examples/sd-jwt-vc-example/custom_header.ts +++ b/examples/sd-jwt-vc-example/custom_header.ts @@ -1,5 +1,5 @@ import { SDJwtVcInstance } from '@sd-jwt/sd-jwt-vc'; -import { DisclosureFrame } from '@sd-jwt/types'; +import type { DisclosureFrame } from '@sd-jwt/types'; import { createSignerVerifier, digest, generateSalt } from './utils'; (async () => { diff --git a/examples/sd-jwt-vc-example/decoy.ts b/examples/sd-jwt-vc-example/decoy.ts index fbff47ff..6f581bae 100644 --- a/examples/sd-jwt-vc-example/decoy.ts +++ b/examples/sd-jwt-vc-example/decoy.ts @@ -1,5 +1,5 @@ import { SDJwtVcInstance } from '@sd-jwt/sd-jwt-vc'; -import { DisclosureFrame } from '@sd-jwt/types'; +import type { DisclosureFrame } from '@sd-jwt/types'; import { createSignerVerifier, digest, generateSalt } from './utils'; (async () => { diff --git a/examples/sd-jwt-vc-example/kb.ts b/examples/sd-jwt-vc-example/kb.ts index 15340fbc..7ccde8ee 100644 --- a/examples/sd-jwt-vc-example/kb.ts +++ b/examples/sd-jwt-vc-example/kb.ts @@ -1,5 +1,5 @@ import { SDJwtVcInstance } from '@sd-jwt/sd-jwt-vc'; -import { DisclosureFrame } from '@sd-jwt/types'; +import type { DisclosureFrame } from '@sd-jwt/types'; import { createSignerVerifier, digest, generateSalt } from './utils'; (async () => { diff --git a/examples/sd-jwt-vc-example/sdjwtobject.ts b/examples/sd-jwt-vc-example/sdjwtobject.ts index 9d1ad3e2..798f8a19 100644 --- a/examples/sd-jwt-vc-example/sdjwtobject.ts +++ b/examples/sd-jwt-vc-example/sdjwtobject.ts @@ -1,5 +1,5 @@ import { SDJwtVcInstance } from '@sd-jwt/sd-jwt-vc'; -import { DisclosureFrame } from '@sd-jwt/types'; +import type { DisclosureFrame } from '@sd-jwt/types'; import { createSignerVerifier, digest, generateSalt } from './utils'; (async () => { diff --git a/package.json b/package.json index a6561ccd..2de9d961 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "build": "lerna run build --stream", "lint": "biome lint ./packages", "format": "biome format . --write", + "biome:ci": "biome ci .", "test": "vitest run --coverage.enabled=true --coverage.include=packages/*", "test:watch": "vitest", "clean": "lerna clean -y", @@ -13,11 +14,7 @@ "publish:next": "lerna publish --no-private --conventional-prerelease --force-publish --canary --no-git-tag-version --include-merged-tags --preid next --pre-dist-tag next --yes", "publish:unstable": "lerna publish --no-private --conventional-prerelease --force-publish --canary --no-git-tag-version --include-merged-tags --preid unstable --pre-dist-tag unstable --yes" }, - "keywords": [ - "sd-jwt", - "sdjwt", - "sd-jwt-vc" - ], + "keywords": ["sd-jwt", "sdjwt", "sd-jwt-vc"], "engines": { "node": ">=16" }, @@ -32,7 +29,7 @@ }, "license": "Apache-2.0", "devDependencies": { - "@biomejs/biome": "1.5.3", + "@biomejs/biome": "^1.6.0", "@types/node": "^20.10.2", "@vitest/coverage-v8": "^1.2.2", "jose": "^5.2.2", diff --git a/packages/browser-crypto/package.json b/packages/browser-crypto/package.json index b50ac69e..8383968c 100644 --- a/packages/browser-crypto/package.json +++ b/packages/browser-crypto/package.json @@ -18,11 +18,7 @@ "test:browser": "vitest run ./src/test/*.spec.ts", "test:cov": "vitest run --coverage" }, - "keywords": [ - "sd-jwt", - "sdjwt", - "sd-jwt-vc" - ], + "keywords": ["sd-jwt", "sdjwt", "sd-jwt-vc"], "repository": { "type": "git", "url": "https://github.com/openwallet-foundation-labs/sd-jwt-js" @@ -37,17 +33,12 @@ "access": "public" }, "tsup": { - "entry": [ - "./src/index.ts" - ], + "entry": ["./src/index.ts"], "sourceMap": true, "splitting": false, "clean": true, "dts": true, - "format": [ - "cjs", - "esm" - ] + "format": ["cjs", "esm"] }, "gitHead": "ded40e4551bde7ae93083181bf26bd1b38bbfcfb" } diff --git a/packages/browser-crypto/src/test/crypto.spec.ts b/packages/browser-crypto/src/test/crypto.spec.ts index 08691f07..b3f0eebb 100644 --- a/packages/browser-crypto/src/test/crypto.spec.ts +++ b/packages/browser-crypto/src/test/crypto.spec.ts @@ -2,7 +2,7 @@ import { describe, expect, test } from 'vitest'; import { generateSalt, digest, getHasher, ES256 } from '../index'; // Extract the major version as a number -const nodeVersionMajor = parseInt( +const nodeVersionMajor = Number.parseInt( process.version.split('.')[0].substring(1), 10, ); diff --git a/packages/core/package.json b/packages/core/package.json index 54893cc3..ad3356ff 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -19,11 +19,7 @@ "test:browser": "vitest run ./src/test/*.spec.ts --environment jsdom", "test:cov": "vitest run --coverage" }, - "keywords": [ - "sd-jwt", - "sdjwt", - "sd-jwt-vc" - ], + "keywords": ["sd-jwt", "sdjwt", "sd-jwt-vc"], "engines": { "node": ">=16" }, @@ -50,17 +46,12 @@ "access": "public" }, "tsup": { - "entry": [ - "./src/index.ts" - ], + "entry": ["./src/index.ts"], "sourceMap": true, "splitting": false, "clean": true, "dts": true, - "format": [ - "cjs", - "esm" - ] + "format": ["cjs", "esm"] }, "gitHead": "ded40e4551bde7ae93083181bf26bd1b38bbfcfb" } diff --git a/packages/core/src/decoy.ts b/packages/core/src/decoy.ts index df4cc441..8f3f3ee1 100644 --- a/packages/core/src/decoy.ts +++ b/packages/core/src/decoy.ts @@ -1,4 +1,4 @@ -import { HasherAndAlg, SaltGenerator } from '@sd-jwt/types'; +import type { HasherAndAlg, SaltGenerator } from '@sd-jwt/types'; import { Uint8ArrayToBase64Url } from '@sd-jwt/utils'; // This function creates a decoy value that can be used to obscure SD JWT payload. diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 27e2ad3a..ed90f034 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -3,16 +3,16 @@ import { Jwt } from './jwt'; import { KBJwt } from './kbjwt'; import { SDJwt, pack } from './sdjwt'; import { - DisclosureFrame, - Hasher, - KBOptions, + type DisclosureFrame, + type Hasher, + type KBOptions, KB_JWT_TYP, - PresentationFrame, - SDJWTCompact, - SDJWTConfig, + type PresentationFrame, + type SDJWTCompact, + type SDJWTConfig, } from '@sd-jwt/types'; import { getSDAlgAndPayload } from '@sd-jwt/decode'; -import { JwtPayload } from '@sd-jwt/types'; +import type { JwtPayload } from '@sd-jwt/types'; export * from './sdjwt'; export * from './kbjwt'; diff --git a/packages/core/src/jwt.ts b/packages/core/src/jwt.ts index 5f2efd9e..4f0e0173 100644 --- a/packages/core/src/jwt.ts +++ b/packages/core/src/jwt.ts @@ -1,5 +1,5 @@ import { Base64urlEncode, SDJWTException } from '@sd-jwt/utils'; -import { Base64urlString, Signer, Verifier } from '@sd-jwt/types'; +import type { Base64urlString, Signer, Verifier } from '@sd-jwt/types'; import { decodeJwt } from '@sd-jwt/decode'; export type JwtData< diff --git a/packages/core/src/kbjwt.ts b/packages/core/src/kbjwt.ts index 705d77a2..c70073bd 100644 --- a/packages/core/src/kbjwt.ts +++ b/packages/core/src/kbjwt.ts @@ -1,11 +1,11 @@ import { Base64urlEncode, SDJWTException } from '@sd-jwt/utils'; import { Jwt } from './jwt'; import { - JwtPayload, + type JwtPayload, KB_JWT_TYP, - kbHeader, - kbPayload, - KbVerifier, + type kbHeader, + type kbPayload, + type KbVerifier, } from '@sd-jwt/types'; export class KBJwt< diff --git a/packages/core/src/sdjwt.ts b/packages/core/src/sdjwt.ts index 17bc0515..654200d2 100644 --- a/packages/core/src/sdjwt.ts +++ b/packages/core/src/sdjwt.ts @@ -3,18 +3,18 @@ import { SDJWTException, Disclosure } from '@sd-jwt/utils'; import { Jwt } from './jwt'; import { KBJwt } from './kbjwt'; import { - DisclosureFrame, - Hasher, - HasherAndAlg, - PresentationFrame, - SDJWTCompact, + type DisclosureFrame, + type Hasher, + type HasherAndAlg, + type PresentationFrame, + type SDJWTCompact, SD_DECOY, SD_DIGEST, SD_LIST_KEY, SD_SEPARATOR, - SaltGenerator, - kbHeader, - kbPayload, + type SaltGenerator, + type kbHeader, + type kbPayload, } from '@sd-jwt/types'; import { createHashMapping, getSDAlgAndPayload, unpack } from '@sd-jwt/decode'; import { transformPresentationFrame } from '@sd-jwt/present'; @@ -236,7 +236,7 @@ export const pack = async >( for (const key in disclosureFrame) { if (key !== SD_DIGEST) { - const idx = parseInt(key); + const idx = Number.parseInt(key); const packed = await pack( claims[idx], disclosureFrame[idx], diff --git a/packages/core/src/test/index.spec.ts b/packages/core/src/test/index.spec.ts index 0f145c08..2cc7d11f 100644 --- a/packages/core/src/test/index.spec.ts +++ b/packages/core/src/test/index.spec.ts @@ -1,9 +1,9 @@ -import { SDJwtInstance, SdJwtPayload } from '../index'; -import { Signer, Verifier, KbVerifier, JwtPayload } from '@sd-jwt/types'; -import Crypto, { KeyLike } from 'node:crypto'; +import { SDJwtInstance, type SdJwtPayload } from '../index'; +import type { Signer, Verifier, KbVerifier, JwtPayload } from '@sd-jwt/types'; +import Crypto, { type KeyLike } from 'node:crypto'; import { describe, expect, test } from 'vitest'; import { digest, generateSalt } from '@sd-jwt/crypto-nodejs'; -import { importJWK, exportJWK, JWK } from 'jose'; +import { importJWK, exportJWK, type JWK } from 'jose'; export const createSignerVerifier = () => { const { privateKey, publicKey } = Crypto.generateKeyPairSync('ed25519'); diff --git a/packages/core/src/test/jwt.spec.ts b/packages/core/src/test/jwt.spec.ts index c2360ea0..2dd59164 100644 --- a/packages/core/src/test/jwt.spec.ts +++ b/packages/core/src/test/jwt.spec.ts @@ -1,7 +1,7 @@ import { SDJWTException } from '@sd-jwt/utils'; import { Jwt } from '../jwt'; import Crypto from 'node:crypto'; -import { Signer, Verifier } from '@sd-jwt/types'; +import type { Signer, Verifier } from '@sd-jwt/types'; import { describe, expect, test } from 'vitest'; describe('JWT', () => { diff --git a/packages/core/src/test/kbjwt.spec.ts b/packages/core/src/test/kbjwt.spec.ts index ec23b8e3..154331fb 100644 --- a/packages/core/src/test/kbjwt.spec.ts +++ b/packages/core/src/test/kbjwt.spec.ts @@ -1,15 +1,15 @@ -import { SDJWTException } from '@sd-jwt/utils'; +import type { SDJWTException } from '@sd-jwt/utils'; import { KBJwt } from '../kbjwt'; import { - JwtPayload, + type JwtPayload, KB_JWT_TYP, - KbVerifier, - Signer, + type KbVerifier, + type Signer, Verifier, } from '@sd-jwt/types'; -import Crypto, { KeyLike } from 'node:crypto'; +import Crypto, { type KeyLike } from 'node:crypto'; import { describe, expect, test } from 'vitest'; -import { JWK, exportJWK, importJWK } from 'jose'; +import { type JWK, exportJWK, importJWK } from 'jose'; describe('KB JWT', () => { test('create', async () => { diff --git a/packages/core/src/test/sdjwt.spec.ts b/packages/core/src/test/sdjwt.spec.ts index 2d42b9d7..1a9d4f2d 100644 --- a/packages/core/src/test/sdjwt.spec.ts +++ b/packages/core/src/test/sdjwt.spec.ts @@ -3,7 +3,7 @@ import { Jwt } from '../jwt'; import { SDJwt, listKeys, pack } from '../sdjwt'; import Crypto from 'node:crypto'; import { describe, test, expect } from 'vitest'; -import { DisclosureFrame, Signer } from '@sd-jwt/types'; +import type { DisclosureFrame, Signer } from '@sd-jwt/types'; import { generateSalt, digest as hasher } from '@sd-jwt/crypto-nodejs'; import { unpack, createHashMapping } from '@sd-jwt/decode'; diff --git a/packages/core/test/app-e2e.spec.ts b/packages/core/test/app-e2e.spec.ts index 9dbf0f2d..d63d060e 100644 --- a/packages/core/test/app-e2e.spec.ts +++ b/packages/core/test/app-e2e.spec.ts @@ -1,13 +1,13 @@ import Crypto from 'node:crypto'; -import { SDJwtInstance, SdJwtPayload } from '../src'; -import { +import { SDJwtInstance, type SdJwtPayload } from '../src'; +import type { DisclosureFrame, PresentationFrame, Signer, Verifier, } from '@sd-jwt/types'; -import fs from 'fs'; -import path from 'path'; +import fs from 'node:fs'; +import path from 'node:path'; import { describe, expect, test } from 'vitest'; import { digest, generateSalt } from '@sd-jwt/crypto-nodejs'; diff --git a/packages/decode/package.json b/packages/decode/package.json index 72897ead..5db18cca 100644 --- a/packages/decode/package.json +++ b/packages/decode/package.json @@ -18,11 +18,7 @@ "test:node": "vitest run ./src/test/*.spec.ts --coverage", "test:browser": "vitest run ./src/test/*.spec.ts --environment jsdom --coverage" }, - "keywords": [ - "sd-jwt", - "sdjwt", - "sd-jwt-vc" - ], + "keywords": ["sd-jwt", "sdjwt", "sd-jwt-vc"], "engines": { "node": ">=16" }, @@ -47,17 +43,12 @@ "access": "public" }, "tsup": { - "entry": [ - "./src/index.ts" - ], + "entry": ["./src/index.ts"], "sourceMap": true, "splitting": false, "clean": true, "dts": true, - "format": [ - "cjs", - "esm" - ] + "format": ["cjs", "esm"] }, "gitHead": "ded40e4551bde7ae93083181bf26bd1b38bbfcfb" } diff --git a/packages/decode/src/decode.ts b/packages/decode/src/decode.ts index edb5e824..551cbbf3 100644 --- a/packages/decode/src/decode.ts +++ b/packages/decode/src/decode.ts @@ -1,12 +1,12 @@ import { Base64urlDecode, SDJWTException, Disclosure } from '@sd-jwt/utils'; import { - Hasher, - HasherAndAlg, + type Hasher, + type HasherAndAlg, SD_DIGEST, SD_LIST_KEY, SD_SEPARATOR, } from '@sd-jwt/types'; -import { HasherAndAlgSync, HasherSync } from '@sd-jwt/types/src/type'; +import type { HasherAndAlgSync, HasherSync } from '@sd-jwt/types/src/type'; export const decodeJwt = < H extends Record, diff --git a/packages/hash/package.json b/packages/hash/package.json index cc38e7c6..e0cd09fb 100644 --- a/packages/hash/package.json +++ b/packages/hash/package.json @@ -19,11 +19,7 @@ "test:browser": "vitest run ./src/test/*.spec.ts --environment jsdom", "test:cov": "vitest run --coverage" }, - "keywords": [ - "sd-jwt", - "sdjwt", - "sd-jwt-vc" - ], + "keywords": ["sd-jwt", "sdjwt", "sd-jwt-vc"], "engines": { "node": ">=16" }, @@ -48,17 +44,12 @@ "access": "public" }, "tsup": { - "entry": [ - "./src/index.ts" - ], + "entry": ["./src/index.ts"], "sourceMap": true, "splitting": false, "clean": true, "dts": true, - "format": [ - "cjs", - "esm" - ] + "format": ["cjs", "esm"] }, "gitHead": "ded40e4551bde7ae93083181bf26bd1b38bbfcfb" } diff --git a/packages/node-crypto/package.json b/packages/node-crypto/package.json index 413825c5..be8d2737 100644 --- a/packages/node-crypto/package.json +++ b/packages/node-crypto/package.json @@ -18,11 +18,7 @@ "test:node": "vitest run ./src/test/*.spec.ts", "test:cov": "vitest run --coverage" }, - "keywords": [ - "sd-jwt", - "sdjwt", - "sd-jwt-vc" - ], + "keywords": ["sd-jwt", "sdjwt", "sd-jwt-vc"], "engines": { "node": ">=16" }, @@ -40,17 +36,12 @@ "access": "public" }, "tsup": { - "entry": [ - "./src/index.ts" - ], + "entry": ["./src/index.ts"], "sourceMap": true, "splitting": false, "clean": true, "dts": true, - "format": [ - "cjs", - "esm" - ] + "format": ["cjs", "esm"] }, "gitHead": "ded40e4551bde7ae93083181bf26bd1b38bbfcfb" } diff --git a/packages/node-crypto/src/crypto.ts b/packages/node-crypto/src/crypto.ts index b18f5392..32a35023 100644 --- a/packages/node-crypto/src/crypto.ts +++ b/packages/node-crypto/src/crypto.ts @@ -1,4 +1,4 @@ -import { createHash, randomBytes, subtle } from 'crypto'; +import { createHash, randomBytes, subtle } from 'node:crypto'; export const generateSalt = (length: number): string => { if (length <= 0) { diff --git a/packages/node-crypto/src/test/crypto.spec.ts b/packages/node-crypto/src/test/crypto.spec.ts index d3359add..572e1011 100644 --- a/packages/node-crypto/src/test/crypto.spec.ts +++ b/packages/node-crypto/src/test/crypto.spec.ts @@ -2,7 +2,7 @@ import { describe, expect, test } from 'vitest'; import { generateSalt, digest, ES256 } from '../index'; // Extract the major version as a number -const nodeVersionMajor = parseInt( +const nodeVersionMajor = Number.parseInt( process.version.split('.')[0].substring(1), 10, ); diff --git a/packages/present/package.json b/packages/present/package.json index 878895e7..86e08d77 100644 --- a/packages/present/package.json +++ b/packages/present/package.json @@ -19,11 +19,7 @@ "test:browser": "vitest run ./src/test/*.spec.ts --environment jsdom", "test:cov": "vitest run --coverage" }, - "keywords": [ - "sd-jwt", - "sdjwt", - "sd-jwt-vc" - ], + "keywords": ["sd-jwt", "sdjwt", "sd-jwt-vc"], "engines": { "node": ">=16" }, @@ -49,17 +45,12 @@ "access": "public" }, "tsup": { - "entry": [ - "./src/index.ts" - ], + "entry": ["./src/index.ts"], "sourceMap": true, "splitting": false, "clean": true, "dts": true, - "format": [ - "cjs", - "esm" - ] + "format": ["cjs", "esm"] }, "gitHead": "ded40e4551bde7ae93083181bf26bd1b38bbfcfb" } diff --git a/packages/present/src/present.ts b/packages/present/src/present.ts index 1b004a8e..ba17ce6a 100644 --- a/packages/present/src/present.ts +++ b/packages/present/src/present.ts @@ -1,5 +1,9 @@ -import { Hasher, PresentationFrame, SD_SEPARATOR } from '@sd-jwt/types'; -import { Disclosure } from '@sd-jwt/utils'; +import { + type Hasher, + type PresentationFrame, + SD_SEPARATOR, +} from '@sd-jwt/types'; +import type { Disclosure } from '@sd-jwt/utils'; import { createHashMapping, decodeSdJwt, @@ -10,7 +14,7 @@ import { decodeSdJwtSync, unpackSync, } from '@sd-jwt/decode'; -import { HasherSync } from '@sd-jwt/types/src/type'; +import type { HasherSync } from '@sd-jwt/types/src/type'; // Presentable keys // The presentable keys are the path of JSON object that are presentable in the SD JWT diff --git a/packages/present/src/test/present.spec.ts b/packages/present/src/test/present.spec.ts index dcccafe9..1b2c0094 100644 --- a/packages/present/src/test/present.spec.ts +++ b/packages/present/src/test/present.spec.ts @@ -8,7 +8,7 @@ import { transformPresentationFrame, } from '../index'; import { decodeSdJwt, decodeSdJwtSync } from '@sd-jwt/decode'; -import { PresentationFrame } from '@sd-jwt/types'; +import type { PresentationFrame } from '@sd-jwt/types'; describe('Present tests', () => { test('presentableKeys', async () => { diff --git a/packages/sd-jwt-vc/package.json b/packages/sd-jwt-vc/package.json index 0a19d434..a000d0c8 100644 --- a/packages/sd-jwt-vc/package.json +++ b/packages/sd-jwt-vc/package.json @@ -20,11 +20,7 @@ "test:e2e": "vitest run ./test/*e2e.spec.ts --environment node", "test:cov": "vitest run --coverage" }, - "keywords": [ - "sd-jwt", - "sdjwt", - "sd-jwt-vc" - ], + "keywords": ["sd-jwt", "sdjwt", "sd-jwt-vc"], "engines": { "node": ">=16" }, @@ -49,17 +45,12 @@ "access": "public" }, "tsup": { - "entry": [ - "./src/index.ts" - ], + "entry": ["./src/index.ts"], "sourceMap": true, "splitting": false, "clean": true, "dts": true, - "format": [ - "cjs", - "esm" - ] + "format": ["cjs", "esm"] }, "gitHead": "ded40e4551bde7ae93083181bf26bd1b38bbfcfb" } diff --git a/packages/sd-jwt-vc/src/index.ts b/packages/sd-jwt-vc/src/index.ts index 2cb8fe74..c4a6c8ee 100644 --- a/packages/sd-jwt-vc/src/index.ts +++ b/packages/sd-jwt-vc/src/index.ts @@ -1,7 +1,7 @@ import { SDJwtInstance } from '@sd-jwt/core'; -import { DisclosureFrame } from '@sd-jwt/types'; +import type { DisclosureFrame } from '@sd-jwt/types'; import { SDJWTException } from '../../utils/dist'; -import { SdJwtVcPayload } from './sd-jwt-vc-payload'; +import type { SdJwtVcPayload } from './sd-jwt-vc-payload'; export { SdJwtVcPayload } from './sd-jwt-vc-payload'; diff --git a/packages/sd-jwt-vc/src/sd-jwt-vc-payload.ts b/packages/sd-jwt-vc/src/sd-jwt-vc-payload.ts index 8017684c..9831268a 100644 --- a/packages/sd-jwt-vc/src/sd-jwt-vc-payload.ts +++ b/packages/sd-jwt-vc/src/sd-jwt-vc-payload.ts @@ -1,4 +1,4 @@ -import { SdJwtPayload } from '@sd-jwt/core'; +import type { SdJwtPayload } from '@sd-jwt/core'; export interface SdJwtVcPayload extends SdJwtPayload { // The Issuer of the Verifiable Credential. The value of iss MUST be a URI. See [RFC7519] for more information. diff --git a/packages/sd-jwt-vc/src/test/index.spec.ts b/packages/sd-jwt-vc/src/test/index.spec.ts index a9e8784f..1e3d34da 100644 --- a/packages/sd-jwt-vc/src/test/index.spec.ts +++ b/packages/sd-jwt-vc/src/test/index.spec.ts @@ -1,9 +1,9 @@ import { digest, generateSalt } from '@sd-jwt/crypto-nodejs'; -import { DisclosureFrame } from '@sd-jwt/types'; +import type { DisclosureFrame } from '@sd-jwt/types'; import { describe, test, expect } from 'vitest'; import { SDJwtVcInstance } from '..'; import { createSignerVerifier } from '../../test/app-e2e.spec'; -import { SdJwtVcPayload } from '../sd-jwt-vc-payload'; +import type { SdJwtVcPayload } from '../sd-jwt-vc-payload'; const iss = 'ExampleIssuer'; const vct = 'https://example.com/schema/1'; diff --git a/packages/sd-jwt-vc/test/app-e2e.spec.ts b/packages/sd-jwt-vc/test/app-e2e.spec.ts index fc37c854..c8ab8afb 100644 --- a/packages/sd-jwt-vc/test/app-e2e.spec.ts +++ b/packages/sd-jwt-vc/test/app-e2e.spec.ts @@ -1,13 +1,13 @@ import Crypto from 'node:crypto'; import { SDJwtVcInstance, SdJwtVcPayload } from '../src/index'; -import { +import type { DisclosureFrame, PresentationFrame, Signer, Verifier, } from '@sd-jwt/types'; -import fs from 'fs'; -import path from 'path'; +import fs from 'node:fs'; +import path from 'node:path'; import { describe, expect, test } from 'vitest'; import { digest, generateSalt } from '@sd-jwt/crypto-nodejs'; diff --git a/packages/types/package.json b/packages/types/package.json index 9868fca2..8ff3fd13 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -19,11 +19,7 @@ "test:browser": "vitest run ./src/test/*.spec.ts --environment jsdom", "test:cov": "vitest run --coverage" }, - "keywords": [ - "sd-jwt", - "sdjwt", - "sd-jwt-vc" - ], + "keywords": ["sd-jwt", "sdjwt", "sd-jwt-vc"], "engines": { "node": ">=16" }, @@ -41,17 +37,12 @@ "access": "public" }, "tsup": { - "entry": [ - "./src/index.ts" - ], + "entry": ["./src/index.ts"], "sourceMap": true, "splitting": false, "clean": true, "dts": true, - "format": [ - "cjs", - "esm" - ] + "format": ["cjs", "esm"] }, "gitHead": "ded40e4551bde7ae93083181bf26bd1b38bbfcfb" } diff --git a/packages/types/src/test/type.spec.ts b/packages/types/src/test/type.spec.ts index 0cb112c8..6346c9f9 100644 --- a/packages/types/src/test/type.spec.ts +++ b/packages/types/src/test/type.spec.ts @@ -5,8 +5,8 @@ import { SD_DIGEST, SD_DECOY, KB_JWT_TYP, - DisclosureFrame, - PresentationFrame, + type DisclosureFrame, + type PresentationFrame, } from '../index'; const claims = { diff --git a/packages/utils/package.json b/packages/utils/package.json index 66ce3ea7..4f91f59a 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -19,11 +19,7 @@ "test:browser": "vitest run ./src/test/*.spec.ts --environment jsdom", "test:cov": "vitest run --coverage" }, - "keywords": [ - "sd-jwt", - "sdjwt", - "sd-jwt-vc" - ], + "keywords": ["sd-jwt", "sdjwt", "sd-jwt-vc"], "engines": { "node": ">=16" }, @@ -48,17 +44,12 @@ "access": "public" }, "tsup": { - "entry": [ - "./src/index.ts" - ], + "entry": ["./src/index.ts"], "sourceMap": true, "splitting": false, "clean": true, "dts": true, - "format": [ - "cjs", - "esm" - ] + "format": ["cjs", "esm"] }, "gitHead": "ded40e4551bde7ae93083181bf26bd1b38bbfcfb" } diff --git a/packages/utils/src/disclosure.ts b/packages/utils/src/disclosure.ts index 6d96ab0d..b8eb97b8 100644 --- a/packages/utils/src/disclosure.ts +++ b/packages/utils/src/disclosure.ts @@ -4,13 +4,17 @@ import { Base64urlEncode, } from './base64url'; import { SDJWTException } from './error'; -import { HasherAndAlg, DisclosureData, HasherAndAlgSync } from '@sd-jwt/types'; +import type { + HasherAndAlg, + DisclosureData, + HasherAndAlgSync, +} from '@sd-jwt/types'; export class Disclosure { public salt: string; public key?: string; public value: T; - private _digest: string | undefined; + public _digest: string | undefined; private _encoded: string | undefined; public constructor( diff --git a/packages/utils/src/test/disclosure.spec.ts b/packages/utils/src/test/disclosure.spec.ts index c777d836..3b456632 100644 --- a/packages/utils/src/test/disclosure.spec.ts +++ b/packages/utils/src/test/disclosure.spec.ts @@ -1,7 +1,7 @@ import { generateSalt, digest as hasher } from '@sd-jwt/crypto-nodejs'; import { Disclosure } from '../disclosure'; import { describe, expect, test } from 'vitest'; -import { Base64urlEncode, SDJWTException } from '../index'; +import { Base64urlEncode, type SDJWTException } from '../index'; const hash = { alg: 'SHA256', hasher }; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fe8270f7..4c70f6bb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,8 +9,8 @@ importers: .: devDependencies: '@biomejs/biome': - specifier: 1.5.3 - version: 1.5.3 + specifier: ^1.6.0 + version: 1.6.0 '@types/node': specifier: ^20.10.2 version: 20.11.25 @@ -284,24 +284,24 @@ packages: resolution: {integrity: sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==} dev: true - /@biomejs/biome@1.5.3: - resolution: {integrity: sha512-yvZCa/g3akwTaAQ7PCwPWDCkZs3Qa5ONg/fgOUT9e6wAWsPftCjLQFPXBeGxPK30yZSSpgEmRCfpGTmVbUjGgg==} + /@biomejs/biome@1.6.0: + resolution: {integrity: sha512-hvP8K1+CV8qc9eNdXtPwzScVxFSHB448CPKSqX6+8IW8G7bbhBVKGC80BowExJN5+vu+kzsj4xkWa780MAOlJw==} engines: {node: '>=14.*'} hasBin: true requiresBuild: true optionalDependencies: - '@biomejs/cli-darwin-arm64': 1.5.3 - '@biomejs/cli-darwin-x64': 1.5.3 - '@biomejs/cli-linux-arm64': 1.5.3 - '@biomejs/cli-linux-arm64-musl': 1.5.3 - '@biomejs/cli-linux-x64': 1.5.3 - '@biomejs/cli-linux-x64-musl': 1.5.3 - '@biomejs/cli-win32-arm64': 1.5.3 - '@biomejs/cli-win32-x64': 1.5.3 - dev: true - - /@biomejs/cli-darwin-arm64@1.5.3: - resolution: {integrity: sha512-ImU7mh1HghEDyqNmxEZBoMPr8SxekkZuYcs+gynKlNW+TALQs7swkERiBLkG9NR0K1B3/2uVzlvYowXrmlW8hw==} + '@biomejs/cli-darwin-arm64': 1.6.0 + '@biomejs/cli-darwin-x64': 1.6.0 + '@biomejs/cli-linux-arm64': 1.6.0 + '@biomejs/cli-linux-arm64-musl': 1.6.0 + '@biomejs/cli-linux-x64': 1.6.0 + '@biomejs/cli-linux-x64-musl': 1.6.0 + '@biomejs/cli-win32-arm64': 1.6.0 + '@biomejs/cli-win32-x64': 1.6.0 + dev: true + + /@biomejs/cli-darwin-arm64@1.6.0: + resolution: {integrity: sha512-K1Fjqye5pt+Ua+seC7V/2bFjfnqOaEOcQbBQSiiefB/VPNOb6lA5NFIfJ1PskTA3JrMXE1k7iqKQn56qrKFS6A==} engines: {node: '>=14.*'} cpu: [arm64] os: [darwin] @@ -309,8 +309,8 @@ packages: dev: true optional: true - /@biomejs/cli-darwin-x64@1.5.3: - resolution: {integrity: sha512-vCdASqYnlpq/swErH7FD6nrFz0czFtK4k/iLgj0/+VmZVjineFPgevOb+Sr9vz0tk0GfdQO60bSpI74zU8M9Dw==} + /@biomejs/cli-darwin-x64@1.6.0: + resolution: {integrity: sha512-CjEALu6vN9RbcfhaBDoj481mesUIsUjxgQn+/kiMCea+Paypqslhez1I7OwRBJnkzz+Pa+PXdABd7S30eyy6+Q==} engines: {node: '>=14.*'} cpu: [x64] os: [darwin] @@ -318,8 +318,8 @@ packages: dev: true optional: true - /@biomejs/cli-linux-arm64-musl@1.5.3: - resolution: {integrity: sha512-DYuMizUYUBYfS0IHGjDrOP1RGipqWfMGEvNEJ398zdtmCKLXaUvTimiox5dvx4X15mBK5M2m8wgWUgOP1giUpQ==} + /@biomejs/cli-linux-arm64-musl@1.6.0: + resolution: {integrity: sha512-prww6AUuJ+IO/GziN3WjtGM/DNOVuPFxqWrK97wKTZygEDdA+o1qHUN2HeCkSyk084xnzbMSbls5xscAKAn43A==} engines: {node: '>=14.*'} cpu: [arm64] os: [linux] @@ -327,8 +327,8 @@ packages: dev: true optional: true - /@biomejs/cli-linux-arm64@1.5.3: - resolution: {integrity: sha512-cupBQv0sNF1OKqBfx7EDWMSsKwRrBUZfjXawT4s6hKV6ALq7p0QzWlxr/sDmbKMLOaLQtw2Qgu/77N9rm+f9Rg==} + /@biomejs/cli-linux-arm64@1.6.0: + resolution: {integrity: sha512-32LVrC7dAgQT39YZ0ieO/VzzpAflozs9mW5K0oKNef7S4ocCdk89E98eXApxOdei0JTf3vfseDCl1AUIp6MwJw==} engines: {node: '>=14.*'} cpu: [arm64] os: [linux] @@ -336,8 +336,8 @@ packages: dev: true optional: true - /@biomejs/cli-linux-x64-musl@1.5.3: - resolution: {integrity: sha512-UUHiAnlDqr2Y/LpvshBFhUYMWkl2/Jn+bi3U6jKuav0qWbbBKU/ByHgR4+NBxpKBYoCtWxhnmatfH1bpPIuZMw==} + /@biomejs/cli-linux-x64-musl@1.6.0: + resolution: {integrity: sha512-NwitWeUKCy8G/rr+rgHPYirnrsOjJEJBWODdaRzweeFNcJjvO6de6AmNdSJzsewzLEaxjOWyoXU03MdzbGz/6Q==} engines: {node: '>=14.*'} cpu: [x64] os: [linux] @@ -345,8 +345,8 @@ packages: dev: true optional: true - /@biomejs/cli-linux-x64@1.5.3: - resolution: {integrity: sha512-YQrSArQvcv4FYsk7Q91Yv4uuu5F8hJyORVcv3zsjCLGkjIjx2RhjYLpTL733SNL7v33GmOlZY0eFR1ko38tuUw==} + /@biomejs/cli-linux-x64@1.6.0: + resolution: {integrity: sha512-b6mWu9Cu4w5B3K46wq9SlxKEZEEL6II/6HFNAuZ4YL8mOeQ0FTMU+wNMJFKkmkSE2zvim3xwW3PknmbLKbe3Mg==} engines: {node: '>=14.*'} cpu: [x64] os: [linux] @@ -354,8 +354,8 @@ packages: dev: true optional: true - /@biomejs/cli-win32-arm64@1.5.3: - resolution: {integrity: sha512-HxatYH7vf/kX9nrD+pDYuV2GI9GV8EFo6cfKkahAecTuZLPxryHx1WEfJthp5eNsE0+09STGkKIKjirP0ufaZA==} + /@biomejs/cli-win32-arm64@1.6.0: + resolution: {integrity: sha512-DlNOL6mG+76iZS1gL/UiuMme7jnt+auzo2+u0aUq6UXYsb75juchwlnVLy2UV5CQjVBRB8+RM+KVoXRZ8NlBjQ==} engines: {node: '>=14.*'} cpu: [arm64] os: [win32] @@ -363,8 +363,8 @@ packages: dev: true optional: true - /@biomejs/cli-win32-x64@1.5.3: - resolution: {integrity: sha512-fMvbSouZEASU7mZH8SIJSANDm5OqsjgtVXlbUqxwed6BP7uuHRSs396Aqwh2+VoW8fwTpp6ybIUoC9FrzB0kyA==} + /@biomejs/cli-win32-x64@1.6.0: + resolution: {integrity: sha512-sXBcXIOGuG8/XcHqmnkhLIs0oy6Dp+TkH4Alr4WH/P8mNsp5GcStI/ZwbEiEoxA0P3Fi+oUppQ6srxaY2rSCHg==} engines: {node: '>=14.*'} cpu: [x64] os: [win32]