@oya-ai/browser 1.0.127 → 1.0.130
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/index.cjs +9 -6
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -6
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -889,7 +889,9 @@ async function signup(options) {
|
|
|
889
889
|
const saved = options.save !== false && saveKey(answer.api_key, http.baseUrl);
|
|
890
890
|
return { apiKey: answer.api_key, claimUrl: answer.claim_url, cloudBrowsers: answer.cloud_browsers, saved };
|
|
891
891
|
}
|
|
892
|
-
var desktopOf = (all) => all.find(
|
|
892
|
+
var desktopOf = (all, persona) => all.find(
|
|
893
|
+
(b) => b.provider === DESKTOP_PROVIDER && b.health !== "dead" && (!persona || b.persona === persona || b.personaName === persona)
|
|
894
|
+
);
|
|
893
895
|
async function pairingLink(http, persona) {
|
|
894
896
|
const { code } = await http.request("POST", "/api/pairing", {
|
|
895
897
|
persona
|
|
@@ -912,10 +914,10 @@ function openLink(link) {
|
|
|
912
914
|
});
|
|
913
915
|
child.unref();
|
|
914
916
|
}
|
|
915
|
-
async function waitForDesktop(list, link, timeoutMs) {
|
|
917
|
+
async function waitForDesktop(list, link, timeoutMs, persona) {
|
|
916
918
|
const deadline = Date.now() + timeoutMs;
|
|
917
919
|
while (Date.now() < deadline) {
|
|
918
|
-
const found = desktopOf(await list());
|
|
920
|
+
const found = desktopOf(await list(), persona);
|
|
919
921
|
if (found) return found;
|
|
920
922
|
await new Promise((r) => setTimeout(r, READY_POLL_MS));
|
|
921
923
|
}
|
|
@@ -932,14 +934,15 @@ var desktopApi = (http, list) => ({
|
|
|
932
934
|
* The person's own desktop browser, signed in to their sites. When it is not
|
|
933
935
|
* connected yet this pairs it: it opens a link, the person clicks Connect in
|
|
934
936
|
* the app (with "Import my logins" ticked, their Chrome logins come along),
|
|
935
|
-
* and this waits until it is up.
|
|
937
|
+
* and this waits until it is up. With `persona`, a running app signed in as
|
|
938
|
+
* another persona is switched the same way: the link reconnects it as this one.
|
|
936
939
|
*/
|
|
937
940
|
connect: async (options = {}) => {
|
|
938
|
-
const running = desktopOf(await list());
|
|
941
|
+
const running = desktopOf(await list(), options.persona);
|
|
939
942
|
if (running) return handleOn(http(), running.id);
|
|
940
943
|
const link = await pairingLink(http(), options.persona);
|
|
941
944
|
if (options.open !== false) openLink(link);
|
|
942
|
-
const found = await waitForDesktop(list, link, options.timeoutMs ?? DESKTOP_TIMEOUT_MS);
|
|
945
|
+
const found = await waitForDesktop(list, link, options.timeoutMs ?? DESKTOP_TIMEOUT_MS, options.persona);
|
|
943
946
|
return handleOn(http(), found.id);
|
|
944
947
|
}
|
|
945
948
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -968,7 +968,7 @@ interface Signup {
|
|
|
968
968
|
}
|
|
969
969
|
/** What `oya.desktop.connect()` takes. */
|
|
970
970
|
interface DesktopOptions {
|
|
971
|
-
/** The persona the desktop app signs in as. Defaults to the key's own. */
|
|
971
|
+
/** The persona (id or name) the desktop app signs in as, switching a running app that is on another one. Defaults to the key's own. */
|
|
972
972
|
persona?: string;
|
|
973
973
|
/** Open the pairing link on this machine (the default). Off, the link is only in the error when the app does not connect. */
|
|
974
974
|
open?: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -968,7 +968,7 @@ interface Signup {
|
|
|
968
968
|
}
|
|
969
969
|
/** What `oya.desktop.connect()` takes. */
|
|
970
970
|
interface DesktopOptions {
|
|
971
|
-
/** The persona the desktop app signs in as. Defaults to the key's own. */
|
|
971
|
+
/** The persona (id or name) the desktop app signs in as, switching a running app that is on another one. Defaults to the key's own. */
|
|
972
972
|
persona?: string;
|
|
973
973
|
/** Open the pairing link on this machine (the default). Off, the link is only in the error when the app does not connect. */
|
|
974
974
|
open?: boolean;
|
package/dist/index.js
CHANGED
|
@@ -857,7 +857,9 @@ async function signup(options) {
|
|
|
857
857
|
const saved = options.save !== false && saveKey(answer.api_key, http.baseUrl);
|
|
858
858
|
return { apiKey: answer.api_key, claimUrl: answer.claim_url, cloudBrowsers: answer.cloud_browsers, saved };
|
|
859
859
|
}
|
|
860
|
-
var desktopOf = (all) => all.find(
|
|
860
|
+
var desktopOf = (all, persona) => all.find(
|
|
861
|
+
(b) => b.provider === DESKTOP_PROVIDER && b.health !== "dead" && (!persona || b.persona === persona || b.personaName === persona)
|
|
862
|
+
);
|
|
861
863
|
async function pairingLink(http, persona) {
|
|
862
864
|
const { code } = await http.request("POST", "/api/pairing", {
|
|
863
865
|
persona
|
|
@@ -880,10 +882,10 @@ function openLink(link) {
|
|
|
880
882
|
});
|
|
881
883
|
child.unref();
|
|
882
884
|
}
|
|
883
|
-
async function waitForDesktop(list, link, timeoutMs) {
|
|
885
|
+
async function waitForDesktop(list, link, timeoutMs, persona) {
|
|
884
886
|
const deadline = Date.now() + timeoutMs;
|
|
885
887
|
while (Date.now() < deadline) {
|
|
886
|
-
const found = desktopOf(await list());
|
|
888
|
+
const found = desktopOf(await list(), persona);
|
|
887
889
|
if (found) return found;
|
|
888
890
|
await new Promise((r) => setTimeout(r, READY_POLL_MS));
|
|
889
891
|
}
|
|
@@ -900,14 +902,15 @@ var desktopApi = (http, list) => ({
|
|
|
900
902
|
* The person's own desktop browser, signed in to their sites. When it is not
|
|
901
903
|
* connected yet this pairs it: it opens a link, the person clicks Connect in
|
|
902
904
|
* the app (with "Import my logins" ticked, their Chrome logins come along),
|
|
903
|
-
* and this waits until it is up.
|
|
905
|
+
* and this waits until it is up. With `persona`, a running app signed in as
|
|
906
|
+
* another persona is switched the same way: the link reconnects it as this one.
|
|
904
907
|
*/
|
|
905
908
|
connect: async (options = {}) => {
|
|
906
|
-
const running = desktopOf(await list());
|
|
909
|
+
const running = desktopOf(await list(), options.persona);
|
|
907
910
|
if (running) return handleOn(http(), running.id);
|
|
908
911
|
const link = await pairingLink(http(), options.persona);
|
|
909
912
|
if (options.open !== false) openLink(link);
|
|
910
|
-
const found = await waitForDesktop(list, link, options.timeoutMs ?? DESKTOP_TIMEOUT_MS);
|
|
913
|
+
const found = await waitForDesktop(list, link, options.timeoutMs ?? DESKTOP_TIMEOUT_MS, options.persona);
|
|
911
914
|
return handleOn(http(), found.id);
|
|
912
915
|
}
|
|
913
916
|
});
|
package/package.json
CHANGED