@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/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { Argon2idParams, Argon2idParamsSchema, EXTENSION_KEY_COMPANION_RE, EXTENSION_KEY_VENDOR_RE, EncOpaque, EncOpaqueSchema, EncScheme1, EncScheme1Schema, EncryptionEnvelope, EncryptionEnvelopeSchema, HashDigestSchema, HashesMap, HashesMapSchema, ItemEntry, ItemEntrySchema, MerkleCommit, MerkleCommitSchema, PassphraseBlock, PassphraseBlockSchema, PoeRecord, PoeRecordSchema, SigEntry, SigEntrySchema, Slot, SlotSchema, Supersedes, SupersedesSchema, TOP_LEVEL_BASE_KEYS, Uri, UriSchema, VersionLiteralSchema, isExtensionKey } from './schema.cjs';
2
2
  export { encodePoeRecord, encodeRecordBodyForSigning } from './encoder.cjs';
3
3
  export { Label309ReassemblyResult, TRANSPORT_CHUNK_MAX_BYTES, chunkRecordBody, encodeLabel309Value, reassembleLabel309Value } from './carriage.cjs';
4
- export { Argon2ParamsCeiling, DEFAULT_PASSPHRASE_PARAMS_CEILING, ValidationIssue, ValidationResult, ValidatorOptions, ValidatorRole, validateCidProfile, validatePoeRecord } from './validator.cjs';
4
+ export { Argon2ParamsCeiling, DEFAULT_PASSPHRASE_PARAMS_CEILING, ValidationIssue, ValidationResult, ValidatorOptions, ValidatorRole, fetchSetUriRejection, isArweaveTxUri, isFetchSetUri, validateCidProfile, validatePoeRecord } from './validator.cjs';
5
5
  export { CARRIAGE_ERROR_CODES, DUAL_SEVERITY_CODES, ERROR_CODES, ERROR_CODE_PART, ErrorCode, ErrorCodePart, SEVERITY, STRUCTURAL_ERROR_CODES, Severity, StructuralErrorCode, VERIFIER_ERROR_CODES, VerifierErrorCode, errorCodeRegistryIndex, severityOf } from './error-codes.cjs';
6
6
  import 'zod';
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { Argon2idParams, Argon2idParamsSchema, EXTENSION_KEY_COMPANION_RE, EXTENSION_KEY_VENDOR_RE, EncOpaque, EncOpaqueSchema, EncScheme1, EncScheme1Schema, EncryptionEnvelope, EncryptionEnvelopeSchema, HashDigestSchema, HashesMap, HashesMapSchema, ItemEntry, ItemEntrySchema, MerkleCommit, MerkleCommitSchema, PassphraseBlock, PassphraseBlockSchema, PoeRecord, PoeRecordSchema, SigEntry, SigEntrySchema, Slot, SlotSchema, Supersedes, SupersedesSchema, TOP_LEVEL_BASE_KEYS, Uri, UriSchema, VersionLiteralSchema, isExtensionKey } from './schema.js';
2
2
  export { encodePoeRecord, encodeRecordBodyForSigning } from './encoder.js';
3
3
  export { Label309ReassemblyResult, TRANSPORT_CHUNK_MAX_BYTES, chunkRecordBody, encodeLabel309Value, reassembleLabel309Value } from './carriage.js';
4
- export { Argon2ParamsCeiling, DEFAULT_PASSPHRASE_PARAMS_CEILING, ValidationIssue, ValidationResult, ValidatorOptions, ValidatorRole, validateCidProfile, validatePoeRecord } from './validator.js';
4
+ export { Argon2ParamsCeiling, DEFAULT_PASSPHRASE_PARAMS_CEILING, ValidationIssue, ValidationResult, ValidatorOptions, ValidatorRole, fetchSetUriRejection, isArweaveTxUri, isFetchSetUri, validateCidProfile, validatePoeRecord } from './validator.js';
5
5
  export { CARRIAGE_ERROR_CODES, DUAL_SEVERITY_CODES, ERROR_CODES, ERROR_CODE_PART, ErrorCode, ErrorCodePart, SEVERITY, STRUCTURAL_ERROR_CODES, Severity, StructuralErrorCode, VERIFIER_ERROR_CODES, VerifierErrorCode, errorCodeRegistryIndex, severityOf } from './error-codes.js';
6
6
  import 'zod';
package/dist/index.js CHANGED
@@ -3019,46 +3019,37 @@ function checkUris(uris, basePath, issues) {
3019
3019
  uris.forEach((uri, ui) => checkOneUri(uri, [...basePath, ui], issues));
3020
3020
  }
