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:
parent
a026c12041
commit
d539e00072
@ -1,4 +1,9 @@
|
|||||||
import { AbiItem } from 'web3-utils'
|
import { AbiItem } from 'web3-utils'
|
||||||
|
|
||||||
|
interface FileTypeHeaders {
|
||||||
|
[key: string]: string
|
||||||
|
}
|
||||||
|
|
||||||
export interface UrlFile {
|
export interface UrlFile {
|
||||||
type: 'url'
|
type: 'url'
|
||||||
|
|
||||||
@ -19,8 +24,13 @@ export interface UrlFile {
|
|||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
method: string
|
method: string
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Headers key value pairs associated with the asset GET request
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
headers?: FileTypeHeaders
|
||||||
|
}
|
||||||
export interface GraphqlQuery {
|
export interface GraphqlQuery {
|
||||||
type: 'graphql'
|
type: 'graphql'
|
||||||
|
|
||||||
@ -40,6 +50,12 @@ export interface GraphqlQuery {
|
|||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
query: string
|
query: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Headers key value pairs associated with the asset GET request
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
headers?: FileTypeHeaders
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Arweave {
|
export interface Arweave {
|
||||||
|
@ -150,9 +150,10 @@ export class Provider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Get DDO File details (if possible)
|
/** Get DDO File details (if possible)
|
||||||
* @param {string} did did
|
* @param {UrlFile | Arweave | Ipfs | GraphqlQuery | Smartcontract} file one of the supported file structures
|
||||||
* @param {number} serviceId the id of the service for which to check the files
|
* @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 {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
|
* @param {AbortSignal} signal abort signal
|
||||||
* @return {Promise<FileInfo[]>} urlDetails
|
* @return {Promise<FileInfo[]>} urlDetails
|
||||||
*/
|
*/
|
||||||
@ -193,14 +194,16 @@ export class Provider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Get URL details (if possible)
|
/** 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 {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
|
* @param {AbortSignal} signal abort signal
|
||||||
* @return {Promise<FileInfo[]>} urlDetails
|
* @return {Promise<FileInfo[]>} urlDetails
|
||||||
*/
|
*/
|
||||||
public async getFileInfo(
|
public async getFileInfo(
|
||||||
file: UrlFile | Arweave | Ipfs | GraphqlQuery | Smartcontract,
|
file: UrlFile | Arweave | Ipfs | GraphqlQuery | Smartcontract,
|
||||||
providerUri: string,
|
providerUri: string,
|
||||||
|
withChecksum: boolean = false,
|
||||||
signal?: AbortSignal
|
signal?: AbortSignal
|
||||||
): Promise<FileInfo[]> {
|
): Promise<FileInfo[]> {
|
||||||
const providerEndpoints = await this.getEndpoints(providerUri)
|
const providerEndpoints = await this.getEndpoints(providerUri)
|
||||||
@ -208,7 +211,7 @@ export class Provider {
|
|||||||
providerUri,
|
providerUri,
|
||||||
providerEndpoints
|
providerEndpoints
|
||||||
)
|
)
|
||||||
const args = file
|
const args = { ...file, checksum: withChecksum }
|
||||||
const files: FileInfo[] = []
|
const files: FileInfo[] = []
|
||||||
const path = this.getEndpointURL(serviceEndpoints, 'fileinfo')
|
const path = this.getEndpointURL(serviceEndpoints, 'fileinfo')
|
||||||
? this.getEndpointURL(serviceEndpoints, 'fileinfo').urlPath
|
? this.getEndpointURL(serviceEndpoints, 'fileinfo').urlPath
|
||||||
|
Loading…
x
Reference in New Issue
Block a user