mirror of
https://github.com/oceanprotocol-archive/squid-js.git
synced 2024-02-02 15:31:51 +01:00
Send the token when is available to authenticate on Brizo.
This commit is contained in:
parent
1f83e333cb
commit
3abe15a023
@ -75,7 +75,7 @@ export class Brizo extends Instantiable {
|
||||
destination: string,
|
||||
index: number = -1,
|
||||
): Promise<string> {
|
||||
const agreementIdSignature = await this.ocean.utils.signature.signText(noZeroX(agreementId), account.getId())
|
||||
const signature = await account.getToken() || await this.ocean.utils.signature.signText(noZeroX(agreementId), account.getId())
|
||||
const filesPromises = files
|
||||
.filter(({}, i) => index === -1 || i === index)
|
||||
.map(async ({index: i}) => {
|
||||
@ -83,7 +83,7 @@ export class Brizo extends Instantiable {
|
||||
consumeUrl += `?index=${i}`
|
||||
consumeUrl += `&serviceAgreementId=${noZeroX(agreementId)}`
|
||||
consumeUrl += `&consumerAddress=${account.getId()}`
|
||||
consumeUrl += `&signature=${agreementIdSignature}`
|
||||
consumeUrl += `&signature=${signature}`
|
||||
|
||||
try {
|
||||
await this.downloadFile(
|
||||
@ -102,14 +102,14 @@ export class Brizo extends Instantiable {
|
||||
|
||||
public async encrypt(
|
||||
did: string,
|
||||
signedDid: string,
|
||||
signature: string,
|
||||
document: any,
|
||||
publisher: string,
|
||||
): Promise<string> {
|
||||
|
||||
const args = {
|
||||
documentId: did,
|
||||
signedDocumentId: signedDid,
|
||||
signature,
|
||||
document: JSON.stringify(document),
|
||||
publisherAddress: publisher,
|
||||
}
|
||||
|
@ -28,8 +28,10 @@ export class OceanSecretStore extends Instantiable {
|
||||
* @return {Promise<string>} Encrypted text.
|
||||
*/
|
||||
public async encrypt(did: string, document: any, publisher: Account): Promise<string> {
|
||||
const signedDid = await this.ocean.utils.signature.signText(noDidPrefixed(did), publisher.getId(), publisher.getPassword())
|
||||
const signature =
|
||||
await publisher.getToken()
|
||||
|| await this.ocean.utils.signature.signText(noDidPrefixed(did), publisher.getId(), publisher.getPassword())
|
||||
|
||||
return await this.ocean.brizo.encrypt(noDidPrefixed(did), signedDid, document, publisher.getId())
|
||||
return await this.ocean.brizo.encrypt(noDidPrefixed(did), signature, document, publisher.getId())
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user