@solongate/proxy 0.81.36 → 0.81.38
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/dist/api-client/client.d.ts +19 -0
- package/dist/api-client/device-login.d.ts +16 -0
- package/dist/api-client/index.d.ts +1 -0
- package/dist/commands/index.js +6 -1
- package/dist/index.js +515 -254
- package/dist/login.js +24 -0
- package/dist/tui/index.js +306 -62
- package/dist/tui/panels/Accounts.d.ts +7 -0
- package/package.json +1 -1
|
@@ -3,6 +3,25 @@ export interface Credentials {
|
|
|
3
3
|
apiKey: string;
|
|
4
4
|
apiUrl: string;
|
|
5
5
|
}
|
|
6
|
+
export interface SavedAccount {
|
|
7
|
+
apiKey: string;
|
|
8
|
+
apiUrl: string;
|
|
9
|
+
project?: string;
|
|
10
|
+
user?: string;
|
|
11
|
+
addedAt?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare function listAccounts(): SavedAccount[];
|
|
14
|
+
/** Upsert an account (dedupe by apiKey). Called from `login`. */
|
|
15
|
+
export declare function saveAccount(acc: SavedAccount): void;
|
|
16
|
+
export declare function setViewCredentials(creds: Credentials | null): void;
|
|
17
|
+
/** True when the given key is the ACTIVE one the guard hooks use. */
|
|
18
|
+
export declare function isActiveAccount(apiKey: string): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Make an account the ACTIVE one the guard hooks read (writes the active-key
|
|
21
|
+
* file). Used when a dataroom login should also become this device's enforcing
|
|
22
|
+
* account. Best-effort; returns false on failure.
|
|
23
|
+
*/
|
|
24
|
+
export declare function setActiveAccount(creds: Credentials): boolean;
|
|
6
25
|
/**
|
|
7
26
|
* Thrown for any non-2xx response. `code`/`message` come from the API's
|
|
8
27
|
* `{ error: { code, message } }` envelope when present; `status` is the HTTP
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface DeviceStart {
|
|
2
|
+
deviceCode: string;
|
|
3
|
+
verifyUrl: string;
|
|
4
|
+
intervalMs: number;
|
|
5
|
+
expiresAt: number;
|
|
6
|
+
}
|
|
7
|
+
export interface DevicePoll {
|
|
8
|
+
status: 'pending' | 'approved' | 'expired' | 'not_found';
|
|
9
|
+
apiKey?: string;
|
|
10
|
+
project?: string;
|
|
11
|
+
user?: string;
|
|
12
|
+
}
|
|
13
|
+
/** Best-effort browser open. No-op on failure (headless / missing opener). */
|
|
14
|
+
export declare function openBrowser(url: string): void;
|
|
15
|
+
export declare function startDeviceLogin(apiUrl?: string): Promise<DeviceStart>;
|
|
16
|
+
export declare function pollDeviceLogin(apiUrl: string, deviceCode: string): Promise<DevicePoll>;
|
package/dist/commands/index.js
CHANGED
|
@@ -5,10 +5,11 @@ var __export = (target, all) => {
|
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
// src/api-client/client.ts
|
|
8
|
-
import { readFileSync, existsSync } from "fs";
|
|
8
|
+
import { readFileSync, writeFileSync, mkdirSync, existsSync } from "fs";
|
|
9
9
|
import { resolve, join } from "path";
|
|
10
10
|
import { homedir } from "os";
|
|
11
11
|
var DEFAULT_API_URL = "https://api.solongate.com";
|
|
12
|
+
var viewOverride = null;
|
|
12
13
|
var ApiError = class extends Error {
|
|
13
14
|
status;
|
|
14
15
|
code;
|
|
@@ -62,6 +63,7 @@ function isAuthenticated() {
|
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
65
|
function resolveCredentials(apiUrlOverride) {
|
|
66
|
+
if (viewOverride && !apiUrlOverride) return viewOverride;
|
|
65
67
|
if (cached && !apiUrlOverride) return cached;
|
|
66
68
|
const file = loginCredentialFile();
|
|
67
69
|
const apiKey = process.env["SOLONGATE_API_KEY"] || file.apiKey || dotenvApiKey();
|
|
@@ -137,6 +139,9 @@ async function request(method, path, opts = {}) {
|
|
|
137
139
|
return json;
|
|
138
140
|
}
|
|
139
141
|
|
|
142
|
+
// src/api-client/device-login.ts
|
|
143
|
+
import { spawn } from "child_process";
|
|
144
|
+
|
|
140
145
|
// src/api-client/policies.ts
|
|
141
146
|
var policies_exports = {};
|
|
142
147
|
__export(policies_exports, {
|