modelos-secure 0.1.2 → 0.2.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.
@@ -0,0 +1 @@
1
+ export { t as loginCommand } from "./login-DZgP66jr.js";
@@ -5,7 +5,7 @@ import { execFile, spawn } from "node:child_process";
5
5
  import { createHash, randomBytes } from "node:crypto";
6
6
  import { createServer } from "node:http";
7
7
  import { emitKeypressEvents } from "node:readline";
8
- import { request } from "node:https";
8
+ import { request as request$1 } from "node:https";
9
9
  import { checkServerIdentity } from "node:tls";
10
10
  // src/ui.ts
11
11
  var color = process.stdout.isTTY && !process.env.NO_COLOR;
@@ -22,7 +22,22 @@ function say(line = "") {
22
22
  console.log(line);
23
23
  }
24
24
  var STEP_WIDTH = 13;
25
+ var lastStep = "";
26
+ /** The last step that finished, so a stop can say where it happened. */
27
+ var lastFinishedStep = () => lastStep;
28
+ /** Work to finish before the process ends on Ctrl-C, such as stopping a review it started. */
29
+ var onStop = [];
30
+ function beforeStopping(work) {
31
+ onStop.push(work);
32
+ return () => {
33
+ onStop.splice(onStop.indexOf(work), 1);
34
+ };
35
+ }
36
+ async function finishBeforeStopping() {
37
+ await Promise.race([Promise.allSettled(onStop.map((work) => work())), new Promise((resolve) => setTimeout(resolve, 5e3))]);
38
+ }
25
39
  function step(name, detail, state = "done") {
40
+ if (state === "done") lastStep = name;
26
41
  const right = state === "done" ? "done" : "";
27
42
  say(` ${bold(name.padEnd(STEP_WIDTH))}${detail}${right ? ` ${grey(right)}` : ""}`);
28
43
  }
@@ -83,15 +98,19 @@ async function ask(question, why, choices) {
83
98
  async function askText(question, secret = false) {
84
99
  process.stdout.write(` ${question} `);
85
100
  if (!interactive()) return "";
86
- return new Promise((resolve) => {
101
+ return new Promise((resolve, reject) => {
87
102
  let value = "";
88
103
  emitKeypressEvents(process.stdin);
89
104
  process.stdin.setRawMode(true);
90
105
  process.stdin.resume();
91
106
  const onKey = (text, key) => {
92
107
  if (key.ctrl && key.name === "c") {
108
+ process.stdin.off("keypress", onKey);
93
109
  process.stdin.setRawMode(false);
94
- process.exit(130);
110
+ process.stdin.pause();
111
+ process.stdout.write("\n");
112
+ reject(new Interrupted());
113
+ return;
95
114
  }
96
115
  if (key.name === "return") {
97
116
  process.stdin.off("keypress", onKey);
@@ -282,7 +301,7 @@ function gcloudIdentityToken(audience) {
282
301
  /** A fetch that connects to the URL's host and checks its certificate against `name`. */
283
302
  function fetchCheckingName(name) {
284
303
  return (url, init = {}) => new Promise((resolve, reject) => {
285
- const outgoing = request(new URL(url), {
304
+ const outgoing = request$1(new URL(url), {
286
305
  method: init.method ?? "GET",
287
306
  headers: init.headers,
288
307
  servername: name,
@@ -639,4 +658,4 @@ async function loginCommand(given = {}) {
639
658
  const who = connection.google?.email;
640
659
  say(`Saved. This machine now works in ${me.workspace}${who ? `, signed in to Google as ${who}` : ""}.`);
641
660
  }
642
- export { step as _, apiClient as a, Interrupted as c, blue as d, bold as f, say as g, red as h, IapRefusal as i, ask as l, grey as m, parseLoginLine as n, atAddress as o, dash as p, ApiError as r, readConnection as s, loginCommand as t, askText as u };
661
+ export { interactive as _, apiClient as a, say as b, Interrupted as c, beforeStopping as d, blue as f, grey as g, finishBeforeStopping as h, IapRefusal as i, ask as l, dash as m, parseLoginLine as n, atAddress as o, bold as p, ApiError as r, readConnection as s, loginCommand as t, askText as u, lastFinishedStep as v, step as x, red as y };