create-disposabl-app 0.11.0 → 0.13.0

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 (42) hide show
  1. package/dist/disposabl.js +14 -10
  2. package/dist/index.js +40 -2
  3. package/dist/templates/default/.github/scripts/disposabl.mjs +15 -1
  4. package/dist/templates/default/.github/scripts/platforms.sh +1 -1
  5. package/dist/templates/default/.github/scripts/release.sh +1 -1
  6. package/dist/templates/default/.github/workflows/pipeline.yml +30 -2
  7. package/dist/templates/default/apps/desktop/README.md +16 -4
  8. package/dist/templates/default/apps/desktop/build-ci.mjs +7 -0
  9. package/dist/templates/default/apps/desktop/forge.config.mts +8 -4
  10. package/dist/templates/default/apps/desktop/package.json +3 -2
  11. package/dist/templates/default/apps/desktop/publish-update.mjs +93 -0
  12. package/dist/templates/default/apps/desktop/src/declarations.d.ts +4 -0
  13. package/dist/templates/default/apps/desktop/src/main.ts +86 -1
  14. package/dist/templates/default/apps/desktop/src/updates.ts +123 -0
  15. package/dist/templates/default/apps/desktop/stage-update.mjs +70 -0
  16. package/dist/templates/default/apps/desktop/vite.main.config.mts +10 -0
  17. package/dist/templates/default/apps/web/src/routeTree.gen.ts +31 -0
  18. package/dist/templates/default/apps/web/src/router/mobile-login.tsx +84 -0
  19. package/dist/templates/default/bun.lock +7 -2
  20. package/dist/templates/default/package.json +1 -1
  21. package/dist/templates/default/packages/backend/convex/authSetup.ts +9 -1
  22. package/dist/templates/default/packages/backend/convex/desktopUpdates/validator.ts +62 -0
  23. package/dist/templates/default/packages/backend/convex/desktopUpdates.ts +216 -0
  24. package/dist/templates/default/packages/backend/convex/http.ts +6 -0
  25. package/dist/templates/default/packages/backend/convex/schema.ts +2 -0
  26. package/dist/templates/default/packages/cli/auth.ts +1 -20
  27. package/dist/templates/default/packages/cli/origin.ts +22 -0
  28. package/dist/templates/default/packages/disposabl-kit/lib/indexing.ts +1 -0
  29. package/dist/templates/default/packages/disposabl-kit/server/files-functions.ts +1 -1
  30. package/dist/templates/default/packages/disposabl-kit/server/lib/static.ts +7 -0
  31. package/dist/templates/default/packages/disposabl-kit/server/lib/telemetry.ts +62 -12
  32. package/dist/templates/default/packages/tests/README.md +2 -0
  33. package/dist/templates/default/packages/tests/ci-platform-selection.test.ts +53 -0
  34. package/dist/templates/default/packages/tests/desktop-publication.test.ts +251 -0
  35. package/dist/templates/default/packages/tests/desktop-updates.test.ts +200 -0
  36. package/dist/templates/default/packages/tests/flows/desktop-updates.e2e.ts +102 -0
  37. package/dist/templates/default/packages/tests/flows/files.e2e.ts +48 -0
  38. package/dist/templates/default/packages/tests/telemetry.test.ts +170 -0
  39. package/dist/templates/default/vendor/README.md +7 -4
  40. package/dist/templates/default/vendor/convex-auth-437831bd-disposabl.3.tgz +0 -0
  41. package/package.json +1 -1
  42. package/dist/templates/default/vendor/convex-auth-437831bd-disposabl.1.tgz +0 -0
@@ -186,3 +186,173 @@ test("page ingestion derives identity from the verified session, never the body"
186
186
  app.features.splice(0, app.features.length, ...originalFeatures);
187
187
  }
188
188
  });
