querysub 0.660.0 → 0.662.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "querysub",
3
- "version": "0.660.0",
3
+ "version": "0.662.0",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "note1": "note on node-forge fork, see https://github.com/digitalbazaar/forge/issues/744 for details",
@@ -79,7 +79,7 @@
79
79
  "node-forge": "https://github.com/sliftist/forge#e618181b469b07bdc70b968b0391beb8ef5fecd6",
80
80
  "pako": "^2.1.0",
81
81
  "peggy": "^5.0.6",
82
- "sliftutils": "^1.7.131",
82
+ "sliftutils": "^1.7.132",
83
83
  "socket-function": "^1.2.35",
84
84
  "terser": "^5.31.0",
85
85
  "typenode": "^6.6.1",
@@ -94,7 +94,7 @@ const archivesBuilderCache = cacheJSONArgsEqual((domain: string, overrides: Part
94
94
  domain = domain.toLowerCase().replaceAll(/[^a-z0-9-]/g, "-");
95
95
  return archiveBuilder(domain, overrides);
96
96
  });
97
- function nestBucket(folder: string, archives: ReturnType<typeof createArchives>) {
97
+ export function nestBucket(folder: string, archives: ReturnType<typeof createArchives>) {
98
98
  if (!folder) return archives;
99
99
  folder = folder.replaceAll("\\", "/");
100
100
  if (!folder.endsWith("/")) {
@@ -136,7 +136,7 @@ function nestBucket(folder: string, archives: ReturnType<typeof createArchives>)
136
136
  };
137
137
  }
138
138
 
139
- function getSafeDomain() {
139
+ export function getSafeDomain() {
140
140
  return getDomain().toLowerCase().replaceAll(/[^a-z0-9-]/g, "-");
141
141
  }
142
142
 
@@ -0,0 +1,19 @@
1
+ import { createArchives } from "sliftutils/storage/remoteStorage/createArchives";
2
+ import { cache } from "socket-function/src/caching";
3
+ import { getSafeDomain, nestBucket } from "./archives2";
4
+
5
+ // The absolute-minimum archives: one private accessor, one backblaze source, no striping, no storage servers. For the values that have to be readable when none of our infrastructure is up (ex, the repo trust config machine deploy needs to bootstrap a machine).
6
+
7
+ const lowLevelBase = cache((bucket: string) => createArchives({
8
+ version: 1,
9
+ sources: [{
10
+ type: "backblaze",
11
+ url: `https://f002.backblazeb2.com/file/${bucket}/storage/storagerouting.json`,
12
+ name: "backblaze",
13
+ validWindow: [0, Number.MAX_SAFE_INTEGER],
14
+ }],
15
+ }));
16
+
17
+ export function getArchivesLowLevel(folder: string) {
18
+ return nestBucket(folder, lowLevelBase(getSafeDomain() + "-low-level"));
19
+ }
@@ -403,10 +403,10 @@ async function main() {
403
403
 
404
404
  console.log("Setting up machine:", sshRemote);
405
405
 
406
- // 0. Update apt
406
+ // 0. Update apt. nothrow, as apt update exits non-zero when ANY configured repo fails (ex, a stale third-party repo whose vendor rotated its GPG key), and setup only needs the main repos - if those are actually broken, the installs below fail loudly anyway.
407
407
  console.log("Updating apt...");
408
- await runPromise(`ssh ${sshRemote} "sudo apt update"`);
409
- console.log("✅ Apt updated");
408
+ await runPromise(`ssh ${sshRemote} "sudo apt update"`, { nothrow: true });
409
+ console.log("✅ Apt updated (any repo errors above are only fatal if the installs below fail)");
410
410
 
411
411
  // 1. Copy backblaze file to remote server (~/backblaze.json)
412
412
  console.log("Copying backblaze credentials...");
@@ -424,7 +424,7 @@ async function main() {
424
424
  console.log("✅ Git already installed");
425
425
  } catch {
426
426
  console.log("Installing git...");
427
- await runPromise(`ssh ${sshRemote} "sudo apt update && sudo apt install -y git"`);
427
+ await runPromise(`ssh ${sshRemote} "sudo apt update; sudo apt install -y git"`);
428
428
  console.log("✅ Git installed");
429
429
  }
430
430
 
@@ -509,7 +509,8 @@ async function main() {
509
509
  }
510
510
 
511
511
  // Get the public key from remote machine
512
- const sshPublicKey = await sshValue(sshRemote, "cat ~/.ssh/id_rsa.pub");
512
+ // Falls back to deriving from the private key, as the .pub file can be missing while the key itself is fine
513
+ const sshPublicKey = await sshValue(sshRemote, "cat ~/.ssh/id_rsa.pub 2>/dev/null || ssh-keygen -y -f ~/.ssh/id_rsa");
513
514
  const keyTitle = `Machine Setup - ${sshRemote} - ${new Date().toISOString()}`;
514
515
 
515
516
  // Add the deploy key to GitHub repository