@learncard/helpers 1.3.0 → 1.3.2
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.cjs.development.js +152 -6
- package/dist/helpers.cjs.development.js.map +4 -4
- package/dist/helpers.cjs.production.min.js +5 -5
- package/dist/helpers.cjs.production.min.js.map +4 -4
- package/dist/helpers.d.ts +153 -0
- package/dist/helpers.esm.js +152 -6
- package/dist/helpers.esm.js.map +4 -4
- package/package.json +2 -2
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;
|
|
@@ -383,6 +435,81 @@ declare const VCValidator: z.ZodObject<{
|
|
|
383
435
|
]>;
|
|
384
436
|
}, z.core.$catchall<z.ZodAny>>;
|
|
385
437
|
export type VC = z.infer<typeof VCValidator>;
|
|
438
|
+
declare const CredentialFormatValidator: z.ZodEnum<{
|
|
439
|
+
"w3c-vc-2.0": "w3c-vc-2.0";
|
|
440
|
+
"w3c-vc-1.1": "w3c-vc-1.1";
|
|
441
|
+
"jwt-vc-json": "jwt-vc-json";
|
|
442
|
+
"dc+sd-jwt": "dc+sd-jwt";
|
|
443
|
+
"vc+sd-jwt": "vc+sd-jwt";
|
|
444
|
+
mso_mdoc: "mso_mdoc";
|
|
445
|
+
}>;
|
|
446
|
+
export type CredentialFormat = z.infer<typeof CredentialFormatValidator>;
|
|
447
|
+
/**
|
|
448
|
+
* Format-discriminated read view over a stored credential. Returned
|
|
449
|
+
* by `toStoredCredential(record)` in `@learncard/helpers`.
|
|
450
|
+
*
|
|
451
|
+
* The `data` field carries the correct wire-form representation for
|
|
452
|
+
* the credential's format:
|
|
453
|
+
* - W3C VCs: the JSON-LD VC object (also what `record.vc` holds)
|
|
454
|
+
* - JWT-VC: the compact JWS string (extracted from `record.vc.proof.jwt`
|
|
455
|
+
* if the record uses the legacy LDP-around-JWT envelope, otherwise
|
|
456
|
+
* the raw string from `record.rawWireForm`)
|
|
457
|
+
* - SD-JWT-VC: the compact `<JWT>~<disclosures>~` string
|
|
458
|
+
* - mDoc: base64url-encoded CBOR bytes (stored as a string for
|
|
459
|
+
* LearnCloud's JSON-only encrypted store; consumers base64-decode
|
|
460
|
+
* when they need raw bytes)
|
|
461
|
+
*
|
|
462
|
+
* Format-aware consumers pattern-match on `format` and use `data`.
|
|
463
|
+
* Legacy consumers continue to read `record.vc` directly — the
|
|
464
|
+
* projector is opt-in, never required.
|
|
465
|
+
*/
|
|
466
|
+
export type StoredCredential = {
|
|
467
|
+
format: "w3c-vc-2.0";
|
|
468
|
+
data: VC;
|
|
469
|
+
} | {
|
|
470
|
+
format: "w3c-vc-1.1";
|
|
471
|
+
data: VC;
|
|
472
|
+
} | {
|
|
473
|
+
format: "jwt-vc-json";
|
|
474
|
+
data: string;
|
|
475
|
+
} | {
|
|
476
|
+
format: "dc+sd-jwt";
|
|
477
|
+
data: string;
|
|
478
|
+
} | {
|
|
479
|
+
format: "vc+sd-jwt";
|
|
480
|
+
data: string;
|
|
481
|
+
} | {
|
|
482
|
+
format: "mso_mdoc";
|
|
483
|
+
data: string;
|
|
484
|
+
};
|
|
485
|
+
export type CredentialRecord<Metadata extends Record<string, any> = Record<never, never>> = {
|
|
486
|
+
id: string;
|
|
487
|
+
uri: string;
|
|
488
|
+
/**
|
|
489
|
+
* Wire-format discriminator for the credential. Optional — when
|
|
490
|
+
* absent, legacy readers infer it from `vc` shape (see
|
|
491
|
+
* `toStoredCredential` in `@learncard/helpers`). Populated on new
|
|
492
|
+
* writes once the consumer is format-aware.
|
|
493
|
+
*
|
|
494
|
+
* Added in ADR-0001 Phase 1 as additive metadata; existing
|
|
495
|
+
* records without this field continue to work unchanged.
|
|
496
|
+
*/
|
|
497
|
+
format?: CredentialFormat;
|
|
498
|
+
/**
|
|
499
|
+
* Optional semantic type hint for fast filtering without parsing
|
|
500
|
+
* the full credential — `vct` for SD-JWT-VC, last-non-VC type for
|
|
501
|
+
* W3C VCs, doctype for mDoc. Added in ADR-0001 Phase 1.
|
|
502
|
+
*/
|
|
503
|
+
semanticType?: string;
|
|
504
|
+
/**
|
|
505
|
+
* On-the-wire representation for formats whose `vc` field cannot
|
|
506
|
+
* hold the canonical form (SD-JWT compact, JWT-VC compact, base64
|
|
507
|
+
* mDoc CBOR). Undefined for W3C VCs (`vc` IS the wire form). Added
|
|
508
|
+
* in ADR-0001 Phase 1.
|
|
509
|
+
*/
|
|
510
|
+
rawWireForm?: string;
|
|
511
|
+
[key: string]: any;
|
|
512
|
+
} & Metadata;
|
|
386
513
|
declare const JWEValidator: z.ZodObject<{
|
|
387
514
|
protected: z.ZodString;
|
|
388
515
|
iv: z.ZodString;
|
|
@@ -717,6 +844,32 @@ export declare const AGE_RATING_TO_MIN_AGE: Record<string, number>;
|
|
|
717
844
|
* @returns Age in years, or null if the date is invalid
|
|
718
845
|
*/
|
|
719
846
|
export declare const calculateAgeFromDob: (dob?: string | null) => number | null;
|
|
847
|
+
/**
|
|
848
|
+
* Project a `CredentialRecord` into a format-discriminated read view.
|
|
849
|
+
*
|
|
850
|
+
* Two paths into the same output:
|
|
851
|
+
*
|
|
852
|
+
* 1. **Explicit format**: if the record carries an explicit `format`
|
|
853
|
+
* discriminator (and `rawWireForm` where required), the projector
|
|
854
|
+
* trusts it. This is the path new format-aware writers take.
|
|
855
|
+
*
|
|
856
|
+
* 2. **Inferred from shape** (legacy fallback): for records that
|
|
857
|
+
* pre-date ADR-0001 Phase 1, the projector inspects `record.vc` and
|
|
858
|
+
* infers the format. W3C VCs → `w3c-vc-2.0` / `w3c-vc-1.1` based
|
|
859
|
+
* on `@context`; transitional SD-JWT wrappers (which never shipped
|
|
860
|
+
* but exist on branch `lc-1796-3`) → `dc+sd-jwt` with the compact
|
|
861
|
+
* extracted from `proof.jwt`; legacy JWT-VC envelopes → `jwt-vc-json`.
|
|
862
|
+
*
|
|
863
|
+
* Returns a `StoredCredential` for every conceivable record. Never
|
|
864
|
+
* throws — credentials with unrecognizable shape fall back to
|
|
865
|
+
* `w3c-vc-1.1` with `data = record.vc` so legacy consumers keep
|
|
866
|
+
* something they can read.
|
|
867
|
+
*
|
|
868
|
+
* This projector is the SAFETY NET that makes the ADR-0001 migration
|
|
869
|
+
* non-breaking: writers can adopt format-tagging at their own pace;
|
|
870
|
+
* readers using this projector see the right discriminator either way.
|
|
871
|
+
*/
|
|
872
|
+
export declare const toStoredCredential: (record: CredentialRecord) => StoredCredential;
|
|
720
873
|
/**
|
|
721
874
|
* Determines whether or not a string is a valid hexadecimal string
|
|
722
875
|
*
|
package/dist/helpers.esm.js
CHANGED
|
@@ -141,6 +141,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
141
141
|
CredentialActivityStatsValidator: /* @__PURE__ */ __name(() => CredentialActivityStatsValidator, "CredentialActivityStatsValidator"),
|
|
142
142
|
CredentialActivityValidator: /* @__PURE__ */ __name(() => CredentialActivityValidator, "CredentialActivityValidator"),
|
|
143
143
|
CredentialActivityWithDetailsValidator: /* @__PURE__ */ __name(() => CredentialActivityWithDetailsValidator, "CredentialActivityWithDetailsValidator"),
|
|
144
|
+
CredentialFormatValidator: /* @__PURE__ */ __name(() => CredentialFormatValidator, "CredentialFormatValidator"),
|
|
144
145
|
CredentialInfoValidator: /* @__PURE__ */ __name(() => CredentialInfoValidator, "CredentialInfoValidator"),
|
|
145
146
|
CredentialNameRefValidator: /* @__PURE__ */ __name(() => CredentialNameRefValidator, "CredentialNameRefValidator"),
|
|
146
147
|
CredentialRecordValidator: /* @__PURE__ */ __name(() => CredentialRecordValidator, "CredentialRecordValidator"),
|
|
@@ -169,6 +170,8 @@ var require_types_cjs_development = __commonJS({
|
|
|
169
170
|
GetSkillPathResultValidator: /* @__PURE__ */ __name(() => GetSkillPathResultValidator, "GetSkillPathResultValidator"),
|
|
170
171
|
GetTemplateRecipientsEventValidator: /* @__PURE__ */ __name(() => GetTemplateRecipientsEventValidator, "GetTemplateRecipientsEventValidator"),
|
|
171
172
|
GuardianStatusValidator: /* @__PURE__ */ __name(() => GuardianStatusValidator, "GuardianStatusValidator"),
|
|
173
|
+
HolderExportConsentRecordValidator: /* @__PURE__ */ __name(() => HolderExportConsentRecordValidator, "HolderExportConsentRecordValidator"),
|
|
174
|
+
HolderExportMetadataValidator: /* @__PURE__ */ __name(() => HolderExportMetadataValidator, "HolderExportMetadataValidator"),
|
|
172
175
|
IdentifierEntryValidator: /* @__PURE__ */ __name(() => IdentifierEntryValidator, "IdentifierEntryValidator"),
|
|
173
176
|
IdentifierTypeValidator: /* @__PURE__ */ __name(() => IdentifierTypeValidator, "IdentifierTypeValidator"),
|
|
174
177
|
IdentityObjectValidator: /* @__PURE__ */ __name(() => IdentityObjectValidator, "IdentityObjectValidator"),
|
|
@@ -248,6 +251,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
248
251
|
RefreshServiceValidator: /* @__PURE__ */ __name(() => RefreshServiceValidator, "RefreshServiceValidator"),
|
|
249
252
|
RegExpValidator: /* @__PURE__ */ __name(() => RegExpValidator, "RegExpValidator"),
|
|
250
253
|
RelatedValidator: /* @__PURE__ */ __name(() => RelatedValidator, "RelatedValidator"),
|
|
254
|
+
RenderMethodValidator: /* @__PURE__ */ __name(() => RenderMethodValidator, "RenderMethodValidator"),
|
|
251
255
|
ReplaceSkillFrameworkSkillsInputValidator: /* @__PURE__ */ __name(() => ReplaceSkillFrameworkSkillsInputValidator, "ReplaceSkillFrameworkSkillsInputValidator"),
|
|
252
256
|
ReplaceSkillFrameworkSkillsResultValidator: /* @__PURE__ */ __name(() => ReplaceSkillFrameworkSkillsResultValidator, "ReplaceSkillFrameworkSkillsResultValidator"),
|
|
253
257
|
RequestLearnerContextEventValidator: /* @__PURE__ */ __name(() => RequestLearnerContextEventValidator, "RequestLearnerContextEventValidator"),
|
|
@@ -290,6 +294,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
290
294
|
SummaryCredentialKeywordValidator: /* @__PURE__ */ __name(() => SummaryCredentialKeywordValidator, "SummaryCredentialKeywordValidator"),
|
|
291
295
|
SyncFrameworkInputValidator: /* @__PURE__ */ __name(() => SyncFrameworkInputValidator, "SyncFrameworkInputValidator"),
|
|
292
296
|
TagValidator: /* @__PURE__ */ __name(() => TagValidator, "TagValidator"),
|
|
297
|
+
TemplateRenderMethodValidator: /* @__PURE__ */ __name(() => TemplateRenderMethodValidator, "TemplateRenderMethodValidator"),
|
|
293
298
|
TermsOfUseValidator: /* @__PURE__ */ __name(() => TermsOfUseValidator, "TermsOfUseValidator"),
|
|
294
299
|
UnsignedAchievementCredentialValidator: /* @__PURE__ */ __name(() => UnsignedAchievementCredentialValidator, "UnsignedAchievementCredentialValidator"),
|
|
295
300
|
UnsignedClrCredentialValidator: /* @__PURE__ */ __name(() => UnsignedClrCredentialValidator, "UnsignedClrCredentialValidator"),
|
|
@@ -13769,6 +13774,19 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
13769
13774
|
genre: external_exports.string().optional(),
|
|
13770
13775
|
audience: external_exports.string().optional()
|
|
13771
13776
|
}).catchall(external_exports.any());
|
|
13777
|
+
var TemplateRenderMethodValidator = external_exports.object({
|
|
13778
|
+
type: external_exports.literal("TemplateRenderMethod"),
|
|
13779
|
+
renderSuite: external_exports.string(),
|
|
13780
|
+
template: external_exports.string(),
|
|
13781
|
+
renderProperty: external_exports.array(external_exports.string()).optional(),
|
|
13782
|
+
outputPreference: external_exports.object({
|
|
13783
|
+
mediaType: external_exports.string()
|
|
13784
|
+
}).optional()
|
|
13785
|
+
});
|
|
13786
|
+
var RenderMethodValidator = external_exports.union([
|
|
13787
|
+
TemplateRenderMethodValidator,
|
|
13788
|
+
external_exports.record(external_exports.string(), external_exports.any())
|
|
13789
|
+
]);
|
|
13772
13790
|
var UnsignedVCValidator = external_exports.object({
|
|
13773
13791
|
"@context": ContextValidator,
|
|
13774
13792
|
id: external_exports.string().optional(),
|
|
@@ -13792,7 +13810,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
13792
13810
|
validUntil: external_exports.string().optional(),
|
|
13793
13811
|
status: CredentialStatusValidator.or(CredentialStatusValidator.array()).optional(),
|
|
13794
13812
|
termsOfUse: TermsOfUseValidator.or(TermsOfUseValidator.array()).optional(),
|
|
13795
|
-
evidence: external_exports.union([VC2EvidenceValidator, external_exports.array(VC2EvidenceValidator)]).optional()
|
|
13813
|
+
evidence: external_exports.union([VC2EvidenceValidator, external_exports.array(VC2EvidenceValidator)]).optional(),
|
|
13814
|
+
renderMethod: external_exports.union([RenderMethodValidator, external_exports.array(RenderMethodValidator)]).optional()
|
|
13796
13815
|
}).catchall(external_exports.any());
|
|
13797
13816
|
var ProofValidator = external_exports.object({
|
|
13798
13817
|
type: external_exports.string(),
|
|
@@ -14100,17 +14119,52 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14100
14119
|
var ClrCredentialValidator = UnsignedClrCredentialValidator.extend({
|
|
14101
14120
|
proof: ProofValidator.or(ProofValidator.array())
|
|
14102
14121
|
});
|
|
14122
|
+
var CredentialFormatValidator = external_exports.enum([
|
|
14123
|
+
"w3c-vc-2.0",
|
|
14124
|
+
"w3c-vc-1.1",
|
|
14125
|
+
"jwt-vc-json",
|
|
14126
|
+
"dc+sd-jwt",
|
|
14127
|
+
"vc+sd-jwt",
|
|
14128
|
+
"mso_mdoc"
|
|
14129
|
+
]);
|
|
14103
14130
|
var StatusCheckEntryValidator = external_exports.object({
|
|
14131
|
+
/**
|
|
14132
|
+
* The `credentialStatus.type` as it appeared on the credential.
|
|
14133
|
+
* One of `BitstringStatusListEntry`, `StatusList2021Entry`,
|
|
14134
|
+
* `RevocationList2020Status`, or any future custom status type.
|
|
14135
|
+
*/
|
|
14104
14136
|
entryType: external_exports.string(),
|
|
14137
|
+
/**
|
|
14138
|
+
* The claimed purpose of the entry. Standard values are
|
|
14139
|
+
* `"revocation"` and `"suspension"`; the spec allows arbitrary
|
|
14140
|
+
* strings.
|
|
14141
|
+
*/
|
|
14105
14142
|
statusPurpose: external_exports.string(),
|
|
14143
|
+
/**
|
|
14144
|
+
* Whether the bit at the credential's index in the status list
|
|
14145
|
+
* bitstring was set.
|
|
14146
|
+
*/
|
|
14106
14147
|
isSet: external_exports.boolean(),
|
|
14148
|
+
/** URL of the status list credential, when known. */
|
|
14107
14149
|
statusListCredential: external_exports.string().optional(),
|
|
14150
|
+
/** Original (string) index within the status list. */
|
|
14108
14151
|
statusListIndex: external_exports.string().optional()
|
|
14109
14152
|
});
|
|
14110
14153
|
var VerificationCheckValidator = external_exports.object({
|
|
14111
14154
|
checks: external_exports.string().array(),
|
|
14112
14155
|
warnings: external_exports.string().array(),
|
|
14113
14156
|
errors: external_exports.string().array(),
|
|
14157
|
+
/**
|
|
14158
|
+
* Per-entry results for the `credentialStatus` check, populated
|
|
14159
|
+
* by `@learncard/didkit-plugin` when the verified credential
|
|
14160
|
+
* carries one or more `credentialStatus` entries. Empty / absent
|
|
14161
|
+
* for credentials without a status entry.
|
|
14162
|
+
*
|
|
14163
|
+
* Marked `.optional()` because the underlying `ssi-ldp`
|
|
14164
|
+
* serializer omits the field when empty (`skip_serializing_if`),
|
|
14165
|
+
* so older WASM builds that pre-date the structured-status
|
|
14166
|
+
* change still validate against this schema.
|
|
14167
|
+
*/
|
|
14114
14168
|
status: StatusCheckEntryValidator.array().optional()
|
|
14115
14169
|
});
|
|
14116
14170
|
var VerificationStatusValidator = external_exports.enum(["Success", "Failed", "Error"]);
|
|
@@ -14128,7 +14182,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14128
14182
|
issuee: ProfileValidator.optional(),
|
|
14129
14183
|
credentialSubject: CredentialSubjectValidator.optional()
|
|
14130
14184
|
});
|
|
14131
|
-
var CredentialRecordValidator = external_exports.object({
|
|
14185
|
+
var CredentialRecordValidator = external_exports.object({
|
|
14186
|
+
id: external_exports.string(),
|
|
14187
|
+
uri: external_exports.string(),
|
|
14188
|
+
format: CredentialFormatValidator.optional(),
|
|
14189
|
+
semanticType: external_exports.string().optional(),
|
|
14190
|
+
rawWireForm: external_exports.string().optional()
|
|
14191
|
+
}).catchall(external_exports.any());
|
|
14132
14192
|
var PaginationOptionsValidator = external_exports.object({
|
|
14133
14193
|
limit: external_exports.number(),
|
|
14134
14194
|
cursor: external_exports.string().optional(),
|
|
@@ -14696,6 +14756,22 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14696
14756
|
date: external_exports.string(),
|
|
14697
14757
|
uris: external_exports.string().array().optional()
|
|
14698
14758
|
});
|
|
14759
|
+
var HolderExportConsentRecordValidator = external_exports.object({
|
|
14760
|
+
termsUri: external_exports.string(),
|
|
14761
|
+
status: ConsentFlowTermsStatusValidator,
|
|
14762
|
+
contract: ConsentFlowContractDetailsValidator,
|
|
14763
|
+
terms: ConsentFlowTermsValidator,
|
|
14764
|
+
transactions: ConsentFlowTransactionValidator.array()
|
|
14765
|
+
});
|
|
14766
|
+
var HolderExportMetadataValidator = external_exports.object({
|
|
14767
|
+
consentRecords: HolderExportConsentRecordValidator.array(),
|
|
14768
|
+
truncated: external_exports.boolean().optional(),
|
|
14769
|
+
warnings: external_exports.string().array().optional(),
|
|
14770
|
+
limits: external_exports.object({
|
|
14771
|
+
maxConsentRecords: external_exports.number(),
|
|
14772
|
+
maxTransactionsPerConsentRecord: external_exports.number()
|
|
14773
|
+
}).optional()
|
|
14774
|
+
});
|
|
14699
14775
|
var PaginatedConsentFlowTransactionsValidator = PaginationResponseValidator.extend({
|
|
14700
14776
|
records: ConsentFlowTransactionValidator.array()
|
|
14701
14777
|
});
|
|
@@ -14782,10 +14858,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14782
14858
|
var LCNNotificationValidator = external_exports.object({
|
|
14783
14859
|
type: LCNNotificationTypeEnumValidator,
|
|
14784
14860
|
to: LCNProfileValidator.partial().and(external_exports.object({ did: external_exports.string() })),
|
|
14785
|
-
from: external_exports.union([
|
|
14786
|
-
external_exports.string(),
|
|
14787
|
-
LCNProfileValidator.partial().and(external_exports.object({ did: external_exports.string() }))
|
|
14788
|
-
]),
|
|
14861
|
+
from: external_exports.union([external_exports.string(), LCNProfileValidator.partial().and(external_exports.object({ did: external_exports.string() }))]),
|
|
14789
14862
|
message: LCNNotificationMessageValidator.optional(),
|
|
14790
14863
|
data: LCNNotificationDataValidator.optional(),
|
|
14791
14864
|
sent: external_exports.iso.datetime().optional(),
|
|
@@ -16495,6 +16568,78 @@ var calculateAgeFromDob = /* @__PURE__ */ __name((dob) => {
|
|
|
16495
16568
|
return age;
|
|
16496
16569
|
}, "calculateAgeFromDob");
|
|
16497
16570
|
|
|
16571
|
+
// src/credential-format.ts
|
|
16572
|
+
var toStoredCredential = /* @__PURE__ */ __name((record) => {
|
|
16573
|
+
if (record.format) {
|
|
16574
|
+
if (record.format === "dc+sd-jwt" || record.format === "vc+sd-jwt" || record.format === "jwt-vc-json" || record.format === "mso_mdoc") {
|
|
16575
|
+
const wireForm = record.rawWireForm ?? extractWireFormFromVc(record.vc);
|
|
16576
|
+
if (typeof wireForm === "string" && wireForm.length > 0) {
|
|
16577
|
+
return { format: record.format, data: wireForm };
|
|
16578
|
+
}
|
|
16579
|
+
}
|
|
16580
|
+
if (record.format === "w3c-vc-2.0" || record.format === "w3c-vc-1.1") {
|
|
16581
|
+
return { format: record.format, data: record.vc };
|
|
16582
|
+
}
|
|
16583
|
+
}
|
|
16584
|
+
const vc = record.vc;
|
|
16585
|
+
if (typeof vc === "string") {
|
|
16586
|
+
if (looksLikeSdJwtCompact(vc)) {
|
|
16587
|
+
return { format: "dc+sd-jwt", data: vc };
|
|
16588
|
+
}
|
|
16589
|
+
if (looksLikeJwsCompact(vc)) {
|
|
16590
|
+
return { format: "jwt-vc-json", data: vc };
|
|
16591
|
+
}
|
|
16592
|
+
}
|
|
16593
|
+
if (vc && typeof vc === "object") {
|
|
16594
|
+
const proof = getWireFormProof(vc, true);
|
|
16595
|
+
const wireFromProof = getWireFormFromProof(proof);
|
|
16596
|
+
if (wireFromProof) {
|
|
16597
|
+
const proofType = proof?.type;
|
|
16598
|
+
if (proofType === "SdJwtCompactProof") {
|
|
16599
|
+
return { format: "dc+sd-jwt", data: wireFromProof };
|
|
16600
|
+
}
|
|
16601
|
+
if (proofType === "JwtProof2020") {
|
|
16602
|
+
return { format: "jwt-vc-json", data: wireFromProof };
|
|
16603
|
+
}
|
|
16604
|
+
}
|
|
16605
|
+
const inferred = inferW3cVersionFromContext(vc);
|
|
16606
|
+
return { format: inferred, data: vc };
|
|
16607
|
+
}
|
|
16608
|
+
return { format: "w3c-vc-1.1", data: vc };
|
|
16609
|
+
}, "toStoredCredential");
|
|
16610
|
+
var SD_JWT_COMPACT_RE = /^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+~/;
|
|
16611
|
+
var JWS_COMPACT_RE = /^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/;
|
|
16612
|
+
var looksLikeSdJwtCompact = /* @__PURE__ */ __name((value) => SD_JWT_COMPACT_RE.test(value), "looksLikeSdJwtCompact");
|
|
16613
|
+
var looksLikeJwsCompact = /* @__PURE__ */ __name((value) => JWS_COMPACT_RE.test(value), "looksLikeJwsCompact");
|
|
16614
|
+
var getWireFormProof = /* @__PURE__ */ __name((vc, requireSupportedType = false) => {
|
|
16615
|
+
if (!vc || typeof vc !== "object") return void 0;
|
|
16616
|
+
const proof = vc.proof;
|
|
16617
|
+
if (Array.isArray(proof)) {
|
|
16618
|
+
for (const entry of proof) {
|
|
16619
|
+
const proofObject2 = asWireFormProof(entry);
|
|
16620
|
+
if (proofObject2 && isUsableWireFormProof(proofObject2, requireSupportedType)) {
|
|
16621
|
+
return proofObject2;
|
|
16622
|
+
}
|
|
16623
|
+
}
|
|
16624
|
+
return void 0;
|
|
16625
|
+
}
|
|
16626
|
+
const proofObject = asWireFormProof(proof);
|
|
16627
|
+
return proofObject && isUsableWireFormProof(proofObject, requireSupportedType) ? proofObject : void 0;
|
|
16628
|
+
}, "getWireFormProof");
|
|
16629
|
+
var asWireFormProof = /* @__PURE__ */ __name((proof) => proof && typeof proof === "object" ? proof : void 0, "asWireFormProof");
|
|
16630
|
+
var isUsableWireFormProof = /* @__PURE__ */ __name((proof, requireSupportedType) => typeof proof.jwt === "string" && proof.jwt.length > 0 && (!requireSupportedType || proof.type === "SdJwtCompactProof" || proof.type === "JwtProof2020"), "isUsableWireFormProof");
|
|
16631
|
+
var getWireFormFromProof = /* @__PURE__ */ __name((proof) => typeof proof?.jwt === "string" && proof.jwt.length > 0 ? proof.jwt : void 0, "getWireFormFromProof");
|
|
16632
|
+
var extractWireFormFromVc = /* @__PURE__ */ __name((vc) => getWireFormFromProof(getWireFormProof(vc)), "extractWireFormFromVc");
|
|
16633
|
+
var inferW3cVersionFromContext = /* @__PURE__ */ __name((vc) => {
|
|
16634
|
+
if (!vc || typeof vc !== "object") return "w3c-vc-1.1";
|
|
16635
|
+
const contextRaw = vc["@context"];
|
|
16636
|
+
const contexts = Array.isArray(contextRaw) ? contextRaw : contextRaw !== void 0 ? [contextRaw] : [];
|
|
16637
|
+
const isV2 = contexts.some(
|
|
16638
|
+
(c) => typeof c === "string" && c.includes("w3.org/ns/credentials/v2")
|
|
16639
|
+
);
|
|
16640
|
+
return isV2 ? "w3c-vc-2.0" : "w3c-vc-1.1";
|
|
16641
|
+
}, "inferW3cVersionFromContext");
|
|
16642
|
+
|
|
16498
16643
|
// src/index.ts
|
|
16499
16644
|
var isHex = /* @__PURE__ */ __name((str) => /^[0-9a-f]+$/i.test(str), "isHex");
|
|
16500
16645
|
var isEncrypted = /* @__PURE__ */ __name((item) => {
|
|
@@ -16586,5 +16731,6 @@ export {
|
|
|
16586
16731
|
quantizeValue,
|
|
16587
16732
|
resizeAndChangeQuality4 as resizeAndChangeQuality,
|
|
16588
16733
|
setBitstringStatusListBit,
|
|
16734
|
+
toStoredCredential,
|
|
16589
16735
|
unwrapBoostCredential
|
|
16590
16736
|
};
|