189
+
190
+ test("deployment telemetry sends only approved platform, channel and elapsed time", async () => {
191
+ process.env.CONVEX_SITE_URL = config.productionConvexSiteUrl;
192
+ delete process.env.E2E_TELEMETRY_DISABLED;
193
+ delete process.env.POSTHOG_ENABLED;
194
+ let body: any;
195
+ globalThis.fetch = (async (_input, init) => {
196
+ body = JSON.parse(String(init?.body));
197
+ return new Response();
198
+ }) as typeof fetch;
199
+ await captureTelemetry(
200
+ "platform_deployment",
201
+ {
202
+ app_id: "private-app",
203
+ platform: "android",
204
+ channel: "preview",
205
+ outcome: "success",
206
+ time_since_app_creation_ms: 7200000,
207
+ run_number: 2,
208
+ run_attempt: 1,
209
+ prompt: "private",
210
+ url: "https://private.example",
211
+ } as any,
212
+ "owner",
213
+ config,
214
+ );
215
+ assert.equal(body.properties.time_since_app_creation_ms, 7200000);
216
+ assert.equal(body.properties.duration_ms, undefined);
217
+ assert.equal(body.properties.run_number, 2);
218
+ assert.equal(body.properties.run_attempt, 1);
219
+ assert.equal(body.properties.platform, "android");
220
+ assert.equal(body.properties.channel, "preview");
221
+ assert.equal(JSON.stringify(body).includes("private"), false);
222
+ const appId = body.properties.app_id;
223
+ assert.match(appId, /^[a-f0-9]{64}$/);
224
+ await captureTelemetry(
225
+ "app_created",
226
+ { app_id: "private-app" },
227
+ "owner",
228
+ config,
229
+ );
230
+ assert.equal(body.properties.app_id, appId);
231
+ await captureTelemetry(
232
+ "app_setup",
233
+ { app_id: "private-app", duration_ms: 400 },
234
+ "owner",
235
+ config,
236
+ );
237
+ assert.equal(body.properties.app_id, appId);
238
+ assert.equal(body.properties.duration_ms, 400);
239
+ await captureTelemetry(
240
+ "app_created",
241
+ { app_id: "another-app" },
242
+ "owner",
243
+ config,
244
+ );
245
+ assert.notEqual(body.properties.app_id, appId);
246
+ });
247
+
248
+ test("release transitions measure from creation and ignore duplicate reports", async () => {
249
+ const { report } = await import("../backend/convex/previews/internal");
250
+ const { default: appConfig } = await import("../../disposabl.json");
251
+ const features = [...appConfig.features];
252
+ const original = Date.now;
253
+ const scheduled: any[] = [];
254
+ let release: any = null;
255
+ const app = {
256
+ _id: "row",
257
+ _creationTime: 1000,
258
+ appId: "11111111-1111-4111-8111-111111111111",
259
+ userId: "owner",
260
+ githubOwner: "owner",
261
+ githubRepo: "repo",
262
+ platforms: ["web"],
263
+ };
264
+ process.env.DISPOSABL_ENVIRONMENT = "production";
265
+ process.env.POSTHOG_PROJECT_TOKEN = "token";
266
+ process.env.POSTHOG_HOST = "https://us.i.posthog.com";
267
+ delete process.env.E2E_TELEMETRY_DISABLED;
268
+ delete process.env.POSTHOG_ENABLED;
269
+ appConfig.features.push("analytics" as never);
270
+ Date.now = () => 6000;
271
+ const ctx = {
272
+ scheduler: {
273
+ runAfter: async (_delay: any, _fn: any, args: any) => {
274
+ scheduled.push(args);
275
+ },
276
+ },
277
+ db: {
278
+ query: (table: string) => ({
279
+ withIndex: () => ({
280
+ unique: async () => (table === "apps" ? app : release),
281
+ }),
282
+ }),
283
+ insert: async (_table: string, data: any) => {
284
+ release = { _id: "release", ...data };
285
+ },
286
+ patch: async (_table: string, _id: string, data: any) => {
287
+ release = { ...release, ...data };
288
+ },
289
+ },
290
+ };
291
+ const args = {
292
+ userId: "owner",
293
+ appId: "11111111-1111-4111-8111-111111111111",
294
+ githubOwner: "owner",
295
+ githubRepo: "repo",
296
+ reference: "main",
297
+ production: true,
298
+ platform: "web",
299
+ status: "ready",
300
+ run: { id: 1, attempt: 1, number: 1, commitSha: "sha", url: "private" },
301
+ };
302
+ try {
303
+ await (report as any)._handler(ctx, args);
304
+ await (report as any)._handler(ctx, args);
305
+ assert.equal(scheduled.length, 1);
306
+ assert.deepEqual(scheduled[0].properties, {
307
+ app_id: app.appId,
308
+ platform: "web",
309
+ channel: "production",
310
+ outcome: "success",
311
+ time_since_app_creation_ms: 5000,
312
+ run_number: 1,
313
+ run_attempt: 1,
314
+ });
315
+ Date.now = () => 604801000;
316
+ const failed = {
317
+ ...args,
318
+ status: "failed",
319
+ run: { ...args.run, id: 2, number: 2 },
320
+ };
321
+ await (report as any)._handler(ctx, failed);
322
+ await (report as any)._handler(ctx, failed);
323
+ assert.equal(scheduled.length, 2);
324
+ assert.equal(scheduled[1].properties.outcome, "error");
325
+ assert.equal(scheduled[1].properties.time_since_app_creation_ms, 604800000);
326
+ assert.equal(
327
+ scheduled[1].properties.app_id,
328
+ scheduled[0].properties.app_id,
329
+ );
330
+ assert.equal(scheduled[1].properties.run_number, 2);
331
+ // Older and duplicate reports cannot alter the latest attempt's observations.
332
+ await (report as any)._handler(ctx, args);
333
+ assert.equal(scheduled.length, 2);
334
+ await (report as any)._handler(ctx, {
335
+ ...failed,
336
+ status: "ready",
337
+ run: { ...failed.run, attempt: 2 },
338
+ });
339
+ assert.equal(scheduled[2].properties.run_attempt, 2);
340
+ assert.equal(scheduled[2].properties.outcome, "success");
341
+ // A same-attempt correction remains reconcilable by app/run/attempt/platform/channel.
342
+ await (report as any)._handler(ctx, {
343
+ ...failed,
344
+ run: { ...failed.run, attempt: 2 },
345
+ });
346
+ assert.equal(scheduled[3].properties.run_attempt, 2);
347
+ assert.equal(scheduled[3].properties.outcome, "error");
348
+ process.env.E2E_TELEMETRY_DISABLED = "1";
349
+ await (report as any)._handler(ctx, {
350
+ ...args,
351
+ run: { ...args.run, id: 3 },
352
+ });
353
+ assert.equal(scheduled.length, 4);
354
+ } finally {
355
+ Date.now = original;
356
+ appConfig.features.splice(0, appConfig.features.length, ...features);
357
+ }
358
+ });
@@ -1,6 +1,6 @@
1
1
  # Convex Auth snapshot
