@net-protocol/storage 0.1.12 → 0.1.14

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.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { fromHex, stringToHex, hexToBytes, hexToString, decodeAbiParameters } from 'viem';
1
+ import { fromHex, hexToString, stringToHex, hexToBytes, decodeAbiParameters } from 'viem';
2
2
  import { readContract } from 'viem/actions';
3
3
  import { keccak256HashString, toBytes32, getPublicClient, getNetContract, normalizeDataOrEmpty } from '@net-protocol/core';
4
4
  import pako from 'pako';
@@ -623,6 +623,17 @@ function getStorageKeyBytes(input, keyFormat) {
623
623
  }
624
624
  return input.length > 32 ? keccak256HashString(input.toLowerCase()) : toBytes32(input.toLowerCase());
625
625
  }
626
+ function extractStorageKeyFromMessageData(data) {
627
+ if (!data || data === "0x" || !data.startsWith("0x")) return null;
628
+ try {
629
+ const decoded = hexToString(data);
630
+ if (decoded.startsWith("netid-") || decoded.length <= 32) {
631
+ return decoded;
632
+ }
633
+ } catch {
634
+ }
635
+ return null;
636
+ }
626
637
  function encodeStorageKeyForUrl(key) {
627
638
  return encodeURIComponent(key);
628
639
  }
@@ -1766,6 +1777,6 @@ function estimateChunkCount(fileSize, isBinary = true) {
1766
1777
  return Math.max(1, Math.ceil(fileSize / chunkSize));
1767
1778
  }
1768
1779
 
1769
- export { CHUNKED_STORAGE_CONTRACT, CHUNKED_STORAGE_READER_CONTRACT, CONCURRENT_XML_FETCHES, MAX_XML_DEPTH, OPTIMAL_CHUNK_SIZE, SAFE_STORAGE_READER_CONTRACT, STORAGE_CONTRACT, STORAGE_ROUTER_CONTRACT, StorageClient, assembleChunks, base64ToDataUri, chunkData, chunkDataForStorage, computeTopLevelHash, containsXmlReferences, detectFileTypeFromBase64, detectStorageType, encodeStorageKeyForUrl, estimateChunkCount, fileToDataUri, formatStorageKeyForDisplay, generateStorageEmbedTag, generateXmlMetadata, generateXmlMetadataWithSource, getChunkCount, getReferenceKey, getStorageKeyBytes, isBinaryFile, parseNetReferences, processDataForStorage, processFileStreaming, processFileStreamingComplete, readFileSlice, resolveOperator, resolveXmlRecursive, shouldSuggestXmlStorage, validateDataSize };
1780
+ export { CHUNKED_STORAGE_CONTRACT, CHUNKED_STORAGE_READER_CONTRACT, CONCURRENT_XML_FETCHES, MAX_XML_DEPTH, OPTIMAL_CHUNK_SIZE, SAFE_STORAGE_READER_CONTRACT, STORAGE_CONTRACT, STORAGE_ROUTER_CONTRACT, StorageClient, assembleChunks, base64ToDataUri, chunkData, chunkDataForStorage, computeTopLevelHash, containsXmlReferences, detectFileTypeFromBase64, detectStorageType, encodeStorageKeyForUrl, estimateChunkCount, extractStorageKeyFromMessageData, fileToDataUri, formatStorageKeyForDisplay, generateStorageEmbedTag, generateXmlMetadata, generateXmlMetadataWithSource, getChunkCount, getReferenceKey, getStorageKeyBytes, isBinaryFile, parseNetReferences, processDataForStorage, processFileStreaming, processFileStreamingComplete, readFileSlice, resolveOperator, resolveXmlRecursive, shouldSuggestXmlStorage, validateDataSize };
1770
1781
  //# sourceMappingURL=index.mjs.map
1771
1782
  //# sourceMappingURL=index.mjs.map