@sd-jwt/core 0.20.0 → 0.20.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/dist/index.js CHANGED
@@ -1263,12 +1263,13 @@ var _SDJwtInstance = class _SDJwtInstance {
1263
1263
  // If requireKeyBindings is true, it will check if the key binding JWT is presentation and verify it
1264
1264
  verify(encodedSDJwt, options) {
1265
1265
  return __async(this, null, function* () {
1266
+ var _a;
1266
1267
  if (!this.userConfig.hasher) {
1267
1268
  throw new SDJWTException("Hasher not found");
1268
1269
  }
1269
1270
  const hasher = this.userConfig.hasher;
1270
1271
  const sdjwt = yield SDJwt.fromEncode(encodedSDJwt, hasher);
1271
- if (!sdjwt.jwt || !sdjwt.jwt.payload) {
1272
+ if (!((_a = sdjwt.jwt) == null ? void 0 : _a.payload)) {
1272
1273
  throw new SDJWTException("Invalid SD JWT");
1273
1274
  }
1274
1275
  const { payload, header } = yield this.validate(encodedSDJwt, options);
@@ -1328,6 +1329,7 @@ var _SDJwtInstance = class _SDJwtInstance {
1328
1329
  */
1329
1330
  safeVerify(encodedSDJwt, options) {
1330
1331
  return __async(this, null, function* () {
1332
+ var _a;
1331
1333
  const errors = [];
1332
1334
  const addError = (code, message, details) => {
1333
1335
  errors.push({ code, message, details });
@@ -1368,7 +1370,7 @@ var _SDJwtInstance = class _SDJwtInstance {
1368
1370
  let header;
1369
1371
  try {
1370
1372
  sdjwt = yield SDJwt.fromEncode(encodedSDJwt, hasher);
1371
- if (!sdjwt.jwt || !sdjwt.jwt.payload) {
1373
+ if (!((_a = sdjwt.jwt) == null ? void 0 : _a.payload)) {
1372
1374
  addError("INVALID_SD_JWT", "Invalid SD JWT: missing JWT or payload");
1373
1375
  }
1374
1376
  } catch (e) {
@@ -1483,7 +1485,8 @@ var _SDJwtInstance = class _SDJwtInstance {
1483
1485
  }
1484
1486
  calculateSDHash(presentSdJwtWithoutKb, sdjwt, hasher) {
1485
1487
  return __async(this, null, function* () {
1486
- if (!sdjwt.jwt || !sdjwt.jwt.payload) {
1488
+ var _a;
1489
+ if (!((_a = sdjwt.jwt) == null ? void 0 : _a.payload)) {
1487
1490
  throw new SDJWTException("Invalid SD JWT");
1488
1491
  }
1489
1492
  const { _sd_alg } = getSDAlgAndPayload(sdjwt.jwt.payload);
@@ -1714,6 +1717,7 @@ var SDJwtGeneralJSONInstance = class {
1714
1717
  // If requireKeyBindings is true, it will check if the key binding JWT is presentation and verify it
1715
1718
  verify(generalJSON, options) {
1716
1719
  return __async(this, null, function* () {
1720
+ var _a;
1717
1721
  if (!this.userConfig.hasher) {
1718
1722
  throw new SDJWTException("Hasher not found");
1719
1723
  }
@@ -1721,7 +1725,7 @@ var SDJwtGeneralJSONInstance = class {
1721
1725
  const { payload, headers } = yield this.validate(generalJSON);
1722
1726
  const encodedSDJwt = generalJSON.toEncoded(0);
1723
1727
  const sdjwt = yield SDJwt.fromEncode(encodedSDJwt, hasher);
1724
- if (!sdjwt.jwt || !sdjwt.jwt.payload) {
1728
+ if (!((_a = sdjwt.jwt) == null ? void 0 : _a.payload)) {
1725
1729
  throw new SDJWTException("Invalid SD JWT");
1726
1730
  }
1727
1731
  if (options == null ? void 0 : options.requiredClaimKeys) {
@@ -1772,7 +1776,8 @@ var SDJwtGeneralJSONInstance = class {
1772
1776
  }
1773
1777
  calculateSDHash(presentSdJwtWithoutKb, sdjwt, hasher) {
1774
1778
  return __async(this, null, function* () {
1775
- if (!sdjwt.jwt || !sdjwt.jwt.payload) {
1779
+ var _a;
1780
+ if (!((_a = sdjwt.jwt) == null ? void 0 : _a.payload)) {
1776
1781
  throw new SDJWTException("Invalid SD JWT");
1777
1782
  }
1778
1783
  const { _sd_alg } = getSDAlgAndPayload(sdjwt.jwt.payload);
package/dist/index.mjs CHANGED
@@ -1204,12 +1204,13 @@ var _SDJwtInstance = class _SDJwtInstance {
1204
1204
  // If requireKeyBindings is true, it will check if the key binding JWT is presentation and verify it
1205
1205
  verify(encodedSDJwt, options) {
1206
1206
  return __async(this, null, function* () {
1207
+ var _a;
1207
1208
  if (!this.userConfig.hasher) {
1208
1209
  throw new SDJWTException("Hasher not found");
1209
1210
  }
1210
1211
  const hasher = this.userConfig.hasher;
1211
1212
  const sdjwt = yield SDJwt.fromEncode(encodedSDJwt, hasher);
1212
- if (!sdjwt.jwt || !sdjwt.jwt.payload) {
1213
+ if (!((_a = sdjwt.jwt) == null ? void 0 : _a.payload)) {
1213
1214
  throw new SDJWTException("Invalid SD JWT");
1214
1215
  }
1215
1216
  const { payload, header } = yield this.validate(encodedSDJwt, options);
@@ -1269,6 +1270,7 @@ var _SDJwtInstance = class _SDJwtInstance {
1269
1270
  */
1270
1271
  safeVerify(encodedSDJwt, options) {
1271
1272
  return __async(this, null, function* () {
1273
+ var _a;
1272
1274
  const errors = [];
1273
1275
  const addError = (code, message, details) => {
1274
1276
  errors.push({ code, message, details });
@@ -1309,7 +1311,7 @@ var _SDJwtInstance = class _SDJwtInstance {
1309
1311
  let header;
1310
1312
  try {
1311
1313
  sdjwt = yield SDJwt.fromEncode(encodedSDJwt, hasher);
1312
- if (!sdjwt.jwt || !sdjwt.jwt.payload) {
1314
+ if (!((_a = sdjwt.jwt) == null ? void 0 : _a.payload)) {
1313
1315
  addError("INVALID_SD_JWT", "Invalid SD JWT: missing JWT or payload");
1314
1316
  }
1315
1317
  } catch (e) {
@@ -1424,7 +1426,8 @@ var _SDJwtInstance = class _SDJwtInstance {
1424
1426
  }
1425
1427
  calculateSDHash(presentSdJwtWithoutKb, sdjwt, hasher) {
1426
1428
  return __async(this, null, function* () {
1427
- if (!sdjwt.jwt || !sdjwt.jwt.payload) {
1429
+ var _a;
1430
+ if (!((_a = sdjwt.jwt) == null ? void 0 : _a.payload)) {
1428
1431
  throw new SDJWTException("Invalid SD JWT");
1429
1432
  }
1430
1433
  const { _sd_alg } = getSDAlgAndPayload(sdjwt.jwt.payload);
@@ -1655,6 +1658,7 @@ var SDJwtGeneralJSONInstance = class {
1655
1658
  // If requireKeyBindings is true, it will check if the key binding JWT is presentation and verify it
1656
1659
  verify(generalJSON, options) {
1657
1660
  return __async(this, null, function* () {
1661
+ var _a;
1658
1662
  if (!this.userConfig.hasher) {
1659
1663
  throw new SDJWTException("Hasher not found");
1660
1664
  }
@@ -1662,7 +1666,7 @@ var SDJwtGeneralJSONInstance = class {
1662
1666
  const { payload, headers } = yield this.validate(generalJSON);
1663
1667
  const encodedSDJwt = generalJSON.toEncoded(0);
1664
1668
  const sdjwt = yield SDJwt.fromEncode(encodedSDJwt, hasher);
1665
- if (!sdjwt.jwt || !sdjwt.jwt.payload) {
1669
+ if (!((_a = sdjwt.jwt) == null ? void 0 : _a.payload)) {
1666
1670
  throw new SDJWTException("Invalid SD JWT");
1667
1671
  }
1668
1672
  if (options == null ? void 0 : options.requiredClaimKeys) {
@@ -1713,7 +1717,8 @@ var SDJwtGeneralJSONInstance = class {
1713
1717
  }
1714
1718
  calculateSDHash(presentSdJwtWithoutKb, sdjwt, hasher) {
1715
1719
  return __async(this, null, function* () {
1716
- if (!sdjwt.jwt || !sdjwt.jwt.payload) {
1720
+ var _a;
1721
+ if (!((_a = sdjwt.jwt) == null ? void 0 : _a.payload)) {
1717
1722
  throw new SDJWTException("Invalid SD JWT");
1718
1723
  }
1719
1724
  const { _sd_alg } = getSDAlgAndPayload(sdjwt.jwt.payload);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sd-jwt/core",
3
- "version": "0.20.0",
3
+ "version": "0.20.1-next.1+c95e1ab",
4
4
  "description": "sd-jwt draft 7 implementation in typescript",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -37,10 +37,10 @@
37
37
  },
38
38
  "license": "Apache-2.0",
39
39
  "devDependencies": {
40
- "@owf/crypto": "^0.1.0-alpha-20260312123226"
40
+ "@owf/crypto": "^0.3.1"
41
41
  },
42
42
  "dependencies": {
43
- "@owf/identity-common": "^0.1.0-alpha-20260312123226"
43
+ "@owf/identity-common": "^0.3.1"
44
44
  },
45
45
  "publishConfig": {
46
46
  "access": "public"
@@ -58,5 +58,5 @@
58
58
  "esm"
59
59
  ]
60
60
  },
61
- "gitHead": "af170ace9b42984f8c6447caf23256fde6204b31"
61
+ "gitHead": "c95e1abfeb39c2814b874396cb03f1b7ef5d478c"
62
62
  }
package/src/index.ts CHANGED
@@ -235,7 +235,7 @@ export class SDJwtInstance<ExtendedPayload extends SdJwtPayload, T = unknown> {
235
235
  const hasher = this.userConfig.hasher;
236
236
 
237
237
  const sdjwt = await SDJwt.fromEncode(encodedSDJwt, hasher);
238
- if (!sdjwt.jwt || !sdjwt.jwt.payload) {
238
+ if (!sdjwt.jwt?.payload) {
239
239
  throw new SDJWTException('Invalid SD JWT');
240
240
  }
241
241
  const { payload, header } = await this.validate(encodedSDJwt, options);
@@ -371,7 +371,7 @@ export class SDJwtInstance<ExtendedPayload extends SdJwtPayload, T = unknown> {
371
371
 
372
372
  try {
373
373
  sdjwt = await SDJwt.fromEncode(encodedSDJwt, hasher);
374
- if (!sdjwt.jwt || !sdjwt.jwt.payload) {
374
+ if (!sdjwt.jwt?.payload) {
375
375
  addError('INVALID_SD_JWT', 'Invalid SD JWT: missing JWT or payload');
376
376
  }
377
377
  } catch (e) {
@@ -503,7 +503,7 @@ export class SDJwtInstance<ExtendedPayload extends SdJwtPayload, T = unknown> {
503
503
  sdjwt: SDJwt,
504
504
  hasher: Hasher,
505
505
  ) {
506
- if (!sdjwt.jwt || !sdjwt.jwt.payload) {
506
+ if (!sdjwt.jwt?.payload) {
507
507
  throw new SDJWTException('Invalid SD JWT');
508
508
  }
509
509
  const { _sd_alg } = getSDAlgAndPayload(sdjwt.jwt.payload);
@@ -794,7 +794,7 @@ export class SDJwtGeneralJSONInstance<ExtendedPayload extends SdJwtPayload> {
794
794
 
795
795
  const encodedSDJwt = generalJSON.toEncoded(0);
796
796
  const sdjwt = await SDJwt.fromEncode(encodedSDJwt, hasher);
797
- if (!sdjwt.jwt || !sdjwt.jwt.payload) {
797
+ if (!sdjwt.jwt?.payload) {
798
798
  throw new SDJWTException('Invalid SD JWT');
799
799
  }
800
800
 
@@ -854,7 +854,7 @@ export class SDJwtGeneralJSONInstance<ExtendedPayload extends SdJwtPayload> {
854
854
  sdjwt: SDJwt,
855
855
  hasher: Hasher,
856
856
  ) {
857
- if (!sdjwt.jwt || !sdjwt.jwt.payload) {
857
+ if (!sdjwt.jwt?.payload) {
858
858
  throw new SDJWTException('Invalid SD JWT');
859
859
  }
860
860
  const { _sd_alg } = getSDAlgAndPayload(sdjwt.jwt.payload);
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "../../../tsconfig.test.json",
3
+ "include": ["./**/*.spec.ts"]
4
+ }