1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | Object.defineProperty(exports, "__esModule", { value: true });
|
9 | const kit_1 = require("@salesforce/kit");
|
10 | const keyChainImpl_1 = require("./keyChainImpl");
|
11 | const logger_1 = require("./logger");
|
12 | const sfdxError_1 = require("./sfdxError");
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | exports.retrieveKeychain = async (platform) => {
|
19 | const logger = await logger_1.Logger.child('keyChain');
|
20 | logger.debug(`platform: ${platform}`);
|
21 | const useGenericUnixKeychainVar = kit_1.env.getBoolean('SFDX_USE_GENERIC_UNIX_KEYCHAIN');
|
22 | const shouldUseGenericUnixKeychain = !!useGenericUnixKeychainVar && useGenericUnixKeychainVar;
|
23 | if (/^win/.test(platform)) {
|
24 | return keyChainImpl_1.keyChainImpl.generic_windows;
|
25 | }
|
26 | else if (/darwin/.test(platform)) {
|
27 |
|
28 |
|
29 | if (shouldUseGenericUnixKeychain) {
|
30 | return keyChainImpl_1.keyChainImpl.generic_unix;
|
31 | }
|
32 | else {
|
33 | return keyChainImpl_1.keyChainImpl.darwin;
|
34 | }
|
35 | }
|
36 | else if (/linux/.test(platform)) {
|
37 |
|
38 | if (shouldUseGenericUnixKeychain) {
|
39 | return keyChainImpl_1.keyChainImpl.generic_unix;
|
40 | }
|
41 | else {
|
42 |
|
43 | try {
|
44 | await keyChainImpl_1.keyChainImpl.linux.validateProgram();
|
45 | return keyChainImpl_1.keyChainImpl.linux;
|
46 | }
|
47 | catch (e) {
|
48 |
|
49 | return keyChainImpl_1.keyChainImpl.generic_unix;
|
50 | }
|
51 | }
|
52 | }
|
53 | else {
|
54 | throw sfdxError_1.SfdxError.create('@salesforce/core', 'encryption', 'UnsupportedOperatingSystemError', [platform]);
|
55 | }
|
56 | };
|
57 |
|
\ | No newline at end of file |