@neosmart/ssclient 2.0.0 → 2.0.1-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.
Files changed (2) hide show
  1. package/install.js +16 -5
  2. package/package.json +1 -1
package/install.js CHANGED
@@ -28,17 +28,17 @@ const __dirname = dirname(__filename);
28
28
  * @property {Record<string, string | string[] | BuildEntry>} precompiled - Mapping of os-arch to builds
29
29
  */
30
30
 
31
+ const VERSION = pkg.version.replace(/[+-].*/, "");
31
32
  const MANIFEST_URLS = [
32
33
  `${__dirname}/manifest.json`,
33
34
  `https://raw.githubusercontent.com/neosmart/securestore-rs/refs/heads/master/ssclient/npm/manifests/v${pkg.version}.json`,
34
- `https://neosmart.net/SecureStore/ssclient/npm/manifests/v${pkg.version}.json`,
35
- `https://raw.githubusercontent.com/neosmart/securestore-rs/refs/tags/ssclient/${pkg.version}/ssclient/npm/manifests/v${pkg.version}.json`,
35
+ `https://raw.githubusercontent.com/neosmart/securestore-rs/refs/heads/master/ssclient/npm/manifests/v${VERSION}.json`,
36
+ `https://neosmart.net/SecureStore/ssclient/npm/manifests/v${VERSION}.json`,
36
37
  ];
37
38
  const BIN_NAME = "ssclient";
38
39
  const PKG_ROOT = __dirname;
39
40
  const FALLBACK_JS = join(PKG_ROOT, "ssclient.js");
40
41
  const BASE_BIN_DIR = join(PKG_ROOT, "bin");
41
- const VERSION = pkg.version;
42
42
  const VERSIONED_DIR = join(BASE_BIN_DIR, `v${VERSION}`);
43
43
  const ENTRY_POINT = join(__dirname, pkg.bin[BIN_NAME]);
44
44
 
@@ -198,8 +198,10 @@ async function linkBinary(target, linkPath) {
198
198
  // Don't check if it exists first because we need to also remove broken symlinks
199
199
  await unlink(linkPath);
200
200
  } catch (err) {
201
- console.error(`Failed to remove existing binary: ${err}`);
202
- throw err;
201
+ if (existsSync(linkPath)) {
202
+ console.error(`Failed to remove existing binary: ${err}`);
203
+ throw err;
204
+ }
203
205
  }
204
206
 
205
207
  const rel = relative(dirname(linkPath), target);
@@ -246,6 +248,9 @@ async function resolve(pathOrUrl, result) {
246
248
  if (!response.ok) {
247
249
  throw new Error(`HTTP Error: ${response.status} ${response.statusText}`);
248
250
  }
251
+ if (/html/i.test(response.headers.get("content-type") ?? "")) {
252
+ throw new Error("Unexpected HTML in response!");
253
+ }
249
254
  return result === "text" ? await response.text() : await response.json();
250
255
  } else if (existsSync(pathOrUrl)) {
251
256
  const text = await readFile(pathOrUrl, { encoding: "utf8" });
@@ -264,8 +269,14 @@ async function main() {
264
269
 
265
270
  /** @type {Manifest} */
266
271
  const manifest = await (async () => {
272
+ /** @type {string | undefined} */
273
+ let last;
267
274
  for (const url of MANIFEST_URLS) {
275
+ if (url === last) {
276
+ continue;
277
+ }
268
278
  try {
279
+ last = url;
269
280
  const manifest = await resolve(url, "json");
270
281
  return manifest;
271
282
  } catch {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@neosmart/ssclient",
3
3
  "description": "SecureStore cli client, cross-platform and sandboxed",
4
- "version": "2.0.0",
4
+ "version": "2.0.1-beta.0",
5
5
  "keywords": [
6
6
  "SecureStore",
7
7
  "encryption",