@@ -32,6 +32,7 @@ export class Saturn {
32
32
* @param {string } [config.customerFallbackURL]
33
33
* @param {number } [config.fallbackLimit]
34
34
* @param {boolean } [config.experimental]
35
+ * @param {string } [config.format]
35
36
* @param {import('./storage/index.js').Storage } [config.storage]
36
37
*/
37
38
constructor ( config = { } ) {
@@ -41,6 +42,7 @@ export class Saturn {
41
42
logURL : 'https://twb3qukm2i654i3tnvx36char40aymqq.lambda-url.us-west-2.on.aws/' ,
42
43
orchURL : 'https://orchestrator.strn.pl/nodes?maxNodes=100' ,
43
44
authURL : 'https://su4hesnyinnwvtk3h2rkauh5ja0qrisq.lambda-url.us-west-2.on.aws/' ,
45
+ format : 'car' ,
44
46
fallbackLimit : 5 ,
45
47
connectTimeout : 5_000 ,
46
48
downloadTimeout : 0
@@ -68,7 +70,7 @@ export class Saturn {
68
70
* @returns {Promise<object> }
69
71
*/
70
72
async fetchCIDWithRace ( cidPath , opts = { } ) {
71
- const options = Object . assign ( { } , this . config , { format : 'car' } , opts )
73
+ const options = Object . assign ( { } , this . config , opts )
72
74
if ( ! opts . originFallback ) {
73
75
const [ cid ] = ( cidPath ?? '' ) . split ( '/' )
74
76
CID . parse ( cid )
@@ -159,7 +161,7 @@ export class Saturn {
159
161
* @returns {Promise<object> }
160
162
*/
161
163
async fetchCID ( cidPath , opts = { } ) {
162
- const options = Object . assign ( { } , this . config , { format : 'car' } , opts )
164
+ const options = Object . assign ( { } , this . config , opts )
163
165
if ( ! opts . originFallback ) {
164
166
const [ cid ] = ( cidPath ?? '' ) . split ( '/' )
165
167
CID . parse ( cid )
@@ -264,7 +266,7 @@ export class Saturn {
264
266
} )
265
267
}
266
268
let byteCount = 0
267
- const fetchOptions = Object . assign ( opts , { format : 'car' } , options )
269
+ const fetchOptions = Object . assign ( opts , options )
268
270
const byteChunks = await this . fetchContent ( cidPath , fetchOptions )
269
271
for await ( const chunk of byteChunks ) {
270
272
// avoid sending duplicate chunks
@@ -347,6 +349,7 @@ export class Saturn {
347
349
*/
348
350
async * fetchContent ( cidPath , opts = { } ) {
349
351
let res , controller , log
352
+ opts = Object . assign ( { } , this . config , opts )
350
353
351
354
if ( opts . raceNodes ) {
352
355
( { res, controller, log } = await this . fetchCIDWithRace ( cidPath , opts ) )
@@ -365,10 +368,10 @@ export class Saturn {
365
368
366
369
try {
367
370
const itr = metricsIterable ( asAsyncIterable ( res . body ) )
368
- if ( opts . format === 'car' ) {
369
- yield * extractVerifiedContent ( cidPath , itr )
370
- } else {
371
+ if ( ! opts . format ) {
371
372
yield * itr
373
+ } else {
374
+ yield * extractVerifiedContent ( cidPath , itr )
372
375
}
373
376
} catch ( err ) {
374
377
log . error = err . message
0 commit comments