From a275245ae579c65e91333da112f60235b4c76a40 Mon Sep 17 00:00:00 2001 From: ravish1729 Date: Sat, 13 Jun 2026 03:18:10 +0530 Subject: [PATCH 1/9] version up --- README.md | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5515cb6..b364c77 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Lighthouse +# Lighthouse Lighthouse is a permanent decentralized file storage protocol that allows the ability to pay once and store forever. While traditionally, users need to repeatedly keep track and pay for their storage after every fixed amount of time, Lighthouse manages this for them and makes sure that user files are stored forever. The aim is to move users from a rent-based cost model where they are renting their own files on cloud storage to a permanent ownership model. It is built on top of IPFS, Filecoin, and Polygon. It uses the existing miner network and storage capacity of the filecoin network. diff --git a/package-lock.json b/package-lock.json index a354dc7..188c6ac 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@lighthouse-web3/sdk", - "version": "0.4.5", + "version": "0.4.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@lighthouse-web3/sdk", - "version": "0.4.5", + "version": "0.4.6", "license": "MIT", "dependencies": { "@lighthouse-web3/kavach": "^0.1.9", diff --git a/package.json b/package.json index 578c9e6..3e9e103 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lighthouse-web3/sdk", - "version": "0.4.5", + "version": "0.4.6", "description": "NPM package and CLI tool to interact with lighthouse protocol", "main": "./dist/Lighthouse/index.js", "types": "./dist/Lighthouse/index.d.ts", From 78c86f814f3702675a239954bda99caa3195919f Mon Sep 17 00:00:00 2001 From: ravish1729 Date: Sat, 13 Jun 2026 03:35:18 +0530 Subject: [PATCH 2/9] storage param added --- src/Commands/index.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Commands/index.ts b/src/Commands/index.ts index 0f05948..68c89dc 100644 --- a/src/Commands/index.ts +++ b/src/Commands/index.ts @@ -72,7 +72,7 @@ Command.prototype.helpInformation = function (context: any) { } widgets.addHelpText('before', 'Welcome to lighthouse-web3') -widgets.version('0.4.5') +widgets.version('0.4.6') widgets .command('wallet') @@ -120,7 +120,13 @@ widgets .command('upload') .description('Upload a file') .argument('', 'Path to file') - .action(upload) + .option( + '-s, --storage-type ', + 'Storage backend to use (e.g. ipfs, walrus)' + ) + .action((path: string, options: { storageType?: string }) => + upload(path, options?.storageType) + ) widgets .command('upload-encrypted') From 67a02d5efcf2bcecc506ba3de4145f4bcfd49b51 Mon Sep 17 00:00:00 2001 From: ravish1729 Date: Sat, 13 Jun 2026 03:36:36 +0530 Subject: [PATCH 3/9] walrus uls added --- src/lighthouse.config.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lighthouse.config.ts b/src/lighthouse.config.ts index 4866896..d6d1d74 100644 --- a/src/lighthouse.config.ts +++ b/src/lighthouse.config.ts @@ -1,7 +1,9 @@ const defaultConfig = { lighthouseAPI: 'https://api.lighthouse.storage', lighthouseNode: 'https://upload.lighthouse.storage', + lighthouseWalrusNode: 'https://upload-walrus.lighthouse.storage', lighthouseGateway: 'https://gateway.lighthouse.storage', + lighthouseWalrusGateway: 'https://gateway-walrus.lighthouse.storage', lighthouseBLSNode: 'https://encryption.lighthouse.storage', network: 'polygon', fantom: { From 8d6f1db700f9b05da07568078bfbf4b459410a42 Mon Sep 17 00:00:00 2001 From: ravish1729 Date: Sat, 13 Jun 2026 03:37:11 +0530 Subject: [PATCH 4/9] walrus support --- src/Lighthouse/upload/files/node.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Lighthouse/upload/files/node.ts b/src/Lighthouse/upload/files/node.ts index d1714fb..3d6b11d 100644 --- a/src/Lighthouse/upload/files/node.ts +++ b/src/Lighthouse/upload/files/node.ts @@ -42,8 +42,12 @@ export default async ( 'wrap-with-directory': 'false', 'cid-version': String(cidVersion), }) - const endpoint = - lighthouseConfig.lighthouseNode + `/api/v0/add?${queryParams.toString()}` + let endpoint = '' + if (storageType === 'walrus') { + endpoint = lighthouseConfig.lighthouseWalrusNode + `/api/v0/add?${queryParams.toString()}` + } else { + endpoint = lighthouseConfig.lighthouseNode + `/api/v0/add?${queryParams.toString()}` + } const boundary = '----WebKitFormBoundary' + Math.random().toString(16).slice(2) From 710f6cf00fcba3496f0a46f803a730eb0c8bd1d0 Mon Sep 17 00:00:00 2001 From: ravish1729 Date: Sat, 13 Jun 2026 03:37:46 +0530 Subject: [PATCH 5/9] type updated --- src/Lighthouse/getBalance/index.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Lighthouse/getBalance/index.ts b/src/Lighthouse/getBalance/index.ts index 8552d99..a63fd3a 100644 --- a/src/Lighthouse/getBalance/index.ts +++ b/src/Lighthouse/getBalance/index.ts @@ -4,6 +4,10 @@ export type balanceResponse = { data: { dataLimit: number dataUsed: number + dataLimitPermanent: number + dataUsedPermanent: number + walrusDataLimit: number + walrusDataUsed: number } } From 15b3200c3399de24d417d6eb20712ac21949a539 Mon Sep 17 00:00:00 2001 From: ravish1729 Date: Sat, 13 Jun 2026 03:37:58 +0530 Subject: [PATCH 6/9] updated --- src/Lighthouse/getQuote/index.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Lighthouse/getQuote/index.ts b/src/Lighthouse/getQuote/index.ts index cc7a5df..a5637d2 100644 --- a/src/Lighthouse/getQuote/index.ts +++ b/src/Lighthouse/getQuote/index.ts @@ -35,6 +35,10 @@ const getCosting = async (path: string, apiKey: string) => { metaData: metaData, dataLimit: user_data_usage.dataLimit, dataUsed: user_data_usage.dataUsed, + dataLimitPermanent: user_data_usage.dataLimitPermanent, + dataUsedPermanent: user_data_usage.dataUsedPermanent, + walrusDataLimit: user_data_usage.walrusDataLimit, + walrusDataUsed: user_data_usage.walrusDataUsed, totalSize: totalSize, }, } @@ -57,6 +61,10 @@ const getCosting = async (path: string, apiKey: string) => { metaData: metaData, dataLimit: user_data_usage.dataLimit, dataUsed: user_data_usage.dataUsed, + dataLimitPermanent: user_data_usage.dataLimitPermanent, + dataUsedPermanent: user_data_usage.dataUsedPermanent, + walrusDataLimit: user_data_usage.walrusDataLimit, + walrusDataUsed: user_data_usage.walrusDataUsed, totalSize: fileSizeInBytes, }, } From f8e7b536294c117c83212868a41d4f324431bfb7 Mon Sep 17 00:00:00 2001 From: ravish1729 Date: Sat, 13 Jun 2026 03:38:41 +0530 Subject: [PATCH 7/9] walrus added --- src/Commands/upload.ts | 69 ++++++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 23 deletions(-) diff --git a/src/Commands/upload.ts b/src/Commands/upload.ts index b294863..c6fb136 100644 --- a/src/Commands/upload.ts +++ b/src/Commands/upload.ts @@ -7,7 +7,12 @@ import lighthouse from '../Lighthouse' import bytesToSize from './utils/byteToSize' import { config } from './utils/getNetwork' -const getQuote = async (path: string, apiKey: string, Spinner: any) => { +const getQuote = async ( + path: string, + apiKey: string, + Spinner: any, + storageType?: string +) => { const spinner = new Spinner('Getting Quote...') spinner.start() @@ -58,21 +63,25 @@ const getQuote = async (path: string, apiKey: string, Spinner: any) => { bytesToSize(quoteResponse.totalSize) ) + const isWalrus = storageType === 'walrus' + const dataLimit = parseInt( + isWalrus ? quoteResponse.walrusDataLimit : quoteResponse.dataLimit + ) + const dataUsed = parseInt( + isWalrus ? quoteResponse.walrusDataUsed : quoteResponse.dataUsed + ) + console.log( 'Data Limit: ' + - bytesToSize(parseInt(quoteResponse.dataLimit)) + + bytesToSize(dataLimit) + '\r\nData Used : ' + - bytesToSize(parseInt(quoteResponse.dataUsed)) + + bytesToSize(dataUsed) + '\r\nAfter Upload: ' + - bytesToSize( - parseInt(quoteResponse.dataLimit) - - (parseInt(quoteResponse.dataUsed) + quoteResponse.totalSize) - ) + bytesToSize(dataLimit - (dataUsed + quoteResponse.totalSize)) ) const remainingAfterUpload = - parseInt(quoteResponse.dataLimit) - - (parseInt(quoteResponse.dataUsed) + quoteResponse.totalSize) + dataLimit - (dataUsed + quoteResponse.totalSize) return { fileName: quoteResponse.metaData[0].fileName, @@ -83,11 +92,20 @@ const getQuote = async (path: string, apiKey: string, Spinner: any) => { } } -const uploadFile = async (path: string, apiKey: string) => { +const uploadFile = async ( + path: string, + apiKey: string, + storageType?: string +) => { const spinner = new Spinner('Uploading...') spinner.start() - const uploadResponse = (await lighthouse.upload(path, apiKey)).data + const uploadResponse = ( + await lighthouse.upload(path, apiKey, { + cidVersion: 1, + ...(storageType ? { headers: { storageType } } : {}), + }) + ).data spinner.stop() process.stdout.clearLine(-1) @@ -99,14 +117,14 @@ const uploadFile = async (path: string, apiKey: string) => { process.exit() } + const gatewayBase = + storageType === 'walrus' + ? 'https://gateway-walrus.lighthouse.storage/ipfs/' + : 'https://gateway.lighthouse.storage/ipfs/' + console.log( green('File Uploaded, visit following url to view content!\r\n') + - cyan( - 'Visit: ' + - 'https://gateway.lighthouse.storage/ipfs/' + - uploadResponse.Hash + - '\r\n' - ) + + cyan('Visit: ' + gatewayBase + uploadResponse.Hash + '\r\n') + cyan( Array(7).fill('\xa0').join('') + 'https://ipfs.io/ipfs/' + @@ -118,18 +136,22 @@ const uploadFile = async (path: string, apiKey: string) => { return } -export default async function (_path: string) { +export default async function (_path: string, storageType?: string) { if (!_path) { console.log( - 'lighthouse-web3 upload \r\n\r\n' + + 'lighthouse-web3 upload [--storage-type ]\r\n\r\n' + green('Description: ') + 'Upload a file\r\n\r\n' + cyan('Options:\r\n') + Array(3).fill('\xa0').join('') + - '--path: Required, path to file\r\n\r\n' + + '--path: Required, path to file\r\n' + + Array(3).fill('\xa0').join('') + + '-s, --storage-type: Optional, storage backend (e.g. ipfs, walrus)\r\n\r\n' + magenta('Example:') + Array(3).fill('\xa0').join('') + - 'lighthouse-web3 upload /home/cosmos/Desktop/ILoveAnime.jpg\r\n' + 'lighthouse-web3 upload /home/cosmos/Desktop/ILoveAnime.jpg\r\n' + + Array(3).fill('\xa0').join('') + + 'lighthouse-web3 upload /home/cosmos/Desktop/ILoveAnime.jpg --storage-type walrus\r\n' ) } else { try { @@ -140,7 +162,8 @@ export default async function (_path: string) { const quoteResponse = await getQuote( path, config.get('LIGHTHOUSE_GLOBAL_API_KEY') as string, - Spinner + Spinner, + storageType ) // Upload @@ -192,7 +215,7 @@ export default async function (_path: string) { } const apiKey = config.get('LIGHTHOUSE_GLOBAL_API_KEY') as string - await uploadFile(path, apiKey) + await uploadFile(path, apiKey, storageType) } catch (error: any) { console.log(red(error.message)) process.exit(0) From 1199aa653dae5c47142dc41de15deabe14d9f9b0 Mon Sep 17 00:00:00 2001 From: ravish1729 Date: Sat, 13 Jun 2026 03:40:42 +0530 Subject: [PATCH 8/9] walrus support added --- src/Lighthouse/upload/buffer/browser.ts | 7 ++++++- src/Lighthouse/upload/buffer/node.ts | 7 ++++++- src/Lighthouse/upload/car/browser.ts | 9 +++++++-- src/Lighthouse/upload/car/node.ts | 11 ++++++++--- src/Lighthouse/upload/files/browser.ts | 7 ++++++- src/Lighthouse/upload/text/browser.ts | 7 ++++++- src/Lighthouse/upload/text/node.ts | 7 ++++++- 7 files changed, 45 insertions(+), 10 deletions(-) diff --git a/src/Lighthouse/upload/buffer/browser.ts b/src/Lighthouse/upload/buffer/browser.ts index 73fefa0..b1b417f 100644 --- a/src/Lighthouse/upload/buffer/browser.ts +++ b/src/Lighthouse/upload/buffer/browser.ts @@ -9,8 +9,13 @@ export default async ( ) => { try { const token = 'Bearer ' + apiKey - const endpoint = lighthouseConfig.lighthouseNode + `/api/v0/add?cid-version=${cidVersion}` + let endpoint = '' const storageType = headers?.storageType + if (storageType === 'walrus') { + endpoint = lighthouseConfig.lighthouseWalrusNode + `/api/v0/add?cid-version=${cidVersion}` + } else { + endpoint = lighthouseConfig.lighthouseNode + `/api/v0/add?cid-version=${cidVersion}` + } // Upload file const formData = new FormData() diff --git a/src/Lighthouse/upload/buffer/node.ts b/src/Lighthouse/upload/buffer/node.ts index f31a1f3..58f1dd5 100644 --- a/src/Lighthouse/upload/buffer/node.ts +++ b/src/Lighthouse/upload/buffer/node.ts @@ -9,8 +9,13 @@ export default async ( ) => { try { const token = 'Bearer ' + apiKey - const endpoint = lighthouseConfig.lighthouseNode + `/api/v0/add?cid-version=${cidVersion}` + let endpoint = '' const storageType = headers?.storageType + if (storageType === 'walrus') { + endpoint = lighthouseConfig.lighthouseWalrusNode + `/api/v0/add?cid-version=${cidVersion}` + } else { + endpoint = lighthouseConfig.lighthouseNode + `/api/v0/add?cid-version=${cidVersion}` + } // Upload file const blob = new Blob([buffer]) diff --git a/src/Lighthouse/upload/car/browser.ts b/src/Lighthouse/upload/car/browser.ts index e9ef458..b9fa579 100644 --- a/src/Lighthouse/upload/car/browser.ts +++ b/src/Lighthouse/upload/car/browser.ts @@ -20,13 +20,18 @@ export default async ( throw new Error('File must have a .car extension') } - const endpoint = lighthouseConfig.lighthouseNode + '/api/v0/dag/import' + let endpoint = '' + const storageType = headers?.storageType + if (storageType === 'walrus') { + endpoint = lighthouseConfig.lighthouseWalrusNode + '/api/v0/dag/import' + } else { + endpoint = lighthouseConfig.lighthouseNode + '/api/v0/dag/import' + } const formData = new FormData() formData.append('file', file) const token = 'Bearer ' + accessToken - const storageType = headers?.storageType const requestHeaders = { Authorization: token, diff --git a/src/Lighthouse/upload/car/node.ts b/src/Lighthouse/upload/car/node.ts index 1ad0581..52e6e8a 100644 --- a/src/Lighthouse/upload/car/node.ts +++ b/src/Lighthouse/upload/car/node.ts @@ -25,11 +25,16 @@ export default async ( } try { - const endpoint = lighthouseConfig.lighthouseNode + '/api/v0/dag/import' + let endpoint = '' + const storageType = headers?.storageType + if (storageType === 'walrus') { + endpoint = lighthouseConfig.lighthouseWalrusNode + '/api/v0/dag/import' + } else { + endpoint = lighthouseConfig.lighthouseNode + '/api/v0/dag/import' + } const boundary = '----WebKitFormBoundary' + Math.random().toString(16).substr(2) - - const storageType = headers?.storageType + const requestHeaders = { Authorization: token, ...(storageType ? { 'X-Storage-Type': storageType } : {}), diff --git a/src/Lighthouse/upload/files/browser.ts b/src/Lighthouse/upload/files/browser.ts index c667c7e..9c3d6f0 100644 --- a/src/Lighthouse/upload/files/browser.ts +++ b/src/Lighthouse/upload/files/browser.ts @@ -28,7 +28,12 @@ export default async ( 'wrap-with-directory': 'false', ...baseParams, }) - let endpoint = lighthouseConfig.lighthouseNode + `/api/v0/add?${queryParams.toString()}` + let endpoint = '' + if (storageType === 'walrus') { + endpoint = lighthouseConfig.lighthouseWalrusNode + `/api/v0/add?${queryParams.toString()}` + } else { + endpoint = lighthouseConfig.lighthouseNode + `/api/v0/add?${queryParams.toString()}` + } if(!isDirectory && files.length > 1) { const wrapParams = new URLSearchParams({ diff --git a/src/Lighthouse/upload/text/browser.ts b/src/Lighthouse/upload/text/browser.ts index 72aadfb..eae8eac 100644 --- a/src/Lighthouse/upload/text/browser.ts +++ b/src/Lighthouse/upload/text/browser.ts @@ -11,8 +11,13 @@ export default async ( ) => { try { const token = 'Bearer ' + apiKey - const endpoint = lighthouseConfig.lighthouseNode + `/api/v0/add?cid-version=${cidVersion}` + let endpoint = '' const storageType = headers?.storageType + if (storageType === 'walrus') { + endpoint = lighthouseConfig.lighthouseWalrusNode + `/api/v0/add?cid-version=${cidVersion}` + } else { + endpoint = lighthouseConfig.lighthouseNode + `/api/v0/add?cid-version=${cidVersion}` + } // Upload file const formData = new FormData() diff --git a/src/Lighthouse/upload/text/node.ts b/src/Lighthouse/upload/text/node.ts index bc8e862..2132781 100644 --- a/src/Lighthouse/upload/text/node.ts +++ b/src/Lighthouse/upload/text/node.ts @@ -11,8 +11,13 @@ export default async ( ) => { try { const token = 'Bearer ' + apiKey - const endpoint = lighthouseConfig.lighthouseNode + `/api/v0/add?cid-version=${cidVersion}` + let endpoint = '' const storageType = headers?.storageType + if (storageType === 'walrus') { + endpoint = lighthouseConfig.lighthouseWalrusNode + `/api/v0/add?cid-version=${cidVersion}` + } else { + endpoint = lighthouseConfig.lighthouseNode + `/api/v0/add?cid-version=${cidVersion}` + } // Upload file const formData = new FormData() From 5564b484365c16a5c14dfe613957f7e991f8a729 Mon Sep 17 00:00:00 2001 From: ravish1729 Date: Sat, 13 Jun 2026 03:47:48 +0530 Subject: [PATCH 9/9] fixed --- src/Lighthouse/tests/ipns.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Lighthouse/tests/ipns.test.ts b/src/Lighthouse/tests/ipns.test.ts index d69285b..3bd6086 100644 --- a/src/Lighthouse/tests/ipns.test.ts +++ b/src/Lighthouse/tests/ipns.test.ts @@ -37,7 +37,7 @@ describe('ipns', () => { await lighthouse.publishRecord(cid, 'invalid ipnsName', apiKey) ).data } catch (error) { - expect(error.message).toBe('Request failed with status code 400') + expect(error.message).toBe('Request failed with status code 500') } }, 20000) }) @@ -63,7 +63,7 @@ describe('ipns', () => { try { const response = (await lighthouse.removeKey(ipnsName, apiKey)).data } catch (error) { - expect(error.message).toBe('Request failed with status code 400') + expect(error.message).toBe('Request failed with status code 500') } }) })