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