@sd-jwt/jwt-status-list 0.17.1-next.0 → 0.17.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/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.17.1](https://github.com/openwallet-foundation/sd-jwt-js/compare/v0.17.0...v0.17.1) (2025-11-18)
7
+
8
+ **Note:** Version bump only for package @sd-jwt/jwt-status-list
9
+
10
+
11
+
12
+
13
+
6
14
  # [0.17.0](https://github.com/openwallet-foundation/sd-jwt-js/compare/v0.16.0...v0.17.0) (2025-10-23)
7
15
 
8
16
 
package/dist/index.d.mts CHANGED
@@ -95,6 +95,15 @@ declare class StatusList {
95
95
  private static decodeStatusList;
96
96
  }
97
97
 
98
+ /**
99
+ * SLException is a custom error class for Status List related exceptions.
100
+ */
101
+ declare class SLException extends Error {
102
+ details?: unknown;
103
+ constructor(message: string, details?: unknown);
104
+ getFullMessage(): string;
105
+ }
106
+
98
107
  /**
99
108
  * Adds the status list to the payload and header of a JWT.
100
109
  * @param list
@@ -119,4 +128,4 @@ declare function getListFromStatusListJWT(jwt: string): StatusList;
119
128
  */
120
129
  declare function getStatusListFromJWT(jwt: string): StatusListEntry;
121
130
 
122
- export { type BitsPerStatus, type JWTwithStatusListPayload, StatusList, type StatusListEntry, type StatusListJWTHeaderParameters, type StatusListJWTPayload, createHeaderAndPayload, getListFromStatusListJWT, getStatusListFromJWT };
131
+ export { type BitsPerStatus, type JWTwithStatusListPayload, SLException, StatusList, type StatusListEntry, type StatusListJWTHeaderParameters, type StatusListJWTPayload, createHeaderAndPayload, getListFromStatusListJWT, getStatusListFromJWT };
package/dist/index.d.ts CHANGED
@@ -95,6 +95,15 @@ declare class StatusList {
95
95
  private static decodeStatusList;
96
96
  }
97
97
 
98
+ /**
99
+ * SLException is a custom error class for Status List related exceptions.
100
+ */
101
+ declare class SLException extends Error {
102
+ details?: unknown;
103
+ constructor(message: string, details?: unknown);
104
+ getFullMessage(): string;
105
+ }
106
+
98
107
  /**
99
108
  * Adds the status list to the payload and header of a JWT.
100
109
  * @param list
@@ -119,4 +128,4 @@ declare function getListFromStatusListJWT(jwt: string): StatusList;
119
128
  */
120
129
  declare function getStatusListFromJWT(jwt: string): StatusListEntry;
121
130
 
122
- export { type BitsPerStatus, type JWTwithStatusListPayload, StatusList, type StatusListEntry, type StatusListJWTHeaderParameters, type StatusListJWTPayload, createHeaderAndPayload, getListFromStatusListJWT, getStatusListFromJWT };
131
+ export { type BitsPerStatus, type JWTwithStatusListPayload, SLException, StatusList, type StatusListEntry, type StatusListJWTHeaderParameters, type StatusListJWTPayload, createHeaderAndPayload, getListFromStatusListJWT, getStatusListFromJWT };
package/dist/index.js CHANGED
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ SLException: () => SLException,
23
24
  StatusList: () => StatusList,
24
25
  createHeaderAndPayload: () => createHeaderAndPayload,
25
26
  getListFromStatusListJWT: () => getListFromStatusListJWT,
@@ -30,6 +31,21 @@ module.exports = __toCommonJS(index_exports);
30
31
  // src/status-list.ts
31
32
  var import_utils = require("@sd-jwt/utils");
32
33
  var import_pako = require("pako");
34
+
35
+ // src/status-list-exception.ts
36
+ var SLException = class _SLException extends Error {
37
+ constructor(message, details) {
38
+ super(message);
39
+ Object.setPrototypeOf(this, _SLException.prototype);
40
+ this.name = "SLException";
41
+ this.details = details;
42
+ }
43
+ getFullMessage() {
44
+ return `${this.name}: ${this.message} ${this.details ? `- ${JSON.stringify(this.details)}` : ""}`;
45
+ }
46
+ };
47
+
48
+ // src/status-list.ts
33
49
  var StatusList = class _StatusList {
34
50
  /**
35
51
  * Create a new StatusListManager instance.
@@ -38,11 +54,11 @@ var StatusList = class _StatusList {
38
54
  */
39
55
  constructor(statusList, bitsPerStatus) {
40
56
  if (![1, 2, 4, 8].includes(bitsPerStatus)) {
41
- throw new Error("bitsPerStatus must be 1, 2, 4, or 8");
57
+ throw new SLException("bitsPerStatus must be 1, 2, 4, or 8");
42
58
  }
43
59
  for (let i = 0; i < statusList.length; i++) {
44
60
  if (statusList[i] > 2 ** bitsPerStatus) {
45
- throw Error(
61
+ throw new SLException(
46
62
  `Status value out of range at index ${i} with value ${statusList[i]}`
47
63
  );
48
64
  }
@@ -174,13 +190,13 @@ function decodeJwt(jwt) {
174
190
  }
175
191
  function createHeaderAndPayload(list, payload, header) {
176
192
  if (!payload.iss) {
177
- throw new Error("iss field is required");
193
+ throw new SLException("iss field is required");
178
194
  }
179
195
  if (!payload.sub) {
180
- throw new Error("sub field is required");
196
+ throw new SLException("sub field is required");
181
197
  }
182
198
  if (!payload.iat) {
183
- throw new Error("iat field is required");
199
+ throw new SLException("iat field is required");
184
200
  }
185
201
  header.typ = "statuslist+jwt";
186
202
  payload.status_list = {
@@ -200,6 +216,7 @@ function getStatusListFromJWT(jwt) {
200
216
  }
201
217
  // Annotate the CommonJS export names for ESM import in node:
202
218
  0 && (module.exports = {
219
+ SLException,
203
220
  StatusList,
204
221
  createHeaderAndPayload,
205
222
  getListFromStatusListJWT,
package/dist/index.mjs CHANGED
@@ -1,6 +1,21 @@
1
1
  // src/status-list.ts
2
2
  import { base64UrlToUint8Array, uint8ArrayToBase64Url } from "@sd-jwt/utils";
3
3
  import { deflate, inflate } from "pako";
4
+
5
+ // src/status-list-exception.ts
6
+ var SLException = class _SLException extends Error {
7
+ constructor(message, details) {
8
+ super(message);
9
+ Object.setPrototypeOf(this, _SLException.prototype);
10
+ this.name = "SLException";
11
+ this.details = details;
12
+ }
13
+ getFullMessage() {
14
+ return `${this.name}: ${this.message} ${this.details ? `- ${JSON.stringify(this.details)}` : ""}`;
15
+ }
16
+ };
17
+
18
+ // src/status-list.ts
4
19
  var StatusList = class _StatusList {
5
20
  /**
6
21
  * Create a new StatusListManager instance.
@@ -9,11 +24,11 @@ var StatusList = class _StatusList {
9
24
  */
10
25
  constructor(statusList, bitsPerStatus) {
11
26
  if (![1, 2, 4, 8].includes(bitsPerStatus)) {
12
- throw new Error("bitsPerStatus must be 1, 2, 4, or 8");
27
+ throw new SLException("bitsPerStatus must be 1, 2, 4, or 8");
13
28
  }
14
29
  for (let i = 0; i < statusList.length; i++) {
15
30
  if (statusList[i] > 2 ** bitsPerStatus) {
16
- throw Error(
31
+ throw new SLException(
17
32
  `Status value out of range at index ${i} with value ${statusList[i]}`
18
33
  );
19
34
  }
@@ -145,13 +160,13 @@ function decodeJwt(jwt) {
145
160
  }
146
161
  function createHeaderAndPayload(list, payload, header) {
147
162
  if (!payload.iss) {
148
- throw new Error("iss field is required");
163
+ throw new SLException("iss field is required");
149
164
  }
150
165
  if (!payload.sub) {
151
- throw new Error("sub field is required");
166
+ throw new SLException("sub field is required");
152
167
  }
153
168
  if (!payload.iat) {
154
- throw new Error("iat field is required");
169
+ throw new SLException("iat field is required");
155
170
  }
156
171
  header.typ = "statuslist+jwt";
157
172
  payload.status_list = {
@@ -170,6 +185,7 @@ function getStatusListFromJWT(jwt) {
170
185
  return payload.status.status_list;
171
186
  }
172
187
  export {
188
+ SLException,
173
189
  StatusList,
174
190
  createHeaderAndPayload,
175
191
  getListFromStatusListJWT,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sd-jwt/jwt-status-list",
3
- "version": "0.17.1-next.0+9f37cdf",
3
+ "version": "0.17.1",
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",
@@ -41,8 +41,8 @@
41
41
  "jose": "^6.1.0"
42
42
  },
43
43
  "dependencies": {
44
- "@sd-jwt/types": "0.17.1-next.0+9f37cdf",
45
- "@sd-jwt/utils": "0.17.1-next.0+9f37cdf",
44
+ "@sd-jwt/types": "0.17.0",
45
+ "@sd-jwt/utils": "0.17.0",
46
46
  "pako": "^2.1.0"
47
47
  },
48
48
  "publishConfig": {
@@ -61,5 +61,5 @@
61
61
  "esm"
62
62
  ]
63
63
  },
64
- "gitHead": "9f37cdfbae982a647e61589fd88dfd79305105c1"
64
+ "gitHead": "1301a03484b285711d7afd7448457348bad96569"
65
65
  }
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './status-list';
2
+ export * from './status-list-exception';
2
3
  export * from './status-list-jwt';
3
4
  export * from './types';
@@ -0,0 +1,19 @@
1
+ /**
2
+ * SLException is a custom error class for Status List related exceptions.
3
+ */
4
+ export class SLException extends Error {
5
+ public details?: unknown;
6
+
7
+ constructor(message: string, details?: unknown) {
8
+ super(message);
9
+ Object.setPrototypeOf(this, SLException.prototype);
10
+ this.name = 'SLException';
11
+ this.details = details;
12
+ }
13
+
14
+ getFullMessage(): string {
15
+ return `${this.name}: ${this.message} ${
16
+ this.details ? `- ${JSON.stringify(this.details)}` : ''
17
+ }`;
18
+ }
19
+ }
@@ -1,6 +1,7 @@
1
1
  import type { JwtPayload } from '@sd-jwt/types';
2
2
  import { base64urlDecode } from '@sd-jwt/utils';
3
3
  import { StatusList } from './status-list';
4
+ import { SLException } from './status-list-exception';
4
5
  import type {
5
6
  JWTwithStatusListPayload,
6
7
  StatusListEntry,
@@ -33,13 +34,13 @@ export function createHeaderAndPayload(
33
34
  // validate if the required fieds are present based on https://www.ietf.org/archive/id/draft-ietf-oauth-status-list-02.html#section-5.1
34
35
 
35
36
  if (!payload.iss) {
36
- throw new Error('iss field is required');
37
+ throw new SLException('iss field is required');
37
38
  }
38
39
  if (!payload.sub) {
39
- throw new Error('sub field is required');
40
+ throw new SLException('sub field is required');
40
41
  }
41
42
  if (!payload.iat) {
42
- throw new Error('iat field is required');
43
+ throw new SLException('iat field is required');
43
44
  }
44
45
  //exp and tll are optional. We will not validate the business logic of the values like exp > iat etc.
45
46
 
@@ -1,5 +1,6 @@
1
1
  import { base64UrlToUint8Array, uint8ArrayToBase64Url } from '@sd-jwt/utils';
2
2
  import { deflate, inflate } from 'pako';
3
+ import { SLException } from './status-list-exception';
3
4
  import type { BitsPerStatus } from './types';
4
5
  /**
5
6
  * StatusListManager is a class that manages a list of statuses with variable bit size.
@@ -16,12 +17,12 @@ export class StatusList {
16
17
  */
17
18
  constructor(statusList: number[], bitsPerStatus: BitsPerStatus) {
18
19
  if (![1, 2, 4, 8].includes(bitsPerStatus)) {
19
- throw new Error('bitsPerStatus must be 1, 2, 4, or 8');
20
+ throw new SLException('bitsPerStatus must be 1, 2, 4, or 8');
20
21
  }
21
22
  //check that the entries in the statusList are within the range of the bitsPerStatus
22
23
  for (let i = 0; i < statusList.length; i++) {
23
24
  if (statusList[i] > 2 ** bitsPerStatus) {
24
- throw Error(
25
+ throw new SLException(
25
26
  `Status value out of range at index ${i} with value ${statusList[i]}`,
26
27
  );
27
28
  }