diff --git a/packages/jwt-status-list/README.md b/packages/jwt-status-list/README.md index d2218998..265555ab 100644 --- a/packages/jwt-status-list/README.md +++ b/packages/jwt-status-list/README.md @@ -43,14 +43,16 @@ const payload: JWTPayload = { }; const header: JWTHeaderParameters = { alg: 'ES256' }; -const jwt = createUnsignedJWT(list, payload, header); +const jwt = createHeaderAndPayload(list, payload, header); -// Sign the JWT with the private key -const signedJwt = await jwt.sign(privateKey); +// Sign the JWT with the private key, e.g. using the `jose` library +const jwt = await new SignJWT(values.payload) + .setProtectedHeader(values.header) + .sign(privateKey); ``` -Interaction with a JWT Status List: +Interaction with a JWT status list on low level: ```typescript //validation of the JWT is not provided by this library!!! @@ -67,10 +69,13 @@ const statusList = getListFromStatusListJWT(list); //get the status of a specific entry const status = statusList.getStatus(reference.idx); - -// handle the status ``` +### Integration into sd-jwt-vc +The status list can be integrated into the [sd-jwt-vc](../sd-jwt-vc/README.md) library to provide a way to verify the status of a credential. In the [test folder](../sd-jwt-vc/src/test/index.spec.ts) you will find an example how to add the status reference to a credential and also how to verify the status of a credential. + +```typescript + ### Caching the status list Depending on the `ttl` field if provided the status list can be cached for a certain amount of time. This library has no internal cache mechanism, so it is up to the user to implement it for example by providing a custom `fetchStatusList` function. diff --git a/packages/jwt-status-list/src/test/status-list-jwt.spec.ts b/packages/jwt-status-list/src/test/status-list-jwt.spec.ts index 45472743..025d35a2 100644 --- a/packages/jwt-status-list/src/test/status-list-jwt.spec.ts +++ b/packages/jwt-status-list/src/test/status-list-jwt.spec.ts @@ -3,7 +3,10 @@ import { getListFromStatusListJWT, getStatusListFromJWT, } from '../status-list-jwt'; -import type { JwtHeaderParameters, JWTwithStatusListPayload } from '../types'; +import type { + StatusListJWTHeaderParameters, + JWTwithStatusListPayload, +} from '../types'; import { StatusList } from '../status-list'; import { jwtVerify, type KeyLike, SignJWT } from 'jose'; import { beforeAll, describe, expect, it } from 'vitest'; @@ -14,6 +17,11 @@ describe('JWTStatusList', () => { let publicKey: KeyLike; let privateKey: KeyLike; + const header: StatusListJWTHeaderParameters = { + alg: 'ES256', + typ: 'statuslist+jwt', + }; + beforeAll(() => { // Generate a key pair for testing const keyPair = generateKeyPairSync('ec', { @@ -31,7 +39,6 @@ describe('JWTStatusList', () => { sub: `${iss}/statuslist/1`, iat: new Date().getTime() / 1000, }; - const header: JwtHeaderParameters = { alg: 'ES256' }; const values = createHeaderAndPayload(statusList, payload, header); @@ -56,7 +63,6 @@ describe('JWTStatusList', () => { sub: `${iss}/statuslist/1`, iat: new Date().getTime() / 1000, }; - const header: JwtHeaderParameters = { alg: 'ES256' }; const values = createHeaderAndPayload(statusList, payload, header); @@ -74,7 +80,6 @@ describe('JWTStatusList', () => { const list = [1, 0, 1, 0, 1]; const statusList = new StatusList(list, 2); const iss = 'https://example.com'; - const header: JwtHeaderParameters = { alg: 'ES256' }; let payload: JwtPayload = { sub: `${iss}/statuslist/1`, iat: new Date().getTime() / 1000, diff --git a/packages/sd-jwt-vc/README.md b/packages/sd-jwt-vc/README.md index 9c3b32cd..067e2bd0 100644 --- a/packages/sd-jwt-vc/README.md +++ b/packages/sd-jwt-vc/README.md @@ -83,8 +83,13 @@ const verified = await sdjwt.verify(presentation); Check out more details in our [documentation](https://github.com/openwallet-foundation-labs/sd-jwt-js/tree/main/docs) or [examples](https://github.com/openwallet-foundation-labs/sd-jwt-js/tree/main/examples) +### Revocation +To add revocation capabilities, you can use the `@sd-jwt/jwt-status-list` library to create a JWT Status List and include it in the SD-JWT-VC. + + ### Dependencies - @sd-jwt/core - @sd-jwt/types - @sd-jwt/utils +- @sd-jwt/jwt-status-list