-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
51 lines (38 loc) · 1.27 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
declare module '@autotelic/envelope-encryptor' {
import { createCipheriv } from 'node:crypto'
import { KMS, KMSClientConfig } from '@aws-sdk/client-kms'
export type CipherKey = Parameters<typeof createCipheriv>[1]
export interface KeyService {
getDataKey: () => Promise<{
encryptedKey: string
plaintextKey: CipherKey
}>
decryptDataKey: (key: string) => Promise<CipherKey>
}
export interface AwsKmsConfig extends KMSClientConfig {}
export type AwsKmsClient = Pick<KMS, 'generateDataKey' | 'decrypt'>
export interface AwsKmsService extends KeyService {}
export function awsKms(
keyId: string,
config?: AwsKmsConfig,
Client?: new (config?: AwsKmsConfig) => AwsKmsClient
): AwsKmsService
export function dummyKms (): KeyService
export function kekService(base64kek: string): KeyService
export interface EncryptorOptions {
encoding?: 'hex'
}
export interface EncryptedData {
ciphertext: string
key: string
salt: string
}
export interface EnvelopeEncryptor {
encrypt: (plaintext: string) => Promise<EncryptedData>
decrypt: (data: EncryptedData) => Promise<string>
}
export function createEnvelopeEncryptor(
keyService: KeyService,
options?: EncryptorOptions
): EnvelopeEncryptor
}