@solongate/proxy 0.83.3 → 0.83.5

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.
@@ -8,13 +8,5 @@ export interface Me {
8
8
  name?: string;
9
9
  slug?: string;
10
10
  } | null;
11
- /**
12
- * Present only for a guest account, and carrying only whether the allowance is
13
- * spent. The size of it and how much is left are the operator's numbers and
14
- * are not sent here.
15
- */
16
- guest?: {
17
- exhausted?: boolean;
18
- } | null;
19
11
  }
20
12
  export declare function me(): Promise<Me>;
@@ -18,16 +18,6 @@ export declare function saveAccount(acc: SavedAccount): void;
18
18
  /** Remove a saved account from this device (does NOT revoke the cloud key). */
19
19
  export declare function removeAccount(apiKey: string): void;
20
20
  export declare function setViewCredentials(creds: Credentials | null): void;
21
- /** The unroutable address a guest ("Skip for now") account is stored under. */
22
- export declare const GUEST_EMAIL_SUFFIX = "@anonymous.solongate.invalid";
23
- /**
24
- * True when the account this device is enforcing with is a guest one.
25
- *
26
- * A guest has no dashboard rights beyond reading, and the CLI is the same
27
- * account reached a different way, so the management commands answer the same
28
- * way the dashboard does rather than half-working here.
29
- */
30
- export declare function isGuestAccount(): boolean;
31
21
  /** The key this device enforces with, or null when it is not paired. */
32
22
  export declare function enforcingKey(): string | null;
33
23
  /** True when the given key is the ACTIVE one the guard hooks use. */
@@ -56,10 +46,6 @@ export declare class ApiError extends Error {
56
46
  readonly code: string;
57
47
  constructor(status: number, code: string, message: string);
58
48
  }
59
- /** Raised when a guest account tries to change something. */
60
- export declare class GuestReadOnlyError extends Error {
61
- constructor();
62
- }
63
49
  /** Raised when no API key can be found — tells the user to run `solongate` and pair. */
64
50
  export declare class NotAuthenticatedError extends Error {
65
51
  constructor();
@@ -135,31 +135,7 @@ function installedGuardVersion() {
135
135
 
136
136
  // src/api-client/client.ts
137
137
  var DEFAULT_API_URL = "https://api.solongate.com";
138
- var accountsFile = () => join2(homedir2(), ".solongate", "accounts.json");
139
- function listAccounts() {
140
- let list5 = [];
141
- try {
142
- const raw = JSON.parse(readFileSync2(accountsFile(), "utf-8"));
143
- if (Array.isArray(raw)) list5 = raw.filter((a) => a && typeof a.apiKey === "string");
144
- } catch {
145
- }
146
- const active2 = loginCredentialFile();
147
- if (active2.apiKey && !list5.some((a) => a.apiKey === active2.apiKey)) {
148
- list5.unshift({ apiKey: active2.apiKey, apiUrl: active2.apiUrl || DEFAULT_API_URL });
149
- }
150
- return list5;
151
- }
152
138
  var viewOverride = null;
153
- var GUEST_EMAIL_SUFFIX = "@anonymous.solongate.invalid";
154
- function isGuestAccount() {
155
- try {
156
- const active2 = loginCredentialFile().apiKey;
157
- if (!active2) return false;
158
- return listAccounts().some((a) => a.apiKey === active2 && (a.email ?? "").endsWith(GUEST_EMAIL_SUFFIX));
159
- } catch {
160
- return false;
161
- }
162
- }
163
139
  var ApiError = class extends Error {
164
140
  status;
165
141
  code;
@@ -170,12 +146,6 @@ var ApiError = class extends Error {
170
146
  this.code = code;
171
147
  }
172
148
  };
173
- var GuestReadOnlyError = class extends Error {
174
- constructor() {
175
- super("Guest account: sign up at auth.solongate.com to change anything. Your project, its policy and everything recorded carry over.");
176
- this.name = "GuestReadOnlyError";
177
- }
178
- };
179
149
  var NotAuthenticatedError = class extends Error {
180
150
  constructor() {
181
151
  super("Not logged in. Run `solongate` and log in from the Accounts panel.");
@@ -240,9 +210,6 @@ function buildUrl(base, path, query) {
240
210
  return url.toString();
241
211
  }
242
212
  async function request(method, path, opts = {}) {
243
- if (method !== "GET" && isGuestAccount()) {
244
- throw new GuestReadOnlyError();
245
- }
246
213
  const creds = resolveCredentials(opts.apiUrl);
247
214
  const url = buildUrl(creds.apiUrl, path, opts.query);
248
215
  const headers = {
@@ -405,6 +405,16 @@ function repairQuiet() {
405
405
  }
406
406
  async function runRepair() {
407
407
  const out = (s) => void process.stderr.write(s + "\n");
408
+ if (process.platform !== "win32" && typeof process.getuid === "function" && process.getuid() === 0 && process.env["SOLONGATE_INTERNAL"] !== "1") {
409
+ out("");
410
+ out(" Do not run `solongate repair` with sudo.");
411
+ out(" It installs the guard into your home directory, and as root it would");
412
+ out(` arm root\u2019s home instead${process.env["SUDO_USER"] ? ` of ${process.env["SUDO_USER"]}\u2019s` : ""} \u2014 reporting success while nothing changed for you.`);
413
+ out("");
414
+ out(" Run it as yourself: solongate repair");
415
+ out("");
416
+ return 1;
417
+ }
408
418
  const rep = repairQuiet();
409
419
  out("");
410
420
  out(" SolonGate repair");