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": {
"react": {
"version": "16"
"version": "16.10"
}
}
}

2
.nvmrc
View File

@ -1 +1 @@
v11
v12

View File

@ -2,7 +2,7 @@ dist: xenial
sudo: required
language: node_js
node_js:
- '11'
- '12'
services:
- docker
@ -33,10 +33,10 @@ env:
- IPFS_GATEWAY_URI="https://ipfs.oceanprotocol.com"
# start Barge with these versions
- BRIZO_VERSION=v0.4.6
- AQUARIUS_VERSION=v0.3.9
- BRIZO_VERSION=v0.7.2
- AQUARIUS_VERSION=v1.0.5
- KEEPER_VERSION=v0.12.7
- EVENTS_HANDLER_VERSION=v0.1.2
- EVENTS_HANDLER_VERSION=v0.3.4
- KEEPER_OWNER_ROLE_ADDRESS="0xe2DD09d719Da89e5a3D0F2549c7E24566e947260"
- 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).
#### [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)
> 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)
#### [v1.3.1](https://github.com/oceanprotocol/commons/compare/v1.3.0...v1.3.1)

View File

@ -13,6 +13,16 @@ const oceanMock = {
}
},
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(),
order: () => {
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",
"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",
"scripts": {
"start": "react-scripts start",
@ -14,53 +14,52 @@
},
"dependencies": {
"@oceanprotocol/art": "^2.2.0",
"@oceanprotocol/squid": "^0.8.3",
"@oceanprotocol/squid": "^1.0.0",
"@oceanprotocol/typographies": "^0.1.0",
"@sindresorhus/slugify": "^0.9.1",
"@truffle/hdwallet-provider": "^1.0.23",
"@truffle/hdwallet-provider": "^1.0.26",
"axios": "^0.19.0",
"bip39": "^3.0.2",
"classnames": "^2.2.6",
"ethereum-blockies": "github:MyEtherWallet/blockies",
"filesize": "^6.0.0",
"filesize": "^6.0.1",
"history": "^4.10.1",
"ipfs": "^0.39.0",
"ipfs-http-client": "^39.0.2",
"is-url-superb": "^3.0.0",
"moment": "^2.24.0",
"query-string": "^6.8.3",
"react": "^16.11.0",
"react-collapsed": "^2.2.2",
"react-datepicker": "^2.9.6",
"react-dom": "^16.11.0",
"query-string": "^6.9.0",
"react": "^16.12.0",
"react-collapsed": "^2.2.3",
"react-datepicker": "^2.10.1",
"react-dom": "^16.12.0",
"react-dotdotdot": "^1.3.1",
"react-dropzone": "^10.1.10",
"react-dropzone": "^10.2.1",
"react-ga": "^2.7.0",
"react-helmet": "^5.2.1",
"react-markdown": "^4.2.2",
"react-modal": "^3.11.1",
"react-moment": "^0.9.6",
"react-paginate": "^6.3.2",
"react-popper": "^1.3.5",
"react-popper": "^1.3.6",
"react-router-dom": "^5.1.2",
"react-transition-group": "^4.3.0",
"shortid": "^2.2.15",
"web3": "^1.2.2"
"web3": "^1.2.4"
},
"devDependencies": {
"@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",
"@types/classnames": "^2.2.9",
"@types/is-url": "^1.2.28",
"@types/jest": "^24.0.22",
"@types/react": "^16.9.11",
"@types/react-datepicker": "^2.9.3",
"@types/jest": "^24.0.23",
"@types/react": "^16.9.15",
"@types/react-datepicker": "^2.9.5",
"@types/react-dom": "^16.9.4",
"@types/react-helmet": "^5.0.14",
"@types/react-modal": "^3.10.0",
"@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/shortid": "^0.0.29",
"@typescript-eslint/eslint-plugin": "^1.6.0",
@ -69,8 +68,8 @@
"jest-mock-axios": "^3.1.2",
"node-sass": "^4.13.0",
"react-scripts": "3.0.1",
"source-map-explorer": "^2.1.0",
"typescript": "^3.7.2"
"source-map-explorer": "^2.1.2",
"typescript": "^3.7.3"
},
"repository": {
"type": "git",

View File

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

View File

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

View File

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

View File

@ -9,7 +9,7 @@ describe('AssetDetails', () => {
it('renders loading without crashing', () => {
const { container } = render(
<AssetDetails
metadata={({ base: { name: '' } } as any) as MetaData}
metadata={({ main: { name: '' } } as any) as MetaData}
ddo={({} as any) as DDO}
/>
)
@ -22,11 +22,13 @@ describe('AssetDetails', () => {
<AssetDetails
metadata={
({
base: {
main: {
name: 'Hello',
description: 'Description',
categories: ['Category'],
files: [{ index: 0 }]
},
additionalInformation: {
description: 'Description',
categories: ['Category']
}
} 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) {
const { base } = metadata
const price = base.price && Web3.utils.fromWei(base.price.toString())
const { main, additionalInformation } = metadata
const price = main.price && Web3.utils.fromWei(main.price.toString())
const metaFixed = [
{
name: 'Author',
value: base.author,
value: main.author,
show: true
},
{
name: 'License',
value: base.license,
value: main.license,
show: true
},
{
@ -60,36 +60,45 @@ export default function AssetDetails({ metadata, ddo }: AssetDetailsProps) {
return (
<>
<aside className={styles.metaPrimary}>
<h2 className={styles.copyrightHolder} title="Copyright Holder">
{base.copyrightHolder}
</h2>
{additionalInformation &&
additionalInformation.copyrightHolder && (
<h2
className={styles.copyrightHolder}
title="Copyright Holder"
>
{additionalInformation.copyrightHolder}
</h2>
)}
<div className={styles.metaPrimaryData}>
<span
title={`Date created, published on ${base.datePublished}`}
title={`Date created, published on ${main.datePublished}`}
>
<Moment
date={base.dateCreated}
date={main.dateCreated}
format="L"
interval={0}
/>
</span>
{base.categories && (
<CategoryLink category={base.categories[0]} />
)}
{additionalInformation &&
additionalInformation.categories && (
<CategoryLink
category={additionalInformation.categories[0]}
/>
)}
{base.files && datafilesLine(base.files)}
{main.files && datafilesLine(main.files)}
</div>
</aside>
{base.description && (
{additionalInformation && additionalInformation.description && (
<Markdown
text={base.description}
text={additionalInformation.description}
className={styles.description}
/>
)}
<Report did={ddo.id} title={metadata.base.name} />
<Report did={ddo.id} title={main.name} />
<div className={styles.metaFixed}>
<h2
@ -111,7 +120,7 @@ export default function AssetDetails({ metadata, ddo }: AssetDetailsProps) {
</ul>
</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,
url: 'https://hello.com',
contentType: 'application/x-zip',
contentLength: 100
contentLength: '100'
}
const ddo = ({
id: 'xxx',
findServiceByType: () => {
return { serviceDefinitionId: 'xxx' }
return { index: 'xxx' }
}
} as any) as DDO

View File

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

View File

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

View File

@ -1,8 +1,10 @@
import Web3 from 'web3'
import { nodeUri } from '../config'
import HDWalletProvider from '@truffle/hdwallet-provider'
import { nodeUri } from '../config'
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 {
private web3: Web3
@ -12,10 +14,6 @@ export class BurnerWalletProvider {
this.web3 = null as any
}
public async isAvailable() {
return true
}
public async isLogged() {
if (localStorage.getItem('seedphrase') !== null) {
return true
@ -35,7 +33,7 @@ export class BurnerWalletProvider {
}
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)
const accounts = await this.web3.eth.getAccounts()
const balance = await this.web3.eth.getBalance(accounts[0])

View File

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

View File

@ -24,6 +24,7 @@ export default function useIpfsApi(config: IpfsConfig) {
ipfsMessage = 'Checking IPFS gateway...'
try {
// eslint-disable-next-line require-atomic-updates
ipfs = await ipfsClient(config)
const version = await ipfs.version()
ipfsVersion = version.version
@ -38,7 +39,6 @@ export default function useIpfsApi(config: IpfsConfig) {
}, [config])
useEffect(() => {
// just like componentWillUnmount()
return function cleanup() {
if (ipfs) {
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 = {
assetId: null,
publisherId: null,
import { MetaData } from '@oceanprotocol/squid'
const AssetModel: MetaData = {
// OEP-08 Attributes
// https://github.com/oceanprotocol/OEPs/tree/master/8
base: {
name: null,
description: null,
dateCreated: null,
author: null,
type: '',
license: null,
copyrightHolder: null,
workExample: '',
files: [],
categories: [],
links: [],
inLanguage: '',
tags: [],
price: ''
main: {
type: 'dataset',
name: '',
dateCreated: '',
author: '',
license: '',
price: '',
files: []
},
additionalInformation: {
description: '',
copyrightHolder: '',
categories: []
}
}

View File

@ -26,19 +26,4 @@ describe('IPFS', () => {
const addingText = await waitForElement(() => getByText(/Adding /))
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',
found: true,
contentType: 'application/zip',
contentLength: 10
contentLength: '10'
}
const { container } = render(
<Item item={item} removeItem={() => null} />
@ -21,7 +21,7 @@ describe('Item', () => {
url: 'https://hello.com/hello.zip',
found: false,
contentType: '',
contentLength: 10
contentLength: '10'
}
const { container } = render(
<Item item={item} removeItem={() => null} />

View File

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

View File

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

View File

@ -280,23 +280,28 @@ class Publish extends Component<{}, PublishState> {
const newAsset = {
// OEP-08 Attributes
// 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,
description: this.state.description,
dateCreated:
new Date(this.state.dateCreated)
.toISOString()
.split('.')[0] + 'Z', // remove milliseconds
author: this.state.author,
license: this.state.license,
copyrightHolder: this.state.copyrightHolder,
files,
price: allowPricing
? Web3.utils.toWei(this.state.price, 'ether')
: this.state.price,
type: this.state.type,
categories: [this.state.categories]
})
files
}),
additionalInformation: Object.assign(
AssetModel.additionalInformation,
{
description: this.state.description,
copyrightHolder: this.state.copyrightHolder,
categories: [this.state.categories]
}
)
}
try {

View File

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

View File

@ -1,3 +1 @@
/* eslint-disable no-console */
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', () => {
// Fill search phrase
cy.get('input#search').type('Title test')
cy.get('input#search').type('Commons Integration Test')
// Start search
cy.get('button')
.contains('Search')

View File

@ -11,15 +11,15 @@
},
{
"name": "brizo",
"version": "~0.4.6"
"version": "~0.7.2"
},
{
"name": "aquarius",
"version": "~0.3.9"
"version": "~1.0.5"
},
{
"name": "squid-js",
"version": "~0.8.3"
"version": "~1.0.0"
},
{
"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",
"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",
"scripts": {
"install": "./scripts/install.sh",
@ -29,22 +29,22 @@
"@typescript-eslint/parser": "^1.6.0",
"auto-changelog": "^1.16.2",
"concurrently": "^5.0.0",
"cypress": "^3.6.0",
"cypress": "^3.7.0",
"cypress-log-to-output": "^1.0.7",
"eslint": "^5.16.0",
"eslint-config-oceanprotocol": "1.4.0",
"eslint-config-oceanprotocol": "^1.4.0",
"eslint-config-prettier": "^6.5.0",
"eslint-plugin-cypress": "^2.7.0",
"eslint-plugin-prettier": "^3.1.1",
"prettier": "^1.18.2",
"prettier": "^1.19.1",
"prettier-stylelint": "^0.4.2",
"release-it": "^12.4.3",
"start-server-and-test": "^1.10.6",
"stylelint": "^11.1.1",
"stylelint": "^12.0.0",
"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",
"typescript": "^3.7.2"
"typescript": "^3.7.3"
},
"repository": {
"type": "git",

224
server/package-lock.json generated
View File

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

View File

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

View File

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