Skip to content

Get started

You need Go 1.26 or newer.

Terminal window
go get gitlab.techeve.de/techeve/pq-seal@latest
sealer, err := pqseal.New(pqseal.Options{})
if err != nil {
return err
}
defer sealer.Close()
// Serves the key and the browser files under a path of your choice.
pqfiber.Mount(app, "/pq-seal", sealer)

Put Mount before the login check if a login page uses it. Without Fiber, see Integration.

const address = '/pq-seal/client.js';
const { SealClient } = await import(/* @vite-ignore */ address);
const seal = await SealClient.connect();
const response = await seal.withFreshKey(async () => fetch('/my/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ user, password: await seal.encrypt('login', password) }),
}));

The result of encrypt is a string, the route belongs to your application. withFreshKey covers a server restart while the page is open.

The address is in a variable on purpose: the Vite dev server tries to resolve a literal, even with @vite-ignore.

password, err := sealer.Open(request.Password, "login")
if err != nil {
return pqfiber.Error(c, err)
}

The context login is free to choose and must be the same on both sides.

The selftest shows whether a browser can do everything:

Terminal window
go run gitlab.techeve.de/techeve/pq-seal/cmd/selftest@latest

Then open http://localhost:8080/.