@ouro.bot/cli 0.1.0-alpha.1010 → 0.1.0-alpha.1013
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/changelog.json +12 -0
- package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
- package/deploy/unraid/sanctuary.xml +1 -1
- package/dist/heart/auth/auth-flow.js +60 -0
- package/dist/heart/core.js +5 -3
- package/dist/heart/provider-credentials.js +2 -2
- package/dist/heart/providers/account-pool.js +549 -0
- package/dist/heart/providers/github-copilot.js +71 -6
- package/dist/heart/quota/fleet-readings.js +222 -0
- package/dist/heart/quota/tranche.js +59 -0
- package/dist/repertoire/bitwarden-native.js +349 -0
- package/dist/repertoire/bitwarden-store.js +49 -4
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
|
@@ -49,6 +49,7 @@ const fs = __importStar(require("node:fs"));
|
|
|
49
49
|
const path = __importStar(require("node:path"));
|
|
50
50
|
const runtime_1 = require("../nerves/runtime");
|
|
51
51
|
const bw_installer_1 = require("./bw-installer");
|
|
52
|
+
const bitwarden_native_1 = require("./bitwarden-native");
|
|
52
53
|
const MAX_ERROR_DETAIL_LENGTH = 500;
|
|
53
54
|
const LONG_ENCODED_TOKEN_PATTERN = /[A-Za-z0-9+/=]{32,}/g;
|
|
54
55
|
const BW_PASSWORD_ENV = "OURO_BW_MASTER_PASSWORD";
|
|
@@ -550,6 +551,12 @@ function parseBwItemId(stdout) {
|
|
|
550
551
|
return null;
|
|
551
552
|
}
|
|
552
553
|
}
|
|
554
|
+
/** Reads go over HTTPS unless OURO_VAULT_NATIVE_READS=0; tests inject a reader or read through bw. */
|
|
555
|
+
function defaultNativeReader(serverUrl, email, masterPassword) {
|
|
556
|
+
if (process.env.OURO_VAULT_NATIVE_READS === "0" || process.env.VITEST !== undefined)
|
|
557
|
+
return null;
|
|
558
|
+
return (0, bitwarden_native_1.sharedNativeVaultReader)(serverUrl, email, masterPassword);
|
|
559
|
+
}
|
|
553
560
|
// ---------------------------------------------------------------------------
|
|
554
561
|
// BitwardenCredentialStore
|
|
555
562
|
// ---------------------------------------------------------------------------
|
|
@@ -569,6 +576,8 @@ class BitwardenCredentialStore {
|
|
|
569
576
|
terminalLoginErrorAt = 0;
|
|
570
577
|
bwBinaryPath = "bw";
|
|
571
578
|
structuredItemCache = null;
|
|
579
|
+
/** Reads the vault over HTTPS without bw; null once it reports the vault unsupported, or when off. */
|
|
580
|
+
nativeReader;
|
|
572
581
|
constructor(serverUrl, email, masterPassword, options = {}) {
|
|
573
582
|
this.serverUrl = serverUrl;
|
|
574
583
|
this.email = email;
|
|
@@ -578,6 +587,7 @@ class BitwardenCredentialStore {
|
|
|
578
587
|
this.onInvalidUnlockSecret = options.onInvalidUnlockSecret;
|
|
579
588
|
this.onLoginSuccess = options.onLoginSuccess;
|
|
580
589
|
this.onProgress = options.onProgress;
|
|
590
|
+
this.nativeReader = options.nativeReader !== undefined ? options.nativeReader : defaultNativeReader(serverUrl, email, masterPassword);
|
|
581
591
|
}
|
|
582
592
|
isReady() {
|
|
583
593
|
return true;
|
|
@@ -994,7 +1004,7 @@ class BitwardenCredentialStore {
|
|
|
994
1004
|
message: `getting credential via bw for ${domain}`,
|
|
995
1005
|
meta: { domain, backend: "bitwarden" },
|
|
996
1006
|
});
|
|
997
|
-
const item = await this.withTransientRetry(() => this.
|
|
1007
|
+
const item = await this.withTransientRetry(() => this.readItemByDomain(domain));
|
|
998
1008
|
if (!item) {
|
|
999
1009
|
(0, runtime_1.emitNervesEvent)({
|
|
1000
1010
|
event: "repertoire.bw_credential_get_end",
|
|
@@ -1018,7 +1028,7 @@ class BitwardenCredentialStore {
|
|
|
1018
1028
|
};
|
|
1019
1029
|
}
|
|
1020
1030
|
async getRawSecret(domain, field) {
|
|
1021
|
-
const item = await this.withTransientRetry(() => this.
|
|
1031
|
+
const item = await this.withTransientRetry(() => this.readItemByDomain(domain));
|
|
1022
1032
|
if (!item) {
|
|
1023
1033
|
throw new Error(`no credential found for domain "${domain}"`);
|
|
1024
1034
|
}
|
|
@@ -1079,6 +1089,7 @@ class BitwardenCredentialStore {
|
|
|
1079
1089
|
this.assertStoredCredentialMatches(domain, data, savedItem);
|
|
1080
1090
|
});
|
|
1081
1091
|
this.structuredItemCache = null;
|
|
1092
|
+
this.nativeReader?.invalidate();
|
|
1082
1093
|
(0, runtime_1.emitNervesEvent)({
|
|
1083
1094
|
event: "repertoire.bw_credential_store_end",
|
|
1084
1095
|
component: "repertoire",
|
|
@@ -1093,8 +1104,7 @@ class BitwardenCredentialStore {
|
|
|
1093
1104
|
message: "listing bw credentials",
|
|
1094
1105
|
meta: { backend: "bitwarden" },
|
|
1095
1106
|
});
|
|
1096
|
-
const
|
|
1097
|
-
const items = parseBwItems(stdout, "bw list items");
|
|
1107
|
+
const items = await this.withTransientRetry(async () => (await this.nativeItems()) ?? parseBwItems(await this.withSessionRetry((session) => this.execBw(["list", "items"], session)), "bw list items"));
|
|
1098
1108
|
const results = items.map((item) => ({
|
|
1099
1109
|
domain: item.name,
|
|
1100
1110
|
username: item.login?.username,
|
|
@@ -1128,6 +1138,7 @@ class BitwardenCredentialStore {
|
|
|
1128
1138
|
}
|
|
1129
1139
|
await this.withSessionRetry((session) => this.execBw(["delete", "item", item.id], session));
|
|
1130
1140
|
this.structuredItemCache = null;
|
|
1141
|
+
this.nativeReader?.invalidate();
|
|
1131
1142
|
(0, runtime_1.emitNervesEvent)({
|
|
1132
1143
|
event: "repertoire.bw_credential_delete_end",
|
|
1133
1144
|
component: "repertoire",
|
|
@@ -1137,6 +1148,40 @@ class BitwardenCredentialStore {
|
|
|
1137
1148
|
return true;
|
|
1138
1149
|
}
|
|
1139
1150
|
// --- Private ---
|
|
1151
|
+
/** One item by name: from the native reader when it serves this vault, else through bw. */
|
|
1152
|
+
async readItemByDomain(domain) {
|
|
1153
|
+
const native = await this.nativeItems();
|
|
1154
|
+
if (native)
|
|
1155
|
+
return native.find((item) => item.name === domain) ?? null;
|
|
1156
|
+
return this.withSessionRetry((session) => this.findItemByDomain(domain, session));
|
|
1157
|
+
}
|
|
1158
|
+
/** Every item through the native reader, or null when reads go through bw. */
|
|
1159
|
+
async nativeItems() {
|
|
1160
|
+
const reader = this.nativeReader;
|
|
1161
|
+
if (!reader)
|
|
1162
|
+
return null;
|
|
1163
|
+
try {
|
|
1164
|
+
return await reader.items();
|
|
1165
|
+
}
|
|
1166
|
+
catch (error) {
|
|
1167
|
+
/* v8 ignore next -- defensive: the reader always throws Error instances @preserve */
|
|
1168
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
1169
|
+
if (err instanceof bitwarden_native_1.NativeVaultUnsupportedError) {
|
|
1170
|
+
this.nativeReader = null;
|
|
1171
|
+
(0, runtime_1.emitNervesEvent)({
|
|
1172
|
+
level: "warn",
|
|
1173
|
+
event: "repertoire.native_vault_fallback",
|
|
1174
|
+
component: "repertoire",
|
|
1175
|
+
message: "reading this vault through bw instead",
|
|
1176
|
+
meta: { email: this.email, serverUrl: this.serverUrl, reason: err.message },
|
|
1177
|
+
});
|
|
1178
|
+
return null;
|
|
1179
|
+
}
|
|
1180
|
+
if (isBwInvalidUnlockSecretMessage(err.message))
|
|
1181
|
+
await this.notifyInvalidUnlockSecret(err);
|
|
1182
|
+
throw err;
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1140
1185
|
async findItemByDomain(domain, session) {
|
|
1141
1186
|
if (shouldUseStructuredItemLookup(domain)) {
|
|
1142
1187
|
const cache = await this.readStructuredItemCache(session);
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ouro.bot/cli",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.1013",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@ouro.bot/cli",
|
|
9
|
-
"version": "0.1.0-alpha.
|
|
9
|
+
"version": "0.1.0-alpha.1013",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sdk": "^0.78.0",
|
|
12
12
|
"@azure/identity": "^4.13.0",
|