Skip to content

Commit 3a4f192

Browse files
authored
Merge pull request #115 from lighthouse-web3/v0.3.5
V0.3.5
2 parents 5bf5f91 + 8f9b094 commit 3a4f192

File tree

15 files changed

+99
-33
lines changed

15 files changed

+99
-33
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Lighthouse <img src="https://img.shields.io/badge/BETA-v0.3.4-green"/>
1+
# Lighthouse <img src="https://img.shields.io/badge/BETA-v0.3.5-green"/>
22

33
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.
44

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lighthouse-web3/sdk",
3-
"version": "0.3.4",
3+
"version": "0.3.5",
44
"description": "NPM package and CLI tool to interact with lighthouse protocol",
55
"main": "./dist/Lighthouse/index.js",
66
"types": "./dist/Lighthouse/index.d.ts",

src/Commands/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Command.prototype.helpInformation = function (context: any) {
7272
}
7373

7474
widgets.addHelpText('before', 'Welcome to lighthouse-web3')
75-
widgets.version('0.3.4')
75+
widgets.version('0.3.5')
7676

7777
widgets
7878
.command('wallet')

src/Lighthouse/upload/files/browser.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
UploadFileReturnType,
66
DealParameters,
77
} from '../../../types'
8-
import { checkDuplicateFileNames } from '../../utils/util'
8+
import { checkDuplicateFileNames, retryFetch } from '../../utils/util'
99

1010
// eslint-disable-next-line @typescript-eslint/no-empty-function
1111
export default async <T extends boolean>(
@@ -35,10 +35,11 @@ export default async <T extends boolean>(
3535
: 'null',
3636
})
3737

38-
const response = await fetch(endpoint, {
38+
const response = await retryFetch(endpoint, {
3939
method: 'POST',
4040
body: formData,
4141
headers: headers,
42+
timeout: 7200000,
4243
})
4344

4445
if (!response.ok) {

src/Lighthouse/upload/files/node.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import basePathConvert from '../../utils/basePathConvert'
22
import { lighthouseConfig } from '../../../lighthouse.config'
33
import { UploadFileReturnType, DealParameters } from '../../../types'
4+
import { retryFetch } from '../../utils/util'
45

56
export async function walk(dir: string) {
67
const { readdir, stat } = eval(`require`)('fs-extra')
@@ -39,18 +40,19 @@ export default async <T extends boolean>(
3940
if (stats.isFile()) {
4041
const data = new FormData()
4142
const stream = createReadStream(sourcePath)
42-
const buffers = []
43+
const buffers: Buffer[] = []
4344
for await (const chunk of stream) {
4445
buffers.push(chunk)
4546
}
4647
const blob = new Blob(buffers)
4748

48-
data.set('file', blob, path.basename(sourcePath))
49+
data.append('file', blob, path.basename(sourcePath))
4950

50-
const response = await fetch(endpoint, {
51+
const response = await retryFetch(endpoint, {
5152
method: 'POST',
5253
body: data,
5354
credentials: 'include',
55+
timeout: 7200000,
5456
headers: {
5557
Encryption: 'false',
5658
Authorization: token,
@@ -65,7 +67,6 @@ export default async <T extends boolean>(
6567
}
6668

6769
let responseData = (await response.text()) as any
68-
console.log(responseData)
6970
if (multi) {
7071
const temp = responseData.split('\n')
7172
responseData = JSON.parse(temp[temp.length - 2])
@@ -80,23 +81,24 @@ export default async <T extends boolean>(
8081

8182
for (const file of files) {
8283
const stream = createReadStream(file)
83-
const buffers: any = []
84+
const buffers: Buffer[] = []
8485
for await (const chunk of stream) {
8586
buffers.push(chunk)
8687
}
8788
const blob = new Blob(buffers)
8889

89-
data.set(
90+
data.append(
9091
'file',
9192
blob,
9293
multi ? path.basename(file) : basePathConvert(sourcePath, file)
9394
)
9495
}
9596

96-
const response = await fetch(endpoint, {
97+
const response = await retryFetch(endpoint, {
9798
method: 'POST',
9899
body: data,
99100
credentials: 'include',
101+
timeout: 7200000,
100102
headers: {
101103
Encryption: 'false',
102104
Authorization: token,

src/Lighthouse/upload/text/browser.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { lighthouseConfig } from '../../../lighthouse.config'
2+
import { retryFetch } from '../../utils/util'
23

34
export default async (text: string, apiKey: string, name: string) => {
45
try {
@@ -8,11 +9,12 @@ export default async (text: string, apiKey: string, name: string) => {
89
// Upload file
910
const formData = new FormData()
1011
const blob = new Blob([text], { type: 'text/plain' })
11-
formData.set('file', blob, name)
12+
formData.append('file', blob, name)
1213

13-
const response = await fetch(endpoint, {
14+
const response = await retryFetch(endpoint, {
1415
method: 'POST',
1516
body: formData,
17+
timeout: 7200000,
1618
headers: {
1719
Encryption: 'false',
1820
'Mime-Type': 'text/plain',

src/Lighthouse/upload/text/node.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { lighthouseConfig } from '../../../lighthouse.config'
2+
import { retryFetch } from '../../utils/util'
23

34
export default async (text: string, apiKey: string, name: string) => {
45
try {
@@ -9,12 +10,13 @@ export default async (text: string, apiKey: string, name: string) => {
910
const formData = new FormData()
1011
const blob = new Blob([Buffer.from(text)])
1112

12-
formData.set('file', blob, name)
13+
formData.append('file', blob, name)
1314

14-
const response = await fetch(endpoint, {
15+
const response = await retryFetch(endpoint, {
1516
method: 'POST',
1617
body: formData,
1718
credentials: 'include',
19+
timeout: 7200000,
1820
headers: {
1921
Encryption: 'false',
2022
'Mime-Type': 'text/plain',

src/Lighthouse/uploadEncrypted/decrypt/browser.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
/* istanbul ignore file */
22
import { decryptFile } from '../encryptionBrowser'
33
import { lighthouseConfig } from '../../../lighthouse.config'
4+
import { retryFetch } from '../../utils/util'
45

56
export default async (
67
cid: string,
78
fileEncryptionKey: string,
89
mimeType: string
910
) => {
10-
const response = await fetch(
11+
const response = await retryFetch(
1112
lighthouseConfig.lighthouseGateway + '/api/v0/cat/' + cid,
1213
{
1314
method: 'POST',
15+
timeout: 7200000,
1416
}
1517
)
1618

src/Lighthouse/uploadEncrypted/decrypt/node.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
/* istanbul ignore file */
22
import { decryptFile } from '../encryptionNode'
33
import { lighthouseConfig } from '../../../lighthouse.config'
4+
import { retryFetch } from '../../utils/util'
45

56
export default async (cid: string, fileEncryptionKey: any) => {
67
try {
7-
const response = await fetch(
8+
const response = await retryFetch(
89
lighthouseConfig.lighthouseGateway + '/api/v0/cat/' + cid,
910
{
1011
method: 'POST',
12+
timeout: 7200000,
1113
}
1214
)
1315

0 commit comments

Comments
 (0)