@cjwddz/git-cdn
v1.0.4
Published
Use GitHub repository as CDN resource storage with optional per-file AES-256-GCM encryption
Maintainers
Readme
@cjwddz/git-cdn
Use a GitHub repository as CDN resource storage, with optional per-file AES-256-GCM encryption.
Features
- Upload / download / delete files in a GitHub repo
- Generate CDN URLs (jsdelivr by default, customizable)
- Per-file AES-256-GCM encryption with independent keys
- Atomic directory sync (merge / replace / clean)
- Browser-side decryption module (~1KB gzip)
- CLI tool for terminal usage
Install
npm install @cjwddz/git-cdnQuick Start
import { GitCDN } from '@cjwddz/git-cdn';
const cdn = new GitCDN({
repo: 'my-assets', // owner auto-detected from token
token: 'ghp_xxxxxxxxxxxx',
branch: 'main',
});
// Upload
const info = await cdn.upload({
source: './logo.png',
repoPath: 'images/logo.png',
});
console.log(info.url);
// Upload with encryption
await cdn.upload({
source: './secret.json',
repoPath: 'data/secret.json',
encryptionKey: 'my-key',
});
// Download with decryption
const data = await cdn.get({
repoPath: 'data/secret.json',
decryptionKey: 'my-key',
});Browser Decryption
import { decryptUrl } from '@cjwddz/git-cdn/browser';
const blobUrl = await decryptUrl(cdnUrl, 'my-key');
document.querySelector('img').src = blobUrl;CLI
git-cdn --repo user/assets --token ghp_xxx upload ./file.png images/file.png
git-cdn get images/file.png ./output.png
git-cdn list images --recursive
git-cdn sync ./local-dir remote-dir --mode replaceSee skill.md for full API reference.
Development
npm install
npm run build
npm run test
npm run lintPublishing
git tag [email protected]
git push origin [email protected]