@adinsure-ops/ops-cli 5.1.1 → 5.1.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/CHANGELOGS.md CHANGED
@@ -1,8 +1,14 @@
1
1
  # Changelogs
2
2
 
3
+ ## 5.1.2: 2024-07-04
4
+
5
+ - LJADIRD-43932: updated all core (oclif) and non-core dependencies
6
+ - LJADIRDSUP-15178: added acquiring token by refreshToken functionality into security context
7
+ - LJADIRD-47453: updated create-nightly-tag regex to match correct versions and create new tag
8
+
3
9
  ## 5.1.1: 2024-05-13
4
10
 
5
- - LJADIRD-46524: Added more verbose output to the security context when aquiring token
11
+ - LJADIRD-46524: added more verbose output to the security context when aquiring token
6
12
 
7
13
  ## 5.1.0: 2024-03-29
8
14
 
package/bin/dev.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ts-node
2
- // eslint-disable-next-line node/shebang, unicorn/prefer-top-level-await
2
+ // eslint-disable-next-line
3
3
  (async () => {
4
4
  const oclif = await import('@oclif/core');
5
5
  await oclif.execute({ type: 'esm', development: true, dir: import.meta.url });
package/bin/run.js CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- // eslint-disable-next-line node/shebang
2
+ // eslint-disable-next-line
3
3
  import oclif from '@oclif/core';
4
4
 
5
- /* eslint-disable unicorn/prefer-top-level-await */
5
+ /* eslint-disable */
6
6
  oclif.run(process.argv.slice(2), import.meta.url)
7
7
  .then(oclif.flush)
8
8
  .catch(oclif.Errors.handle);
@@ -28,8 +28,8 @@ export default class CommandBase extends Command {
28
28
  }
29
29
  });
30
30
  }
