For full documentation, visit docs.postguard.eu.
TypeScript/JavaScript SDK for PostGuard, published as @e4a/pg-js on npm. Works in both browsers and Node.js.
PostGuard encrypts data for recipients based on their identity attributes (email address, phone number, etc.) rather than traditional public keys. Recipients prove their identity via Yivi to decrypt. This SDK is the main way web applications and email add-ons integrate with PostGuard.
npm install @e4a/pg-jsimport { PostGuard } from '@e4a/pg-js';
const pg = new PostGuard({
pkgUrl: 'https://pkg.postguard.eu',
});
// Encrypt
const sealed = pg.encrypt({
sign: pg.sign.apiKey('your-api-key'),
recipients: [pg.recipient.email('bob@example.com')],
files: fileList,
});
const { uuid } = await sealed.upload();
// Decrypt
const opened = pg.open({ uuid });
const result = await opened.decrypt({ element: '#yivi-popup' });
result.download();See the full API reference for encryption options, signing methods, recipient types, and email helpers.
Install dependencies and build:
npm install
npm run prebuild
npm run buildRun the tests:
npm run testReleases are handled by semantic-release on the main branch. When commits land on main, semantic-release determines the next version from conventional commit messages and publishes to npm automatically.
MIT