@learncard/helpers 1.2.17 → 1.3.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.
@@ -66,6 +66,8 @@ var require_types_cjs_development = __commonJS({
66
66
  AgeRatingValidator: /* @__PURE__ */ __name(() => AgeRatingValidator, "AgeRatingValidator"),
67
67
  AlignmentTargetTypeValidator: /* @__PURE__ */ __name(() => AlignmentTargetTypeValidator, "AlignmentTargetTypeValidator"),
68
68
  AlignmentValidator: /* @__PURE__ */ __name(() => AlignmentValidator, "AlignmentValidator"),
69
+ AllocateCredentialStatusInputValidator: /* @__PURE__ */ __name(() => AllocateCredentialStatusInputValidator, "AllocateCredentialStatusInputValidator"),
70
+ AllocatedBitstringStatusListEntryValidator: /* @__PURE__ */ __name(() => AllocatedBitstringStatusListEntryValidator, "AllocatedBitstringStatusListEntryValidator"),
69
71
  AllowConnectionRequestsEnum: /* @__PURE__ */ __name(() => AllowConnectionRequestsEnum, "AllowConnectionRequestsEnum"),
70
72
  AppBoostValidator: /* @__PURE__ */ __name(() => AppBoostValidator, "AppBoostValidator"),
71
73
  AppEventInputValidator: /* @__PURE__ */ __name(() => AppEventInputValidator, "AppEventInputValidator"),
@@ -83,6 +85,10 @@ var require_types_cjs_development = __commonJS({
83
85
  AuthGrantValidator: /* @__PURE__ */ __name(() => AuthGrantValidator, "AuthGrantValidator"),
84
86
  AuthSessionError: /* @__PURE__ */ __name(() => AuthSessionError, "AuthSessionError"),
85
87
  AutoBoostConfigValidator: /* @__PURE__ */ __name(() => AutoBoostConfigValidator, "AutoBoostConfigValidator"),
88
+ BITSTRING_STATUS_PURPOSES: /* @__PURE__ */ __name(() => BITSTRING_STATUS_PURPOSES, "BITSTRING_STATUS_PURPOSES"),
89
+ BitstringStatusListCredentialSubjectValidator: /* @__PURE__ */ __name(() => BitstringStatusListCredentialSubjectValidator, "BitstringStatusListCredentialSubjectValidator"),
90
+ BitstringStatusListEntryValidator: /* @__PURE__ */ __name(() => BitstringStatusListEntryValidator, "BitstringStatusListEntryValidator"),
91
+ BitstringStatusPurposeValidator: /* @__PURE__ */ __name(() => BitstringStatusPurposeValidator, "BitstringStatusPurposeValidator"),
86
92
  BoostPermissionsQueryValidator: /* @__PURE__ */ __name(() => BoostPermissionsQueryValidator, "BoostPermissionsQueryValidator"),
87
93
  BoostPermissionsValidator: /* @__PURE__ */ __name(() => BoostPermissionsValidator, "BoostPermissionsValidator"),
88
94
  BoostQueryValidator: /* @__PURE__ */ __name(() => BoostQueryValidator, "BoostQueryValidator"),
@@ -144,6 +150,7 @@ var require_types_cjs_development = __commonJS({
144
150
  CredentialStatusValidator: /* @__PURE__ */ __name(() => CredentialStatusValidator, "CredentialStatusValidator"),
145
151
  CredentialSubjectValidator: /* @__PURE__ */ __name(() => CredentialSubjectValidator, "CredentialSubjectValidator"),
146
152
  CriteriaValidator: /* @__PURE__ */ __name(() => CriteriaValidator, "CriteriaValidator"),
153
+ DEFAULT_BITSTRING_STATUS_LIST_SIZE: /* @__PURE__ */ __name(() => DEFAULT_BITSTRING_STATUS_LIST_SIZE, "DEFAULT_BITSTRING_STATUS_LIST_SIZE"),
147
154
  DeleteFrameworkInputValidator: /* @__PURE__ */ __name(() => DeleteFrameworkInputValidator, "DeleteFrameworkInputValidator"),
148
155
  DeleteSkillInputValidator: /* @__PURE__ */ __name(() => DeleteSkillInputValidator, "DeleteSkillInputValidator"),
149
156
  DidDocumentValidator: /* @__PURE__ */ __name(() => DidDocumentValidator, "DidDocumentValidator"),
@@ -243,6 +250,7 @@ var require_types_cjs_development = __commonJS({
243
250
  RefreshServiceValidator: /* @__PURE__ */ __name(() => RefreshServiceValidator, "RefreshServiceValidator"),
244
251
  RegExpValidator: /* @__PURE__ */ __name(() => RegExpValidator, "RegExpValidator"),
245
252
  RelatedValidator: /* @__PURE__ */ __name(() => RelatedValidator, "RelatedValidator"),
253
+ RenderMethodValidator: /* @__PURE__ */ __name(() => RenderMethodValidator, "RenderMethodValidator"),
246
254
  ReplaceSkillFrameworkSkillsInputValidator: /* @__PURE__ */ __name(() => ReplaceSkillFrameworkSkillsInputValidator, "ReplaceSkillFrameworkSkillsInputValidator"),
247
255
  ReplaceSkillFrameworkSkillsResultValidator: /* @__PURE__ */ __name(() => ReplaceSkillFrameworkSkillsResultValidator, "ReplaceSkillFrameworkSkillsResultValidator"),
248
256
  RequestLearnerContextEventValidator: /* @__PURE__ */ __name(() => RequestLearnerContextEventValidator, "RequestLearnerContextEventValidator"),
@@ -279,11 +287,13 @@ var require_types_cjs_development = __commonJS({
279
287
  SkillTreeNodeInputValidator: /* @__PURE__ */ __name(() => SkillTreeNodeInputValidator, "SkillTreeNodeInputValidator"),
280
288
  SkillTreeNodeValidator: /* @__PURE__ */ __name(() => SkillTreeNodeValidator, "SkillTreeNodeValidator"),
281
289
  SkillValidator: /* @__PURE__ */ __name(() => SkillValidator, "SkillValidator"),
290
+ StatusCheckEntryValidator: /* @__PURE__ */ __name(() => StatusCheckEntryValidator, "StatusCheckEntryValidator"),
282
291
  StringQuery: /* @__PURE__ */ __name(() => StringQuery, "StringQuery"),
283
292
  SummaryCredentialDataValidator: /* @__PURE__ */ __name(() => SummaryCredentialDataValidator, "SummaryCredentialDataValidator"),
284
293
  SummaryCredentialKeywordValidator: /* @__PURE__ */ __name(() => SummaryCredentialKeywordValidator, "SummaryCredentialKeywordValidator"),
285
294
  SyncFrameworkInputValidator: /* @__PURE__ */ __name(() => SyncFrameworkInputValidator, "SyncFrameworkInputValidator"),
286
295
  TagValidator: /* @__PURE__ */ __name(() => TagValidator, "TagValidator"),
296
+ TemplateRenderMethodValidator: /* @__PURE__ */ __name(() => TemplateRenderMethodValidator, "TemplateRenderMethodValidator"),
287
297
  TermsOfUseValidator: /* @__PURE__ */ __name(() => TermsOfUseValidator, "TermsOfUseValidator"),
288
298
  UnsignedAchievementCredentialValidator: /* @__PURE__ */ __name(() => UnsignedAchievementCredentialValidator, "UnsignedAchievementCredentialValidator"),
289
299
  UnsignedClrCredentialValidator: /* @__PURE__ */ __name(() => UnsignedClrCredentialValidator, "UnsignedClrCredentialValidator"),
@@ -13763,6 +13773,19 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
13763
13773
  genre: external_exports.string().optional(),
13764
13774
  audience: external_exports.string().optional()
13765
13775
  }).catchall(external_exports.any());
13776
+ var TemplateRenderMethodValidator = external_exports.object({
13777
+ type: external_exports.literal("TemplateRenderMethod"),
13778
+ renderSuite: external_exports.string(),
13779
+ template: external_exports.string(),
13780
+ renderProperty: external_exports.array(external_exports.string()).optional(),
13781
+ outputPreference: external_exports.object({
13782
+ mediaType: external_exports.string()
13783
+ }).optional()
13784
+ });
13785
+ var RenderMethodValidator = external_exports.union([
13786
+ TemplateRenderMethodValidator,
13787
+ external_exports.record(external_exports.string(), external_exports.any())
13788
+ ]);
13766
13789
  var UnsignedVCValidator = external_exports.object({
13767
13790
  "@context": ContextValidator,
13768
13791
  id: external_exports.string().optional(),
@@ -13786,7 +13809,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
13786
13809
  validUntil: external_exports.string().optional(),
13787
13810
  status: CredentialStatusValidator.or(CredentialStatusValidator.array()).optional(),
13788
13811
  termsOfUse: TermsOfUseValidator.or(TermsOfUseValidator.array()).optional(),
13789
- evidence: external_exports.union([VC2EvidenceValidator, external_exports.array(VC2EvidenceValidator)]).optional()
13812
+ evidence: external_exports.union([VC2EvidenceValidator, external_exports.array(VC2EvidenceValidator)]).optional(),
13813
+ renderMethod: external_exports.union([RenderMethodValidator, external_exports.array(RenderMethodValidator)]).optional()
13790
13814
  }).catchall(external_exports.any());
13791
13815
  var ProofValidator = external_exports.object({
13792
13816
  type: external_exports.string(),
@@ -14094,10 +14118,45 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14094
14118
  var ClrCredentialValidator = UnsignedClrCredentialValidator.extend({
14095
14119
  proof: ProofValidator.or(ProofValidator.array())
14096
14120
  });
14121
+ var StatusCheckEntryValidator = external_exports.object({
14122
+ /**
14123
+ * The `credentialStatus.type` as it appeared on the credential.
14124
+ * One of `BitstringStatusListEntry`, `StatusList2021Entry`,
14125
+ * `RevocationList2020Status`, or any future custom status type.
14126
+ */
14127
+ entryType: external_exports.string(),
14128
+ /**
14129
+ * The claimed purpose of the entry. Standard values are
14130
+ * `"revocation"` and `"suspension"`; the spec allows arbitrary
14131
+ * strings.
14132
+ */
14133
+ statusPurpose: external_exports.string(),
14134
+ /**
14135
+ * Whether the bit at the credential's index in the status list
14136
+ * bitstring was set.
14137
+ */
14138
+ isSet: external_exports.boolean(),
14139
+ /** URL of the status list credential, when known. */
14140
+ statusListCredential: external_exports.string().optional(),
14141
+ /** Original (string) index within the status list. */
14142
+ statusListIndex: external_exports.string().optional()
14143
+ });
14097
14144
  var VerificationCheckValidator = external_exports.object({
14098
14145
  checks: external_exports.string().array(),
14099
14146
  warnings: external_exports.string().array(),
14100
- errors: external_exports.string().array()
14147
+ errors: external_exports.string().array(),
14148
+ /**
14149
+ * Per-entry results for the `credentialStatus` check, populated
14150
+ * by `@learncard/didkit-plugin` when the verified credential
14151
+ * carries one or more `credentialStatus` entries. Empty / absent
14152
+ * for credentials without a status entry.
14153
+ *
14154
+ * Marked `.optional()` because the underlying `ssi-ldp`
14155
+ * serializer omits the field when empty (`skip_serializing_if`),
14156
+ * so older WASM builds that pre-date the structured-status
14157
+ * change still validate against this schema.
14158
+ */
14159
+ status: StatusCheckEntryValidator.array().optional()
14101
14160
  });
14102
14161
  var VerificationStatusValidator = external_exports.enum(["Success", "Failed", "Error"]);
14103
14162
  var VerificationStatusEnum = VerificationStatusValidator.enum;
@@ -15505,6 +15564,29 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15505
15564
  __name2(this, "AuthSessionError");
15506
15565
  }
15507
15566
  };
15567
+ var BITSTRING_STATUS_PURPOSES = ["revocation", "suspension"];
15568
+ var DEFAULT_BITSTRING_STATUS_LIST_SIZE = 131072;
15569
+ var BitstringStatusPurposeValidator = external_exports.enum(BITSTRING_STATUS_PURPOSES);
15570
+ var BitstringStatusListEntryValidator = external_exports.object({
15571
+ id: external_exports.string().optional(),
15572
+ type: external_exports.literal("BitstringStatusListEntry"),
15573
+ statusPurpose: BitstringStatusPurposeValidator,
15574
+ statusListIndex: external_exports.string(),
15575
+ statusListCredential: external_exports.string()
15576
+ });
15577
+ var AllocatedBitstringStatusListEntryValidator = BitstringStatusListEntryValidator.extend({
15578
+ id: external_exports.string()
15579
+ });
15580
+ var BitstringStatusListCredentialSubjectValidator = external_exports.object({
15581
+ id: external_exports.string().optional(),
15582
+ type: external_exports.literal("BitstringStatusList"),
15583
+ statusPurpose: BitstringStatusPurposeValidator,
15584
+ encodedList: external_exports.string()
15585
+ });
15586
+ var AllocateCredentialStatusInputValidator = external_exports.object({
15587
+ statusPurposes: external_exports.array(BitstringStatusPurposeValidator).optional(),
15588
+ listSize: external_exports.number().int().positive().optional()
15589
+ }).default({});
15508
15590
  }
15509
15591
  });
15510
15592
 
@@ -15544,6 +15626,10 @@ __export(index_exports, {
15544
15626
  fixUrl: () => fixUrl4,
15545
15627
  formatNumber: () => formatNumber,
15546
15628
  generateSrcSet: () => generateSrcSet4,
15629
+ getBitstringStatusListBit: () => getBitstringStatusListBit,
15630
+ getBitstringStatusListEntries: () => getBitstringStatusListEntries,
15631
+ getBitstringStatusListEntryForPurpose: () => getBitstringStatusListEntryForPurpose,
15632
+ getCredentialStatusArray: () => getCredentialStatusArray,
15547
15633
  getProvider: () => getProvider,
15548
15634
  getUrlsFromSrcSet: () => getUrlsFromSrcSet,
15549
15635
  immerArraySlice: () => immerArraySlice,
@@ -15552,6 +15638,7 @@ __export(index_exports, {
15552
15638
  innerReactOuterImmer: () => innerReactOuterImmer,
15553
15639
  innerReactOuterReact: () => innerReactOuterReact,
15554
15640
  isAppDidWeb: () => isAppDidWeb,
15641
+ isBitstringStatusListEntry: () => isBitstringStatusListEntry,
15555
15642
  isEncrypted: () => isEncrypted,
15556
15643
  isHex: () => isHex,
15557
15644
  isNotMaybe: () => isNotMaybe,
@@ -15559,6 +15646,7 @@ __export(index_exports, {
15559
15646
  isVC2Format: () => isVC2Format,
15560
15647
  quantizeValue: () => quantizeValue,
15561
15648
  resizeAndChangeQuality: () => resizeAndChangeQuality4,
15649
+ setBitstringStatusListBit: () => setBitstringStatusListBit,
15562
15650
  unwrapBoostCredential: () => unwrapBoostCredential
15563
15651
  });
15564
15652
  module.exports = __toCommonJS(index_exports);
@@ -16362,6 +16450,45 @@ var immerArraySlice = /* @__PURE__ */ __name(((setState, index, value) => {
16362
16450
  return updateSlice(index, value);
16363
16451
  }), "immerArraySlice");
16364
16452
 
16453
+ // src/bitstring-status-list/index.ts
16454
+ var getCredentialStatusArray = /* @__PURE__ */ __name((credential) => {
16455
+ if (!credential || typeof credential !== "object" || Array.isArray(credential)) return [];
16456
+ const status = credential.credentialStatus;
16457
+ if (!status) return [];
16458
+ return Array.isArray(status) ? status : [status];
16459
+ }, "getCredentialStatusArray");
16460
+ var isBitstringStatusListEntry = /* @__PURE__ */ __name((status) => {
16461
+ if (!status || typeof status !== "object") return false;
16462
+ const record = status;
16463
+ return record.type === "BitstringStatusListEntry" && (record.statusPurpose === "revocation" || record.statusPurpose === "suspension") && typeof record.statusListIndex === "string" && typeof record.statusListCredential === "string";
16464
+ }, "isBitstringStatusListEntry");
16465
+ var getBitstringStatusListEntries = /* @__PURE__ */ __name((credential) => {
16466
+ if (!credential || typeof credential !== "object" || Array.isArray(credential)) return [];
16467
+ const record = credential;
16468
+ const statuses = getCredentialStatusArray(record);
16469
+ return [
16470
+ ...statuses.filter(isBitstringStatusListEntry),
16471
+ ...getBitstringStatusListEntries(record.boostCredential)
16472
+ ];
16473
+ }, "getBitstringStatusListEntries");
16474
+ var getBitstringStatusListEntryForPurpose = /* @__PURE__ */ __name((credential, statusPurpose) => getBitstringStatusListEntries(credential).find((entry) => entry.statusPurpose === statusPurpose), "getBitstringStatusListEntryForPurpose");
16475
+ var getBitstringStatusListBit = /* @__PURE__ */ __name((bitstring, index) => {
16476
+ if (!Number.isInteger(index) || index < 0) {
16477
+ throw new Error("Bitstring status list index is out of range");
16478
+ }
16479
+ const byte = bitstring[Math.floor(index / 8)] ?? 0;
16480
+ return (byte & 1 << index % 8) !== 0;
16481
+ }, "getBitstringStatusListBit");
16482
+ var setBitstringStatusListBit = /* @__PURE__ */ __name((bitstring, index, value) => {
16483
+ if (!Number.isInteger(index) || index < 0 || index >= bitstring.length * 8) {
16484
+ throw new Error("Bitstring status list index is out of range");
16485
+ }
16486
+ const byteIndex = Math.floor(index / 8);
16487
+ const mask = 1 << index % 8;
16488
+ const current = bitstring[byteIndex] ?? 0;
16489
+ bitstring[byteIndex] = value ? current | mask : current & ~mask;
16490
+ }, "setBitstringStatusListBit");
16491
+
16365
16492
  // src/Utilities.ts
16366
16493
  var import_zod = require("zod");
16367
16494
  var ImageResizingValidator = import_zod.z.object({ type: import_zod.z.literal("resizing") });