@runeya/runeya 2.0.84 → 2.0.85

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-BWQ4J4D5.js");
282
+ const { createLocalServer, pullEnv, PullEnvError, registerInstance } = await import("./src-URY4IL2E.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.84",
3
+ "version": "2.0.85",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "runeya": "./index.js"
@@ -408,9 +408,20 @@ var authMiddleware = t.middleware(async ({ ctx, next }) => {
408
408
  });
409
409
  var protectedProcedure = t.procedure.use(authMiddleware);
410
410
  var LOOPBACK = /* @__PURE__ */ new Set(["127.0.0.1", "::1", "::ffff:127.0.0.1"]);
411
- function requireLoopback(ctx) {
412
- if (!ctx.remoteAddress || !LOOPBACK.has(ctx.remoteAddress)) {
413
- throw new TRPCError({ code: "FORBIDDEN", message: "This route only answers the local machine." });
411
+ async function requireLoopbackOrToken(ctx) {
412
+ if (ctx.remoteAddress && LOOPBACK.has(ctx.remoteAddress)) return;
413
+ if (isCiMode()) return;
414
+ const authorization = ctx.authorization;
415
+ if (!authorization?.startsWith("Bearer ")) {
416
+ throw new TRPCError({
417
+ code: "FORBIDDEN",
418
+ message: "This route answers the local machine, or a signed-in app."
419
+ });
420
+ }
421
+ try {
422
+ await verifyJwt(authorization.slice(7));
423
+ } catch {
424
+ throw new TRPCError({ code: "UNAUTHORIZED", message: "Invalid or expired token" });
414
425
  }
415
426
  }
416
427
  function requireServiceAction(ctx, serviceId, action) {
@@ -603,7 +614,7 @@ var appUpdateRouter = router({
603
614
  ready: z2.boolean()
604
615
  })
605
616
  ).query(async ({ ctx }) => {
606
- requireLoopback(ctx);
617
+ await requireLoopbackOrToken(ctx);
607
618
  const npmPath = resolveNpm();
608
619
  const npmVersion = await probeVersion(npmPath, ["--version"]);
609
620
  const globalPrefix = npmVersion ? await probeVersion(npmPath, ["prefix", "-g"]) : null;
@@ -630,7 +641,7 @@ var appUpdateRouter = router({
630
641
  installedVersion: z2.string().nullable()
631
642
  })
632
643
  ).mutation(async ({ ctx }) => {
633
- requireLoopback(ctx);
644
+ await requireLoopbackOrToken(ctx);
634
645
  requireDesktop();
635
646
  const npmPath = resolveNpm();
636
647
  try {
@@ -655,8 +666,8 @@ var appUpdateRouter = router({
655
666
  * quelques instants — le démarrage réessaie déjà sur EADDRINUSE, c'est ce qui
656
667
  * rend ce relais possible sans temporisation ici.
657
668
  */
658
- restart: publicProcedure.output(z2.object({ restarting: z2.literal(true), version: z2.string() })).mutation(({ ctx }) => {
659
- requireLoopback(ctx);
669
+ restart: publicProcedure.output(z2.object({ restarting: z2.literal(true), version: z2.string() })).mutation(async ({ ctx }) => {
670
+ await requireLoopbackOrToken(ctx);
660
671
  requireDesktop();
661
672
  const child = spawn(process.execPath, process.argv.slice(1), {
662
673
  detached: true,
@@ -18266,4 +18277,4 @@ export {
18266
18277
  pullEnv,
18267
18278
  registerInstance
18268
18279
  };
18269
- //# sourceMappingURL=src-BWQ4J4D5.js.map
18280
+ //# sourceMappingURL=src-URY4IL2E.js.map