@cardanowall/poe-standard 0.10.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/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/index.cjs
CHANGED
|
@@ -3021,46 +3021,37 @@ function checkUris(uris, basePath, issues) {
|
|
|
3021
3021
|
uris.forEach((uri, ui) => checkOneUri(uri, [...basePath, ui], issues));
|
|
3022
3022
|
}
|
|
3023
3023
|
function checkOneUri(uri, path, issues) {
|
|
3024
|
+
const rejection = fetchSetUriRejection(uri);
|
|
3025
|
+
if (rejection !== null) issues.push(issueOf("INVALID_URI", path, rejection));
|
|
3026
|
+
}
|
|
3027
|
+
function isArweaveTxid(body) {
|
|
3028
|
+
return /^[A-Za-z0-9_-]{43}$/.test(body);
|
|
3029
|
+
}
|
|
3030
|
+
function fetchSetUriRejection(uri) {
|
|
3024
3031
|
if (uri.includes("#")) {
|
|
3025
|
-
|
|
3026
|
-
issueOf("INVALID_URI", path, "URI contains a fragment identifier ('#'), which is forbidden")
|
|
3027
|
-
);
|
|
3028
|
-
return;
|
|
3032
|
+
return "URI contains a fragment identifier ('#'), which is forbidden";
|
|
3029
3033
|
}
|
|
3030
3034
|
const sepIdx = uri.indexOf("://");
|
|
3031
3035
|
if (sepIdx <= 0 || !/^[a-z][a-z0-9+.-]*$/i.test(uri.slice(0, sepIdx))) {
|
|
3032
|
-
|
|
3033
|
-
issueOf("INVALID_URI", path, "URI is not absolute (missing scheme://hierarchical-part)")
|
|
3034
|
-
);
|
|
3035
|
-
return;
|
|
3036
|
+
return "URI is not absolute (missing scheme://hierarchical-part)";
|
|
3036
3037
|
}
|
|
3037
3038
|
const scheme = uri.slice(0, sepIdx).toLowerCase();
|
|
3038
3039
|
const rest = uri.slice(sepIdx + "://".length);
|
|
3039
3040
|
if (scheme === "ar") {
|
|
3040
|
-
|
|
3041
|
-
issues.push(
|
|
3042
|
-
issueOf(
|
|
3043
|
-
"INVALID_URI",
|
|
3044
|
-
path,
|
|
3045
|
-
"ar:// URI does not match `^ar://[A-Za-z0-9_-]{43}$` (43-char base64url txid, no path/query/fragment)"
|
|
3046
|
-
)
|
|
3047
|
-
);
|
|
3048
|
-
}
|
|
3049
|
-
return;
|
|
3041
|
+
return isArweaveTxid(rest) ? null : "ar:// URI does not match `^ar://[A-Za-z0-9_-]{43}$` (43-char base64url txid, no path/query/fragment)";
|
|
3050
3042
|
}
|
|
3051
3043
|
if (scheme === "ipfs") {
|
|
3052
3044
|
const slashIdx = rest.indexOf("/");
|
|
3053
3045
|
const cid = slashIdx === -1 ? rest : rest.slice(0, slashIdx);
|
|
3054
|
-
|
|
3055
|
-
issues.push(
|
|
3056
|
-
issueOf("INVALID_URI", path, "ipfs:// URI is not a valid CID under the Label 309 profile")
|
|
3057
|
-
);
|
|
3058
|
-
}
|
|
3059
|
-
return;
|
|
3046
|
+
return validateCidProfile(cid) ? null : "ipfs:// URI is not a valid CID under the Label 309 profile";
|
|
3060
3047
|
}
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3048
|
+
return "unsupported URI scheme; v1 PoE URI set is {ar://, ipfs://}";
|
|
3049
|
+
}
|
|
3050
|
+
function isFetchSetUri(uri) {
|
|
3051
|
+
return fetchSetUriRejection(uri) === null;
|
|
3052
|
+
}
|
|
3053
|
+
function isArweaveTxUri(uri) {
|
|
3054
|
+
return uri.startsWith("ar://") && isArweaveTxid(uri.slice("ar://".length));
|
|
3064
3055
|
}
|
|
3065
3056
|
function checkItemEnc(item, idx, opts, issues) {
|
|
3066
3057
|
const encPath = ["items", idx, "enc"];
|
|
@@ -3870,7 +3861,10 @@ exports.encodeLabel309Value = encodeLabel309Value;
|
|
|
3870
3861
|
exports.encodePoeRecord = encodePoeRecord;
|
|
3871
3862
|
exports.encodeRecordBodyForSigning = encodeRecordBodyForSigning;
|
|
3872
3863
|
exports.errorCodeRegistryIndex = errorCodeRegistryIndex;
|
|
3864
|
+
exports.fetchSetUriRejection = fetchSetUriRejection;
|
|
3865
|
+
exports.isArweaveTxUri = isArweaveTxUri;
|
|
3873
3866
|
exports.isExtensionKey = isExtensionKey;
|
|
3867
|
+
exports.isFetchSetUri = isFetchSetUri;
|
|
3874
3868
|
exports.reassembleLabel309Value = reassembleLabel309Value;
|
|
3875
3869
|
exports.severityOf = severityOf;
|
|
3876
3870
|
exports.validateCidProfile = validateCidProfile;
|