Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"workflows",
"usage-reporter",
"payment-settler",
"retrieval",
"stats-api"
],
"scripts": {
Expand Down
11 changes: 7 additions & 4 deletions piece-retriever/bin/piece-retriever.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { isValidEthereumAddress } from '../lib/address.js'
import {
isValidEthereumAddress,
httpAssert,
setContentSecurityPolicy,
getBadBitsEntry,
} from '@filbeam/retrieval'

import { parseRequest } from '../lib/request.js'
import {
retrieveFile as defaultRetrieveFile,
Expand All @@ -9,9 +15,6 @@ import {
logRetrievalResult,
updateDataSetStats,
} from '../lib/store.js'
import { httpAssert } from '../lib/http-assert.js'
import { setContentSecurityPolicy } from '../lib/content-security-policy.js'
import { getBadBitsEntry } from '../lib/bad-bits-util.js'

export default {
/**
Expand Down
2 changes: 1 addition & 1 deletion piece-retriever/lib/request.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { httpAssert } from './http-assert.js'
import { httpAssert } from '@filbeam/retrieval'

/**
* Parse params found in path of the request URL
Expand Down
2 changes: 1 addition & 1 deletion piece-retriever/lib/store.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { httpAssert } from './http-assert.js'
import { httpAssert } from '@filbeam/retrieval'

/**
* Logs the result of a file retrieval attempt to the D1 database.
Expand Down
3 changes: 3 additions & 0 deletions piece-retriever/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
"deploy:mainnet": "wrangler deploy --env mainnet",
"start": "wrangler d1 migrations apply dev-db --local --env dev --cwd ../db && wrangler dev --env dev",
"test": "wrangler d1 migrations apply test-db --local --cwd ../db && vitest run"
},
"dependencies": {
"@filbeam/retrieval": "^1.0.0"
}
}
2 changes: 1 addition & 1 deletion piece-retriever/test/test-helpers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DNS_ROOT } from './retriever.test'
import { getBadBitsEntry } from '../lib/bad-bits-util'
import { getBadBitsEntry } from '@filbeam/retrieval'

/**
* @param {string} payerWalletAddress
Expand Down
6 changes: 5 additions & 1 deletion piece-retriever/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@
},
"include": ["**/*.ts", "**/*.js", "src/**/*.json"],
"exclude": ["dist", "test"],
"references": []
"references": [
{
"path": "../retrieval/tsconfig.json"
}
]
}
4 changes: 4 additions & 0 deletions retrieval/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './lib/address.js'
export * from './lib/bad-bits-util.js'
export * from './lib/content-security-policy.js'
export * from './lib/http-assert.js'
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,3 @@ export async function getBadBitsEntry(cid) {
.join('')
return hashHex
}

/**
* @param {{ DB: D1Database }} env
* @param {string} cid
* @returns {Promise<boolean>}
*/
export async function findInBadBits(env, cid) {
const badBitsEntry = await getBadBitsEntry(cid)

const result = await env.DB.prepare('SELECT * FROM bad_bits WHERE hash = ?')
Comment on lines -19 to -22
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An unused function that we forgot to remove during the bad-bits DB->KV refactor.

.bind(badBitsEntry)
.all()

return result.results.length > 0
}
File renamed without changes.
12 changes: 12 additions & 0 deletions retrieval/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "@filbeam/retrieval",
"version": "1.0.0",
"private": true,
"description": "FilBeam retrieval helpers",
"author": "Space Meridian <filbeam@meridian.space>",
"type": "module",
"main": "index.js",
"scripts": {
"test": "vitest run"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { describe, it, expect } from 'vitest'
import { isValidEthereumAddress } from '../lib/address.js'

describe('isValidEthereumAddress', () => {
/** @type {{ name: string; input: string; expected: boolean }[]} */
const cases = [
{
name: 'valid lowercase address',
Expand Down
11 changes: 11 additions & 0 deletions retrieval/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"outDir": "dist"
},
"include": ["**/*.js"],
"exclude": ["dist"],
"references": []
}
3 changes: 3 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
{
"path": "payment-settler/tsconfig.json"
},
{
"path": "retrieval/tsconfig.json"
},
{
"path": "stats-api/tsconfig.json"
}
Expand Down
1 change: 1 addition & 0 deletions vitest.workspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ export default defineWorkspace([
'workflows',
'usage-reporter',
'payment-settler',
'retrieval',
'stats-api',
])