@veilio-inc/cli 0.1.0 → 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.
- package/README.md +36 -3
- package/dist/args.d.ts +25 -1
- package/dist/args.d.ts.map +1 -1
- package/dist/args.js +51 -1
- package/dist/args.js.map +1 -1
- package/dist/cloud-commands.d.ts +70 -0
- package/dist/cloud-commands.d.ts.map +1 -0
- package/dist/cloud-commands.js +394 -0
- package/dist/cloud-commands.js.map +1 -0
- package/dist/cloud.d.ts +100 -0
- package/dist/cloud.d.ts.map +1 -0
- package/dist/cloud.js +178 -0
- package/dist/cloud.js.map +1 -0
- package/dist/commands.d.ts +14 -1
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +14 -0
- package/dist/commands.js.map +1 -1
- package/dist/credential.d.ts +52 -0
- package/dist/credential.d.ts.map +1 -0
- package/dist/credential.js +135 -0
- package/dist/credential.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +136 -0
- package/dist/index.js.map +1 -1
- package/dist/store.d.ts +25 -0
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +26 -1
- package/dist/store.js.map +1 -1
- package/package.json +7 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloud-commands.js","sourceRoot":"","sources":["../src/cloud-commands.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,EAAE;AACF,8EAA8E;AAC9E,gFAAgF;AAChF,gFAAgF;AAChF,6EAA6E;AAC7E,gFAAgF;AAChF,gBAAgB;AAEhB,OAAO,EACL,UAAU,EACV,SAAS,EACT,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,OAAO,GAIR,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EAClB,UAAU,EACV,kBAAkB,GAEnB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,OAAO,EAAE,UAAU,E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C;KACF,CAAC,CAAA;IACF,EAAE,CAAC,MAAM,CAAC,UAAU,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,wBAAwB,OAAO,CAAC,EAAE,IAAI,CAAC,CAAA;IAClF,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,SAAS,WAAW,CAAC,EAAM;IACzB,EAAE,CAAC,MAAM,CAAC,oDAAoD,CAAC,CAAA;IAC/D,OAAO,UAAU,CAAA;AACnB,CAAC;AAED,gFAAgF;AAChF,SAAS,kBAAkB,CAAC,GAAY,EAAE,EAAM;IAC9C,OAAO,kBAAkB,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;AACpC,CAAC"}
|
package/dist/cloud.d.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { Credential } from './credential.js';
|
|
2
|
+
/** The public Cloud. `--instance` overrides it for a self-hosted deployment. */
|
|
3
|
+
export declare const DEFAULT_INSTANCE = "https://app.veilio.dev";
|
|
4
|
+
/** How long any single request may take before we give up on it. */
|
|
5
|
+
export declare const REQUEST_TIMEOUT_MS = 15000;
|
|
6
|
+
/**
|
|
7
|
+
* What went wrong, in the terms the user needs to act on.
|
|
8
|
+
*
|
|
9
|
+
* `kind` exists because the remedies differ and a single "request failed" would
|
|
10
|
+
* send people to the wrong one (FR-007):
|
|
11
|
+
* - `unauthenticated` — the credential is wrong or the session was revoked.
|
|
12
|
+
* Sign in again.
|
|
13
|
+
* - `unentitled` — the sign-in worked; the plan does not include this. Nothing
|
|
14
|
+
* about signing in again will help.
|
|
15
|
+
* - `suspended` — the account is under review. Export and erasure still work;
|
|
16
|
+
* nothing else does, and a bigger plan will not change that.
|
|
17
|
+
* - `forbidden` — authenticated, entitled, and still not allowed: somebody
|
|
18
|
+
* else's map, or a team role this account does not hold.
|
|
19
|
+
* - `unreachable` — the instance did not answer. Nothing is wrong with the
|
|
20
|
+
* account.
|
|
21
|
+
* - `server` — the instance answered with a failure of its own.
|
|
22
|
+
*/
|
|
23
|
+
export type CloudErrorKind = 'unauthenticated' | 'unentitled' | 'suspended' | 'forbidden' | 'unreachable' | 'server';
|
|
24
|
+
export declare class CloudError extends Error {
|
|
25
|
+
readonly kind: CloudErrorKind;
|
|
26
|
+
readonly status?: number | undefined;
|
|
27
|
+
constructor(kind: CloudErrorKind, message: string, status?: number | undefined);
|
|
28
|
+
}
|
|
29
|
+
export interface RequestOptions {
|
|
30
|
+
/** Base URL of the instance. Defaults to the public Cloud. */
|
|
31
|
+
instance?: string;
|
|
32
|
+
/** Bearer credential, when the call needs one. */
|
|
33
|
+
credential?: Credential | null;
|
|
34
|
+
method?: 'GET' | 'POST' | 'DELETE';
|
|
35
|
+
body?: unknown;
|
|
36
|
+
signal?: AbortSignal;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* One request, with the failure modes already sorted into something actionable.
|
|
40
|
+
*
|
|
41
|
+
* Everything that reaches the network in this package goes through here, so the
|
|
42
|
+
* `X-Veilio-Client` header, the timeout and the error mapping are decided once
|
|
43
|
+
* rather than per call site.
|
|
44
|
+
*/
|
|
45
|
+
export declare function request<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
46
|
+
/** A map as the list endpoint describes it. */
|
|
47
|
+
export interface CloudMapSummary {
|
|
48
|
+
id: string;
|
|
49
|
+
name: string;
|
|
50
|
+
scope: 'personal' | 'team';
|
|
51
|
+
identifier_count: number | null;
|
|
52
|
+
updated_at: string;
|
|
53
|
+
/** `client-envelope` means WE decrypt it; anything else the server already did. */
|
|
54
|
+
storage: string;
|
|
55
|
+
}
|
|
56
|
+
export interface CloudMapList {
|
|
57
|
+
personalMaps: CloudMapSummary[];
|
|
58
|
+
teamMaps: CloudMapSummary[];
|
|
59
|
+
/** Placeholder -> identifier, merged across the team's maps. Null when the
|
|
60
|
+
* account has no active team or the plan lacks shared dictionaries — the
|
|
61
|
+
* server's entitlement answer, not a client-side guess (spec 005 US4). */
|
|
62
|
+
teamNamespace: Record<string, string> | null;
|
|
63
|
+
plan: string;
|
|
64
|
+
}
|
|
65
|
+
/** A single map. `map_data` is an opaque envelope string for a personal map. */
|
|
66
|
+
export interface CloudMap extends CloudMapSummary {
|
|
67
|
+
map_data: string | Record<string, string>;
|
|
68
|
+
}
|
|
69
|
+
/** The account's vault parameters. Never the passphrase, never the key. */
|
|
70
|
+
export type VaultInfo = {
|
|
71
|
+
initialized: false;
|
|
72
|
+
} | {
|
|
73
|
+
initialized: true;
|
|
74
|
+
salt: string;
|
|
75
|
+
verifier: string;
|
|
76
|
+
kdf?: {
|
|
77
|
+
name: string;
|
|
78
|
+
iterations: number;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
export declare function listMaps(credential: Credential): Promise<CloudMapList>;
|
|
82
|
+
export declare function getMap(credential: Credential, id: string): Promise<CloudMap>;
|
|
83
|
+
export declare function createMap(credential: Credential, body: {
|
|
84
|
+
name: string;
|
|
85
|
+
map_data: string;
|
|
86
|
+
identifier_count?: number;
|
|
87
|
+
scope?: 'personal';
|
|
88
|
+
}): Promise<{
|
|
89
|
+
id: string;
|
|
90
|
+
}>;
|
|
91
|
+
/**
|
|
92
|
+
* The vault parameters, so the key can be derived HERE.
|
|
93
|
+
*
|
|
94
|
+
* The salt and the KDF cost are all the server holds, and all it can hold: the
|
|
95
|
+
* passphrase never leaves this machine and the key is never transmitted. That is
|
|
96
|
+
* the zero-knowledge claim, and it is kept by there being no code anywhere that
|
|
97
|
+
* could send either.
|
|
98
|
+
*/
|
|
99
|
+
export declare function getVault(credential: Credential): Promise<VaultInfo>;
|
|
100
|
+
//# sourceMappingURL=cloud.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloud.d.ts","sourceRoot":"","sources":["../src/cloud.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,gFAAgF;AAChF,eAAO,MAAM,gBAAgB,2BAA2B,CAAA;AAExD,oEAAoE;AACpE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,GAAG,IAAI,CAAA;IAC5C,IAAI,EAAE,MAAM,CAAA;CACb;AAED,gFAAgF;AAChF,MAAM,WAAW,QAAS,SAAQ,eAAe;IAC/C,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC1C;AAED,2EAA2E;AAC3E,MAAM,MAAM,SAAS,GACjB;IAAE,WAAW,EAAE,KAAK,CAAA;CAAE,GACtB;IACE,WAAW,EAAE,IAAI,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,GAAG,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAA;CAC3C,CAAA;AAEL,wBAAgB,QAAQ,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,CAEtE;AAED,wBAAgB,MAAM,CAAC,UAAU,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAE5E;AAED,wBAAgB,SAAS,CACvB,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,UAAU,CAAA;CAAE,GACtF,OAAO,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,CAEzB;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CAEnE"}
|
package/dist/cloud.js
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
// The network boundary. The ONLY module in this package permitted to make a
|
|
2
|
+
// request.
|
|
3
|
+
//
|
|
4
|
+
// Every other file here is offline by construction, and that is a published
|
|
5
|
+
// claim rather than an implementation detail: the CLI makes the same privacy
|
|
6
|
+
// promise the web app does, and `veilio scrub` on a laptop with no account must
|
|
7
|
+
// touch nothing (FR-001, FR-002).
|
|
8
|
+
//
|
|
9
|
+
// A promise like that is kept by a boundary somebody can see, not by everyone
|
|
10
|
+
// remembering. So the rule is structural and it is enforced twice:
|
|
11
|
+
//
|
|
12
|
+
// - `offline.test.ts` walks the import graph from `commands.ts` and fails if
|
|
13
|
+
// this module is reachable from it, including down branches no test drives.
|
|
14
|
+
// - The same file asserts this is the only source in `src/` that names
|
|
15
|
+
// `fetch`, so moving the call somewhere else fails rather than passing.
|
|
16
|
+
//
|
|
17
|
+
// Which means: if you are adding a request, it goes here. If that feels
|
|
18
|
+
// awkward — because the thing you are writing is a local command that suddenly
|
|
19
|
+
// needs the network — the awkwardness is the design telling you something.
|
|
20
|
+
//
|
|
21
|
+
// NOTE (spec 005 Phase 3): this module deliberately has no callers yet. It is
|
|
22
|
+
// created ahead of the commands that use it so the boundary exists before
|
|
23
|
+
// anything crosses it, and so the tests that police it are written against
|
|
24
|
+
// something real. Phase 4 (`login`, `logout`, `whoami`) is what consumes it.
|
|
25
|
+
/** The public Cloud. `--instance` overrides it for a self-hosted deployment. */
|
|
26
|
+
export const DEFAULT_INSTANCE = 'https://app.veilio.dev';
|
|
27
|
+
/** How long any single request may take before we give up on it. */
|
|
28
|
+
export const REQUEST_TIMEOUT_MS = 15_000;
|
|
29
|
+
export class CloudError extends Error {
|
|
30
|
+
kind;
|
|
31
|
+
status;
|
|
32
|
+
constructor(kind, message, status) {
|
|
33
|
+
super(message);
|
|
34
|
+
this.kind = kind;
|
|
35
|
+
this.status = status;
|
|
36
|
+
this.name = 'CloudError';
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* One request, with the failure modes already sorted into something actionable.
|
|
41
|
+
*
|
|
42
|
+
* Everything that reaches the network in this package goes through here, so the
|
|
43
|
+
* `X-Veilio-Client` header, the timeout and the error mapping are decided once
|
|
44
|
+
* rather than per call site.
|
|
45
|
+
*/
|
|
46
|
+
export async function request(path, options = {}) {
|
|
47
|
+
// The credential's own instance wins, so a token issued by A can never be
|
|
48
|
+
// sent to B. But silently ignoring an explicit `--instance` would be a
|
|
49
|
+
// fallback nobody was told about (Constitution V), so a conflict is refused
|
|
50
|
+
// rather than quietly resolved.
|
|
51
|
+
if (options.credential &&
|
|
52
|
+
options.instance &&
|
|
53
|
+
trimSlashes(options.instance) !== trimSlashes(options.credential.instance)) {
|
|
54
|
+
throw new CloudError('unauthenticated', `signed in to ${options.credential.instance}; run \`veilio logout\` before using ${options.instance}`);
|
|
55
|
+
}
|
|
56
|
+
const base = trimSlashes(options.credential?.instance ?? options.instance ?? DEFAULT_INSTANCE);
|
|
57
|
+
const url = `${base}${path}`;
|
|
58
|
+
const headers = {
|
|
59
|
+
// What this session gets labelled in the user's sessions list. It is a
|
|
60
|
+
// self-report and the server treats it as one — it must never gate access,
|
|
61
|
+
// or a header anyone can set becomes an authorisation input.
|
|
62
|
+
'X-Veilio-Client': 'cli',
|
|
63
|
+
Accept: 'application/json',
|
|
64
|
+
};
|
|
65
|
+
if (options.credential)
|
|
66
|
+
headers.Authorization = `Bearer ${options.credential.token}`;
|
|
67
|
+
if (options.body !== undefined)
|
|
68
|
+
headers['Content-Type'] = 'application/json';
|
|
69
|
+
// A hung instance must not hang the terminal.
|
|
70
|
+
//
|
|
71
|
+
// `AbortSignal.any` rather than a hand-rolled controller, for two reasons the
|
|
72
|
+
// manual version got wrong. It honours a signal that is ALREADY aborted — a
|
|
73
|
+
// listener added after the fact never fires, so a cancelled command still put
|
|
74
|
+
// its request on the wire with the bearer token attached. And it drops its
|
|
75
|
+
// own listeners when collected, where the manual `addEventListener` retained
|
|
76
|
+
// one closure per request on a shared signal.
|
|
77
|
+
const deadline = AbortSignal.timeout(REQUEST_TIMEOUT_MS);
|
|
78
|
+
const signal = options.signal ? AbortSignal.any([options.signal, deadline]) : deadline;
|
|
79
|
+
let response;
|
|
80
|
+
try {
|
|
81
|
+
response = await fetch(url, {
|
|
82
|
+
method: options.method ?? 'GET',
|
|
83
|
+
headers,
|
|
84
|
+
body: options.body === undefined ? undefined : JSON.stringify(options.body),
|
|
85
|
+
signal,
|
|
86
|
+
// An API client has no reason to follow a redirect, and following one is
|
|
87
|
+
// how a bearer token ends up somewhere it was never issued for.
|
|
88
|
+
redirect: 'error',
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
// DNS failure, refused connection, TLS problem, timeout. None of them says
|
|
93
|
+
// anything about the account, and reporting them as an auth problem would
|
|
94
|
+
// send someone to re-enter a password that was never the issue.
|
|
95
|
+
throw new CloudError('unreachable', `could not reach ${base}: ${err instanceof Error ? err.message : String(err)}`);
|
|
96
|
+
}
|
|
97
|
+
// The deadline is deliberately still armed. `fetch` resolves as soon as the
|
|
98
|
+
// HEADERS arrive, so a server that answers `200 OK` and then stalls mid-body
|
|
99
|
+
// would hang the terminal for ever under a timer cleared at the line above —
|
|
100
|
+
// which is exactly what "must not hang the terminal" used to promise and not
|
|
101
|
+
// do. Every body read below is tied to the same signal, so a stalled stream
|
|
102
|
+
// aborts with it.
|
|
103
|
+
if (response.status === 401) {
|
|
104
|
+
throw new CloudError('unauthenticated', 'not signed in, or the session was revoked — run `veilio login`', 401);
|
|
105
|
+
}
|
|
106
|
+
if (response.status === 402 || response.status === 403) {
|
|
107
|
+
// The status alone is not the answer, and treating it as one gets the remedy
|
|
108
|
+
// wrong on exactly the routes this will call. The server answers 403 for a
|
|
109
|
+
// SUSPENDED account (a RODO rights-only state), for a team-role refusal, and
|
|
110
|
+
// for a map belonging to somebody else — while the actual paywall is 402.
|
|
111
|
+
// Rendering all of those as "your plan does not include that" tells a
|
|
112
|
+
// suspended user to go and buy something.
|
|
113
|
+
const body = await bodyOf(response);
|
|
114
|
+
const message = typeof body.error === 'string' && body.error !== '' ? body.error : null;
|
|
115
|
+
if (body.suspended === true) {
|
|
116
|
+
throw new CloudError('suspended', message ?? 'this account is suspended', response.status);
|
|
117
|
+
}
|
|
118
|
+
if (response.status === 402 || body.paywall === true || body.upgrade === true) {
|
|
119
|
+
throw new CloudError('unentitled', message ?? 'this account’s plan does not include that', response.status);
|
|
120
|
+
}
|
|
121
|
+
throw new CloudError('forbidden', message ?? 'not permitted on this account', 403);
|
|
122
|
+
}
|
|
123
|
+
if (!response.ok) {
|
|
124
|
+
const body = await bodyOf(response);
|
|
125
|
+
throw new CloudError('server', typeof body.error === 'string' && body.error !== ''
|
|
126
|
+
? body.error
|
|
127
|
+
: `${base} returned ${response.status}`, response.status);
|
|
128
|
+
}
|
|
129
|
+
// A 204 or an empty body is a legitimate answer — `POST /api/auth/logout` is
|
|
130
|
+
// the obvious one — and `response.json()` throws a bare SyntaxError on it,
|
|
131
|
+
// which escapes every `catch (e) { if (e instanceof CloudError) }` a caller
|
|
132
|
+
// writes and surfaces as a stack trace instead of a message.
|
|
133
|
+
if (response.status === 204)
|
|
134
|
+
return undefined;
|
|
135
|
+
const text = await response.text();
|
|
136
|
+
if (text === '')
|
|
137
|
+
return undefined;
|
|
138
|
+
try {
|
|
139
|
+
return JSON.parse(text);
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
throw new CloudError('server', `${base} answered ${response.status} with something that was not JSON`, response.status);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
export function listMaps(credential) {
|
|
146
|
+
return request('/api/maps', { credential });
|
|
147
|
+
}
|
|
148
|
+
export function getMap(credential, id) {
|
|
149
|
+
return request(`/api/maps/${encodeURIComponent(id)}`, { credential });
|
|
150
|
+
}
|
|
151
|
+
export function createMap(credential, body) {
|
|
152
|
+
return request('/api/maps', { credential, method: 'POST', body });
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* The vault parameters, so the key can be derived HERE.
|
|
156
|
+
*
|
|
157
|
+
* The salt and the KDF cost are all the server holds, and all it can hold: the
|
|
158
|
+
* passphrase never leaves this machine and the key is never transmitted. That is
|
|
159
|
+
* the zero-knowledge claim, and it is kept by there being no code anywhere that
|
|
160
|
+
* could send either.
|
|
161
|
+
*/
|
|
162
|
+
export function getVault(credential) {
|
|
163
|
+
return request('/api/auth/vault', { credential });
|
|
164
|
+
}
|
|
165
|
+
function trimSlashes(url) {
|
|
166
|
+
return url.replace(/\/+$/, '');
|
|
167
|
+
}
|
|
168
|
+
/** A failure response's body, or an empty object when it had none we can read. */
|
|
169
|
+
async function bodyOf(response) {
|
|
170
|
+
try {
|
|
171
|
+
const parsed = await response.json();
|
|
172
|
+
return typeof parsed === 'object' && parsed !== null ? parsed : {};
|
|
173
|
+
}
|
|
174
|
+
catch {
|
|
175
|
+
return {};
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=cloud.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloud.js","sourceRoot":"","sources":["../src/cloud.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,WAAW;AACX,EAAE;AACF,4EAA4E;AAC5E,6EAA6E;AAC7E,gFAAgF;AAChF,kCAAkC;AAClC,EAAE;AACF,8EAA8E;AAC9E,mEAAmE;AACnE,EAAE;AACF,+EAA+E;AAC/E,gFAAgF;AAChF,yEAAyE;AACzE,4EAA4E;AAC5E,EAAE;AACF,wEAAwE;AACxE,+EAA+E;AAC/E,2EAA2E;AAC3E,EAAE;AACF,8EAA8E;AAC9E,0EAA0E;AAC1E,2EAA2E;AAC3E,6EAA6E;AAI7E,gFAAgF;AAChF,MAAM,CAAC,MAAM,gBAAgB,GAAG,wBAAwB,CAAA;AAExD,oEAAoE;AACpE,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAA;AAsBxC,MAAM,OAAO,UAAW,SAAQ,KAAK;IAExB;IAEA;IAHX,YACW,IAAoB,EAC7B,OAAe,EACN,MAAe;QAExB,KAAK,CAAC,OAAO,CAAC,CAAA;QAJL,SAAI,GAAJ,IAAI,CAAgB;QAEpB,WAAM,GAAN,MAAM,CAAS;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I,CAAC,CAAC,CAAE,MAAkC,CAAC,CAAC,CAAC,EAAE,CAAA;IACjG,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAA;IACX,CAAC;AACH,CAAC"}
|
package/dist/commands.d.ts
CHANGED
|
@@ -4,6 +4,19 @@ export interface Io {
|
|
|
4
4
|
stdin: () => Promise<string>;
|
|
5
5
|
stdout: (text: string) => void;
|
|
6
6
|
stderr: (text: string) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Home directory the credential lives under. Optional, and every field below
|
|
9
|
+
* is optional for the same reason: the local commands in this file must
|
|
10
|
+
* remain constructible without any of it. A required field here would mean a
|
|
11
|
+
* caller who only wants `scrub` has to supply a way to read a password.
|
|
12
|
+
*
|
|
13
|
+
* Undefined means "the real one" — `credential.ts` defaults to `homedir()`.
|
|
14
|
+
*/
|
|
15
|
+
home?: string;
|
|
16
|
+
/** Read a line from the terminal. Only the cloud commands use it. */
|
|
17
|
+
prompt?: (label: string) => Promise<string>;
|
|
18
|
+
/** Read a line without echoing it. Only the cloud commands use it. */
|
|
19
|
+
password?: (label: string) => Promise<string>;
|
|
7
20
|
}
|
|
8
21
|
/** Exit codes are the contract for CI and pre-commit hooks:
|
|
9
22
|
* 0 clean, 1 findings that should stop the pipeline, 2 usage/IO failure. */
|
|
@@ -15,5 +28,5 @@ export declare function runRestore(args: ParsedArgs, io: Io): Promise<number>;
|
|
|
15
28
|
/** Detect-only pass for pre-commit hooks and CI. Never rewrites anything. */
|
|
16
29
|
export declare function runScan(args: ParsedArgs, io: Io): Promise<number>;
|
|
17
30
|
export declare function runMap(args: ParsedArgs, io: Io): Promise<number>;
|
|
18
|
-
export declare const HELP = "veilio \u2014 anonymize code before it reaches an LLM, restore it after.\n\nUSAGE\n veilio <command> [files...] [options]\n\nCOMMANDS\n scrub [files...] Mask identifiers and redact credentials. Reads stdin when\n no file is given. Writes the symbol map to .veilio/map.json.\n restore [files...] Swap placeholders back and strip AI-generated noise.\n scan [files...] Detect credentials only; never rewrites. Exits 1 when it\n finds something \u2014 use it in a pre-commit hook or CI.\n map Show the current symbol map (--clear to wipe it).\n\nOPTIONS\n -l, --language <lang> auto (default), typescript, python, go, java, csharp,\n rust, ruby, php, c, sql\n -s, --secrets <policy> redact (default) | warn | off\n -p, --preamble Prepend the downstream-AI note and placeholder legend\n -m, --map <path> Use a specific map file\n --json Machine-readable output (scan, map)\n --strict scan: also fail on advisory findings\n --keep-docs restore: keep JSDoc blocks the model wrote\n -f, --force Allow a map write that would drop existing entries\n -q, --quiet Suppress the all-clear summary (findings always show)\n -h, --help Show this help\n -v, --version Show the version\n\nEXIT CODES\n 0 clean 1 findings that should stop the pipeline 2 usage or IO error\n\nEXAMPLES\n veilio scrub src/billing.ts | pbcopy\n pbpaste | veilio restore\n git diff --cached | veilio scan # pre-commit gate\n veilio scan 'src/**/*.ts' --json > findings.json\n\nTransformed code goes to stdout; everything else goes to stderr, so the CLI\ncomposes in a pipe.\n";
|
|
31
|
+
export declare const HELP = "veilio \u2014 anonymize code before it reaches an LLM, restore it after.\n\nUSAGE\n veilio <command> [files...] [options]\n\nCOMMANDS\n scrub [files...] Mask identifiers and redact credentials. Reads stdin when\n no file is given. Writes the symbol map to .veilio/map.json.\n restore [files...] Swap placeholders back and strip AI-generated noise.\n scan [files...] Detect credentials only; never rewrites. Exits 1 when it\n finds something \u2014 use it in a pre-commit hook or CI.\n map Show the current symbol map (--clear to wipe it).\n\n Everything above works offline, with no account. The three below connect a\n Veilio Cloud subscription and are the only commands that touch the network.\n\n login Sign in to Veilio Cloud (--instance for self-hosted).\n logout Revoke the session and forget the credential.\n whoami Show the signed-in account. Answers from disk; makes no\n request, so it works with the instance down.\n maps list List the maps this account holds in Cloud.\n maps pull <id> Fetch one into the local store. A personal map is\n decrypted here \u2014 the passphrase never leaves the machine.\n maps push [name] Encrypt the local map and upload it.\n\nOPTIONS\n -l, --language <lang> auto (default), typescript, python, go, java, csharp,\n rust, ruby, php, c, sql\n -s, --secrets <policy> redact (default) | warn | off\n -p, --preamble Prepend the downstream-AI note and placeholder legend\n -m, --map <path> Use a specific map file\n --json Machine-readable output (scan, map)\n --strict scan: also fail on advisory findings\n --keep-docs restore: keep JSDoc blocks the model wrote\n -f, --force Allow a map write that would drop existing entries\n -q, --quiet Suppress the all-clear summary (findings always show)\n --instance <url> login: the Veilio instance to sign in to. Defaults to\n the public Cloud; https required (localhost excepted)\n -h, --help Show this help\n -v, --version Show the version\n\nEXIT CODES\n 0 clean 1 findings that should stop the pipeline 2 usage or IO error\n\nEXAMPLES\n veilio scrub src/billing.ts | pbcopy\n pbpaste | veilio restore\n git diff --cached | veilio scan # pre-commit gate\n veilio scan 'src/**/*.ts' --json > findings.json\n\nTransformed code goes to stdout; everything else goes to stderr, so the CLI\ncomposes in a pipe.\n";
|
|
19
32
|
//# sourceMappingURL=commands.d.ts.map
|
package/dist/commands.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAG3C,MAAM,WAAW,EAAE;IACjB,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAA;IAC5B,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAC9B,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAG3C,MAAM,WAAW,EAAE;IACjB,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAA;IAC5B,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAC9B,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAC9B;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,qEAAqE;IACrE,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;IAC3C,sEAAsE;IACtE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;CAC9C;AAED;6EAC6E;AAC7E,eAAO,MAAM,OAAO,IAAI,CAAA;AACxB,eAAO,MAAM,aAAa,IAAI,CAAA;AAC9B,eAAO,MAAM,UAAU,IAAI,CAAA;AAsB3B,wBAAsB,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAyDxE;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAsD1E;AAED,6EAA6E;AAC7E,wBAAsB,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAiCvE;AAED,wBAAsB,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAsBtE;AAED,eAAO,MAAM,IAAI,moFAoDhB,CAAA"}
|
package/dist/commands.js
CHANGED
|
@@ -187,6 +187,18 @@ COMMANDS
|
|
|
187
187
|
finds something — use it in a pre-commit hook or CI.
|
|
188
188
|
map Show the current symbol map (--clear to wipe it).
|
|
189
189
|
|
|
190
|
+
Everything above works offline, with no account. The three below connect a
|
|
191
|
+
Veilio Cloud subscription and are the only commands that touch the network.
|
|
192
|
+
|
|
193
|
+
login Sign in to Veilio Cloud (--instance for self-hosted).
|
|
194
|
+
logout Revoke the session and forget the credential.
|
|
195
|
+
whoami Show the signed-in account. Answers from disk; makes no
|
|
196
|
+
request, so it works with the instance down.
|
|
197
|
+
maps list List the maps this account holds in Cloud.
|
|
198
|
+
maps pull <id> Fetch one into the local store. A personal map is
|
|
199
|
+
decrypted here — the passphrase never leaves the machine.
|
|
200
|
+
maps push [name] Encrypt the local map and upload it.
|
|
201
|
+
|
|
190
202
|
OPTIONS
|
|
191
203
|
-l, --language <lang> auto (default), typescript, python, go, java, csharp,
|
|
192
204
|
rust, ruby, php, c, sql
|
|
@@ -198,6 +210,8 @@ OPTIONS
|
|
|
198
210
|
--keep-docs restore: keep JSDoc blocks the model wrote
|
|
199
211
|
-f, --force Allow a map write that would drop existing entries
|
|
200
212
|
-q, --quiet Suppress the all-clear summary (findings always show)
|
|
213
|
+
--instance <url> login: the Veilio instance to sign in to. Defaults to
|
|
214
|
+
the public Cloud; https required (localhost excepted)
|
|
201
215
|
-h, --help Show this help
|
|
202
216
|
-v, --version Show the version
|
|
203
217
|
|
package/dist/commands.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,EAAE;AACF,kCAAkC;AAClC,iFAAiF;AACjF,2DAA2D;AAC3D,iFAAiF;AACjF,6BAA6B;AAE7B,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EACL,SAAS,EACT,aAAa,EACb,kBAAkB,EAClB,OAAO,EACP,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACR,SAAS,GAEV,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../src/commands.ts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AAQ;cACE,QAAQ;wBACE,QAAQ;IAC5B,QAAQ;;;;CAIX,CAAA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export declare const CREDENTIAL_FILE = "credential.json";
|
|
2
|
+
export interface Credential {
|
|
3
|
+
/** The session bearer token, exactly as issued. */
|
|
4
|
+
token: string;
|
|
5
|
+
/** The email it belongs to, so `whoami` need not make a request. */
|
|
6
|
+
account: string;
|
|
7
|
+
/** Base URL it was issued by, so a self-hosted instance is addressable. */
|
|
8
|
+
instance: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Where the credential lives.
|
|
12
|
+
*
|
|
13
|
+
* Under the user's home directory, not the project store: a token authorises a
|
|
14
|
+
* person, not a repository, and putting it beside `.veilio/map.json` would drop
|
|
15
|
+
* it into whatever directory the CLI happened to run in — including, eventually,
|
|
16
|
+
* one somebody commits.
|
|
17
|
+
*
|
|
18
|
+
* `home` is injectable so tests do not write to the real one.
|
|
19
|
+
*/
|
|
20
|
+
export declare function credentialPath(home?: string): string;
|
|
21
|
+
/** https, or a loopback address for local development. Nothing else. */
|
|
22
|
+
export declare function isSafeInstance(value: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* The stored credential, or null.
|
|
25
|
+
*
|
|
26
|
+
* Null means "not signed in", and it means that for every reason a read can
|
|
27
|
+
* fail. Callers get one case to handle, and no caller has to decide whether a
|
|
28
|
+
* particular kind of breakage is worth reporting — none of them is.
|
|
29
|
+
*/
|
|
30
|
+
export declare function readCredential(home?: string): Credential | null;
|
|
31
|
+
/**
|
|
32
|
+
* Write the credential, 0600.
|
|
33
|
+
*
|
|
34
|
+
* Called only after the server has accepted a sign-in — validate, then persist
|
|
35
|
+
* (Constitution IV). A file written before the check leaves a credential behind
|
|
36
|
+
* for an attempt that failed.
|
|
37
|
+
*
|
|
38
|
+
* `chmodSync` after the write because `mode` on `writeFileSync` applies only
|
|
39
|
+
* when the file is created; without it, re-signing in over a world-readable file
|
|
40
|
+
* left from some earlier mistake would leave it world-readable.
|
|
41
|
+
*/
|
|
42
|
+
export declare function writeCredential(credential: Credential, home?: string): void;
|
|
43
|
+
/**
|
|
44
|
+
* Remove the credential. Returns whether there was one to remove.
|
|
45
|
+
*
|
|
46
|
+
* Never throws, for the same reason reads do not: `logout` on a machine that was
|
|
47
|
+
* never signed in should say so and exit cleanly, not fail. Note the ordering
|
|
48
|
+
* this does NOT own — `logout` revokes server-side FIRST and only then calls
|
|
49
|
+
* this, because deleting first leaves a live session the user believes is gone.
|
|
50
|
+
*/
|
|
51
|
+
export declare function removeCredential(home?: string): boolean;
|
|
52
|
+
//# sourceMappingURL=credential.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential.d.ts","sourceRoot":"","sources":["../src/credential.ts"],"names":[],"mappings":"AAwBA,eAAO,MAAM,eAAe,oBAAoB,CAAA;AAEhD,MAAM,WAAW,UAAU;IACzB,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAA;IACb,oEAAoE;IACpE,OAAO,EAAE,MAAM,CAAA;IACf,2EAA2E;IAC3E,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,IAAI,GAAE,MAAkB,GAAG,MAAM,CAE/D;AAED,wEAAwE;AACxE,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CASrD;AAqBD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,IAAI,GAAE,MAAkB,GAAG,UAAU,GAAG,IAAI,CAc1E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,GAAE,MAAkB,GAAG,IAAI,CAKtF;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,GAAE,MAAkB,GAAG,OAAO,CAiBlE"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// The signed-in credential, on disk.
|
|
2
|
+
//
|
|
3
|
+
// One file per machine per instance, holding the session token the server
|
|
4
|
+
// issued, the account it belongs to, and the instance that issued it. It is
|
|
5
|
+
// never transmitted and never sent anywhere — `whoami` answers from it, which is
|
|
6
|
+
// why it carries the account and the instance rather than the token alone.
|
|
7
|
+
//
|
|
8
|
+
// EVERY read tolerates absence and corruption, and that is the whole design.
|
|
9
|
+
// This file sits underneath commands that must work for someone who has never
|
|
10
|
+
// heard of the Cloud edition (FR-001, FR-003). A reader that throws on a
|
|
11
|
+
// truncated file turns a half-written credential into a broken `veilio scrub`,
|
|
12
|
+
// and the person it breaks for is the one who never signed in.
|
|
13
|
+
//
|
|
14
|
+
// So there is exactly one failure mode here: "not signed in". Missing file,
|
|
15
|
+
// unreadable file, a directory where the file should be, invalid JSON, JSON of
|
|
16
|
+
// the wrong shape, an empty token — all of it reads as signed out, because every
|
|
17
|
+
// one of them means the same thing to the caller and none of them is worth
|
|
18
|
+
// stopping a local command over.
|
|
19
|
+
import { chmodSync, mkdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
20
|
+
import { dirname, join } from 'node:path';
|
|
21
|
+
import { homedir } from 'node:os';
|
|
22
|
+
import { STORE_DIR } from '@veilio-inc/engine';
|
|
23
|
+
export const CREDENTIAL_FILE = 'credential.json';
|
|
24
|
+
/**
|
|
25
|
+
* Where the credential lives.
|
|
26
|
+
*
|
|
27
|
+
* Under the user's home directory, not the project store: a token authorises a
|
|
28
|
+
* person, not a repository, and putting it beside `.veilio/map.json` would drop
|
|
29
|
+
* it into whatever directory the CLI happened to run in — including, eventually,
|
|
30
|
+
* one somebody commits.
|
|
31
|
+
*
|
|
32
|
+
* `home` is injectable so tests do not write to the real one.
|
|
33
|
+
*/
|
|
34
|
+
export function credentialPath(home = homedir()) {
|
|
35
|
+
return join(home, STORE_DIR, CREDENTIAL_FILE);
|
|
36
|
+
}
|
|
37
|
+
/** https, or a loopback address for local development. Nothing else. */
|
|
38
|
+
export function isSafeInstance(value) {
|
|
39
|
+
let url;
|
|
40
|
+
try {
|
|
41
|
+
url = new URL(value);
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
if (url.protocol === 'https:')
|
|
47
|
+
return true;
|
|
48
|
+
return url.hostname === 'localhost' || url.hostname === '127.0.0.1' || url.hostname === '[::1]';
|
|
49
|
+
}
|
|
50
|
+
function isCredential(value) {
|
|
51
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
52
|
+
return false;
|
|
53
|
+
const c = value;
|
|
54
|
+
return (typeof c.token === 'string' &&
|
|
55
|
+
c.token !== '' &&
|
|
56
|
+
typeof c.account === 'string' &&
|
|
57
|
+
c.account !== '' &&
|
|
58
|
+
typeof c.instance === 'string' &&
|
|
59
|
+
c.instance !== '' &&
|
|
60
|
+
// A credential naming an `http://` instance would put the bearer token on
|
|
61
|
+
// the wire in the clear, on every request, for ever — and self-hosted LAN
|
|
62
|
+
// setups are exactly where somebody writes one by hand. Refusing to read it
|
|
63
|
+
// reads as "not signed in", which is the safe direction and the one the
|
|
64
|
+
// rest of this module already takes.
|
|
65
|
+
isSafeInstance(c.instance));
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The stored credential, or null.
|
|
69
|
+
*
|
|
70
|
+
* Null means "not signed in", and it means that for every reason a read can
|
|
71
|
+
* fail. Callers get one case to handle, and no caller has to decide whether a
|
|
72
|
+
* particular kind of breakage is worth reporting — none of them is.
|
|
73
|
+
*/
|
|
74
|
+
export function readCredential(home = homedir()) {
|
|
75
|
+
let raw;
|
|
76
|
+
try {
|
|
77
|
+
raw = readFileSync(credentialPath(home), 'utf8');
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
let parsed;
|
|
83
|
+
try {
|
|
84
|
+
parsed = JSON.parse(raw);
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
return isCredential(parsed) ? parsed : null;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Write the credential, 0600.
|
|
93
|
+
*
|
|
94
|
+
* Called only after the server has accepted a sign-in — validate, then persist
|
|
95
|
+
* (Constitution IV). A file written before the check leaves a credential behind
|
|
96
|
+
* for an attempt that failed.
|
|
97
|
+
*
|
|
98
|
+
* `chmodSync` after the write because `mode` on `writeFileSync` applies only
|
|
99
|
+
* when the file is created; without it, re-signing in over a world-readable file
|
|
100
|
+
* left from some earlier mistake would leave it world-readable.
|
|
101
|
+
*/
|
|
102
|
+
export function writeCredential(credential, home = homedir()) {
|
|
103
|
+
const path = credentialPath(home);
|
|
104
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
105
|
+
writeFileSync(path, `${JSON.stringify(credential, null, 2)}\n`, { mode: 0o600 });
|
|
106
|
+
chmodSync(path, 0o600);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Remove the credential. Returns whether there was one to remove.
|
|
110
|
+
*
|
|
111
|
+
* Never throws, for the same reason reads do not: `logout` on a machine that was
|
|
112
|
+
* never signed in should say so and exit cleanly, not fail. Note the ordering
|
|
113
|
+
* this does NOT own — `logout` revokes server-side FIRST and only then calls
|
|
114
|
+
* this, because deleting first leaves a live session the user believes is gone.
|
|
115
|
+
*/
|
|
116
|
+
export function removeCredential(home = homedir()) {
|
|
117
|
+
const path = credentialPath(home);
|
|
118
|
+
try {
|
|
119
|
+
statSync(path);
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
// Genuinely not signed in. Nothing to do, and not an error.
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
// A failure to DELETE is a different thing entirely, and it throws.
|
|
126
|
+
//
|
|
127
|
+
// Returning false for both meant `logout` would print "you weren't signed in"
|
|
128
|
+
// while a live bearer token sat on disk — an unsearchable parent directory, a
|
|
129
|
+
// read-only mount, a file held open on Windows. That inverts FR-005 and
|
|
130
|
+
// contradicts the whole reason this function is called before the file is
|
|
131
|
+
// considered gone. The caller catches and reports the path.
|
|
132
|
+
rmSync(path, { recursive: true, force: true });
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=credential.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential.js","sourceRoot":"","sources":["../src/credential.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,EAAE;AACF,0EAA0E;AAC1E,4EAA4E;AAC5E,iFAAiF;AACjF,2EAA2E;AAC3E,EAAE;AACF,6EAA6E;AAC7E,8EAA8E;AAC9E,yEAAyE;AACzE,+EAA+E;AAC/E,+DAA+D;AAC/D,EAAE;AACF,4EAA4E;AAC5E,+EAA+E;AAC/E,iFAAiF;AACjF,2EAA2E;AAC3E,iCAAiC;AAEjC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC7F,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAE9C,MAAM,CAAC,MAAM,eAAe,GAAG,iBAAiB,CAAA;AAWhD;;;;;;;;;GASG;AACH,MAAM,UAAU,cAAc,CAAC,OAAe,OAAO,EAAE;IACrD,OAAO,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,eAAe,CAAC,CAAA;AAC/C,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,IAAI,GAAQ,CAAA;IACZ,IAAI,CAAC;QACH,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAA;IACtB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;IACD,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ;QAAE,OAA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