@bluestep-systems/b6p-core 1.1.0 → 1.3.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 +199 -55
- package/dist/B6PCore.d.ts +22 -0
- package/dist/B6PCore.js +60 -8
- package/dist/B6PCore.js.map +1 -1
- package/dist/Err.d.ts +40 -0
- package/dist/Err.js +58 -0
- package/dist/Err.js.map +1 -1
- package/dist/cache/GitCredentialHosts.d.ts +46 -0
- package/dist/cache/GitCredentialHosts.js +90 -0
- package/dist/cache/GitCredentialHosts.js.map +1 -0
- package/dist/cache/GitCredentialResets.d.ts +89 -0
- package/dist/cache/GitCredentialResets.js +119 -0
- package/dist/cache/GitCredentialResets.js.map +1 -0
- package/dist/constants/Gateway.d.ts +1 -0
- package/dist/constants/Gateway.js +1 -0
- package/dist/constants/Gateway.js.map +1 -1
- package/dist/constants/GitCredential.d.ts +19 -0
- package/dist/constants/GitCredential.js +24 -0
- package/dist/constants/GitCredential.js.map +1 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.js +3 -1
- package/dist/constants/index.js.map +1 -1
- package/dist/gateway/GatewayClient.d.ts +32 -0
- package/dist/gateway/GatewayClient.js +21 -2
- package/dist/gateway/GatewayClient.js.map +1 -1
- package/dist/gateway/GatewayKb.d.ts +56 -1
- package/dist/gateway/GatewayKb.js +205 -0
- package/dist/gateway/GatewayKb.js.map +1 -1
- package/dist/gitCredential/GitConfigRunner.d.ts +97 -0
- package/dist/gitCredential/GitConfigRunner.js +244 -0
- package/dist/gitCredential/GitConfigRunner.js.map +1 -0
- package/dist/gitCredential/GitCredentialContext.d.ts +39 -0
- package/dist/gitCredential/GitCredentialContext.js +3 -0
- package/dist/gitCredential/GitCredentialContext.js.map +1 -0
- package/dist/gitCredential/GitCredentialService.d.ts +390 -0
- package/dist/gitCredential/GitCredentialService.js +594 -0
- package/dist/gitCredential/GitCredentialService.js.map +1 -0
- package/dist/gitCredential/configFile.d.ts +71 -0
- package/dist/gitCredential/configFile.js +289 -0
- package/dist/gitCredential/configFile.js.map +1 -0
- package/dist/gitCredential/credentialConfig.d.ts +146 -0
- package/dist/gitCredential/credentialConfig.js +523 -0
- package/dist/gitCredential/credentialConfig.js.map +1 -0
- package/dist/gitCredential/hosts.d.ts +17 -0
- package/dist/gitCredential/hosts.js +44 -0
- package/dist/gitCredential/hosts.js.map +1 -0
- package/dist/index.d.ts +16 -3
- package/dist/index.js +34 -2
- package/dist/index.js.map +1 -1
- package/dist/persistence/PersistenceKeys.d.ts +12 -1
- package/dist/persistence/PersistenceKeys.js +11 -0
- package/dist/persistence/PersistenceKeys.js.map +1 -1
- package/dist/persistence/SharedFilePersistence.d.ts +30 -11
- package/dist/persistence/SharedFilePersistence.js +66 -13
- package/dist/persistence/SharedFilePersistence.js.map +1 -1
- package/dist/persistence/exitCleanup.d.ts +37 -0
- package/dist/persistence/exitCleanup.js +142 -0
- package/dist/persistence/exitCleanup.js.map +1 -0
- package/dist/persistence/fileLock.d.ts +57 -0
- package/dist/persistence/fileLock.js +252 -0
- package/dist/persistence/fileLock.js.map +1 -0
- package/dist/persistence/lockedMutation.d.ts +26 -0
- package/dist/persistence/lockedMutation.js +45 -0
- package/dist/persistence/lockedMutation.js.map +1 -0
- package/dist/providers.d.ts +15 -0
- package/dist/script/ScriptContext.d.ts +7 -0
- package/dist/script/ScriptService.d.ts +6 -0
- package/dist/script/ScriptService.js +14 -0
- package/dist/script/ScriptService.js.map +1 -1
- package/dist/testing/FakeGateway.d.ts +24 -0
- package/dist/testing/FakeGateway.js +176 -0
- package/dist/testing/FakeGateway.js.map +1 -1
- package/dist/types.d.ts +95 -0
- package/package.json +2 -2
|
@@ -0,0 +1,594 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.GitCredentialService = exports.GIT_SETUP_FLOOR = exports.GIT_MATCHING_FLOOR = void 0;
|
|
37
|
+
exports.parseGitVersion = parseGitVersion;
|
|
38
|
+
exports.parseCredentialRequest = parseCredentialRequest;
|
|
39
|
+
const path = __importStar(require("node:path"));
|
|
40
|
+
const GitCredential_1 = require("../constants/GitCredential");
|
|
41
|
+
const Err_1 = require("../Err");
|
|
42
|
+
const GatewayClient_1 = require("../gateway/GatewayClient");
|
|
43
|
+
const GatewayToken_1 = require("../gateway/GatewayToken");
|
|
44
|
+
const configFile_1 = require("./configFile");
|
|
45
|
+
const credentialConfig_1 = require("./credentialConfig");
|
|
46
|
+
const hosts_1 = require("./hosts");
|
|
47
|
+
/**
|
|
48
|
+
* The oldest git whose credential contexts {@link credentialContextMatch} follows: the partial-URL
|
|
49
|
+
* fallback (credential.c `match_partial_url`) arrived in git 2.27.0 and is unchanged through 2.53.
|
|
50
|
+
* Status, setup and removal refuse an older git.
|
|
51
|
+
* @lastreviewed null
|
|
52
|
+
*/
|
|
53
|
+
exports.GIT_MATCHING_FLOOR = "2.27.0";
|
|
54
|
+
/**
|
|
55
|
+
* The oldest git that reports the file `git config --global` writes (`git var GIT_CONFIG_GLOBAL`),
|
|
56
|
+
* which setup needs.
|
|
57
|
+
* @lastreviewed null
|
|
58
|
+
*/
|
|
59
|
+
exports.GIT_SETUP_FLOOR = "2.42.0";
|
|
60
|
+
/**
|
|
61
|
+
* The `major.minor.patch` of `git --version` output (`git version 2.45.1.windows.1`,
|
|
62
|
+
* `git version 2.39.3 (Apple Git-146)`), or `null`.
|
|
63
|
+
* @lastreviewed null
|
|
64
|
+
*/
|
|
65
|
+
function parseGitVersion(output) {
|
|
66
|
+
const match = /git version (\d+)\.(\d+)(?:\.(\d+))?/.exec(output);
|
|
67
|
+
return match ? [Number(match[1]), Number(match[2]), Number(match[3] ?? 0)] : null;
|
|
68
|
+
}
|
|
69
|
+
function atLeast(version, floor) {
|
|
70
|
+
const want = floor.split(".").map(Number);
|
|
71
|
+
for (let i = 0; i < 3; i++) {
|
|
72
|
+
if (version[i] !== want[i]) {
|
|
73
|
+
return version[i] > want[i];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
function checkedHelper(helper) {
|
|
79
|
+
const command = helper ?? GitCredential_1.GitCredential.DEFAULT_HELPER;
|
|
80
|
+
if (command.trim() === "" || /[\r\n\0]/.test(command)) {
|
|
81
|
+
throw new Err_1.Err.GitCredentialSetupError("The helper command is empty or spans more than one line.", null);
|
|
82
|
+
}
|
|
83
|
+
return command;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The `key=value` attributes of one credential request as git writes them (git-credential(1),
|
|
87
|
+
* "INPUT/OUTPUT FORMAT"): one per line, up to a blank line or the end. A repeated key keeps its
|
|
88
|
+
* last value; the `key[]=` multi-valued ones are not needed here and are skipped.
|
|
89
|
+
* @lastreviewed null
|
|
90
|
+
*/
|
|
91
|
+
function parseCredentialRequest(input) {
|
|
92
|
+
const fields = new Map();
|
|
93
|
+
for (const raw of input.split("\n")) {
|
|
94
|
+
const line = raw.endsWith("\r") ? raw.slice(0, -1) : raw;
|
|
95
|
+
if (line === "") {
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
const eq = line.indexOf("=");
|
|
99
|
+
if (eq <= 0) {
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
const key = line.slice(0, eq);
|
|
103
|
+
if (key.endsWith("[]")) {
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
fields.set(key, line.slice(eq + 1));
|
|
107
|
+
}
|
|
108
|
+
return fields;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* b6p as git's credential helper: plain `git fetch`, `pull` and `push` in a knowledge-base clone
|
|
112
|
+
* (the gateway) or a script's draft (a tenant) use the stored `b6pt_` token without asking, the
|
|
113
|
+
* way `gh auth setup-git` does for github.com.
|
|
114
|
+
*
|
|
115
|
+
* It answers only for an allowlist ({@link allowedHosts}): the configured gateway's host when it is
|
|
116
|
+
* https, and the tenant hosts script pulls reached with the token. The match is exact on
|
|
117
|
+
* `host[:port]`, https only, and a request naming another user, or carrying a `url=` git never
|
|
118
|
+
* sends a helper, gets nothing. For anything else it
|
|
119
|
+
* answers nothing, so git asks its other helpers.
|
|
120
|
+
*
|
|
121
|
+
* The token goes only to stdout, as the answer to `get`: never into argv, a log line or a message.
|
|
122
|
+
* @lastreviewed null
|
|
123
|
+
*/
|
|
124
|
+
class GitCredentialService {
|
|
125
|
+
ctx;
|
|
126
|
+
constructor(ctx) {
|
|
127
|
+
this.ctx = ctx;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* The hosts answered for, the gateway first. An unusable gateway URL, or one that is not https
|
|
131
|
+
* (loopback http, used in development), contributes none.
|
|
132
|
+
* @lastreviewed null
|
|
133
|
+
*/
|
|
134
|
+
async allowedHosts() {
|
|
135
|
+
const allowed = [];
|
|
136
|
+
const gateway = await this.gatewayHost();
|
|
137
|
+
if (gateway !== null) {
|
|
138
|
+
allowed.push({ host: gateway, source: "gateway" });
|
|
139
|
+
}
|
|
140
|
+
for (const host of await this.ctx.hosts.hosts()) {
|
|
141
|
+
if (host !== gateway) {
|
|
142
|
+
allowed.push({ host, source: "script-pull" });
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return allowed;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Answer one credential-helper call: `action` is git's argument (`get`, `store` or `erase`) and
|
|
149
|
+
* `input` what git wrote on stdin. Returns what to write on stdout; the caller then exits 0.
|
|
150
|
+
* Never throws.
|
|
151
|
+
*
|
|
152
|
+
* - `get` answers `username` and `password` (the stored token) only for an https request to an
|
|
153
|
+
* allowed host, and nothing otherwise.
|
|
154
|
+
* - `store` does nothing: the token enters only through the consumer's own sign-in, so git has
|
|
155
|
+
* nothing to teach b6p.
|
|
156
|
+
* - `erase` does nothing either. git sends it after any refusal of the credential (a 401), and the
|
|
157
|
+
* stored token is the one credential every b6p operation shares: one tenant refusing it, or a
|
|
158
|
+
* moment's outage answered with a 401, would otherwise sign b6p out everywhere. A token that is
|
|
159
|
+
* really revoked is replaced through the consumer's sign-in, as before.
|
|
160
|
+
* - Any other action does nothing, as git expects of a helper.
|
|
161
|
+
* @lastreviewed null
|
|
162
|
+
*/
|
|
163
|
+
async answer(action, input) {
|
|
164
|
+
if (action !== "get") {
|
|
165
|
+
return "";
|
|
166
|
+
}
|
|
167
|
+
try {
|
|
168
|
+
return await this.get(parseCredentialRequest(input));
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
this.ctx.logger.warn("A git credential request could not be answered; git will ask elsewhere.");
|
|
172
|
+
return "";
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Every allowed host and whether b6p is the only helper git asks for it, with the other helpers
|
|
177
|
+
* and the entries responsible when it is not, plus the generic helpers. Read from the config in
|
|
178
|
+
* effect in `cwd` (default the process's directory): system, global (`~/.gitconfig`,
|
|
179
|
+
* `$XDG_CONFIG_HOME/git/config`), the command line and `GIT_CONFIG_COUNT`, and inside a
|
|
180
|
+
* repository its local and worktree config, with what they include. `scope` says which; no
|
|
181
|
+
* status covers another repository's own config ({@link GitCredentialStatusScope}).
|
|
182
|
+
*
|
|
183
|
+
* Entries match as git's credential contexts do ({@link credentialContextMatch}). Where an entry
|
|
184
|
+
* applies to only some requests (one scoped to a path, say), another helper counts as asked and a
|
|
185
|
+
* reset or b6p's own entry as not applying, and an `includeIf` after the last reset counts as a
|
|
186
|
+
* helper that may be asked, so a host is `configured` only when git certainly asks b6p alone.
|
|
187
|
+
* Changes nothing.
|
|
188
|
+
*
|
|
189
|
+
* @throws {Err.GitCredentialSetupError} when git is missing or older than {@link GIT_MATCHING_FLOOR}.
|
|
190
|
+
* @lastreviewed null
|
|
191
|
+
*/
|
|
192
|
+
async setupStatus(options = {}) {
|
|
193
|
+
const helper = checkedHelper(options.helper);
|
|
194
|
+
await this.requireGit(exports.GIT_MATCHING_FLOOR);
|
|
195
|
+
return this.statusOf(await this.helperEntries(options.cwd), new Set([helper]), await this.scopeAt(options.cwd));
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Whether git asks b6p alone for the host of one clone's remote (`origin` by default), reading
|
|
199
|
+
* the config in effect in that clone (its local and worktree config included), so a consumer can
|
|
200
|
+
* warn after a `kb pull` or `script pull` that git there would also ask another helper. `null`
|
|
201
|
+
* when the clone has no such remote, or its URL's host is not an allowed one. Changes nothing.
|
|
202
|
+
*
|
|
203
|
+
* @throws {Err.GitCredentialSetupError} when git is missing or older than {@link GIT_MATCHING_FLOOR}.
|
|
204
|
+
* @lastreviewed null
|
|
205
|
+
*/
|
|
206
|
+
async cloneStatus(dir, options = {}) {
|
|
207
|
+
const helper = checkedHelper(options.helper);
|
|
208
|
+
const remote = options.remote ?? "origin";
|
|
209
|
+
if (!/^[A-Za-z0-9._-]+$/.test(remote)) {
|
|
210
|
+
throw new Err_1.Err.GitCredentialSetupError("The remote name is not a plain name.", null);
|
|
211
|
+
}
|
|
212
|
+
await this.requireGit(exports.GIT_MATCHING_FLOOR);
|
|
213
|
+
const outcome = await this.ctx.gitConfig.run(["--get", `remote.${remote}.url`], { cwd: dir });
|
|
214
|
+
if (outcome.code !== 0) {
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
217
|
+
let host;
|
|
218
|
+
try {
|
|
219
|
+
const url = new URL(outcome.stdout.trim());
|
|
220
|
+
url.username = "";
|
|
221
|
+
url.password = "";
|
|
222
|
+
host = (0, hosts_1.credentialHostOf)(url);
|
|
223
|
+
}
|
|
224
|
+
catch {
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
const allowed = (await this.allowedHosts()).find((a) => a.host === host);
|
|
228
|
+
if (allowed === undefined) {
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
return { ...allowed, ...(0, credentialConfig_1.askedFor)(await this.helperEntries(dir), allowed.host, new Set([helper])) };
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Make b6p the helper git asks for every allowed host, in the user's global git config, the way
|
|
235
|
+
* `gh auth setup-git` does: a new `[credential "https://<host>"]` section holding an empty
|
|
236
|
+
* `helper =` (a reset, so no earlier helper such as `store` or `cache` answers that host or keeps
|
|
237
|
+
* the token) and then `helper =` b6p's command, appended in one edit to the file git itself says
|
|
238
|
+
* `git config --global` writes ({@link GitConfigRunner.globalFile}), under git's own lock on that
|
|
239
|
+
* file, so the pair is written whole or not at all.
|
|
240
|
+
*
|
|
241
|
+
* A host is repaired when the system and global config (the files setup can change) do not
|
|
242
|
+
* certainly make git ask b6p alone; one that does is left alone, so a second run changes
|
|
243
|
+
* nothing. b6p's own entries for a repaired host, and its reset pairs
|
|
244
|
+
* ({@link GitCredentialResetState}), are taken out first, so neither line is ever doubled. Every
|
|
245
|
+
* pair written is recorded ({@link GitCredentialResets}) before and after the edit. The user's
|
|
246
|
+
* entries are never moved or deleted: one that still applies after b6p's (a `*.bluestep.net`
|
|
247
|
+
* helper later in the config, a repository's own helper, say) leaves the host
|
|
248
|
+
* `configured: false` in `hosts` (read as {@link setupStatus} reads, in `cwd`), with the entry in
|
|
249
|
+
* `others`.
|
|
250
|
+
*
|
|
251
|
+
* The whole run holds the git config lock ({@link GitCredentialResets.exclusive}), so two setups,
|
|
252
|
+
* or a setup and a removal, never interleave, in one process or several.
|
|
253
|
+
*
|
|
254
|
+
* @throws {Err.GitCredentialSetupError} when git is missing or older than {@link GIT_SETUP_FLOOR}, a
|
|
255
|
+
* config file cannot be read, locked or written, or `git config` fails.
|
|
256
|
+
* @lastreviewed null
|
|
257
|
+
*/
|
|
258
|
+
async setupGit(options = {}) {
|
|
259
|
+
const helper = checkedHelper(options.helper);
|
|
260
|
+
const helpers = new Set([helper]);
|
|
261
|
+
await this.requireGit(exports.GIT_SETUP_FLOOR);
|
|
262
|
+
return this.ctx.resets.exclusive(async () => {
|
|
263
|
+
const file = await this.ctx.gitConfig.globalFile();
|
|
264
|
+
let entries = await this.helperEntries(options.cwd);
|
|
265
|
+
let claims = await this.settleResets(entries);
|
|
266
|
+
const before = await this.statusOf(entries.filter(isWritableScope), helpers, "global");
|
|
267
|
+
const added = [];
|
|
268
|
+
const alreadyConfigured = [];
|
|
269
|
+
const keptResets = [];
|
|
270
|
+
for (const host of before.hosts) {
|
|
271
|
+
if (host.configured) {
|
|
272
|
+
alreadyConfigured.push(host.host);
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
const out = await this.removeFor(entries, claims, helpers, (url) => (0, credentialConfig_1.patternIsHost)(url, host.host), "any");
|
|
276
|
+
keptResets.push(...out.keptResets);
|
|
277
|
+
entries = await this.helperEntries(options.cwd);
|
|
278
|
+
await this.install(entries, file, host.host, helper);
|
|
279
|
+
entries = await this.helperEntries(options.cwd);
|
|
280
|
+
claims = await this.settleResets(entries);
|
|
281
|
+
added.push(host.host);
|
|
282
|
+
}
|
|
283
|
+
const after = await this.statusOf(entries, helpers, await this.scopeAt(options.cwd));
|
|
284
|
+
return {
|
|
285
|
+
added,
|
|
286
|
+
alreadyConfigured,
|
|
287
|
+
hosts: after.hosts,
|
|
288
|
+
otherHelpers: after.otherHelpers,
|
|
289
|
+
keptResets,
|
|
290
|
+
scope: after.scope,
|
|
291
|
+
};
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Take b6p out of the user's global git config: each reset pair that is b6p's
|
|
296
|
+
* ({@link GitCredentialResetState}) with one of `helpers` after it, both lines in one edit under
|
|
297
|
+
* git's lock on the file, then every other `credential.<url>.helper` entry whose value is one of
|
|
298
|
+
* `helpers`, for any URL and in any spelling (a host no longer allowed included), each from the
|
|
299
|
+
* file it came from. Only system-independent global files are edited; a repository's config is
|
|
300
|
+
* never touched. A reset b6p did not write, or whose ownership is not certain, is never removed,
|
|
301
|
+
* whatever sits next to it; one b6p wrote but cannot tell apart is reported in `keptResets`.
|
|
302
|
+
* Holds the git config lock throughout, as {@link setupGit} does.
|
|
303
|
+
*
|
|
304
|
+
* @throws {Err.GitCredentialSetupError} when git is missing or older than {@link GIT_MATCHING_FLOOR},
|
|
305
|
+
* a config file cannot be locked or written, or `git config` fails.
|
|
306
|
+
* @lastreviewed null
|
|
307
|
+
*/
|
|
308
|
+
async removeGit(options = {}) {
|
|
309
|
+
const helpers = new Set((options.helpers ?? [GitCredential_1.GitCredential.DEFAULT_HELPER]).map((h) => checkedHelper(h)));
|
|
310
|
+
await this.requireGit(exports.GIT_MATCHING_FLOOR);
|
|
311
|
+
return this.ctx.resets.exclusive(async () => {
|
|
312
|
+
const entries = await this.helperEntries();
|
|
313
|
+
const claims = await this.settleResets(entries);
|
|
314
|
+
return this.removeFor(entries, claims, helpers, () => true, "named");
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
async statusOf(entries, helpers, scope) {
|
|
318
|
+
const hosts = (await this.allowedHosts()).map((allowed) => ({
|
|
319
|
+
...allowed,
|
|
320
|
+
...(0, credentialConfig_1.askedFor)(entries, allowed.host, helpers),
|
|
321
|
+
}));
|
|
322
|
+
return {
|
|
323
|
+
hosts,
|
|
324
|
+
configured: hosts.length > 0 && hosts.every((host) => host.configured),
|
|
325
|
+
otherHelpers: [
|
|
326
|
+
...new Set(entries.filter((e) => e.kind === "helper" && e.url === null && e.value !== "").map((e) => e.value)),
|
|
327
|
+
],
|
|
328
|
+
scope,
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
get pathStyle() {
|
|
332
|
+
return this.ctx.gitConfig.pathStyle ?? (process.platform === "win32" ? "win32" : "posix");
|
|
333
|
+
}
|
|
334
|
+
async scopeAt(cwd) {
|
|
335
|
+
return (await this.ctx.gitConfig.git(["rev-parse", "--git-dir"], { cwd })).code === 0 ? "global+here" : "global";
|
|
336
|
+
}
|
|
337
|
+
async requireGit(floor) {
|
|
338
|
+
this.gitVersion ??= this.ctx.gitConfig.git(["--version"]).then((outcome) => {
|
|
339
|
+
if (outcome.code === -1) {
|
|
340
|
+
throw new Err_1.Err.GitCredentialSetupError("git could not be run; it may not be installed.", null);
|
|
341
|
+
}
|
|
342
|
+
const version = outcome.code === 0 ? parseGitVersion(outcome.stdout) : null;
|
|
343
|
+
if (version === null) {
|
|
344
|
+
// git reads its config even for --version, and exits 128 on a broken one: say what git said.
|
|
345
|
+
const said = gitSaid(outcome.stderr);
|
|
346
|
+
throw new Err_1.Err.GitCredentialSetupError(said
|
|
347
|
+
? `git failed (exit ${outcome.code}): ${said}`
|
|
348
|
+
: `git did not report a version b6p recognises (exit ${outcome.code}).`, outcome.code);
|
|
349
|
+
}
|
|
350
|
+
return version;
|
|
351
|
+
});
|
|
352
|
+
let version;
|
|
353
|
+
try {
|
|
354
|
+
version = await this.gitVersion;
|
|
355
|
+
}
|
|
356
|
+
catch (error) {
|
|
357
|
+
this.gitVersion = undefined;
|
|
358
|
+
throw error;
|
|
359
|
+
}
|
|
360
|
+
if (!atLeast(version, floor)) {
|
|
361
|
+
throw new Err_1.Err.GitCredentialSetupError(`git ${version.join(".")} is older than ${floor}, which this needs.`, null);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
gitVersion;
|
|
365
|
+
/**
|
|
366
|
+
* Append b6p's reset-then-`helper` pair for `host` to `file` in one edit under git's lock,
|
|
367
|
+
* recorded `adding` (with the pairs the key had) before and `installed` after; when the edit
|
|
368
|
+
* throws, the record is settled from the file as it then is. The edit is refused when the file no
|
|
369
|
+
* longer holds what the record counted, or does not parse.
|
|
370
|
+
* @lastreviewed null
|
|
371
|
+
*/
|
|
372
|
+
async install(entries, file, host, helper) {
|
|
373
|
+
const key = (0, credentialConfig_1.helperKeyFor)(host);
|
|
374
|
+
const pairsBefore = (0, credentialConfig_1.pairsOf)(entries, file, key, helper, this.pathStyle);
|
|
375
|
+
await this.ctx.resets.put(file, key, { state: "adding", helper, pairsBefore });
|
|
376
|
+
const bytes = asBytes(helper);
|
|
377
|
+
try {
|
|
378
|
+
await this.ctx.gitConfig.editFile(file, (text) => {
|
|
379
|
+
const parsed = (0, configFile_1.parseConfigFile)(text);
|
|
380
|
+
if (parsed === null) {
|
|
381
|
+
throw new Err_1.Err.GitCredentialSetupError(`git config file ${file} could not be read as git reads it.`, null);
|
|
382
|
+
}
|
|
383
|
+
if ((0, configFile_1.pairsIn)(parsed, key, bytes).length !== pairsBefore) {
|
|
384
|
+
throw new Err_1.Err.GitCredentialSetupError(`git config file ${file} changed while setup was writing it.`, null);
|
|
385
|
+
}
|
|
386
|
+
const next = (0, configFile_1.appendPair)(text, `https://${host}`, bytes);
|
|
387
|
+
const written = (0, configFile_1.parseConfigFile)(next);
|
|
388
|
+
if (written === null ||
|
|
389
|
+
!(0, configFile_1.keepsEntries)(parsed, written, 2) ||
|
|
390
|
+
(0, configFile_1.pairsIn)(written, key, bytes).length !== pairsBefore + 1) {
|
|
391
|
+
throw new Err_1.Err.GitCredentialSetupError(`b6p's entries could not be appended to git config file ${file} without changing an entry already there.`, null);
|
|
392
|
+
}
|
|
393
|
+
return next;
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
catch (error) {
|
|
397
|
+
// Settled from the file, not cleared: an error after the edit landed must not orphan b6p's pair.
|
|
398
|
+
await this.helperEntries()
|
|
399
|
+
.then((now) => this.settleResets(now))
|
|
400
|
+
.catch(() => undefined);
|
|
401
|
+
throw error;
|
|
402
|
+
}
|
|
403
|
+
await this.ctx.resets.put(file, key, { state: "installed", helper });
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Take out b6p's entries for the URLs `urls` passes, in global files only. First each reset pair of
|
|
407
|
+
* b6p's (`owned`) whose helper is one of `helpers` (or, for `pairs: "any"`, whatever its helper,
|
|
408
|
+
* as setup replacing its own pair does): re-read under git's lock on its file, and removed, both
|
|
409
|
+
* lines in that one edit, only when the file holds exactly one such pair. A file with several,
|
|
410
|
+
* and every `unconfirmed` claim, is reported and forgotten, and only its helper lines go, so what
|
|
411
|
+
* is left is an inert reset. Then b6p's other helper entries, each spelling from its own file.
|
|
412
|
+
* @lastreviewed null
|
|
413
|
+
*/
|
|
414
|
+
async removeFor(entries, claims, helpers, urls, pairs) {
|
|
415
|
+
const style = this.pathStyle;
|
|
416
|
+
const removed = [];
|
|
417
|
+
const keptResets = [];
|
|
418
|
+
const pairHelpers = new Set();
|
|
419
|
+
const once = (file, key, value) => `${(0, credentialConfig_1.configPathKey)(file, style)}\0${key}\0${value}`;
|
|
420
|
+
for (const claim of claims.owned) {
|
|
421
|
+
if (!urls(claim.url) || (pairs === "named" && !helpers.has(claim.record.helper))) {
|
|
422
|
+
continue;
|
|
423
|
+
}
|
|
424
|
+
const result = { outcome: "gone" };
|
|
425
|
+
await this.ctx.gitConfig.editFile(claim.file, (text) => {
|
|
426
|
+
const parsed = (0, configFile_1.parseConfigFile)(text);
|
|
427
|
+
const found = parsed === null ? [] : (0, configFile_1.pairsIn)(parsed, asBytes(claim.key), asBytes(claim.record.helper));
|
|
428
|
+
if (parsed === null || (found.length === 1 && !(found[0][0].ownLine && found[0][1].ownLine))) {
|
|
429
|
+
result.outcome = "unconfirmed";
|
|
430
|
+
}
|
|
431
|
+
else if (found.length > 1) {
|
|
432
|
+
result.outcome = "shared-key";
|
|
433
|
+
}
|
|
434
|
+
else if (found.length === 1) {
|
|
435
|
+
result.outcome = "removed";
|
|
436
|
+
return (0, configFile_1.removePair)(text, parsed, found[0]);
|
|
437
|
+
}
|
|
438
|
+
return null;
|
|
439
|
+
});
|
|
440
|
+
if (result.outcome === "removed") {
|
|
441
|
+
if (!removed.includes(claim.url)) {
|
|
442
|
+
removed.push(claim.url);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
else if (result.outcome !== "gone") {
|
|
446
|
+
keptResets.push({ url: claim.url, file: claim.file, reason: result.outcome });
|
|
447
|
+
pairHelpers.add(once(claim.file, claim.key, claim.record.helper));
|
|
448
|
+
}
|
|
449
|
+
await this.ctx.resets.put(claim.file, claim.key, undefined);
|
|
450
|
+
}
|
|
451
|
+
for (const claim of claims.unconfirmed) {
|
|
452
|
+
if (urls(claim.url)) {
|
|
453
|
+
keptResets.push({ url: claim.url, file: claim.file, reason: "unconfirmed" });
|
|
454
|
+
await this.ctx.resets.put(claim.file, claim.key, undefined);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
const now = claims.owned.length > 0 ? await this.helperEntries() : entries;
|
|
458
|
+
const done = new Set();
|
|
459
|
+
for (const entry of now) {
|
|
460
|
+
if (entry.kind !== "helper" ||
|
|
461
|
+
entry.scope !== "global" ||
|
|
462
|
+
entry.url === null ||
|
|
463
|
+
entry.file === null ||
|
|
464
|
+
entry.value === "" ||
|
|
465
|
+
!urls(entry.url)) {
|
|
466
|
+
continue;
|
|
467
|
+
}
|
|
468
|
+
const id = once(entry.file, entry.key, entry.value);
|
|
469
|
+
if (done.has(id) || !(helpers.has(entry.value) || pairHelpers.has(id))) {
|
|
470
|
+
continue;
|
|
471
|
+
}
|
|
472
|
+
done.add(id);
|
|
473
|
+
requireSuccess(await this.ctx.gitConfig.run(["--file", entry.file, "--unset-all", entry.key, (0, credentialConfig_1.exactValuePattern)(entry.value)]), "remove");
|
|
474
|
+
if (!removed.includes(entry.url)) {
|
|
475
|
+
removed.push(entry.url);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
return { removed, keptResets };
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* Settle every reset record against the config as it is now ({@link GitCredentialResetState})
|
|
482
|
+
* and return the claims that stand: `owned` (installed, its pair in place) and `unconfirmed`.
|
|
483
|
+
* Ownership is never inferred from a count of empty values: an installed record whose helper no
|
|
484
|
+
* longer directly follows an empty value of its key in its file is dropped, and an addition that
|
|
485
|
+
* left the file with any number of pairs but the two it predicts becomes `unconfirmed`.
|
|
486
|
+
* @lastreviewed null
|
|
487
|
+
*/
|
|
488
|
+
async settleResets(entries) {
|
|
489
|
+
const style = this.pathStyle;
|
|
490
|
+
const claims = { owned: [], unconfirmed: [] };
|
|
491
|
+
for (const [file, keys] of Object.entries(await this.ctx.resets.all())) {
|
|
492
|
+
for (const [key, record] of Object.entries(keys)) {
|
|
493
|
+
const url = (0, credentialConfig_1.urlOfKey)(key);
|
|
494
|
+
const pairs = (0, credentialConfig_1.pairsOf)(entries, file, key, record.helper, style);
|
|
495
|
+
const before = record.pairsBefore ?? 0;
|
|
496
|
+
let next;
|
|
497
|
+
if (url === null) {
|
|
498
|
+
next = undefined;
|
|
499
|
+
}
|
|
500
|
+
else if (record.state === "installed") {
|
|
501
|
+
next = pairs > 0 ? record : undefined;
|
|
502
|
+
}
|
|
503
|
+
else if (record.state === "adding") {
|
|
504
|
+
next =
|
|
505
|
+
pairs === before
|
|
506
|
+
? undefined
|
|
507
|
+
: pairs === before + 1
|
|
508
|
+
? { state: "installed", helper: record.helper }
|
|
509
|
+
: { state: "unconfirmed", helper: record.helper };
|
|
510
|
+
}
|
|
511
|
+
else {
|
|
512
|
+
next = record;
|
|
513
|
+
}
|
|
514
|
+
if (next !== record) {
|
|
515
|
+
await this.ctx.resets.put(file, key, next);
|
|
516
|
+
}
|
|
517
|
+
if (next !== undefined && url !== null) {
|
|
518
|
+
(next.state === "installed" ? claims.owned : claims.unconfirmed).push({ file, key, url, record: next });
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
return claims;
|
|
523
|
+
}
|
|
524
|
+
async get(fields) {
|
|
525
|
+
// git hands a helper the URL's parts (protocol, host, path), never `url=`. A `url=` here was not written by git
|
|
526
|
+
// and could be parsed differently from how git would (a backslash, say), so it is refused, not reconciled.
|
|
527
|
+
if (fields.has("url")) {
|
|
528
|
+
return "";
|
|
529
|
+
}
|
|
530
|
+
const protocol = fields.get("protocol");
|
|
531
|
+
const host = fields.get("host");
|
|
532
|
+
if (protocol !== "https" || host === undefined) {
|
|
533
|
+
return "";
|
|
534
|
+
}
|
|
535
|
+
const username = fields.get("username");
|
|
536
|
+
if (username !== undefined && username !== GitCredential_1.GitCredential.USERNAME) {
|
|
537
|
+
return "";
|
|
538
|
+
}
|
|
539
|
+
const requested = (0, hosts_1.requestedCredentialHost)(host);
|
|
540
|
+
if (requested === null || !(await this.allowedHosts()).some((allowed) => allowed.host === requested)) {
|
|
541
|
+
return "";
|
|
542
|
+
}
|
|
543
|
+
const token = await this.ctx.token.token();
|
|
544
|
+
if (token === undefined || (0, GatewayToken_1.gatewayTokenProblem)(token) !== null) {
|
|
545
|
+
return "";
|
|
546
|
+
}
|
|
547
|
+
return `username=${GitCredential_1.GitCredential.USERNAME}\npassword=${token}\n`;
|
|
548
|
+
}
|
|
549
|
+
async gatewayHost() {
|
|
550
|
+
try {
|
|
551
|
+
return (0, hosts_1.credentialHostOf)(new URL((0, GatewayClient_1.parseGatewayOrigin)(await this.ctx.gatewayUrl())));
|
|
552
|
+
}
|
|
553
|
+
catch {
|
|
554
|
+
return null;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
async helperEntries(cwd) {
|
|
558
|
+
const outcome = await this.ctx.gitConfig.run(credentialConfig_1.LIST_CREDENTIAL_ENTRIES, { cwd });
|
|
559
|
+
if (outcome.code === 1) {
|
|
560
|
+
return [];
|
|
561
|
+
}
|
|
562
|
+
requireSuccess(outcome, "read");
|
|
563
|
+
// git names a repository's own file relative to where it ran (`.git/config`).
|
|
564
|
+
const base = cwd ?? process.cwd();
|
|
565
|
+
return (0, credentialConfig_1.parseHelperEntries)(outcome.stdout).map((entry) => entry.file === null || path.isAbsolute(entry.file) || path.win32.isAbsolute(entry.file)
|
|
566
|
+
? entry
|
|
567
|
+
: { ...entry, file: path.resolve(base, entry.file) });
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
exports.GitCredentialService = GitCredentialService;
|
|
571
|
+
// The line of git's stderr that says what went wrong: its first `fatal:` or `error:` line, else its first line.
|
|
572
|
+
function gitSaid(stderr) {
|
|
573
|
+
const lines = stderr
|
|
574
|
+
.split(/\r?\n/)
|
|
575
|
+
.map((line) => line.trim())
|
|
576
|
+
.filter((line) => line !== "");
|
|
577
|
+
return lines.find((line) => /^(fatal|error):/.test(line)) ?? lines[0] ?? "";
|
|
578
|
+
}
|
|
579
|
+
// A string as the bytes of its UTF-8 encoding, one latin1 character each: the form config file edits work in.
|
|
580
|
+
const asBytes = (text) => Buffer.from(text, "utf8").toString("latin1");
|
|
581
|
+
// The scopes setup can change: global files, and system ones that come before them.
|
|
582
|
+
const isWritableScope = (entry) => entry.scope === "system" || entry.scope === "global";
|
|
583
|
+
function requireSuccess(outcome, what) {
|
|
584
|
+
if (outcome.code === 0) {
|
|
585
|
+
return;
|
|
586
|
+
}
|
|
587
|
+
if (outcome.code === -1) {
|
|
588
|
+
throw new Err_1.Err.GitCredentialSetupError("git could not be run; it may not be installed.", null);
|
|
589
|
+
}
|
|
590
|
+
const verb = { read: "reading", add: "adding to", remove: "removing from" }[what];
|
|
591
|
+
const detail = gitSaid(outcome.stderr);
|
|
592
|
+
throw new Err_1.Err.GitCredentialSetupError(`git config failed ${verb} the user's git config (exit ${outcome.code})${detail ? `: ${detail}` : ""}.`, outcome.code);
|
|
593
|
+
}
|
|
594
|
+
//# sourceMappingURL=GitCredentialService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GitCredentialService.js","sourceRoot":"","sources":["../../src/gitCredential/GitCredentialService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAY,IAAI,sCAAkB;AAElC,8DAA2D;AAC3D,gCAA6B;AAC7B,4DAA8D;AAC9D,0DAA8D;AAC9D,6CAA8F;AAC9F,yDAa4B;AAG5B,mCAAoE;AA0NpE;;;;;GAKG;AACU,QAAA,kBAAkB,GAAG,QAAQ,CAAC;AAE3C;;;;GAIG;AACU,QAAA,eAAe,GAAG,QAAQ,CAAC;AAExC;;;;GAIG;AACH,yBAAgC,MAAc;IAC5C,MAAM,KAAK,GAAG,sCAAsC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAClE,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACp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