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,
|
destination: string,
|
||||||
index: number = -1,
|
index: number = -1,
|
||||||
): Promise<string> {
|
): 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
|
const filesPromises = files
|
||||||
.filter(({}, i) => index === -1 || i === index)
|
.filter(({}, i) => index === -1 || i === index)
|
||||||
.map(async ({index: i}) => {
|
.map(async ({index: i}) => {
|
||||||
@ -83,7 +83,7 @@ export class Brizo extends Instantiable {
|
|||||||
consumeUrl += `?index=${i}`
|
consumeUrl += `?index=${i}`
|
||||||
consumeUrl += `&serviceAgreementId=${noZeroX(agreementId)}`
|
consumeUrl += `&serviceAgreementId=${noZeroX(agreementId)}`
|
||||||
consumeUrl += `&consumerAddress=${account.getId()}`
|
consumeUrl += `&consumerAddress=${account.getId()}`
|
||||||
consumeUrl += `&signature=${agreementIdSignature}`
|
consumeUrl += `&signature=${signature}`
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.downloadFile(
|
await this.downloadFile(
|
||||||
@ -102,14 +102,14 @@ export class Brizo extends Instantiable {
|
|||||||
|
|
||||||
public async encrypt(
|
public async encrypt(
|
||||||
did: string,
|
did: string,
|
||||||
signedDid: string,
|
signature: string,
|
||||||
document: any,
|
document: any,
|
||||||
publisher: string,
|
publisher: string,
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
|
|
||||||
const args = {
|
const args = {
|
||||||
documentId: did,
|
documentId: did,
|
||||||
signedDocumentId: signedDid,
|
signature,
|
||||||
document: JSON.stringify(document),
|
document: JSON.stringify(document),
|
||||||
publisherAddress: publisher,
|
publisherAddress: publisher,
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,10 @@ export class OceanSecretStore extends Instantiable {
|
|||||||
* @return {Promise<string>} Encrypted text.
|
* @return {Promise<string>} Encrypted text.
|
||||||
*/
|
*/
|
||||||
public async encrypt(did: string, document: any, publisher: Account): Promise<string> {
|
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…
x
Reference in New Issue
Block a user