@runeya/runeya 2.0.83 → 2.0.84

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/index.js CHANGED
@@ -279,7 +279,7 @@ async function main() {
279
279
  ensureNodeBinOnPath();
280
280
  await ensureUserBinsOnPath();
281
281
  if (!isPullEnv) stampConsole();
282
- const { createLocalServer, pullEnv, PullEnvError, registerInstance } = await import("./src-OHWIFAND.js");
282
+ const { createLocalServer, pullEnv, PullEnvError, registerInstance } = await import("./src-BWQ4J4D5.js");
283
283
  if (isPullEnv) {
284
284
  if (!serviceArg) {
285
285
  console.error("Error: --service (-s) is required with --pull-env");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runeya/runeya",
3
- "version": "2.0.83",
3
+ "version": "2.0.84",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "runeya": "./index.js"
@@ -7702,13 +7702,23 @@ function getDeviceName() {
7702
7702
  const suffix = dir && dir !== ".runeya" ? ` \xB7 ${dir}` : "";
7703
7703
  return `${host}${suffix}`.slice(0, 64);
7704
7704
  }
7705
- function isLocalOrigin(url) {
7705
+ function callbackForReturnTo(url) {
7706
+ let parsed;
7706
7707
  try {
7707
- const { protocol, hostname: hostname2 } = new URL(url);
7708
- return (protocol === "http:" || protocol === "https:") && (hostname2 === "localhost" || hostname2 === "127.0.0.1" || hostname2 === "[::1]");
7708
+ parsed = new URL(url);
7709
7709
  } catch {
7710
- return false;
7710
+ return null;
7711
+ }
7712
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return null;
7713
+ const { hostname: hostname2, port } = parsed;
7714
+ if (hostname2 === "localhost" || hostname2 === "127.0.0.1" || hostname2 === "[::1]") {
7715
+ return `http://127.0.0.1:${env.PORT}/api/cloud/callback`;
7711
7716
  }
7717
+ if (!env.RUNEYA_LAN_PROXY) return null;
7718
+ const effectivePort = port || (parsed.protocol === "https:" ? "443" : "80");
7719
+ if (effectivePort !== String(env.PORT)) return null;
7720
+ if (!lanIps().includes(hostname2)) return null;
7721
+ return `${parsed.origin}/api/cloud/callback`;
7712
7722
  }
7713
7723
  async function cloudFetch2(path, init = {}) {
7714
7724
  try {
@@ -7727,11 +7737,14 @@ function isAllowedProxyPath(path) {
7727
7737
  var cloudAuthRouter = router({
7728
7738
  /** Build the cloud authorization URL to open in the browser. */
7729
7739
  startLogin: protectedProcedure.input(z16.object({ returnTo: z16.string().url().max(2048) })).mutation(async ({ input }) => {
7730
- if (!isLocalOrigin(input.returnTo)) {
7731
- throw new TRPCError11({ code: "BAD_REQUEST", message: "returnTo must be a local origin." });
7740
+ const callback = callbackForReturnTo(input.returnTo);
7741
+ if (!callback) {
7742
+ throw new TRPCError11({
7743
+ code: "BAD_REQUEST",
7744
+ message: env.RUNEYA_LAN_PROXY ? "returnTo must be this machine, on the server port." : "returnTo must be a local origin."
7745
+ });
7732
7746
  }
7733
7747
  const state = cloudSessionStore.createState(input.returnTo);
7734
- const callback = `http://127.0.0.1:${env.PORT}/api/cloud/callback`;
7735
7748
  const url = `${getCloudAppUrl()}/link-local?callback=${encodeURIComponent(callback)}&state=${encodeURIComponent(state)}`;
7736
7749
  return { url };
7737
7750
  }),
@@ -18253,4 +18266,4 @@ export {
18253
18266
  pullEnv,
18254
18267
  registerInstance
18255
18268
  };
18256
- //# sourceMappingURL=src-OHWIFAND.js.map
18269
+ //# sourceMappingURL=src-BWQ4J4D5.js.map