UNPKG

1.57 kBTypeScriptView Raw
1import { AsyncOptionalCreatable } from '@salesforce/kit';
2import { KeyChain } from './keyChainImpl';
3interface CryptoOptions {
4 keychain?: KeyChain;
5 platform?: string;
6 retryStatus?: string;
7 noResetOnClose?: boolean;
8}
9/**
10 * Class for managing encrypting and decrypting private auth information.
11 */
12export declare class Crypto extends AsyncOptionalCreatable<CryptoOptions> {
13 private key;
14 private options;
15 private noResetOnClose;
16 /**
17 * Constructor
18 * **Do not directly construct instances of this class -- use {@link Crypto.create} instead.**
19 *
20 * @param options The options for the class instance.
21 * @ignore
22 */
23 constructor(options?: CryptoOptions);
24 /**
25 * Encrypts text. Returns the encrypted string or undefined if no string was passed.
26 *
27 * @param text The text to encrypt.
28 */
29 encrypt(text: string): string;
30 /**
31 * Decrypts text.
32 *
33 * @param text The text to decrypt.
34 */
35 decrypt(text: string): string;
36 /**
37 * Takes a best guess if the value provided was encrypted by {@link Crypto.encrypt} by
38 * checking the delimiter, tag length, and valid characters.
39 *
40 * @param text The text
41 * @returns true if the text is encrypted, false otherwise.
42 */
43 isEncrypted(text?: string): boolean;
44 /**
45 * Clears the crypto state. This should be called in a finally block.
46 */
47 close(): void;
48 /**
49 * Initialize async components.
50 */
51 protected init(): Promise<void>;
52 private getKeyChain;
53}
54export {};