@openparachute/hub 0.5.13 → 0.5.14-rc.10

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 (101) hide show
  1. package/README.md +109 -15
  2. package/package.json +2 -2
  3. package/src/__tests__/account-home-ui.test.ts +205 -0
  4. package/src/__tests__/admin-handlers.test.ts +74 -0
  5. package/src/__tests__/admin-host-admin-token.test.ts +62 -0
  6. package/src/__tests__/admin-vault-admin-token.test.ts +44 -0
  7. package/src/__tests__/admin-vaults.test.ts +70 -4
  8. package/src/__tests__/api-account.test.ts +191 -1
  9. package/src/__tests__/api-mint-token.test.ts +682 -3
  10. package/src/__tests__/api-modules-config.test.ts +16 -10
  11. package/src/__tests__/api-modules-ops.test.ts +97 -0
  12. package/src/__tests__/api-modules.test.ts +100 -83
  13. package/src/__tests__/api-ready.test.ts +135 -0
  14. package/src/__tests__/api-revoke-token.test.ts +384 -0
  15. package/src/__tests__/api-users.test.ts +390 -13
  16. package/src/__tests__/chrome-strip.test.ts +15 -15
  17. package/src/__tests__/cli.test.ts +7 -5
  18. package/src/__tests__/cloudflare-detect.test.ts +60 -5
  19. package/src/__tests__/expose-auth-preflight.test.ts +58 -50
  20. package/src/__tests__/expose-cloudflare.test.ts +114 -3
  21. package/src/__tests__/expose-interactive.test.ts +10 -4
  22. package/src/__tests__/expose-public-auto.test.ts +5 -1
  23. package/src/__tests__/expose.test.ts +49 -1
  24. package/src/__tests__/hub-db.test.ts +194 -29
  25. package/src/__tests__/hub-server.test.ts +322 -33
  26. package/src/__tests__/hub.test.ts +11 -0
  27. package/src/__tests__/init.test.ts +827 -0
  28. package/src/__tests__/lifecycle.test.ts +33 -1
  29. package/src/__tests__/migrate.test.ts +433 -51
  30. package/src/__tests__/notes-redirect.test.ts +20 -20
  31. package/src/__tests__/oauth-handlers.test.ts +1060 -29
  32. package/src/__tests__/oauth-ui.test.ts +12 -1
  33. package/src/__tests__/proxy-error-ui.test.ts +212 -0
  34. package/src/__tests__/proxy-state.test.ts +192 -0
  35. package/src/__tests__/resource-binding.test.ts +97 -0
  36. package/src/__tests__/scope-explanations.test.ts +36 -0
  37. package/src/__tests__/serve.test.ts +9 -9
  38. package/src/__tests__/services-manifest.test.ts +40 -40
  39. package/src/__tests__/setup-wizard.test.ts +1114 -66
  40. package/src/__tests__/setup.test.ts +1 -1
  41. package/src/__tests__/status.test.ts +39 -0
  42. package/src/__tests__/users.test.ts +396 -9
  43. package/src/__tests__/vault-auth-status.test.ts +271 -11
  44. package/src/__tests__/vault-hub-origin-env.test.ts +126 -0
  45. package/src/__tests__/well-known.test.ts +9 -9
  46. package/src/__tests__/wizard.test.ts +372 -0
  47. package/src/account-home-ui.ts +547 -0
  48. package/src/admin-handlers.ts +49 -17
  49. package/src/admin-host-admin-token.ts +25 -0
  50. package/src/admin-login-ui.ts +4 -4
  51. package/src/admin-vault-admin-token.ts +17 -0
  52. package/src/admin-vaults.ts +48 -15
  53. package/src/api-account.ts +72 -6
  54. package/src/api-mint-token.ts +132 -24
  55. package/src/api-modules-ops.ts +52 -16
  56. package/src/api-modules.ts +31 -14
  57. package/src/api-ready.ts +102 -0
  58. package/src/api-revoke-token.ts +107 -21
  59. package/src/api-users.ts +497 -58
  60. package/src/bun-link.ts +55 -0
  61. package/src/chrome-strip.ts +6 -6
  62. package/src/cli.ts +93 -24
  63. package/src/cloudflare/config.ts +10 -4
  64. package/src/cloudflare/detect.ts +73 -6
  65. package/src/commands/expose-auth-preflight.ts +55 -63
  66. package/src/commands/expose-cloudflare.ts +114 -10
  67. package/src/commands/expose-interactive.ts +10 -11
  68. package/src/commands/expose-public-auto.ts +6 -4
  69. package/src/commands/expose.ts +8 -0
  70. package/src/commands/init.ts +563 -0
  71. package/src/commands/install.ts +41 -23
  72. package/src/commands/lifecycle.ts +12 -0
  73. package/src/commands/migrate.ts +293 -41
  74. package/src/commands/status.ts +10 -1
  75. package/src/commands/wizard.ts +843 -0
  76. package/src/env-file.ts +10 -0
  77. package/src/help.ts +157 -17
  78. package/src/hub-db.ts +42 -0
  79. package/src/hub-server.ts +136 -23
  80. package/src/hub-settings.ts +13 -2
  81. package/src/hub.ts +16 -9
  82. package/src/notes-redirect.ts +5 -5
  83. package/src/oauth-handlers.ts +342 -173
  84. package/src/oauth-ui.ts +28 -2
  85. package/src/proxy-error-ui.ts +506 -0
  86. package/src/proxy-state.ts +131 -0
  87. package/src/resource-binding.ts +134 -0
  88. package/src/scope-attenuation.ts +85 -0
  89. package/src/scope-explanations.ts +94 -5
  90. package/src/service-spec.ts +39 -18
  91. package/src/setup-wizard.ts +1173 -117
  92. package/src/users.ts +307 -29
  93. package/src/vault/auth-status.ts +152 -25
  94. package/src/vault-hub-origin-env.ts +100 -0
  95. package/web/ui/dist/assets/index-2SSK7JbM.js +61 -0
  96. package/web/ui/dist/assets/index-B28SdMSz.css +1 -0
  97. package/web/ui/dist/index.html +2 -2
  98. package/src/__tests__/vault-tokens-create-interactive.test.ts +0 -183
  99. package/src/commands/vault-tokens-create-interactive.ts +0 -143
  100. package/web/ui/dist/assets/index-7DtAXz7y.css +0 -1
  101. package/web/ui/dist/assets/index-Dzrbe6EP.js +0 -61
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Tests for the `/notes/*` → `/app/notes/*` redirect helper (Notes-as-app
2
+ * Tests for the `/notes/*` → `/surface/notes/*` redirect helper (Notes-as-app
3
3
  * migration Phase 2, parachute-app design doc §16).
4
4
  *
5
5
  * Covers the path-match predicate, the target-URL builder, the DB-aware
@@ -52,30 +52,30 @@ describe("notes-redirect — isLegacyNotesPath", () => {
52
52
  });
53
53
 
54
54
  describe("notes-redirect — buildNotesRedirectTarget", () => {
55
- test("rewrites the bare path /notes → /app/notes", () => {
56
- expect(buildNotesRedirectTarget("/notes", "")).toBe("/app/notes");
55
+ test("rewrites the bare path /notes → /surface/notes", () => {
56
+ expect(buildNotesRedirectTarget("/notes", "")).toBe("/surface/notes");
57
57
  });
58
58
 
59
- test("rewrites the trailing-slash form /notes/ → /app/notes/", () => {
60
- expect(buildNotesRedirectTarget("/notes/", "")).toBe("/app/notes/");
59
+ test("rewrites the trailing-slash form /notes/ → /surface/notes/", () => {
60
+ expect(buildNotesRedirectTarget("/notes/", "")).toBe("/surface/notes/");
61
61
  });
62
62
 
63
- test("rewrites a sub-path /notes/sw.js → /app/notes/sw.js", () => {
64
- expect(buildNotesRedirectTarget("/notes/sw.js", "")).toBe("/app/notes/sw.js");
63
+ test("rewrites a sub-path /notes/sw.js → /surface/notes/sw.js", () => {
64
+ expect(buildNotesRedirectTarget("/notes/sw.js", "")).toBe("/surface/notes/sw.js");
65
65
  });
66
66
 
67
67
  test("preserves a single-param query string", () => {
68
- expect(buildNotesRedirectTarget("/notes/foo", "?q=1")).toBe("/app/notes/foo?q=1");
68
+ expect(buildNotesRedirectTarget("/notes/foo", "?q=1")).toBe("/surface/notes/foo?q=1");
69
69
  });
70
70
 
71
71
  test("preserves a multi-param query string verbatim (no re-encoding)", () => {
72
72
  expect(buildNotesRedirectTarget("/notes/foo", "?a=1&b=hello%20world")).toBe(
73
- "/app/notes/foo?a=1&b=hello%20world",
73
+ "/surface/notes/foo?a=1&b=hello%20world",
74
74
  );
75
75
  });
76
76
 
77
77
  test("preserves the bare /notes + query (no trailing slash on rewrite)", () => {
78
- expect(buildNotesRedirectTarget("/notes", "?next=foo")).toBe("/app/notes?next=foo");
78
+ expect(buildNotesRedirectTarget("/notes", "?next=foo")).toBe("/surface/notes?next=foo");
79
79
  });
80
80
  });
81
81
 
@@ -90,13 +90,13 @@ describe("notes-redirect — maybeRedirectNotes", () => {
90
90
  // Absent DB defaults to redirect-on — the migration-default direction.
91
91
  // Operators flipping the opt-out flag have a hub-with-DB; the default
92
92
  // doesn't depend on DB readiness.
93
- expect(maybeRedirectNotes("/notes/foo", "?q=1", undefined)).toBe("/app/notes/foo?q=1");
93
+ expect(maybeRedirectNotes("/notes/foo", "?q=1", undefined)).toBe("/surface/notes/foo?q=1");
94
94
  });
95
95
 
96
96
  test("returns the target URL when the path matches and the flag is absent (default)", () => {
97
97
  const db = openHubDb(hubDbPath(dir));
98
98
  try {
99
- expect(maybeRedirectNotes("/notes/foo", "", db)).toBe("/app/notes/foo");
99
+ expect(maybeRedirectNotes("/notes/foo", "", db)).toBe("/surface/notes/foo");
100
100
  } finally {
101
101
  db.close();
102
102
  }
@@ -109,7 +109,7 @@ describe("notes-redirect — maybeRedirectNotes", () => {
109
109
  try {
110
110
  setNotesRedirectDisabled(db, true);
111
111
  setNotesRedirectDisabled(db, false);
112
- expect(maybeRedirectNotes("/notes/foo", "", db)).toBe("/app/notes/foo");
112
+ expect(maybeRedirectNotes("/notes/foo", "", db)).toBe("/surface/notes/foo");
113
113
  } finally {
114
114
  db.close();
115
115
  }
@@ -144,18 +144,18 @@ describe("notes-redirect — logNotesRedirect (throttled)", () => {
144
144
 
145
145
  test("logs once on the first hit", () => {
146
146
  const lines: string[] = [];
147
- logNotesRedirect("/notes/foo", "/app/notes/foo", {
147
+ logNotesRedirect("/notes/foo", "/surface/notes/foo", {
148
148
  now: () => 1_000_000,
149
149
  log: (m) => lines.push(m),
150
150
  });
151
- expect(lines).toEqual(["[notes-migration] redirect /notes/foo → /app/notes/foo"]);
151
+ expect(lines).toEqual(["[notes-migration] redirect /notes/foo → /surface/notes/foo"]);
152
152
  });
153
153
 
154
154
  test("throttles repeated hits to the same path within the window", () => {
155
155
  const lines: string[] = [];
156
156
  // Five hits within a 10-second span — well inside the 60-second window.
157
157
  for (let i = 0; i < 5; i++) {
158
- logNotesRedirect("/notes/foo", "/app/notes/foo", {
158
+ logNotesRedirect("/notes/foo", "/surface/notes/foo", {
159
159
  now: () => 1_000_000 + i * 2_000,
160
160
  log: (m) => lines.push(m),
161
161
  });
@@ -165,12 +165,12 @@ describe("notes-redirect — logNotesRedirect (throttled)", () => {
165
165
 
166
166
  test("re-logs the same path after the window expires", () => {
167
167
  const lines: string[] = [];
168
- logNotesRedirect("/notes/foo", "/app/notes/foo", {
168
+ logNotesRedirect("/notes/foo", "/surface/notes/foo", {
169
169
  now: () => 1_000_000,
170
170
  log: (m) => lines.push(m),
171
171
  });
172
172
  // 60_001 ms later → window has rolled, log fires again.
173
- logNotesRedirect("/notes/foo", "/app/notes/foo", {
173
+ logNotesRedirect("/notes/foo", "/surface/notes/foo", {
174
174
  now: () => 1_000_000 + 60_001,
175
175
  log: (m) => lines.push(m),
176
176
  });
@@ -179,11 +179,11 @@ describe("notes-redirect — logNotesRedirect (throttled)", () => {
179
179
 
180
180
  test("logs distinct paths independently (per-path bucket)", () => {
181
181
  const lines: string[] = [];
182
- logNotesRedirect("/notes/foo", "/app/notes/foo", {
182
+ logNotesRedirect("/notes/foo", "/surface/notes/foo", {
183
183
  now: () => 1_000_000,
184
184
  log: (m) => lines.push(m),
185
185
  });
186
- logNotesRedirect("/notes/bar", "/app/notes/bar", {
186
+ logNotesRedirect("/notes/bar", "/surface/notes/bar", {
187
187
  now: () => 1_000_000,
188
188
  log: (m) => lines.push(m),
189
189
  });