@forge/cli-shared 9.10.0-next.1-experimental-65945d2 → 9.10.0-next.1-experimental-1e95696
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -4
- package/out/apps/get-app-owner.d.ts.map +1 -1
- package/out/auth/personal/credential-store.d.ts +1 -31
- package/out/auth/personal/credential-store.d.ts.map +1 -1
- package/out/auth/personal/credential-store.js +16 -177
- package/out/auth/personal/token-authenticator.js +1 -1
- package/out/graphql/gql/graphql.d.ts +211 -5
- package/out/graphql/gql/graphql.d.ts.map +1 -1
- package/out/ui/text.d.ts +2 -12
- package/out/ui/text.d.ts.map +1 -1
- package/out/ui/text.js +2 -27
- package/package.json +3 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# @forge/cli-shared
|
|
2
2
|
|
|
3
|
-
## 9.10.0-next.1-experimental-
|
|
3
|
+
## 9.10.0-next.1-experimental-1e95696
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- ffd952f: Replace Keytar with a dedicated credential file protected by macOS and Linux permissions or Windows ACLs. This is a breaking authentication change: users with credentials stored in the OS keychain must run `forge login` once after upgrading. `FORGE_EMAIL` and `FORGE_API_TOKEN` continue to take precedence over saved credentials.
|
|
4
8
|
|
|
5
9
|
### Minor Changes
|
|
6
10
|
|
|
@@ -8,11 +12,10 @@
|
|
|
8
12
|
|
|
9
13
|
### Patch Changes
|
|
10
14
|
|
|
11
|
-
- ffd952f: Add an experimental file-backed credential store with restricted macOS, Linux, and Windows permissions.
|
|
12
15
|
- Updated dependencies [e865360]
|
|
13
16
|
- Updated dependencies [5d8a857]
|
|
14
|
-
- @forge/util@3.1.0-next.0-experimental-
|
|
15
|
-
- @forge/manifest@13.8.1-next.0-experimental-
|
|
17
|
+
- @forge/util@3.1.0-next.0-experimental-1e95696
|
|
18
|
+
- @forge/manifest@13.8.1-next.0-experimental-1e95696
|
|
16
19
|
|
|
17
20
|
## 9.10.0-next.1
|
|
18
21
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-app-owner.d.ts","sourceRoot":"","sources":["../../src/apps/get-app-owner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA4B,MAAM,YAAY,CAAC;AAErE,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,qBAAa,oBAAqB,SAAQ,KAAK;;CAI9C;AAED,eAAO,MAAM,aAAa;
|
|
1
|
+
{"version":3,"file":"get-app-owner.d.ts","sourceRoot":"","sources":["../../src/apps/get-app-owner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA4B,MAAM,YAAY,CAAC;AAErE,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,qBAAa,oBAAqB,SAAQ,KAAK;;CAI9C;AAED,eAAO,MAAM,aAAa;QAuC0tz4G,8CAAc;GA9Bhwz4G,CAAC;AAEH,qBAAa,gBAAgB;IAEzB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,YAAY;gBADZ,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,iBAAiB;IAGrC,OAAO;;;;;;;;;;;;;YAMN,WAAW;CAe1B"}
|
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
import * as t from 'io-ts';
|
|
2
|
-
import { CachedConf } from '../../cache';
|
|
3
2
|
import { UserError } from '../../shared';
|
|
4
|
-
import { Logger } from '../../ui';
|
|
5
3
|
import { UserRepository } from './user-repository';
|
|
6
4
|
export declare const EMAIL_KEY = "FORGE_EMAIL";
|
|
7
5
|
export declare const API_TOKEN_KEY = "FORGE_API_TOKEN";
|
|
8
|
-
export declare const FILE_CREDENTIAL_STORE_FLAG = "FORGE_CLI_ENABLE_FILE_CREDENTIAL_STORE";
|
|
9
|
-
export interface Keytar {
|
|
10
|
-
getPassword(service: string, account: string): Promise<string | null>;
|
|
11
|
-
setPassword(service: string, account: string, password: string): Promise<void>;
|
|
12
|
-
deletePassword(service: string, account: string): Promise<void>;
|
|
13
|
-
}
|
|
14
6
|
export declare const personalApiCredentialsShape: t.TypeC<{
|
|
15
7
|
email: t.StringC;
|
|
16
8
|
token: t.StringC;
|
|
@@ -25,11 +17,6 @@ export type PersonalApiCredentialsValidated = t.TypeOf<typeof personalApiCredent
|
|
|
25
17
|
export declare class NoTokenInStoreError extends UserError {
|
|
26
18
|
constructor();
|
|
27
19
|
}
|
|
28
|
-
export declare class NoKeytarError extends UserError {
|
|
29
|
-
constructor();
|
|
30
|
-
}
|
|
31
|
-
export declare class KeytarAccessError extends UserError {
|
|
32
|
-
}
|
|
33
20
|
export declare class CredentialStoreSecurityError extends UserError {
|
|
34
21
|
constructor();
|
|
35
22
|
}
|
|
@@ -60,22 +47,5 @@ export declare class FileCredentialStore implements CredentialStore {
|
|
|
60
47
|
setCredentials(credentials: PersonalApiCredentialsValidated): Promise<void>;
|
|
61
48
|
deleteCredentials(): Promise<void>;
|
|
62
49
|
}
|
|
63
|
-
export declare
|
|
64
|
-
private readonly logger;
|
|
65
|
-
private readonly instructionsURL;
|
|
66
|
-
private readonly keytar;
|
|
67
|
-
private readonly cachedConfig;
|
|
68
|
-
private readonly userRepository;
|
|
69
|
-
private keytarAccount;
|
|
70
|
-
constructor(logger: Logger, instructionsURL: string, keytar: Keytar | null, cachedConfig: CachedConf, userRepository: UserRepository);
|
|
71
|
-
private wrapKeytarError;
|
|
72
|
-
decodeCredentials(credentialsString: string | null): PersonalApiCredentialsValidated;
|
|
73
|
-
getCredentialsKeytar(keytar: Keytar): Promise<PersonalApiCredentialsValidated | undefined>;
|
|
74
|
-
popInsecurePlaintextCredentials(): PersonalApiCredentialsValidated | undefined;
|
|
75
|
-
deleteInsecurePlaintextCredentials(): void;
|
|
76
|
-
getCredentials(): Promise<PersonalApiCredentialsValidated>;
|
|
77
|
-
setCredentials(credentials: PersonalApiCredentialsValidated): Promise<void>;
|
|
78
|
-
deleteCredentials(): Promise<void>;
|
|
79
|
-
}
|
|
80
|
-
export declare function getCredentialStore(logger: Logger, userRepository: UserRepository): CredentialStore;
|
|
50
|
+
export declare function getCredentialStore(userRepository: UserRepository): CredentialStore;
|
|
81
51
|
//# sourceMappingURL=credential-store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credential-store.d.ts","sourceRoot":"","sources":["../../../src/auth/personal/credential-store.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,CAAC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"credential-store.d.ts","sourceRoot":"","sources":["../../../src/auth/personal/credential-store.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,CAAC,MAAM,OAAO,CAAC;AAE3B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,eAAO,MAAM,SAAS,gBAAgB,CAAC;AACvC,eAAO,MAAM,aAAa,oBAAoB,CAAC;AAiB/C,eAAO,MAAM,2BAA2B;;;EAGtC,CAAC;AAEH,eAAO,MAAM,oCAAoC;;;;EAI/C,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAClF,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,oCAAoC,CAAC,CAAC;AAEpG,qBAAa,mBAAoB,SAAQ,SAAS;;CAIjD;AAED,qBAAa,4BAA6B,SAAQ,SAAS;;CAI1D;AAED,MAAM,WAAW,gBAAgB;IAC/B,cAAc,IAAI,OAAO,CAAC,+BAA+B,CAAC,CAAC;CAC5D;AAED,MAAM,WAAW,eAAgB,SAAQ,gBAAgB;IACvD,cAAc,CAAC,WAAW,EAAE,+BAA+B,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5E,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACpC;AAID,MAAM,MAAM,4BAA4B,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAezG,wBAAgB,sBAAsB,CACpC,eAAe,kBAAa,EAC5B,WAAW,GAAE,MAAM,CAAC,UAAwB,EAC5C,QAAQ,SAAY,GACnB,MAAM,CAwBR;AAED,qBAAa,mBAAoB,YAAW,eAAe;IAIvD,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IACpC,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,aAAa;IAPhC,OAAO,CAAC,cAAc,CAA8B;gBAGjC,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,MAAM,EACf,mBAAmB,SAA2B,EAC9C,eAAe,kBAAa,EAC5B,aAAa,GAAE,4BAAwD;YAG5E,iBAAiB;YAWjB,eAAe;YAaf,oBAAoB;YA0BpB,kBAAkB;YAiDlB,aAAa;YAab,mBAAmB;IA4B3B,cAAc,IAAI,OAAO,CAAC,+BAA+B,CAAC;IAkB1D,cAAc,CAAC,WAAW,EAAE,+BAA+B,GAAG,OAAO,CAAC,IAAI,CAAC;IAiB3E,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;CAkBzC;AAED,wBAAgB,kBAAkB,CAAC,cAAc,EAAE,cAAc,GAAG,eAAe,CAElF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.FileCredentialStore = exports.CredentialStoreSecurityError = exports.NoTokenInStoreError = exports.personalApiCredentialsValidatedShape = exports.personalApiCredentialsShape = exports.API_TOKEN_KEY = exports.EMAIL_KEY = void 0;
|
|
4
4
|
exports.getCredentialsFilePath = getCredentialsFilePath;
|
|
5
5
|
exports.getCredentialStore = getCredentialStore;
|
|
6
6
|
const tslib_1 = require("tslib");
|
|
@@ -11,40 +11,25 @@ const path_1 = tslib_1.__importDefault(require("path"));
|
|
|
11
11
|
const util_1 = require("util");
|
|
12
12
|
const Either_1 = require("fp-ts/lib/Either");
|
|
13
13
|
const t = tslib_1.__importStar(require("io-ts"));
|
|
14
|
-
const cache_1 = require("../../cache");
|
|
15
|
-
const instruction_1 = require("../instruction");
|
|
16
14
|
const graphql_1 = require("../../graphql");
|
|
17
15
|
const shared_1 = require("../../shared");
|
|
18
16
|
const ui_1 = require("../../ui");
|
|
19
17
|
exports.EMAIL_KEY = 'FORGE_EMAIL';
|
|
20
18
|
exports.API_TOKEN_KEY = 'FORGE_API_TOKEN';
|
|
21
|
-
exports.FILE_CREDENTIAL_STORE_FLAG = 'FORGE_CLI_ENABLE_FILE_CREDENTIAL_STORE';
|
|
22
|
-
const KEYTAR_SERVICE = 'Atlassian';
|
|
23
|
-
const CACHE_CREDENTIALS_KEY = 'forge-credentials';
|
|
24
19
|
const CREDENTIALS_FILE_NAME = 'credentials.json';
|
|
25
|
-
const CONFIG_DIRECTORY_SUFFIX = 'nodejs';
|
|
26
20
|
const CREDENTIALS_DIRECTORY_MODE = 0o700;
|
|
27
21
|
const CREDENTIALS_FILE_MODE = 0o600;
|
|
28
22
|
const PERMISSION_BITS_MASK = 0o777;
|
|
29
|
-
const GROUP_OR_OTHER_WRITE_BITS_MASK = 0o022;
|
|
30
23
|
const WINDOWS_SYSTEM_SID = 'S-1-5-18';
|
|
31
24
|
const WINDOWS_ADMINISTRATORS_SID = 'S-1-5-32-544';
|
|
32
|
-
var
|
|
33
|
-
(function (
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
})(
|
|
40
|
-
function getKeytar() {
|
|
41
|
-
try {
|
|
42
|
-
return require('keytar');
|
|
43
|
-
}
|
|
44
|
-
catch {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
25
|
+
var CredentialAccount;
|
|
26
|
+
(function (CredentialAccount) {
|
|
27
|
+
CredentialAccount["DEV"] = "Ecosystem-staging";
|
|
28
|
+
CredentialAccount["STG"] = "Ecosystem-staging";
|
|
29
|
+
CredentialAccount["PROD"] = "Ecosystem";
|
|
30
|
+
CredentialAccount["FEDRAMP_MODERATE_STAGING"] = "Ecosystem-fedm-staging";
|
|
31
|
+
CredentialAccount["FEDRAMP_MODERATE_PROD"] = "Ecosystem-fedm-prod";
|
|
32
|
+
})(CredentialAccount || (CredentialAccount = {}));
|
|
48
33
|
exports.personalApiCredentialsShape = t.type({
|
|
49
34
|
email: t.string,
|
|
50
35
|
token: t.string
|
|
@@ -60,15 +45,6 @@ class NoTokenInStoreError extends shared_1.UserError {
|
|
|
60
45
|
}
|
|
61
46
|
}
|
|
62
47
|
exports.NoTokenInStoreError = NoTokenInStoreError;
|
|
63
|
-
class NoKeytarError extends shared_1.UserError {
|
|
64
|
-
constructor() {
|
|
65
|
-
super(ui_1.Text.error.noKeytar);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
exports.NoKeytarError = NoKeytarError;
|
|
69
|
-
class KeytarAccessError extends shared_1.UserError {
|
|
70
|
-
}
|
|
71
|
-
exports.KeytarAccessError = KeytarAccessError;
|
|
72
48
|
class CredentialStoreSecurityError extends shared_1.UserError {
|
|
73
49
|
constructor() {
|
|
74
50
|
super(ui_1.Text.error.credentialsFilePermissions);
|
|
@@ -89,13 +65,13 @@ function getCredentialsFilePath(currentPlatform = (0, os_1.platform)(), environm
|
|
|
89
65
|
let credentialsDirectory;
|
|
90
66
|
switch (currentPlatform) {
|
|
91
67
|
case 'darwin':
|
|
92
|
-
credentialsDirectory = platformPath.join(userHome, 'Library', '
|
|
68
|
+
credentialsDirectory = platformPath.join(userHome, 'Library', 'Application Support', 'Atlassian', 'Forge');
|
|
93
69
|
break;
|
|
94
70
|
case 'win32':
|
|
95
71
|
credentialsDirectory = platformPath.join(environment.LOCALAPPDATA || platformPath.join(userHome, 'AppData', 'Local'), 'Atlassian', 'Forge');
|
|
96
72
|
break;
|
|
97
73
|
default:
|
|
98
|
-
credentialsDirectory = platformPath.join(environment.
|
|
74
|
+
credentialsDirectory = platformPath.join(environment.XDG_DATA_HOME || platformPath.join(userHome, '.local', 'share'), 'Atlassian', 'Forge');
|
|
99
75
|
}
|
|
100
76
|
return platformPath.join(credentialsDirectory, CREDENTIALS_FILE_NAME);
|
|
101
77
|
}
|
|
@@ -172,19 +148,17 @@ class FileCredentialStore {
|
|
|
172
148
|
return;
|
|
173
149
|
}
|
|
174
150
|
const credentialsDirectory = path_1.default.dirname(this.credentialsFilePath);
|
|
175
|
-
|
|
151
|
+
await fs_1.promises.mkdir(credentialsDirectory, {
|
|
176
152
|
recursive: true,
|
|
177
153
|
mode: CREDENTIALS_DIRECTORY_MODE
|
|
178
154
|
});
|
|
179
|
-
|
|
180
|
-
await fs_1.promises.chmod(credentialsDirectory, CREDENTIALS_DIRECTORY_MODE);
|
|
181
|
-
}
|
|
155
|
+
await fs_1.promises.chmod(credentialsDirectory, CREDENTIALS_DIRECTORY_MODE);
|
|
182
156
|
const directoryStat = await fs_1.promises.stat(credentialsDirectory);
|
|
183
157
|
const currentUserId = process.getuid?.();
|
|
184
158
|
if (currentUserId === undefined ||
|
|
185
159
|
!directoryStat.isDirectory() ||
|
|
186
160
|
directoryStat.uid !== currentUserId ||
|
|
187
|
-
(directoryStat.mode &
|
|
161
|
+
(directoryStat.mode & PERMISSION_BITS_MASK) !== CREDENTIALS_DIRECTORY_MODE) {
|
|
188
162
|
throw new Error('The credentials directory is not owned exclusively by the current user');
|
|
189
163
|
}
|
|
190
164
|
if (!fileExists) {
|
|
@@ -288,141 +262,6 @@ class FileCredentialStore {
|
|
|
288
262
|
}
|
|
289
263
|
}
|
|
290
264
|
exports.FileCredentialStore = FileCredentialStore;
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
instructionsURL;
|
|
294
|
-
keytar;
|
|
295
|
-
cachedConfig;
|
|
296
|
-
userRepository;
|
|
297
|
-
keytarAccount;
|
|
298
|
-
constructor(logger, instructionsURL, keytar, cachedConfig, userRepository) {
|
|
299
|
-
this.logger = logger;
|
|
300
|
-
this.instructionsURL = instructionsURL;
|
|
301
|
-
this.keytar = keytar;
|
|
302
|
-
this.cachedConfig = cachedConfig;
|
|
303
|
-
this.userRepository = userRepository;
|
|
304
|
-
this.keytarAccount = (0, graphql_1.getEnvironmentConfig)(KeytarAccount);
|
|
305
|
-
}
|
|
306
|
-
wrapKeytarError(e) {
|
|
307
|
-
const message = (0, shared_1.wrapError)(e).message;
|
|
308
|
-
let error;
|
|
309
|
-
const currentPlatform = (0, os_1.platform)();
|
|
310
|
-
switch (currentPlatform) {
|
|
311
|
-
case 'darwin':
|
|
312
|
-
error = ui_1.Text.error.keytarAccessError.mac(message);
|
|
313
|
-
break;
|
|
314
|
-
case 'linux':
|
|
315
|
-
error = ui_1.Text.error.keytarAccessError.linux(message);
|
|
316
|
-
break;
|
|
317
|
-
case 'win32':
|
|
318
|
-
error = ui_1.Text.error.keytarAccessError.windows(message);
|
|
319
|
-
break;
|
|
320
|
-
default:
|
|
321
|
-
error = ui_1.Text.error.keytarAccessError.other(message);
|
|
322
|
-
}
|
|
323
|
-
throw new KeytarAccessError(error);
|
|
324
|
-
}
|
|
325
|
-
decodeCredentials(credentialsString) {
|
|
326
|
-
if (!credentialsString) {
|
|
327
|
-
throw new NoTokenInStoreError();
|
|
328
|
-
}
|
|
329
|
-
let credentials;
|
|
330
|
-
try {
|
|
331
|
-
credentials = JSON.parse(credentialsString);
|
|
332
|
-
}
|
|
333
|
-
catch {
|
|
334
|
-
throw new NoTokenInStoreError();
|
|
335
|
-
}
|
|
336
|
-
const decodeResult = exports.personalApiCredentialsValidatedShape.decode(credentials);
|
|
337
|
-
if ((0, Either_1.isLeft)(decodeResult)) {
|
|
338
|
-
throw new NoTokenInStoreError();
|
|
339
|
-
}
|
|
340
|
-
return decodeResult.right;
|
|
341
|
-
}
|
|
342
|
-
async getCredentialsKeytar(keytar) {
|
|
343
|
-
let stringifiedPersonalApiCredentials;
|
|
344
|
-
try {
|
|
345
|
-
stringifiedPersonalApiCredentials = await keytar.getPassword(KEYTAR_SERVICE, this.keytarAccount);
|
|
346
|
-
}
|
|
347
|
-
catch (e) {
|
|
348
|
-
this.wrapKeytarError(e);
|
|
349
|
-
}
|
|
350
|
-
if (!stringifiedPersonalApiCredentials) {
|
|
351
|
-
return undefined;
|
|
352
|
-
}
|
|
353
|
-
return this.decodeCredentials(stringifiedPersonalApiCredentials);
|
|
354
|
-
}
|
|
355
|
-
popInsecurePlaintextCredentials() {
|
|
356
|
-
const result = this.cachedConfig.get(CACHE_CREDENTIALS_KEY);
|
|
357
|
-
if (result) {
|
|
358
|
-
this.logger.warn(ui_1.Text.warning.plaintextCredentialsFound(this.instructionsURL));
|
|
359
|
-
this.deleteInsecurePlaintextCredentials();
|
|
360
|
-
}
|
|
361
|
-
return result;
|
|
362
|
-
}
|
|
363
|
-
deleteInsecurePlaintextCredentials() {
|
|
364
|
-
this.cachedConfig.delete(CACHE_CREDENTIALS_KEY);
|
|
365
|
-
}
|
|
366
|
-
async getCredentials() {
|
|
367
|
-
let result;
|
|
368
|
-
const plaintextCredentials = this.popInsecurePlaintextCredentials();
|
|
369
|
-
if (plaintextCredentials) {
|
|
370
|
-
if (this.keytar) {
|
|
371
|
-
await this.setCredentials(plaintextCredentials);
|
|
372
|
-
this.logger.warn(ui_1.Text.warning.plaintextCredentialsMigrated);
|
|
373
|
-
}
|
|
374
|
-
else {
|
|
375
|
-
this.logger.warn(ui_1.Text.warning.plaintextCredentialsNotMigrated);
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
if (process.env[exports.API_TOKEN_KEY] && process.env[exports.EMAIL_KEY]) {
|
|
379
|
-
const credentials = {
|
|
380
|
-
email: process.env[exports.EMAIL_KEY],
|
|
381
|
-
token: process.env[exports.API_TOKEN_KEY]
|
|
382
|
-
};
|
|
383
|
-
const { accountId } = await this.userRepository.getUser(credentials);
|
|
384
|
-
result = { ...credentials, accountId };
|
|
385
|
-
}
|
|
386
|
-
else if (this.keytar) {
|
|
387
|
-
result = await this.getCredentialsKeytar(this.keytar);
|
|
388
|
-
}
|
|
389
|
-
if (result) {
|
|
390
|
-
return result;
|
|
391
|
-
}
|
|
392
|
-
throw new NoTokenInStoreError();
|
|
393
|
-
}
|
|
394
|
-
async setCredentials(credentials) {
|
|
395
|
-
if (this.keytar) {
|
|
396
|
-
try {
|
|
397
|
-
await this.keytar.setPassword(KEYTAR_SERVICE, this.keytarAccount, JSON.stringify(credentials));
|
|
398
|
-
}
|
|
399
|
-
catch (e) {
|
|
400
|
-
throw new NoKeytarError();
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
else {
|
|
404
|
-
throw new NoKeytarError();
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
async deleteCredentials() {
|
|
408
|
-
if (this.keytar) {
|
|
409
|
-
try {
|
|
410
|
-
await this.keytar.deletePassword(KEYTAR_SERVICE, this.keytarAccount);
|
|
411
|
-
}
|
|
412
|
-
catch (e) {
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
this.deleteInsecurePlaintextCredentials();
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
exports.CredentialStoreImpl = CredentialStoreImpl;
|
|
419
|
-
function getCredentialStore(logger, userRepository) {
|
|
420
|
-
const credentialAccount = (0, graphql_1.getEnvironmentConfig)(KeytarAccount);
|
|
421
|
-
if (process.env[exports.FILE_CREDENTIAL_STORE_FLAG] === 'true') {
|
|
422
|
-
return new FileCredentialStore(userRepository, credentialAccount);
|
|
423
|
-
}
|
|
424
|
-
const keytar = getKeytar();
|
|
425
|
-
const cachedConfig = cache_1.CachedConf.getCache(cache_1.CONFIG_PROJECT_NAME);
|
|
426
|
-
const instructionsUrl = (0, instruction_1.getInstructionsUrl)();
|
|
427
|
-
return new CredentialStoreImpl(logger, instructionsUrl, keytar, cachedConfig, userRepository);
|
|
265
|
+
function getCredentialStore(userRepository) {
|
|
266
|
+
return new FileCredentialStore(userRepository, (0, graphql_1.getEnvironmentConfig)(CredentialAccount));
|
|
428
267
|
}
|
|
@@ -19,7 +19,7 @@ class PersonalTokenAuthenticator {
|
|
|
19
19
|
if (process.env[credential_store_1.API_TOKEN_KEY] && process.env[credential_store_1.EMAIL_KEY]) {
|
|
20
20
|
return ui_1.Text.error.invalidTokenInEnv(instructionsUrl, credential_store_1.EMAIL_KEY, credential_store_1.API_TOKEN_KEY);
|
|
21
21
|
}
|
|
22
|
-
return ui_1.Text.error.
|
|
22
|
+
return ui_1.Text.error.invalidTokenInCredentialFile;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
exports.PersonalTokenAuthenticator = PersonalTokenAuthenticator;
|