@learncard/learn-card-plugin 1.2.20 → 1.2.22
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.js → index.cjs} +2 -2
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/{learn-card-plugin.cjs.development.js → learn-card-plugin.cjs.development.cjs} +106 -2
- package/dist/learn-card-plugin.cjs.development.cjs.map +7 -0
- package/dist/learn-card-plugin.cjs.production.min.cjs +2 -0
- package/dist/learn-card-plugin.cjs.production.min.cjs.map +7 -0
- package/dist/learn-card-plugin.esm.js +105 -1
- package/dist/learn-card-plugin.esm.js.map +4 -4
- package/dist/test/verificationPrettifier.test.d.ts +2 -0
- package/dist/test/verificationPrettifier.test.d.ts.map +1 -0
- package/dist/verificationPrettifier.d.ts +4 -0
- package/dist/verificationPrettifier.d.ts.map +1 -0
- package/package.json +19 -6
- package/dist/learn-card-plugin.cjs.development.js.map +0 -7
- package/dist/learn-card-plugin.cjs.production.min.js +0 -2
- package/dist/learn-card-plugin.cjs.production.min.js.map +0 -7
|
@@ -1806,6 +1806,108 @@ var verifyCredential = /* @__PURE__ */ __name((learnCard) => {
|
|
|
1806
1806
|
};
|
|
1807
1807
|
}, "verifyCredential");
|
|
1808
1808
|
|
|
1809
|
+
// src/verificationPrettifier.ts
|
|
1810
|
+
import { VerificationStatusEnum as VerificationStatusEnum2 } from "@learncard/types";
|
|
1811
|
+
var SUCCESS_LABELS = {
|
|
1812
|
+
parse: { check: "Format", message: "Valid" },
|
|
1813
|
+
disclosure_hash_integrity: { check: "Selective Disclosure", message: "Claims verified" },
|
|
1814
|
+
issuer_resolved: { check: "Issuer", message: "Identified" },
|
|
1815
|
+
issuer_signature: { check: "Signature", message: "Valid" },
|
|
1816
|
+
expiration: { check: "Expiration", message: "Does Not Expire" },
|
|
1817
|
+
vct: { check: "Credential Type", message: "Verified" },
|
|
1818
|
+
proof: { check: "Proof", message: "Valid" },
|
|
1819
|
+
credentialStatus: { check: "Status", message: "Active" },
|
|
1820
|
+
// The W3C verifier (learn-card/verify.ts) normalizes both `status` and
|
|
1821
|
+
// `credentialStatus` success rows to check: 'status' (lowercase), so the
|
|
1822
|
+
// bare `status` alias is required or those rows render unprettified.
|
|
1823
|
+
status: { check: "Status", message: "Active" },
|
|
1824
|
+
credentialSchema: { check: "Schema", message: "Valid" }
|
|
1825
|
+
};
|
|
1826
|
+
var ERROR_LABELS = {
|
|
1827
|
+
invalid_compact_form: { check: "Format", message: "Invalid" },
|
|
1828
|
+
invalid_jwt: { check: "Format", message: "Invalid" },
|
|
1829
|
+
invalid_typ: { check: "Format", message: "Invalid type" },
|
|
1830
|
+
missing_iss: { check: "Issuer", message: "Missing" },
|
|
1831
|
+
missing_vct: { check: "Credential Type", message: "Missing" },
|
|
1832
|
+
missing_alg: { check: "Signature", message: "Algorithm missing" },
|
|
1833
|
+
unsupported_alg: { check: "Signature", message: "Unsupported algorithm" },
|
|
1834
|
+
unsupported_sd_alg: { check: "Selective Disclosure", message: "Unsupported algorithm" },
|
|
1835
|
+
invalid_disclosure: { check: "Selective Disclosure", message: "Invalid" },
|
|
1836
|
+
disclosure_hash_mismatch: { check: "Selective Disclosure", message: "Tampered" },
|
|
1837
|
+
issuer_resolution_failed: { check: "Issuer", message: "Could not be found" },
|
|
1838
|
+
verification_method_not_found: { check: "Issuer", message: "Key not found" },
|
|
1839
|
+
verification_method_not_authorized: { check: "Issuer", message: "Key not authorized" },
|
|
1840
|
+
signature_invalid: { check: "Signature", message: "Invalid" },
|
|
1841
|
+
expired: { check: "Expiration", message: "Expired" },
|
|
1842
|
+
not_yet_valid: { check: "Expiration", message: "Not yet valid" },
|
|
1843
|
+
vct_mismatch: { check: "Credential Type", message: "Mismatch" },
|
|
1844
|
+
status_check_failed: { check: "Status", message: "Revoked or suspended" },
|
|
1845
|
+
kb_jwt_invalid: { check: "Key Binding", message: "Invalid" },
|
|
1846
|
+
presentation_verification_failed: { check: "Presentation", message: "Invalid" },
|
|
1847
|
+
key_binding_mismatch: { check: "Holder Key", message: "Mismatch" },
|
|
1848
|
+
unsupported_cnf_confirmation_type: { check: "Holder Key", message: "Unsupported type" },
|
|
1849
|
+
internal_error: { check: "Verification", message: "Something went wrong" }
|
|
1850
|
+
};
|
|
1851
|
+
var isAlreadyPrettified = /* @__PURE__ */ __name((check) => {
|
|
1852
|
+
if (!check) return true;
|
|
1853
|
+
return /^[A-Z]/.test(check) || /\s/.test(check);
|
|
1854
|
+
}, "isAlreadyPrettified");
|
|
1855
|
+
var extractErrorCode = /* @__PURE__ */ __name((message) => {
|
|
1856
|
+
if (!message) return void 0;
|
|
1857
|
+
const match2 = message.match(/^([a-z][a-z0-9_]*):/);
|
|
1858
|
+
return match2?.[1];
|
|
1859
|
+
}, "extractErrorCode");
|
|
1860
|
+
var codeFromCheck = /* @__PURE__ */ __name((check) => {
|
|
1861
|
+
if (!check) return void 0;
|
|
1862
|
+
const token = check.split(/[:\s]/)[0];
|
|
1863
|
+
return /^[a-z][a-z0-9_]*$/.test(token) ? token : void 0;
|
|
1864
|
+
}, "codeFromCheck");
|
|
1865
|
+
var resolveErrorCode = /* @__PURE__ */ __name((item) => {
|
|
1866
|
+
const candidates = [
|
|
1867
|
+
extractErrorCode(item.message),
|
|
1868
|
+
extractErrorCode(item.details),
|
|
1869
|
+
codeFromCheck(item.check)
|
|
1870
|
+
];
|
|
1871
|
+
return candidates.find((code) => code !== void 0 && code in ERROR_LABELS);
|
|
1872
|
+
}, "resolveErrorCode");
|
|
1873
|
+
var isMessageRaw = /* @__PURE__ */ __name((message, check) => {
|
|
1874
|
+
if (!message) return true;
|
|
1875
|
+
if (message === check) return true;
|
|
1876
|
+
if (/^[a-z][a-z0-9_]*$/.test(message)) return true;
|
|
1877
|
+
if (message.startsWith(`${check}:`)) return true;
|
|
1878
|
+
return false;
|
|
1879
|
+
}, "isMessageRaw");
|
|
1880
|
+
var prettifyVerificationItem = /* @__PURE__ */ __name((item) => {
|
|
1881
|
+
const isFailed = item.status === VerificationStatusEnum2.Failed;
|
|
1882
|
+
if (isFailed) {
|
|
1883
|
+
const code = resolveErrorCode(item);
|
|
1884
|
+
if (!code) return item;
|
|
1885
|
+
const label2 = ERROR_LABELS[code];
|
|
1886
|
+
const detailsHumanized = Boolean(item.details) && !isMessageRaw(item.details, item.check);
|
|
1887
|
+
const messageHumanized = Boolean(item.message) && !isMessageRaw(item.message, item.check);
|
|
1888
|
+
let message;
|
|
1889
|
+
if (messageHumanized) message = item.message;
|
|
1890
|
+
else if (detailsHumanized) message = void 0;
|
|
1891
|
+
else message = label2.message;
|
|
1892
|
+
return {
|
|
1893
|
+
...item,
|
|
1894
|
+
check: label2.check,
|
|
1895
|
+
message
|
|
1896
|
+
};
|
|
1897
|
+
}
|
|
1898
|
+
if (isAlreadyPrettified(item.check)) return item;
|
|
1899
|
+
const label = SUCCESS_LABELS[item.check];
|
|
1900
|
+
if (label) {
|
|
1901
|
+
return {
|
|
1902
|
+
...item,
|
|
1903
|
+
check: label.check,
|
|
1904
|
+
message: isMessageRaw(item.message, item.check) ? label.message : item.message
|
|
1905
|
+
};
|
|
1906
|
+
}
|
|
1907
|
+
return item;
|
|
1908
|
+
}, "prettifyVerificationItem");
|
|
1909
|
+
var prettifyVerificationItems = /* @__PURE__ */ __name((items) => items.map(prettifyVerificationItem), "prettifyVerificationItems");
|
|
1910
|
+
|
|
1809
1911
|
// src/index.ts
|
|
1810
1912
|
var getLearnCardPlugin = /* @__PURE__ */ __name((learnCard) => ({
|
|
1811
1913
|
name: "LearnCard",
|
|
@@ -1816,6 +1918,8 @@ var getLearnCardPlugin = /* @__PURE__ */ __name((learnCard) => ({
|
|
|
1816
1918
|
}
|
|
1817
1919
|
}), "getLearnCardPlugin");
|
|
1818
1920
|
export {
|
|
1819
|
-
getLearnCardPlugin
|
|
1921
|
+
getLearnCardPlugin,
|
|
1922
|
+
prettifyVerificationItem,
|
|
1923
|
+
prettifyVerificationItems
|
|
1820
1924
|
};
|
|
1821
1925
|
//# sourceMappingURL=learn-card-plugin.esm.js.map
|