1 | import { Nullable } from '@salesforce/ts-types';
|
2 | import * as childProcess from 'child_process';
|
3 | import * as nodeFs from 'fs';
|
4 | export declare type FsIfc = Pick<typeof nodeFs, 'statSync'>;
|
5 |
|
6 |
|
7 |
|
8 | export interface PasswordStore {
|
9 | |
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | getPassword(opts: ProgramOpts, fn: (error: Nullable<Error>, password?: string) => void, retryCount?: number): Promise<void>;
|
16 | |
17 |
|
18 |
|
19 |
|
20 |
|
21 | setPassword(opts: ProgramOpts, fn: (error: Nullable<Error>, password?: string) => void): Promise<void>;
|
22 | }
|
23 |
|
24 |
|
25 |
|
26 | export declare class KeychainAccess implements PasswordStore {
|
27 | private osImpl;
|
28 | private fsIfc;
|
29 | |
30 |
|
31 |
|
32 |
|
33 |
|
34 | constructor(osImpl: OsImpl, fsIfc: FsIfc);
|
35 | /**
|
36 | * Validates the os level program is executable.
|
37 | */
|
38 | validateProgram(): Promise<void>;
|
39 | /**
|
40 | * Returns a password using the native program for credential management.
|
41 | * @param opts Options for the credential lookup.
|
42 | * @param fn Callback function (err, password).
|
43 | * @param retryCount Used internally to track the number of retries for getting a password out of the keychain.
|
44 | */
|
45 | getPassword(opts: ProgramOpts, fn: (error: Nullable<Error>, password?: string) => void, retryCount?: number): Promise<void>;
|
46 | /**
|
47 | * Sets a password using the native program for credential management.
|
48 | * @param opts Options for the credential lookup.
|
49 | * @param fn Callback function (err, password).
|
50 | */
|
51 | setPassword(opts: ProgramOpts, fn: (error: Nullable<Error>, password?: string) => void): Promise<void>;
|
52 | }
|
53 | interface ProgramOpts {
|
54 | account: string;
|
55 | service: string;
|
56 | password?: string;
|
57 | }
|
58 | interface OsImpl {
|
59 | getProgram(): string;
|
60 | getProgramOptions(opts: ProgramOpts): string[];
|
61 | getCommandFunc(opts: ProgramOpts, fn: (program: string, opts: string[]) => childProcess.ChildProcess): childProcess.ChildProcess;
|
62 | onGetCommandClose(code: number, stdout: string, stderr: string, opts: ProgramOpts, fn: (err: Nullable<Error>, result?: string) => void): Promise<void>;
|
63 | setProgramOptions(opts: ProgramOpts): string[];
|
64 | setCommandFunc(opts: ProgramOpts, fn: (program: string, opts: string[]) => childProcess.ChildProcess): childProcess.ChildProcess;
|
65 | onSetCommandClose(code: number, stdout: string, stderr: string, opts: ProgramOpts, fn: (err: Nullable<Error>) => void): Promise<void>;
|
66 | }
|
67 |
|
68 |
|
69 |
|
70 | export declare class GenericKeychainAccess implements PasswordStore {
|
71 | getPassword(opts: ProgramOpts, fn: (error: Nullable<Error>, password?: string) => void): Promise<void>;
|
72 | setPassword(opts: ProgramOpts, fn: (error: Nullable<Error>, password?: string) => void): Promise<void>;
|
73 | protected isValidFileAccess(cb: (error: Nullable<NodeJS.ErrnoException>) => Promise<void>): Promise<void>;
|
74 | }
|
75 |
|
76 |
|
77 |
|
78 | export declare class GenericUnixKeychainAccess extends GenericKeychainAccess {
|
79 | protected isValidFileAccess(cb: (error: Nullable<Error>) => Promise<void>): Promise<void>;
|
80 | }
|
81 |
|
82 |
|
83 |
|
84 | export declare class GenericWindowsKeychainAccess extends GenericKeychainAccess {
|
85 | protected isValidFileAccess(cb: (error: Nullable<Error>) => Promise<void>): Promise<void>;
|
86 | }
|
87 |
|
88 |
|
89 |
|
90 | export declare const keyChainImpl: {
|
91 | generic_unix: GenericUnixKeychainAccess;
|
92 | generic_windows: GenericWindowsKeychainAccess;
|
93 | darwin: KeychainAccess;
|
94 | linux: KeychainAccess;
|
95 | validateProgram: (programPath: string, fsIfc: Pick<typeof nodeFs, "statSync">, isExeIfc: (mode: number, gid: number, uid: number) => boolean) => Promise<void>;
|
96 | };
|
97 | export declare type KeyChain = GenericUnixKeychainAccess | GenericWindowsKeychainAccess | KeychainAccess;
|
98 | export {};
|