apk-hub-sdk
v1.0.1
Published
Official JavaScript/TypeScript SDK, AES-256 Crypto & CLI for APK Hub Android app distribution and OTA updates
Maintainers
Readme
APK Hub SDK (apk-hub-sdk)
Official JavaScript & TypeScript SDK, AES-256 Crypto Utilities, and CLI for APK Hub — the modern Android OTA update and app distribution platform.
📦 Installation
# npm
npm install apk-hub-sdk
# yarn
yarn add apk-hub-sdk
# pnpm
pnpm add apk-hub-sdk🚀 Features
- ⚡ Over-The-Air (OTA) Updates: Seamless in-app updates for React Native, Capacitor, and Node.js.
- 🔐 AES-256-GCM Encryption & Decryption: Secure token storage, payload encryption, and safe API key obfuscation.
- 🛡️ SHA-256 Hash Integrity: Automatically checks and verifies binary integrity before install.
- 🚀 CI/CD CLI: Publish and manage releases straight from GitHub Actions / GitLab CI.
- 📦 Dual-Mode API: Client-side read-only key (
pk_live_...) and CI/CD secret key (sk_live_...).
🔒 Encryption & Decryption Usage
import { encrypt, decrypt, encryptJSON, decryptJSON, sha256 } from 'apk-hub-sdk'
const secretPassphrase = 'your-secure-passphrase-or-key'
// 1. String Encryption & Decryption (AES-256-GCM)
const ciphertext = encrypt('sensitive_api_key_or_token', secretPassphrase)
console.log('Encrypted:', ciphertext) // enc_gcm:iv:tag:ciphertext
const plaintext = decrypt(ciphertext, secretPassphrase)
console.log('Decrypted:', plaintext) // sensitive_api_key_or_token
// 2. JSON Object Encryption & Decryption
const payload = { userId: '123', plan: 'enterprise', active: true }
const encryptedObject = encryptJSON(payload, secretPassphrase)
const decryptedObject = decryptJSON<{ userId: string }>(encryptedObject, secretPassphrase)
console.log('User ID:', decryptedObject.userId)
// 3. SHA-256 Hashing
const hash = sha256('file-or-data-content')
console.log('SHA-256:', hash)📱 React Native OTA Updates
import { ApkHubUpdater } from 'apk-hub-sdk'
import { Alert } from 'react-native'
import DeviceInfo from 'react-native-device-info'
const updater = new ApkHubUpdater({
packageName: 'com.example.myapp',
publicKey: 'pk_live_your_public_key',
currentVersionCode: parseInt(DeviceInfo.getBuildNumber(), 10),
channel: 'stable',
})
export async function checkForAppUpdates() {
await updater.checkAndUpdate({
onUpdateFound: async (info) => {
return new Promise((resolve) => {
Alert.alert(
'Update Available',
`Version ${info.latestVersion} is available.\n\n${info.releaseNotes}`,
[
{ text: 'Later', style: 'cancel', onPress: () => resolve(false) },
{ text: 'Update Now', onPress: () => resolve(true) }
]
)
})
},
onProgress: (percent) => {
console.log(`Download progress: ${percent}%`)
},
onReadyToInstall: (filePath) => {
console.log('Downloaded APK verified and ready at', filePath)
},
onError: (err) => {
console.error('Update failed:', err)
}
})
}🛠️ CI/CD CLI Commands
Run directly with npx:
# 1. Encrypt or Decrypt data
npx apk-hub-sdk encrypt "MySecretValue" --key "passphrase123"
npx apk-hub-sdk decrypt "enc_gcm:..." --key "passphrase123"
# 2. Check for App Updates
npx apk-hub-sdk check com.example.myapp --key pk_live_abc123 --installed 40
# 3. Publish an APK Release (GitHub Actions / GitLab CI)
npx apk-hub-sdk publish ./build/app-release.apk \
--app app_12345 \
--key sk_live_your_secret_key \
--notes "Performance improvements and bug fixes" \
--channel stable \
--rollout 100📄 License
MIT © APK Hub Team
