1
0
mirror of https://github.com/oceanprotocol/commons.git synced 2023-03-15 18:03:00 +01:00

Merge pull request #207 from oceanprotocol/feature/v2-ddo

Migrate to new v2 DDO structure
This commit is contained in:
Matthias Kretschmann 2019-12-09 14:20:20 +01:00 committed by GitHub
commit 1b07944e02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 2091 additions and 8081 deletions

View File

@ -37,7 +37,7 @@
}, },
"settings": { "settings": {
"react": { "react": {
"version": "16" "version": "16.10"
} }
} }
} }

2
.nvmrc
View File

@ -1 +1 @@
v11 v12

View File

@ -2,7 +2,7 @@ dist: xenial
sudo: required sudo: required
language: node_js language: node_js
node_js: node_js:
- '11' - '12'
services: services:
- docker - docker
@ -33,10 +33,10 @@ env:
- IPFS_GATEWAY_URI="https://ipfs.oceanprotocol.com" - IPFS_GATEWAY_URI="https://ipfs.oceanprotocol.com"
# start Barge with these versions # start Barge with these versions
- BRIZO_VERSION=v0.4.6 - BRIZO_VERSION=v0.7.2
- AQUARIUS_VERSION=v0.3.9 - AQUARIUS_VERSION=v1.0.5
- KEEPER_VERSION=v0.12.7 - KEEPER_VERSION=v0.12.7
- EVENTS_HANDLER_VERSION=v0.1.2 - EVENTS_HANDLER_VERSION=v0.3.4
- KEEPER_OWNER_ROLE_ADDRESS="0xe2DD09d719Da89e5a3D0F2549c7E24566e947260" - KEEPER_OWNER_ROLE_ADDRESS="0xe2DD09d719Da89e5a3D0F2549c7E24566e947260"
- FAUCET_TIMESPAN=0 - FAUCET_TIMESPAN=0

View File

