1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00

add headers (#1665)

This commit is contained in:
Bogdan Fazakas 2022-12-19 12:08:35 +02:00 committed by GitHub
parent a026c12041
commit d539e00072
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 5 deletions

View File

@ -1,4 +1,9 @@
import { AbiItem } from 'web3-utils'
interface FileTypeHeaders {
[key: string]: string
}
export interface UrlFile {
type: 'url'
@ -19,8 +24,13 @@ export interface UrlFile {
* @type {string}
*/
method: string
}
/**
* Headers key value pairs associated with the asset GET request
* @type {string}
*/
headers?: FileTypeHeaders
}
export interface GraphqlQuery {
type: 'graphql'
@ -40,6 +50,12 @@ export interface GraphqlQuery {
* @type {string}
*/
query: string
/**
* Headers key value pairs associated with the asset GET request
* @type {string}
*/
headers?: FileTypeHeaders
}
export interface Arweave {

View File

@ -150,9 +150,10 @@ export class Provider {
}
/** Get DDO File details (if possible)
* @param {string} did did
* @param {number} serviceId the id of the service for which to check the files
* @param {UrlFile | Arweave | Ipfs | GraphqlQuery | Smartcontract} file one of the supported file structures
* @param {string} serviceId the id of the service for which to check the files
* @param {string} providerUri uri of the provider that will be used to check the file
* @param {boolean} withChecksum if true, will return checksum of files content
* @param {AbortSignal} signal abort signal
* @return {Promise<FileInfo[]>} urlDetails
*/
@ -193,14 +194,16 @@ export class Provider {
}
/** Get URL details (if possible)
* @param {string} url or did
* @param {UrlFile | Arweave | Ipfs | GraphqlQuery | Smartcontract} file one of the supported file structures
* @param {string} providerUri uri of the provider that will be used to check the file
* @param {boolean} withChecksum if true, will return checksum of files content
* @param {AbortSignal} signal abort signal
* @return {Promise<FileInfo[]>} urlDetails
*/
public async getFileInfo(
file: UrlFile | Arweave | Ipfs | GraphqlQuery | Smartcontract,
providerUri: string,
withChecksum: boolean = false,
signal?: AbortSignal
): Promise<FileInfo[]> {
const providerEndpoints = await this.getEndpoints(providerUri)
@ -208,7 +211,7 @@ export class Provider {
providerUri,
providerEndpoints
)
const args = file
const args = { ...file, checksum: withChecksum }
const files: FileInfo[] = []
const path = this.getEndpointURL(serviceEndpoints, 'fileinfo')
? this.getEndpointURL(serviceEndpoints, 'fileinfo').urlPath