npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@afriex/media

v1.0.0

Published

Upload invoices, payment proofs and documents to the Afriex Business API

Readme

@afriex/media

File upload service for the Afriex SDK. Upload an invoice, a payment proof or an identity document, and get back the key that other requests take.

Installation

npm install @afriex/media @afriex/core
# or
pnpm add @afriex/media @afriex/core

Usage

import { readFile } from "node:fs/promises";
import { AfriexClient } from "@afriex/core";
import { MediaService } from "@afriex/media";

const client = new AfriexClient({
  apiKey: "your-api-key",
});

const media = new MediaService(client.getHttpClient());

// Upload a file in one call
const { key } = await media.upload({
  fileName: "invoice-1042.pdf",
  type: "transaction",
  file: await readFile("./invoice-1042.pdf"),
  contentType: "application/pdf",
});

// Or do the two steps yourself
const uploadUrl = await media.createUploadUrl({
  fileName: "invoice-1042.pdf",
  type: "transaction",
});

await fetch(uploadUrl.url, {
  method: "PUT",
  body: await readFile("./invoice-1042.pdf"),
});

console.log(uploadUrl.key, uploadUrl.expiresIn);

Attach the key to the request that needs the file. Requests never take the presigned URL.

| The file is | Upload it with type | Pass the key as | | --------------------------------- | --------------------- | ---------------------------------------------------- | | An invoice for a SWIFT withdrawal | transaction | meta.invoice on transactions.create() | | A pool-account payment proof | transaction | fileKey on transactions.submitPoolAccountProof() | | An identity document | user | The document field that asks for it |

API Reference

createUploadUrl(request: CreateUploadUrlRequest): Promise<UploadUrl>

Generate a presigned URL to upload one file to.

Endpoint: POST /media/url

Required: fileName

Optional: type, one of transaction or user. Defaults to user.

Returns: { url, key, expiresIn }. PUT the file to url within expiresIn seconds (usually 300). After that, request a new URL.

upload(request: UploadFileRequest): Promise<UploadedFile>

Request an upload URL and upload the file to it.

Required: fileName, file (a Blob, an ArrayBuffer or a Uint8Array; a Node.js Buffer is a Uint8Array)

Optional: type, contentType

Returns: { key }

Throws: ValidationError before any request when file is not one of the accepted types, NetworkError when the upload cannot be sent, and AfriexError when the storage host rejects it.

The upload goes to the storage host, not to the Afriex API, so it is sent without your API key and is not retried.

The two upload types

transaction and user files are stored apart. A key from one is not found by an endpoint that expects the other: a pool-account payment proof uploaded as user is rejected with INVALID_BUSINESS_POOL_ACCOUNT_REQUEST.

License

MIT