2
2
 
3
- `convex-auth-437831bd-disposabl.1.tgz` is `@convex-dev/auth` version `2.0.0-beta.0-reboot.437831bd-disposabl.1`, built from [convex/convex-auth](https://github.com/convex/convex-auth) commit [`437831bdd0990c9faac305f60354e53aec91cd36`](https://github.com/convex/convex-auth/commit/437831bdd0990c9faac305f60354e53aec91cd36), with the changes below. The archive contains source, compiled JavaScript, declarations, and the upstream Apache 2.0 license. SHA-256: `c36b22dc91c627fd6c7f11e7f91392ad7d18914807e58058b061cc771f876b58`.
3
+ `convex-auth-437831bd-disposabl.3.tgz` is `@convex-dev/auth` version `2.0.0-beta.0-reboot.437831bd-disposabl.3`, built from [convex/convex-auth](https://github.com/convex/convex-auth) commit [`437831bdd0990c9faac305f60354e53aec91cd36`](https://github.com/convex/convex-auth/commit/437831bdd0990c9faac305f60354e53aec91cd36), with the changes below. The archive contains source, compiled JavaScript, declarations, and the upstream Apache 2.0 license. SHA-256: `d98796ba391859edcf95892d8a66b919fdd5f4dbc355de3ee68186525d473c87`.
4
4
 
5
5
  Relative to that commit, the only source changes under `packages/core/src` are:
6
6
 
@@ -8,26 +8,29 @@ Relative to that commit, the only source changes under `packages/core/src` are:
8
8
  - `lib/oauth/dbHelpers.ts`: use `CALLBACK_URL` when set, otherwise retain the upstream callback URL.
9
9
  - `lib/oauth/authorize.ts`: accept an optional asynchronous `authorizationState` callback and use its result as the OAuth authorization URL's state; the original state remains with the browser.
10
10
  - `methods/google/server.ts`: expose and pass through that callback in `GoogleProviderOptions`.
11
+ - `component/public.ts`: add an app-server-only `exchangeSession` operation. It validates source ownership, revocation, inactivity, maximum lifetime and account existence, then uses the existing session issuer to create independent browser credentials. The application must authenticate the source or atomically redeem a single-use handoff before calling it. Component API metadata includes this operation.
12
+
13
+ - `browser/sessionManager.ts`: serialize session adoption with the existing cross-tab refresh mutex so an older refresh cannot overwrite a newly selected account.
11
14
 
12
15
  These extensions support password-only deployments and shared preview callbacks. The application signs and verifies the preview routing envelope; see [Google setup](../packages/disposabl-kit/GOOGLE_AUTH.md). They do not replace Convex Auth's PKCE or native state validation.
13
16
 
14
17
  ## Rebuild
15
18
 
16
- Use Node and pnpm versions compatible with the upstream checkout. The archive itself is the source of the four changes, so no separate install-time patch is required. From a clean checkout of the exact upstream commit, with this archive at `$AUTH_ARCHIVE`:
19
+ Use Node and pnpm versions compatible with the upstream checkout. The archive itself is the source of these changes, so no separate install-time patch is required. From a clean checkout of the exact upstream commit, with this archive at `$AUTH_ARCHIVE`:
17
20
 
18
21
  ```sh
19
22
  git checkout 437831bdd0990c9faac305f60354e53aec91cd36
20
23
  pnpm install --frozen-lockfile
21
24
  mkdir -p /tmp/disposabl-auth-source
22
25
  tar -xzf "$AUTH_ARCHIVE" -C /tmp/disposabl-auth-source
23
- for path in components/google/convex.config.ts lib/oauth/authorize.ts lib/oauth/dbHelpers.ts methods/google/server.ts; do
26
+ for path in components/google/convex.config.ts lib/oauth/authorize.ts lib/oauth/dbHelpers.ts methods/google/server.ts component/public.ts component/_generated/component.ts browser/sessionManager.ts; do
24
27
  cp "/tmp/disposabl-auth-source/package/src/$path" "packages/core/src/$path"
25
28
  done
26
29
  git diff -- packages/core/src
27
30
  pnpm --filter @convex-dev/auth build
28
31
  cp /tmp/disposabl-auth-source/package/LICENSE packages/core/LICENSE
29
32
  cd packages/core
30
- npm pkg set version=2.0.0-beta.0-reboot.437831bd-disposabl.1
33
+ npm pkg set version=2.0.0-beta.0-reboot.437831bd-disposabl.3
31
34
  npm pack --ignore-scripts
32
35
  ```
33
36
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-disposabl-app",
3
- "version": "0.11.0",
3
+ "version": "0.13.0",
4
4
  "description": "Create a Disposabl app",
5
5
  "type": "module",
6
6
  "license": "MIT",