@forge/cli-shared 9.11.0-next.9 → 10.0.0-next.13
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 +26 -0
- package/out/apps/create-an-app.d.ts +2 -2
- package/out/apps/create-an-app.d.ts.map +1 -1
- package/out/apps/create-an-app.js +2 -2
- package/out/apps/get-app-owner.d.ts.map +1 -1
- package/out/auth/personal/credential-store.d.ts +18 -24
- package/out/auth/personal/credential-store.d.ts.map +1 -1
- package/out/auth/personal/credential-store.js +208 -121
- package/out/auth/personal/token-authenticator.js +1 -1
- package/out/config/config-file.d.ts.map +1 -1
- package/out/config/config-file.js +1 -1
- package/out/file-system/file-system-reader.d.ts.map +1 -1
- package/out/file-system/file-system-reader.js +3 -4
- package/out/graphql/gql/graphql.d.ts +168 -15
- package/out/graphql/gql/graphql.d.ts.map +1 -1
- package/out/shared/forge-cli-attribution.d.ts +3 -0
- package/out/shared/forge-cli-attribution.d.ts.map +1 -1
- package/out/shared/forge-cli-attribution.js +32 -5
- package/out/shared/index.d.ts +0 -3
- package/out/shared/index.d.ts.map +1 -1
- package/out/shared/index.js +0 -5
- package/out/shared/read-app-config-files.d.ts.map +1 -1
- package/out/shared/read-app-config-files.js +3 -4
- package/out/shared/runner-signals.d.ts +6 -0
- package/out/shared/runner-signals.d.ts.map +1 -0
- package/out/shared/runner-signals.js +11 -0
- package/out/ui/text.d.ts +7 -16
- package/out/ui/text.d.ts.map +1 -1
- package/out/ui/text.js +13 -36
- package/package.json +3 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @forge/cli-shared
|
|
2
2
|
|
|
3
|
+
## 10.0.0-next.13
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- f93687f: 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.
|
|
8
|
+
|
|
9
|
+
## 10.0.0-next.12
|
|
10
|
+
|
|
11
|
+
### Major Changes
|
|
12
|
+
|
|
13
|
+
- a4b2f56: Rename --no-install to --skip-dependencies for create and module add
|
|
14
|
+
|
|
15
|
+
## 9.11.0-next.11
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- 112c0c6: Add `isAgentV2` and `isCIV2` to the attribution payload (`atl-attribution` header and analytics events), detecting whether a named agent or CI runs the command without reading the `CI` variable: `isCIV2` is `"true"` when `ci-info` names a CI tool, not when `CI=true`, and `isAgentV2` is `"true"` when an agent names itself, with or without a terminal. A named agent in a CI tool is both. `isAgent` and `isCI` are unchanged. Also send `ciHint` (the CI tool's `ci-info` id), `isTerminal` (stdin is a terminal) and `isUnrecognizedNonTTY`. The new fields are strings so the backend keeps them as wildcard fields. With the `non-interactive` setting `auto`, non-interactive mode turns on for a named agent (`isAgentV2`), in CI or not; CI, scripts and unnamed agents keep today's behaviour
|
|
20
|
+
|
|
21
|
+
Bump `@vercel/detect-agent` to 1.2.7 and add `ci-info` 4.4.0
|
|
22
|
+
|
|
23
|
+
## 9.11.0-next.10
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- 32cccae: Use native `Array.prototype.flat` and `flatMap` instead of the `array.prototype.flatmap` polyfill.
|
|
28
|
+
|
|
3
29
|
## 9.11.0-next.9
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
|
@@ -6,7 +6,7 @@ export interface CreateAppCommandInput extends CreateAppClientInput {
|
|
|
6
6
|
template: string;
|
|
7
7
|
directory: string;
|
|
8
8
|
compatibility?: AppCompatibility;
|
|
9
|
-
|
|
9
|
+
skipDependencies?: boolean;
|
|
10
10
|
prependAppName?: boolean;
|
|
11
11
|
beforeRegister?: (directory: string) => Promise<void>;
|
|
12
12
|
}
|
|
@@ -24,7 +24,7 @@ export declare class CreateAppCommand {
|
|
|
24
24
|
private readonly packageInstaller;
|
|
25
25
|
private readonly statsig;
|
|
26
26
|
constructor(templater: Templater, registerAppCommand: RegisterAppCommand, packageInstaller: PackageInstaller, statsig: StatsigService);
|
|
27
|
-
execute({ name, description, template, directory, compatibility, developerSpaceId, billingConsent, appFeatures,
|
|
27
|
+
execute({ name, description, template, directory, compatibility, developerSpaceId, billingConsent, appFeatures, skipDependencies, prependAppName, beforeRegister }: CreateAppCommandInput): Promise<CreateAppCommandResult>;
|
|
28
28
|
getAvailableTemplates(): Promise<string[]>;
|
|
29
29
|
filterAvailableProducts<T extends string>(products: T[], teamworkGraph: T, crossContext: T): Promise<T[]>;
|
|
30
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-an-app.d.ts","sourceRoot":"","sources":["../../src/apps/create-an-app.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC/G,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,MAAM,WAAW,qBAAsB,SAAQ,oBAAoB;IACjE,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,gBAAgB,CAAC;IACjC,
|
|
1
|
+
{"version":3,"file":"create-an-app.d.ts","sourceRoot":"","sources":["../../src/apps/create-an-app.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;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 +20,7 @@ class CreateAppCommand {
|
|
|
20
20
|
this.packageInstaller = packageInstaller;
|
|
21
21
|
this.statsig = statsig;
|
|
22
22
|
}
|
|
23
|
-
async execute({ name, description, template, directory, compatibility, developerSpaceId, billingConsent, appFeatures,
|
|
23
|
+
async execute({ name, description, template, directory, compatibility, developerSpaceId, billingConsent, appFeatures, skipDependencies, prependAppName = true, beforeRegister }) {
|
|
24
24
|
await this.templater.downloadAndExtract(template, directory);
|
|
25
25
|
if (beforeRegister) {
|
|
26
26
|
try {
|
|
@@ -41,7 +41,7 @@ class CreateAppCommand {
|
|
|
41
41
|
shouldPrependAppName: prependAppName,
|
|
42
42
|
compatibility
|
|
43
43
|
});
|
|
44
|
-
if (
|
|
44
|
+
if (!skipDependencies) {
|
|
45
45
|
await this.packageInstaller.install(directory);
|
|
46
46
|
}
|
|
47
47
|
return {
|
|
@@ -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;QAuC+68gH,8CAAc;GA9Br98gH,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,15 +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 interface Keytar {
|
|
9
|
-
getPassword(service: string, account: string): Promise<string | null>;
|
|
10
|
-
setPassword(service: string, account: string, password: string): Promise<void>;
|
|
11
|
-
deletePassword(service: string, account: string): Promise<void>;
|
|
12
|
-
}
|
|
13
6
|
export declare const personalApiCredentialsShape: t.TypeC<{
|
|
14
7
|
email: t.StringC;
|
|
15
8
|
token: t.StringC;
|
|
@@ -24,10 +17,8 @@ export type PersonalApiCredentialsValidated = t.TypeOf<typeof personalApiCredent
|
|
|
24
17
|
export declare class NoTokenInStoreError extends UserError {
|
|
25
18
|
constructor();
|
|
26
19
|
}
|
|
27
|
-
export declare class
|
|
28
|
-
constructor();
|
|
29
|
-
}
|
|
30
|
-
export declare class KeytarAccessError extends UserError {
|
|
20
|
+
export declare class CredentialStoreSecurityError extends UserError {
|
|
21
|
+
constructor(cause?: unknown);
|
|
31
22
|
}
|
|
32
23
|
export interface CredentialGetter {
|
|
33
24
|
getCredentials(): Promise<PersonalApiCredentialsValidated>;
|
|
@@ -36,22 +27,25 @@ export interface CredentialStore extends CredentialGetter {
|
|
|
36
27
|
setCredentials(credentials: PersonalApiCredentialsValidated): Promise<void>;
|
|
37
28
|
deleteCredentials(): Promise<void>;
|
|
38
29
|
}
|
|
39
|
-
export
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
private readonly keytar;
|
|
43
|
-
private readonly cachedConfig;
|
|
30
|
+
export type CredentialStoreCommandRunner = (command: string, args: readonly string[]) => Promise<string>;
|
|
31
|
+
export declare function getCredentialsFilePath(currentPlatform?: NodeJS.Platform, environment?: NodeJS.ProcessEnv, userHome?: string): string;
|
|
32
|
+
export declare class FileCredentialStore implements CredentialStore {
|
|
44
33
|
private readonly userRepository;
|
|
45
|
-
private
|
|
46
|
-
|
|
47
|
-
private
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
34
|
+
private readonly account;
|
|
35
|
+
private readonly credentialsFilePath;
|
|
36
|
+
private readonly currentPlatform;
|
|
37
|
+
private readonly commandRunner;
|
|
38
|
+
private windowsUserSid;
|
|
39
|
+
constructor(userRepository: UserRepository, account: string, credentialsFilePath?: string, currentPlatform?: NodeJS.Platform, commandRunner?: CredentialStoreCommandRunner);
|
|
40
|
+
private getWindowsUserSid;
|
|
41
|
+
private applyWindowsAcl;
|
|
42
|
+
private secureWindowsStorage;
|
|
43
|
+
private securePosixStorage;
|
|
44
|
+
private secureStorage;
|
|
45
|
+
private readCredentialsFile;
|
|
52
46
|
getCredentials(): Promise<PersonalApiCredentialsValidated>;
|
|
53
47
|
setCredentials(credentials: PersonalApiCredentialsValidated): Promise<void>;
|
|
54
48
|
deleteCredentials(): Promise<void>;
|
|
55
49
|
}
|
|
56
|
-
export declare function getCredentialStore(
|
|
50
|
+
export declare function getCredentialStore(userRepository: UserRepository): CredentialStore;
|
|
57
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":"
|
|
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,m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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;CA2BzC;AAED,wBAAgB,kBAAkB,CAAC,cAAc,EAAE,cAAc,GAAG,eAAe,CAElF"}
|
|
@@ -1,36 +1,35 @@
|
|
|
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
|
+
exports.getCredentialsFilePath = getCredentialsFilePath;
|
|
4
5
|
exports.getCredentialStore = getCredentialStore;
|
|
5
6
|
const tslib_1 = require("tslib");
|
|
7
|
+
const child_process_1 = require("child_process");
|
|
8
|
+
const fs_1 = require("fs");
|
|
6
9
|
const os_1 = require("os");
|
|
10
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
11
|
+
const util_1 = require("util");
|
|
7
12
|
const Either_1 = require("fp-ts/lib/Either");
|
|
8
13
|
const t = tslib_1.__importStar(require("io-ts"));
|
|
9
|
-
const cache_1 = require("../../cache");
|
|
10
|
-
const instruction_1 = require("../instruction");
|
|
11
14
|
const graphql_1 = require("../../graphql");
|
|
12
15
|
const shared_1 = require("../../shared");
|
|
13
16
|
const ui_1 = require("../../ui");
|
|
14
17
|
exports.EMAIL_KEY = 'FORGE_EMAIL';
|
|
15
18
|
exports.API_TOKEN_KEY = 'FORGE_API_TOKEN';
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
catch {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
19
|
+
const CREDENTIALS_FILE_NAME = 'credentials.json';
|
|
20
|
+
const CREDENTIALS_DIRECTORY_MODE = 0o700;
|
|
21
|
+
const CREDENTIALS_FILE_MODE = 0o600;
|
|
22
|
+
const PERMISSION_BITS_MASK = 0o777;
|
|
23
|
+
const WINDOWS_SYSTEM_SID = 'S-1-5-18';
|
|
24
|
+
const WINDOWS_ADMINISTRATORS_SID = 'S-1-5-32-544';
|
|
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 = {}));
|
|
34
33
|
exports.personalApiCredentialsShape = t.type({
|
|
35
34
|
email: t.string,
|
|
36
35
|
token: t.string
|
|
@@ -46,146 +45,234 @@ class NoTokenInStoreError extends shared_1.UserError {
|
|
|
46
45
|
}
|
|
47
46
|
}
|
|
48
47
|
exports.NoTokenInStoreError = NoTokenInStoreError;
|
|
49
|
-
class
|
|
50
|
-
constructor() {
|
|
51
|
-
super(ui_1.Text.error.
|
|
48
|
+
class CredentialStoreSecurityError extends shared_1.UserError {
|
|
49
|
+
constructor(cause) {
|
|
50
|
+
super(ui_1.Text.error.credentialsFilePermissions);
|
|
51
|
+
this.cause = cause;
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
exports.
|
|
55
|
-
|
|
54
|
+
exports.CredentialStoreSecurityError = CredentialStoreSecurityError;
|
|
55
|
+
const execFileAsync = (0, util_1.promisify)(child_process_1.execFile);
|
|
56
|
+
const runCredentialStoreCommand = async (command, args) => {
|
|
57
|
+
const { stdout } = await execFileAsync(command, [...args], { encoding: 'utf8', windowsHide: true });
|
|
58
|
+
return stdout;
|
|
59
|
+
};
|
|
60
|
+
const credentialsByAccountShape = t.record(t.string, exports.personalApiCredentialsValidatedShape);
|
|
61
|
+
function isFileNotFoundError(error) {
|
|
62
|
+
return typeof error === 'object' && error !== null && 'code' in error && error.code === 'ENOENT';
|
|
56
63
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
function getCredentialsFilePath(currentPlatform = (0, os_1.platform)(), environment = process.env, userHome = (0, os_1.homedir)()) {
|
|
65
|
+
const platformPath = currentPlatform === 'win32' ? path_1.default.win32 : path_1.default.posix;
|
|
66
|
+
let credentialsDirectory;
|
|
67
|
+
switch (currentPlatform) {
|
|
68
|
+
case 'darwin':
|
|
69
|
+
credentialsDirectory = platformPath.join(userHome, 'Library', 'Application Support', 'Atlassian', 'Forge');
|
|
70
|
+
break;
|
|
71
|
+
case 'win32':
|
|
72
|
+
credentialsDirectory = platformPath.join(environment.LOCALAPPDATA || platformPath.join(userHome, 'AppData', 'Local'), 'Atlassian', 'Forge');
|
|
73
|
+
break;
|
|
74
|
+
default:
|
|
75
|
+
credentialsDirectory = platformPath.join(environment.XDG_DATA_HOME || platformPath.join(userHome, '.local', 'share'), 'Atlassian', 'Forge');
|
|
76
|
+
}
|
|
77
|
+
return platformPath.join(credentialsDirectory, CREDENTIALS_FILE_NAME);
|
|
78
|
+
}
|
|
79
|
+
class FileCredentialStore {
|
|
63
80
|
userRepository;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
81
|
+
account;
|
|
82
|
+
credentialsFilePath;
|
|
83
|
+
currentPlatform;
|
|
84
|
+
commandRunner;
|
|
85
|
+
windowsUserSid;
|
|
86
|
+
constructor(userRepository, account, credentialsFilePath = getCredentialsFilePath(), currentPlatform = (0, os_1.platform)(), commandRunner = runCredentialStoreCommand) {
|
|
70
87
|
this.userRepository = userRepository;
|
|
71
|
-
this.
|
|
88
|
+
this.account = account;
|
|
89
|
+
this.credentialsFilePath = credentialsFilePath;
|
|
90
|
+
this.currentPlatform = currentPlatform;
|
|
91
|
+
this.commandRunner = commandRunner;
|
|
72
92
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
error = ui_1.Text.error.keytarAccessError.linux(message);
|
|
83
|
-
break;
|
|
84
|
-
case 'win32':
|
|
85
|
-
error = ui_1.Text.error.keytarAccessError.windows(message);
|
|
86
|
-
break;
|
|
87
|
-
default:
|
|
88
|
-
error = ui_1.Text.error.keytarAccessError.other(message);
|
|
89
|
-
}
|
|
90
|
-
throw new KeytarAccessError(error);
|
|
93
|
+
async getWindowsUserSid() {
|
|
94
|
+
this.windowsUserSid ??= this.commandRunner('whoami.exe', ['/user', '/fo', 'csv', '/nh']).then((output) => {
|
|
95
|
+
const sid = output.trim().match(/"?(S-\d(?:-\d+)+)"?$/)?.[1];
|
|
96
|
+
if (!sid) {
|
|
97
|
+
throw new Error('Could not determine the current Windows user SID');
|
|
98
|
+
}
|
|
99
|
+
return sid;
|
|
100
|
+
});
|
|
101
|
+
return this.windowsUserSid;
|
|
91
102
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
103
|
+
async applyWindowsAcl(targetPath, directory) {
|
|
104
|
+
const userSid = await this.getWindowsUserSid();
|
|
105
|
+
const permission = directory ? '(OI)(CI)F' : 'F';
|
|
106
|
+
await this.commandRunner('icacls.exe', [
|
|
107
|
+
targetPath,
|
|
108
|
+
'/inheritance:r',
|
|
109
|
+
'/grant:r',
|
|
110
|
+
`*${userSid}:${permission}`,
|
|
111
|
+
`*${WINDOWS_SYSTEM_SID}:${permission}`,
|
|
112
|
+
`*${WINDOWS_ADMINISTRATORS_SID}:${permission}`
|
|
113
|
+
]);
|
|
114
|
+
}
|
|
115
|
+
async secureWindowsStorage(createFile) {
|
|
116
|
+
let fileExists = true;
|
|
97
117
|
try {
|
|
98
|
-
|
|
118
|
+
await fs_1.promises.access(this.credentialsFilePath);
|
|
99
119
|
}
|
|
100
|
-
catch {
|
|
101
|
-
|
|
120
|
+
catch (error) {
|
|
121
|
+
if (!isFileNotFoundError(error)) {
|
|
122
|
+
throw error;
|
|
123
|
+
}
|
|
124
|
+
fileExists = false;
|
|
102
125
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
throw new NoTokenInStoreError();
|
|
126
|
+
if (!fileExists && !createFile) {
|
|
127
|
+
return;
|
|
106
128
|
}
|
|
107
|
-
|
|
129
|
+
const credentialsDirectory = path_1.default.dirname(this.credentialsFilePath);
|
|
130
|
+
await fs_1.promises.mkdir(credentialsDirectory, { recursive: true });
|
|
131
|
+
await this.applyWindowsAcl(credentialsDirectory, true);
|
|
132
|
+
if (!fileExists) {
|
|
133
|
+
await fs_1.promises.writeFile(this.credentialsFilePath, '', { flag: 'wx' });
|
|
134
|
+
}
|
|
135
|
+
await this.applyWindowsAcl(this.credentialsFilePath, false);
|
|
108
136
|
}
|
|
109
|
-
async
|
|
110
|
-
let
|
|
137
|
+
async securePosixStorage(createFile) {
|
|
138
|
+
let fileExists = true;
|
|
111
139
|
try {
|
|
112
|
-
|
|
140
|
+
await fs_1.promises.access(this.credentialsFilePath);
|
|
113
141
|
}
|
|
114
|
-
catch (
|
|
115
|
-
|
|
142
|
+
catch (error) {
|
|
143
|
+
if (!isFileNotFoundError(error)) {
|
|
144
|
+
throw error;
|
|
145
|
+
}
|
|
146
|
+
fileExists = false;
|
|
116
147
|
}
|
|
117
|
-
if (!
|
|
118
|
-
return
|
|
148
|
+
if (!fileExists && !createFile) {
|
|
149
|
+
return;
|
|
119
150
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
151
|
+
const credentialsDirectory = path_1.default.dirname(this.credentialsFilePath);
|
|
152
|
+
await fs_1.promises.mkdir(credentialsDirectory, {
|
|
153
|
+
recursive: true,
|
|
154
|
+
mode: CREDENTIALS_DIRECTORY_MODE
|
|
155
|
+
});
|
|
156
|
+
await fs_1.promises.chmod(credentialsDirectory, CREDENTIALS_DIRECTORY_MODE);
|
|
157
|
+
const directoryStat = await fs_1.promises.stat(credentialsDirectory);
|
|
158
|
+
const currentUserId = process.getuid?.();
|
|
159
|
+
if (currentUserId === undefined ||
|
|
160
|
+
!directoryStat.isDirectory() ||
|
|
161
|
+
directoryStat.uid !== currentUserId ||
|
|
162
|
+
(directoryStat.mode & PERMISSION_BITS_MASK) !== CREDENTIALS_DIRECTORY_MODE) {
|
|
163
|
+
throw new Error('The credentials directory is not owned exclusively by the current user');
|
|
164
|
+
}
|
|
165
|
+
if (!fileExists) {
|
|
166
|
+
const file = await fs_1.promises.open(this.credentialsFilePath, 'wx', CREDENTIALS_FILE_MODE);
|
|
167
|
+
await file.close();
|
|
168
|
+
}
|
|
169
|
+
await fs_1.promises.chmod(this.credentialsFilePath, CREDENTIALS_FILE_MODE);
|
|
170
|
+
const fileStat = await fs_1.promises.stat(this.credentialsFilePath);
|
|
171
|
+
if (!fileStat.isFile() ||
|
|
172
|
+
fileStat.uid !== currentUserId ||
|
|
173
|
+
(fileStat.mode & PERMISSION_BITS_MASK) !== CREDENTIALS_FILE_MODE) {
|
|
174
|
+
throw new Error('Could not restrict access to the credentials file');
|
|
127
175
|
}
|
|
128
|
-
return result;
|
|
129
|
-
}
|
|
130
|
-
deleteInsecurePlaintextCredentials() {
|
|
131
|
-
this.cachedConfig.delete(CACHE_CREDENTIALS_KEY);
|
|
132
176
|
}
|
|
133
|
-
async
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
if (this.keytar) {
|
|
138
|
-
await this.setCredentials(plaintextCredentials);
|
|
139
|
-
this.logger.warn(ui_1.Text.warning.plaintextCredentialsMigrated);
|
|
177
|
+
async secureStorage(createFile) {
|
|
178
|
+
try {
|
|
179
|
+
if (this.currentPlatform === 'win32') {
|
|
180
|
+
await this.secureWindowsStorage(createFile);
|
|
140
181
|
}
|
|
141
182
|
else {
|
|
142
|
-
this.
|
|
183
|
+
await this.securePosixStorage(createFile);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
await fs_1.promises.rm(this.credentialsFilePath, { force: true }).catch(() => undefined);
|
|
188
|
+
throw new CredentialStoreSecurityError(error);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
async readCredentialsFile() {
|
|
192
|
+
let contents;
|
|
193
|
+
try {
|
|
194
|
+
await this.secureStorage(false);
|
|
195
|
+
contents = await fs_1.promises.readFile(this.credentialsFilePath, 'utf8');
|
|
196
|
+
}
|
|
197
|
+
catch (error) {
|
|
198
|
+
if (isFileNotFoundError(error)) {
|
|
199
|
+
return {};
|
|
143
200
|
}
|
|
201
|
+
throw error;
|
|
144
202
|
}
|
|
203
|
+
let parsed;
|
|
204
|
+
try {
|
|
205
|
+
parsed = JSON.parse(contents);
|
|
206
|
+
}
|
|
207
|
+
catch {
|
|
208
|
+
throw new NoTokenInStoreError();
|
|
209
|
+
}
|
|
210
|
+
const decodeResult = credentialsByAccountShape.decode(parsed);
|
|
211
|
+
if ((0, Either_1.isLeft)(decodeResult)) {
|
|
212
|
+
throw new NoTokenInStoreError();
|
|
213
|
+
}
|
|
214
|
+
return decodeResult.right;
|
|
215
|
+
}
|
|
216
|
+
async getCredentials() {
|
|
145
217
|
if (process.env[exports.API_TOKEN_KEY] && process.env[exports.EMAIL_KEY]) {
|
|
146
218
|
const credentials = {
|
|
147
219
|
email: process.env[exports.EMAIL_KEY],
|
|
148
220
|
token: process.env[exports.API_TOKEN_KEY]
|
|
149
221
|
};
|
|
150
222
|
const { accountId } = await this.userRepository.getUser(credentials);
|
|
151
|
-
|
|
223
|
+
return { ...credentials, accountId };
|
|
152
224
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
if (result) {
|
|
157
|
-
return result;
|
|
225
|
+
const credentials = (await this.readCredentialsFile())[this.account];
|
|
226
|
+
if (!credentials) {
|
|
227
|
+
throw new NoTokenInStoreError();
|
|
158
228
|
}
|
|
159
|
-
|
|
229
|
+
return credentials;
|
|
160
230
|
}
|
|
161
231
|
async setCredentials(credentials) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
catch (e) {
|
|
167
|
-
throw new NoKeytarError();
|
|
168
|
-
}
|
|
232
|
+
let credentialsByAccount;
|
|
233
|
+
try {
|
|
234
|
+
credentialsByAccount = await this.readCredentialsFile();
|
|
169
235
|
}
|
|
170
|
-
|
|
171
|
-
|
|
236
|
+
catch (error) {
|
|
237
|
+
if (!(error instanceof NoTokenInStoreError)) {
|
|
238
|
+
throw error;
|
|
239
|
+
}
|
|
240
|
+
credentialsByAccount = {};
|
|
172
241
|
}
|
|
242
|
+
credentialsByAccount[this.account] = credentials;
|
|
243
|
+
await this.secureStorage(true);
|
|
244
|
+
await fs_1.promises.writeFile(this.credentialsFilePath, `${JSON.stringify(credentialsByAccount, null, 2)}\n`, 'utf8');
|
|
245
|
+
await this.secureStorage(false);
|
|
173
246
|
}
|
|
174
247
|
async deleteCredentials() {
|
|
175
|
-
|
|
248
|
+
let credentialsByAccount;
|
|
249
|
+
try {
|
|
250
|
+
credentialsByAccount = await this.readCredentialsFile();
|
|
251
|
+
}
|
|
252
|
+
catch (error) {
|
|
253
|
+
if (!(error instanceof NoTokenInStoreError)) {
|
|
254
|
+
throw error;
|
|
255
|
+
}
|
|
256
|
+
await fs_1.promises.rm(this.credentialsFilePath, { force: true });
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
delete credentialsByAccount[this.account];
|
|
260
|
+
if (Object.keys(credentialsByAccount).length === 0) {
|
|
176
261
|
try {
|
|
177
|
-
await
|
|
262
|
+
await fs_1.promises.unlink(this.credentialsFilePath);
|
|
178
263
|
}
|
|
179
|
-
catch (
|
|
264
|
+
catch (error) {
|
|
265
|
+
if (!isFileNotFoundError(error)) {
|
|
266
|
+
throw error;
|
|
267
|
+
}
|
|
180
268
|
}
|
|
269
|
+
return;
|
|
181
270
|
}
|
|
182
|
-
this.
|
|
271
|
+
await fs_1.promises.writeFile(this.credentialsFilePath, `${JSON.stringify(credentialsByAccount, null, 2)}\n`, 'utf8');
|
|
272
|
+
await this.secureStorage(false);
|
|
183
273
|
}
|
|
184
274
|
}
|
|
185
|
-
exports.
|
|
186
|
-
function getCredentialStore(
|
|
187
|
-
|
|
188
|
-
const cachedConfig = cache_1.CachedConf.getCache(cache_1.CONFIG_PROJECT_NAME);
|
|
189
|
-
const instructionsUrl = (0, instruction_1.getInstructionsUrl)();
|
|
190
|
-
return new CredentialStoreImpl(logger, instructionsUrl, keytar, cachedConfig, userRepository);
|
|
275
|
+
exports.FileCredentialStore = FileCredentialStore;
|
|
276
|
+
function getCredentialStore(userRepository) {
|
|
277
|
+
return new FileCredentialStore(userRepository, (0, graphql_1.getEnvironmentConfig)(CredentialAccount));
|
|
191
278
|
}
|
|
@@ -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;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-file.d.ts","sourceRoot":"","sources":["../../src/config/config-file.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGpE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAoB,MAAM,IAAI,CAAC;AAGlE,OAAO,EACL,OAAO,EACP,cAAc,EACd,SAAS,EAOV,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,SAAS,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"config-file.d.ts","sourceRoot":"","sources":["../../src/config/config-file.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGpE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAoB,MAAM,IAAI,CAAC;AAGlE,OAAO,EACL,OAAO,EACP,cAAc,EACd,SAAS,EAOV,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEvD,qBAAa,oBAAqB,SAAQ,eAAe;;CAIxD;AAED,qBAAa,8BAA+B,SAAQ,SAAS;gBAC/C,SAAS,EAAE,MAAM,EAAE;CAGhC;AAED,MAAM,WAAW,OAAO;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,gBAAgB;IAC/B,cAAc,IAAI,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;CAC3C;AAED,MAAM,MAAM,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;AACpC,MAAM,MAAM,cAAc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AAO,CAAC,MAAM,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAe1E,YAAY,CAAC,aAAa,CAAC,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAsB1E,aAAa,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAKzD,OAAO,CAAC,eAAe;CAkCxB"}
|
|
@@ -181,7 +181,7 @@ class ConfigFile {
|
|
|
181
181
|
this.writeManifest(currentConfigDoc);
|
|
182
182
|
}
|
|
183
183
|
getHostedResourceModules(modules) {
|
|
184
|
-
const modulesArray =
|
|
184
|
+
const modulesArray = Object.values(modules).flat();
|
|
185
185
|
return modulesArray.filter(config_1.isHostedResourceModule);
|
|
186
186
|
}
|
|
187
187
|
assertNoMissingResources(modules, resources) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-system-reader.d.ts","sourceRoot":"","sources":["../../src/file-system/file-system-reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"file-system-reader.d.ts","sourceRoot":"","sources":["../../src/file-system/file-system-reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,MAAM,IAAI,CAAC;AAS9C,KAAK,cAAc,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,OAAO,CAAC;AAEjE,qBAAa,gBAAgB;IACpB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAIrC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAQxC,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAS5D,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,CAAC,MAAM,GAAG,cAAc,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAgBtG,QAAQ,CAAC,EAAE,OAAO,EAAE,SAAiB,EAAE,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAmB3G,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAI7C,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAQ9C,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IASxE,gBAAgB,IAAI,MAAM;IAI1B,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM;IAO3C,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAQvC,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAU/E,OAAO,CAAC,eAAe;IAQV,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAIpE"}
|
|
@@ -8,7 +8,6 @@ const os_1 = require("os");
|
|
|
8
8
|
const path_1 = tslib_1.__importStar(require("path"));
|
|
9
9
|
const util_1 = require("util");
|
|
10
10
|
const recursive_readdir_1 = tslib_1.__importDefault(require("recursive-readdir"));
|
|
11
|
-
const shared_1 = require("../shared");
|
|
12
11
|
const FILE_NOT_FOUND_CODE = 'ENOENT';
|
|
13
12
|
class FileSystemReader {
|
|
14
13
|
fileExists(filePath) {
|
|
@@ -46,14 +45,14 @@ class FileSystemReader {
|
|
|
46
45
|
async readGlob({ pattern, filesOnly = false }) {
|
|
47
46
|
let results = await (0, glob_1.glob)(pattern, {});
|
|
48
47
|
if (filesOnly) {
|
|
49
|
-
results = (
|
|
48
|
+
results = (await Promise.all(results.map(async (result) => {
|
|
50
49
|
if ((await fs_1.default.promises.lstat(result)).isFile()) {
|
|
51
50
|
return [result];
|
|
52
51
|
}
|
|
53
52
|
else {
|
|
54
53
|
return [];
|
|
55
54
|
}
|
|
56
|
-
})));
|
|
55
|
+
}))).flat();
|
|
57
56
|
}
|
|
58
57
|
results.sort();
|
|
59
58
|
return results;
|
|
@@ -113,7 +112,7 @@ class FileSystemReader {
|
|
|
113
112
|
}
|
|
114
113
|
async getFileGlobList(globList) {
|
|
115
114
|
const files = await Promise.all(globList.map((pattern) => this.readGlob({ pattern, filesOnly: true })));
|
|
116
|
-
return
|
|
115
|
+
return files.flat();
|
|
117
116
|
}
|
|
118
117
|
}
|
|
119
118
|
exports.FileSystemReader = FileSystemReader;
|