@cardanowall/poe-standard 0.9.0 → 0.11.0
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/README.md +45 -38
- package/dist/index.cjs +21 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +19 -28
- package/dist/index.js.map +1 -1
- package/dist/validator.cjs +21 -27
- package/dist/validator.cjs.map +1 -1
- package/dist/validator.d.cts +29 -1
- package/dist/validator.d.ts +29 -1
- package/dist/validator.js +19 -28
- package/dist/validator.js.map +1 -1
- package/package.json +2 -2
package/dist/validator.cjs
CHANGED
|
@@ -2908,46 +2908,37 @@ function checkUris(uris, basePath, issues) {
|
|
|
2908
2908
|
uris.forEach((uri, ui) => checkOneUri(uri, [...basePath, ui], issues));
|
|
2909
2909
|
}
|
|
2910
2910
|
function checkOneUri(uri, path, issues) {
|
|
2911
|
+
const rejection = fetchSetUriRejection(uri);
|
|
2912
|
+
if (rejection !== null) issues.push(issueOf("INVALID_URI", path, rejection));
|
|
2913
|
+
}
|
|
2914
|
+
function isArweaveTxid(body) {
|
|
2915
|
+
return /^[A-Za-z0-9_-]{43}$/.test(body);
|
|
2916
|
+
}
|
|
2917
|
+
function fetchSetUriRejection(uri) {
|
|
2911
2918
|
if (uri.includes("#")) {
|
|
2912
|
-
|
|
2913
|
-
issueOf("INVALID_URI", path, "URI contains a fragment identifier ('#'), which is forbidden")
|
|
2914
|
-
);
|
|
2915
|
-
return;
|
|
2919
|
+
return "URI contains a fragment identifier ('#'), which is forbidden";
|
|
2916
2920
|
}
|
|
2917
2921
|
const sepIdx = uri.indexOf("://");
|
|
2918
2922
|
if (sepIdx <= 0 || !/^[a-z][a-z0-9+.-]*$/i.test(uri.slice(0, sepIdx))) {
|
|
2919
|
-
|
|
2920
|
-
issueOf("INVALID_URI", path, "URI is not absolute (missing scheme://hierarchical-part)")
|
|
2921
|
-
);
|
|
2922
|
-
return;
|
|
2923
|
+
return "URI is not absolute (missing scheme://hierarchical-part)";
|
|
2923
2924
|
}
|
|
2924
2925
|
const scheme = uri.slice(0, sepIdx).toLowerCase();
|
|
2925
2926
|
const rest = uri.slice(sepIdx + "://".length);
|
|
2926
2927
|
if (scheme === "ar") {
|
|
2927
|
-
|
|
2928
|
-
issues.push(
|
|
2929
|
-
issueOf(
|
|
2930
|
-
"INVALID_URI",
|
|
2931
|
-
path,
|
|
2932
|
-
"ar:// URI does not match `^ar://[A-Za-z0-9_-]{43}$` (43-char base64url txid, no path/query/fragment)"
|
|
2933
|
-
)
|
|
2934
|
-
);
|
|
2935
|
-
}
|
|
2936
|
-
return;
|
|
2928
|
+
return isArweaveTxid(rest) ? null : "ar:// URI does not match `^ar://[A-Za-z0-9_-]{43}$` (43-char base64url txid, no path/query/fragment)";
|
|
2937
2929
|
}
|
|
2938
2930
|
if (scheme === "ipfs") {
|
|
2939
2931
|
const slashIdx = rest.indexOf("/");
|
|
2940
2932
|
const cid = slashIdx === -1 ? rest : rest.slice(0, slashIdx);
|
|
2941
|
-
|
|
2942
|
-
issues.push(
|
|
2943
|
-
issueOf("INVALID_URI", path, "ipfs:// URI is not a valid CID under the Label 309 profile")
|
|
2944
|
-
);
|
|
2945
|
-
}
|
|
2946
|
-
return;
|
|
2933
|
+
return validateCidProfile(cid) ? null : "ipfs:// URI is not a valid CID under the Label 309 profile";
|
|
2947
2934
|
}
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2935
|
+
return "unsupported URI scheme; v1 PoE URI set is {ar://, ipfs://}";
|
|
2936
|
+
}
|
|
2937
|
+
function isFetchSetUri(uri) {
|
|
2938
|
+
return fetchSetUriRejection(uri) === null;
|
|
2939
|
+
}
|
|
2940
|
+
function isArweaveTxUri(uri) {
|
|
2941
|
+
return uri.startsWith("ar://") && isArweaveTxid(uri.slice("ar://".length));
|
|
2951
2942
|
}
|
|
2952
2943
|
function checkItemEnc(item, idx, opts, issues) {
|
|
2953
2944
|
const encPath = ["items", idx, "enc"];
|
|
@@ -3726,6 +3717,9 @@ function valueAtPath(root, path) {
|
|
|
3726
3717
|
*/
|
|
3727
3718
|
|
|
3728
3719
|
exports.DEFAULT_PASSPHRASE_PARAMS_CEILING = DEFAULT_PASSPHRASE_PARAMS_CEILING;
|
|
3720
|
+
exports.fetchSetUriRejection = fetchSetUriRejection;
|
|
3721
|
+
exports.isArweaveTxUri = isArweaveTxUri;
|
|
3722
|
+
exports.isFetchSetUri = isFetchSetUri;
|
|
3729
3723
|
exports.validateCidProfile = validateCidProfile;
|
|
3730
3724
|
exports.validatePoeRecord = validatePoeRecord;
|
|
3731
3725
|
//# sourceMappingURL=validator.cjs.map
|