Constructors

Properties

payment?: PaymentHandlers<URL>
server: URL
signer?: Signer
createDeleteAuth: ((signer, hash, message?, expiration?) => Promise<SignedEvent>) = createDeleteAuth

Type declaration

    • (signer, hash, message?, expiration?): Promise<SignedEvent>
    • Parameters

      • signer: Signer
      • hash: string | string[]
      • message: string = "Delete Blob"
      • expiration: number = ...

      Returns Promise<SignedEvent>

createGetAuth: ((signer, serverOrHash, message, expiration?) => Promise<SignedEvent>) = createDownloadAuth

Type declaration

    • (signer, serverOrHash, message, expiration?): Promise<SignedEvent>
    • Creates a GET auth event

      Parameters

      • signer: Signer

        the signer to use for signing the event

      • serverOrHash: string | string[]

        A server URL or one or many blob hashes

      • message: string

        A human readable explanation of what the auth token will be used for

      • expiration: number = ...

        The expiration time in seconds

      Returns Promise<SignedEvent>

createListAuth: ((signer, message?, expiration?) => Promise<SignedEvent>) = createListAuth

Type declaration

    • (signer, message?, expiration?): Promise<SignedEvent>
    • Parameters

      • signer: Signer
      • message: string = "List Blobs"
      • expiration: number = ...

      Returns Promise<SignedEvent>

createUploadAuth: ((signer, blobsOrHashes, message?, expiration?) => Promise<SignedEvent>) = createUploadAuth

Type declaration

    • (signer, blobsOrHashes, message?, expiration?): Promise<SignedEvent>
    • Creates an upload auth event

      Parameters

      • signer: Signer

        the signer to use for signing the event

      • blobsOrHashes: string | string[] | UploadType | UploadType[]

        one or an array of sha256 hashes

      • message: string = "Upload Blob"

        A human readable explanation of what the auth token will be used for

      • expiration: number = ...

        The expiration time in seconds

      Returns Promise<SignedEvent>

deleteBlob: (<S>(server, hash, opts?) => Promise<boolean>) = deleteBlob

Type declaration

    • <S>(server, hash, opts?): Promise<boolean>
    • Deletes a blob to a server

      Type Parameters

      Parameters

      • server: S
      • hash: string
      • Optional opts: DeleteOptions<S>

      Returns Promise<boolean>

downloadBlob: (<S>(server, hash, opts?) => Promise<Response>) = downloadBlob

Type declaration

    • <S>(server, hash, opts?): Promise<Response>
    • Downloads a blob from a server and returns the Response

      Type Parameters

      Parameters

      • server: S
      • hash: string
      • Optional opts: DownloadOptions<S>

      Returns Promise<Response>

encodeAuthorizationHeader: ((event) => string) = encodeAuthorizationHeader

Type declaration

    • (event): string
    • Parameters

      • event: SignedEvent

      Returns string

getFileSha256: ((blob) => string | Promise<string>) = getBlobSha256

Type declaration

    • (blob): string | Promise<string>
    • gets or calculates the sha2456 of a Blob

      Parameters

      Returns string | Promise<string>

listBlobs: (<S>(server, pubkey, opts?) => Promise<BlobDescriptor[]>) = listBlobs

Type declaration

    • <S>(server, pubkey, opts?): Promise<BlobDescriptor[]>
    • Mirrors a blob to a server

      Type Parameters

      Parameters

      • server: S
      • pubkey: string
      • Optional opts: ListOptions<S>

      Returns Promise<BlobDescriptor[]>

mirrorBlob: (<S>(server, blob, opts?) => Promise<BlobDescriptor>) = mirrorBlob

Type declaration

    • <S>(server, blob, opts?): Promise<BlobDescriptor>
    • Mirrors a blob to a server

      Type Parameters

      Parameters

      • server: S
      • blob: BlobDescriptor
      • Optional opts: MirrorOptions<S>

      Returns Promise<BlobDescriptor>

uploadBlob: (<S, B>(server, blob, opts?) => Promise<BlobDescriptor>) = uploadBlob

Type declaration

    • <S, B>(server, blob, opts?): Promise<BlobDescriptor>
    • Upload a blob to a server, handles payment and auth

      Type Parameters

      Parameters

      • server: S
      • blob: B
      • Optional opts: UploadOptions<S, B>

      Returns Promise<BlobDescriptor>

Methods

  • Parameters

    • hash: string
    • Optional message: string
    • Optional expiration: number

    Returns Promise<SignedEvent>

  • Parameters

    • message: string
    • hash: string
    • Optional expiration: number

    Returns Promise<SignedEvent>

  • Parameters

    • Optional message: string
    • Optional expiration: number

    Returns Promise<SignedEvent>

  • Parameters

    • blob: string | BlobDescriptor
    • Optional message: string
    • Optional expiration: number

    Returns Promise<SignedEvent>

  • Parameters

    • blob: UploadType
    • Optional message: string
    • Optional expiration: number

    Returns Promise<SignedEvent>

  • Parameters

    • hash: string
    • Optional opts: Omit<DeleteOptions<URL>, "auth" | "onPayment" | "onAuth"> & {
          auth?: boolean | SignedEvent;
          payment?: boolean;
      }

    Returns Promise<boolean>

  • Parameters

    • hash: string
    • Optional opts: Omit<DownloadOptions<URL>, "auth" | "onPayment" | "onAuth"> & {
          auth?: boolean | SignedEvent;
          payment?: boolean;
      }

    Returns Promise<Blob>

  • Parameters

    • hash: string

    Returns Promise<boolean>

  • Parameters

    • pubkey: string
    • Optional opts: Omit<ListOptions<URL>, "auth" | "onPayment" | "onAuth"> & {
          auth?: boolean | SignedEvent;
          payment?: boolean;
      }

    Returns Promise<BlobDescriptor[]>

  • Parameters

    • blob: BlobDescriptor
    • Optional opts: Omit<MirrorOptions<URL>, "auth" | "onPayment" | "onAuth"> & {
          auth?: boolean | SignedEvent;
          payment?: boolean;
      }

    Returns Promise<BlobDescriptor>

  • Type Parameters

    Parameters

    • blob: B
    • Optional opts: Omit<UploadOptions<URL, B>, "auth" | "onPayment" | "onAuth"> & {
          auth?: boolean | SignedEvent;
          payment?: boolean;
      }

    Returns Promise<BlobDescriptor>

  • Parameters

    Returns Promise<boolean>