@sphereon/ssi-sdk.vc-status-list 0.34.1-feature.SSISDK.17.bitstring.sl.10 → 0.34.1-feature.SSISDK.17.bitstring.sl.11

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.cjs CHANGED
@@ -35,6 +35,7 @@ __export(index_exports, {
35
35
  StatusOAuth: () => StatusOAuth,
36
36
  checkStatusForCredential: () => checkStatusForCredential,
37
37
  checkStatusIndexFromStatusListCredential: () => checkStatusIndexFromStatusListCredential,
38
+ createCredentialStatusFromStatusList: () => createCredentialStatusFromStatusList,
38
39
  createNewStatusList: () => createNewStatusList,
39
40
  fetchStatusListCredential: () => fetchStatusListCredential,
40
41
  simpleCheckStatusFromStatusListUrl: () => simpleCheckStatusFromStatusListUrl,
@@ -257,13 +258,14 @@ var StatusList2021Implementation = class {
257
258
  encodedList,
258
259
  proofFormat
259
260
  }, context);
261
+ if (!("statusPurpose" in credentialSubject)) {
262
+ return Promise.reject(Error("statusPurpose is required in credentialSubject for StatusList2021"));
263
+ }
260
264
  return {
261
265
  statusListCredential: updatedCredential,
262
266
  encodedList,
263
267
  statusList2021: {
264
- ..."statusPurpose" in credentialSubject ? {
265
- statusPurpose: credentialSubject.statusPurpose
266
- } : {},
268
+ statusPurpose: credentialSubject.statusPurpose,
267
269
  indexingDirection: "rightToLeft"
268
270
  },
269
271
  length: statusList.length - 1,
@@ -328,10 +330,12 @@ var StatusList2021Implementation = class {
328
330
  const encodedList = getAssertedProperty("encodedList", credentialSubject);
329
331
  const proofFormat = import_ssi_types2.CredentialMapper.detectDocumentType(statusListPayload) === import_ssi_types2.DocumentFormat.JWT ? "jwt" : "lds";
330
332
  const statusPurpose = getAssertedProperty("statusPurpose", credentialSubject);
333
+ const indexingDirection = "rightToLeft";
331
334
  const list = await import_vc_status_list.StatusList.decode({
332
335
  encodedList
333
336
  });
334
337
  return {
338
+ // Base implementation fields
335
339
  id,
336
340
  encodedList,
337
341
  issuer,
@@ -340,18 +344,36 @@ var StatusList2021Implementation = class {
340
344
  length: list.length,
341
345
  statusListCredential: statusListPayload,
342
346
  statuslistContentType: this.buildContentType(proofFormat),
347
+ correlationId: args.correlationId,
348
+ driverType: args.driverType,
349
+ // Flattened StatusList2021-specific fields
350
+ indexingDirection,
351
+ statusPurpose,
352
+ // Legacy nested structure for backward compatibility
343
353
  statusList2021: {
344
- indexingDirection: "rightToLeft",
345
- statusPurpose
346
- },
347
- ...args.correlationId && {
348
- correlationId: args.correlationId
349
- },
350
- ...args.driverType && {
351
- driverType: args.driverType
354
+ indexingDirection,
355
+ statusPurpose,
356
+ // Optional fields from args
357
+ ...args.correlationId && {
358
+ correlationId: args.correlationId
359
+ },
360
+ ...args.driverType && {
361
+ driverType: args.driverType
362
+ }
352
363
  }
353
364
  };
354
365
  }
366
+ async createCredentialStatus(args) {
367
+ const { statusList, statusListIndex } = args;
368
+ const statusList2021 = statusList;
369
+ return {
370
+ id: `${statusList.id}#${statusListIndex}`,
371
+ type: "StatusList2021Entry",
372
+ statusPurpose: statusList2021.statusPurpose ?? "revocation",
373
+ statusListIndex: "" + statusListIndex,
374
+ statusListCredential: statusList.id
375
+ };
376
+ }
355
377
  async createVerifiableCredential(args, context) {
356
378
  const identifier = await context.agent.identifierManagedGet({
357
379
  identifier: typeof args.issuer === "string" ? args.issuer : args.issuer.id,
@@ -728,9 +750,6 @@ var OAuthStatusListImplementation = class {
728
750
  statuslistContentType: this.buildContentType(proofFormat)
729
751
  };
730
752
  }
731
- buildContentType(proofFormat) {
732
- return `application/statuslist+${proofFormat === "cbor" ? "cwt" : "jwt"}`;
733
- }
734
753
  async checkStatusIndex(args) {
735
754
  const { statusListCredential, statusListIndex } = args;
736
755
  if (typeof statusListCredential !== "string") {
@@ -749,7 +768,10 @@ var OAuthStatusListImplementation = class {
749
768
  const proofFormat = determineProofFormat(statusListPayload);
750
769
  const decoded = proofFormat === "jwt" ? decodeStatusListJWT(statusListPayload) : decodeStatusListCWT(statusListPayload);
751
770
  const { statusList, issuer, id, exp } = decoded;
771
+ const bitsPerStatus = statusList.getBitsPerStatus();
772
+ const expiresAt = exp ? new Date(exp * 1e3) : void 0;
752
773
  return {
774
+ // Base implementation fields
753
775
  id,
754
776
  encodedList: statusList.compressStatusList(),
755
777
  issuer,
@@ -758,12 +780,21 @@ var OAuthStatusListImplementation = class {
758
780
  length: statusList.statusList.length,
759
781
  statusListCredential: statusListPayload,
760
782
  statuslistContentType: this.buildContentType(proofFormat),
783
+ correlationId: args.correlationId,
784
+ driverType: args.driverType,
785
+ // Flattened OAuth-specific fields
786
+ bitsPerStatus,
787
+ ...expiresAt && {
788
+ expiresAt
789
+ },
790
+ // Legacy nested structure for backward compatibility
761
791
  oauthStatusList: {
762
- bitsPerStatus: statusList.getBitsPerStatus(),
763
- ...exp && {
764
- expiresAt: new Date(exp * 1e3)
792
+ bitsPerStatus,
793
+ ...expiresAt && {
794
+ expiresAt
765
795
  }
766
796
  },
797
+ // Optional fields from args
767
798
  ...args.correlationId && {
768
799
  correlationId: args.correlationId
769
800
  },
@@ -772,6 +803,21 @@ var OAuthStatusListImplementation = class {
772
803
  }
773
804
  };
774
805
  }
806
+ async createCredentialStatus(args) {
807
+ const { statusList, statusListIndex } = args;
808
+ const oauthStatusList = statusList;
809
+ return {
810
+ id: `${statusList.id}#${statusListIndex}`,
811
+ type: "OAuthStatusListEntry",
812
+ bitsPerStatus: oauthStatusList.bitsPerStatus,
813
+ statusListIndex: "" + statusListIndex,
814
+ statusListCredential: statusList.id,
815
+ expiresAt: oauthStatusList.expiresAt
816
+ };
817
+ }
818
+ buildContentType(proofFormat) {
819
+ return `application/statuslist+${proofFormat === "cbor" ? "cwt" : "jwt"}`;
820
+ }
775
821
  async createSignedStatusList(proofFormat, context, statusList, issuerString, id, expiresAt, keyRef) {
776
822
  switch (proofFormat) {
777
823
  case "jwt": {
@@ -981,6 +1027,7 @@ var BitstringStatusListImplementation = class {
981
1027
  const ttl = credSubject.ttl;
982
1028
  const statuslistLength = import_vc_bitstring_status_lists.BitstreamStatusList.getStatusListLength(encodedList, bitsPerStatus);
983
1029
  return {
1030
+ // Base implementation fields
984
1031
  id,
985
1032
  encodedList,
986
1033
  issuer,
@@ -989,13 +1036,35 @@ var BitstringStatusListImplementation = class {
989
1036
  length: statuslistLength,
990
1037
  statusListCredential: statusListPayload,
991
1038
  statuslistContentType: this.buildContentType(proofFormat),
1039
+ correlationId: args.correlationId,
1040
+ driverType: args.driverType,
1041
+ // Flattened Bitstring-specific fields
1042
+ statusPurpose,
1043
+ bitsPerStatus,
1044
+ ...validFrom && {
1045
+ validFrom
1046
+ },
1047
+ ...validUntil && {
1048
+ validUntil
1049
+ },
1050
+ ...ttl && {
1051
+ ttl
1052
+ },
1053
+ // Legacy nested structure for backward compatibility
992
1054
  bitstringStatusList: {
993
1055
  statusPurpose,
994
1056
  bitsPerStatus,
995
- validFrom,
996
- validUntil,
997
- ttl
1057
+ ...validFrom && {
1058
+ validFrom
1059
+ },
1060
+ ...validUntil && {
1061
+ validUntil
1062
+ },
1063
+ ...ttl && {
1064
+ ttl
1065
+ }
998
1066
  },
1067
+ // Optional fields from args
999
1068
  ...args.correlationId && {
1000
1069
  correlationId: args.correlationId
1001
1070
  },
@@ -1004,6 +1073,24 @@ var BitstringStatusListImplementation = class {
1004
1073
  }
1005
1074
  };
1006
1075
  }
1076
+ async createCredentialStatus(args) {
1077
+ const { statusList, statusListEntry, statusListIndex } = args;
1078
+ const isBitstringEntry = /* @__PURE__ */ __name((entry) => {
1079
+ return "statusPurpose" in entry;
1080
+ }, "isBitstringEntry");
1081
+ if (!isBitstringEntry(statusListEntry)) {
1082
+ throw new Error("Expected bitstring status list entry for bitstring status list");
1083
+ }
1084
+ const bitstringStatusList = statusList;
1085
+ return {
1086
+ id: `${statusList.id}#${statusListIndex}`,
1087
+ type: "BitstringStatusListEntry",
1088
+ statusPurpose: statusListEntry.statusPurpose,
1089
+ statusListIndex: "" + statusListIndex,
1090
+ statusListCredential: statusList.id,
1091
+ bitsPerStatus: bitstringStatusList.bitsPerStatus
1092
+ };
1093
+ }
1007
1094
  async createVerifiableCredential(args, context) {
1008
1095
  const identifier = await context.agent.identifierManagedGet({
1009
1096
  identifier: typeof args.issuer === "string" ? args.issuer : args.issuer.id,
@@ -1202,14 +1289,26 @@ async function statusListCredentialToDetails({ correlationId, driverType, status
1202
1289
  statusListType = type.replace("Credential", "");
1203
1290
  }
1204
1291
  const implementation = getStatusListImplementation(statusListType);
1205
- return await implementation.toStatusListDetails({
1292
+ const result = await implementation.toStatusListDetails({
1206
1293
  statusListPayload: credential,
1207
1294
  correlationId,
1208
1295
  driverType,
1209
1296
  bitsPerStatus
1210
1297
  });
1298
+ return result;
1211
1299
  }
1212
1300
  __name(statusListCredentialToDetails, "statusListCredentialToDetails");
1301
+ async function createCredentialStatusFromStatusList(args) {
1302
+ const { statusList, statusListEntry, statusListIndex } = args;
1303
+ const statusListType = determineStatusListType(statusList.statusListCredential);
1304
+ const implementation = getStatusListImplementation(statusListType);
1305
+ return implementation.createCredentialStatus({
1306
+ statusList,
1307
+ statusListEntry,
1308
+ statusListIndex
1309
+ });
1310
+ }
1311
+ __name(createCredentialStatusFromStatusList, "createCredentialStatusFromStatusList");
1213
1312
  async function updateStatusListIndexFromEncodedList(args, context) {
1214
1313
  const { type } = getAssertedValue("type", args);
1215
1314
  const implementation = getStatusListImplementation(type);