3021
3021
  function checkOneUri(uri, path, issues) {
3022
+ const rejection = fetchSetUriRejection(uri);
3023
+ if (rejection !== null) issues.push(issueOf("INVALID_URI", path, rejection));
3024
+ }
3025
+ function isArweaveTxid(body) {
3026
+ return /^[A-Za-z0-9_-]{43}$/.test(body);
3027
+ }
3028
+ function fetchSetUriRejection(uri) {
3022
3029
  if (uri.includes("#")) {
3023
- issues.push(
3024
- issueOf("INVALID_URI", path, "URI contains a fragment identifier ('#'), which is forbidden")
3025
- );
3026
- return;
3030
+ return "URI contains a fragment identifier ('#'), which is forbidden";
3027
3031
  }
3028
3032
  const sepIdx = uri.indexOf("://");
3029
3033
  if (sepIdx <= 0 || !/^[a-z][a-z0-9+.-]*$/i.test(uri.slice(0, sepIdx))) {
3030
- issues.push(
3031
- issueOf("INVALID_URI", path, "URI is not absolute (missing scheme://hierarchical-part)")
3032
- );
3033
- return;
3034
+ return "URI is not absolute (missing scheme://hierarchical-part)";
3034
3035
  }
3035
3036
  const scheme = uri.slice(0, sepIdx).toLowerCase();
3036
3037
  const rest = uri.slice(sepIdx + "://".length);
3037
3038
  if (scheme === "ar") {
3038
- if (!/^[A-Za-z0-9_-]{43}$/.test(rest)) {
3039
- issues.push(
3040
- issueOf(
3041
- "INVALID_URI",
3042
- path,
3043
- "ar:// URI does not match `^ar://[A-Za-z0-9_-]{43}$` (43-char base64url txid, no path/query/fragment)"
3044
- )
3045
- );
3046
- }
3047
- return;
3039
+ return isArweaveTxid(rest) ? null : "ar:// URI does not match `^ar://[A-Za-z0-9_-]{43}$` (43-char base64url txid, no path/query/fragment)";
3048
3040
  }
3049
3041
  if (scheme === "ipfs") {
3050
3042
  const slashIdx = rest.indexOf("/");
3051
3043
  const cid = slashIdx === -1 ? rest : rest.slice(0, slashIdx);
3052
- if (!validateCidProfile(cid)) {
3053
- issues.push(
3054
- issueOf("INVALID_URI", path, "ipfs:// URI is not a valid CID under the Label 309 profile")
3055
- );
3056
- }
3057
- return;
3044
+ return validateCidProfile(cid) ? null : "ipfs:// URI is not a valid CID under the Label 309 profile";
3058
3045
  }
3059
- issues.push(
3060
- issueOf("INVALID_URI", path, "unsupported URI scheme; v1 PoE URI set is {ar://, ipfs://}")
3061
- );
3046
+ return "unsupported URI scheme; v1 PoE URI set is {ar://, ipfs://}";
3047
+ }
3048
+ function isFetchSetUri(uri) {
3049
+ return fetchSetUriRejection(uri) === null;
3050
+ }
3051
+ function isArweaveTxUri(uri) {
3052
+ return uri.startsWith("ar://") && isArweaveTxid(uri.slice("ar://".length));
3062
3053
  }
3063
3054
  function checkItemEnc(item, idx, opts, issues) {
3064
3055
  const encPath = ["items", idx, "enc"];
@@ -3836,6 +3827,6 @@ function valueAtPath(root, path) {
3836
3827
  (*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) *)
3837
3828
  */
3838
3829
 
3839
- export { Argon2idParamsSchema, CARRIAGE_ERROR_CODES, DEFAULT_PASSPHRASE_PARAMS_CEILING, DUAL_SEVERITY_CODES, ERROR_CODES, ERROR_CODE_PART, EXTENSION_KEY_COMPANION_RE, EXTENSION_KEY_VENDOR_RE, EncOpaqueSchema, EncScheme1Schema, EncryptionEnvelopeSchema, HashDigestSchema, HashesMapSchema, ItemEntrySchema, MerkleCommitSchema, PassphraseBlockSchema, PoeRecordSchema, SEVERITY, STRUCTURAL_ERROR_CODES, SigEntrySchema, SlotSchema, SupersedesSchema, TOP_LEVEL_BASE_KEYS, TRANSPORT_CHUNK_MAX_BYTES, UriSchema, VERIFIER_ERROR_CODES, VersionLiteralSchema, chunkRecordBody, encodeLabel309Value, encodePoeRecord, encodeRecordBodyForSigning, errorCodeRegistryIndex, isExtensionKey, reassembleLabel309Value, severityOf, validateCidProfile, validatePoeRecord };
3830
+ export { Argon2idParamsSchema, CARRIAGE_ERROR_CODES, DEFAULT_PASSPHRASE_PARAMS_CEILING, DUAL_SEVERITY_CODES, ERROR_CODES, ERROR_CODE_PART, EXTENSION_KEY_COMPANION_RE, EXTENSION_KEY_VENDOR_RE, EncOpaqueSchema, EncScheme1Schema, EncryptionEnvelopeSchema, HashDigestSchema, HashesMapSchema, ItemEntrySchema, MerkleCommitSchema, PassphraseBlockSchema, PoeRecordSchema, SEVERITY, STRUCTURAL_ERROR_CODES, SigEntrySchema, SlotSchema, SupersedesSchema, TOP_LEVEL_BASE_KEYS, TRANSPORT_CHUNK_MAX_BYTES, UriSchema, VERIFIER_ERROR_CODES, VersionLiteralSchema, chunkRecordBody, encodeLabel309Value, encodePoeRecord, encodeRecordBodyForSigning, errorCodeRegistryIndex, fetchSetUriRejection, isArweaveTxUri, isExtensionKey, isFetchSetUri, reassembleLabel309Value, severityOf, validateCidProfile, validatePoeRecord };
3840
3831
  //# sourceMappingURL=index.js.map
3841
3832
  //# sourceMappingURL=index.js.map