@sd-jwt/jwt-status-list 0.12.0 → 0.12.1-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -4
- package/package.json +3 -3
- package/src/test/status-list-jwt.spec.ts +5 -5
package/README.md
CHANGED
|
@@ -6,11 +6,10 @@
|
|
|
6
6
|
# SD-JWT Implementation in JavaScript (TypeScript)
|
|
7
7
|
|
|
8
8
|
## jwt-status-list
|
|
9
|
+
|
|
9
10
|
An implementation of the [Token Status List](https://datatracker.ietf.org/doc/draft-ietf-oauth-status-list/) for a JWT representation, not for CBOR.
|
|
10
11
|
This library helps to verify the status of a specific entry in a JWT, and to generate a status list and pack it into a signed JWT. It does not provide any functions to manage the status list itself.
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
13
|
## Installation
|
|
15
14
|
|
|
16
15
|
To install this project, run the following command:
|
|
@@ -27,9 +26,11 @@ pnpm install @sd-jwt/jwt-status-list
|
|
|
27
26
|
```
|
|
28
27
|
|
|
29
28
|
Ensure you have Node.js installed as a prerequisite.
|
|
29
|
+
|
|
30
30
|
## Usage
|
|
31
31
|
|
|
32
32
|
Creation of a JWT Status List:
|
|
33
|
+
|
|
33
34
|
```typescript
|
|
34
35
|
// pass the list as an array and the amount of bits per entry.
|
|
35
36
|
const list = new StatusList([1, 0, 1, 1, 1], 1);
|
|
@@ -37,9 +38,9 @@ const iss = 'https://example.com';
|
|
|
37
38
|
const payload: JWTPayload = {
|
|
38
39
|
iss,
|
|
39
40
|
sub: `${iss}/statuslist/1`,
|
|
40
|
-
iat:
|
|
41
|
+
iat: Math.floor(Date.now() / 1000), // issued at time in seconds
|
|
41
42
|
ttl: 3000, // time to live in seconds, optional
|
|
42
|
-
exp:
|
|
43
|
+
exp: Math.floor(Date.now() / 1000) + 3600, // expiration time in seconds, optional
|
|
43
44
|
};
|
|
44
45
|
const header: JWTHeaderParameters = { alg: 'ES256' };
|
|
45
46
|
|
|
@@ -53,6 +54,7 @@ const jwt = await new SignJWT(values.payload)
|
|
|
53
54
|
```
|
|
54
55
|
|
|
55
56
|
Interaction with a JWT status list on low level:
|
|
57
|
+
|
|
56
58
|
```typescript
|
|
57
59
|
//validation of the JWT is not provided by this library!!!
|
|
58
60
|
|
|
@@ -72,9 +74,11 @@ const status = statusList.getStatus(reference.idx);
|
|
|
72
74
|
```
|
|
73
75
|
|
|
74
76
|
### Integration into sd-jwt-vc
|
|
77
|
+
|
|
75
78
|
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.
|
|
76
79
|
|
|
77
80
|
### Caching the status list
|
|
81
|
+
|
|
78
82
|
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.
|
|
79
83
|
|
|
80
84
|
## Development
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sd-jwt/jwt-status-list",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.1-next.1+0a2f20b",
|
|
4
4
|
"description": "Implementation based on https://datatracker.ietf.org/doc/draft-ietf-oauth-status-list/",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"jose": "^5.2.2"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@sd-jwt/types": "0.12.
|
|
45
|
+
"@sd-jwt/types": "0.12.1-next.1+0a2f20b",
|
|
46
46
|
"base64url": "^3.0.1",
|
|
47
47
|
"pako": "^2.1.0"
|
|
48
48
|
},
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"esm"
|
|
63
63
|
]
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "0a2f20b6383d2356540e7a9cc37748c7b9caced2"
|
|
66
66
|
}
|
|
@@ -37,7 +37,7 @@ describe('JWTStatusList', () => {
|
|
|
37
37
|
const payload: JwtPayload = {
|
|
38
38
|
iss,
|
|
39
39
|
sub: `${iss}/statuslist/1`,
|
|
40
|
-
iat:
|
|
40
|
+
iat: Math.floor(Date.now() / 1000),
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
const values = createHeaderAndPayload(statusList, payload, header);
|
|
@@ -61,7 +61,7 @@ describe('JWTStatusList', () => {
|
|
|
61
61
|
const payload: JwtPayload = {
|
|
62
62
|
iss,
|
|
63
63
|
sub: `${iss}/statuslist/1`,
|
|
64
|
-
iat:
|
|
64
|
+
iat: Math.floor(Date.now() / 1000),
|
|
65
65
|
};
|
|
66
66
|
|
|
67
67
|
const values = createHeaderAndPayload(statusList, payload, header);
|
|
@@ -82,7 +82,7 @@ describe('JWTStatusList', () => {
|
|
|
82
82
|
const iss = 'https://example.com';
|
|
83
83
|
let payload: JwtPayload = {
|
|
84
84
|
sub: `${iss}/statuslist/1`,
|
|
85
|
-
iat:
|
|
85
|
+
iat: Math.floor(Date.now() / 1000),
|
|
86
86
|
};
|
|
87
87
|
expect(() => {
|
|
88
88
|
createHeaderAndPayload(statusList, payload as JwtPayload, header);
|
|
@@ -90,7 +90,7 @@ describe('JWTStatusList', () => {
|
|
|
90
90
|
|
|
91
91
|
payload = {
|
|
92
92
|
iss,
|
|
93
|
-
iat:
|
|
93
|
+
iat: Math.floor(Date.now() / 1000),
|
|
94
94
|
};
|
|
95
95
|
expect(() => createHeaderAndPayload(statusList, payload, header)).toThrow(
|
|
96
96
|
'sub field is required',
|
|
@@ -109,7 +109,7 @@ describe('JWTStatusList', () => {
|
|
|
109
109
|
const payload: JWTwithStatusListPayload = {
|
|
110
110
|
iss: 'https://example.com',
|
|
111
111
|
sub: 'https://example.com/status/1',
|
|
112
|
-
iat:
|
|
112
|
+
iat: Math.floor(Date.now() / 1000),
|
|
113
113
|
status: {
|
|
114
114
|
status_list: {
|
|
115
115
|
idx: 0,
|