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

oss-s3

v0.0.2

Published

Aliyun OSS API 兼容层,用于将依赖 `ali-oss` 的项目迁移到 AWS S3/STS,尽量保持代码不变。

Readme

oss-s3

Aliyun OSS API 兼容层,用于将依赖 ali-oss 的项目迁移到 AWS S3/STS,尽量保持代码不变。

特性

  • OSS 模式直连 ali-oss,S3 模式包装 AWS SDK v3
  • API 与类型签名对齐 Aliyun OSS(以 @types/ali-oss 为准)
  • 支持 Bun/Node 服务端与 Browser(Webpack 5)
  • 支持 AWS 默认凭证链(EKS Pod Identity/EC2/ECS 角色/环境变量)

安装

bun add oss-s3
# or
npm install oss-s3

快速使用

OSS 模式(Aliyun OSS)

import OSSCompat from "oss-s3";

const client = new OSSCompat({
  mode: "oss",
  region: "oss-cn-hangzhou",
  accessKeyId: "<accessKeyId>",
  accessKeySecret: "<accessKeySecret>",
  bucket: "<bucket-name>",
});

S3 模式(AWS S3)

import OSSCompat from "oss-s3";

const client = new OSSCompat({
  mode: "s3",
  region: "us-west-2",
  bucket: "my-bucket",
});

全局默认配置(迁移开关)

import { configure, getDefaults } from "oss-s3";

configure({
  mode: "s3",
  region: "us-west-2",
  s3: { requestChecksumCalculation: "WHEN_REQUIRED", upload: { auto: true } },
});

const defaults = getDefaults();
console.log(defaults.mode, defaults.region);

说明:

  • createClient / createSts 未显式传入 mode 时会使用默认值
  • S3 模式未显式传入 region 时会使用默认 region
  • 请在创建客户端之前调用 configure

配置说明

顶层字段(OSS/S3 共用):

  • mode: "oss" | "s3"
  • region, endpoint
  • accessKeyId, accessKeySecret, stsToken
  • bucket, secure, timeout, cname 等 OSS 配置字段

S3 专用配置(s3 字段):

  • requestChecksumCalculation: "WHEN_SUPPORTED" | "WHEN_REQUIRED"
  • requestStreamBufferSize
  • forcePathStyle
  • upload: { enabled?, auto?, partSize?, queueSize?, leavePartsOnError? }

S3 认证方式

  • 支持显式提供 accessKeyId/accessKeySecret
  • 支持 AWS 默认凭证链(EKS Pod Identity/EC2/ECS 角色/环境变量)
  • 使用默认凭证链时,建议用 asyncSignatureUrl 生成签名 URL(同步 signatureUrl 需要显式 AK)
  • 建议明确 region,或使用 AWS_REGION / AWS_DEFAULT_REGION

S3 上传提示

  • requestChecksumCalculation 控制上传校验和计算:默认 WHEN_SUPPORTED
  • 流式 Body 出现校验和报错时,可设置 requestStreamBufferSize 或将 Body 转为 ReadableStream/Uint8Array
  • 若出现 “unknown length” 警告或网络协商问题,可启用 s3.upload
    • enabled: true 强制所有 putUpload
    • auto: true 仅在无法推断 ContentLength 时启用 Upload

S3 模式能力覆盖

已实现:

  • put / get / getStream / head / delete
  • list / listV2
  • copy / putMeta / deleteMulti
  • getObjectUrl / generateObjectUrl
  • signatureUrl / asyncSignatureUrl / signatureUrlV4

暂不支持:

  • putStream
  • append
  • 桶级操作(listBuckets/putBucket 等)
  • ACL/Policy/Logging/Website/Lifecycle/CORS 等桶配置
  • multipart 相关能力(initMultipartUpload/uploadPart/complete 等)
  • restore/object-tagging/rtmp/image 等扩展能力

STS 兼容性

  • OSS 模式:OSS.STS(ali-oss 原生)
  • S3 模式:createSts / AwsStsCompatassumeRole 结构对齐)

构建与测试

bun run build
bun test