@phren/cli 0.3.62 → 0.3.63
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/bridge/pair.js +15 -4
- package/dist/bridge-hook.mjs +2 -2
- package/package.json +1 -1
package/dist/bridge/pair.js
CHANGED
|
@@ -107,7 +107,7 @@ const request = z.object({
|
|
|
107
107
|
});
|
|
108
108
|
/** Listen for one phone. Resolves once its key is authorized; rejects on timeout or too many bad proofs. */
|
|
109
109
|
export async function startPairing(options) {
|
|
110
|
-
let failures = 0, finished = false, timer;
|
|
110
|
+
let failures = 0, finished = false, claimed = false, timer;
|
|
111
111
|
let approvals = Promise.resolve();
|
|
112
112
|
let resolve, reject;
|
|
113
113
|
const done = new Promise((yes, no) => { resolve = yes; reject = no; });
|
|
@@ -152,11 +152,11 @@ export async function startPairing(options) {
|
|
|
152
152
|
if (input.typed) {
|
|
153
153
|
// One question at a time, each bound to its own phone: a single answer
|
|
154
154
|
// never allows two keys.
|
|
155
|
-
const ask = approvals.then(() => finished || incoming.socket.destroyed ? false
|
|
155
|
+
const ask = approvals.then(() => finished || claimed || incoming.socket.destroyed ? false
|
|
156
156
|
: options.approve ? options.approve({ device: input.device, name: input.name, check: pairingCheckCode(keyFingerprint(publicKey)) }) : false);
|
|
157
157
|
approvals = ask.catch(() => false);
|
|
158
158
|
const allowed = await ask;
|
|
159
|
-
if (finished)
|
|
159
|
+
if (finished || claimed)
|
|
160
160
|
throw new BridgeError(410, "Pairing is closed. Run phren pair again.");
|
|
161
161
|
// A phone that gave up while the question waited gets nothing written.
|
|
162
162
|
if (incoming.socket.destroyed)
|
|
@@ -164,9 +164,20 @@ export async function startPairing(options) {
|
|
|
164
164
|
if (!allowed)
|
|
165
165
|
throw new BridgeError(403, "The computer didn't allow this phone. Run phren pair again and allow it there.");
|
|
166
166
|
}
|
|
167
|
+
// Claimed before the key is written, so a phone queued behind this one is
|
|
168
|
+
// told pairing is closed rather than asked about while the write runs.
|
|
169
|
+
if (finished || claimed)
|
|
170
|
+
throw new BridgeError(410, "Pairing is closed. Run phren pair again.");
|
|
171
|
+
claimed = true;
|
|
167
172
|
const comment = input.device === "android" ? "phren-android" : "phren-iphone";
|
|
168
173
|
const encoded = publicKey.split(" ")[1];
|
|
169
|
-
|
|
174
|
+
try {
|
|
175
|
+
await appendAuthorizedKey(`restrict,pty,${forcedCommand} ${publicKey} ${comment}`, existing => existing.split(/\s+/).includes(encoded), "This phone key is already authorized with different options.", options.sshDirectory);
|
|
176
|
+
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
claimed = false;
|
|
179
|
+
throw error;
|
|
180
|
+
}
|
|
170
181
|
reply(response, 200, {
|
|
171
182
|
v: 1, name: options.name, user: options.user, sshPort: options.sshPort, fingerprint: options.fingerprint ?? null,
|
|
172
183
|
proof: pairingProof(options.code, "computer", options.fingerprint ?? "", publicKey),
|
package/dist/bridge-hook.mjs
CHANGED
|
@@ -37414,7 +37414,7 @@ var init_package_metadata = __esm({
|
|
|
37414
37414
|
__dirname = path35.dirname(fileURLToPath2(import.meta.url));
|
|
37415
37415
|
ROOT = path35.join(__dirname, "..");
|
|
37416
37416
|
PACKAGE_JSON_PATH = path35.join(ROOT, "package.json");
|
|
37417
|
-
BUNDLED_VERSION = true ? "0.3.
|
|
37417
|
+
BUNDLED_VERSION = true ? "0.3.63" : "0.0.0";
|
|
37418
37418
|
PACKAGE_JSON = readPackageJson();
|
|
37419
37419
|
PACKAGE_NAME = PACKAGE_JSON.name || "phren";
|
|
37420
37420
|
VERSION = PACKAGE_JSON.version || BUNDLED_VERSION;
|
|
@@ -82812,7 +82812,7 @@ async function main() {
|
|
|
82812
82812
|
return askpass2(args[1]);
|
|
82813
82813
|
}
|
|
82814
82814
|
const { runBridge: runBridge2 } = await Promise.resolve().then(() => (init_command(), command_exports));
|
|
82815
|
-
return runBridge2(args, "0.3.
|
|
82815
|
+
return runBridge2(args, "0.3.63");
|
|
82816
82816
|
}
|
|
82817
82817
|
main().then((code) => {
|
|
82818
82818
|
process.exitCode = code;
|