Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@inngest/middleware-encryption
Advanced tools
Readme
[!WARNING] This package is currently in alpha. Use with caution.
This package provides an encryption middleware for Inngest, enabling secure handling of sensitive data. It encrypts data being sent to and from Inngest, ensuring plaintext data never leaves your server.
AES-256-CBC
.npm install @inngest/middleware-encryption
[!NOTE] Requires TypeScript SDK v3+
To use the encryption middleware, import and initialize it with your encryption key(s). You can optionally provide a custom encryption service.
By default, the following will be encrypted:
data.encrypted
import { encryptionMiddleware } from "@inngest/middleware-encryption";
// Initialize the middleware
const mw = encryptionMiddleware({
key: "your-encryption-key",
});
// Use the middleware with Inngest
const inngest = new Inngest({
id: "my-app",
middleware: [mw],
});
Only select pieces of event data are encrypted. By default, only the data.encrypted
field.
This can be customized using the eventEncryptionField
setting
string
- Encrypt fields matching this namestring[]
- Encrypt fields matching these names(field: string) => boolean
- Provide a function to decide whether to encrypt a fieldfalse
- Disable all event encryptionProvide an Array<string>
when providing your key
to support rotating encryption keys.
The first key is always used to encrypt, but decryption will be attempted with all keys.
To create a custom encryption service, you need to implement the abstract EncryptionService
class provided by the package. Your custom service must implement two core methods: encrypt
and decrypt
.
export abstract class EncryptionService {
public abstract encrypt(value: unknown): string;
public abstract decrypt(value: string): unknown;
}
For example, here's how you might define, instantiate, and use a custom encryption service:
import { EncryptionService } from "@inngest/middleware-encryption";
class CustomEncryptionService implements EncryptionService {
constructor(/* custom parameters */) {
// Initialization code here
}
encrypt(value: unknown): string {
// Implement your custom encryption logic here
// Example: return CustomEncryptLib.encrypt(JSON.stringify(value), this.customKey);
}
decrypt(value: string): unknown {
// Implement your custom decryption logic here
// Example: return JSON.parse(CustomEncryptLib.decrypt(value, this.customKey));
}
}
You can then pass it to the encryptionMiddleware
function like so:
const customService = new CustomEncryptionService(/* custom parameters */);
const mw = encryptionMiddleware({
encryptionService: customService,
});
// Use the middleware with Inngest
const inngest = new Inngest({
id: "my-app",
middleware: [mw],
});
FAQs
E2E encryption middleware for Inngest.
The npm package @inngest/middleware-encryption receives a total of 146 weekly downloads. As such, @inngest/middleware-encryption popularity was classified as not popular.
We found that @inngest/middleware-encryption demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.