@net-protocol/storage 0.1.13 → 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.d.mts +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -2
- package/dist/index.mjs.map +1 -1
- package/dist/react.js.map +1 -1
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -208,6 +208,17 @@ declare function formatStorageKeyForDisplay(storageKey: string): {
|
|
|
208
208
|
* @param keyFormat - Optional format override: "raw" to always convert, "bytes32" to use as-is, undefined for auto-detect
|
|
209
209
|
*/
|
|
210
210
|
declare function getStorageKeyBytes(input: string, keyFormat?: "raw" | "bytes32"): string;
|
|
211
|
+
/**
|
|
212
|
+
* Extract a storage key from a message's hex-encoded data field.
|
|
213
|
+
*
|
|
214
|
+
* Follows the same detection heuristic as the Net website:
|
|
215
|
+
* a value is treated as a storage key reference if the decoded string
|
|
216
|
+
* starts with "netid-" or is 32 characters or fewer.
|
|
217
|
+
*
|
|
218
|
+
* @param data - The hex-encoded data field from a NetMessage
|
|
219
|
+
* @returns The decoded storage key string, or null if not a storage reference
|
|
220
|
+
*/
|
|
221
|
+
declare function extractStorageKeyFromMessageData(data: `0x${string}` | string | undefined): string | null;
|
|
211
222
|
/**
|
|
212
223
|
* Encodes a storage key for use in URL paths.
|
|
213
224
|
*
|
|
@@ -514,4 +525,4 @@ declare const CONCURRENT_XML_FETCHES = 3;
|
|
|
514
525
|
*/
|
|
515
526
|
declare function resolveXmlRecursive(content: string, defaultOperator: string, client: PublicClient, maxDepth: number, visited?: Set<string>, inheritedOperator?: string): Promise<string>;
|
|
516
527
|
|
|
517
|
-
export { BulkStorageKey, 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, StorageClientOptions, StorageData, type StreamingChunkResult, type StreamingProcessResult, 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 };
|
|
528
|
+
export { BulkStorageKey, 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, StorageClientOptions, StorageData, type StreamingChunkResult, type StreamingProcessResult, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -208,6 +208,17 @@ declare function formatStorageKeyForDisplay(storageKey: string): {
|
|
|
208
208
|
* @param keyFormat - Optional format override: "raw" to always convert, "bytes32" to use as-is, undefined for auto-detect
|
|
209
209
|
*/
|
|
210
210
|
declare function getStorageKeyBytes(input: string, keyFormat?: "raw" | "bytes32"): string;
|
|
211
|
+
/**
|
|
212
|
+
* Extract a storage key from a message's hex-encoded data field.
|
|
213
|
+
*
|
|
214
|
+
* Follows the same detection heuristic as the Net website:
|
|
215
|
+
* a value is treated as a storage key reference if the decoded string
|
|
216
|
+
* starts with "netid-" or is 32 characters or fewer.
|
|
217
|
+
*
|
|
218
|
+
* @param data - The hex-encoded data field from a NetMessage
|
|
219
|
+
* @returns The decoded storage key string, or null if not a storage reference
|
|
220
|
+
*/
|
|
221
|
+
declare function extractStorageKeyFromMessageData(data: `0x${string}` | string | undefined): string | null;
|
|
211
222
|
/**
|
|
212
223
|
* Encodes a storage key for use in URL paths.
|
|
213
224
|
*
|
|
@@ -514,4 +525,4 @@ declare const CONCURRENT_XML_FETCHES = 3;
|
|
|
514
525
|
*/
|
|
515
526
|
declare function resolveXmlRecursive(content: string, defaultOperator: string, client: PublicClient, maxDepth: number, visited?: Set<string>, inheritedOperator?: string): Promise<string>;
|
|
516
527
|
|
|
517
|
-
export { BulkStorageKey, 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, StorageClientOptions, StorageData, type StreamingChunkResult, type StreamingProcessResult, 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 };
|
|
528
|
+
export { BulkStorageKey, 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, StorageClientOptions, StorageData, type StreamingChunkResult, type StreamingProcessResult, 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 };
|
package/dist/index.js
CHANGED
|
@@ -629,6 +629,17 @@ function getStorageKeyBytes(input, keyFormat) {
|
|
|
629
629
|
}
|
|
630
630
|
return input.length > 32 ? core.keccak256HashString(input.toLowerCase()) : core.toBytes32(input.toLowerCase());
|
|
631
631
|
}
|
|
632
|
+
function extractStorageKeyFromMessageData(data) {
|
|
633
|
+
if (!data || data === "0x" || !data.startsWith("0x")) return null;
|
|
634
|
+
try {
|
|
635
|
+
const decoded = viem.hexToString(data);
|
|
636
|
+
if (decoded.startsWith("netid-") || decoded.length <= 32) {
|
|
637
|
+
return decoded;
|
|
638
|
+
}
|
|
639
|
+
} catch {
|
|
640
|
+
}
|
|
641
|
+
return null;
|
|
642
|
+
}
|
|
632
643
|
function encodeStorageKeyForUrl(key) {
|
|
633
644
|
return encodeURIComponent(key);
|
|
634
645
|
}
|
|
@@ -1791,6 +1802,7 @@ exports.detectFileTypeFromBase64 = detectFileTypeFromBase64;
|
|
|
1791
1802
|
exports.detectStorageType = detectStorageType;
|
|
1792
1803
|
exports.encodeStorageKeyForUrl = encodeStorageKeyForUrl;
|
|
1793
1804
|
exports.estimateChunkCount = estimateChunkCount;
|
|
1805
|
+
exports.extractStorageKeyFromMessageData = extractStorageKeyFromMessageData;
|
|
1794
1806
|
exports.fileToDataUri = fileToDataUri;
|
|
1795
1807
|
exports.formatStorageKeyForDisplay = formatStorageKeyForDisplay;
|
|
1796
1808
|
exports.generateStorageEmbedTag = generateStorageEmbedTag;
|