31
- getVersion(versionFile = 'VERSION', ...filesToCheck) {
32
- return __awaiter(this, void 0, void 0, function* () {
31
+ getVersion() {
32
+ return __awaiter(this, arguments, void 0, function* (versionFile = 'VERSION', ...filesToCheck) {
33
33
  filesToCheck.unshift(versionFile);
34
34
  const gitRoot = yield this.getGitRoot();
35
35
  for (const file of filesToCheck) {
@@ -39,8 +39,8 @@ class DownloadStudio extends CommandBase {
39
39
  });
40
40
  }
41
41
  findExtensionIfEnabled(studioVersion, enabled) {
42
- var _a;
43
42
  return __awaiter(this, void 0, void 0, function* () {
43
+ var _a;
44
44
  if (!enabled) {
45
45
  return false;
46
46
  }
@@ -3,8 +3,8 @@ import { Args, Flags, ux } from '@oclif/core';
3
3
  import chalk from 'chalk';
4
4
  import CommandBaseJira from '../../command.base.jira.js';
5
5
  class JiraLabels extends CommandBaseJira {
6
- setLabels(jira, issue, add = [], remove = []) {
7
- return __awaiter(this, void 0, void 0, function* () {
6
+ setLabels(jira_1, issue_1) {
7
+ return __awaiter(this, arguments, void 0, function* (jira, issue, add = [], remove = []) {
8
8
  const labels = [];
9
9
  for (const label of add) {
10
10
  const add = {
@@ -79,8 +79,8 @@ class Generate extends CommandBase {
79
79
  const _super = Object.create(null, {
80
80
  run: { get: () => super.run }
81
81
  });
82
- var _a;
83
82
  return __awaiter(this, void 0, void 0, function* () {
83
+ var _a;
84
84
  _super.run.call(this);
85
85
  const { flags } = yield this.parse(Generate);
86
86
  const root = path.resolve(process.cwd());
@@ -92,9 +92,7 @@ class Login extends CommandBase {
92
92
  // Then let's acquire an authentication token from AAD
93
93
  try {
94
94
  const queryURL = new url.URL(req.url, 'http://localhost:3044').searchParams;
95
- const name = yield this.security.acquireToken(
96
- // eslint-disable-next-line unicorn/prefer-spread
97
- Object.fromEntries(Array.from(queryURL.entries())));
95
+ const name = yield this.security.acquireToken(Object.fromEntries(Array.from(queryURL.entries())));
98
96
  this.log(`Hello ${name}!`);
99
97
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
100
98
  }
@@ -35,14 +35,12 @@ class NpmCheckPublish extends CommandBase {
35
35
  return __awaiter(this, void 0, void 0, function* () {
36
36
  _super.run.call(this);
37
37
  try {
38
- // eslint-disable-next-line unicorn/no-await-expression-member
39
38
  const { flags } = (yield this.parse(NpmCheckPublish)).flags;
40
39
  const npmContext = new NpmContext();
41
40
  ux.action.start('Parsing packages to check', undefined, { stdout: true });
42
41
  const packages = yield npmContext.packageList(this, flags.package, flags.exclude);
43
42
  ux.action.stop(`${chalk.green('done')}`);
44
43
  ux.action.start('Getting list of available packages', undefined, { stdout: true });
45
- // eslint-disable-next-line unicorn/no-await-expression-member
46
44
  const allPackages = (yield npmContext.getAllNpmPackages(flags.pat)).data;
47
45
  ux.action.stop(`${chalk.green('done')}`);
48
46
  yield this.checkPackagesExists(packages, allPackages, flags.version);
@@ -16,8 +16,8 @@ class NpmDependencyUpdate extends CommandBase {
16
16
  * @param {string[]} filter Regular expressions filter for packages
17
17
  * @returns {Prmoise<void>} Void Promise
18
18
  */
19
- updateDependencies(newVersion, packages, force = false, filter = ['**/*']) {
20
- return __awaiter(this, void 0, void 0, function* () {
19
+ updateDependencies(newVersion_1, packages_1) {
20
+ return __awaiter(this, arguments, void 0, function* (newVersion, packages, force = false, filter = ['**/*']) {
21
21
  // Find all package.json files that are not in node modules
22
22
  for (const path of packages) {
23
23
  try {
@@ -5,9 +5,9 @@ import { spawn } from 'child_process';
5
5
  import CommandBase from '../../command.base.js';
6
6
  import NpmContext from '../../lib/npm.js';
7
7
  class NpmPublish extends CommandBase {
8
- publishPackage(pkg, cmd = ['yarn', 'publish']) {
9
- var _a, e_1, _b, _c, _d, e_2, _e, _f;
10
- return __awaiter(this, void 0, void 0, function* () {
8
+ publishPackage(pkg_1) {
9
+ return __awaiter(this, arguments, void 0, function* (pkg, cmd = ['yarn', 'publish']) {
10
+ var _a, e_1, _b, _c, _d, e_2, _e, _f;
11
11
  let sh;
12
12
  let args;
13
13
  // cross platform compatibility
@@ -56,7 +56,7 @@ class NpmPublish extends CommandBase {
56
56
  }
57
57
  finally { if (e_2) throw e_2.error; }
58
58
  }
59
- const exitCode = yield new Promise((resolve, _reject) => {
59
+ const exitCode = yield new Promise((resolve) => {
60
60
  this.cp.on('close', resolve);
61
61
  });
62
62
  if (exitCode) {
@@ -150,7 +150,6 @@ class NpmPublish extends CommandBase {
150
150
  const packages = yield npmContext.packageList(this, flags.package, flags.exclude);
151
151
  ux.action.stop(`${chalk.green('done')}`);
152
152
  ux.action.start('Getting list of published packages', undefined, { stdout: true });
153
- // eslint-disable-next-line unicorn/no-await-expression-member
154
153
  const allPackages = (yield npmContext.getAllNpmPackages(flags.pat)).data;
155
154
  ux.action.stop(`${chalk.green('done')}`);
156
155
  yield this.publishPackages(packages, allPackages, flags.version, flags.retry);
@@ -17,8 +17,8 @@ class NuGetDependencyUpdate extends CommandBase {
17
17
  * @param {string[]} filter Regular expressions filter for packages
18
18
  * @returns {Prmoise<void>} Void Promise
19
19
  */
20
- updateDependencies(newVersion, packages, filter = '') {
21
- return __awaiter(this, void 0, void 0, function* () {
20
+ updateDependencies(newVersion_1, packages_1) {
21
+ return __awaiter(this, arguments, void 0, function* (newVersion, packages, filter = '') {
22
22
  // Find all package.json files that are not in node modules
23
23
  for (const path of packages) {
24
24
  try {
@@ -142,7 +142,7 @@ class PrepareContent extends CommandBase {
142
142
  const m = line.match('^([!#])?(.+?)({.*?})?$');
143
143
  const dotfileLine = {
144
144
  prefix: m[1],
145
- source: path.join(sourceDirectory, path.normalize(m[2].trim())),
145
+ source: path.join(sourceDirectory, path.normalize(m[2].trim())), // should it be absolute path?
146
146
  transformData: m[3],
147
147
  };
148
148
  /*
@@ -264,11 +264,9 @@ class PrepareContent extends CommandBase {
264
264
  });
265
265
  }
266
266
  });
267
- /* eslint-disable unicorn/no-array-callback-reference */
268
267
  const doCopyTransform = copyTransformList.map(t);
269
268
  const doModuleTransform = modlueTransformList.map(t);
270
269
  const doExclude = excludeList.map(t);
271
- /* eslint-enable unicorn/no-array-callback-reference */
272
270
  /* Copy first, then transform and finally remove files. This should
273
271
  ensure that transformations can overwrite previous copies. Removals
274
272
  can still erase transformations though. If needed, we can remove
@@ -4,7 +4,7 @@ import axios from 'axios';
4
4
  import chalk from 'chalk';
5
5
  import fs from 'fs-extra';
6
6
  import inquirer from 'inquirer';
7
- import _ from 'lodash-es';
7
+ import _ from 'lodash';
8
8
  import path from 'path';
9
9
  import semver from 'semver';
10
10
  import CommandBase from '../command.base.js';
@@ -146,8 +146,8 @@ end;`;
146
146
  const _super = Object.create(null, {
147
147
  run: { get: () => super.run }
148
148
  });
149
- var _a, _b, _c;
150
149
  return __awaiter(this, void 0, void 0, function* () {
150
+ var _a, _b, _c;
151
151
  _super.run.call(this);
152
152
  const { args, flags } = yield this.parse(Sql);
153
153
  const fullVersion = (_a = flags.version) !== null && _a !== void 0 ? _a : yield this.getVersion('SQL_SCRIPTS_VERSION', 'PLATFORM_VERSION', 'VERSION');
@@ -244,7 +244,6 @@ end;`;
244
244
  this.log(`Generation script: '${chalk.green(scriptId + '.sql')}'`);
245
245
  }
246
246
  else {
247
- // eslint-disable-next-line unicorn/no-await-expression-member
248
247
  scriptId = (yield this.getScriptId(version.version)).data;
249
248
  this.log(`Got: '${chalk.green(scriptId)}'`);
250
249
  }
@@ -61,8 +61,8 @@ class Translate extends CommandBase {
61
61
  * @throws Error message
62
62
  */
63
63
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
64
- extractFiles(content, destinationDir, xmlFilename = '') {
65
- return __awaiter(this, void 0, void 0, function* () {
64
+ extractFiles(content_1, destinationDir_1) {
65
+ return __awaiter(this, arguments, void 0, function* (content, destinationDir, xmlFilename = '') {
66
66
  const zip = yield JSZip.loadAsync(content);
67
67
  for (const fileName of Object.keys(zip.files)) {
68
68
  const buffer = yield zip.files[fileName].async('nodebuffer');
@@ -118,8 +118,8 @@ class Version extends CommandBase {
118
118
  });
119
119
  });
120
120
  }
121
- insertScript(token, version, prefix, skip = false) {
122
- return __awaiter(this, void 0, void 0, function* () {
121
+ insertScript(token_1, version_1, prefix_1) {
122
+ return __awaiter(this, arguments, void 0, function* (token, version, prefix, skip = false) {
123
123
  ux.action.start('Inserting new script version', undefined, { stdout: true });
124
124
  if (skip) {
125
125
  ux.action.stop(`${chalk.blue('skip')}`);
@@ -10,7 +10,7 @@ export const versionOverride = function () {
10
10
  catch (error) {
11
11
  this.error(error);
12
12
  }
13
- // eslint-disable-next-line no-process-exit, unicorn/no-process-exit
13
+ // eslint-disable-next-line no-process-exit
14
14
  return process.exit(0);
15
15
  }
16
16
  });
@@ -7,9 +7,9 @@ export default class ChildProcessCommand {
7
7
  * @return {void}
8
8
  */
9
9
  runCommand(cmd) {
10
- var _a, e_1, _b, _c, _d, e_2, _e, _f;
11
- var _g;
12
10
  return __awaiter(this, void 0, void 0, function* () {
11
+ var _a, e_1, _b, _c, _d, e_2, _e, _f;
12
+ var _g;
13
13
  let sh;
14
14
  let args;
15
15
  let cp;
@@ -61,7 +61,7 @@ export default class ChildProcessCommand {
61
61
  }
62
62
  finally { if (e_2) throw e_2.error; }
63
63
  }
64
- const exitCode = yield new Promise((resolve, _reject) => {
64
+ const exitCode = yield new Promise((resolve) => {
65
65
  cp.on('close', resolve);
66
66
  });
67
67
  if (exitCode) {
package/lib/lib/gitlab.js CHANGED
@@ -14,8 +14,8 @@ export default class GitLab {
14
14
  * @param prefix Prefix
15
15
  * @returns {semver.SemVer} Version object
16
16
  */
17
- getLatestVersion(searchVersion, prefix = '') {
18
- return __awaiter(this, void 0, void 0, function* () {
17
+ getLatestVersion(searchVersion_1) {
18
+ return __awaiter(this, arguments, void 0, function* (searchVersion, prefix = '') {
19
19
  const versions = [];
20
20
  try {
21
21
  let page = 1;
@@ -32,13 +32,13 @@ export default class GitLab {
32
32
  page,
33
33
  },
34
34
  });
35
- // eslint-disable-next-line unicorn/no-array-for-each, @typescript-eslint/no-explicit-any
35
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
36
36
  response.data.forEach((tag) => {
37
- const regex = new RegExp(`${prefix}(v\\d*\\.\\d*\\.\\d*-\\d{4}.*)`);
37
+ const regex = new RegExp(`${prefix}v\\d+\\.\\d+\\.\\d+(-\\d{6}\\.\\d+)?$`);
38
38
  let searchTag = tag;
39
39
  const match = tag.name.match(regex);
40
- if (match !== null && match[1]) {
41
- searchTag = match[1];
40
+ if (match !== null && match[0]) {
41
+ searchTag = match[0].replace(prefix, '');
42
42
  }
43
43
  const customOptions = {
44
44
  includePrerelease: true,
package/lib/lib/npm.js CHANGED
@@ -33,8 +33,8 @@ export default class NpmContext {
33
33
  * Get package names
34
34
  */
35
35
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
36
- packageList(context, packages = ['**/*'], excludes = ['']) {
37
- return __awaiter(this, void 0, void 0, function* () {
36
+ packageList(context_1) {
37
+ return __awaiter(this, arguments, void 0, function* (context, packages = ['**/*'], excludes = ['']) {
38
38
  try {
39
39
  const workspaces = yield this.getWorkspaces();
40
40
  let searchPattern = ['package.json', '**/package.json', '!**/node_modules'];
@@ -77,8 +77,8 @@ export default class NpmContext {
77
77
  * @returns {Promise<string>} Returns all the NPM packages
78
78
  */
79
79
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
80
- getAllNpmPackages(patToken = '') {
81
- return __awaiter(this, void 0, void 0, function* () {
80
+ getAllNpmPackages() {
81
+ return __awaiter(this, arguments, void 0, function* (patToken = '') {
82
82
  const uri = `https://feeds.dev.azure.com/adacta-fintech/adinsure/_apis/packaging/Feeds/feed/packages?api-version=6.0-preview.1&includeAllVersions=true&protocolType=Npm`;
83
83
  return axios.get(uri, {
84
84
  headers: {
package/lib/lib/nuget.js CHANGED
@@ -7,8 +7,8 @@ export default class NugetContext {
7
7
  * @param exclude List of excluded packages
8
8
  * @returns {Promise<string>} Array of package names
9
9
  */
10
- projectList(exclude = []) {
11
- return __awaiter(this, void 0, void 0, function* () {
10
+ projectList() {
11
+ return __awaiter(this, arguments, void 0, function* (exclude = []) {
12
12
  try {
13
13
  const searchPattern = ['**/*.csproj'];
14
14
  for (const exc of exclude) {
@@ -33,6 +33,23 @@ export default class SecurityContext {
33
33
  * @returns [[Promise<TokenResponse>]]
34
34
  */
35
35
  getLoginUrl(): Promise<string>;
36
+ /**
37
+ * Retrieves the refresh token from the MSAL (Microsoft Authentication Library) token cache.
38
+ *
39
+ * @returns {string} The refresh token.
40
+ *
41
+ * @example
42
+ * const refreshToken = getRefreshToken();
43
+ * console.log(refreshToken);
44
+ *
45
+ * @description
46
+ * The `getRefreshToken` function extracts the refresh token from the serialized token cache
47
+ * managed by the MSAL library. This function first serializes the token cache, parses it into
48
+ * a JSON object, and then retrieves the refresh token from the parsed object.
49
+ *
50
+ * @throws {Error} If there are issues with parsing the token cache or accessing the refresh token.
51
+ */
52
+ getRefreshToken(): string;
36
53
  /**
37
54
  * Gets the current authentication token.
38
55
  * This function will also automatically try to refresh token if expired.
@@ -1,5 +1,5 @@
1
1
  import { __awaiter } from "tslib";
2
- import { AuthError, ConfidentialClientApplication, CryptoProvider, PublicClientApplication } from '@azure/msal-node';
2
+ import { AuthError, ConfidentialClientApplication, CryptoProvider, InteractionRequiredAuthError, PublicClientApplication, } from '@azure/msal-node';
3
3
  import { reject } from 'lodash-es';
4
4
  import path from 'path';
5
5
  import LocalCachePlugin from './cache.js';
@@ -47,28 +47,56 @@ export default class SecurityContext {
47
47
  * @returns [[Promise<TokenResponse>]]
48
48
  */
49
49
  getLoginUrl() {
50
- return new Promise((resolve, _reject) => {
50
+ return new Promise((resolve) => {
51
51
  // Generate PKCE Codes before starting the authorization flow
52
- this._cryptoProvider.generatePkceCodes().then(({ verifier, challenge }) => {
52
+ this._cryptoProvider
53
+ .generatePkceCodes()
54
+ .then(({ verifier, challenge }) => {
53
55
  this._verifier = verifier;
54
56
  this._challenge = challenge;
55
57
  const authCodeUrlParameters = {
56
- scopes: [this.resource + '/.default'],
58
+ scopes: [this.resource + '/.default', 'offline_access'],
57
59
  redirectUri: this.redirectUri,
58
60
  codeChallenge: this._challenge,
59
61
  codeChallengeMethod: 'S256',
60
62
  };
61
63
  // Get url to sign user in and consent to scopes needed for applicatio
62
- this._pca.getAuthCodeUrl(authCodeUrlParameters).then(url => {
64
+ this._pca
65
+ .getAuthCodeUrl(authCodeUrlParameters)
66
+ .then((url) => {
63
67
  resolve(url);
64
- }).catch(error => {
68
+ })
69
+ .catch((error) => {
65
70
  reject(JSON.stringify(error));
66
71
  });
67
- }).catch(error => {
72
+ })
73
+ .catch((error) => {
68
74
  reject(error);
69
75
  });
70
76
  });
71
77
  }
78
+ /**
79
+ * Retrieves the refresh token from the MSAL (Microsoft Authentication Library) token cache.
80
+ *
81
+ * @returns {string} The refresh token.
82
+ *
83
+ * @example
84
+ * const refreshToken = getRefreshToken();
85
+ * console.log(refreshToken);
86
+ *
87
+ * @description
88
+ * The `getRefreshToken` function extracts the refresh token from the serialized token cache
89
+ * managed by the MSAL library. This function first serializes the token cache, parses it into
90
+ * a JSON object, and then retrieves the refresh token from the parsed object.
91
+ *
92
+ * @throws {Error} If there are issues with parsing the token cache or accessing the refresh token.
93
+ */
94
+ getRefreshToken() {
95
+ const tokenCache = this._pca.getTokenCache().serialize();
96
+ const refreshTokenObject = JSON.parse(tokenCache).RefreshToken;
97
+ const refreshToken = refreshTokenObject[Object.keys(refreshTokenObject)[0]].secret;
98
+ return refreshToken;
99
+ }
72
100
  /**
73
101
  * Gets the current authentication token.
74
102
  * This function will also automatically try to refresh token if expired.
@@ -82,10 +110,12 @@ export default class SecurityContext {
82
110
  const cachedAccounts = yield msalTokenCache.getAllAccounts();
83
111
  return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
84
112
  if (cachedAccounts.length > 0) {
85
- this._pca.acquireTokenSilent({
113
+ this._pca
114
+ .acquireTokenSilent({
86
115
  account: cachedAccounts[0],
87
116
  scopes: [this.resource + '/.default', 'offline_access'],
88
- }).then(response => {
117
+ })
118
+ .then((response) => {
89
119
  if (response) {
90
120
  const { accessToken } = response;
91
121
  resolve(accessToken);
@@ -93,11 +123,30 @@ export default class SecurityContext {
93
123
  else {
94
124
  reject(new Error('Error getting token, please call `ops login`.'));
95
125
  }
96
- }).catch(error => {
126
+ })
127
+ .catch((error) => __awaiter(this, void 0, void 0, function* () {
128
+ if (error instanceof InteractionRequiredAuthError) {
129
+ try {
130
+ const tokenRespone = yield this._pca.acquireTokenByRefreshToken({
131
+ refreshToken: this.getRefreshToken(),
132
+ scopes: [this.resource + '/.default'],
133
+ forceCache: true,
134
+ });
135
+ if (tokenRespone === null) {
136
+ throw new AuthError('Cannot retrieve user cache and use the refresh token!');
137
+ }
138
+ resolve(tokenRespone.accessToken);
139
+ //eslint-disable-next-line @typescript-eslint/no-explicit-any
140
+ }
141
+ catch (error) {
142
+ reject(new Error(error));
143
+ }
144
+ }
97
145
  reject(new Error(error));
98
- });
146
+ }));
99
147
  }
100
- else if (process.env.AZURE_CLIENT_ID && process.env.AZURE_CLIENT_SECRET) {
148
+ else if (process.env.AZURE_CLIENT_ID &&
149
+ process.env.AZURE_CLIENT_SECRET) {
101
150
  const cca = new ConfidentialClientApplication({
102
151
  auth: {
103
152
  clientId: process.env.AZURE_CLIENT_ID,
@@ -114,7 +163,8 @@ export default class SecurityContext {
114
163
  cca.acquireTokenSilent({
115
164
  account: ccaCachedAccounts[0],
116
165
  scopes: [this.resource + '/.default'],
117
- }).then(response => {
166
+ })
167
+ .then((response) => {
118
168
  if (response) {
119
169
  const { accessToken } = response;
120
170
  resolve(accessToken);
@@ -122,22 +172,26 @@ export default class SecurityContext {
122
172
  else {
123
173
  reject(new Error('Error getting token, please call `ops login`.'));
124
174
  }
125
- }).catch(error => {
175
+ })
176
+ .catch((error) => {
126
177
  reject(new Error(error));
127
178
  });
128
179
  }
129
180
  else {
130
181
  cca.acquireTokenByClientCredential({
131
182
  scopes: [this.resource + '/.default', 'offline_access'],
132
- }).then(response => {
183
+ })
184
+ .then((response) => {
133
185
  if (response) {
134
186
  const { accessToken } = response;
187
+ console.log(accessToken);
135
188
  resolve(accessToken);
136
189
  }
137
190
  else {
138
191
  reject(new Error('Error getting token, please call `ops login`.'));
139
192
  }
140
- }).catch(error => {
193
+ })
194
+ .catch((error) => {
141
195
  reject(new Error(error));
142
196
  });
143
197
  }
@@ -155,7 +209,7 @@ export default class SecurityContext {
155
209
  * @returns [[Promise<TokenResponse>]]
156
210
  */
157
211
  acquireToken(query) {
158
- return new Promise((resolve, _reject) => {
212
+ return new Promise((resolve) => {
159
213
  if (this._verifier === null) {
160
214
  throw new Error(`PKCE verifier missing.`);
161
215
  }
@@ -167,12 +221,15 @@ export default class SecurityContext {
167
221
  codeVerifier: this._verifier,
168
222
  clientInfo: query.client_info,
169
223
  };
170
- this._pca.acquireTokenByCode(tokenRequest).then(token => {
224
+ this._pca
225
+ .acquireTokenByCode(tokenRequest)
226
+ .then((token) => {
171
227
  var _a;
172
228
  if ((_a = token.account) === null || _a === void 0 ? void 0 : _a.name) {
173
229
  resolve(token.account.name);
174
230
  }
175
- }).catch(error => {
231
+ })
232
+ .catch((error) => {
176
233
  if (error instanceof AuthError) {
177
234
  const authError = error;
178
235
  console.log(`Error name: + ${authError.name}`);
@@ -192,7 +249,8 @@ export default class SecurityContext {
192
249
  */
193
250
  acquireTokenDeviceFlow() {
194
251
  return new Promise((resolve, reject) => {
195
- this._pca.acquireTokenByDeviceCode({
252
+ this._pca
253
+ .acquireTokenByDeviceCode({
196
254
  deviceCodeCallback(response) {
197
255
  if (response.message) {
198
256
  // tslint:disable-next-line: no-console
@@ -200,9 +258,11 @@ export default class SecurityContext {
200
258
  }
201
259
  },
202
260
  scopes: [this.resource + '/.default', 'offline_access'],
203
- }).then(_response => {
261
+ })
262
+ .then(() => {
204
263
  resolve();
205
- }).catch(error => {
264
+ })
265
+ .catch((error) => {
206
266
  reject(error);
207
267
  });
208
268
  });
@@ -218,17 +278,23 @@ export default class SecurityContext {
218
278
  const cachedAccounts = yield msalTokenCache.getAllAccounts();
219
279
  return new Promise((resolve, reject) => {
220
280
  if (cachedAccounts.length > 0) {
221
- this._pca.acquireTokenSilent({
281
+ this._pca
282
+ .acquireTokenSilent({
222
283
  account: cachedAccounts[0],
223
- scopes: [this.devopsResourceId + '/.default', 'offline_access'],
224
- }).then(response => {
284
+ scopes: [
285
+ this.devopsResourceId + '/.default',
286
+ 'offline_access',
287
+ ],
288
+ })
289
+ .then((response) => {
225
290
  if (response) {
226
291
  resolve(response.accessToken);
227
292
  }
228
293
  else {
229
294
  reject(new Error('Error getting token, please call `ops login`.'));
230
295
  }
231
- }).catch(error => {
296
+ })
297
+ .catch((error) => {
232
298
  reject(new Error(error));
233
299
  });
234
300
  }