@inngest/middleware-encryption
Version:
E2E encryption middleware for Inngest.
31 lines (30 loc) • 1.1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.manualEncryptionMiddleware = void 0;
const inngest_1 = require("inngest");
const stages_1 = require("./stages");
/**
* Encrypts and decrypts data sent to and from Inngest.
*
* Returns two separate middlewares: one for encrypting data, and one for
* decrypting data, used in special circumstances pre-v4.
*/
const manualEncryptionMiddleware = (
/**
* Options used to configure the encryption middleware. If a custom
* `encryptionService` is not provided, the `key` option is required.
*/
opts) => {
const { encrypt, decrypt } = (0, stages_1.getEncryptionStages)(opts);
return {
encryptionMiddleware: new inngest_1.InngestMiddleware({
name: "@inngest/middleware-encryption/manual/encrypt",
init: () => encrypt,
}),
decryptionMiddleware: new inngest_1.InngestMiddleware({
name: "@inngest/middleware-encryption/manual/decrypt",
init: () => decrypt,
}),
};
};
exports.manualEncryptionMiddleware = manualEncryptionMiddleware;