diff --git a/config/system-user-dev.json b/config/system-user-dev.json index 69826dc..53fd88a 100644 --- a/config/system-user-dev.json +++ b/config/system-user-dev.json @@ -1,6 +1,6 @@ { - "password": "spksihHDsyk3JUUkH3xt", + "password": "eYrzProqwsAyO3CT0Ftf", "email": "system@system.com", - "id": "67a8a8e25a3e45751f654a13", - "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3YThhOGUyNWEzZTQ1NzUxZjY1NGExMyIsImlhdCI6MTczOTEwNjUzMH0.ViWmWvfJF2UnM46pRXvl0sXThfP2dNlzrmzSxpWChew" + "id": "67a8af30c958c587f890cd8f", + "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3YThhZjMwYzk1OGM1ODdmODkwY2Q4ZiIsImlhdCI6MTczOTEwODE0NH0.OFdVwH8ikbChHV0wjRpYvnL7vu46HDYS-od3FRtm9Nc" } \ No newline at end of file diff --git a/src/controllers/rest-api/ipfs/controller.js b/src/controllers/rest-api/ipfs/controller.js index b6b9ac8..0856026 100644 --- a/src/controllers/rest-api/ipfs/controller.js +++ b/src/controllers/rest-api/ipfs/controller.js @@ -282,8 +282,9 @@ class IpfsRESTControllerLib { // DRY error handler handleError (ctx, err) { - console.log('handleError() err.status: ', err.status) - console.log('handleError() err.message: ', err.message) + // console.log('handleError() err.status: ', err.status) + // console.log('handleError() err.message: ', err.message) + // If an HTTP status is specified by the buisiness logic, use that. if (err.status) { if (err.message) { @@ -292,7 +293,7 @@ class IpfsRESTControllerLib { ctx.throw(err.status) } } else { - console.log(`handleError() err.message: ${err.message}`) + // console.log(`handleError() err.message: ${err.message}`) // By default use a 422 error if the HTTP status is not specified. ctx.throw(422, err.message) } diff --git a/src/use-cases/ipfs-use-cases.js b/src/use-cases/ipfs-use-cases.js index fe669a5..7497061 100644 --- a/src/use-cases/ipfs-use-cases.js +++ b/src/use-cases/ipfs-use-cases.js @@ -201,8 +201,15 @@ class IpfsUseCases { fileChunks.push(chunk) } } catch (err) { + // Extra logic here to look at the filename of the first file and make sure + // it ends in .json. + const name = contentArray[0].name + if (!name.endsWith('.json')) { + throw new Error(`CID ${cid} is a directory and its first file does not resolve to a valid JSON file.`) + } + // Handle CIDs that are directorys containing a JSON file. (TokenTiger.com tokens) - for await (const chunk of helia.fs.cat(`${cid}/${contentArray[0].name}`)) { + for await (const chunk of helia.fs.cat(`${cid}/${name}`)) { fileChunks.push(chunk) } }