@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
|
@@ -143,6 +143,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
143
143
|
CredentialActivityStatsValidator: /* @__PURE__ */ __name(() => CredentialActivityStatsValidator, "CredentialActivityStatsValidator"),
|
|
144
144
|
CredentialActivityValidator: /* @__PURE__ */ __name(() => CredentialActivityValidator, "CredentialActivityValidator"),
|
|
145
145
|
CredentialActivityWithDetailsValidator: /* @__PURE__ */ __name(() => CredentialActivityWithDetailsValidator, "CredentialActivityWithDetailsValidator"),
|
|
146
|
+
CredentialFormatValidator: /* @__PURE__ */ __name(() => CredentialFormatValidator, "CredentialFormatValidator"),
|
|
146
147
|
CredentialInfoValidator: /* @__PURE__ */ __name(() => CredentialInfoValidator, "CredentialInfoValidator"),
|
|
147
148
|
CredentialNameRefValidator: /* @__PURE__ */ __name(() => CredentialNameRefValidator, "CredentialNameRefValidator"),
|
|
148
149
|
CredentialRecordValidator: /* @__PURE__ */ __name(() => CredentialRecordValidator, "CredentialRecordValidator"),
|
|
@@ -171,6 +172,8 @@ var require_types_cjs_development = __commonJS({
|
|
|
171
172
|
GetSkillPathResultValidator: /* @__PURE__ */ __name(() => GetSkillPathResultValidator, "GetSkillPathResultValidator"),
|
|
172
173
|
GetTemplateRecipientsEventValidator: /* @__PURE__ */ __name(() => GetTemplateRecipientsEventValidator, "GetTemplateRecipientsEventValidator"),
|
|
173
174
|
GuardianStatusValidator: /* @__PURE__ */ __name(() => GuardianStatusValidator, "GuardianStatusValidator"),
|
|
175
|
+
HolderExportConsentRecordValidator: /* @__PURE__ */ __name(() => HolderExportConsentRecordValidator, "HolderExportConsentRecordValidator"),
|
|
176
|
+
HolderExportMetadataValidator: /* @__PURE__ */ __name(() => HolderExportMetadataValidator, "HolderExportMetadataValidator"),
|
|
174
177
|
IdentifierEntryValidator: /* @__PURE__ */ __name(() => IdentifierEntryValidator, "IdentifierEntryValidator"),
|
|
175
178
|
IdentifierTypeValidator: /* @__PURE__ */ __name(() => IdentifierTypeValidator, "IdentifierTypeValidator"),
|
|
176
179
|
IdentityObjectValidator: /* @__PURE__ */ __name(() => IdentityObjectValidator, "IdentityObjectValidator"),
|
|
@@ -250,6 +253,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
250
253
|
RefreshServiceValidator: /* @__PURE__ */ __name(() => RefreshServiceValidator, "RefreshServiceValidator"),
|
|
251
254
|
RegExpValidator: /* @__PURE__ */ __name(() => RegExpValidator, "RegExpValidator"),
|
|
252
255
|
RelatedValidator: /* @__PURE__ */ __name(() => RelatedValidator, "RelatedValidator"),
|
|
256
|
+
RenderMethodValidator: /* @__PURE__ */ __name(() => RenderMethodValidator, "RenderMethodValidator"),
|
|
253
257
|
ReplaceSkillFrameworkSkillsInputValidator: /* @__PURE__ */ __name(() => ReplaceSkillFrameworkSkillsInputValidator, "ReplaceSkillFrameworkSkillsInputValidator"),
|
|
254
258
|
ReplaceSkillFrameworkSkillsResultValidator: /* @__PURE__ */ __name(() => ReplaceSkillFrameworkSkillsResultValidator, "ReplaceSkillFrameworkSkillsResultValidator"),
|
|
255
259
|
RequestLearnerContextEventValidator: /* @__PURE__ */ __name(() => RequestLearnerContextEventValidator, "RequestLearnerContextEventValidator"),
|
|
@@ -292,6 +296,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
292
296
|
SummaryCredentialKeywordValidator: /* @__PURE__ */ __name(() => SummaryCredentialKeywordValidator, "SummaryCredentialKeywordValidator"),
|
|
293
297
|
SyncFrameworkInputValidator: /* @__PURE__ */ __name(() => SyncFrameworkInputValidator, "SyncFrameworkInputValidator"),
|
|
294
298
|
TagValidator: /* @__PURE__ */ __name(() => TagValidator, "TagValidator"),
|
|
299
|
+
TemplateRenderMethodValidator: /* @__PURE__ */ __name(() => TemplateRenderMethodValidator, "TemplateRenderMethodValidator"),
|
|
295
300
|
TermsOfUseValidator: /* @__PURE__ */ __name(() => TermsOfUseValidator, "TermsOfUseValidator"),
|
|
296
301
|
UnsignedAchievementCredentialValidator: /* @__PURE__ */ __name(() => UnsignedAchievementCredentialValidator, "UnsignedAchievementCredentialValidator"),
|
|
297
302
|
UnsignedClrCredentialValidator: /* @__PURE__ */ __name(() => UnsignedClrCredentialValidator, "UnsignedClrCredentialValidator"),
|
|
@@ -13771,6 +13776,19 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
13771
13776
|
genre: external_exports.string().optional(),
|
|
13772
13777
|
audience: external_exports.string().optional()
|
|
13773
13778
|
}).catchall(external_exports.any());
|
|
13779
|
+
var TemplateRenderMethodValidator = external_exports.object({
|
|
13780
|
+
type: external_exports.literal("TemplateRenderMethod"),
|
|
13781
|
+
renderSuite: external_exports.string(),
|
|
13782
|
+
template: external_exports.string(),
|
|
13783
|
+
renderProperty: external_exports.array(external_exports.string()).optional(),
|
|
13784
|
+
outputPreference: external_exports.object({
|
|
13785
|
+
mediaType: external_exports.string()
|
|
13786
|
+
}).optional()
|
|
13787
|
+
});
|
|
13788
|
+
var RenderMethodValidator = external_exports.union([
|
|
13789
|
+
TemplateRenderMethodValidator,
|
|
13790
|
+
external_exports.record(external_exports.string(), external_exports.any())
|
|
13791
|
+
]);
|
|
13774
13792
|
var UnsignedVCValidator = external_exports.object({
|
|
13775
13793
|
"@context": ContextValidator,
|
|
13776
13794
|
id: external_exports.string().optional(),
|
|
@@ -13794,7 +13812,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
13794
13812
|
validUntil: external_exports.string().optional(),
|
|
13795
13813
|
status: CredentialStatusValidator.or(CredentialStatusValidator.array()).optional(),
|
|
13796
13814
|
termsOfUse: TermsOfUseValidator.or(TermsOfUseValidator.array()).optional(),
|
|
13797
|
-
evidence: external_exports.union([VC2EvidenceValidator, external_exports.array(VC2EvidenceValidator)]).optional()
|
|
13815
|
+
evidence: external_exports.union([VC2EvidenceValidator, external_exports.array(VC2EvidenceValidator)]).optional(),
|
|
13816
|
+
renderMethod: external_exports.union([RenderMethodValidator, external_exports.array(RenderMethodValidator)]).optional()
|
|
13798
13817
|
}).catchall(external_exports.any());
|
|
13799
13818
|
var ProofValidator = external_exports.object({
|
|
13800
13819
|
type: external_exports.string(),
|
|
@@ -14102,17 +14121,52 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14102
14121
|
var ClrCredentialValidator = UnsignedClrCredentialValidator.extend({
|
|
14103
14122
|
proof: ProofValidator.or(ProofValidator.array())
|
|
14104
14123
|
});
|
|
14124
|
+
var CredentialFormatValidator = external_exports.enum([
|
|
14125
|
+
"w3c-vc-2.0",
|
|
14126
|
+
"w3c-vc-1.1",
|
|
14127
|
+
"jwt-vc-json",
|
|
14128
|
+
"dc+sd-jwt",
|
|
14129
|
+
"vc+sd-jwt",
|
|
14130
|
+
"mso_mdoc"
|
|
14131
|
+
]);
|
|
14105
14132
|
var StatusCheckEntryValidator = external_exports.object({
|
|
14133
|
+
/**
|
|
14134
|
+
* The `credentialStatus.type` as it appeared on the credential.
|
|
14135
|
+
* One of `BitstringStatusListEntry`, `StatusList2021Entry`,
|
|
14136
|
+
* `RevocationList2020Status`, or any future custom status type.
|
|
14137
|
+
*/
|
|
14106
14138
|
entryType: external_exports.string(),
|
|
14139
|
+
/**
|
|
14140
|
+
* The claimed purpose of the entry. Standard values are
|
|
14141
|
+
* `"revocation"` and `"suspension"`; the spec allows arbitrary
|
|
14142
|
+
* strings.
|
|
14143
|
+
*/
|
|
14107
14144
|
statusPurpose: external_exports.string(),
|
|
14145
|
+
/**
|
|
14146
|
+
* Whether the bit at the credential's index in the status list
|
|
14147
|
+
* bitstring was set.
|
|
14148
|
+
*/
|
|
14108
14149
|
isSet: external_exports.boolean(),
|
|
14150
|
+
/** URL of the status list credential, when known. */
|
|
14109
14151
|
statusListCredential: external_exports.string().optional(),
|
|
14152
|
+
/** Original (string) index within the status list. */
|
|
14110
14153
|
statusListIndex: external_exports.string().optional()
|
|
14111
14154
|
});
|
|
14112
14155
|
var VerificationCheckValidator = external_exports.object({
|
|
14113
14156
|
checks: external_exports.string().array(),
|
|
14114
14157
|
warnings: external_exports.string().array(),
|
|
14115
14158
|
errors: external_exports.string().array(),
|
|
14159
|
+
/**
|
|
14160
|
+
* Per-entry results for the `credentialStatus` check, populated
|
|
14161
|
+
* by `@learncard/didkit-plugin` when the verified credential
|
|
14162
|
+
* carries one or more `credentialStatus` entries. Empty / absent
|
|
14163
|
+
* for credentials without a status entry.
|
|
14164
|
+
*
|
|
14165
|
+
* Marked `.optional()` because the underlying `ssi-ldp`
|
|
14166
|
+
* serializer omits the field when empty (`skip_serializing_if`),
|
|
14167
|
+
* so older WASM builds that pre-date the structured-status
|
|
14168
|
+
* change still validate against this schema.
|
|
14169
|
+
*/
|
|
14116
14170
|
status: StatusCheckEntryValidator.array().optional()
|
|
14117
14171
|
});
|
|
14118
14172
|
var VerificationStatusValidator = external_exports.enum(["Success", "Failed", "Error"]);
|
|
@@ -14130,7 +14184,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14130
14184
|
issuee: ProfileValidator.optional(),
|
|
14131
14185
|
credentialSubject: CredentialSubjectValidator.optional()
|
|
14132
14186
|
});
|
|
14133
|
-
var CredentialRecordValidator = external_exports.object({
|
|
14187
|
+
var CredentialRecordValidator = external_exports.object({
|
|
14188
|
+
id: external_exports.string(),
|
|
14189
|
+
uri: external_exports.string(),
|
|
14190
|
+
format: CredentialFormatValidator.optional(),
|
|
14191
|
+
semanticType: external_exports.string().optional(),
|
|
14192
|
+
rawWireForm: external_exports.string().optional()
|
|
14193
|
+
}).catchall(external_exports.any());
|
|
14134
14194
|
var PaginationOptionsValidator = external_exports.object({
|
|
14135
14195
|
limit: external_exports.number(),
|
|
14136
14196
|
cursor: external_exports.string().optional(),
|
|
@@ -14698,6 +14758,22 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14698
14758
|
date: external_exports.string(),
|
|
14699
14759
|
uris: external_exports.string().array().optional()
|
|
14700
14760
|
});
|
|
14761
|
+
var HolderExportConsentRecordValidator = external_exports.object({
|
|
14762
|
+
termsUri: external_exports.string(),
|
|
14763
|
+
status: ConsentFlowTermsStatusValidator,
|
|
14764
|
+
contract: ConsentFlowContractDetailsValidator,
|
|
14765
|
+
terms: ConsentFlowTermsValidator,
|
|
14766
|
+
transactions: ConsentFlowTransactionValidator.array()
|
|
14767
|
+
});
|
|
14768
|
+
var HolderExportMetadataValidator = external_exports.object({
|
|
14769
|
+
consentRecords: HolderExportConsentRecordValidator.array(),
|
|
14770
|
+
truncated: external_exports.boolean().optional(),
|
|
14771
|
+
warnings: external_exports.string().array().optional(),
|
|
14772
|
+
limits: external_exports.object({
|
|
14773
|
+
maxConsentRecords: external_exports.number(),
|
|
14774
|
+
maxTransactionsPerConsentRecord: external_exports.number()
|
|
14775
|
+
}).optional()
|
|
14776
|
+
});
|
|
14701
14777
|
var PaginatedConsentFlowTransactionsValidator = PaginationResponseValidator.extend({
|
|
14702
14778
|
records: ConsentFlowTransactionValidator.array()
|
|
14703
14779
|
});
|
|
@@ -14784,10 +14860,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14784
14860
|
var LCNNotificationValidator = external_exports.object({
|
|
14785
14861
|
type: LCNNotificationTypeEnumValidator,
|
|
14786
14862
|
to: LCNProfileValidator.partial().and(external_exports.object({ did: external_exports.string() })),
|
|
14787
|
-
from: external_exports.union([
|
|
14788
|
-
external_exports.string(),
|
|
14789
|
-
LCNProfileValidator.partial().and(external_exports.object({ did: external_exports.string() }))
|
|
14790
|
-
]),
|
|
14863
|
+
from: external_exports.union([external_exports.string(), LCNProfileValidator.partial().and(external_exports.object({ did: external_exports.string() }))]),
|
|
14791
14864
|
message: LCNNotificationMessageValidator.optional(),
|
|
14792
14865
|
data: LCNNotificationDataValidator.optional(),
|
|
14793
14866
|
sent: external_exports.iso.datetime().optional(),
|
|
@@ -15604,6 +15677,7 @@ __export(index_exports, {
|
|
|
15604
15677
|
quantizeValue: () => quantizeValue,
|
|
15605
15678
|
resizeAndChangeQuality: () => resizeAndChangeQuality4,
|
|
15606
15679
|
setBitstringStatusListBit: () => setBitstringStatusListBit,
|
|
15680
|
+
toStoredCredential: () => toStoredCredential,
|
|
15607
15681
|
unwrapBoostCredential: () => unwrapBoostCredential
|
|
15608
15682
|
});
|
|
15609
15683
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -16544,6 +16618,78 @@ var calculateAgeFromDob = /* @__PURE__ */ __name((dob) => {
|
|
|
16544
16618
|
return age;
|
|
16545
16619
|
}, "calculateAgeFromDob");
|
|
16546
16620
|
|
|
16621
|
+
// src/credential-format.ts
|
|
16622
|
+
var toStoredCredential = /* @__PURE__ */ __name((record) => {
|
|
16623
|
+
if (record.format) {
|
|
16624
|
+
if (record.format === "dc+sd-jwt" || record.format === "vc+sd-jwt" || record.format === "jwt-vc-json" || record.format === "mso_mdoc") {
|
|
16625
|
+
const wireForm = record.rawWireForm ?? extractWireFormFromVc(record.vc);
|
|
16626
|
+
if (typeof wireForm === "string" && wireForm.length > 0) {
|
|
16627
|
+
return { format: record.format, data: wireForm };
|
|
16628
|
+
}
|
|
16629
|
+
}
|
|
16630
|
+
if (record.format === "w3c-vc-2.0" || record.format === "w3c-vc-1.1") {
|
|
16631
|
+
return { format: record.format, data: record.vc };
|
|
16632
|
+
}
|
|
16633
|
+
}
|
|
16634
|
+
const vc = record.vc;
|
|
16635
|
+
if (typeof vc === "string") {
|
|
16636
|
+
if (looksLikeSdJwtCompact(vc)) {
|
|
16637
|
+
return { format: "dc+sd-jwt", data: vc };
|
|
16638
|
+
}
|
|
16639
|
+
if (looksLikeJwsCompact(vc)) {
|
|
16640
|
+
return { format: "jwt-vc-json", data: vc };
|
|
16641
|
+
}
|
|
16642
|
+
}
|
|
16643
|
+
if (vc && typeof vc === "object") {
|
|
16644
|
+
const proof = getWireFormProof(vc, true);
|
|
16645
|
+
const wireFromProof = getWireFormFromProof(proof);
|
|
16646
|
+
if (wireFromProof) {
|
|
16647
|
+
const proofType = proof?.type;
|
|
16648
|
+
if (proofType === "SdJwtCompactProof") {
|
|
16649
|
+
return { format: "dc+sd-jwt", data: wireFromProof };
|
|
16650
|
+
}
|
|
16651
|
+
if (proofType === "JwtProof2020") {
|
|
16652
|
+
return { format: "jwt-vc-json", data: wireFromProof };
|
|
16653
|
+
}
|
|
16654
|
+
}
|
|
16655
|
+
const inferred = inferW3cVersionFromContext(vc);
|
|
16656
|
+
return { format: inferred, data: vc };
|
|
16657
|
+
}
|
|
16658
|
+
return { format: "w3c-vc-1.1", data: vc };
|
|
16659
|
+
}, "toStoredCredential");
|
|
16660
|
+
var SD_JWT_COMPACT_RE = /^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+~/;
|
|
16661
|
+
var JWS_COMPACT_RE = /^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/;
|
|
16662
|
+
var looksLikeSdJwtCompact = /* @__PURE__ */ __name((value) => SD_JWT_COMPACT_RE.test(value), "looksLikeSdJwtCompact");
|
|
16663
|
+
var looksLikeJwsCompact = /* @__PURE__ */ __name((value) => JWS_COMPACT_RE.test(value), "looksLikeJwsCompact");
|
|
16664
|
+
var getWireFormProof = /* @__PURE__ */ __name((vc, requireSupportedType = false) => {
|
|
16665
|
+
if (!vc || typeof vc !== "object") return void 0;
|
|
16666
|
+
const proof = vc.proof;
|
|
16667
|
+
if (Array.isArray(proof)) {
|
|
16668
|
+
for (const entry of proof) {
|
|
16669
|
+
const proofObject2 = asWireFormProof(entry);
|
|
16670
|
+
if (proofObject2 && isUsableWireFormProof(proofObject2, requireSupportedType)) {
|
|
16671
|
+
return proofObject2;
|
|
16672
|
+
}
|
|
16673
|
+
}
|
|
16674
|
+
return void 0;
|
|
16675
|
+
}
|
|
16676
|
+
const proofObject = asWireFormProof(proof);
|
|
16677
|
+
return proofObject && isUsableWireFormProof(proofObject, requireSupportedType) ? proofObject : void 0;
|
|
16678
|
+
}, "getWireFormProof");
|
|
16679
|
+
var asWireFormProof = /* @__PURE__ */ __name((proof) => proof && typeof proof === "object" ? proof : void 0, "asWireFormProof");
|
|
16680
|
+
var isUsableWireFormProof = /* @__PURE__ */ __name((proof, requireSupportedType) => typeof proof.jwt === "string" && proof.jwt.length > 0 && (!requireSupportedType || proof.type === "SdJwtCompactProof" || proof.type === "JwtProof2020"), "isUsableWireFormProof");
|
|
16681
|
+
var getWireFormFromProof = /* @__PURE__ */ __name((proof) => typeof proof?.jwt === "string" && proof.jwt.length > 0 ? proof.jwt : void 0, "getWireFormFromProof");
|
|
16682
|
+
var extractWireFormFromVc = /* @__PURE__ */ __name((vc) => getWireFormFromProof(getWireFormProof(vc)), "extractWireFormFromVc");
|
|
16683
|
+
var inferW3cVersionFromContext = /* @__PURE__ */ __name((vc) => {
|
|
16684
|
+
if (!vc || typeof vc !== "object") return "w3c-vc-1.1";
|
|
16685
|
+
const contextRaw = vc["@context"];
|
|
16686
|
+
const contexts = Array.isArray(contextRaw) ? contextRaw : contextRaw !== void 0 ? [contextRaw] : [];
|
|
16687
|
+
const isV2 = contexts.some(
|
|
16688
|
+
(c) => typeof c === "string" && c.includes("w3.org/ns/credentials/v2")
|
|
16689
|
+
);
|
|
16690
|
+
return isV2 ? "w3c-vc-2.0" : "w3c-vc-1.1";
|
|
16691
|
+
}, "inferW3cVersionFromContext");
|
|
16692
|
+
|
|
16547
16693
|
// src/index.ts
|
|
16548
16694
|
var isHex = /* @__PURE__ */ __name((str) => /^[0-9a-f]+$/i.test(str), "isHex");
|
|
16549
16695
|
var isEncrypted = /* @__PURE__ */ __name((item) => {
|