@servicenow/sdk 1.0.2
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 +24 -0
- package/bin/debug.js +3 -0
- package/bin/index.js +2 -0
- package/dist/auth/index.d.ts +11 -0
- package/dist/auth/index.js +206 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/keychain/index.d.ts +12 -0
- package/dist/auth/keychain/index.js +44 -0
- package/dist/auth/keychain/index.js.map +1 -0
- package/dist/command/auth/commands/clear.d.ts +6 -0
- package/dist/command/auth/commands/clear.js +30 -0
- package/dist/command/auth/commands/clear.js.map +1 -0
- package/dist/command/auth/commands/list.d.ts +6 -0
- package/dist/command/auth/commands/list.js +30 -0
- package/dist/command/auth/commands/list.js.map +1 -0
- package/dist/command/auth/commands/save.d.ts +10 -0
- package/dist/command/auth/commands/save.js +96 -0
- package/dist/command/auth/commands/save.js.map +1 -0
- package/dist/command/auth/commands/setDefault.d.ts +6 -0
- package/dist/command/auth/commands/setDefault.js +30 -0
- package/dist/command/auth/commands/setDefault.js.map +1 -0
- package/dist/command/auth/commands/validate.d.ts +6 -0
- package/dist/command/auth/commands/validate.js +43 -0
- package/dist/command/auth/commands/validate.js.map +1 -0
- package/dist/command/auth/index.d.ts +2 -0
- package/dist/command/auth/index.js +35 -0
- package/dist/command/auth/index.js.map +1 -0
- package/dist/command/build/index.d.ts +11 -0
- package/dist/command/build/index.js +98 -0
- package/dist/command/build/index.js.map +1 -0
- package/dist/command/clean/index.d.ts +6 -0
- package/dist/command/clean/index.js +34 -0
- package/dist/command/clean/index.js.map +1 -0
- package/dist/command/compile/index.d.ts +7 -0
- package/dist/command/compile/index.js +42 -0
- package/dist/command/compile/index.js.map +1 -0
- package/dist/command/convert/index.d.ts +12 -0
- package/dist/command/convert/index.js +77 -0
- package/dist/command/convert/index.js.map +1 -0
- package/dist/command/create/index.d.ts +15 -0
- package/dist/command/create/index.js +92 -0
- package/dist/command/create/index.js.map +1 -0
- package/dist/command/deploy/index.d.ts +12 -0
- package/dist/command/deploy/index.js +80 -0
- package/dist/command/deploy/index.js.map +1 -0
- package/dist/command/fetch/index.d.ts +12 -0
- package/dist/command/fetch/index.js +78 -0
- package/dist/command/fetch/index.js.map +1 -0
- package/dist/command/generate-modules/index.d.ts +7 -0
- package/dist/command/generate-modules/index.js +46 -0
- package/dist/command/generate-modules/index.js.map +1 -0
- package/dist/command/pack/index.d.ts +6 -0
- package/dist/command/pack/index.js +40 -0
- package/dist/command/pack/index.js.map +1 -0
- package/dist/command/package-dependencies/index.d.ts +8 -0
- package/dist/command/package-dependencies/index.js +52 -0
- package/dist/command/package-dependencies/index.js.map +1 -0
- package/dist/command/test/index.d.ts +3 -0
- package/dist/command/test/index.js +52 -0
- package/dist/command/test/index.js.map +1 -0
- package/dist/command/transform/index.d.ts +3 -0
- package/dist/command/transform/index.js +63 -0
- package/dist/command/transform/index.js.map +1 -0
- package/dist/epilogue/index.d.ts +1 -0
- package/dist/epilogue/index.js +9 -0
- package/dist/epilogue/index.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +55 -0
- package/dist/index.js.map +1 -0
- package/dist/usage/index.d.ts +1 -0
- package/dist/usage/index.js +16 -0
- package/dist/usage/index.js.map +1 -0
- package/dist/util.d.ts +1 -0
- package/dist/util.js +25 -0
- package/dist/util.js.map +1 -0
- package/license +9 -0
- package/package.json +42 -0
- package/src/auth/index.ts +238 -0
- package/src/auth/keychain/index.ts +23 -0
- package/src/command/auth/commands/clear.ts +21 -0
- package/src/command/auth/commands/list.ts +21 -0
- package/src/command/auth/commands/save.ts +100 -0
- package/src/command/auth/commands/setDefault.ts +21 -0
- package/src/command/auth/commands/validate.ts +35 -0
- package/src/command/auth/index.ts +24 -0
- package/src/command/build/index.ts +96 -0
- package/src/command/clean/index.ts +22 -0
- package/src/command/compile/index.ts +31 -0
- package/src/command/convert/index.ts +76 -0
- package/src/command/create/index.ts +97 -0
- package/src/command/deploy/index.ts +84 -0
- package/src/command/fetch/index.ts +78 -0
- package/src/command/generate-modules/index.ts +36 -0
- package/src/command/pack/index.ts +27 -0
- package/src/command/package-dependencies/index.ts +43 -0
- package/src/command/test/index.ts +40 -0
- package/src/command/transform/index.ts +45 -0
- package/src/epilogue/index.ts +5 -0
- package/src/index.ts +50 -0
- package/src/usage/index.ts +13 -0
- package/src/util.ts +21 -0
package/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# @servicenow/sdk
|
|
2
|
+
|
|
3
|
+
The Servicenow SDK!
|
|
4
|
+
|
|
5
|
+
## Pre-requisites
|
|
6
|
+
|
|
7
|
+
* Node.js v16
|
|
8
|
+
* npm v8
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install --global @servicenow/sdk
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
### Command list
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
now-sdk --help
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Refer to [ServiceNow ](https://docs.servicenow.com/bundle/washingtondc-api-reference/page/script/sdk/reference/servicenow-sdk-cli-commands.html) docs for more information
|
package/bin/debug.js
ADDED
package/bin/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Creds } from '@servicenow/sdk-cli-core/dist/command/login';
|
|
2
|
+
export declare const SERVICE = "fluent";
|
|
3
|
+
export interface StoredCredential extends Creds {
|
|
4
|
+
isDefault: boolean;
|
|
5
|
+
alias: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function getCredentials(args: any): Promise<Creds>;
|
|
8
|
+
export declare function storeCredentials(alias: string, host: string, username: string, password: string, isDefault: boolean): Promise<void>;
|
|
9
|
+
export declare function updateDefaultCredential(alias: string, defaultCreds?: StoredCredential): Promise<void>;
|
|
10
|
+
export declare function removeCredentials(alias: string): Promise<void>;
|
|
11
|
+
export declare function listCredentials(alias: string): Promise<void>;
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.listCredentials = exports.removeCredentials = exports.updateDefaultCredential = exports.storeCredentials = exports.getCredentials = exports.SERVICE = void 0;
|
|
16
|
+
const logger_1 = require("@servicenow/sdk-cli-core/dist/cli-util/logger");
|
|
17
|
+
const Error_1 = require("@servicenow/sdk-cli-core/dist/cli-util/Error");
|
|
18
|
+
const keychain_1 = require("./keychain");
|
|
19
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
20
|
+
const test_1 = require("../command/test");
|
|
21
|
+
exports.SERVICE = 'fluent';
|
|
22
|
+
const DEFAULT_ALIAS = 'fluent-default';
|
|
23
|
+
const keychain = new keychain_1.KeyChain(exports.SERVICE);
|
|
24
|
+
function getCredentials(args) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
const [command] = args._;
|
|
27
|
+
let credentials;
|
|
28
|
+
if (command === test_1.TEST_COMMAND) {
|
|
29
|
+
credentials = { username: args.username, password: args.password, host: args.host };
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
credentials = yield getStoredCredentials(args.auth);
|
|
33
|
+
}
|
|
34
|
+
return credentials;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
exports.getCredentials = getCredentials;
|
|
38
|
+
function getStoredCredentials(alias = DEFAULT_ALIAS) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
if (alias === DEFAULT_ALIAS) {
|
|
41
|
+
const defaultCreds = yield getDefaultCredentials();
|
|
42
|
+
if (!defaultCreds) {
|
|
43
|
+
throw new Error_1.NowSDKError('Default Credential has not been set, Please provide the credential alias to use or set a default by using "$now-sdk auth set-default" command', { command: 'login', type: 'credential_storage' });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const keyStore = yield keychain.getPassword(alias);
|
|
47
|
+
if (!keyStore) {
|
|
48
|
+
throw new Error_1.NowSDKError(`Could not find stored credentials for alias: ${alias}, Please check the alias provided or save an alias using "$now-sdk auth save" command`, { command: 'login', type: 'credential_storage' });
|
|
49
|
+
}
|
|
50
|
+
return JSON.parse(keyStore);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function storeCredentials(alias, host, username, password, isDefault) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
host = getOrigin(host);
|
|
56
|
+
const defaultCreds = yield getDefaultCredentials();
|
|
57
|
+
// if no default is set, set the current alias as default
|
|
58
|
+
if (!defaultCreds || defaultCreds.alias === alias) {
|
|
59
|
+
isDefault = true;
|
|
60
|
+
}
|
|
61
|
+
const creds = {
|
|
62
|
+
username,
|
|
63
|
+
password,
|
|
64
|
+
host,
|
|
65
|
+
isDefault,
|
|
66
|
+
alias,
|
|
67
|
+
};
|
|
68
|
+
yield keychain.setPassword(alias, JSON.stringify(creds));
|
|
69
|
+
if (isDefault) {
|
|
70
|
+
yield updateDefaultCredential(alias, defaultCreds);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
exports.storeCredentials = storeCredentials;
|
|
75
|
+
function updateDefaultCredential(alias, defaultCreds) {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
logger_1.logger.info(`Setting alias ${alias} as default ...`);
|
|
78
|
+
const keyStore = yield keychain.getPassword(alias);
|
|
79
|
+
if (!keyStore) {
|
|
80
|
+
throw new Error_1.NowSDKError(`No credentials found for alias ${alias}, Please check the alias provided or save an alias using "$now-sdk auth save" command`, { command: 'auth', type: 'credential_storage' });
|
|
81
|
+
}
|
|
82
|
+
defaultCreds = defaultCreds !== null && defaultCreds !== void 0 ? defaultCreds : (yield getDefaultCredentials());
|
|
83
|
+
if (defaultCreds) {
|
|
84
|
+
const { alias: defaultCredAlias } = defaultCreds;
|
|
85
|
+
if (defaultCredAlias === alias) {
|
|
86
|
+
logger_1.logger.info(`alias ${alias} is already set as default`);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
defaultCreds.isDefault = false;
|
|
90
|
+
keychain.setPassword(defaultCredAlias, JSON.stringify(defaultCreds));
|
|
91
|
+
}
|
|
92
|
+
const creds = JSON.parse(keyStore);
|
|
93
|
+
creds.isDefault = true;
|
|
94
|
+
keychain.setPassword(DEFAULT_ALIAS, JSON.stringify(creds));
|
|
95
|
+
keychain.setPassword(alias, JSON.stringify(creds));
|
|
96
|
+
logger_1.logger.info(`Successfully set alias ${alias} as default`);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
exports.updateDefaultCredential = updateDefaultCredential;
|
|
100
|
+
function getDefaultCredentials() {
|
|
101
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
+
const keyStore = yield keychain.getPassword(DEFAULT_ALIAS);
|
|
103
|
+
if (!keyStore) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
return JSON.parse(keyStore);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
function removeCredentials(alias) {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
if (process.env['NODE_ENV'] === 'test') {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (alias === 'all') {
|
|
115
|
+
logger_1.logger.info(`Removing all stored credentials ...`);
|
|
116
|
+
const credentials = yield keychain.findCredentials();
|
|
117
|
+
if (!credentials || credentials.length === 0) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
for (const credential of credentials) {
|
|
121
|
+
yield keychain.deletePassword(credential.account);
|
|
122
|
+
}
|
|
123
|
+
logger_1.logger.info(`Successfully removed all stored credentials`);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
logger_1.logger.info(`Removing credentials for alias: ${alias} ...`);
|
|
127
|
+
const keyStore = yield keychain.getPassword(alias);
|
|
128
|
+
if (!keyStore) {
|
|
129
|
+
logger_1.logger.info(`No credentials found for alias: ${alias}`);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const creds = JSON.parse(keyStore);
|
|
133
|
+
if (creds.isDefault) {
|
|
134
|
+
logger_1.logger.info(`alias ${alias} is set as default, removing default ...`);
|
|
135
|
+
yield keychain.deletePassword(DEFAULT_ALIAS);
|
|
136
|
+
}
|
|
137
|
+
yield keychain.deletePassword(alias);
|
|
138
|
+
logger_1.logger.info(`Successfully removed credentials for alias ${alias}`);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
exports.removeCredentials = removeCredentials;
|
|
142
|
+
function listCredentials(alias) {
|
|
143
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
144
|
+
if (process.env['NODE_ENV'] === 'test') {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
const storedCreds = yield fetchCredentials(alias);
|
|
148
|
+
if (storedCreds.size === 0) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if (alias === 'all') {
|
|
152
|
+
logger_1.logger.info(`Listing all credentials: `);
|
|
153
|
+
storedCreds.forEach((creds, alias) => {
|
|
154
|
+
prettyPrintCredentials(creds, alias);
|
|
155
|
+
});
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
logger_1.logger.info(`Listing credentials for alias ${alias} ...`);
|
|
159
|
+
prettyPrintCredentials(storedCreds.get(alias));
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
exports.listCredentials = listCredentials;
|
|
163
|
+
function prettyPrintCredentials(storedCreds, alias) {
|
|
164
|
+
const { host, username, isDefault } = storedCreds;
|
|
165
|
+
if (alias) {
|
|
166
|
+
console.log(chalk_1.default.cyan.bold(`[${alias}]`));
|
|
167
|
+
}
|
|
168
|
+
console.log(` host = ${host}`);
|
|
169
|
+
console.log(` username = ${username}`);
|
|
170
|
+
console.log(` ${isDefault ? chalk_1.default.green('default = Yes') : 'default = No'}`);
|
|
171
|
+
}
|
|
172
|
+
function fetchCredentials(alias) {
|
|
173
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
174
|
+
const storedCreds = new Map();
|
|
175
|
+
if (alias === 'all') {
|
|
176
|
+
const credentials = yield keychain.findCredentials();
|
|
177
|
+
if (!credentials || credentials.length === 0) {
|
|
178
|
+
logger_1.logger.info(`No credentials found`);
|
|
179
|
+
return storedCreds;
|
|
180
|
+
}
|
|
181
|
+
for (const credential of credentials) {
|
|
182
|
+
if (credential.account === DEFAULT_ALIAS) {
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
const { alias: storedAlias, host, username, isDefault, } = JSON.parse(credential.password);
|
|
186
|
+
storedCreds.set(storedAlias, { host, username, isDefault });
|
|
187
|
+
}
|
|
188
|
+
return storedCreds;
|
|
189
|
+
}
|
|
190
|
+
const keyStore = yield keychain.getPassword(alias);
|
|
191
|
+
if (!keyStore) {
|
|
192
|
+
logger_1.logger.info(`No credentials found for alias: ${alias}`);
|
|
193
|
+
return storedCreds;
|
|
194
|
+
}
|
|
195
|
+
const { alias: storedAlias, host, username, isDefault } = JSON.parse(keyStore);
|
|
196
|
+
storedCreds.set(storedAlias, { host, username, isDefault });
|
|
197
|
+
return storedCreds;
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
function getOrigin(host) {
|
|
201
|
+
if (!host) {
|
|
202
|
+
return '';
|
|
203
|
+
}
|
|
204
|
+
return new URL(host).origin;
|
|
205
|
+
}
|
|
206
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,0EAAsE;AAEtE,wEAA0E;AAC1E,yCAAqC;AACrC,kDAAyB;AACzB,0CAA8C;AAEjC,QAAA,OAAO,GAAG,QAAQ,CAAA;AAC/B,MAAM,aAAa,GAAG,gBAAgB,CAAA;AAEtC,MAAM,QAAQ,GAAG,IAAI,mBAAQ,CAAC,eAAO,CAAC,CAAA;AAStC,SAAsB,cAAc,CAAC,IAAS;;QAC1C,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;QACxB,IAAI,WAA8B,CAAA;QAClC,IAAI,OAAO,KAAK,mBAAY,EAAE,CAAC;YAC3B,WAAW,GAAG,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAS,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAS,EAAE,IAAI,EAAE,IAAI,CAAC,IAAK,EAAE,CAAA;QAC1F,CAAC;aAAM,CAAC;YACJ,WAAW,GAAG,MAAM,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACvD,CAAC;QACD,OAAO,WAAW,CAAA;IACtB,CAAC;CAAA;AATD,wCASC;AAED,SAAe,oBAAoB,CAAC,QAAgB,aAAa;;QAC7D,IAAI,KAAK,KAAK,aAAa,EAAE,CAAC;YAC1B,MAAM,YAAY,GAAG,MAAM,qBAAqB,EAAE,CAAA;YAClD,IAAI,CAAC,YAAY,EAAE,CAAC;gBAChB,MAAM,IAAI,mBAAW,CACjB,+IAA+I,EAC/I,EAAE,OAAO,EAAE,OAAO,EAAE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IACtB,CAAC;CAAA;AAED,SAAS,SAAS,CAAC,IAAa;IAC5B,IAAI,CAAC,IAAI,EAAE,CAAC;QACR,OAAO,EAAE,CAAA;IACb,CAAC;IACD,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,MAAM,CAAA;AAC/B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare class KeyChain {
|
|
2
|
+
private readonly service;
|
|
3
|
+
constructor(service: string);
|
|
4
|
+
private getSingleton;
|
|
5
|
+
getPassword(account: string): Promise<string | null>;
|
|
6
|
+
setPassword(account: string, password: string): Promise<void>;
|
|
7
|
+
deletePassword(account: string): Promise<boolean>;
|
|
8
|
+
findCredentials(): Promise<Array<{
|
|
9
|
+
account: string;
|
|
10
|
+
password: string;
|
|
11
|
+
}>>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.KeyChain = void 0;
|
|
13
|
+
class KeyChain {
|
|
14
|
+
constructor(service) {
|
|
15
|
+
this.service = service;
|
|
16
|
+
}
|
|
17
|
+
getSingleton() {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
return (yield import('keytar')).default;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
getPassword(account) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
return this.getSingleton().then((k) => k.getPassword(this.service, account));
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
setPassword(account, password) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
return this.getSingleton().then((k) => k.setPassword(this.service, account, password));
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
deletePassword(account) {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
return this.getSingleton().then((k) => k.deletePassword(this.service, account));
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
findCredentials() {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
return this.getSingleton().then((k) => k.findCredentials(this.service));
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.KeyChain = KeyChain;
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/auth/keychain/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,MAAa,QAAQ;IACjB,YAA6B,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;IAAG,CAAC;IAElC,YAAY;;YACtB,OAAO,CAAC,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAA;QAC3C,CAAC;KAAA;IAEK,WAAW,CAAC,OAAe;;YAC7B,OAAO,IAAI,CAAC,YAAY,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;QAChF,CAAC;KAAA;IAEK,WAAW,CAAC,OAAe,EAAE,QAAgB;;YAC/C,OAAO,IAAI,CAAC,YAAY,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAA;QAC1F,CAAC;KAAA;IAEK,cAAc,CAAC,OAAe;;YAChC,OAAO,IAAI,CAAC,YAAY,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;QACnF,CAAC;KAAA;IAEK,eAAe;;YACjB,OAAO,IAAI,CAAC,YAAY,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA;QAC3E,CAAC;KAAA;CACJ;AAtBD,4BAsBC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.clear = void 0;
|
|
13
|
+
const auth_1 = require("../../../auth");
|
|
14
|
+
exports.clear = {
|
|
15
|
+
command: 'clear [alias]',
|
|
16
|
+
describe: 'Clear authentication credentials for an instance',
|
|
17
|
+
builder: (yargs) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
return yargs.positional('alias', {
|
|
19
|
+
describe: 'credential alias to clear',
|
|
20
|
+
type: 'string',
|
|
21
|
+
default: 'all',
|
|
22
|
+
});
|
|
23
|
+
}),
|
|
24
|
+
handler: function (args) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
yield (0, auth_1.removeCredentials)(args.alias);
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=clear.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clear.js","sourceRoot":"","sources":["../../../../src/command/auth/commands/clear.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,wCAAiD;AAMpC,QAAA,KAAK,GAAsC;IACpD,OAAO,EAAE,eAAe;IACxB,QAAQ,EAAE,kDAAkD;IAC5D,OAAO,EAAE,CAAO,KAAW,EAAE,EAAE;QAC3B,OAAO,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE;YAC7B,QAAQ,EAAE,2BAA2B;YACrC,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,KAAK;SACjB,CAAC,CAAA;IACN,CAAC,CAAA;IACD,OAAO,EAAE,UAAgB,IAAmC;;YACxD,MAAM,IAAA,wBAAiB,EAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACvC,CAAC;KAAA;CACJ,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.list = void 0;
|
|
13
|
+
const auth_1 = require("../../../auth");
|
|
14
|
+
exports.list = {
|
|
15
|
+
command: 'list [alias]',
|
|
16
|
+
describe: 'List all available authentication credentials',
|
|
17
|
+
builder: (yargs) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
return yargs.positional('alias', {
|
|
19
|
+
describe: 'credential alias to view',
|
|
20
|
+
type: 'string',
|
|
21
|
+
default: 'all',
|
|
22
|
+
});
|
|
23
|
+
}),
|
|
24
|
+
handler: function (args) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
yield (0, auth_1.listCredentials)(args.alias);
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../../src/command/auth/commands/list.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,wCAA+C;AAMlC,QAAA,IAAI,GAAsC;IACnD,OAAO,EAAE,cAAc;IACvB,QAAQ,EAAE,+CAA+C;IACzD,OAAO,EAAE,CAAO,KAAW,EAAE,EAAE;QAC3B,OAAO,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE;YAC7B,QAAQ,EAAE,0BAA0B;YACpC,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,KAAK;SACjB,CAAC,CAAA;IACN,CAAC,CAAA;IACD,OAAO,EAAE,UAAgB,IAAmC;;YACxD,MAAM,IAAA,sBAAe,EAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACrC,CAAC;KAAA;CACJ,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CommandModule } from 'yargs';
|
|
2
|
+
export declare const DEFAULT_HOST = "http://localhost:8080";
|
|
3
|
+
interface Arguments {
|
|
4
|
+
host: string | undefined;
|
|
5
|
+
username: string | undefined;
|
|
6
|
+
alias: string;
|
|
7
|
+
default: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const save: CommandModule<unknown, Arguments>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.save = exports.DEFAULT_HOST = void 0;
|
|
13
|
+
const auth_1 = require("../../../auth");
|
|
14
|
+
const prompts_1 = require("@inquirer/prompts");
|
|
15
|
+
exports.DEFAULT_HOST = 'http://localhost:8080';
|
|
16
|
+
const options = {
|
|
17
|
+
host: {
|
|
18
|
+
describe: 'Target host for application deployment',
|
|
19
|
+
defaultValue: exports.DEFAULT_HOST,
|
|
20
|
+
},
|
|
21
|
+
username: {
|
|
22
|
+
describe: 'The username to authenticate with the instance',
|
|
23
|
+
defaultValue: 'admin',
|
|
24
|
+
},
|
|
25
|
+
alias: {
|
|
26
|
+
describe: 'The alias to use for the host and username combination',
|
|
27
|
+
},
|
|
28
|
+
default: {
|
|
29
|
+
describe: 'Set the alias as the default',
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
exports.save = {
|
|
33
|
+
command: 'save <alias>',
|
|
34
|
+
describe: 'Store authentication credentials for an instance',
|
|
35
|
+
builder: (yargs) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
+
return yargs
|
|
37
|
+
.positional('alias', {
|
|
38
|
+
describe: options.alias.describe,
|
|
39
|
+
type: 'string',
|
|
40
|
+
demandOption: true,
|
|
41
|
+
})
|
|
42
|
+
.option('host', {
|
|
43
|
+
describe: options.host.describe,
|
|
44
|
+
type: 'string',
|
|
45
|
+
})
|
|
46
|
+
.option('username', {
|
|
47
|
+
describe: options.username.describe,
|
|
48
|
+
type: 'string',
|
|
49
|
+
})
|
|
50
|
+
.option('default', {
|
|
51
|
+
describe: options.default.describe,
|
|
52
|
+
type: 'boolean',
|
|
53
|
+
default: false,
|
|
54
|
+
alias: 'd',
|
|
55
|
+
})
|
|
56
|
+
.epilogue(`You will be prompted for a password to authenticate with the instance.`);
|
|
57
|
+
}),
|
|
58
|
+
handler: function (args) {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
const { login: loginService } = yield import('@servicenow/sdk-cli-core/dist/command/login/index.js');
|
|
61
|
+
const { logger } = yield import('@servicenow/sdk-cli-core/dist/cli-util/logger/index.js');
|
|
62
|
+
try {
|
|
63
|
+
const host = args.host ||
|
|
64
|
+
(yield (0, prompts_1.input)({
|
|
65
|
+
message: options.host.describe,
|
|
66
|
+
default: options.host.defaultValue,
|
|
67
|
+
}));
|
|
68
|
+
logger.info(`Authenticating to instance "${host}".`);
|
|
69
|
+
const username = args.username ||
|
|
70
|
+
(yield (0, prompts_1.input)({
|
|
71
|
+
message: options.username.describe,
|
|
72
|
+
default: options.username.defaultValue,
|
|
73
|
+
}));
|
|
74
|
+
const password = yield (0, prompts_1.password)({
|
|
75
|
+
message: 'The password to authenticate with the instance',
|
|
76
|
+
validate(val) {
|
|
77
|
+
return val.length > 0;
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
const session = yield loginService({ host, username, password });
|
|
81
|
+
if (!session) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const { instanceUrl } = session;
|
|
85
|
+
logger.successful(`Successfully authenticated to instance ${instanceUrl}.`);
|
|
86
|
+
logger.info(`Storing credentials for instance "${instanceUrl}" with alias ${args.alias}.`);
|
|
87
|
+
yield (0, auth_1.storeCredentials)(args.alias, instanceUrl, username, password, args.default);
|
|
88
|
+
logger.successful(`Successfully stored credentials for instance "${instanceUrl}" with alias ${args.alias}.`);
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
logger.error(error instanceof Error ? error.message : error, error);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
//# sourceMappingURL=save.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"save.js","sourceRoot":"","sources":["../../../../src/command/auth/commands/save.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,wCAAgD;AAChD,+CAAoE;AACvD,QAAA,YAAY,GAAG,uBAAuB,CAAA;AAenD,MAAM,OAAO,GAAY;IACrB,IAAI,EAAE;QACF,QAAQ,EAAE,wCAAwC;QAClD,YAAY,EAAE,oBAAY;KAC7B;IACD,QAAQ,EAAE;QACN,QAAQ,EAAE,gDAAgD;QAC1D,YAAY,EAAE,OAAO;KACxB;IACD,KAAK,EAAE;QACH,QAAQ,EAAE,wDAAwD;KACrE;IACD,OAAO,EAAE;QACL,QAAQ,EAAE,8BAA8B;KAC3C;CACJ,CAAA;AAEY,QAAA,IAAI,GAAsC;IACnD,OAAO,EAAE,cAAc;IACvB,QAAQ,EAAE,kDAAkD;IAC5D,OAAO,EAAE,CAAO,KAAW,EAAE,EAAE;QAC3B,OAAO,KAAK;aACP,UAAU,CAAC,OAAO,EAAE;YACjB,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC,QAAQ;YAChC,IAAI,EAAE,QAAQ;YACd,YAAY,EAAE,IAAI;SACrB,CAAC;aACD,MAAM,CAAC,MAAM,EAAE;YACZ,QAAQ,EAAE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AC,CAAA;oBACzB,CAAC;iBACJ,CAAC,CAAA;gBACF,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAA;gBAEhE,IAAI,CAAC,OAAO,EAAE,CAAC;oBACX,OAAM;gBACV,CAAC;gBAED,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAA;gBAC/B,MAAM,CAAC,UAAU,CAAC,0CAA0C,WAAW,GAAG,CAAC,CAAA;gBAC3E,MAAM,CAAC,IAAI,CAAC,qCAAqC,WAAW,gBAAgB,IAAI,CAAC,KAAK,GAAG,CAAC,CAAA;gBAC1F,MAAM,IAAA,uBAAgB,EAAC,IAAI,CAAC,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;gBACjF,MAAM,CAAC,UAAU,CAAC,iDAAiD,WAAW,gBAAgB,IAAI,CAAC,KAAK,GAAG,CAAC,CAAA;YAChH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACb,MAAM,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAE,KAAgB,EAAE,KAAK,CAAC,CAAA;YACnF,CAAC;QACL,CAAC;KAAA;CACJ,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.setDefault = void 0;
|
|
13
|
+
const auth_1 = require("../../../auth");
|
|
14
|
+
exports.setDefault = {
|
|
15
|
+
command: 'set-default <alias>',
|
|
16
|
+
describe: 'Set/Update the default credential alias',
|
|
17
|
+
builder: (yargs) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
return yargs.positional('alias', {
|
|
19
|
+
describe: 'credential alias to set as default option',
|
|
20
|
+
type: 'string',
|
|
21
|
+
demandOption: true,
|
|
22
|
+
});
|
|
23
|
+
}),
|
|
24
|
+
handler: function (args) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
yield (0, auth_1.updateDefaultCredential)(args.alias);
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=setDefault.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setDefault.js","sourceRoot":"","sources":["../../../../src/command/auth/commands/setDefault.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,wCAAuD;AAM1C,QAAA,UAAU,GAAsC;IACzD,OAAO,EAAE,qBAAqB;IAC9B,QAAQ,EAAE,yCAAyC;IACnD,OAAO,EAAE,CAAO,KAAW,EAAE,EAAE;QAC3B,OAAO,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE;YAC7B,QAAQ,EAAE,2CAA2C;YACrD,IAAI,EAAE,QAAQ;YACd,YAAY,EAAE,IAAI;SACrB,CAAC,CAAA;IACN,CAAC,CAAA;IACD,OAAO,EAAE,UAAgB,IAAmC;;YACxD,MAAM,IAAA,8BAAuB,EAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QAC7C,CAAC;KAAA;CACJ,CAAA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.validate = void 0;
|
|
13
|
+
const auth_1 = require("../../../auth");
|
|
14
|
+
exports.validate = {
|
|
15
|
+
describe: 'Validate authentication credentials for an instance',
|
|
16
|
+
builder: (yargs) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
return yargs.positional('alias', {
|
|
18
|
+
describe: 'credential alias to validate against the instance',
|
|
19
|
+
type: 'string',
|
|
20
|
+
demandOption: true,
|
|
21
|
+
});
|
|
22
|
+
}),
|
|
23
|
+
handler: function (args) {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
const { login: loginService } = yield import('@servicenow/sdk-cli-core/dist/command/login/index.js');
|
|
26
|
+
const { logger } = yield import('@servicenow/sdk-cli-core/dist/cli-util/logger/index.js');
|
|
27
|
+
try {
|
|
28
|
+
args['auth'] = args.alias; //getCredentials expects alias from args.auth
|
|
29
|
+
const creds = yield (0, auth_1.getCredentials)(args);
|
|
30
|
+
const session = yield loginService(creds);
|
|
31
|
+
if (!session) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const { instanceUrl } = session;
|
|
35
|
+
logger.successful(`Successfully validated creds with instance ${instanceUrl}.`);
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
logger.error(error instanceof Error ? error.message : error, error);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../../src/command/auth/commands/validate.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,wCAA8C;AAMjC,QAAA,QAAQ,GAAsC;IACvD,QAAQ,EAAE,qDAAqD;IAC/D,OAAO,EAAE,CAAO,KAAW,EAAE,EAAE;QAC3B,OAAO,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE;YAC7B,QAAQ,EAAE,mDAAmD;YAC7D,IAAI,EAAE,QAAQ;YACd,YAAY,EAAE,IAAI;SACrB,CAAC,CAAA;IACN,CAAC,CAAA;IACD,OAAO,EAAE,UAAgB,IAAmC;;YACxD,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,MAAM,MAAM,CAAC,sDAAsD,CAAC,CAAA;YACpG,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,wDAAwD,CAAC,CAAA;YACzF,IAAI,CAAC;gBACD,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAA,CAAC,6CAA6C;gBACvE,MAAM,KAAK,GAAG,MAAM,IAAA,qBAAc,EAAC,IAAI,CAAC,CAAA;gBAExC,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,KAAK,CAAC,CAAA;gBAEzC,IAAI,CAAC,OAAO,EAAE,CAAC;oBACX,OAAM;gBACV,CAAC;gBACD,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAA;gBAC/B,MAAM,CAAC,UAAU,CAAC,8CAA8C,WAAW,GAAG,CAAC,CAAA;YACnF,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACb,MAAM,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAE,KAAgB,EAAE,KAAK,CAAC,CAAA;YACnF,CAAC;QACL,CAAC;KAAA;CACJ,CAAA"}
|