Comparing version 1.10.23 to 1.10.24
@@ -0,0 +0,0 @@ export default class Ar { |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import Api from "./lib/api"; |
@@ -23,3 +23,3 @@ "use strict"; | ||
if (response.status === 404) { | ||
throw new error_1.default("BLOCK_NOT_FOUND" /* BLOCK_NOT_FOUND */); | ||
throw new error_1.default("BLOCK_NOT_FOUND" /* ArweaveErrorType.BLOCK_NOT_FOUND */); | ||
} | ||
@@ -26,0 +26,0 @@ else { |
@@ -0,0 +0,0 @@ import Api from "./lib/api"; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -67,3 +71,3 @@ if (k2 === undefined) k2 = k; | ||
console.error(`[chunk] Failed to fetch chunk at offset ${startOffset + byte}`); | ||
console.error(`[chunk] This could indicate that the chunk wasn't uploaded or hasn't yet seeded properly to a particular gatway/node`); | ||
console.error(`[chunk] This could indicate that the chunk wasn't uploaded or hasn't yet seeded properly to a particular gateway/node`); | ||
} | ||
@@ -75,3 +79,3 @@ if (chunkData) { | ||
else { | ||
throw new Error(`Coudn't complete data download at ${byte}/${size}`); | ||
throw new Error(`Couldn't complete data download at ${byte}/${size}`); | ||
} | ||
@@ -78,0 +82,0 @@ } |
@@ -0,0 +0,0 @@ import Ar from "./ar"; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
import Arweave from "./common"; | ||
export = Arweave; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -10,2 +10,3 @@ /// <reference types="node" /> | ||
logger?: Function; | ||
network?: string; | ||
} | ||
@@ -12,0 +13,0 @@ export default class Api { |
@@ -29,2 +29,3 @@ "use strict"; | ||
logger: config.logger || console.log, | ||
network: config.network, | ||
}; | ||
@@ -59,2 +60,6 @@ } | ||
request() { | ||
const headers = {}; | ||
if (this.config.network) { | ||
headers["x-network"] = this.config.network; | ||
} | ||
let instance = axios_1.default.create({ | ||
@@ -64,2 +69,3 @@ baseURL: `${this.config.protocol}://${this.config.host}:${this.config.port}`, | ||
maxContentLength: 1024 * 1024 * 512, | ||
headers, | ||
}); | ||
@@ -66,0 +72,0 @@ if (this.config.logging) { |
@@ -0,0 +0,0 @@ import { JWKInterface } from "../wallet"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=crypto-interface.js.map |
@@ -0,0 +0,0 @@ /// <reference types="node" /> |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
export declare function pemTojwk(pem: any, extras?: any): any; | ||
export declare function jwkTopem(json: any): any; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
@@ -0,0 +0,0 @@ /// <reference types="node" /> |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
@@ -0,0 +0,0 @@ declare type DeepHashChunk = Uint8Array | DeepHashChunks; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { AxiosResponse } from "axios"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ export interface Chunk { |
@@ -35,4 +35,10 @@ "use strict"; | ||
const chunk = rest.slice(0, chunkSize); | ||
console.log(common_1.default); | ||
const dataHash = await common_1.default.crypto.hash(chunk); | ||
cursor += chunk.byteLength; | ||
console.log({ | ||
dataHash, | ||
minByteRange: cursor - chunk.byteLength, | ||
maxByteRange: cursor, | ||
}); | ||
chunks.push({ | ||
@@ -39,0 +45,0 @@ dataHash, |
@@ -0,0 +0,0 @@ import Transaction from "./transaction"; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
@@ -0,0 +0,0 @@ import { Chunk, Proof } from "./merkle"; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
@@ -0,0 +0,0 @@ export declare type Base64UrlString = string; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
@@ -0,0 +0,0 @@ export interface JWKPublicInterface { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=wallet.js.map |
@@ -0,0 +0,0 @@ import Api from "./lib/api"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import Api from "./lib/api"; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
@@ -0,0 +0,0 @@ /// <reference types="node" /> |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -54,3 +58,3 @@ if (k2 === undefined) k2 = k; | ||
* However, this introduces a problem with ardrive-js, so we will enforce | ||
* config = {transformReponse: []} where we do not require a transform | ||
* config = {transformResponse: []} where we do not require a transform | ||
*/ | ||
@@ -72,3 +76,3 @@ return this.api | ||
* We need to specify a response transformer to override | ||
* the default JSON.parse behaviour, as this causes | ||
* the default JSON.parse behavior, as this causes | ||
* winston to be converted to a number and we want to | ||
@@ -100,8 +104,8 @@ * return it as a winston string. | ||
if (response.status == 404) { | ||
throw new error_1.default("TX_NOT_FOUND" /* TX_NOT_FOUND */); | ||
throw new error_1.default("TX_NOT_FOUND" /* ArweaveErrorType.TX_NOT_FOUND */); | ||
} | ||
if (response.status == 410) { | ||
throw new error_1.default("TX_FAILED" /* TX_FAILED */); | ||
throw new error_1.default("TX_FAILED" /* ArweaveErrorType.TX_FAILED */); | ||
} | ||
throw new error_1.default("TX_INVALID" /* TX_INVALID */); | ||
throw new error_1.default("TX_INVALID" /* ArweaveErrorType.TX_INVALID */); | ||
} | ||
@@ -140,7 +144,23 @@ fromRaw(attributes) { | ||
async getData(id, options) { | ||
// Only download from chunks, while /{txid} may work | ||
// it may give false positive about the data being seeded | ||
// if getData is problematic, please consider fetch-ing | ||
// an arweave gateway directly! | ||
const data = await this.chunks.downloadChunkedData(id); | ||
let data = undefined; | ||
try { | ||
data = await this.chunks.downloadChunkedData(id); | ||
} | ||
catch (error) { | ||
console.error(`Error while trying to download chunked data for ${id}`); | ||
console.error(error); | ||
} | ||
if (!data) { | ||
console.warn(`Falling back to gateway cache for ${id}`); | ||
try { | ||
data = (await this.api.get(`/${id}`)).data; | ||
} | ||
catch (error) { | ||
console.error(`Error while trying to download contiguous data from gateway cache for ${id}`); | ||
console.error(error); | ||
} | ||
} | ||
if (!data) { | ||
throw new Error(`${id} was not found!`); | ||
} | ||
if (options && options.decode && !options.string) { | ||
@@ -226,3 +246,3 @@ return data; | ||
const uploader = await this.getUploader(transaction, transaction.data); | ||
// Emulate existing error & return value behaviour. | ||
// Emulate existing error & return value behavior. | ||
try { | ||
@@ -229,0 +249,0 @@ while (!uploader.isComplete) { |
@@ -0,0 +0,0 @@ import Api from "./lib/api"; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
{ | ||
"name": "arweave", | ||
"version": "1.10.23", | ||
"version": "1.10.24", | ||
"description": "Arweave JS client library", | ||
"main": "./node/index.js", | ||
"browser": "./web/index.js", | ||
"files": [ | ||
"node", | ||
"web", | ||
"bundles" | ||
], | ||
"files": ["node", "web", "bundles"], | ||
"scripts": { | ||
@@ -60,23 +56,23 @@ "compile:node": "tsc --declaration -project tsconfig.node.json", | ||
"@types/base64-js": "^1.3.0", | ||
"@types/chai": "^4.2.12", | ||
"@types/mocha": "^9.0.0", | ||
"@types/node": "^14.14.22", | ||
"@types/chai": "^4.3.1", | ||
"@types/mocha": "^9.1.1", | ||
"@types/node": "^17.0.38", | ||
"buffer": "^6.0.3", | ||
"chai": "^4.2.0", | ||
"chai": "^4.3.6", | ||
"crypto-browserify": "^3.12.0", | ||
"mkdirp": "^1.0.4", | ||
"mocha": "^9.1.2", | ||
"mocha": "^10.0.0", | ||
"ncp": "^2.0.0", | ||
"opener": "^1.5.2", | ||
"prettier": "2.2.1", | ||
"prettier": "2.6.2", | ||
"process": "^0.11.10", | ||
"rimraf": "^3.0.2", | ||
"stream-browserify": "^3.0.0", | ||
"terser-webpack-plugin": "^5.1.4", | ||
"ts-loader": "^9.2.6", | ||
"ts-node": "^10.2.1", | ||
"typescript": "^4.1.3", | ||
"webpack": "^5.20.1", | ||
"webpack-bundle-analyzer": "^4.4.0", | ||
"webpack-cli": "^4.5.0" | ||
"terser-webpack-plugin": "^5.3.3", | ||
"ts-loader": "^9.3.0", | ||
"ts-node": "^10.8.0", | ||
"typescript": "^4.7.2", | ||
"webpack": "^5.72.1", | ||
"webpack-bundle-analyzer": "^4.5.0", | ||
"webpack-cli": "^4.9.2" | ||
}, | ||
@@ -91,9 +87,9 @@ "targets": { | ||
"dependencies": { | ||
"arconnect": "^0.2.8", | ||
"arconnect": "^0.4.2", | ||
"asn1.js": "^5.4.1", | ||
"axios": "^0.22.0", | ||
"base64-js": "^1.3.1", | ||
"bignumber.js": "^9.0.1", | ||
"axios": "^0.27.2", | ||
"base64-js": "^1.5.1", | ||
"bignumber.js": "^9.0.2", | ||
"util": "^0.12.4" | ||
} | ||
} |
@@ -1,6 +0,6 @@ | ||
# Arweave JS | ||
# Arweave JS | ||
Arweave JS is the JavaScript/TypeScript SDK for interacting with the Arweave network and uploading data to the permaweb. It works in latest browsers and Node JS. | ||
**Note:** If you are planning to upload large batches of data transactions to the Arweave network, it is strongly advised that you use [ArBundles](https://github.com/Bundler-Network/arbundles) instead of transactions with Arweave.js. You can read about bundles and their advantages on the [Arwiki](https://arwiki.wiki/#/en/preview/WUAtjfiDQEIqhsUcHXIFTn5ZmeDIE7If9hJREBLRgak). | ||
**Note:** If you are planning to upload large batches of data transactions to the Arweave network, it is strongly advised that you use [ArBundles](https://github.com/Bundler-Network/arbundles) instead of transactions with Arweave.js. You can read about bundles and their advantages on the [Arwiki](https://arwiki.wiki/#/en/bundles). | ||
@@ -410,4 +410,4 @@ - [Arweave JS](#arweave-js) | ||
while (!uploader.isComplete) { | ||
await uploader.uploadChunks(); | ||
console.log(`${progress.pctComplete}% complete`); | ||
await uploader.uploadChunk(); | ||
console.log(`${uploader.pctComplete}% complete`); | ||
} | ||
@@ -414,0 +414,0 @@ ``` |
@@ -0,0 +0,0 @@ export default class Ar { |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import Api from "./lib/api"; |
@@ -20,3 +20,3 @@ "use strict"; | ||
if (response.status === 404) { | ||
throw new error_1.default("BLOCK_NOT_FOUND" /* BLOCK_NOT_FOUND */); | ||
throw new error_1.default("BLOCK_NOT_FOUND" /* ArweaveErrorType.BLOCK_NOT_FOUND */); | ||
} | ||
@@ -23,0 +23,0 @@ else { |
@@ -0,0 +0,0 @@ import Api from "./lib/api"; |
@@ -48,3 +48,3 @@ "use strict"; | ||
console.error(`[chunk] Failed to fetch chunk at offset ${startOffset + byte}`); | ||
console.error(`[chunk] This could indicate that the chunk wasn't uploaded or hasn't yet seeded properly to a particular gatway/node`); | ||
console.error(`[chunk] This could indicate that the chunk wasn't uploaded or hasn't yet seeded properly to a particular gateway/node`); | ||
} | ||
@@ -56,3 +56,3 @@ if (chunkData) { | ||
else { | ||
throw new Error(`Coudn't complete data download at ${byte}/${size}`); | ||
throw new Error(`Couldn't complete data download at ${byte}/${size}`); | ||
} | ||
@@ -59,0 +59,0 @@ } |
@@ -0,0 +0,0 @@ import Ar from "./ar"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import Arweave from "./common"; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
@@ -10,2 +10,3 @@ /// <reference types="node" /> | ||
logger?: Function; | ||
network?: string; | ||
} | ||
@@ -12,0 +13,0 @@ export default class Api { |
@@ -26,2 +26,3 @@ "use strict"; | ||
logger: config.logger || console.log, | ||
network: config.network, | ||
}; | ||
@@ -56,2 +57,6 @@ } | ||
request() { | ||
const headers = {}; | ||
if (this.config.network) { | ||
headers["x-network"] = this.config.network; | ||
} | ||
let instance = axios_1.default.create({ | ||
@@ -61,2 +66,3 @@ baseURL: `${this.config.protocol}://${this.config.host}:${this.config.port}`, | ||
maxContentLength: 1024 * 1024 * 512, | ||
headers, | ||
}); | ||
@@ -63,0 +69,0 @@ if (this.config.logging) { |
@@ -0,0 +0,0 @@ import { JWKInterface } from "../wallet"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=crypto-interface.js.map |
@@ -0,0 +0,0 @@ /// <reference types="node" /> |
@@ -0,0 +0,0 @@ "use strict"; |
export declare function pemTojwk(pem: any, extras?: any): any; | ||
export declare function jwkTopem(json: any): any; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ /// <reference types="node" /> |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ declare type DeepHashChunk = Uint8Array | DeepHashChunks; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { AxiosResponse } from "axios"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ export interface Chunk { |
@@ -32,4 +32,10 @@ "use strict"; | ||
const chunk = rest.slice(0, chunkSize); | ||
console.log(common_1.default); | ||
const dataHash = await common_1.default.crypto.hash(chunk); | ||
cursor += chunk.byteLength; | ||
console.log({ | ||
dataHash, | ||
minByteRange: cursor - chunk.byteLength, | ||
maxByteRange: cursor, | ||
}); | ||
chunks.push({ | ||
@@ -36,0 +42,0 @@ dataHash, |
@@ -0,0 +0,0 @@ import Transaction from "./transaction"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { Chunk, Proof } from "./merkle"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ export declare type Base64UrlString = string; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ export interface JWKPublicInterface { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=wallet.js.map |
@@ -0,0 +0,0 @@ import Api from "./lib/api"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import Api from "./lib/api"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ /// <reference types="node" /> |
@@ -32,3 +32,3 @@ "use strict"; | ||
* However, this introduces a problem with ardrive-js, so we will enforce | ||
* config = {transformReponse: []} where we do not require a transform | ||
* config = {transformResponse: []} where we do not require a transform | ||
*/ | ||
@@ -50,3 +50,3 @@ return this.api | ||
* We need to specify a response transformer to override | ||
* the default JSON.parse behaviour, as this causes | ||
* the default JSON.parse behavior, as this causes | ||
* winston to be converted to a number and we want to | ||
@@ -78,8 +78,8 @@ * return it as a winston string. | ||
if (response.status == 404) { | ||
throw new error_1.default("TX_NOT_FOUND" /* TX_NOT_FOUND */); | ||
throw new error_1.default("TX_NOT_FOUND" /* ArweaveErrorType.TX_NOT_FOUND */); | ||
} | ||
if (response.status == 410) { | ||
throw new error_1.default("TX_FAILED" /* TX_FAILED */); | ||
throw new error_1.default("TX_FAILED" /* ArweaveErrorType.TX_FAILED */); | ||
} | ||
throw new error_1.default("TX_INVALID" /* TX_INVALID */); | ||
throw new error_1.default("TX_INVALID" /* ArweaveErrorType.TX_INVALID */); | ||
} | ||
@@ -118,7 +118,23 @@ fromRaw(attributes) { | ||
async getData(id, options) { | ||
// Only download from chunks, while /{txid} may work | ||
// it may give false positive about the data being seeded | ||
// if getData is problematic, please consider fetch-ing | ||
// an arweave gateway directly! | ||
const data = await this.chunks.downloadChunkedData(id); | ||
let data = undefined; | ||
try { | ||
data = await this.chunks.downloadChunkedData(id); | ||
} | ||
catch (error) { | ||
console.error(`Error while trying to download chunked data for ${id}`); | ||
console.error(error); | ||
} | ||
if (!data) { | ||
console.warn(`Falling back to gateway cache for ${id}`); | ||
try { | ||
data = (await this.api.get(`/${id}`)).data; | ||
} | ||
catch (error) { | ||
console.error(`Error while trying to download contiguous data from gateway cache for ${id}`); | ||
console.error(error); | ||
} | ||
} | ||
if (!data) { | ||
throw new Error(`${id} was not found!`); | ||
} | ||
if (options && options.decode && !options.string) { | ||
@@ -204,3 +220,3 @@ return data; | ||
const uploader = await this.getUploader(transaction, transaction.data); | ||
// Emulate existing error & return value behaviour. | ||
// Emulate existing error & return value behavior. | ||
try { | ||
@@ -207,0 +223,0 @@ while (!uploader.isComplete) { |
@@ -0,0 +0,0 @@ import Api from "./lib/api"; |
@@ -0,0 +0,0 @@ "use strict"; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1275449
14351
1
+ Addedarconnect@0.4.2(transitive)
+ Addedasynckit@0.4.0(transitive)
+ Addedaxios@0.27.2(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addedform-data@4.0.0(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
- Removedarconnect@0.2.9(transitive)
- Removedaxios@0.22.0(transitive)
Updatedarconnect@^0.4.2
Updatedaxios@^0.27.2
Updatedbase64-js@^1.5.1
Updatedbignumber.js@^9.0.2