@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.
package/dist/helpers.d.ts CHANGED
@@ -181,6 +181,32 @@ declare const UnsignedVCValidator: z.ZodObject<{
181
181
  audience: z.ZodOptional<z.ZodString>;
182
182
  }, z.core.$catchall<z.ZodAny>>>
183
183
  ]>>;
184
+ renderMethod: z.ZodOptional<z.ZodUnion<readonly [
185
+ z.ZodUnion<readonly [
186
+ z.ZodObject<{
187
+ type: z.ZodLiteral<"TemplateRenderMethod">;
188
+ renderSuite: z.ZodString;
189
+ template: z.ZodString;
190
+ renderProperty: z.ZodOptional<z.ZodArray<z.ZodString>>;
191
+ outputPreference: z.ZodOptional<z.ZodObject<{
192
+ mediaType: z.ZodString;
193
+ }, z.core.$strip>>;
194
+ }, z.core.$strip>,
195
+ z.ZodRecord<z.ZodString, z.ZodAny>
196
+ ]>,
197
+ z.ZodArray<z.ZodUnion<readonly [
198
+ z.ZodObject<{
199
+ type: z.ZodLiteral<"TemplateRenderMethod">;
200
+ renderSuite: z.ZodString;
201
+ template: z.ZodString;
202
+ renderProperty: z.ZodOptional<z.ZodArray<z.ZodString>>;
203
+ outputPreference: z.ZodOptional<z.ZodObject<{
204
+ mediaType: z.ZodString;
205
+ }, z.core.$strip>>;
206
+ }, z.core.$strip>,
207
+ z.ZodRecord<z.ZodString, z.ZodAny>
208
+ ]>>
209
+ ]>>;
184
210
  }, z.core.$catchall<z.ZodAny>>;
185
211
  export type UnsignedVC = z.infer<typeof UnsignedVCValidator>;
186
212
  declare const VCValidator: z.ZodObject<{
@@ -359,6 +385,32 @@ declare const VCValidator: z.ZodObject<{
359
385
  audience: z.ZodOptional<z.ZodString>;
360
386
  }, z.core.$catchall<z.ZodAny>>>
361
387
  ]>>;
