@aspect-evp/issuer
v0.2.0
Published
EVP issuer implementation for email providers
Maintainers
Readme
@aspect-evp/issuer
EVP issuer implementation for email providers.
Installation
npm install @aspect-evp/issuerUsage
import { createIssuerMiddleware, EmailVerificationIssuer } from '@aspect-evp/issuer';
// Initialize with your signing key
const issuer = new EmailVerificationIssuer({
issuer: 'mail.example.com',
privateKey: yourPrivateKeyJWK,
kid: '2024-01-key',
algorithm: 'EdDSA',
privateEmailSupported: true,
webauthnSupported: true,
});
const middleware = createIssuerMiddleware(
issuer,
async (cookie, email) => userSessionOwnsEmail(cookie, email),
{
createPrivateEmail: async (email) => createRelayAddress(email),
verifyDirectedEmail: async (email, directed) => relayBelongsTo(email, directed),
createWebAuthnChallenge: async (email) => createChallenge(email),
verifyWebAuthnResponse: async (email, response, cookie) =>
verifyAssertion(email, response, cookie),
}
);
// Serve /.well-known/email-verification
app.get('/.well-known/email-verification', (req, res) => {
res.json(issuer.getMetadata('https://mail.example.com'));
});
// Serve JWKS
app.get('/email-verification/jwks', async (req, res) => {
res.json(await issuer.getJWKS());
});
// Pass a standard Web Request to middleware.handleIssuance() and serialize
// its { status, headers, body } result with your framework adapter.Key Generation
import { EmailVerificationIssuer } from '@aspect-evp/issuer';
// Generate a new EdDSA key pair
const keyPair = await EmailVerificationIssuer.generateKeyPair('EdDSA');
console.log(keyPair.privateKey); // Store securely
console.log(keyPair.publicKey); // Expose via JWKSSupported Algorithms
EdDSA(recommended)ES256ES384RS256
Documentation
See the full documentation for complete API reference.
License
MIT