@ -4,10 +4,19 @@ All notable changes to this project will be documented in this file. Dates are d
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
#### [v2.0.0-beta.3](https://github.com/oceanprotocol/commons/compare/v1.3.2...v2.0.0-beta.3)
> 22 November 2019
- bump web3 packages [`8c3262c`](https://github.com/oceanprotocol/commons/commit/8c3262c1d91727dcb514ff049d8db5f48e812fed)
- bump packages [`5800027`](https://github.com/oceanprotocol/commons/commit/5800027cbf4461cb274ce182e3350e3a1c4b708c)
- update to new DDO structure [`985803d`](https://github.com/oceanprotocol/commons/commit/985803d43e4a3d729d90196f260b128bf2e37f63)
#### [v1.3.2](https://github.com/oceanprotocol/commons/compare/v1.3.1...v1.3.2) #### [v1.3.2](https://github.com/oceanprotocol/commons/compare/v1.3.1...v1.3.2)
> 22 November 2019 > 22 November 2019
- Release 1.3.2 [`b02cda0`](https://github.com/oceanprotocol/commons/commit/b02cda043c33c00174e4e4f3ec56e7d0aa5386da)
- bump to squid-js v0.8.3 [`8ca727f`](https://github.com/oceanprotocol/commons/commit/8ca727fffc2cc137b978b7d65ed586da405b015b) - bump to squid-js v0.8.3 [`8ca727f`](https://github.com/oceanprotocol/commons/commit/8ca727fffc2cc137b978b7d65ed586da405b015b)
#### [v1.3.1](https://github.com/oceanprotocol/commons/compare/v1.3.0...v1.3.1) #### [v1.3.1](https://github.com/oceanprotocol/commons/compare/v1.3.0...v1.3.1)

View File

@ -13,6 +13,16 @@ const oceanMock = {
} }
}, },
assets: { assets: {
query: () => {
return {
results: [],
page: 1,
/* eslint-disable @typescript-eslint/camelcase */
total_pages: 1611,
total_results: 1611
/* eslint-enable @typescript-eslint/camelcase */
}
},
resolve: jest.fn(), resolve: jest.fn(),
order: () => { order: () => {
return { return {

8594
client/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
{ {
"name": "commons-client", "name": "commons-client",
"description": "Ocean Protocol marketplace frontend to explore, download, and publish open data sets.", "description": "Ocean Protocol marketplace frontend to explore, download, and publish open data sets.",
"version": "1.3.2", "version": "2.0.0-beta.3",
"license": "Apache-2.0", "license": "Apache-2.0",
"scripts": { "scripts": {
"start": "react-scripts start", "start": "react-scripts start",
@ -14,53 +14,52 @@
}, },
"dependencies": { "dependencies": {
"@oceanprotocol/art": "^2.2.0", "@oceanprotocol/art": "^2.2.0",
"@oceanprotocol/squid": "^0.8.3", "@oceanprotocol/squid": "^1.0.0",
"@oceanprotocol/typographies": "^0.1.0", "@oceanprotocol/typographies": "^0.1.0",
"@sindresorhus/slugify": "^0.9.1", "@sindresorhus/slugify": "^0.9.1",
"@truffle/hdwallet-provider": "^1.0.23", "@truffle/hdwallet-provider": "^1.0.26",
"axios": "^0.19.0", "axios": "^0.19.0",
"bip39": "^3.0.2", "bip39": "^3.0.2",
"classnames": "^2.2.6", "classnames": "^2.2.6",
"ethereum-blockies": "github:MyEtherWallet/blockies", "ethereum-blockies": "github:MyEtherWallet/blockies",
"filesize": "^6.0.0", "filesize": "^6.0.1",
"history": "^4.10.1", "history": "^4.10.1",
"ipfs": "^0.39.0",
"ipfs-http-client": "^39.0.2", "ipfs-http-client": "^39.0.2",
"is-url-superb": "^3.0.0", "is-url-superb": "^3.0.0",
"moment": "^2.24.0", "moment": "^2.24.0",
"query-string": "^6.8.3", "query-string": "^6.9.0",
"react": "^16.11.0", "react": "^16.12.0",
"react-collapsed": "^2.2.2", "react-collapsed": "^2.2.3",
"react-datepicker": "^2.9.6", "react-datepicker": "^2.10.1",
"react-dom": "^16.11.0", "react-dom": "^16.12.0",
"react-dotdotdot": "^1.3.1", "react-dotdotdot": "^1.3.1",
"react-dropzone": "^10.1.10", "react-dropzone": "^10.2.1",
"react-ga": "^2.7.0", "react-ga": "^2.7.0",
"react-helmet": "^5.2.1", "react-helmet": "^5.2.1",
"react-markdown": "^4.2.2", "react-markdown": "^4.2.2",
"react-modal": "^3.11.1", "react-modal": "^3.11.1",
"react-moment": "^0.9.6", "react-moment": "^0.9.6",
"react-paginate": "^6.3.2", "react-paginate": "^6.3.2",
"react-popper": "^1.3.5", "react-popper": "^1.3.6",
"react-router-dom": "^5.1.2", "react-router-dom": "^5.1.2",
"react-transition-group": "^4.3.0", "react-transition-group": "^4.3.0",
"shortid": "^2.2.15", "shortid": "^2.2.15",
"web3": "^1.2.2" "web3": "^1.2.4"
}, },
"devDependencies": { "devDependencies": {
"@react-mock/state": "^0.1.8", "@react-mock/state": "^0.1.8",
"@testing-library/jest-dom": "^4.2.3", "@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2", "@testing-library/react": "^9.3.2",
"@types/classnames": "^2.2.9", "@types/classnames": "^2.2.9",
"@types/is-url": "^1.2.28", "@types/is-url": "^1.2.28",
"@types/jest": "^24.0.22", "@types/jest": "^24.0.23",
"@types/react": "^16.9.11", "@types/react": "^16.9.15",
"@types/react-datepicker": "^2.9.3", "@types/react-datepicker": "^2.9.5",
"@types/react-dom": "^16.9.4", "@types/react-dom": "^16.9.4",
"@types/react-helmet": "^5.0.14", "@types/react-helmet": "^5.0.14",
"@types/react-modal": "^3.10.0", "@types/react-modal": "^3.10.0",
"@types/react-paginate": "^6.2.1", "@types/react-paginate": "^6.2.1",
"@types/react-router-dom": "^5.1.2", "@types/react-router-dom": "^5.1.3",
"@types/react-transition-group": "^4.2.3", "@types/react-transition-group": "^4.2.3",
"@types/shortid": "^0.0.29", "@types/shortid": "^0.0.29",
"@typescript-eslint/eslint-plugin": "^1.6.0", "@typescript-eslint/eslint-plugin": "^1.6.0",
@ -69,8 +68,8 @@
"jest-mock-axios": "^3.1.2", "jest-mock-axios": "^3.1.2",
"node-sass": "^4.13.0", "node-sass": "^4.13.0",
"react-scripts": "3.0.1", "react-scripts": "3.0.1",
"source-map-explorer": "^2.1.0", "source-map-explorer": "^2.1.2",
"typescript": "^3.7.2" "typescript": "^3.7.3"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -17,18 +17,18 @@ const AssetTeaser = ({
list?: boolean list?: boolean
minimal?: boolean minimal?: boolean
}) => { }) => {
const { metadata } = asset.findServiceByType('Metadata') const { attributes } = asset.findServiceByType('metadata')
const { base } = metadata const { main, additionalInformation } = attributes
return list ? ( return list ? (
<article className={styles.assetList}> <article className={styles.assetList}>
<Link to={`/asset/${asset.id}`}> <Link to={`/asset/${asset.id}`}>
<h1>{base.name}</h1> <h1>{main.name}</h1>
<div <div
className={styles.date} className={styles.date}
title={`Published on ${base.datePublished}`} title={`Published on ${main.datePublished}`}
> >
{moment(base.datePublished, 'YYYYMMDD').fromNow()} {moment(main.datePublished, 'YYYYMMDD').fromNow()}
</div> </div>
</Link> </Link>
</article> </article>
@ -39,22 +39,29 @@ const AssetTeaser = ({
} }
> >
<Link to={`/asset/${asset.id}`}> <Link to={`/asset/${asset.id}`}>
{base.categories && !minimal && ( {additionalInformation.categories && !minimal && (
<CategoryImage dimmed category={base.categories[0]} /> <CategoryImage
dimmed
category={additionalInformation.categories[0]}
/>
)} )}
<h1>{base.name}</h1> <h1>{main.name}</h1>
{!minimal && ( {!minimal && (
<div className={styles.description}> <div className={styles.description}>
<Dotdotdot clamp={3}>{base.description}</Dotdotdot> <Dotdotdot clamp={3}>
{additionalInformation.description}
</Dotdotdot>
</div> </div>
)} )}
<footer className={styles.assetFooter}> <footer className={styles.assetFooter}>
{base.categories && <div>{base.categories[0]}</div>} {additionalInformation.categories && (
<div>{additionalInformation.categories[0]}</div>
)}
{allowPricing && ( {allowPricing && (
<div className={styles.price}> <div className={styles.price}>
<span> <span>
{Web3.utils.fromWei(base.price.toString())} {Web3.utils.fromWei(main.price.toString())}
</span>{' '} </span>{' '}
OCEAN OCEAN
</div> </div>

View File

@ -37,7 +37,7 @@ export default class AssetsLatest extends PureComponent<{}, AssetsLatestState> {
} }
try { try {
const search = await ocean.aquarius.queryMetadata(searchQuery) const search = await ocean.assets.query(searchQuery)
this.setState({ this.setState({
latestAssets: search.results, latestAssets: search.results,
isLoadingLatest: false isLoadingLatest: false

View File

@ -52,7 +52,7 @@ export default class ChannelTeaser extends Component<
} }
try { try {
const search = await ocean.aquarius.queryMetadata(searchQuery) const search = await ocean.assets.query(searchQuery)
this.setState({ this.setState({
channelAssets: search.results, channelAssets: search.results,
isLoadingChannel: false isLoadingChannel: false

View File

@ -9,7 +9,7 @@ describe('AssetDetails', () => {
it('renders loading without crashing', () => { it('renders loading without crashing', () => {
const { container } = render( const { container } = render(
<AssetDetails <AssetDetails
metadata={({ base: { name: '' } } as any) as MetaData} metadata={({ main: { name: '' } } as any) as MetaData}
ddo={({} as any) as DDO} ddo={({} as any) as DDO}
/> />
) )
@ -22,11 +22,13 @@ describe('AssetDetails', () => {
<AssetDetails <AssetDetails
metadata={ metadata={
({ ({
base: { main: {
name: 'Hello', name: 'Hello',
description: 'Description',
categories: ['Category'],
files: [{ index: 0 }] files: [{ index: 0 }]
},
additionalInformation: {
description: 'Description',
categories: ['Category']
} }
} as any) as MetaData } as any) as MetaData
} }

View File

@ -31,18 +31,18 @@ const MetaFixedItem = ({ name, value }: { name: string; value: string }) => (
) )
export default function AssetDetails({ metadata, ddo }: AssetDetailsProps) { export default function AssetDetails({ metadata, ddo }: AssetDetailsProps) {
const { base } = metadata const { main, additionalInformation } = metadata
const price = base.price && Web3.utils.fromWei(base.price.toString()) const price = main.price && Web3.utils.fromWei(main.price.toString())
const metaFixed = [ const metaFixed = [
{ {
name: 'Author', name: 'Author',
value: base.author, value: main.author,
show: true show: true
}, },
{ {
name: 'License', name: 'License',
value: base.license, value: main.license,
show: true show: true
}, },
{ {
@ -60,36 +60,45 @@ export default function AssetDetails({ metadata, ddo }: AssetDetailsProps) {
return ( return (
<> <>
<aside className={styles.metaPrimary}> <aside className={styles.metaPrimary}>
<h2 className={styles.copyrightHolder} title="Copyright Holder"> {additionalInformation &&
{base.copyrightHolder} additionalInformation.copyrightHolder && (
</h2> <h2
className={styles.copyrightHolder}
title="Copyright Holder"
>
{additionalInformation.copyrightHolder}
</h2>
)}
<div className={styles.metaPrimaryData}> <div className={styles.metaPrimaryData}>
<span <span
title={`Date created, published on ${base.datePublished}`} title={`Date created, published on ${main.datePublished}`}
> >
<Moment <Moment
date={base.dateCreated} date={main.dateCreated}
format="L" format="L"
interval={0} interval={0}
/> />
</span> </span>
{base.categories && ( {additionalInformation &&
<CategoryLink category={base.categories[0]} /> additionalInformation.categories && (
)} <CategoryLink
category={additionalInformation.categories[0]}
/>
)}
{base.files && datafilesLine(base.files)} {main.files && datafilesLine(main.files)}
</div> </div>
</aside> </aside>
{base.description && ( {additionalInformation && additionalInformation.description && (
<Markdown <Markdown
text={base.description} text={additionalInformation.description}
className={styles.description} className={styles.description}
/> />
)} )}
<Report did={ddo.id} title={metadata.base.name} /> <Report did={ddo.id} title={main.name} />
<div className={styles.metaFixed}> <div className={styles.metaFixed}>
<h2 <h2
@ -111,7 +120,7 @@ export default function AssetDetails({ metadata, ddo }: AssetDetailsProps) {
</ul> </ul>
</div> </div>
<AssetFilesDetails files={base.files ? base.files : []} ddo={ddo} /> <AssetFilesDetails files={main.files ? main.files : []} ddo={ddo} />
</> </>
) )
} }

View File

@ -14,13 +14,13 @@ const file = {
index: 0, index: 0,
url: 'https://hello.com', url: 'https://hello.com',
contentType: 'application/x-zip', contentType: 'application/x-zip',
contentLength: 100 contentLength: '100'
} }
const ddo = ({ const ddo = ({
id: 'xxx', id: 'xxx',
findServiceByType: () => { findServiceByType: () => {
return { serviceDefinitionId: 'xxx' } return { index: 'xxx' }
} }
} as any) as DDO } as any) as DDO

View File

@ -59,7 +59,7 @@ export default class AssetFile extends PureComponent<
try { try {
const accounts = await ocean.accounts.list() const accounts = await ocean.accounts.list()
const service = ddo.findServiceByType('Access') const service = ddo.findServiceByType('access')
const agreements = await ocean.keeper.conditions.accessSecretStoreCondition.getGrantedDidByConsumer( const agreements = await ocean.keeper.conditions.accessSecretStoreCondition.getGrantedDidByConsumer(
accounts[0].id accounts[0].id
@ -74,7 +74,7 @@ export default class AssetFile extends PureComponent<
;({ agreementId } = agreement) ;({ agreementId } = agreement)
} else { } else {
agreementId = await ocean.assets agreementId = await ocean.assets
.order(ddo.id, service.serviceDefinitionId, accounts[0]) .order(ddo.id, service.index, accounts[0])
.next((step: number) => this.setState({ step })) .next((step: number) => this.setState({ step }))
} }
@ -84,7 +84,7 @@ export default class AssetFile extends PureComponent<
const path = await ocean.assets.consume( const path = await ocean.assets.consume(
agreementId, agreementId,
ddo.id, ddo.id,
service.serviceDefinitionId, service.index,
accounts[0], accounts[0],
'', '',
index index
@ -119,11 +119,9 @@ export default class AssetFile extends PureComponent<
<ul key={index} className={styles.file}> <ul key={index} className={styles.file}>
{contentType || contentLength ? ( {contentType || contentLength ? (
<> <>
<li>{cleanupContentType(contentType)}</li>
<li> <li>
{contentType && cleanupContentType(contentType)} {contentLength && contentLength !== '0'
</li>
<li>
{contentLength && contentLength > 0
? filesize(contentLength) ? filesize(contentLength)
: ''} : ''}
</li> </li>

View File

@ -23,6 +23,7 @@ interface AssetState {
ddo: DDO ddo: DDO
metadata: MetaData metadata: MetaData
error: string error: string
isLoading: boolean
} }
class Asset extends Component<AssetProps, AssetState> { class Asset extends Component<AssetProps, AssetState> {
@ -30,8 +31,9 @@ class Asset extends Component<AssetProps, AssetState> {
public state = { public state = {
ddo: ({} as any) as DDO, ddo: ({} as any) as DDO,
metadata: ({ base: { name: '' } } as any) as MetaData, metadata: ({ main: { name: '' } } as any) as MetaData,
error: '' error: '',
isLoading: true
} }
public async componentDidMount() { public async componentDidMount() {
@ -42,8 +44,12 @@ class Asset extends Component<AssetProps, AssetState> {
try { try {
const { ocean } = this.context const { ocean } = this.context
const ddo = await ocean.assets.resolve(this.props.match.params.did) const ddo = await ocean.assets.resolve(this.props.match.params.did)
const { metadata } = ddo.findServiceByType('Metadata') const { attributes } = ddo.findServiceByType('metadata')
this.setState({ ddo, metadata }) this.setState({
ddo,
metadata: attributes,
isLoading: false
})
} catch (error) { } catch (error) {
Logger.error(error.message) Logger.error(error.message)
this.setState({ this.setState({
@ -53,8 +59,9 @@ class Asset extends Component<AssetProps, AssetState> {
} }
public render() { public render() {
const { metadata, ddo, error } = this.state const { metadata, ddo, error, isLoading } = this.state
const isLoading = metadata.base.name === '' const { main, additionalInformation } = metadata
const hasError = error !== '' const hasError = error !== ''
return isLoading && !hasError ? ( return isLoading && !hasError ? (
@ -68,13 +75,14 @@ class Asset extends Component<AssetProps, AssetState> {
</Content> </Content>
) : ( ) : (
<Route <Route
title={metadata.base.name} title={main.name}
image={ image={
metadata.base.categories && ( additionalInformation &&
additionalInformation.categories && (
<CategoryImage <CategoryImage
header header
dimmed dimmed
category={metadata.base.categories[0]} category={additionalInformation.categories[0]}
/> />
) )
} }

View File

@ -68,7 +68,7 @@ export default class Channel extends PureComponent<ChannelProps, ChannelState> {
} }
try { try {
const search = await ocean.aquarius.queryMetadata(searchQuery) const search = await ocean.assets.query(searchQuery)
this.setState({ this.setState({
results: search.results, results: search.results,
totalResults: search.totalResults, totalResults: search.totalResults,

View File

@ -1,8 +1,10 @@
import Web3 from 'web3' import Web3 from 'web3'
import { nodeUri } from '../config'
import HDWalletProvider from '@truffle/hdwallet-provider' import HDWalletProvider from '@truffle/hdwallet-provider'
import { nodeUri } from '../config'
import { requestFromFaucet } from '../ocean' import { requestFromFaucet } from '../ocean'
const bip39 = require('bip39') // eslint-disable-line @typescript-eslint/no-var-requires
// eslint-disable-next-line @typescript-eslint/no-var-requires
const bip39 = require('bip39')
export class BurnerWalletProvider { export class BurnerWalletProvider {
private web3: Web3 private web3: Web3
@ -12,10 +14,6 @@ export class BurnerWalletProvider {
this.web3 = null as any this.web3 = null as any
} }
public async isAvailable() {
return true
}
public async isLogged() { public async isLogged() {
if (localStorage.getItem('seedphrase') !== null) { if (localStorage.getItem('seedphrase') !== null) {
return true return true
@ -35,7 +33,7 @@ export class BurnerWalletProvider {
} }
localStorage.setItem('logType', 'BurnerWallet') localStorage.setItem('logType', 'BurnerWallet')
const provider = new HDWalletProvider(mnemonic, `${nodeUri}`, 0, 1) const provider = new HDWalletProvider(mnemonic, nodeUri, 0, 1)
this.web3 = new Web3(provider as any) this.web3 = new Web3(provider as any)
const accounts = await this.web3.eth.getAccounts() const accounts = await this.web3.eth.getAccounts()
const balance = await this.web3.eth.getBalance(accounts[0]) const balance = await this.web3.eth.getBalance(accounts[0])

View File

@ -59,7 +59,7 @@ export default class MarketProvider extends PureComponent<
try { try {
const { ocean } = this.props const { ocean } = this.props
const search = await ocean.aquarius.queryMetadata(searchQuery) const search = await ocean.assets.query(searchQuery)
this.setState({ totalAssets: search.totalResults }) this.setState({ totalAssets: search.totalResults })
} catch (error) { } catch (error) {
Logger.error('Error', error.message) Logger.error('Error', error.message)

View File

@ -24,6 +24,7 @@ export default function useIpfsApi(config: IpfsConfig) {
ipfsMessage = 'Checking IPFS gateway...' ipfsMessage = 'Checking IPFS gateway...'
try { try {
// eslint-disable-next-line require-atomic-updates
ipfs = await ipfsClient(config) ipfs = await ipfsClient(config)
const version = await ipfs.version() const version = await ipfs.version()
ipfsVersion = version.version ipfsVersion = version.version
@ -38,7 +39,6 @@ export default function useIpfsApi(config: IpfsConfig) {
}, [config]) }, [config])
useEffect(() => { useEffect(() => {
// just like componentWillUnmount()
return function cleanup() { return function cleanup() {
if (ipfs) { if (ipfs) {
setIpfsReady(false) setIpfsReady(false)

View File

@ -1,27 +0,0 @@
import React from 'react'
import { render, wait, act } from '@testing-library/react'
import useIpfs from './use-ipfs'
export default function TestComponent() {
const { ipfsVersion, isIpfsReady, ipfsError, ipfsMessage } = useIpfs()
return (
<div>
{isIpfsReady && <span>Ready</span>}
{ipfsVersion} - {ipfsMessage} - {ipfsError}
</div>
)
}
describe('use-ipfs', () => {
it('renders without crashing', async () => {
let element: any
await act(async () => {
element = render(<TestComponent />)
})
expect(element.container.firstChild).toBeInTheDocument()
await wait(() => element.getByText('Ready'))
})
})

View File

@ -1,74 +0,0 @@
/* eslint-disable no-console */
import Ipfs from 'ipfs'
import { useEffect, useState } from 'react'
import os from 'os'
import shortid from 'shortid'
let ipfs: any = null
let ipfsMessage = ''
let ipfsVersion = ''
export default function useIpfs() {
const [isIpfsReady, setIpfsReady] = useState(Boolean(ipfs))
const [ipfsError, setIpfsError] = useState('')
useEffect(() => {
async function startIpfs() {
ipfsMessage = 'Starting IPFS...'
if (ipfs) {
console.log('IPFS already started')
// } else if (window.ipfs && window.ipfs.enable) {
// console.log('Found window.ipfs')
// ipfs = await window.ipfs.enable()
} else {
try {
const message = 'IPFS started'
console.time(message)
ipfs = await Ipfs.create({
repo: `${os.homedir()}/.jsipfs-${shortid.generate()}`,
config: {
Addresses: {
// 0 for port so system just assigns a new free port
// to allow multiple nodes running at same time
Swarm: ['/ip4/0.0.0.0/tcp/0']
}
}
})
console.timeEnd(message)
ipfsMessage = message
const { agentVersion } = await ipfs.id()
ipfsVersion = agentVersion
} catch (error) {
const message = `IPFS init error: ${error.message}`
ipfsMessage = message
console.error(message)
ipfs = null
setIpfsError(error.message)
}
}
setIpfsReady(Boolean(ipfs))
}
startIpfs()
// just like componentWillUnmount()
return function cleanup() {
if (ipfs && ipfs.stop) {
console.time('IPFS stopped')
ipfs.stop()
setIpfsReady(false)
ipfs = null
ipfsMessage = ''
ipfsVersion = ''
setIpfsError('')
console.timeEnd('IPFS stopped')
}
}
}, [])
return { ipfs, ipfsVersion, isIpfsReady, ipfsError, ipfsMessage }
}

View File

@ -1,24 +1,21 @@
const AssetModel = { import { MetaData } from '@oceanprotocol/squid'
assetId: null,
publisherId: null,
const AssetModel: MetaData = {
// OEP-08 Attributes // OEP-08 Attributes
// https://github.com/oceanprotocol/OEPs/tree/master/8 // https://github.com/oceanprotocol/OEPs/tree/master/8
base: { main: {
name: null, type: 'dataset',
description: null, name: '',
dateCreated: null, dateCreated: '',
author: null, author: '',
type: '', license: '',
license: null, price: '',
copyrightHolder: null, files: []
workExample: '', },
files: [], additionalInformation: {
categories: [], description: '',
links: [], copyrightHolder: '',
inLanguage: '', categories: []
tags: [],
price: ''
} }
} }

View File

@ -26,19 +26,4 @@ describe('IPFS', () => {
const addingText = await waitForElement(() => getByText(/Adding /)) const addingText = await waitForElement(() => getByText(/Adding /))
expect(addingText).toBeDefined() expect(addingText).toBeDefined()
}) })
// it('Local Node: files can be dropped', async () => {
// const { debug, container, findByText, getByText } = render(
// <Ipfs addFile={addFile} node />
// )
// expect(container).toBeInTheDocument()
// // wait for IPFS node
// await findByText(/IPFS started/)
// // drop a file
// const dropzoneInput = container.querySelector('.dropzone input')
// Object.defineProperty(dropzoneInput, 'files', { value: [file] })
// dropzoneInput && fireEvent.drop(dropzoneInput)
// await waitForElement(() => getByText(/File found/), { timeout: 100000 })
// expect(addFile).toHaveBeenCalledTimes(1)
// })
}) })

View File

@ -8,7 +8,7 @@ describe('Item', () => {
url: 'https://hello.com/hello.zip', url: 'https://hello.com/hello.zip',
found: true, found: true,
contentType: 'application/zip', contentType: 'application/zip',
contentLength: 10 contentLength: '10'
} }
const { container } = render( const { container } = render(
<Item item={item} removeItem={() => null} /> <Item item={item} removeItem={() => null} />
@ -21,7 +21,7 @@ describe('Item', () => {
url: 'https://hello.com/hello.zip', url: 'https://hello.com/hello.zip',
found: false, found: false,
contentType: '', contentType: '',
contentLength: 10 contentLength: '10'
} }
const { container } = render( const { container } = render(
<Item item={item} removeItem={() => null} /> <Item item={item} removeItem={() => null} />

View File

@ -11,7 +11,7 @@ const Item = ({
url: string url: string
found: boolean found: boolean
contentType: string contentType: string
contentLength: number contentLength: string
} }
removeFile(): void removeFile(): void
}) => ( }) => (

View File

@ -14,7 +14,7 @@ const files = [
url: 'https://hello.com', url: 'https://hello.com',
checksum: 'cccccc', checksum: 'cccccc',
checksumType: 'MD5', checksumType: 'MD5',
contentLength: 100, contentLength: '100',
contentType: 'application/zip', contentType: 'application/zip',
resourceId: 'xxx', resourceId: 'xxx',
encoding: 'UTF-8', encoding: 'UTF-8',
@ -28,14 +28,14 @@ const mockResponse = {
result: { result: {
url: 'https://demo.com', url: 'https://demo.com',
contentType: 'application/zip', contentType: 'application/zip',
contentLength: 237347827, contentLength: '237347827',
found: true found: true
} }
} }
} }
const renderComponent = () => describe('Files', () => {
render( const ui = (
<Files <Files
files={files} files={files}
placeholder="Hello" placeholder="Hello"
@ -44,16 +44,15 @@ const renderComponent = () =>
/> />
) )
describe('Files', () => { it('renders without crashing', () => {
it('renders without crashing', async () => { const { container } = render(ui)
const { container } = renderComponent()
expect(container.firstChild).toBeInTheDocument() expect(container.firstChild).toBeInTheDocument()
expect(container.querySelector('.itemForm')).not.toBeInTheDocument() expect(container.querySelector('.itemForm')).not.toBeInTheDocument()
}) })
it('new file form can be opened and closed', async () => { it('new file form can be opened and closed', async () => {
const { container, getByText } = renderComponent() const { container, getByText } = render(ui)
// open // open
fireEvent.click(getByText('+ From URL')) fireEvent.click(getByText('+ From URL'))
@ -67,7 +66,7 @@ describe('Files', () => {
}) })
it('new IPFS file form can be opened and closed', async () => { it('new IPFS file form can be opened and closed', async () => {
const { getByText } = renderComponent() const { getByText } = render(ui)
// open // open
fireEvent.click(getByText('+ Add to IPFS')) fireEvent.click(getByText('+ Add to IPFS'))
@ -82,15 +81,15 @@ describe('Files', () => {
expect(text).not.toBeInTheDocument() expect(text).not.toBeInTheDocument()
}) })
it('item can be removed', async () => { it('item can be removed', () => {
const { getByTitle } = renderComponent() const { getByTitle } = render(ui)
fireEvent.click(getByTitle('Remove item')) fireEvent.click(getByTitle('Remove item'))
expect(files.length).toBe(0) expect(files.length).toBe(0)
}) })
it('item can be added', async () => { it('item can be added', async () => {
const { getByText, getByPlaceholderText } = renderComponent() const { getByText, getByPlaceholderText } = render(ui)
fireEvent.click(getByText('+ From URL')) fireEvent.click(getByText('+ From URL'))
await waitForElement(() => getByText('- Cancel')) await waitForElement(() => getByText('- Cancel'))

View File

@ -280,23 +280,28 @@ class Publish extends Component<{}, PublishState> {
const newAsset = { const newAsset = {
// OEP-08 Attributes // OEP-08 Attributes
// https://github.com/oceanprotocol/OEPs/tree/master/8 // https://github.com/oceanprotocol/OEPs/tree/master/8
base: Object.assign(AssetModel.base, { main: Object.assign(AssetModel.main, {
type: this.state.type,
name: this.state.name, name: this.state.name,
description: this.state.description,
dateCreated: dateCreated:
new Date(this.state.dateCreated) new Date(this.state.dateCreated)
.toISOString() .toISOString()
.split('.')[0] + 'Z', // remove milliseconds .split('.')[0] + 'Z', // remove milliseconds
author: this.state.author, author: this.state.author,
license: this.state.license, license: this.state.license,
copyrightHolder: this.state.copyrightHolder,
files,
price: allowPricing price: allowPricing
? Web3.utils.toWei(this.state.price, 'ether') ? Web3.utils.toWei(this.state.price, 'ether')
: this.state.price, : this.state.price,
type: this.state.type, files
categories: [this.state.categories] }),
}) additionalInformation: Object.assign(
AssetModel.additionalInformation,
{
description: this.state.description,
copyrightHolder: this.state.copyrightHolder,
categories: [this.state.categories]
}
)
} }
try { try {

View File

@ -90,7 +90,7 @@ class Search extends PureComponent<SearchProps, SearchState> {
} }
try { try {
const search = await ocean.aquarius.queryMetadata(searchQuery) const search = await ocean.assets.query(searchQuery)
this.setState({ this.setState({
results: search.results, results: search.results,
totalResults: search.totalResults, totalResults: search.totalResults,

View File

@ -1,3 +1 @@
/* eslint-disable no-console */
import '@testing-library/jest-dom/extend-expect' import '@testing-library/jest-dom/extend-expect'

View File

@ -1,190 +0,0 @@
{
"@context": "https://w3id.org/did/v1",
"id": "did:op:52f2ed716f97463e97beeb414195a075b606675874204e3da39b0c237377dbd3",
"publicKey": [
{
"id": "did:op:52f2ed716f97463e97beeb414195a075b606675874204e3da39b0c237377dbd3",
"type": "EthereumECDSAKey",
"owner": "0x5e3264A651303b93A3a3BC5eaB5c8676f5C3D7b1"
}
],
"authentication": [
{
"type": "RsaSignatureAuthentication2018",
"publicKey": "did:op:52f2ed716f97463e97beeb414195a075b606675874204e3da39b0c237377dbd3"
}
],
"service": [
{
"type": "Access",
"creator": "",
"purchaseEndpoint": "https://brizo.duero.dev-ocean.com:443/api/v1/brizo/services/access/initialize",
"serviceEndpoint": "https://brizo.duero.dev-ocean.com:443/api/v1/brizo/services/consume",
"name": "dataAssetAccessServiceAgreement",
"templateId": "0xfA16d26e9F4fffC6e40963B281a0bB08C31ed40C",
"serviceAgreementTemplate": {
"contractName": "EscrowAccessSecretStoreTemplate",
"events": [
{
"name": "AgreementCreated",
"actorType": "consumer",
"handler": {
"moduleName": "escrowAccessSecretStoreTemplate",
"functionName": "fulfillLockRewardCondition",
"version": "0.1"
}
}
],
"fulfillmentOrder": [
"lockReward.fulfill",
"accessSecretStore.fulfill",
"escrowReward.fulfill"
],
"conditionDependency": {
"lockReward": [],
"accessSecretStore": [],
"escrowReward": ["lockReward", "accessSecretStore"]
},
"conditions": [
{
"name": "lockReward",
"timelock": 0,
"timeout": 0,
"contractName": "LockRewardCondition",
"functionName": "fulfill",
"parameters": [
{
"name": "_rewardAddress",
"type": "address",
"value": "0x5e3264A651303b93A3a3BC5eaB5c8676f5C3D7b1"
},
{ "name": "_amount", "type": "uint256", "value": 0 }
],
"events": [
{
"name": "Fulfilled",
"actorType": "publisher",
"handler": {
"moduleName": "lockRewardCondition",
"functionName": "fulfillAccessSecretStoreCondition",
"version": "0.1"
}
}
]
},
{
"name": "accessSecretStore",
"timelock": 0,
"timeout": 0,
"contractName": "AccessSecretStoreCondition",
"functionName": "fulfill",
"parameters": [
{
"name": "_documentId",
"type": "bytes32",
"value": "52f2ed716f97463e97beeb414195a075b606675874204e3da39b0c237377dbd3"
},
{ "name": "_grantee", "type": "address", "value": "" }
],
"events": [
{
"name": "Fulfilled",
"actorType": "publisher",
"handler": {
"moduleName": "accessSecretStore",
"functionName": "fulfillEscrowRewardCondition",
"version": "0.1"
}
},
{
"name": "TimedOut",
"actorType": "consumer",
"handler": {
"moduleName": "accessSecretStore",
"functionName": "fulfillEscrowRewardCondition",
"version": "0.1"
}
}
]
},
{
"name": "escrowReward",
"timelock": 0,
"timeout": 0,
"contractName": "EscrowReward",
"functionName": "fulfill",
"parameters": [
{ "name": "_amount", "type": "uint256", "value": 0 },
{ "name": "_receiver", "type": "address", "value": "" },
{ "name": "_sender", "type": "address", "value": "" },
{ "name": "_lockCondition", "type": "bytes32", "value": "" },
{ "name": "_releaseCondition", "type": "bytes32", "value": "" }
],
"events": [
{
"name": "Fulfilled",
"actorType": "publisher",
"handler": {
"moduleName": "escrowRewardCondition",
"functionName": "verifyRewardTokens",
"version": "0.1"
}
}
]
}
]
},
"serviceDefinitionId": "0"
},
{
"type": "Authorization",
"service": "SecretStore",
"serviceEndpoint": "https://secret-store.duero.dev-ocean.com:443",
"serviceDefinitionId": "1"
},
{
"type": "Metadata",
"serviceEndpoint": "https://aquarius.duero.dev-ocean.com:443/api/v1/aquarius/assets/ddo/did:op:52f2ed716f97463e97beeb414195a075b606675874204e3da39b0c237377dbd3",
"metadata": {
"curation": { "rating": 0.0, "numVotes": 0, "isListed": true },
"base": {
"name": "Technical Whitepaper",
"description": "This paper presents Ocean Protocol. Ocean is a decentralized protocol and network of artificial intelligence (AI) data/services. \n\nOcean does decentralized orchestration: at its core are decentralized service agreements and decentralized access control, which execute on decentralized virtual machines. This allows connection to, monetization of, and curation of arbitrary data services. On that, Ocean adds network rewards to incentivize data sharing, including privacy-preserving data commons.",
"dateCreated": "2019-05-10T11:55:58.492Z",
"author": "Ocean Protocol",
"type": "dataset",
"license": "Public Domain",
"copyrightHolder": "Ocean Protocol Foundation Ltd.",
"files": [
{
"found": true,
"contentLength": "2989228",
"contentType": "application/pdf",
"compression": "none",
"index": 0
}
],
"categories": ["Engineering"],
"links": [],
"tags": "",
"price": 0,
"encryptedFiles": "0x95116a697eadb4b5058682749f587321cb918ec6239a193a7e1e3587d7de28e761e8819e2241e9375b035eacc3dcec4799e0da4cd52552ab583082366ff4e0fb1f72a63ae071206859cfc53abdea2135c660cfba1e81361efce10bfcec323d63b0dcf009dd2c48dfcde09c95dcf69d6c6a318e869ac26b7dc0fcb085e1421b394aaf4d4fac05e992c13a225c5c1e138a7fb27185ba5e1709760ecd43e89eafef435ad97ffb",
"checksum": "9b624a8f9cd7f9d1127c818f32453f43dc6c633472a682bb880d69093b4b9615",
"datePublished": "2019-05-10T14:40:01Z"
},
"additionalInformation": {
"updateFrequency": null,
"structuredMarkup": []
}
},
"serviceDefinitionId": "2"
}
],
"created": "2019-05-10T14:39:53Z",
"proof": {
"created": "2019-05-10T14:39:55Z",
"creator": "0x5e3264A651303b93A3a3BC5eaB5c8676f5C3D7b1",
"type": "DDOIntegritySignature",
"signatureValue": "0x94c3042facdb0601cb5c90264b1e8d1ae6902043af4303c57869d2881748621b03d943f4bb2ccd5d18429964f4ebc425d77baffc576884cfd78ae0987082c5931b"
}
}

View File

@ -8,7 +8,7 @@ describe('Search', () => {
it('should search for assets from homepage', () => { it('should search for assets from homepage', () => {
// Fill search phrase // Fill search phrase
cy.get('input#search').type('Title test') cy.get('input#search').type('Commons Integration Test')
// Start search // Start search
cy.get('button') cy.get('button')
.contains('Search') .contains('Search')

View File

@ -11,15 +11,15 @@
}, },
{ {
"name": "brizo", "name": "brizo",
"version": "~0.4.6" "version": "~0.7.2"
}, },
{ {
"name": "aquarius", "name": "aquarius",
"version": "~0.3.9" "version": "~1.0.5"
}, },
{ {
"name": "squid-js", "name": "squid-js",
"version": "~0.8.3" "version": "~1.0.0"
}, },
{ {
"name": "faucet", "name": "faucet",

703
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
{ {
"name": "commons", "name": "commons",
"description": "Ocean Protocol marketplace to explore, download, and publish open data sets.", "description": "Ocean Protocol marketplace to explore, download, and publish open data sets.",
"version": "1.3.2", "version": "2.0.0-beta.3",
"license": "Apache-2.0", "license": "Apache-2.0",
"scripts": { "scripts": {
"install": "./scripts/install.sh", "install": "./scripts/install.sh",
@ -29,22 +29,22 @@
"@typescript-eslint/parser": "^1.6.0", "@typescript-eslint/parser": "^1.6.0",
"auto-changelog": "^1.16.2", "auto-changelog": "^1.16.2",
"concurrently": "^5.0.0", "concurrently": "^5.0.0",
"cypress": "^3.6.0", "cypress": "^3.7.0",
"cypress-log-to-output": "^1.0.7", "cypress-log-to-output": "^1.0.7",
"eslint": "^5.16.0", "eslint": "^5.16.0",
"eslint-config-oceanprotocol": "1.4.0", "eslint-config-oceanprotocol": "^1.4.0",
"eslint-config-prettier": "^6.5.0", "eslint-config-prettier": "^6.5.0",
"eslint-plugin-cypress": "^2.7.0", "eslint-plugin-cypress": "^2.7.0",
"eslint-plugin-prettier": "^3.1.1", "eslint-plugin-prettier": "^3.1.1",
"prettier": "^1.18.2", "prettier": "^1.19.1",
"prettier-stylelint": "^0.4.2", "prettier-stylelint": "^0.4.2",
"release-it": "^12.4.3", "release-it": "^12.4.3",
"start-server-and-test": "^1.10.6", "start-server-and-test": "^1.10.6",
"stylelint": "^11.1.1", "stylelint": "^12.0.0",
"stylelint-config-bigchaindb": "^1.2.2", "stylelint-config-bigchaindb": "^1.2.2",
"stylelint-config-css-modules": "^1.5.0", "stylelint-config-css-modules": "^2.1.0",
"stylelint-config-standard": "^19.0.0", "stylelint-config-standard": "^19.0.0",
"typescript": "^3.7.2" "typescript": "^3.7.3"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

224
server/package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "commons-server", "name": "commons-server",
"version": "1.3.2", "version": "2.0.0-beta.3",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -514,20 +514,14 @@
} }
}, },
"@types/jest": { "@types/jest": {
"version": "24.0.22", "version": "24.0.23",
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-24.0.22.tgz", "resolved": "https://registry.npmjs.org/@types/jest/-/jest-24.0.23.tgz",
"integrity": "sha512-t2OvhNZnrNjlzi2i0/cxbLVM59WN15I2r1Qtb7wDv28PnV9IzrPtagFRey/S9ezdLD0zyh1XGMQIEQND2YEfrw==", "integrity": "sha512-L7MBvwfNpe7yVPTXLn32df/EK+AMBFAFvZrRuArGs7npEWnlziUXK+5GMIUTI4NIuwok3XibsjXCs5HxviYXjg==",
"dev": true, "dev": true,
"requires": { "requires": {
"@types/jest-diff": "*" "jest-diff": "^24.3.0"
} }
}, },
"@types/jest-diff": {
"version": "20.0.1",
"resolved": "https://registry.npmjs.org/@types/jest-diff/-/jest-diff-20.0.1.tgz",
"integrity": "sha512-yALhelO3i0hqZwhjtcr6dYyaLoCHbAMshwtj6cGxTvHZAKXHsYGdff6E8EPw3xLKY0ELUTQ69Q1rQiJENnccMA==",
"dev": true
},
"@types/mime": { "@types/mime": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/@types/mime/-/mime-2.0.1.tgz", "resolved": "https://registry.npmjs.org/@types/mime/-/mime-2.0.1.tgz",
@ -544,9 +538,9 @@
} }
}, },
"@types/node": { "@types/node": {
"version": "12.12.6", "version": "12.12.14",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.6.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.14.tgz",
"integrity": "sha512-FjsYUPzEJdGXjwKqSpE0/9QEh6kzhTAeObA54rn6j3rR4C/mzpI9L0KNfoeASSPMMdxIsoJuCLDWcM/rVjIsSA==" "integrity": "sha512-u/SJDyXwuihpwjXy7hOOghagLEV1KdAST6syfnOk6QZAMzZuWZqXy5aYYZbh8Jdpd4escVFP0MvftHNDb9pruA=="
}, },
"@types/range-parser": { "@types/range-parser": {
"version": "1.2.3", "version": "1.2.3",
@ -722,9 +716,9 @@
} }
}, },
"arg": { "arg": {
"version": "4.1.1", "version": "4.1.2",
"resolved": "https://registry.npmjs.org/arg/-/arg-4.1.1.tgz", "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.2.tgz",
"integrity": "sha512-SlmP3fEA88MBv0PypnXZ8ZfJhwmDeIE3SP71j37AiXQBXYosPV0x6uISAaHYSlSVhmHOVkomen0tbGk6Anlebw==", "integrity": "sha512-+ytCkGcBtHZ3V2r2Z06AncYO8jz46UEamcspGoU8lHcEbpn6J77QK0vdWvChsclg/tM5XIJC5tnjmPp7Eq6Obg==",
"dev": true "dev": true
}, },
"arr-diff": { "arr-diff": {
@ -787,12 +781,6 @@
"integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==", "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==",
"dev": true "dev": true
}, },
"async-each": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.3.tgz",
"integrity": "sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ==",
"dev": true
},
"async-limiter": { "async-limiter": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz",
@ -951,9 +939,9 @@
} }
}, },
"binary-extensions": { "binary-extensions": {
"version": "1.13.1", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.1.tgz", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.0.0.tgz",
"integrity": "sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw==", "integrity": "sha512-Phlt0plgpIIBOGTT/ehfFnbNlfsDEiqmzE2KRXoX1bLIlir4X/MR+zSyBEkL05ffWgnRSf/DXv+WrUAVr93/ow==",
"dev": true "dev": true
}, },
"body-parser": { "body-parser": {
@ -1162,30 +1150,76 @@
} }
}, },
"chokidar": { "chokidar": {
"version": "2.1.8", "version": "3.3.0",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.8.tgz", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.3.0.tgz",
"integrity": "sha512-ZmZUazfOzf0Nve7duiCKD23PFSCs4JPoYyccjUFF3aQkQadqBhfzhjkwBH2mNOG9cTBwhamM37EIsIkZw3nRgg==", "integrity": "sha512-dGmKLDdT3Gdl7fBUe8XK+gAtGmzy5Fn0XkkWQuYxGIgWVPPse2CxFA5mtrlD0TOHaHjEUqkWNyP1XdHoJES/4A==",
"dev": true, "dev": true,
"requires": { "requires": {
"anymatch": "^2.0.0", "anymatch": "~3.1.1",
"async-each": "^1.0.1", "braces": "~3.0.2",
"braces": "^2.3.2", "fsevents": "~2.1.1",
"fsevents": "^1.2.7", "glob-parent": "~5.1.0",
"glob-parent": "^3.1.0", "is-binary-path": "~2.1.0",
"inherits": "^2.0.3", "is-glob": "~4.0.1",
"is-binary-path": "^1.0.0", "normalize-path": "~3.0.0",
"is-glob": "^4.0.0", "readdirp": "~3.2.0"
"normalize-path": "^3.0.0",
"path-is-absolute": "^1.0.0",
"readdirp": "^2.2.1",
"upath": "^1.1.1"
}, },
"dependencies": { "dependencies": {
"anymatch": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.1.tgz",
"integrity": "sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg==",
"dev": true,
"requires": {
"normalize-path": "^3.0.0",
"picomatch": "^2.0.4"
}
},
"braces": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
"integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
"dev": true,
"requires": {
"fill-range": "^7.0.1"
}
},
"fill-range": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
"integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
"dev": true,
"requires": {
"to-regex-range": "^5.0.1"
}
},
"fsevents": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.2.tgz",
"integrity": "sha512-R4wDiBwZ0KzpgOWetKDug1FZcYhqYnUYKtfZYt4mD5SBz76q0KR4Q9o7GIPamsVPGmW3EYPPJ0dOOjvx32ldZA==",
"dev": true,
"optional": true
},
"is-number": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
"dev": true
},
"normalize-path": { "normalize-path": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
"integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",
"dev": true "dev": true
},
"to-regex-range": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
"dev": true,
"requires": {
"is-number": "^7.0.0"
}
} }
} }
}, },
@ -1286,9 +1320,9 @@
} }
}, },
"commander": { "commander": {
"version": "2.20.0", "version": "2.20.3",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz", "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",
"integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==", "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
"dev": true, "dev": true,
"optional": true "optional": true
}, },
@ -1923,9 +1957,9 @@
} }
}, },
"express-validator": { "express-validator": {
"version": "6.2.0", "version": "6.3.0",
"resolved": "https://registry.npmjs.org/express-validator/-/express-validator-6.2.0.tgz", "resolved": "https://registry.npmjs.org/express-validator/-/express-validator-6.3.0.tgz",
"integrity": "sha512-892cPistoSPzMuoG2p1W+2ZxBi0bAvPaaYgXK1E1C8/QncLo2d1HbiDDWkXUtTthjGEzEmwiELLJHu1Ez2hOEg==", "integrity": "sha512-qzKJaUg6BrcRBeZH+QNq2G8/QrLOuaozWKFeeod1oVcMcdauDiTxgbvQeWkhCSlS9V37mx/CVaXKvpRBjR0IeQ==",
"requires": { "requires": {
"lodash": "^4.17.15", "lodash": "^4.17.15",
"validator": "^11.1.0" "validator": "^11.1.0"
@ -2758,24 +2792,12 @@
} }
}, },
"glob-parent": { "glob-parent": {
"version": "3.1.0", "version": "5.1.0",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.0.tgz",
"integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", "integrity": "sha512-qjtRgnIVmOfnKUE3NJAQEdk+lKrxfw8t5ke7SXtfMTHcjsBfOfWXCQfdb30zfDoZQ2IRSIiidmjtbHZPZ++Ihw==",
"dev": true, "dev": true,
"requires": { "requires": {
"is-glob": "^3.1.0", "is-glob": "^4.0.1"
"path-dirname": "^1.0.0"
},
"dependencies": {
"is-glob": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz",
"integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=",
"dev": true,
"requires": {
"is-extglob": "^2.1.0"
}
}
} }
}, },
"global-dirs": { "global-dirs": {
@ -2833,9 +2855,9 @@
"dev": true "dev": true
}, },
"handlebars": { "handlebars": {
"version": "4.4.3", "version": "4.5.3",
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.4.3.tgz", "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.5.3.tgz",
"integrity": "sha512-B0W4A2U1ww3q7VVthTKfh+epHx+q4mCt6iK+zEAzbMBpWQAwxCeKxEGpj/1oQTpzPXDNSOG7hmG14TsISH50yw==", "integrity": "sha512-3yPecJoJHK/4c6aZhSvxOyG4vJKDshV36VHp0iVCDVh7o9w2vwi3NSnL2MMPj3YdduqaBcu7cGbggJQM0br9xA==",
"dev": true, "dev": true,
"requires": { "requires": {
"neo-async": "^2.6.0", "neo-async": "^2.6.0",
@ -3045,12 +3067,12 @@
"dev": true "dev": true
}, },
"is-binary-path": { "is-binary-path": {
"version": "1.0.1", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz",
"integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==",
"dev": true, "dev": true,
"requires": { "requires": {
"binary-extensions": "^1.0.0" "binary-extensions": "^2.0.0"
} }
}, },
"is-buffer": { "is-buffer": {
@ -4249,12 +4271,12 @@
} }
}, },
"nodemon": { "nodemon": {
"version": "1.19.4", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-1.19.4.tgz", "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.1.tgz",
"integrity": "sha512-VGPaqQBNk193lrJFotBU8nvWZPqEZY2eIzymy2jjY0fJ9qIsxA0sxQ8ATPl0gZC645gijYEc1jtZvpS8QWzJGQ==", "integrity": "sha512-UC6FVhNLXjbbV4UzaXA3wUdbEkUZzLGgMGzmxvWAex5nzib/jhcSHVFlQODdbuUHq8SnnZ4/EABBAbC3RplvPg==",
"dev": true, "dev": true,
"requires": { "requires": {
"chokidar": "^2.1.8", "chokidar": "^3.2.2",
"debug": "^3.2.6", "debug": "^3.2.6",
"ignore-by-default": "^1.0.1", "ignore-by-default": "^1.0.1",
"minimatch": "^3.0.4", "minimatch": "^3.0.4",
@ -4550,12 +4572,6 @@
"integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=",
"dev": true "dev": true
}, },
"path-dirname": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz",
"integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=",
"dev": true
},
"path-exists": { "path-exists": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz",
@ -4605,6 +4621,12 @@
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
"integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns="
}, },
"picomatch": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.1.1.tgz",
"integrity": "sha512-OYMyqkKzK7blWO/+XZYP6w8hH0LDvkBvdvKukti+7kqYFCiEAk+gI3DWnryapc0Dau05ugGTy0foQ6mqn4AHYA==",
"dev": true
},
"pify": { "pify": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz",
@ -4806,14 +4828,12 @@
} }
}, },
"readdirp": { "readdirp": {
"version": "2.2.1", "version": "3.2.0",
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.2.1.tgz", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.2.0.tgz",
"integrity": "sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ==", "integrity": "sha512-crk4Qu3pmXwgxdSgGhgA/eXiJAPQiX4GMOZZMXnqKxHX7TaoL+3gQVo/WeuAiogr07DpnfjIMpXXa+PAIvwPGQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"graceful-fs": "^4.1.11", "picomatch": "^2.0.4"
"micromatch": "^3.1.10",
"readable-stream": "^2.0.2"
} }
}, },
"realpath-native": { "realpath-native": {
@ -5753,9 +5773,9 @@
"dev": true "dev": true
}, },
"ts-jest": { "ts-jest": {
"version": "24.1.0", "version": "24.2.0",
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-24.1.0.tgz", "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-24.2.0.tgz",
"integrity": "sha512-HEGfrIEAZKfu1pkaxB9au17b1d9b56YZSqz5eCVE8mX68+5reOvlM93xGOzzCREIov9mdH7JBG+s0UyNAqr0tQ==", "integrity": "sha512-Yc+HLyldlIC9iIK8xEN7tV960Or56N49MDP7hubCZUeI7EbIOTsas6rXCMB4kQjLACJ7eDOF4xWEO5qumpKsag==",
"dev": true, "dev": true,
"requires": { "requires": {
"bs-logger": "0.x", "bs-logger": "0.x",
@ -5788,9 +5808,9 @@
} }
}, },
"ts-node": { "ts-node": {
"version": "8.4.1", "version": "8.5.4",
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.4.1.tgz", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.5.4.tgz",
"integrity": "sha512-5LpRN+mTiCs7lI5EtbXmF/HfMeCjzt7DH9CZwtkr6SywStrNQC723wG+aOWFiLNn7zT3kD/RnFqi3ZUfr4l5Qw==", "integrity": "sha512-izbVCRV68EasEPQ8MSIGBNK9dc/4sYJJKYA+IarMQct1RtEot6Xp0bXuClsbUSnKpg50ho+aOAx8en5c+y4OFw==",
"dev": true, "dev": true,
"requires": { "requires": {
"arg": "^4.1.0", "arg": "^4.1.0",
@ -5832,19 +5852,19 @@
} }
}, },
"typescript": { "typescript": {
"version": "3.7.2", "version": "3.7.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.2.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.3.tgz",
"integrity": "sha512-ml7V7JfiN2Xwvcer+XAf2csGO1bPBdRbFCkYBczNZggrBZ9c7G3riSUeJmqEU5uOtXNPMhE3n+R4FA/3YOAWOQ==", "integrity": "sha512-Mcr/Qk7hXqFBXMN7p7Lusj1ktCBydylfQM/FZCk5glCNQJrCUKPkMHdo9R0MTFWsC/4kPFvDS0fDPvukfCkFsw==",
"dev": true "dev": true
}, },
"uglify-js": { "uglify-js": {
"version": "3.6.1", "version": "3.7.1",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.1.tgz", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.7.1.tgz",
"integrity": "sha512-+dSJLJpXBb6oMHP+Yvw8hUgElz4gLTh82XuX68QiJVTXaE5ibl6buzhNkQdYhBlIhozWOC9ge16wyRmjG4TwVQ==", "integrity": "sha512-pnOF7jY82wdIhATVn87uUY/FHU+MDUdPLkmGFvGoclQmeu229eTkbG5gjGGBi3R7UuYYSEeYXY/TTY5j2aym2g==",
"dev": true, "dev": true,
"optional": true, "optional": true,
"requires": { "requires": {
"commander": "2.20.0", "commander": "~2.20.3",
"source-map": "~0.6.1" "source-map": "~0.6.1"
} }
}, },
@ -5940,12 +5960,6 @@
"integrity": "sha1-0vD3N9FrBhXnKmk17QQhRXLVb5c=", "integrity": "sha1-0vD3N9FrBhXnKmk17QQhRXLVb5c=",
"dev": true "dev": true
}, },
"upath": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/upath/-/upath-1.2.0.tgz",
"integrity": "sha512-aZwGpamFO61g3OlfT7OQCHqhGnW43ieH9WZeP7QxN/G/jS4jfqUkZxoryvJgVPEcrl5NL/ggHsSmLMHuH64Lhg==",
"dev": true
},
"update-notifier": { "update-notifier": {
"version": "2.5.0", "version": "2.5.0",
"resolved": "https://registry.npmjs.org/update-notifier/-/update-notifier-2.5.0.tgz", "resolved": "https://registry.npmjs.org/update-notifier/-/update-notifier-2.5.0.tgz",

View File

@ -1,7 +1,7 @@
{ {
"name": "commons-server", "name": "commons-server",
"description": "Ocean Protocol marketplace backend.", "description": "Ocean Protocol marketplace backend.",
"version": "1.3.2", "version": "2.0.0-beta.3",
"license": "Apache-2.0", "license": "Apache-2.0",
"main": "dist/src/server.js", "main": "dist/src/server.js",
"scripts": { "scripts": {
@ -19,7 +19,7 @@
"debug": "^4.1.1", "debug": "^4.1.1",
"dotenv": "^8.2.0", "dotenv": "^8.2.0",
"express": "^4.17.1", "express": "^4.17.1",
"express-validator": "^6.2.0", "express-validator": "^6.3.0",
"morgan": "^1.9.1", "morgan": "^1.9.1",
"request": "^2.88.0" "request": "^2.88.0"
}, },
@ -28,17 +28,17 @@
"@types/compression": "^1.0.1", "@types/compression": "^1.0.1",
"@types/debug": "^4.1.5", "@types/debug": "^4.1.5",
"@types/express": "^4.17.2", "@types/express": "^4.17.2",
"@types/jest": "^24.0.22", "@types/jest": "^24.0.23",
"@types/morgan": "^1.7.37", "@types/morgan": "^1.7.37",
"@types/node": "^12.12.6", "@types/node": "^12.12.14",
"@types/request": "^2.48.3", "@types/request": "^2.48.3",
"@types/supertest": "^2.0.8", "@types/supertest": "^2.0.8",
"jest": "^24.9.0", "jest": "^24.9.0",
"nodemon": "^1.19.4", "nodemon": "^2.0.1",
"supertest": "^4.0.2", "supertest": "^4.0.2",
"ts-jest": "^24.1.0", "ts-jest": "^24.2.0",
"ts-node": "^8.4.1", "ts-node": "^8.5.4",
"typescript": "^3.7.2" "typescript": "^3.7.3"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -42,9 +42,7 @@ export class UrlCheckRouter {
result.found = true result.found = true
if (headers['content-length']) { if (headers['content-length']) {
result.contentLength = parseInt( result.contentLength = headers['content-length']
headers['content-length']
) // convert to number
} }
// sometimes servers send content-range header, // sometimes servers send content-range header,
@ -54,7 +52,7 @@ export class UrlCheckRouter {
!headers['content-length'] !headers['content-length']
) { ) {
const size = headers['content-range'].split('/')[1] const size = headers['content-range'].split('/')[1]
result.contentLength = parseInt(size) // convert to number result.contentLength = size
} }
if (headers['content-type']) { if (headers['content-type']) {