@sd-jwt/jwt-status-list 0.7.1-next.1 → 0.7.1-next.2
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/dist/index.d.mts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +10 -7
- package/dist/index.mjs +10 -7
- package/package.json +3 -3
- package/src/status-list.ts +12 -8
- package/src/test/status-list.spec.ts +7 -2
package/dist/index.d.mts
CHANGED
|
@@ -42,7 +42,7 @@ type StatusListJWTHeaderParameters = {
|
|
|
42
42
|
* StatusListManager is a class that manages a list of statuses with variable bit size.
|
|
43
43
|
*/
|
|
44
44
|
declare class StatusList {
|
|
45
|
-
private
|
|
45
|
+
private _statusList;
|
|
46
46
|
private bitsPerStatus;
|
|
47
47
|
private totalStatuses;
|
|
48
48
|
/**
|
|
@@ -51,6 +51,10 @@ declare class StatusList {
|
|
|
51
51
|
* @param bitsPerStatus
|
|
52
52
|
*/
|
|
53
53
|
constructor(statusList: number[], bitsPerStatus: BitsPerStatus);
|
|
54
|
+
/**
|
|
55
|
+
* Get the status list.
|
|
56
|
+
*/
|
|
57
|
+
get statusList(): number[];
|
|
54
58
|
/**
|
|
55
59
|
* Get the number of statuses.
|
|
56
60
|
* @returns
|
|
@@ -59,7 +63,6 @@ declare class StatusList {
|
|
|
59
63
|
/**
|
|
60
64
|
* Get the status at a specific index.
|
|
61
65
|
* @param index
|
|
62
|
-
* @returns
|
|
63
66
|
*/
|
|
64
67
|
getStatus(index: number): number;
|
|
65
68
|
/**
|
|
@@ -70,14 +73,12 @@ declare class StatusList {
|
|
|
70
73
|
setStatus(index: number, value: number): void;
|
|
71
74
|
/**
|
|
72
75
|
* Compress the status list.
|
|
73
|
-
* @returns
|
|
74
76
|
*/
|
|
75
77
|
compressStatusList(): string;
|
|
76
78
|
/**
|
|
77
79
|
* Decompress the compressed status list and return a new StatusList instance.
|
|
78
80
|
* @param compressed
|
|
79
81
|
* @param bitsPerStatus
|
|
80
|
-
* @returns
|
|
81
82
|
*/
|
|
82
83
|
static decompressStatusList(compressed: string, bitsPerStatus: BitsPerStatus): StatusList;
|
|
83
84
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -42,7 +42,7 @@ type StatusListJWTHeaderParameters = {
|
|
|
42
42
|
* StatusListManager is a class that manages a list of statuses with variable bit size.
|
|
43
43
|
*/
|
|
44
44
|
declare class StatusList {
|
|
45
|
-
private
|
|
45
|
+
private _statusList;
|
|
46
46
|
private bitsPerStatus;
|
|
47
47
|
private totalStatuses;
|
|
48
48
|
/**
|
|
@@ -51,6 +51,10 @@ declare class StatusList {
|
|
|
51
51
|
* @param bitsPerStatus
|
|
52
52
|
*/
|
|
53
53
|
constructor(statusList: number[], bitsPerStatus: BitsPerStatus);
|
|
54
|
+
/**
|
|
55
|
+
* Get the status list.
|
|
56
|
+
*/
|
|
57
|
+
get statusList(): number[];
|
|
54
58
|
/**
|
|
55
59
|
* Get the number of statuses.
|
|
56
60
|
* @returns
|
|
@@ -59,7 +63,6 @@ declare class StatusList {
|
|
|
59
63
|
/**
|
|
60
64
|
* Get the status at a specific index.
|
|
61
65
|
* @param index
|
|
62
|
-
* @returns
|
|
63
66
|
*/
|
|
64
67
|
getStatus(index: number): number;
|
|
65
68
|
/**
|
|
@@ -70,14 +73,12 @@ declare class StatusList {
|
|
|
70
73
|
setStatus(index: number, value: number): void;
|
|
71
74
|
/**
|
|
72
75
|
* Compress the status list.
|
|
73
|
-
* @returns
|
|
74
76
|
*/
|
|
75
77
|
compressStatusList(): string;
|
|
76
78
|
/**
|
|
77
79
|
* Decompress the compressed status list and return a new StatusList instance.
|
|
78
80
|
* @param compressed
|
|
79
81
|
* @param bitsPerStatus
|
|
80
|
-
* @returns
|
|
81
82
|
*/
|
|
82
83
|
static decompressStatusList(compressed: string, bitsPerStatus: BitsPerStatus): StatusList;
|
|
83
84
|
/**
|
package/dist/index.js
CHANGED
|
@@ -57,10 +57,16 @@ var StatusList = class _StatusList {
|
|
|
57
57
|
);
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
this.
|
|
60
|
+
this._statusList = statusList;
|
|
61
61
|
this.bitsPerStatus = bitsPerStatus;
|
|
62
62
|
this.totalStatuses = statusList.length;
|
|
63
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Get the status list.
|
|
66
|
+
*/
|
|
67
|
+
get statusList() {
|
|
68
|
+
return this._statusList;
|
|
69
|
+
}
|
|
64
70
|
/**
|
|
65
71
|
* Get the number of statuses.
|
|
66
72
|
* @returns
|
|
@@ -71,13 +77,12 @@ var StatusList = class _StatusList {
|
|
|
71
77
|
/**
|
|
72
78
|
* Get the status at a specific index.
|
|
73
79
|
* @param index
|
|
74
|
-
* @returns
|
|
75
80
|
*/
|
|
76
81
|
getStatus(index) {
|
|
77
82
|
if (index < 0 || index >= this.totalStatuses) {
|
|
78
83
|
throw new Error("Index out of bounds");
|
|
79
84
|
}
|
|
80
|
-
return this.
|
|
85
|
+
return this._statusList[index];
|
|
81
86
|
}
|
|
82
87
|
/**
|
|
83
88
|
* Set the status at a specific index.
|
|
@@ -88,11 +93,10 @@ var StatusList = class _StatusList {
|
|
|
88
93
|
if (index < 0 || index >= this.totalStatuses) {
|
|
89
94
|
throw new Error("Index out of bounds");
|
|
90
95
|
}
|
|
91
|
-
this.
|
|
96
|
+
this._statusList[index] = value;
|
|
92
97
|
}
|
|
93
98
|
/**
|
|
94
99
|
* Compress the status list.
|
|
95
|
-
* @returns
|
|
96
100
|
*/
|
|
97
101
|
compressStatusList() {
|
|
98
102
|
const byteArray = this.encodeStatusList();
|
|
@@ -103,7 +107,6 @@ var StatusList = class _StatusList {
|
|
|
103
107
|
* Decompress the compressed status list and return a new StatusList instance.
|
|
104
108
|
* @param compressed
|
|
105
109
|
* @param bitsPerStatus
|
|
106
|
-
* @returns
|
|
107
110
|
*/
|
|
108
111
|
static decompressStatusList(compressed, bitsPerStatus) {
|
|
109
112
|
const decoded = new Uint8Array(
|
|
@@ -132,7 +135,7 @@ var StatusList = class _StatusList {
|
|
|
132
135
|
let bitIndex = 0;
|
|
133
136
|
let currentByte = "";
|
|
134
137
|
for (let i = 0; i < this.totalStatuses; i++) {
|
|
135
|
-
const status = this.
|
|
138
|
+
const status = this._statusList[i];
|
|
136
139
|
currentByte = status.toString(2).padStart(numBits, "0") + currentByte;
|
|
137
140
|
bitIndex += numBits;
|
|
138
141
|
if (bitIndex >= 8 || i === this.totalStatuses - 1) {
|
package/dist/index.mjs
CHANGED
|
@@ -18,10 +18,16 @@ var StatusList = class _StatusList {
|
|
|
18
18
|
);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
this.
|
|
21
|
+
this._statusList = statusList;
|
|
22
22
|
this.bitsPerStatus = bitsPerStatus;
|
|
23
23
|
this.totalStatuses = statusList.length;
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Get the status list.
|
|
27
|
+
*/
|
|
28
|
+
get statusList() {
|
|
29
|
+
return this._statusList;
|
|
30
|
+
}
|
|
25
31
|
/**
|
|
26
32
|
* Get the number of statuses.
|
|
27
33
|
* @returns
|
|
@@ -32,13 +38,12 @@ var StatusList = class _StatusList {
|
|
|
32
38
|
/**
|
|
33
39
|
* Get the status at a specific index.
|
|
34
40
|
* @param index
|
|
35
|
-
* @returns
|
|
36
41
|
*/
|
|
37
42
|
getStatus(index) {
|
|
38
43
|
if (index < 0 || index >= this.totalStatuses) {
|
|
39
44
|
throw new Error("Index out of bounds");
|
|
40
45
|
}
|
|
41
|
-
return this.
|
|
46
|
+
return this._statusList[index];
|
|
42
47
|
}
|
|
43
48
|
/**
|
|
44
49
|
* Set the status at a specific index.
|
|
@@ -49,11 +54,10 @@ var StatusList = class _StatusList {
|
|
|
49
54
|
if (index < 0 || index >= this.totalStatuses) {
|
|
50
55
|
throw new Error("Index out of bounds");
|
|
51
56
|
}
|
|
52
|
-
this.
|
|
57
|
+
this._statusList[index] = value;
|
|
53
58
|
}
|
|
54
59
|
/**
|
|
55
60
|
* Compress the status list.
|
|
56
|
-
* @returns
|
|
57
61
|
*/
|
|
58
62
|
compressStatusList() {
|
|
59
63
|
const byteArray = this.encodeStatusList();
|
|
@@ -64,7 +68,6 @@ var StatusList = class _StatusList {
|
|
|
64
68
|
* Decompress the compressed status list and return a new StatusList instance.
|
|
65
69
|
* @param compressed
|
|
66
70
|
* @param bitsPerStatus
|
|
67
|
-
* @returns
|
|
68
71
|
*/
|
|
69
72
|
static decompressStatusList(compressed, bitsPerStatus) {
|
|
70
73
|
const decoded = new Uint8Array(
|
|
@@ -93,7 +96,7 @@ var StatusList = class _StatusList {
|
|
|
93
96
|
let bitIndex = 0;
|
|
94
97
|
let currentByte = "";
|
|
95
98
|
for (let i = 0; i < this.totalStatuses; i++) {
|
|
96
|
-
const status = this.
|
|
99
|
+
const status = this._statusList[i];
|
|
97
100
|
currentByte = status.toString(2).padStart(numBits, "0") + currentByte;
|
|
98
101
|
bitIndex += numBits;
|
|
99
102
|
if (bitIndex >= 8 || i === this.totalStatuses - 1) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sd-jwt/jwt-status-list",
|
|
3
|
-
"version": "0.7.1-next.
|
|
3
|
+
"version": "0.7.1-next.2+0329a6b",
|
|
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.7.1-next.
|
|
45
|
+
"@sd-jwt/types": "0.7.1-next.2+0329a6b",
|
|
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": "0329a6b4e8ba11d2fd727c41606c17acbb68e3c5"
|
|
66
66
|
}
|
package/src/status-list.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { BitsPerStatus } from './types';
|
|
|
5
5
|
* StatusListManager is a class that manages a list of statuses with variable bit size.
|
|
6
6
|
*/
|
|
7
7
|
export class StatusList {
|
|
8
|
-
private
|
|
8
|
+
private _statusList: number[];
|
|
9
9
|
private bitsPerStatus: BitsPerStatus;
|
|
10
10
|
private totalStatuses: number;
|
|
11
11
|
|
|
@@ -26,11 +26,18 @@ export class StatusList {
|
|
|
26
26
|
);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
this.
|
|
29
|
+
this._statusList = statusList;
|
|
30
30
|
this.bitsPerStatus = bitsPerStatus;
|
|
31
31
|
this.totalStatuses = statusList.length;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Get the status list.
|
|
36
|
+
*/
|
|
37
|
+
get statusList(): number[] {
|
|
38
|
+
return this._statusList;
|
|
39
|
+
}
|
|
40
|
+
|
|
34
41
|
/**
|
|
35
42
|
* Get the number of statuses.
|
|
36
43
|
* @returns
|
|
@@ -42,13 +49,12 @@ export class StatusList {
|
|
|
42
49
|
/**
|
|
43
50
|
* Get the status at a specific index.
|
|
44
51
|
* @param index
|
|
45
|
-
* @returns
|
|
46
52
|
*/
|
|
47
53
|
getStatus(index: number): number {
|
|
48
54
|
if (index < 0 || index >= this.totalStatuses) {
|
|
49
55
|
throw new Error('Index out of bounds');
|
|
50
56
|
}
|
|
51
|
-
return this.
|
|
57
|
+
return this._statusList[index];
|
|
52
58
|
}
|
|
53
59
|
|
|
54
60
|
/**
|
|
@@ -60,12 +66,11 @@ export class StatusList {
|
|
|
60
66
|
if (index < 0 || index >= this.totalStatuses) {
|
|
61
67
|
throw new Error('Index out of bounds');
|
|
62
68
|
}
|
|
63
|
-
this.
|
|
69
|
+
this._statusList[index] = value;
|
|
64
70
|
}
|
|
65
71
|
|
|
66
72
|
/**
|
|
67
73
|
* Compress the status list.
|
|
68
|
-
* @returns
|
|
69
74
|
*/
|
|
70
75
|
compressStatusList(): string {
|
|
71
76
|
const byteArray = this.encodeStatusList();
|
|
@@ -77,7 +82,6 @@ export class StatusList {
|
|
|
77
82
|
* Decompress the compressed status list and return a new StatusList instance.
|
|
78
83
|
* @param compressed
|
|
79
84
|
* @param bitsPerStatus
|
|
80
|
-
* @returns
|
|
81
85
|
*/
|
|
82
86
|
static decompressStatusList(
|
|
83
87
|
compressed: string,
|
|
@@ -113,7 +117,7 @@ export class StatusList {
|
|
|
113
117
|
let bitIndex = 0;
|
|
114
118
|
let currentByte = '';
|
|
115
119
|
for (let i = 0; i < this.totalStatuses; i++) {
|
|
116
|
-
const status = this.
|
|
120
|
+
const status = this._statusList[i];
|
|
117
121
|
// Place bits from status into currentByte, starting from the most significant bit.
|
|
118
122
|
currentByte = status.toString(2).padStart(numBits, '0') + currentByte;
|
|
119
123
|
bitIndex += numBits;
|
|
@@ -26,9 +26,14 @@ describe('StatusList', () => {
|
|
|
26
26
|
const manager = new StatusList(status, 1);
|
|
27
27
|
const encoded = manager.compressStatusList();
|
|
28
28
|
expect(encoded).toBe('eNrbuRgAAhcBXQ');
|
|
29
|
-
const
|
|
29
|
+
const list = StatusList.decompressStatusList(encoded, 1);
|
|
30
30
|
for (let i = 0; i < status.length; i++) {
|
|
31
|
-
expect(
|
|
31
|
+
expect(list.getStatus(i)).toBe(status[i]);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//get the whole list and check if it is equal
|
|
35
|
+
for (let i = 0; i < list.statusList.length; i++) {
|
|
36
|
+
expect(list.statusList[i]).toBe(status[i]);
|
|
32
37
|
}
|
|
33
38
|
});
|
|
34
39
|
|