mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
Merge pull request #358 from oceanprotocol/feature/remove_ddo_proof
remove ddo prof
This commit is contained in:
commit
6ad85057a2
@ -117,35 +117,10 @@ export class DDO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates proof using personal sing.
|
* Generates and adds a simple hash proof on publicKey
|
||||||
* @param {Ocean} ocean Ocean instance.
|
* @param {Ocean} ocean Ocean instance.
|
||||||
* @param {string} publicKey Public key to be used on personal sign.
|
* @param {string} publicKey Public key to be used on personal sign.
|
||||||
* @param {string} password Password if it's required.
|
* @return {Promise<void>}
|
||||||
* @return {Promise<Proof>} Proof object.
|
|
||||||
*/
|
|
||||||
public async generateProof(
|
|
||||||
ocean: Ocean,
|
|
||||||
publicKey: string,
|
|
||||||
password?: string
|
|
||||||
): Promise<Proof> {
|
|
||||||
const checksum = this.getChecksum()
|
|
||||||
|
|
||||||
const signature = await ocean.utils.signature.signText(checksum, publicKey, password)
|
|
||||||
|
|
||||||
return {
|
|
||||||
created: new Date().toISOString().replace(/\.[0-9]{3}/, ''),
|
|
||||||
creator: publicKey,
|
|
||||||
type: 'DDOIntegritySignature',
|
|
||||||
signatureValue: signature
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generates and adds a proof using personal sing on the DDO.
|
|
||||||
* @param {Ocean} ocean Ocean instance.
|
|
||||||
* @param {string} publicKey Public key to be used on personal sign.
|
|
||||||
* @param {string} password Password if it's required.
|
|
||||||
* @return {Promise<Proof>} Proof object.
|
|
||||||
*/
|
*/
|
||||||
public async addProof(
|
public async addProof(
|
||||||
ocean: Ocean,
|
ocean: Ocean,
|
||||||
@ -155,6 +130,14 @@ export class DDO {
|
|||||||
if (this.proof) {
|
if (this.proof) {
|
||||||
throw new Error('Proof already exists')
|
throw new Error('Proof already exists')
|
||||||
}
|
}
|
||||||
this.proof = await this.generateProof(ocean, publicKey, password)
|
this.proof = {
|
||||||
|
created: new Date().toISOString().replace(/\.[0-9]{3}/, ''),
|
||||||
|
creator: publicKey,
|
||||||
|
type: 'AddressHash',
|
||||||
|
signatureValue: Web3Provider.getWeb3()
|
||||||
|
.utils.sha3(publicKey)
|
||||||
|
// TODO: security/detect-unsafe-regex
|
||||||
|
.replace(/^0x([a-f0-9]{64})(:!.+)?$/i, '0x$1')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,6 @@ export enum CreateProgressStep {
|
|||||||
DataTokenCreated,
|
DataTokenCreated,
|
||||||
EncryptingFiles,
|
EncryptingFiles,
|
||||||
FilesEncrypted,
|
FilesEncrypted,
|
||||||
GeneratingProof,
|
|
||||||
ProofGenerated,
|
|
||||||
StoringDdo,
|
StoringDdo,
|
||||||
DdoStored
|
DdoStored
|
||||||
}
|
}
|
||||||
@ -188,11 +186,7 @@ export class Assets extends Instantiable {
|
|||||||
index: indexCount++
|
index: indexCount++
|
||||||
})) as Service[]
|
})) as Service[]
|
||||||
})
|
})
|
||||||
this.logger.log('Generating proof')
|
await ddo.addProof(this.ocean, publisher.getId())
|
||||||
observer.next(CreateProgressStep.GeneratingProof)
|
|
||||||
await ddo.addProof(this.ocean, publisher.getId(), publisher.getPassword())
|
|
||||||
this.logger.log('Proof generated')
|
|
||||||
observer.next(CreateProgressStep.ProofGenerated)
|
|
||||||
this.logger.log('Storing DDO')
|
this.logger.log('Storing DDO')
|
||||||
observer.next(CreateProgressStep.StoringDdo)
|
observer.next(CreateProgressStep.StoringDdo)
|
||||||
// const storedDdo = await this.ocean.metadatacache.storeDDO(ddo)
|
// const storedDdo = await this.ocean.metadatacache.storeDDO(ddo)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user