388
+ renderMethod: z.ZodOptional<z.ZodUnion<readonly [
389
+ z.ZodUnion<readonly [
390
+ z.ZodObject<{
391
+ type: z.ZodLiteral<"TemplateRenderMethod">;
392
+ renderSuite: z.ZodString;
393
+ template: z.ZodString;
394
+ renderProperty: z.ZodOptional<z.ZodArray<z.ZodString>>;
395
+ outputPreference: z.ZodOptional<z.ZodObject<{
396
+ mediaType: z.ZodString;
397
+ }, z.core.$strip>>;
398
+ }, z.core.$strip>,
399
+ z.ZodRecord<z.ZodString, z.ZodAny>
400
+ ]>,
401
+ z.ZodArray<z.ZodUnion<readonly [
402
+ z.ZodObject<{
403
+ type: z.ZodLiteral<"TemplateRenderMethod">;
404
+ renderSuite: z.ZodString;
405
+ template: z.ZodString;
406
+ renderProperty: z.ZodOptional<z.ZodArray<z.ZodString>>;
407
+ outputPreference: z.ZodOptional<z.ZodObject<{
408
+ mediaType: z.ZodString;
409
+ }, z.core.$strip>>;
410
+ }, z.core.$strip>,
411
+ z.ZodRecord<z.ZodString, z.ZodAny>
412
+ ]>>
413
+ ]>>;
362
414
  proof: z.ZodUnion<[
363
415
  z.ZodObject<{
364
416
  type: z.ZodString;
@@ -410,6 +462,22 @@ declare const JWEValidator: z.ZodObject<{
410
462
  }, z.core.$strip>>>;
411
463
  }, z.core.$strip>;
412
464
  export type JWE = z.infer<typeof JWEValidator>;
465
+ declare const BitstringStatusPurposeValidator: z.ZodEnum<{
466
+ revocation: "revocation";
467
+ suspension: "suspension";
468
+ }>;
469
+ export type BitstringStatusPurpose = z.infer<typeof BitstringStatusPurposeValidator>;
470
+ declare const BitstringStatusListEntryValidator: z.ZodObject<{
471
+ id: z.ZodOptional<z.ZodString>;
472
+ type: z.ZodLiteral<"BitstringStatusListEntry">;
473
+ statusPurpose: z.ZodEnum<{
474
+ revocation: "revocation";
475
+ suspension: "suspension";
476
+ }>;
477
+ statusListIndex: z.ZodString;
478
+ statusListCredential: z.ZodString;
479
+ }, z.core.$strip>;
480
+ export type BitstringStatusListEntry = z.infer<typeof BitstringStatusListEntryValidator>;
413
481
  declare const Providers: {
414
482
  filestack: typeof filestack;
415
483
  unsplash: typeof unsplash;
@@ -574,6 +642,12 @@ export type ImmerArraySlice = {
574
642
  <State>(setState: Updater<State[]>, index: number, value: State): void;
575
643
  };
576
644
  export declare const immerArraySlice: ImmerArraySlice;
645
+ export declare const getCredentialStatusArray: (credential: unknown) => Record<string, unknown>[];
646
+ export declare const isBitstringStatusListEntry: (status: unknown) => status is BitstringStatusListEntry;
647
+ export declare const getBitstringStatusListEntries: (credential: unknown) => BitstringStatusListEntry[];
648
+ export declare const getBitstringStatusListEntryForPurpose: (credential: unknown, statusPurpose: BitstringStatusPurpose) => BitstringStatusListEntry | undefined;
649
+ export declare const getBitstringStatusListBit: (bitstring: Uint8Array, index: number) => boolean;
650
+ export declare const setBitstringStatusListBit: (bitstring: Uint8Array, index: number, value: boolean) => void;
577
651
  export declare const ImageResizingValidator: z.ZodObject<{
578
652
  type: z.ZodLiteral<"resizing">;
579
653
  }, z.core.$strip>;
@@ -64,6 +64,8 @@ var require_types_cjs_development = __commonJS({
64
64
  AgeRatingValidator: /* @__PURE__ */ __name(() => AgeRatingValidator, "AgeRatingValidator"),
65
65
  AlignmentTargetTypeValidator: /* @__PURE__ */ __name(() => AlignmentTargetTypeValidator, "AlignmentTargetTypeValidator"),
66
66
  AlignmentValidator: /* @__PURE__ */ __name(() => AlignmentValidator, "AlignmentValidator"),
67
+ AllocateCredentialStatusInputValidator: /* @__PURE__ */ __name(() => AllocateCredentialStatusInputValidator, "AllocateCredentialStatusInputValidator"),
68
+ AllocatedBitstringStatusListEntryValidator: /* @__PURE__ */ __name(() => AllocatedBitstringStatusListEntryValidator, "AllocatedBitstringStatusListEntryValidator"),
67
69
  AllowConnectionRequestsEnum: /* @__PURE__ */ __name(() => AllowConnectionRequestsEnum, "AllowConnectionRequestsEnum"),
68
70
  AppBoostValidator: /* @__PURE__ */ __name(() => AppBoostValidator, "AppBoostValidator"),
69
71
  AppEventInputValidator: /* @__PURE__ */ __name(() => AppEventInputValidator, "AppEventInputValidator"),
@@ -81,6 +83,10 @@ var require_types_cjs_development = __commonJS({
81
83
  AuthGrantValidator: /* @__PURE__ */ __name(() => AuthGrantValidator, "AuthGrantValidator"),
82
84
  AuthSessionError: /* @__PURE__ */ __name(() => AuthSessionError, "AuthSessionError"),
83
85
  AutoBoostConfigValidator: /* @__PURE__ */ __name(() => AutoBoostConfigValidator, "AutoBoostConfigValidator"),
86
+ BITSTRING_STATUS_PURPOSES: /* @__PURE__ */ __name(() => BITSTRING_STATUS_PURPOSES, "BITSTRING_STATUS_PURPOSES"),
87
+ BitstringStatusListCredentialSubjectValidator: /* @__PURE__ */ __name(() => BitstringStatusListCredentialSubjectValidator, "BitstringStatusListCredentialSubjectValidator"),
88
+ BitstringStatusListEntryValidator: /* @__PURE__ */ __name(() => BitstringStatusListEntryValidator, "BitstringStatusListEntryValidator"),
89
+ BitstringStatusPurposeValidator: /* @__PURE__ */ __name(() => BitstringStatusPurposeValidator, "BitstringStatusPurposeValidator"),
84
90
  BoostPermissionsQueryValidator: /* @__PURE__ */ __name(() => BoostPermissionsQueryValidator, "BoostPermissionsQueryValidator"),
85
91
  BoostPermissionsValidator: /* @__PURE__ */ __name(() => BoostPermissionsValidator, "BoostPermissionsValidator"),
86
92
  BoostQueryValidator: /* @__PURE__ */ __name(() => BoostQueryValidator, "BoostQueryValidator"),
@@ -142,6 +148,7 @@ var require_types_cjs_development = __commonJS({
142
148
  CredentialStatusValidator: /* @__PURE__ */ __name(() => CredentialStatusValidator, "CredentialStatusValidator"),
143
149
  CredentialSubjectValidator: /* @__PURE__ */ __name(() => CredentialSubjectValidator, "CredentialSubjectValidator"),
144
150
  CriteriaValidator: /* @__PURE__ */ __name(() => CriteriaValidator, "CriteriaValidator"),
151
+ DEFAULT_BITSTRING_STATUS_LIST_SIZE: /* @__PURE__ */ __name(() => DEFAULT_BITSTRING_STATUS_LIST_SIZE, "DEFAULT_BITSTRING_STATUS_LIST_SIZE"),
145
152
  DeleteFrameworkInputValidator: /* @__PURE__ */ __name(() => DeleteFrameworkInputValidator, "DeleteFrameworkInputValidator"),
146
153
  DeleteSkillInputValidator: /* @__PURE__ */ __name(() => DeleteSkillInputValidator, "DeleteSkillInputValidator"),
147
154
  DidDocumentValidator: /* @__PURE__ */ __name(() => DidDocumentValidator, "DidDocumentValidator"),
@@ -241,6 +248,7 @@ var require_types_cjs_development = __commonJS({
241
248
  RefreshServiceValidator: /* @__PURE__ */ __name(() => RefreshServiceValidator, "RefreshServiceValidator"),
242
249
  RegExpValidator: /* @__PURE__ */ __name(() => RegExpValidator, "RegExpValidator"),
243
250
  RelatedValidator: /* @__PURE__ */ __name(() => RelatedValidator, "RelatedValidator"),
251
+ RenderMethodValidator: /* @__PURE__ */ __name(() => RenderMethodValidator, "RenderMethodValidator"),
244
252
  ReplaceSkillFrameworkSkillsInputValidator: /* @__PURE__ */ __name(() => ReplaceSkillFrameworkSkillsInputValidator, "ReplaceSkillFrameworkSkillsInputValidator"),
245
253
  ReplaceSkillFrameworkSkillsResultValidator: /* @__PURE__ */ __name(() => ReplaceSkillFrameworkSkillsResultValidator, "ReplaceSkillFrameworkSkillsResultValidator"),
246
254
  RequestLearnerContextEventValidator: /* @__PURE__ */ __name(() => RequestLearnerContextEventValidator, "RequestLearnerContextEventValidator"),
@@ -277,11 +285,13 @@ var require_types_cjs_development = __commonJS({
277
285
  SkillTreeNodeInputValidator: /* @__PURE__ */ __name(() => SkillTreeNodeInputValidator, "SkillTreeNodeInputValidator"),
278
286
  SkillTreeNodeValidator: /* @__PURE__ */ __name(() => SkillTreeNodeValidator, "SkillTreeNodeValidator"),
279
287
  SkillValidator: /* @__PURE__ */ __name(() => SkillValidator, "SkillValidator"),
288
+ StatusCheckEntryValidator: /* @__PURE__ */ __name(() => StatusCheckEntryValidator, "StatusCheckEntryValidator"),
280
289
  StringQuery: /* @__PURE__ */ __name(() => StringQuery, "StringQuery"),
281
290
  SummaryCredentialDataValidator: /* @__PURE__ */ __name(() => SummaryCredentialDataValidator, "SummaryCredentialDataValidator"),
282
291
  SummaryCredentialKeywordValidator: /* @__PURE__ */ __name(() => SummaryCredentialKeywordValidator, "SummaryCredentialKeywordValidator"),
283
292
  SyncFrameworkInputValidator: /* @__PURE__ */ __name(() => SyncFrameworkInputValidator, "SyncFrameworkInputValidator"),
284
293
  TagValidator: /* @__PURE__ */ __name(() => TagValidator, "TagValidator"),
294
+ TemplateRenderMethodValidator: /* @__PURE__ */ __name(() => TemplateRenderMethodValidator, "TemplateRenderMethodValidator"),
285
295
  TermsOfUseValidator: /* @__PURE__ */ __name(() => TermsOfUseValidator, "TermsOfUseValidator"),
286
296
  UnsignedAchievementCredentialValidator: /* @__PURE__ */ __name(() => UnsignedAchievementCredentialValidator, "UnsignedAchievementCredentialValidator"),
287
297
  UnsignedClrCredentialValidator: /* @__PURE__ */ __name(() => UnsignedClrCredentialValidator, "UnsignedClrCredentialValidator"),
@@ -13761,6 +13771,19 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
13761
13771
  genre: external_exports.string().optional(),
13762
13772
  audience: external_exports.string().optional()
13763
13773
  }).catchall(external_exports.any());
13774
+ var TemplateRenderMethodValidator = external_exports.object({
13775
+ type: external_exports.literal("TemplateRenderMethod"),
13776
+ renderSuite: external_exports.string(),
13777
+ template: external_exports.string(),
13778
+ renderProperty: external_exports.array(external_exports.string()).optional(),
13779
+ outputPreference: external_exports.object({
13780
+ mediaType: external_exports.string()
13781
+ }).optional()
13782
+ });
13783
+ var RenderMethodValidator = external_exports.union([
13784
+ TemplateRenderMethodValidator,
13785
+ external_exports.record(external_exports.string(), external_exports.any())
13786
+ ]);
13764
13787
  var UnsignedVCValidator = external_exports.object({
13765
13788
  "@context": ContextValidator,
13766
13789
  id: external_exports.string().optional(),
@@ -13784,7 +13807,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
13784
13807
  validUntil: external_exports.string().optional(),
13785
13808
  status: CredentialStatusValidator.or(CredentialStatusValidator.array()).optional(),
13786
13809
  termsOfUse: TermsOfUseValidator.or(TermsOfUseValidator.array()).optional(),
13787
- evidence: external_exports.union([VC2EvidenceValidator, external_exports.array(VC2EvidenceValidator)]).optional()
13810
+ evidence: external_exports.union([VC2EvidenceValidator, external_exports.array(VC2EvidenceValidator)]).optional(),
13811
+ renderMethod: external_exports.union([RenderMethodValidator, external_exports.array(RenderMethodValidator)]).optional()
13788
13812
  }).catchall(external_exports.any());
13789
13813
  var ProofValidator = external_exports.object({
13790
13814
  type: external_exports.string(),
@@ -14092,10 +14116,45 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14092
14116
  var ClrCredentialValidator = UnsignedClrCredentialValidator.extend({
14093
14117
  proof: ProofValidator.or(ProofValidator.array())
14094
14118
  });
14119
+ var StatusCheckEntryValidator = external_exports.object({
14120
+ /**
14121
+ * The `credentialStatus.type` as it appeared on the credential.
14122
+ * One of `BitstringStatusListEntry`, `StatusList2021Entry`,
14123
+ * `RevocationList2020Status`, or any future custom status type.
14124
+ */
14125
+ entryType: external_exports.string(),
14126
+ /**
14127
+ * The claimed purpose of the entry. Standard values are
14128
+ * `"revocation"` and `"suspension"`; the spec allows arbitrary
14129
+ * strings.
14130
+ */
14131
+ statusPurpose: external_exports.string(),
14132
+ /**
14133
+ * Whether the bit at the credential's index in the status list
14134
+ * bitstring was set.
14135
+ */
14136
+ isSet: external_exports.boolean(),
14137
+ /** URL of the status list credential, when known. */
14138
+ statusListCredential: external_exports.string().optional(),
14139
+ /** Original (string) index within the status list. */
14140
+ statusListIndex: external_exports.string().optional()
14141
+ });
14095
14142
  var VerificationCheckValidator = external_exports.object({
14096
14143
  checks: external_exports.string().array(),
14097
14144
  warnings: external_exports.string().array(),
14098
- errors: external_exports.string().array()
14145
+ errors: external_exports.string().array(),
14146
+ /**
14147
+ * Per-entry results for the `credentialStatus` check, populated
14148
+ * by `@learncard/didkit-plugin` when the verified credential
14149
+ * carries one or more `credentialStatus` entries. Empty / absent
14150
+ * for credentials without a status entry.
14151
+ *
14152
+ * Marked `.optional()` because the underlying `ssi-ldp`
14153
+ * serializer omits the field when empty (`skip_serializing_if`),
14154
+ * so older WASM builds that pre-date the structured-status
14155
+ * change still validate against this schema.
14156
+ */
14157
+ status: StatusCheckEntryValidator.array().optional()
14099
14158
  });
14100
14159
  var VerificationStatusValidator = external_exports.enum(["Success", "Failed", "Error"]);
14101
14160
  var VerificationStatusEnum = VerificationStatusValidator.enum;
@@ -15503,6 +15562,29 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15503
15562
  __name2(this, "AuthSessionError");
15504
15563
  }
15505
15564
  };
15565
+ var BITSTRING_STATUS_PURPOSES = ["revocation", "suspension"];
15566
+ var DEFAULT_BITSTRING_STATUS_LIST_SIZE = 131072;
15567
+ var BitstringStatusPurposeValidator = external_exports.enum(BITSTRING_STATUS_PURPOSES);
15568
+ var BitstringStatusListEntryValidator = external_exports.object({
15569
+ id: external_exports.string().optional(),
15570
+ type: external_exports.literal("BitstringStatusListEntry"),
15571
+ statusPurpose: BitstringStatusPurposeValidator,
15572
+ statusListIndex: external_exports.string(),
15573
+ statusListCredential: external_exports.string()
15574
+ });
15575
+ var AllocatedBitstringStatusListEntryValidator = BitstringStatusListEntryValidator.extend({
15576
+ id: external_exports.string()
15577
+ });
15578
+ var BitstringStatusListCredentialSubjectValidator = external_exports.object({
15579
+ id: external_exports.string().optional(),
15580
+ type: external_exports.literal("BitstringStatusList"),
15581
+ statusPurpose: BitstringStatusPurposeValidator,
15582
+ encodedList: external_exports.string()
15583
+ });
15584
+ var AllocateCredentialStatusInputValidator = external_exports.object({
15585
+ statusPurposes: external_exports.array(BitstringStatusPurposeValidator).optional(),
15586
+ listSize: external_exports.number().int().positive().optional()
15587
+ }).default({});
15506
15588
  }
15507
15589
  });
15508
15590
 
@@ -16319,6 +16401,45 @@ var immerArraySlice = /* @__PURE__ */ __name(((setState, index, value) => {
16319
16401
  return updateSlice(index, value);
16320
16402
  }), "immerArraySlice");
16321
16403
 
16404
+ // src/bitstring-status-list/index.ts
16405
+ var getCredentialStatusArray = /* @__PURE__ */ __name((credential) => {
16406
+ if (!credential || typeof credential !== "object" || Array.isArray(credential)) return [];
16407
+ const status = credential.credentialStatus;
16408
+ if (!status) return [];
16409
+ return Array.isArray(status) ? status : [status];
16410
+ }, "getCredentialStatusArray");
16411
+ var isBitstringStatusListEntry = /* @__PURE__ */ __name((status) => {
16412
+ if (!status || typeof status !== "object") return false;
16413
+ const record = status;
16414
+ return record.type === "BitstringStatusListEntry" && (record.statusPurpose === "revocation" || record.statusPurpose === "suspension") && typeof record.statusListIndex === "string" && typeof record.statusListCredential === "string";
16415
+ }, "isBitstringStatusListEntry");
16416
+ var getBitstringStatusListEntries = /* @__PURE__ */ __name((credential) => {
16417
+ if (!credential || typeof credential !== "object" || Array.isArray(credential)) return [];
16418
+ const record = credential;
16419
+ const statuses = getCredentialStatusArray(record);
16420
+ return [
16421
+ ...statuses.filter(isBitstringStatusListEntry),
16422
+ ...getBitstringStatusListEntries(record.boostCredential)
16423
+ ];
16424
+ }, "getBitstringStatusListEntries");
16425
+ var getBitstringStatusListEntryForPurpose = /* @__PURE__ */ __name((credential, statusPurpose) => getBitstringStatusListEntries(credential).find((entry) => entry.statusPurpose === statusPurpose), "getBitstringStatusListEntryForPurpose");
16426
+ var getBitstringStatusListBit = /* @__PURE__ */ __name((bitstring, index) => {
16427
+ if (!Number.isInteger(index) || index < 0) {
16428
+ throw new Error("Bitstring status list index is out of range");
16429
+ }
16430
+ const byte = bitstring[Math.floor(index / 8)] ?? 0;
16431
+ return (byte & 1 << index % 8) !== 0;
16432
+ }, "getBitstringStatusListBit");
16433
+ var setBitstringStatusListBit = /* @__PURE__ */ __name((bitstring, index, value) => {
16434
+ if (!Number.isInteger(index) || index < 0 || index >= bitstring.length * 8) {
16435
+ throw new Error("Bitstring status list index is out of range");
16436
+ }
16437
+ const byteIndex = Math.floor(index / 8);
16438
+ const mask = 1 << index % 8;
16439
+ const current = bitstring[byteIndex] ?? 0;
16440
+ bitstring[byteIndex] = value ? current | mask : current & ~mask;
16441
+ }, "setBitstringStatusListBit");
16442
+
16322
16443
  // src/Utilities.ts
16323
16444
  import { z } from "zod";
16324
16445
  var ImageResizingValidator = z.object({ type: z.literal("resizing") });
@@ -16487,6 +16608,10 @@ export {
16487
16608
  fixUrl4 as fixUrl,
16488
16609
  formatNumber,
16489
16610
  generateSrcSet4 as generateSrcSet,
16611
+ getBitstringStatusListBit,
16612
+ getBitstringStatusListEntries,
16613
+ getBitstringStatusListEntryForPurpose,
16614
+ getCredentialStatusArray,
16490
16615
  getProvider,
16491
16616
  getUrlsFromSrcSet,
16492
16617
  immerArraySlice,
@@ -16495,6 +16620,7 @@ export {
16495
16620
  innerReactOuterImmer,
16496
16621
  innerReactOuterReact,
16497
16622
  isAppDidWeb,
16623
+ isBitstringStatusListEntry,
16498
16624
  isEncrypted,
16499
16625
  isHex,
16500
16626
  isNotMaybe,
@@ -16502,5 +16628,6 @@ export {
16502
16628
  isVC2Format,
16503
16629
  quantizeValue,
16504
16630
  resizeAndChangeQuality4 as resizeAndChangeQuality,
16631
+ setBitstringStatusListBit,
16505
16632
  unwrapBoostCredential
16506
16633
  };