{"_id":"@1-/s3","name":"@1-/s3","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@1-/s3","version":"0.1.0","description":"Minimalist S3 uploader with SHA3-256 deduplication / 基于 SHA3-256 哈希去重的极简 S3 上传工具","keywords":["deduplication","s3","sha3-256","signature-v4","upload"],"homepage":"https://github.com/webc-site/npm/tree/main/s3","license":"MulanPSL-2.0","author":{"name":"x-at-01@googlegroups.com"},"repository":{"type":"git","url":"git+https://github.com/webc-site/npm.git"},"type":"module","exports":{"./*":"./*"},"peerDependencies":{"@1-/url_exist":"^0.1.0","@3-/ext":"^0.0.2","@3-/req":"^0.1.18","@3-/utf8":"^0.1.1"},"_id":"@1-/s3@0.1.0","bugs":{"url":"https://github.com/webc-site/npm/issues"},"_nodeVersion":"26.2.0","_npmVersion":"11.13.0","dist":{"integrity":"sha512-ZFkly9k2GkhLCf8DqeXlbaHm/wWLRC1YE62s3/MrCbuDcGcEVMrRlWmIAKhoKXvb8VS2tWlHoUHPd5kRfyPEoA==","shasum":"a25e67eabcd5a762ffe50edded239f89225d73d7","tarball":"https://registry.npmjs.org/@1-/s3/-/s3-0.1.0.tgz","fileCount":16,"unpackedSize":11808,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDoPL8SsDCzUqb+HJTj04EkAY5CGsn04510hCUd/Bq3mAIgE9D4MP3RXwsiwS3l4fy20eDNg/M0eal997dgotejVbY="}]},"_npmUser":{"name":"i18n-now","email":"i18n.site@gmail.com"},"directories":{},"maintainers":[{"name":"i18n-now","email":"i18n.site@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/s3_0.1.0_1781019595472_0.5411963371949071"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-09T15:39:55.299Z","0.1.0":"2026-06-09T15:39:55.618Z","modified":"2026-06-09T15:39:55.961Z"},"maintainers":[{"name":"i18n-now","email":"i18n.site@gmail.com"}],"description":"Minimalist S3 uploader with SHA3-256 deduplication / 基于 SHA3-256 哈希去重的极简 S3 上传工具","homepage":"https://github.com/webc-site/npm/tree/main/s3","keywords":["deduplication","s3","sha3-256","signature-v4","upload"],"repository":{"type":"git","url":"git+https://github.com/webc-site/npm.git"},"author":{"name":"x-at-01@googlegroups.com"},"bugs":{"url":"https://github.com/webc-site/npm/issues"},"license":"MulanPSL-2.0","readme":"[English](#en) | [中文](#zh)\n\n---\n\n<a id=\"en\"></a>\n# @1-/s3 : Minimalist S3 uploader with SHA3-256 deduplication\n\n## Features\n\n- Hash deduplication: Verifies file existence via HEAD request before upload, reducing bandwidth and storage.\n- Native cryptography: Computes HMAC-SHA256 signature using Web Crypto API to generate AWS Signature Version 4, eliminating external cryptography library dependencies.\n- Zero SDK: Implements direct HTTP requests without AWS SDK, minimizing package size.\n- Automatic MIME identification: Resolves MIME types automatically based on file extensions.\n- Long-term caching: Adds immutable Cache-Control headers to optimize CDN distribution.\n\n## Usage\n\n```javascript\nimport uploadInit from \"@1-/s3/upload.js\";\n\nconst upload = uploadInit(\n  process.env.S3_ID,\n  process.env.S3_SK,\n  process.env.S3_HOST,\n  process.env.S3_BUCKET,\n  process.env.S3_REGION,\n);\n\nconst buf = Buffer.from(\"data\");\nconst sha3_b64 = await upload(buf, \"test.txt\");\n\nconsole.log(sha3_b64);\n```\n\n## Design\n\n![](https://fastly.jsdelivr.net/gh/webc-fs/-@p8/gH0INfqSzrKgAN1Azflg.svg)\n\n## Tech Stack\n\n- Runtime: Bun / Node.js\n- Cryptography: Web Crypto API (HMAC-SHA256)\n- Hash: Node.js / Bun crypto module (SHA3-256)\n- Network: `@3-/req` (Fetch API wrapper)\n\n## Code Structure\n\n- `src/upload.js`: Orchestrates check and upload flow.\n- `src/sign.js`: Generates AWS Signature Version 4.\n- `src/sha3b64.js`: Computes SHA3-256 base64url hash.\n- `src/extMime.js`: Resolves MIME from file extension.\n- `src/mime.js`: Dictionary of extension-to-MIME mappings.\n- `src/amzDate.js`: Formats UTC timestamps required by AWS.\n- `src/const.js`: Constant definitions including Cache-Control headers.\n\n## History\n\nAWS S3 (Simple Storage Service) was launched by Amazon in 2006, introducing cloud object storage with simple HTTP methods (GET, PUT, DELETE) to manage internet-scale data.\n\nContent-Addressable Storage (CAS) trace back to the Venti backup system of Bell Labs in 2002, and Git version control system later.\n\nThis library combines both ideas, calculating SHA3-256 hashes on client-side to achieve cost-effective S3 upload deduplication with minimal code size.\n\n## About\n\nThis library is developed by [WebC.site](https://webc.site).\n\n[WebC.site](https://webc.site): A new paradigm of web development for AI\n\n---\n\n<a id=\"zh\"></a>\n# @1-/s3 : 基于 SHA3-256 哈希去重的极简 S3 上传工具\n\n## 功能介绍\n\n- 哈希去重：上传前发送 HEAD 请求验证文件是否存在，节省带宽与存储。\n- 原生加密：调用 Web Crypto API 计算 HMAC-SHA256 生成 AWS Signature Version 4 签名，无第三方加密库依赖。\n- 零 SDK：无需 AWS SDK，缩减依赖体积。\n- 自动识别 MIME：根据文件后缀自动映射 MIME 类型。\n- 长期缓存：注入 Cache-Control 头，优化 CDN 缓存效率。\n\n## 使用演示\n\n```javascript\nimport uploadInit from \"@1-/s3/upload.js\";\n\nconst upload = uploadInit(\n  process.env.S3_ID,\n  process.env.S3_SK,\n  process.env.S3_HOST,\n  process.env.S3_BUCKET,\n  process.env.S3_REGION,\n);\n\nconst buf = Buffer.from(\"data\");\nconst sha3_b64 = await upload(buf, \"test.txt\");\n\nconsole.log(sha3_b64);\n```\n\n## 设计思路\n\n![](https://fastly.jsdelivr.net/gh/webc-fs/-@Fa/QwHd0pzgXyjpJku37knA.svg)\n\n## 技术栈\n\n- 运行环境：Bun / Node.js\n- 加密算法：Web Crypto API (HMAC-SHA256)\n- 哈希计算：Node.js / Bun crypto 模块 (SHA3-256)\n- 网络请求：`@3-/req` (基于 Fetch API 的封装)\n\n## 代码结构\n\n- `src/upload.js`: 编排检测与上传流程。\n- `src/sign.js`: 实现 AWS Signature Version 4 签名。\n- `src/sha3b64.js`: 计算 Buffer 的 SHA3-256 值并转为 base64url 格式。\n- `src/extMime.js`: 文件后缀获取及 MIME 映射。\n- `src/mime.js`: 常用 MIME 类型字典与匹配逻辑。\n- `src/amzDate.js`: 格式化 AWS 要求的 UTC 时间戳。\n- `src/const.js`: 定义默认的 Cache-Control 响应头常量。\n\n## 历史故事\n\nAWS S3 于 2006 年由亚马逊推出，开启了云计算对象存储时代，使用简单的 HTTP 方法（GET、PUT、DELETE）解决大规模文件存储扩展性难题。\n\n内容寻址存储（CAS）设计理念最早可追溯至 2002 年贝尔实验室的 Venti 备份系统，后被 Git 等版本控制系统广泛采用。\n\n本工具将内容寻址与 S3 存储结合，在客户端完成 SHA3-256 计算，以精简的代码实现存储去重。\n\n## 关于\n\n本库由 [WebC.site](https://webc.site) 开发。\n\n[WebC.site](https://webc.site) : 面向人工智能的网站开发新范式\n","readmeFilename":"README.md","_rev":"1-ac7f04e90f34d34d6330a11d68c16339"}