@inngest/middleware-encryption
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -6,3 +6,12 @@ import { InngestMiddleware, type MiddlewareOptions } from "inngest"; | ||
declare const ENCRYPTION_MARKER = "__ENCRYPTED__"; | ||
/** | ||
* The default field used to store encrypted data in events. | ||
*/ | ||
export declare const DEFAULT_ENCRYPTION_FIELD = "encrypted"; | ||
/** | ||
* Available types to control the top-level fields of the event that will be | ||
* encrypted. Can be a single field name, an array of field names, a function | ||
* that returns `true` if a field should be encrypted, or `false` to disable all | ||
* event encryption. | ||
*/ | ||
export type EventEncryptionFieldInput = string | string[] | ((field: string) => boolean) | false; | ||
@@ -15,9 +24,9 @@ /** | ||
* The key or keys used to encrypt and decrypt data. If multiple keys are | ||
* provided, the first key will be used to encrypt data and all keys will | ||
* be tried when decrypting data. | ||
* provided, the first key will be used to encrypt data and all keys will be | ||
* tried when decrypting data. | ||
*/ | ||
key?: string | string[]; | ||
/** | ||
* The encryption service used to encrypt and decrypt data. If not provided, | ||
* a default encryption service will be used. | ||
* The encryption service used to encrypt and decrypt data. If not provided, a | ||
* default encryption service will be used. | ||
*/ | ||
@@ -27,6 +36,7 @@ encryptionService?: EncryptionService; | ||
* The top-level fields of the event that will be encrypted. Can be a single | ||
* field name, an array of field names, a function that returns `true` if | ||
* a field should be encrypted, or `false` to disable all event encryption. | ||
* field name, an array of field names, a function that returns `true` if a | ||
* field should be encrypted, or `false` to disable all event encryption. | ||
* | ||
* By default, the top-level field named `"encrypted"` will be encrypted (exported as `DEFAULT_ENCRYPTION_FIELD`). | ||
* By default, the top-level field named `"encrypted"` will be encrypted | ||
* (exported as `DEFAULT_ENCRYPTION_FIELD`). | ||
*/ | ||
@@ -39,2 +49,5 @@ eventEncryptionField?: EventEncryptionFieldInput; | ||
export declare const encryptionMiddleware: (opts: EncryptionMiddlewareOptions) => InngestMiddleware<MiddlewareOptions>; | ||
/** | ||
* The encrypted value as it will be sent to Inngest. | ||
*/ | ||
export interface EncryptedValue { | ||
@@ -50,3 +63,11 @@ [ENCRYPTION_MARKER]: true; | ||
export declare abstract class EncryptionService { | ||
/** | ||
* Given an `unknown` value, encrypts it and returns the encrypted value as a | ||
* `string`. | ||
*/ | ||
abstract encrypt(value: unknown): string; | ||
/** | ||
* Given an encrypted `string`, decrypts it and returns the decrypted value as | ||
* any value. | ||
*/ | ||
abstract decrypt(value: string): unknown; | ||
@@ -53,0 +74,0 @@ } |
@@ -14,2 +14,5 @@ "use strict"; | ||
const ENCRYPTION_MARKER = "__ENCRYPTED__"; | ||
/** | ||
* The default field used to store encrypted data in events. | ||
*/ | ||
exports.DEFAULT_ENCRYPTION_FIELD = "encrypted"; | ||
@@ -16,0 +19,0 @@ /** |
{ | ||
"name": "@inngest/middleware-encryption", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "E2E encryption middleware for Inngest.", | ||
@@ -36,2 +36,3 @@ "main": "dist/index.js", | ||
"@types/crypto-js": "^4.2.1", | ||
"inngest": "^3.19.7", | ||
"typescript": "~5.4.0" | ||
@@ -38,0 +39,0 @@ }, |
26826
278
3