unplugin-https-reverse-proxy 4.0.4 → 4.1.0-beta.2

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.
Files changed (47) hide show
  1. package/README.md +30 -6
  2. package/dist/{chunk-5R33PUJP.js → chunk-7CA3EIIX.js} +681 -223
  3. package/dist/{chunk-2P7SUCQ3.js → chunk-EY3HXBJ4.js} +0 -26
  4. package/dist/chunk-RKHJN6KY.js +53 -0
  5. package/dist/esbuild.cjs +781 -300
  6. package/dist/esbuild.js +3 -2
  7. package/dist/index.cjs +781 -300
  8. package/dist/index.js +3 -2
  9. package/dist/nuxt.cjs +779 -290
  10. package/dist/nuxt.js +5 -9
  11. package/dist/privileged-helper.cjs +668 -0
  12. package/dist/privileged-helper.d.cts +2 -0
  13. package/dist/privileged-helper.d.ts +2 -0
  14. package/dist/privileged-helper.js +641 -0
  15. package/dist/rollup.cjs +781 -300
  16. package/dist/rollup.js +3 -2
  17. package/dist/rspack.cjs +781 -300
  18. package/dist/rspack.js +3 -2
  19. package/dist/utils.cjs +0 -28
  20. package/dist/utils.d.cts +1 -3
  21. package/dist/utils.d.ts +1 -3
  22. package/dist/utils.js +1 -5
  23. package/dist/vite.cjs +781 -300
  24. package/dist/vite.js +3 -2
  25. package/dist/webpack.cjs +781 -300
  26. package/dist/webpack.js +3 -2
  27. package/package.json +1 -4
  28. package/src/caddy/caddyfile.ts +1 -0
  29. package/src/caddy/index.ts +183 -110
  30. package/src/caddy/privileged.ts +118 -0
  31. package/src/caddy/utils.ts +0 -43
  32. package/src/index.ts +1 -15
  33. package/src/nuxt.ts +1 -6
  34. package/src/privileged/bootstrap.ts +174 -0
  35. package/src/privileged/client.ts +287 -0
  36. package/src/privileged/entry.ts +45 -0
  37. package/src/privileged/hosts-file.ts +142 -0
  38. package/src/privileged/launch.ts +193 -0
  39. package/src/privileged/ports.ts +45 -0
  40. package/src/privileged/protocol.ts +111 -0
  41. package/src/privileged/server.ts +465 -0
  42. package/src/privileged/session.ts +114 -0
  43. package/src/privileged/validation.ts +38 -0
  44. package/src/privileged/windows-elevation.ts +80 -0
  45. package/src/privileged-helper.ts +109 -0
  46. package/src/utils.ts +0 -28
  47. package/src/host/index.ts +0 -52
package/README.md CHANGED
@@ -314,15 +314,39 @@ Please check [caddy path](https://github.com/zcf0508/unplugin-https-reverse-prox
314
314
  ## Usage
315
315
 
316
316
  ```bash
317
- # macOS
318
- sudo -E npm run dev # your dev script
319
- # ^ `-E` is important
320
-
321
- # windows
322
- # use powershell as administrator
317
+ # macOS / Linux / Windows
323
318
  npm run dev # your dev script
324
319
  ```
325
320
 
321
+ Run it as your normal user. The plugin starts a small privileged helper that
322
+ runs as administrator, and only that helper touches `/etc/hosts` and ports
323
+ 80/443. Your dev server, its caches and `node_modules` stay owned by you.
324
+
325
+ On macOS and Linux the plugin asks for your password once when the dev server
326
+ starts, then reuses the sudo credential for the rest of the session. If you
327
+ already ran `sudo -v` in the same terminal, no prompt is shown.
328
+
329
+ The helper restores the hosts entries by itself when the dev server exits,
330
+ including when it is killed or crashes.
331
+
332
+ ### Granting the permission once (optional)
333
+
334
+ To skip the password prompt entirely, allow the plugin's helper in
335
+ `/etc/sudoers.d/` (edit with `sudo visudo -f /etc/sudoers.d/uhrp`):
336
+
337
+ ```
338
+ yourname ALL=(root) NOPASSWD: /usr/bin/killall -HUP mDNSResponder
339
+ yourname ALL=(root) NOPASSWD: /usr/bin/install -m 644 -o root -g wheel /tmp/uhrp-hosts.* /etc/hosts
340
+ ```
341
+
342
+ The second rule only matters when the helper rewrites `/etc/hosts` through
343
+ `install`; adjust the paths to your platform.
344
+
345
+ ### Windows
346
+
347
+ Run `npm run dev` normally. Windows raises a UAC prompt once, when the helper
348
+ is started through `Start-Process -Verb RunAs`.
349
+
326
350
  If your broswer shows a not trusted certificate warning, please check the keychain.
327
351
 
328
352
  ![keychain](https://github.com/zcf0508/unplugin-https-reverse-proxy/blob/main/images/Snipaste_2023-11-16_16-59-55.png)