Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds function for check URL from provider. #483

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/provider/Provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,20 @@ export class Provider extends Instantiable {
}
}

public async checkURL(url: string): Promise<string> {
const args = { url }
try {
const response = await this.ocean.utils.fetch.post(
this.getCheckURLEndpoint(),
decodeURI(JSON.stringify(args))
)
return (await response.json()).encryptedDocument
} catch (e) {
this.logger.error(e)
throw new Error('HTTP request failed')
}
}

/** Get nonce from provider
* @param {String} consumerAddress
* @return {Promise<string>} string
Expand Down Expand Up @@ -279,6 +293,10 @@ export class Provider extends Instantiable {
return `${this.url}${apiPath}/encrypt`
}

public getCheckURLEndpoint(): string {
return `${this.url}${apiPath}/checkURL`
}

public getPublishEndpoint(): string {
return `${this.url}${apiPath}/publish`
}
Expand Down