Pick the SDK that matches your platform, install it, and encrypt something.
Install the SDK:
::: code-group
npm install @e4a/pg-jspnpm add @e4a/pg-jsyarn add @e4a/pg-js:::
The SDK bundles all its dependencies internally. You do not need to install @e4a/pg-wasm, Yivi packages, or any other PostGuard package separately.
import { PostGuard } from '@e4a/pg-js';
const pg = new PostGuard({
pkgUrl: 'https://pkg.staging.yivi.app',
cryptifyUrl: 'https://fileshare.staging.yivi.app',
});
const sealed = pg.encrypt({
files: fileList,
recipients: [pg.recipient.email('bob@example.com')],
sign: pg.sign.apiKey('PG-your-key'),
});
// Silent upload by default. Pass `notify: { recipients: true }` to have
// Cryptify also email the recipient a download link.
const { uuid } = await sealed.upload();const opened = pg.open({ uuid });
const result = await opened.decrypt({
element: '#yivi-web',
});
result.download();The element parameter points to an HTML element where the SDK renders the Yivi QR code. The recipient scans this with their Yivi app to prove their identity.
You need Vite plugins for WASM support and top-level await:
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
import wasm from 'vite-plugin-wasm';
import topLevelAwait from 'vite-plugin-top-level-await';
export default defineConfig({
plugins: [sveltekit(), wasm(), topLevelAwait()]
});No Node.js polyfills are needed. The SDK handles all browser compatibility internally.
The SDK inlines its WASM binary as base64 at build time, so no WASM loader plugins or file copying are needed. The Thunderbird addon bundles with esbuild and the WASM is included automatically.
Your extension manifest must allow WASM execution ('wasm-unsafe-eval' in Manifest V3 CSP). See the Thunderbird addon bundling section for full details.
See the JS SDK reference for all encryption and decryption options, or the pg-sveltekit example for a complete web app.
Install from NuGet:
dotnet add package E4A.PostGuardThe .NET SDK requires a native library (libpg_ffi) built from the postguard repo. The NuGet package includes prebuilt binaries for linux-x64, linux-arm64, osx-x64, osx-arm64, and win-x64.
using E4A.PostGuard;
using E4A.PostGuard.Models;
var pg = new PostGuard(new PostGuardConfig
{
PkgUrl = "https://pkg.staging.postguard.eu",
CryptifyUrl = "https://fileshare.staging.postguard.eu"
});
var sealed = pg.Encrypt(new EncryptInput
{
Files = [new PgFile("report.txt", fileStream)],
Recipients = [pg.Recipient.Email("bob@example.com")],
Sign = pg.Sign.ApiKey("PG-your-key")
});
// Silent upload by default. Pass `new UploadOptions { Notify = new
// NotifyOptions { Recipients = true } }` to also email the recipient.
var result = await sealed.UploadAsync();
Console.WriteLine(result.Uuid);The .NET SDK is sending-side only. Decryption is handled by the receiving side via the PostGuard website or email plugins.
See the .NET SDK reference for all options, or the pg-dotnet example for a complete console app.