Skip to content

Commit

Permalink
add headers (#1665)
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdanfazakas committed Dec 19, 2022
1 parent a026c12 commit d539e00
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
18 changes: 17 additions & 1 deletion src/@types/File.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { AbiItem } from 'web3-utils'

interface FileTypeHeaders {
[key: string]: string
}

export interface UrlFile {
type: 'url'

Expand All @@ -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'

Expand All @@ -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 {
Expand Down
11 changes: 7 additions & 4 deletions src/services/Provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -193,22 +194,24 @@ 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)
const serviceEndpoints = await this.getServiceEndpoints(
providerUri,
providerEndpoints
)
const args = file
const args = { ...file, checksum: withChecksum }
const files: FileInfo[] = []
const path = this.getEndpointURL(serviceEndpoints, 'fileinfo')
? this.getEndpointURL(serviceEndpoints, 'fileinfo').urlPath
Expand Down

0 comments on commit d539e00

Please sign in to comment.