ensc-ts-sdk
v1.3.6
Published
A lightweight Typescript library to give you the best experience with managing your ensc business profile
Downloads
45
Maintainers
Readme
ensc-ts-sdk
A tiny, typed SDK for the ENSC Payments API. It automatically encrypts (AES-256-GCM) and signs (Ed25519) requests, and works in browsers and Node without shims.
- ⚙️ Typed Axios client
- 🔐 AES-256-GCM encryption + Ed25519 signing
- 🌐 Browser & Node compatible (dynamic
cryptoimport) - 📦 ESM & CJS builds + TypeScript types
- 🧹 Tree-shakable (
"sideEffects": false)
Install
npm i ensc-ts-sdk
# or: yarn add ensc-ts-sdk
# or: pnpm add ensc-ts-sdkQuick start
import { ENSCClient, Asset } from 'ensc-ts-sdk';
const client = new ENSCClient({
apiKey: process.env.API_KEY!, // issued by ProsperaVest
encryptionKey: process.env.ENCRYPTION_KEY!, // base64-encoded 32B AES key
privateKey: process.env.SIGNING_PRIVATE_KEY!, // PEM (Ed25519)
// baseUrl: 'https://ensc.prosperavest.com' // optional override
});
// Approve then transfer
await client.approve({
recipient: '0xReceiver...',
assetType: Asset.ENSC,
amount: 100
});
await client.transfer({
from: '0xSender...',
recipient: '0xReceiver...',
assetType: Asset.ENSC,
amount: 100
});API
Client
new ENSCClient({
apiKey: string,
encryptionKey: string, // base64 AES-256 (32 bytes)
privateKey: string, // PEM Ed25519 (RFC 8410)
baseUrl?: string
});Methods
client.mint({ recipient, amount, assetSymbol })
client.mintAllocation({ recipient })
client.approve({ recipient, assetType, amount, sender? })
client.transfer({ from, recipient, assetType, amount })
client.redeemAsset({
recipient, amount, assetType,
payoutEmail?, bank?, accountNumber?
})
client.withdraw({ pvRef, txHash })
client.getBalance(recipient, assetContractAddress)
client.getTransactionHistory(page?, limit?)
client.verifyPayout({ tx_ref })
client.getBanks()All requests except
/banksand/generate-virtual-accountare encrypted + signed automatically.
Crypto helpers (optional)
If you need direct access:
import { encryptPayload, type EncryptedPayload } from 'ensc-ts-sdk';
import { verifySignature } from 'ensc-ts-sdk';
// Also: signMessage, decryptPayloadBrowser & Node
- Browser: WebCrypto (AES-GCM) +
tweetnaclfor Ed25519. - Node: dynamic
import('crypto')for AES-GCM & verification. - We guard all
process.envusage so bundlers don’t inject shims.
Types & Modules
- ESM:
dist/index.mjs - CJS:
dist/index.js - Types:
dist/index.d.ts
Troubleshooting
- “Invalid AES-256 key” →
encryptionKeymust be base64 for exactly 32 bytes. - Signature/401/403 → Verify PEM formatting of the Ed25519 key, and API key validity.
- Bundler tries to polyfill
cryptoin browser → We only import Nodecryptodynamically on server paths.
Development
npm i
npm run build
npm testIntegration tests require env vars:
API_BASE_URL,API_KEY,ENCRYPTION_KEY,SIGNING_PRIVATE_KEY
Versioning
SemVer. Use patch for internal fixes, minor for backward-compatible features, major for breaking changes.
License
MIT © ProsperaVest
---
# `ensc-ts-sdk/CHANGELOG.md` (template)
```md
# Changelog
All notable changes to **ensc-ts-sdk** will be documented here.
## [1.3.1] - 2025-xx-xx
### Added
- ...
### Changed
- ...
### Fixed
- ...
### Removed
- ...
---
## [1.3.0] - 2025-xx-xx
### Added
- Initial public release with:
- AES-256-GCM encryption + Ed25519 signing
- ESM/CJS + types
- Approve, transfer, redeem, withdraw, balances, transactions, banks