stepzen 0.9.38 → 0.9.39-beta.0
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/README.md +2 -2
- package/lib/commands/login.js +6 -6
- package/lib/commands/whoami.js +23 -15
- package/lib/shared/actions.d.ts +1 -1
- package/lib/shared/actions.js +12 -4
- package/lib/shared/configuration.d.ts +0 -1
- package/lib/shared/configuration.js +3 -25
- package/lib/shared/constants.d.ts +0 -2
- package/lib/shared/constants.js +3 -5
- package/lib/shared/stepzen-sdk.d.ts +25 -0
- package/lib/shared/stepzen-sdk.js +7 -0
- package/lib/shared/utils.d.ts +1 -0
- package/lib/shared/utils.js +19 -12
- package/lib/start/deploy.js +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ $ npm install -g stepzen
|
|
|
29
29
|
$ stepzen COMMAND
|
|
30
30
|
running command...
|
|
31
31
|
$ stepzen (-v|--version|version)
|
|
32
|
-
stepzen/0.9.
|
|
32
|
+
stepzen/0.9.39-beta.0 darwin-x64 node-v14.18.3
|
|
33
33
|
$ stepzen --help [COMMAND]
|
|
34
34
|
USAGE
|
|
35
35
|
$ stepzen COMMAND
|
|
@@ -80,7 +80,7 @@ OPTIONS
|
|
|
80
80
|
-n, --nested-commands Include all nested commands in the output.
|
|
81
81
|
```
|
|
82
82
|
|
|
83
|
-
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v5.1.
|
|
83
|
+
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v5.1.11/src/commands/help.ts)_
|
|
84
84
|
|
|
85
85
|
## `stepzen import SCHEMAS`
|
|
86
86
|
|
package/lib/commands/login.js
CHANGED
|
@@ -8,6 +8,7 @@ const command_1 = require("@oclif/command");
|
|
|
8
8
|
const errors_1 = require("@oclif/errors");
|
|
9
9
|
const cli_ux_1 = require("cli-ux");
|
|
10
10
|
const configuration_1 = require("../shared/configuration");
|
|
11
|
+
const stepzen_sdk_1 = require("../shared/stepzen-sdk");
|
|
11
12
|
class Login extends command_1.Command {
|
|
12
13
|
async run() {
|
|
13
14
|
const { flags } = this.parse(Login);
|
|
@@ -37,19 +38,18 @@ class Login extends command_1.Command {
|
|
|
37
38
|
});
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
|
-
const configuration = {
|
|
41
|
-
account,
|
|
42
|
-
adminkey,
|
|
43
|
-
};
|
|
44
41
|
// Check whether the account and admin key exist and are correct by calling
|
|
45
42
|
// the stepzen admin api.
|
|
46
|
-
const isValidConfiguration = await
|
|
43
|
+
const isValidConfiguration = await stepzen_sdk_1.default.verify(account, adminkey);
|
|
47
44
|
if (!isValidConfiguration) {
|
|
48
45
|
// Exit, with error
|
|
49
46
|
throw new errors_1.CLIError('We are unable to verify your account details. Could you please check them?');
|
|
50
47
|
}
|
|
51
48
|
// Change the default account.
|
|
52
|
-
configuration_1.writeConfigurationToLoginFile(
|
|
49
|
+
configuration_1.writeConfigurationToLoginFile({
|
|
50
|
+
account,
|
|
51
|
+
adminkey,
|
|
52
|
+
});
|
|
53
53
|
this.log('You have successfully logged in.');
|
|
54
54
|
}
|
|
55
55
|
}
|
package/lib/commands/whoami.js
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
const chalk = require("chalk");
|
|
5
5
|
const command_1 = require("@oclif/command");
|
|
6
6
|
const configuration_1 = require("../shared/configuration");
|
|
7
|
+
const utils_1 = require("../shared/utils");
|
|
7
8
|
class WhoAmI extends command_1.Command {
|
|
8
9
|
async run() {
|
|
9
10
|
const { flags } = this.parse(WhoAmI);
|
|
@@ -17,18 +18,20 @@ class WhoAmI extends command_1.Command {
|
|
|
17
18
|
adminkey: 'not set',
|
|
18
19
|
apikey: 'not set',
|
|
19
20
|
};
|
|
21
|
+
if (flags.adminkey) {
|
|
22
|
+
this.log(configuration.adminkey || details.adminkey);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (flags.apikey) {
|
|
26
|
+
this.log(configuration.apikey || details.apikey);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
20
29
|
if (configuration.adminkey) {
|
|
21
30
|
if (flags.showkeys) {
|
|
22
31
|
details.adminkey = configuration.adminkey;
|
|
23
32
|
}
|
|
24
33
|
else {
|
|
25
|
-
|
|
26
|
-
const key = parts[2];
|
|
27
|
-
const firstTwoChars = key.substring(0, 2);
|
|
28
|
-
const lastTwoChars = key.slice(-2);
|
|
29
|
-
const stars = '*'.repeat(key.length - 4);
|
|
30
|
-
const masked = `${firstTwoChars}${stars}${lastTwoChars}`;
|
|
31
|
-
details.adminkey = `${parts[0]}::${parts[1]}::${masked} `;
|
|
34
|
+
details.adminkey = utils_1.maskStepZenKey(configuration.adminkey);
|
|
32
35
|
}
|
|
33
36
|
}
|
|
34
37
|
if (configuration.apikey) {
|
|
@@ -36,13 +39,7 @@ class WhoAmI extends command_1.Command {
|
|
|
36
39
|
details.apikey = configuration.apikey;
|
|
37
40
|
}
|
|
38
41
|
else {
|
|
39
|
-
|
|
40
|
-
const key = parts[2];
|
|
41
|
-
const firstTwoChars = key.substring(0, 2);
|
|
42
|
-
const lastTwoChars = key.slice(-2);
|
|
43
|
-
const stars = '*'.repeat(key.length - 4);
|
|
44
|
-
const masked = `${firstTwoChars}${stars}${lastTwoChars}`;
|
|
45
|
-
details.apikey = `${parts[0]}::${parts[1]}::${masked} `;
|
|
42
|
+
details.apikey = utils_1.maskStepZenKey(configuration.apikey);
|
|
46
43
|
}
|
|
47
44
|
}
|
|
48
45
|
this.log();
|
|
@@ -57,6 +54,17 @@ WhoAmI.description = 'stepzen whoami';
|
|
|
57
54
|
WhoAmI.hidden = true;
|
|
58
55
|
WhoAmI.flags = {
|
|
59
56
|
help: command_1.flags.help({ char: 'h' }),
|
|
60
|
-
showkeys: command_1.flags.boolean({
|
|
57
|
+
showkeys: command_1.flags.boolean({
|
|
58
|
+
default: false,
|
|
59
|
+
exclusive: ['adminkey', 'apikey'],
|
|
60
|
+
}),
|
|
61
|
+
apikey: command_1.flags.boolean({
|
|
62
|
+
default: false,
|
|
63
|
+
exclusive: ['showkeys', 'adminkey'],
|
|
64
|
+
}),
|
|
65
|
+
adminkey: command_1.flags.boolean({
|
|
66
|
+
default: false,
|
|
67
|
+
exclusive: ['showkeys', 'apikey'],
|
|
68
|
+
}),
|
|
61
69
|
};
|
|
62
70
|
WhoAmI.args = [];
|
package/lib/shared/actions.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ZenCtlResponse } from './types';
|
|
2
2
|
export declare const deploy: (destination: string, configurationsets: string | undefined, schema: string) => Promise<ZenCtlResponse>;
|
|
3
|
-
export declare const list: (type:
|
|
3
|
+
export declare const list: (type: 'configurationsets' | 'schemas') => Promise<ZenCtlResponse>;
|
|
4
4
|
export declare const upload: (type: string, destination: string, file: string | undefined, directory: string | undefined) => Promise<any>;
|
package/lib/shared/actions.js
CHANGED
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.upload = exports.list = exports.deploy = void 0;
|
|
5
|
+
// This file contains 'actions' - calls to zenctl
|
|
6
|
+
const errors_1 = require("@oclif/errors");
|
|
5
7
|
const configuration_1 = require("./configuration");
|
|
6
8
|
const constants_1 = require("./constants");
|
|
7
|
-
const
|
|
9
|
+
const stepzen_sdk_1 = require("./stepzen-sdk");
|
|
8
10
|
exports.deploy = async (destination, configurationsets, schema) => {
|
|
9
11
|
const config = configuration_1.readConfiguration();
|
|
10
12
|
const server = constants_1.STEPZEN_SERVER_URL.replace('{account}', config.account);
|
|
11
|
-
const client = await
|
|
13
|
+
const client = await stepzen_sdk_1.default.client({
|
|
12
14
|
account: config.account,
|
|
13
15
|
adminkey: config.adminkey,
|
|
14
16
|
domain: constants_1.STEPZEN_DOMAIN,
|
|
@@ -23,7 +25,7 @@ exports.deploy = async (destination, configurationsets, schema) => {
|
|
|
23
25
|
exports.list = async (type) => {
|
|
24
26
|
const config = configuration_1.readConfiguration();
|
|
25
27
|
const server = constants_1.STEPZEN_SERVER_URL.replace('{account}', config.account);
|
|
26
|
-
const client = await
|
|
28
|
+
const client = await stepzen_sdk_1.default.client({
|
|
27
29
|
account: config.account,
|
|
28
30
|
adminkey: config.adminkey,
|
|
29
31
|
domain: constants_1.STEPZEN_DOMAIN,
|
|
@@ -34,16 +36,22 @@ exports.list = async (type) => {
|
|
|
34
36
|
exports.upload = async (type, destination, file, directory) => {
|
|
35
37
|
const config = configuration_1.readConfiguration();
|
|
36
38
|
const server = constants_1.STEPZEN_SERVER_URL.replace('{account}', config.account);
|
|
37
|
-
const client = await
|
|
39
|
+
const client = await stepzen_sdk_1.default.client({
|
|
38
40
|
account: config.account,
|
|
39
41
|
adminkey: config.adminkey,
|
|
40
42
|
domain: constants_1.STEPZEN_DOMAIN,
|
|
41
43
|
server,
|
|
42
44
|
});
|
|
43
45
|
if (type === 'configurationset') {
|
|
46
|
+
if (!file) {
|
|
47
|
+
throw new errors_1.CLIError('Please specify a source file with the --file flag');
|
|
48
|
+
}
|
|
44
49
|
return client.upload.configurationset(destination, file);
|
|
45
50
|
}
|
|
46
51
|
if (type === 'schema') {
|
|
52
|
+
if (!directory) {
|
|
53
|
+
throw new errors_1.CLIError('Please specify a source directory with the --dir flag');
|
|
54
|
+
}
|
|
47
55
|
return client.upload.schema(destination, directory);
|
|
48
56
|
}
|
|
49
57
|
};
|
|
@@ -2,5 +2,4 @@ import { MachineConfiguration } from './types';
|
|
|
2
2
|
export declare const readConfiguration: () => MachineConfiguration | boolean;
|
|
3
3
|
export declare const importConfiguration: (filepath: string) => MachineConfiguration;
|
|
4
4
|
export declare const removeConfigurationFromLoginFile: () => boolean;
|
|
5
|
-
export declare const verifyConfiguration: (configuration: MachineConfiguration) => Promise<boolean>;
|
|
6
5
|
export declare const writeConfigurationToLoginFile: (configuration: MachineConfiguration) => MachineConfiguration;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.writeConfigurationToLoginFile = exports.
|
|
4
|
+
exports.writeConfigurationToLoginFile = exports.removeConfigurationFromLoginFile = exports.importConfiguration = exports.readConfiguration = void 0;
|
|
5
5
|
// This file contains methods for managing configuration
|
|
6
6
|
const errors_1 = require("@oclif/errors");
|
|
7
7
|
const debug = require("debug");
|
|
8
|
-
const node_fetch_1 = require("node-fetch");
|
|
9
8
|
const fs = require("fs");
|
|
10
9
|
const path = require("path");
|
|
11
10
|
const yaml = require("yaml");
|
|
@@ -14,8 +13,8 @@ exports.readConfiguration = () => {
|
|
|
14
13
|
try {
|
|
15
14
|
let configuration;
|
|
16
15
|
// If the configuration comes from an env var, use it
|
|
17
|
-
if (
|
|
18
|
-
configuration =
|
|
16
|
+
if (process.env.STEPZEN_CONFIG_CONTENT) {
|
|
17
|
+
configuration = process.env.STEPZEN_CONFIG_CONTENT;
|
|
19
18
|
}
|
|
20
19
|
else {
|
|
21
20
|
// Read the stored configuration, if it exists.
|
|
@@ -56,27 +55,6 @@ exports.removeConfigurationFromLoginFile = () => {
|
|
|
56
55
|
return false;
|
|
57
56
|
}
|
|
58
57
|
};
|
|
59
|
-
exports.verifyConfiguration = async (configuration) => {
|
|
60
|
-
const headers = {
|
|
61
|
-
Authorization: `Apikey ${configuration.adminkey}`,
|
|
62
|
-
Host: `${configuration.account}.${constants_1.STEPZEN_DOMAIN}`,
|
|
63
|
-
};
|
|
64
|
-
const url = `${constants_1.STEPZEN_SERVER_URL}${constants_1.ADMIN_VERIFY_URL}`.replace('{account}', configuration.account);
|
|
65
|
-
debug('stepzen:headers')(headers);
|
|
66
|
-
debug('stepzen:url')(url);
|
|
67
|
-
// Try and ping zenctl. If your details are incorrect, it will return a 404
|
|
68
|
-
try {
|
|
69
|
-
const response = await node_fetch_1.default(url, {
|
|
70
|
-
headers,
|
|
71
|
-
method: 'POST',
|
|
72
|
-
});
|
|
73
|
-
await response.json();
|
|
74
|
-
return true;
|
|
75
|
-
}
|
|
76
|
-
catch (_a) {
|
|
77
|
-
return false;
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
58
|
exports.writeConfigurationToLoginFile = (configuration) => {
|
|
81
59
|
// Generate YAML from the configuration
|
|
82
60
|
const content = yaml.stringify(configuration);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export declare const STEPZEN_CONFIG_CONTENT: string | undefined;
|
|
2
1
|
export declare const STEPZEN_CONFIG_DIRECTORY: string;
|
|
3
2
|
export declare const STEPZEN_CONFIG_FILE: string;
|
|
4
3
|
export declare const STEPZEN_DOMAIN: string;
|
|
@@ -6,7 +5,6 @@ export declare const STEPZEN_SERVER_URL: string;
|
|
|
6
5
|
export declare const STEPZEN_GENERATOR_ENGINES_SCHEMA: string;
|
|
7
6
|
export declare const STEPZEN_GENERATOR_ENGINES_ENDPOINT = "stepzen-generator/engines";
|
|
8
7
|
export declare const STEPZEN_API_TEMPLATES_REPOSITORY = "https://github.com/steprz/stepzen-schemas";
|
|
9
|
-
export declare const ADMIN_ACCOUNT_URL = "/cli/admin/account";
|
|
10
8
|
export declare const ADMIN_DEPLOY_URL = "/cli/admin/deploy";
|
|
11
9
|
export declare const ADMIN_LIST_URL = "/cli/admin/list";
|
|
12
10
|
export declare const ADMIN_UPLOAD_URL = "/cli/admin/upload";
|
package/lib/shared/constants.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.ADMIN_VERIFY_URL = exports.ADMIN_UPLOAD_URL = exports.ADMIN_LIST_URL = exports.ADMIN_DEPLOY_URL = exports.
|
|
4
|
+
exports.ADMIN_VERIFY_URL = exports.ADMIN_UPLOAD_URL = exports.ADMIN_LIST_URL = exports.ADMIN_DEPLOY_URL = exports.STEPZEN_API_TEMPLATES_REPOSITORY = exports.STEPZEN_GENERATOR_ENGINES_ENDPOINT = exports.STEPZEN_GENERATOR_ENGINES_SCHEMA = exports.STEPZEN_SERVER_URL = exports.STEPZEN_DOMAIN = exports.STEPZEN_CONFIG_FILE = exports.STEPZEN_CONFIG_DIRECTORY = void 0;
|
|
5
5
|
// This file contains constants and all magic strings
|
|
6
6
|
const dotenv = require("dotenv");
|
|
7
7
|
const os = require("os");
|
|
@@ -9,9 +9,8 @@ const path = require("path");
|
|
|
9
9
|
// This allows you to set environment variables in a `.env` file.
|
|
10
10
|
// This file needs to be in your working directory.
|
|
11
11
|
dotenv.config();
|
|
12
|
-
const {
|
|
12
|
+
const { STEPZEN_CONFIG_FILE: ENV_VAR_STEPZEN_CONFIG_FILE, STEPZEN_DOMAIN: ENV_VAR_STEPZEN_DOMAIN, STEPZEN_GENERATOR_ENGINES_SCHEMA: ENV_VAR_STEPZEN_GENERATOR_ENGINES_SCHEMA, STEPZEN_SERVER_URL: ENV_VAR_STEPZEN_SERVER_URL, } = process.env;
|
|
13
13
|
// Where your authentication details are stored locally
|
|
14
|
-
exports.STEPZEN_CONFIG_CONTENT = ENV_VAR_STEPZEN_CONFIG_CONTENT;
|
|
15
14
|
exports.STEPZEN_CONFIG_DIRECTORY = path.join(os.homedir(), '.stepzen');
|
|
16
15
|
exports.STEPZEN_CONFIG_FILE = ENV_VAR_STEPZEN_CONFIG_FILE || 'stepzen-config.yaml';
|
|
17
16
|
// The zenctl domain. Override with the env var `STEPZEN_DOMAIN`
|
|
@@ -25,8 +24,7 @@ exports.STEPZEN_GENERATOR_ENGINES_SCHEMA = ENV_VAR_STEPZEN_GENERATOR_ENGINES_SCH
|
|
|
25
24
|
exports.STEPZEN_GENERATOR_ENGINES_ENDPOINT = 'stepzen-generator/engines';
|
|
26
25
|
// API Templates repository
|
|
27
26
|
exports.STEPZEN_API_TEMPLATES_REPOSITORY = 'https://github.com/steprz/stepzen-schemas';
|
|
28
|
-
// Paths to the endpoints used
|
|
29
|
-
exports.ADMIN_ACCOUNT_URL = '/cli/admin/account';
|
|
27
|
+
// Paths to the endpoints used (only for tests)
|
|
30
28
|
exports.ADMIN_DEPLOY_URL = '/cli/admin/deploy';
|
|
31
29
|
exports.ADMIN_LIST_URL = '/cli/admin/list';
|
|
32
30
|
exports.ADMIN_UPLOAD_URL = '/cli/admin/upload';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
declare const stepzen: {
|
|
2
|
+
verify: (account: string, adminkey: string) => Promise<boolean>;
|
|
3
|
+
client: (options: Pick<import("@stepzen/sdk").StepZenAccount, "account" | "adminkey"> & Partial<import("@stepzen/sdk").StepZenAccount>) => Promise<{
|
|
4
|
+
account: () => Promise<{
|
|
5
|
+
account: string;
|
|
6
|
+
apikey: string;
|
|
7
|
+
} | {
|
|
8
|
+
success: false;
|
|
9
|
+
errors: string[];
|
|
10
|
+
}>;
|
|
11
|
+
deploy: (destination: string, properties: {
|
|
12
|
+
configurationsets?: string[] | undefined;
|
|
13
|
+
schema: string;
|
|
14
|
+
}) => Promise<import("@stepzen/sdk").ZenCtlResponse>;
|
|
15
|
+
list: {
|
|
16
|
+
configurationsets: () => Promise<import("@stepzen/sdk").ZenCtlResponse>;
|
|
17
|
+
schemas: () => Promise<import("@stepzen/sdk").ZenCtlResponse>;
|
|
18
|
+
};
|
|
19
|
+
upload: {
|
|
20
|
+
configurationset: (destination: string, file: string) => Promise<import("@stepzen/sdk").ZenCtlResponse>;
|
|
21
|
+
schema: (destination: string, directory: string) => Promise<import("@stepzen/sdk").ZenCtlResponse>;
|
|
22
|
+
};
|
|
23
|
+
}>;
|
|
24
|
+
};
|
|
25
|
+
export default stepzen;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const sdk_1 = require("@stepzen/sdk");
|
|
5
|
+
const { version } = require('../../package.json');
|
|
6
|
+
const stepzen = sdk_1.init({ appName: `stepzen-cli/${version}` });
|
|
7
|
+
exports.default = stepzen;
|
package/lib/shared/utils.d.ts
CHANGED
|
@@ -4,3 +4,4 @@ export declare const ensureApiKey: () => Promise<void>;
|
|
|
4
4
|
export declare const getDirectory: (d?: string | undefined) => string;
|
|
5
5
|
export declare const getStepZenExtensions: () => Promise<string>;
|
|
6
6
|
export declare const validateEndpoint: (endpoint: string) => any;
|
|
7
|
+
export declare const maskStepZenKey: (key: string) => string;
|
package/lib/shared/utils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.validateEndpoint = exports.getStepZenExtensions = exports.getDirectory = exports.ensureApiKey = exports.clearConsole = exports.checkAuth = void 0;
|
|
4
|
+
exports.maskStepZenKey = exports.validateEndpoint = exports.getStepZenExtensions = exports.getDirectory = exports.ensureApiKey = exports.clearConsole = exports.checkAuth = void 0;
|
|
5
5
|
const errors_1 = require("@oclif/errors");
|
|
6
6
|
const chalk = require("chalk");
|
|
7
7
|
const debug = require("debug");
|
|
@@ -12,6 +12,7 @@ const path = require("path");
|
|
|
12
12
|
const prettier = require("prettier");
|
|
13
13
|
const constants_1 = require("./constants");
|
|
14
14
|
const configuration_1 = require("./configuration");
|
|
15
|
+
const stepzen_sdk_1 = require("./stepzen-sdk");
|
|
15
16
|
exports.checkAuth = async () => {
|
|
16
17
|
var _a;
|
|
17
18
|
const configuration = configuration_1.readConfiguration();
|
|
@@ -24,7 +25,7 @@ exports.checkAuth = async () => {
|
|
|
24
25
|
if (details.account === 'test') {
|
|
25
26
|
return;
|
|
26
27
|
}
|
|
27
|
-
const isValidAccount = await
|
|
28
|
+
const isValidAccount = await stepzen_sdk_1.default.verify(details.account, details.adminkey);
|
|
28
29
|
if (!isValidAccount) {
|
|
29
30
|
if ((_a = details.account) === null || _a === void 0 ? void 0 : _a.endsWith('Playground')) {
|
|
30
31
|
console.log(chalk.yellow(`
|
|
@@ -54,16 +55,12 @@ exports.ensureApiKey = async () => {
|
|
|
54
55
|
if (!details.apikey) {
|
|
55
56
|
debug('stepzen:account')(`Fetching API key for account ${details.account}`);
|
|
56
57
|
try {
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
});
|
|
64
|
-
const { apikey } = await response.json();
|
|
65
|
-
details.apikey = apikey;
|
|
66
|
-
await configuration_1.writeConfigurationToLoginFile(details);
|
|
58
|
+
const client = await stepzen_sdk_1.default.client(details);
|
|
59
|
+
const response = await client.account();
|
|
60
|
+
if ('apikey' in response) {
|
|
61
|
+
details.apikey = response.apikey;
|
|
62
|
+
await configuration_1.writeConfigurationToLoginFile(details);
|
|
63
|
+
}
|
|
67
64
|
}
|
|
68
65
|
catch (_a) { }
|
|
69
66
|
}
|
|
@@ -105,3 +102,13 @@ exports.validateEndpoint = (endpoint) => {
|
|
|
105
102
|
return error;
|
|
106
103
|
return true;
|
|
107
104
|
};
|
|
105
|
+
exports.maskStepZenKey = (key) => {
|
|
106
|
+
const parts = key.split('::');
|
|
107
|
+
const thirdPart = parts[2];
|
|
108
|
+
const firstTwoChars = thirdPart.substring(0, 2);
|
|
109
|
+
const lastTwoChars = thirdPart.slice(-2);
|
|
110
|
+
const stars = '*'.repeat(thirdPart.length - 4);
|
|
111
|
+
const maskedThirdPart = `${firstTwoChars}${stars}${lastTwoChars}`;
|
|
112
|
+
const masked = `${parts[0]}::${parts[1]}::${maskedThirdPart} `;
|
|
113
|
+
return masked;
|
|
114
|
+
};
|
package/lib/start/deploy.js
CHANGED
|
@@ -109,7 +109,7 @@ exports.default = async (file, workspace, flags) => {
|
|
|
109
109
|
console.log(chalk.grey(`You can test your hosted API with cURL:`));
|
|
110
110
|
console.log();
|
|
111
111
|
console.log(`curl ${endpoint} \\`);
|
|
112
|
-
console.log(` --header "Authorization: Apikey
|
|
112
|
+
console.log(` --header "Authorization: Apikey $(stepzen whoami --apikey)" \\`);
|
|
113
113
|
console.log(` --header "Content-Type: application/json" \\`);
|
|
114
114
|
console.log(` --data '{"query": "your graphql query"}'`);
|
|
115
115
|
console.log();
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.9.
|
|
1
|
+
{"version":"0.9.39-beta.0","commands":{"deploy":{"id":"deploy","description":"deploy to stepzen","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"configurationsets":{"name":"configurationsets","type":"option","description":"Configurationsets to use","default":""},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"schema":{"name":"schema","type":"option","description":"Schema to use","required":true},"silent":{"name":"silent","type":"boolean","allowNo":false}},"args":[{"name":"destination","description":"destination","required":true}]},"import":{"id":"import","description":"import schemas from stepzen","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"dir":{"name":"dir","type":"option","description":"working directory"},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"silent":{"name":"silent","type":"boolean","hidden":true,"allowNo":false}},"args":[{"name":"schemas","required":true}]},"init":{"id":"init","description":"stepzen init","pluginName":"stepzen","pluginType":"core","hidden":true,"aliases":[],"flags":{"endpoint":{"name":"endpoint","type":"option","hidden":true},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"yes":{"name":"yes","type":"boolean","hidden":true,"allowNo":false}},"args":[{"name":"directory","hidden":true}]},"lint":{"id":"lint","description":"stepzen lint","pluginName":"stepzen","pluginType":"core","hidden":true,"aliases":[],"flags":{"dir":{"name":"dir","type":"option","hidden":true},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"list":{"id":"list","description":"list your items","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"type","description":"type","required":true,"options":["configurationsets","schemas"]}]},"login":{"id":"login","description":"log in to stepzen","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"account":{"name":"account","type":"option","char":"a","hidden":true},"adminkey":{"name":"adminkey","type":"option","char":"k","hidden":true},"config":{"name":"config","type":"option","hidden":true},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"logout":{"id":"logout","description":"log out of stepzen","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"start":{"id":"start","description":"upload and deploy your schema","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"dir":{"name":"dir","type":"option","description":"working directory"},"endpoint":{"name":"endpoint","type":"option","description":"Override workspace endpoint"},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"no-console":{"name":"no-console","type":"boolean","hidden":true,"allowNo":false},"no-dashboard":{"name":"no-dashboard","type":"boolean","hidden":true,"allowNo":false},"no-init":{"name":"no-init","type":"boolean","hidden":true,"allowNo":false},"no-server":{"name":"no-server","type":"boolean","hidden":true,"allowNo":false},"no-validate":{"name":"no-validate","type":"boolean","hidden":true,"allowNo":false},"no-watcher":{"name":"no-watcher","type":"boolean","hidden":true,"allowNo":false},"port":{"name":"port","type":"option","default":5001}},"args":[]},"transpile":{"id":"transpile","description":"transpile a graphql schema","pluginName":"stepzen","pluginType":"core","hidden":true,"aliases":[],"flags":{"config":{"name":"config","type":"option","hidden":true},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"hide-output":{"name":"hide-output","type":"boolean","hidden":true,"allowNo":false},"inspect":{"name":"inspect","type":"boolean","char":"i","hidden":true,"allowNo":false},"inspect-after":{"name":"inspect-after","type":"boolean","hidden":true,"allowNo":false},"output-configuration":{"name":"output-configuration","type":"boolean","allowNo":false},"silent":{"name":"silent","type":"boolean","allowNo":false}},"args":[{"name":"folder","required":true}]},"upload":{"id":"upload","description":"upload to stepzen","pluginName":"stepzen","pluginType":"core","aliases":[],"flags":{"dir":{"name":"dir","type":"option","description":"A directory to upload"},"file":{"name":"file","type":"option","description":"A file to upload"},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"silent":{"name":"silent","type":"boolean","allowNo":false}},"args":[{"name":"type","description":"type","required":true,"options":["configurationset","schema"]},{"name":"destination","description":"destination","required":true}]},"validate":{"id":"validate","description":"validate a graphql schema","pluginName":"stepzen","pluginType":"core","hidden":true,"aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"folder","required":true}]},"whoami":{"id":"whoami","description":"stepzen whoami","pluginName":"stepzen","pluginType":"core","hidden":true,"aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"showkeys":{"name":"showkeys","type":"boolean","allowNo":false},"apikey":{"name":"apikey","type":"boolean","allowNo":false},"adminkey":{"name":"adminkey","type":"boolean","allowNo":false}},"args":[]}}}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stepzen",
|
|
3
3
|
"description": "The StepZen CLI",
|
|
4
|
-
"version": "0.9.
|
|
4
|
+
"version": "0.9.39-beta.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Darren Waddell <darren@stepzen.com>",
|
|
7
7
|
"contributors": [
|
|
@@ -27,15 +27,15 @@
|
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@oclif/command": "^1.8.0",
|
|
30
|
-
"@oclif/config": "^1.
|
|
30
|
+
"@oclif/config": "^1.18.3",
|
|
31
31
|
"@oclif/errors": "1.3.5",
|
|
32
|
-
"@oclif/plugin-help": "^5.1.
|
|
32
|
+
"@oclif/plugin-help": "^5.1.11",
|
|
33
33
|
"@stepzen/dashboard": "0.1.36",
|
|
34
|
-
"@stepzen/sdk": "0.9.
|
|
35
|
-
"@stepzen/transpiler": "0.0.
|
|
34
|
+
"@stepzen/sdk": "0.9.43",
|
|
35
|
+
"@stepzen/transpiler": "0.0.35",
|
|
36
36
|
"chalk": "^4.1.1",
|
|
37
37
|
"chokidar": "^3.5.2",
|
|
38
|
-
"cli-ux": "^6.0.
|
|
38
|
+
"cli-ux": "^6.0.9",
|
|
39
39
|
"compare-versions": "^3.6.0",
|
|
40
40
|
"date-fns": "^2.26.0",
|
|
41
41
|
"debug": "^4.3.0",
|