azureauth 0.4.4 → 0.4.6

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.
Files changed (2) hide show
  1. package/package.json +4 -1
  2. package/scripts/install.js +34 -19
package/package.json CHANGED
@@ -1,10 +1,13 @@
1
1
  {
2
2
  "name": "azureauth",
3
- "version": "0.4.4",
3
+ "version": "0.4.6",
4
4
  "description": "node-azure auth wrapps the AzureAuth CLI wrapper for performing AAD Authentication",
5
5
  "bin": {
6
6
  "azureauth": "./cli.js"
7
7
  },
8
+ "repository": {
9
+ "url": "https://github.com/jcreamer898/node-azureauth"
10
+ },
8
11
  "main": "lib/index.js",
9
12
  "type": "module",
10
13
  "scripts": {
@@ -2,9 +2,10 @@ import path from "path";
2
2
  import fs from "fs";
3
3
  import { DownloaderHelper } from "node-downloader-helper";
4
4
  import decompress from "decompress";
5
- import { fileURLToPath } from 'url'
5
+ import { fileURLToPath } from "url";
6
6
 
7
- const __dirname = fileURLToPath(new URL('.', import.meta.url))
7
+ const __dirname = fileURLToPath(new URL(".", import.meta.url));
8
+ const AZURE_AUTH_VERSION = "0.8.4";
8
9
 
9
10
  async function download(url, saveDirectory) {
10
11
  const downloader = new DownloaderHelper(url, saveDirectory);
@@ -27,11 +28,11 @@ const arch = process.arch;
27
28
 
28
29
  const AZUREAUTH_INFO = {
29
30
  name: "azureauth",
30
- // https://github.com/AzureAD/microsoft-authentication-cli/releases/download/0.8.2/azureauth-0.8.2-osx-arm64.tar.gz
31
- // https://github.com/AzureAD/microsoft-authentication-cli/releases/download/0.8.2/azureauth-0.8.2-osx-x64.tar.gz
32
- // https://github.com/AzureAD/microsoft-authentication-cli/releases/download/0.8.2/azureauth-0.8.2-win10-x64.zip
31
+ // https://github.com/AzureAD/microsoft-authentication-cli/releases/download/${AZUREAUTH_INFO.version}/azureauth-${AZUREAUTH_INFO.version}-osx-arm64.tar.gz
32
+ // https://github.com/AzureAD/microsoft-authentication-cli/releases/download/${AZUREAUTH_INFO.version}/azureauth-${AZUREAUTH_INFO.version}-osx-x64.tar.gz
33
+ // https://github.com/AzureAD/microsoft-authentication-cli/releases/download/${AZUREAUTH_INFO.version}/azureauth-${AZUREAUTH_INFO.version}-win10-x64.zip
33
34
  url: "https://github.com/AzureAD/microsoft-authentication-cli/releases/download/",
34
- version: "0.8.2",
35
+ version: AZURE_AUTH_VERSION,
35
36
  };
36
37
 
37
38
  const AZUREAUTH_NAME_MAP = {
@@ -67,33 +68,36 @@ export const install = async () => {
67
68
  // if platform is missing, download source instead of executable
68
69
  const DOWNLOAD_MAP = {
69
70
  win32: {
70
- def: "azureauth.exe",
71
- x64: "azureauth-0.8.2-win10-x64.zip",
71
+ x64: `azureauth-${AZUREAUTH_INFO.version}-win10-x64.zip`,
72
72
  },
73
73
  darwin: {
74
- def: "azureauth",
75
- x64: "azureauth-0.8.2-osx-x64.tar.gz",
74
+ x64: `azureauth-${AZUREAUTH_INFO.version}-osx-x64.tar.gz`,
75
+ arm64: `azureauth-${AZUREAUTH_INFO.version}-osx-arm64.tar.gz`,
76
76
  },
77
77
  // TODO: support linux when the binaries are available
78
78
  // linux: {
79
79
  // def: "azureauth.exe",
80
- // x64: "azureauth-0.8.2-win10-x64.zip",
80
+ // x64: "azureauth-${AZUREAUTH_INFO.version}-win10-x64.zip",
81
81
  // },
82
82
  };
83
83
  if (platform in DOWNLOAD_MAP) {
84
84
  // download the executable
85
- const filename =
86
- arch in DOWNLOAD_MAP[platform]
87
- ? DOWNLOAD_MAP[platform][arch]
88
- : DOWNLOAD_MAP[platform].def;
89
-
85
+ let filename = "";
86
+ if (arch in DOWNLOAD_MAP[platform]) {
87
+ filename = DOWNLOAD_MAP[platform][arch];
88
+ } else {
89
+ throw new Error("Arch is not supported in azureauth");
90
+ }
90
91
  const url = `${AZUREAUTH_INFO.url}${AZUREAUTH_INFO.version}/${filename}`;
91
92
  const distPath = path.join(OUTPUT_DIR, "azureauth");
92
93
  const archivePath = path.join(OUTPUT_DIR, filename);
93
94
 
94
95
  console.log(`Downloading azureauth from ${url}`);
95
- await download(url, OUTPUT_DIR);
96
-
96
+ try {
97
+ await download(url, OUTPUT_DIR);
98
+ } catch (err) {
99
+ throw new Error(`Download failed: ${err.message}`);
100
+ }
97
101
  console.log(`Downloaded in ${OUTPUT_DIR}`);
98
102
 
99
103
  // Make a dir to uncompress the zip or tar into
@@ -117,4 +121,15 @@ export const install = async () => {
117
121
  }
118
122
  };
119
123
 
120
- await install();
124
+ const MAX_RETRIES = 3;
125
+ for (let i = 0; i < MAX_RETRIES; i++) {
126
+ try {
127
+ await install();
128
+ break; // success, so exit the loop
129
+ } catch (err) {
130
+ console.log(`Install failed: ${err.message}`);
131
+ }
132
+ if (i === MAX_RETRIES - 1) {
133
+ throw new Error(`Install failed after ${MAX_RETRIES} attempts`);
134
+ }
135
+ }