create-disposabl-app 0.17.6 → 0.18.1
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/README.md +4 -0
- package/dist/disposabl.js +42 -9
- package/dist/index.js +64 -18
- package/dist/templates/default/apps/mobile/README.md +40 -0
- package/dist/templates/default/apps/mobile/app.config.js +46 -2
- package/dist/templates/default/apps/mobile/app.json +2 -1
- package/dist/templates/default/apps/mobile/package.json +7 -1
- package/dist/templates/default/apps/mobile/plugins/with-android-signing.js +23 -1
- package/dist/templates/default/apps/mobile/scripts/fresh-android.mjs +24 -0
- package/dist/templates/default/apps/mobile/scripts/play-aab.mjs +176 -0
- package/dist/templates/default/apps/mobile/scripts/verify-play-aab.mjs +77 -0
- package/dist/templates/default/bun.lock +12 -3
- package/dist/templates/default/bunfig.toml +1 -0
- package/dist/templates/default/package.json +6 -2
- package/dist/templates/default/packages/backend/convex/files/guard.ts +2 -0
- package/dist/templates/default/packages/backend/convex/http.ts +11 -1
- package/dist/templates/default/packages/backend/convex/schema.ts +10 -0
- package/dist/templates/default/packages/backend/convex/telemetry.ts +12 -16
- package/dist/templates/default/packages/cli/telemetry.ts +40 -3
- package/dist/templates/default/packages/disposabl-kit/PAYMENTS.md +2 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/account-deletion.tsx +111 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/consent-identity.tsx +50 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/legal-page.tsx +12 -1
- package/dist/templates/default/packages/disposabl-kit/client/lib/telemetry-lease.ts +200 -0
- package/dist/templates/default/packages/disposabl-kit/client/lib/telemetry.ts +8 -1
- package/dist/templates/default/packages/disposabl-kit/client/routes/consent.tsx +23 -1
- package/dist/templates/default/packages/disposabl-kit/client/routes/legal/delete-account.tsx +6 -1
- package/dist/templates/default/packages/disposabl-kit/client/routes/legal/support.tsx +33 -0
- package/dist/templates/default/packages/disposabl-kit/client/routes/pricing.tsx +13 -0
- package/dist/templates/default/packages/disposabl-kit/client/routes/route.tsx +19 -2
- package/dist/templates/default/packages/disposabl-kit/client/vite.config.ts +1 -0
- package/dist/templates/default/packages/disposabl-kit/legal/README.md +1 -1
- package/dist/templates/default/packages/disposabl-kit/legal/config.ts +32 -4
- package/dist/templates/default/packages/disposabl-kit/legal/index.ts +2 -2
- package/dist/templates/default/packages/disposabl-kit/legal/publisher.ts +6 -0
- package/dist/templates/default/packages/disposabl-kit/mobile/billing/account-billing.tsx +13 -9
- package/dist/templates/default/packages/disposabl-kit/mobile/billing/paywall.ts +28 -4
- package/dist/templates/default/packages/disposabl-kit/mobile/billing/policy.ts +31 -14
- package/dist/templates/default/packages/disposabl-kit/mobile/billing/web-checkout.ts +45 -34
- package/dist/templates/default/packages/disposabl-kit/mobile/components/settings-links.tsx +14 -0
- package/dist/templates/default/packages/disposabl-kit/mobile/expo-plugin.cjs +3 -0
- package/dist/templates/default/packages/disposabl-kit/mobile/index.ts +4 -0
- package/dist/templates/default/packages/disposabl-kit/mobile/layout.tsx +55 -8
- package/dist/templates/default/packages/disposabl-kit/server/billing-functions.ts +147 -124
- package/dist/templates/default/packages/disposabl-kit/server/billing-handoff.ts +113 -95
- package/dist/templates/default/packages/disposabl-kit/server/files-functions.ts +70 -54
- package/dist/templates/default/packages/disposabl-kit/server/http.ts +49 -21
- package/dist/templates/default/packages/disposabl-kit/server/lib/platform-spec.ts +25 -1
- package/dist/templates/default/packages/disposabl-kit/server/lib/telemetry.ts +375 -69
- package/dist/templates/default/packages/sdk/README.md +2 -0
- package/dist/templates/default/packages/sdk/src/analytics.ts +7 -2
- package/dist/templates/default/packages/skill/SKILL.md +4 -2
- package/dist/templates/default/packages/skill/references/store-submissions.md +25 -0
- package/dist/templates/default/packages/tests/README.md +28 -1
- package/dist/templates/default/packages/tests/account-deletion-ui.test.ts +21 -0
- package/dist/templates/default/packages/tests/auth-email-setup.test.ts +45 -0
- package/dist/templates/default/packages/tests/components/account-deletion.test.mjs +82 -0
- package/dist/templates/default/packages/tests/components/consent-identity.test.mjs +175 -0
- package/dist/templates/default/packages/tests/components/mobile-deletion-link.test.mjs +40 -0
- package/dist/templates/default/packages/tests/components/mobile-theme.test.mjs +56 -3
- package/dist/templates/default/packages/tests/components/pricing-identity.test.mjs +113 -0
- package/dist/templates/default/packages/tests/components/support-page.test.mjs +36 -0
- package/dist/templates/default/packages/tests/consent-identity.test.ts +13 -0
- package/dist/templates/default/packages/tests/desktop-macos-release.test.ts +153 -145
- package/dist/templates/default/packages/tests/flows/legal.e2e.ts +40 -3
- package/dist/templates/default/packages/tests/helpers/auth-email-setup/probe.test.mjs +44 -0
- package/dist/templates/default/packages/tests/helpers/mobile-simulator/preflight.py +80 -0
- package/dist/templates/default/packages/tests/helpers/mobile-simulator/test_preflight.py +57 -0
- package/dist/templates/default/packages/tests/mobile-android-e2e-network.test.ts +81 -1
- package/dist/templates/default/packages/tests/mobile-android-signing.test.ts +52 -0
- package/dist/templates/default/packages/tests/mobile-deletion-link.test.ts +21 -0
- package/dist/templates/default/packages/tests/mobile-ios-reachability-pin.test.ts +84 -0
- package/dist/templates/default/packages/tests/mobile-simulator-preflight.test.ts +16 -0
- package/dist/templates/default/packages/tests/native-billing.test.ts +288 -0
- package/dist/templates/default/packages/tests/pricing-identity.test.ts +13 -0
- package/dist/templates/default/packages/tests/sdk-analytics.test.ts +28 -2
- package/dist/templates/default/packages/tests/support-page.test.ts +13 -0
- package/dist/templates/default/packages/tests/telemetry.test.ts +389 -18
- package/dist/templates/default/packages/tests/ui-telemetry-lease.test.ts +346 -0
- package/dist/templates/default/patches/convex-mcp-account-erasure-alpha7.patch +466 -0
- package/dist/templates/default/vendor/README.md +61 -1
- package/dist/templates/default/vendor/convex-auth-040d8e36-disposabl.1.patch +890 -0
- package/dist/templates/default/vendor/convex-auth-040d8e36-disposabl.1.tgz +0 -0
- package/dist/templates/default/vendor/convex-auth-040d8e36-disposabl.2.patch +1060 -0
- package/dist/templates/default/vendor/convex-auth-040d8e36-disposabl.2.tgz +0 -0
- package/dist/templates/default/vendor/convex-auth-437831bd-disposabl.4.tgz +0 -0
- package/dist/templates/default/vendor/convex-auth-437831bd-disposabl.5.tgz +0 -0
- package/dist/templates/default/vendor/convex-auth-437831bd-disposabl.6.tgz +0 -0
- package/dist/templates/default/vendor/convex-auth-437831bd-disposabl.7.tgz +0 -0
- package/dist/templates/default/vendor/convex-auth-437831bd-disposabl.8.tgz +0 -0
- package/dist/templates/default/vendor/convex-auth-core-erasure-disposabl.6.patch +115 -0
- package/dist/templates/default/vendor/convex-auth-identity-cutoff-disposabl.7.patch +442 -0
- package/dist/templates/default/vendor/convex-auth-identity-erasure-disposabl.8.md +11 -0
- package/dist/templates/default/vendor/convex-auth-identity-erasure-disposabl.8.patch +78 -0
- package/dist/templates/default/vendor/convex-auth-marker-disposabl.4.patch +169 -0
- package/dist/templates/default/vendor/convex-auth-marker-password-disposabl.5.patch +126 -0
- package/package.json +1 -1
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import config from "../../../../disposabl.json";
|
|
2
2
|
import { makeFunctionReference } from "convex/server";
|
|
3
3
|
import { v } from "convex/values";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
internalMutation,
|
|
6
|
+
internalAction,
|
|
7
|
+
internalQuery,
|
|
8
|
+
type ActionCtx,
|
|
9
|
+
type MutationCtx,
|
|
10
|
+
type QueryCtx,
|
|
11
|
+
} from "../../../backend/convex/_generated/server";
|
|
5
12
|
|
|
6
13
|
export type TelemetryEvent =
|
|
7
14
|
| "api_operation"
|
|
@@ -81,62 +88,257 @@ const expireIdentityRef = makeFunctionReference<
|
|
|
81
88
|
{ id: string },
|
|
82
89
|
null
|
|
83
90
|
>("telemetry:expireIdentity");
|
|
91
|
+
const deliverLinkRef = makeFunctionReference<"action", { id: string }, null>(
|
|
92
|
+
"telemetry:deliverLink",
|
|
93
|
+
);
|
|
84
94
|
|
|
85
|
-
export const
|
|
95
|
+
export const createClaimIdentity = (
|
|
96
|
+
checkUser?: (ctx: MutationCtx, userId: string) => Promise<void>,
|
|
97
|
+
) =>
|
|
98
|
+
internalMutation({
|
|
99
|
+
args: {
|
|
100
|
+
hash: v.optional(v.string()),
|
|
101
|
+
newHash: v.string(),
|
|
102
|
+
userId: v.optional(v.string()),
|
|
103
|
+
link: v.optional(
|
|
104
|
+
v.object({
|
|
105
|
+
anonymous: v.string(),
|
|
106
|
+
distinct: v.string(),
|
|
107
|
+
eventId: v.string(),
|
|
108
|
+
}),
|
|
109
|
+
),
|
|
110
|
+
},
|
|
111
|
+
returns: v.union(v.boolean(), v.null(), v.literal("linked")),
|
|
112
|
+
handler: async (ctx, { hash, newHash, userId, link }) => {
|
|
113
|
+
if (userId !== undefined) await checkUser?.(ctx, userId);
|
|
114
|
+
const row = hash
|
|
115
|
+
? await ctx.db
|
|
116
|
+
.query("telemetryIdentities")
|
|
117
|
+
.withIndex("by_hash", (q) => q.eq("hash", hash))
|
|
118
|
+
.unique()
|
|
119
|
+
: null;
|
|
120
|
+
if (
|
|
121
|
+
row &&
|
|
122
|
+
row.expiresAt > Date.now() &&
|
|
123
|
+
(!row.userId || row.userId === userId)
|
|
124
|
+
) {
|
|
125
|
+
if (userId && !row.userId) {
|
|
126
|
+
await ctx.db.patch("telemetryIdentities", row._id, {
|
|
127
|
+
userId,
|
|
128
|
+
...(link
|
|
129
|
+
? {
|
|
130
|
+
link: {
|
|
131
|
+
...link,
|
|
132
|
+
createdAt: Date.now(),
|
|
133
|
+
attempts: 0,
|
|
134
|
+
retryAfter: Date.now(),
|
|
135
|
+
},
|
|
136
|
+
}
|
|
137
|
+
: {}),
|
|
138
|
+
});
|
|
139
|
+
if (link) {
|
|
140
|
+
await ctx.scheduler.runAfter(0, deliverLinkRef, { id: row._id });
|
|
141
|
+
// A scheduled action can fail before it reserves its own retry.
|
|
142
|
+
await ctx.scheduler.runAfter(30_000, deliverLinkRef, {
|
|
143
|
+
id: row._id,
|
|
144
|
+
});
|
|
145
|
+
return "linked";
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (
|
|
149
|
+
row.link &&
|
|
150
|
+
row.link.attempts >= 5 &&
|
|
151
|
+
Date.now() >= row.link.retryAfter
|
|
152
|
+
) {
|
|
153
|
+
await ctx.db.patch("telemetryIdentities", row._id, {
|
|
154
|
+
link: { ...row.link, attempts: 0, retryAfter: Date.now() },
|
|
155
|
+
});
|
|
156
|
+
await ctx.scheduler.runAfter(0, deliverLinkRef, { id: row._id });
|
|
157
|
+
await ctx.scheduler.runAfter(30_000, deliverLinkRef, { id: row._id });
|
|
158
|
+
}
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
const now = Date.now();
|
|
162
|
+
const bucket = await ctx.db
|
|
163
|
+
.query("telemetryIssuance")
|
|
164
|
+
.withIndex("by_key", (q) => q.eq("key", "global"))
|
|
165
|
+
.unique();
|
|
166
|
+
const tokens = bucket
|
|
167
|
+
? Math.min(
|
|
168
|
+
issuanceBurst,
|
|
169
|
+
bucket.tokens +
|
|
170
|
+
Math.max(0, now - bucket.updatedAt) / issuanceRefillMs,
|
|
171
|
+
)
|
|
172
|
+
: issuanceBurst;
|
|
173
|
+
if (tokens < 1) return null;
|
|
174
|
+
if (bucket) {
|
|
175
|
+
await ctx.db.patch("telemetryIssuance", bucket._id, {
|
|
176
|
+
tokens: tokens - 1,
|
|
177
|
+
updatedAt: now,
|
|
178
|
+
});
|
|
179
|
+
} else {
|
|
180
|
+
await ctx.db.insert("telemetryIssuance", {
|
|
181
|
+
key: "global",
|
|
182
|
+
tokens: tokens - 1,
|
|
183
|
+
updatedAt: now,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
const id = await ctx.db.insert("telemetryIdentities", {
|
|
187
|
+
hash: newHash,
|
|
188
|
+
expiresAt: Date.now() + identityTtl,
|
|
189
|
+
...(userId ? { userId } : {}),
|
|
190
|
+
});
|
|
191
|
+
await ctx.scheduler.runAfter(identityTtl, expireIdentityRef, { id });
|
|
192
|
+
return false;
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
export const claimIdentity = createClaimIdentity();
|
|
197
|
+
|
|
198
|
+
const linkValue = v.object({
|
|
199
|
+
anonymous: v.string(),
|
|
200
|
+
distinct: v.string(),
|
|
201
|
+
eventId: v.string(),
|
|
202
|
+
createdAt: v.number(),
|
|
203
|
+
attempts: v.number(),
|
|
204
|
+
retryAfter: v.number(),
|
|
205
|
+
});
|
|
206
|
+
export const createLinkLookup = (
|
|
207
|
+
checkUser?: (ctx: QueryCtx, userId: string) => Promise<void>,
|
|
208
|
+
) =>
|
|
209
|
+
internalQuery({
|
|
210
|
+
args: { id: v.id("telemetryIdentities") },
|
|
211
|
+
returns: v.union(linkValue, v.null()),
|
|
212
|
+
handler: async (ctx, { id }) => {
|
|
213
|
+
const row = await ctx.db.get("telemetryIdentities", id);
|
|
214
|
+
if (!row?.link || !row.userId) return null;
|
|
215
|
+
try {
|
|
216
|
+
await checkUser?.(ctx, row.userId);
|
|
217
|
+
} catch {
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
return row.link;
|
|
221
|
+
},
|
|
222
|
+
});
|
|
223
|
+
export const getLink = createLinkLookup();
|
|
224
|
+
export const finishLink = internalMutation({
|
|
86
225
|
args: {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
226
|
+
id: v.id("telemetryIdentities"),
|
|
227
|
+
eventId: v.string(),
|
|
228
|
+
success: v.boolean(),
|
|
90
229
|
},
|
|
91
|
-
returns: v.
|
|
92
|
-
handler: async (ctx, {
|
|
93
|
-
const row =
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
230
|
+
returns: v.null(),
|
|
231
|
+
handler: async (ctx, { id, eventId, success }) => {
|
|
232
|
+
const row = await ctx.db.get("telemetryIdentities", id);
|
|
233
|
+
if (!row?.link || row.link.eventId !== eventId) return null;
|
|
234
|
+
if (success)
|
|
235
|
+
await ctx.db.patch("telemetryIdentities", id, { link: undefined });
|
|
236
|
+
return null;
|
|
237
|
+
},
|
|
238
|
+
});
|
|
239
|
+
export const beginLink = internalMutation({
|
|
240
|
+
args: {
|
|
241
|
+
id: v.id("telemetryIdentities"),
|
|
242
|
+
eventId: v.string(),
|
|
243
|
+
attempts: v.number(),
|
|
244
|
+
},
|
|
245
|
+
returns: v.boolean(),
|
|
246
|
+
handler: async (ctx, { id, eventId, attempts }) => {
|
|
247
|
+
const row = await ctx.db.get("telemetryIdentities", id);
|
|
99
248
|
if (
|
|
100
|
-
row
|
|
101
|
-
row.
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
bucket.tokens +
|
|
117
|
-
Math.max(0, now - bucket.updatedAt) / issuanceRefillMs,
|
|
118
|
-
)
|
|
119
|
-
: issuanceBurst;
|
|
120
|
-
if (tokens < 1) return null;
|
|
121
|
-
if (bucket) {
|
|
122
|
-
await ctx.db.patch("telemetryIssuance", bucket._id, {
|
|
123
|
-
tokens: tokens - 1,
|
|
124
|
-
updatedAt: now,
|
|
125
|
-
});
|
|
126
|
-
} else {
|
|
127
|
-
await ctx.db.insert("telemetryIssuance", {
|
|
128
|
-
key: "global",
|
|
129
|
-
tokens: tokens - 1,
|
|
130
|
-
updatedAt: now,
|
|
249
|
+
!row?.link ||
|
|
250
|
+
row.link.eventId !== eventId ||
|
|
251
|
+
row.link.attempts !== attempts ||
|
|
252
|
+
attempts >= 5
|
|
253
|
+
)
|
|
254
|
+
return false;
|
|
255
|
+
await ctx.db.patch("telemetryIdentities", id, {
|
|
256
|
+
link: {
|
|
257
|
+
...row.link,
|
|
258
|
+
attempts: attempts + 1,
|
|
259
|
+
retryAfter: Date.now() + 5 * 60_000,
|
|
260
|
+
},
|
|
261
|
+
});
|
|
262
|
+
if (attempts + 1 < 5)
|
|
263
|
+
await ctx.scheduler.runAfter(2 ** (attempts + 1) * 1000, deliverLinkRef, {
|
|
264
|
+
id,
|
|
131
265
|
});
|
|
266
|
+
return true;
|
|
267
|
+
},
|
|
268
|
+
});
|
|
269
|
+
const getLinkRef = makeFunctionReference<
|
|
270
|
+
"query",
|
|
271
|
+
{ id: string },
|
|
272
|
+
{
|
|
273
|
+
anonymous: string;
|
|
274
|
+
distinct: string;
|
|
275
|
+
eventId: string;
|
|
276
|
+
createdAt: number;
|
|
277
|
+
attempts: number;
|
|
278
|
+
retryAfter: number;
|
|
279
|
+
} | null
|
|
280
|
+
>("telemetry:getLink");
|
|
281
|
+
const finishLinkRef = makeFunctionReference<
|
|
282
|
+
"mutation",
|
|
283
|
+
{ id: string; eventId: string; success: boolean },
|
|
284
|
+
null
|
|
285
|
+
>("telemetry:finishLink");
|
|
286
|
+
const beginLinkRef = makeFunctionReference<
|
|
287
|
+
"mutation",
|
|
288
|
+
{ id: string; eventId: string; attempts: number },
|
|
289
|
+
boolean
|
|
290
|
+
>("telemetry:beginLink");
|
|
291
|
+
export const deliverLink = internalAction({
|
|
292
|
+
args: { id: v.id("telemetryIdentities") },
|
|
293
|
+
returns: v.null(),
|
|
294
|
+
handler: async (ctx, { id }) => {
|
|
295
|
+
const link = await ctx.runQuery(getLinkRef, { id });
|
|
296
|
+
if (!link || link.attempts >= 5) return null;
|
|
297
|
+
if (
|
|
298
|
+
!(await ctx.runMutation(beginLinkRef, {
|
|
299
|
+
id,
|
|
300
|
+
eventId: link.eventId,
|
|
301
|
+
attempts: link.attempts,
|
|
302
|
+
}))
|
|
303
|
+
)
|
|
304
|
+
return null;
|
|
305
|
+
if (!(await ctx.runQuery(getLinkRef, { id }))) return null;
|
|
306
|
+
let success = false;
|
|
307
|
+
if (telemetryEnabled()) {
|
|
308
|
+
const token =
|
|
309
|
+
settings.analytics?.projectToken ?? process.env.POSTHOG_PROJECT_TOKEN!;
|
|
310
|
+
const host = settings.analytics?.host ?? process.env.POSTHOG_HOST!;
|
|
311
|
+
if (/^phc_[A-Za-z0-9_-]+$/.test(token)) {
|
|
312
|
+
try {
|
|
313
|
+
const response = await fetch(`${host}/capture/`, {
|
|
314
|
+
method: "POST",
|
|
315
|
+
redirect: "error",
|
|
316
|
+
signal: AbortSignal.timeout(2000),
|
|
317
|
+
headers: { "Content-Type": "application/json" },
|
|
318
|
+
body: JSON.stringify({
|
|
319
|
+
api_key: token,
|
|
320
|
+
event: "$identify",
|
|
321
|
+
uuid: link.eventId,
|
|
322
|
+
timestamp: new Date(link.createdAt).toISOString(),
|
|
323
|
+
properties: {
|
|
324
|
+
distinct_id: link.distinct,
|
|
325
|
+
$anon_distinct_id: link.anonymous,
|
|
326
|
+
$ip: "0.0.0.0",
|
|
327
|
+
},
|
|
328
|
+
}),
|
|
329
|
+
});
|
|
330
|
+
success = response.ok;
|
|
331
|
+
} catch {
|
|
332
|
+
/* Retry only this idempotent event. */
|
|
333
|
+
}
|
|
334
|
+
}
|
|
132
335
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
336
|
+
await ctx.runMutation(finishLinkRef, {
|
|
337
|
+
id,
|
|
338
|
+
eventId: link.eventId,
|
|
339
|
+
success,
|
|
137
340
|
});
|
|
138
|
-
|
|
139
|
-
return false;
|
|
341
|
+
return null;
|
|
140
342
|
},
|
|
141
343
|
});
|
|
142
344
|
|
|
@@ -165,6 +367,129 @@ async function opaqueId(value: string) {
|
|
|
165
367
|
).join("");
|
|
166
368
|
}
|
|
167
369
|
|
|
370
|
+
const bootstrapClaim = makeFunctionReference<
|
|
371
|
+
"mutation",
|
|
372
|
+
{
|
|
373
|
+
hash?: string;
|
|
374
|
+
newHash: string;
|
|
375
|
+
userId?: string;
|
|
376
|
+
link?: { anonymous: string; distinct: string; eventId: string };
|
|
377
|
+
},
|
|
378
|
+
boolean | null | "linked"
|
|
379
|
+
>("telemetry:claimIdentity");
|
|
380
|
+
const uuidPattern =
|
|
381
|
+
/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
382
|
+
const bootstrapHeaders = {
|
|
383
|
+
"Access-Control-Allow-Origin": "*",
|
|
384
|
+
"Access-Control-Allow-Headers": "Authorization, Content-Type",
|
|
385
|
+
"Access-Control-Allow-Methods": "POST, OPTIONS",
|
|
386
|
+
"Cache-Control": "no-store",
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
/** Shared by SDK bootstrap and categorized page capture; linking is transactional. */
|
|
390
|
+
export async function claimTelemetryClient(
|
|
391
|
+
ctx: ActionCtx,
|
|
392
|
+
existing: string | undefined,
|
|
393
|
+
userId: string | null,
|
|
394
|
+
) {
|
|
395
|
+
const projectToken =
|
|
396
|
+
settings.analytics?.projectToken ?? process.env.POSTHOG_PROJECT_TOKEN!;
|
|
397
|
+
const issued = crypto.randomUUID();
|
|
398
|
+
const anonymousDistinct = existing
|
|
399
|
+
? await opaqueId(`disposabl:${projectToken}:anonymous:${existing}`)
|
|
400
|
+
: undefined;
|
|
401
|
+
const userDistinct = userId
|
|
402
|
+
? await opaqueId(`disposabl:${projectToken}:${userId}`)
|
|
403
|
+
: undefined;
|
|
404
|
+
const claim = await ctx.runMutation(bootstrapClaim, {
|
|
405
|
+
...(existing ? { hash: await hashTelemetryIdentity(existing) } : {}),
|
|
406
|
+
newHash: await hashTelemetryIdentity(issued),
|
|
407
|
+
...(userId ? { userId } : {}),
|
|
408
|
+
...(anonymousDistinct && userDistinct
|
|
409
|
+
? {
|
|
410
|
+
link: {
|
|
411
|
+
anonymous: anonymousDistinct,
|
|
412
|
+
distinct: userDistinct,
|
|
413
|
+
eventId: crypto.randomUUID(),
|
|
414
|
+
},
|
|
415
|
+
}
|
|
416
|
+
: {}),
|
|
417
|
+
});
|
|
418
|
+
if (claim === null) return null;
|
|
419
|
+
const anonymousId = claim && existing ? existing : issued;
|
|
420
|
+
const chosenAnonymousDistinct = await opaqueId(
|
|
421
|
+
`disposabl:${projectToken}:anonymous:${anonymousId}`,
|
|
422
|
+
);
|
|
423
|
+
const distinctId = userId
|
|
424
|
+
? await opaqueId(`disposabl:${projectToken}:${userId}`)
|
|
425
|
+
: chosenAnonymousDistinct;
|
|
426
|
+
return { anonymousId, distinctId };
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/** The expiry governs client refresh; it cannot revoke the public project token. */
|
|
430
|
+
export async function bootstrapTelemetry(
|
|
431
|
+
ctx: ActionCtx,
|
|
432
|
+
request: Request,
|
|
433
|
+
getUser: (ctx: ActionCtx) => Promise<string | null>,
|
|
434
|
+
enabled: () => boolean = telemetryEnabled,
|
|
435
|
+
) {
|
|
436
|
+
let body: unknown;
|
|
437
|
+
try {
|
|
438
|
+
body = await request.json();
|
|
439
|
+
} catch {
|
|
440
|
+
return new Response(null, { status: 400, headers: bootstrapHeaders });
|
|
441
|
+
}
|
|
442
|
+
if (
|
|
443
|
+
!body ||
|
|
444
|
+
typeof body !== "object" ||
|
|
445
|
+
Array.isArray(body) ||
|
|
446
|
+
Object.keys(body).some((key) => key !== "anonymousId") ||
|
|
447
|
+
("anonymousId" in body &&
|
|
448
|
+
(typeof body.anonymousId !== "string" ||
|
|
449
|
+
!uuidPattern.test(body.anonymousId)))
|
|
450
|
+
)
|
|
451
|
+
return new Response(null, { status: 400, headers: bootstrapHeaders });
|
|
452
|
+
if (!enabled())
|
|
453
|
+
return new Response(null, { status: 204, headers: bootstrapHeaders });
|
|
454
|
+
const projectToken =
|
|
455
|
+
settings.analytics?.projectToken ?? process.env.POSTHOG_PROJECT_TOKEN!;
|
|
456
|
+
const host = settings.analytics?.host ?? process.env.POSTHOG_HOST!;
|
|
457
|
+
if (!/^phc_[A-Za-z0-9_-]+$/.test(projectToken))
|
|
458
|
+
return new Response(null, { status: 204, headers: bootstrapHeaders });
|
|
459
|
+
let userId: string | null;
|
|
460
|
+
try {
|
|
461
|
+
userId = await getUser(ctx);
|
|
462
|
+
} catch {
|
|
463
|
+
return new Response(null, { status: 401, headers: bootstrapHeaders });
|
|
464
|
+
}
|
|
465
|
+
if (request.headers.has("Authorization") && !userId)
|
|
466
|
+
return new Response(null, { status: 401, headers: bootstrapHeaders });
|
|
467
|
+
const existing =
|
|
468
|
+
"anonymousId" in body ? (body.anonymousId as string) : undefined;
|
|
469
|
+
let identity: Awaited<ReturnType<typeof claimTelemetryClient>>;
|
|
470
|
+
try {
|
|
471
|
+
identity = await claimTelemetryClient(ctx, existing, userId);
|
|
472
|
+
} catch {
|
|
473
|
+
return new Response(null, {
|
|
474
|
+
status: userId ? 401 : 503,
|
|
475
|
+
headers: bootstrapHeaders,
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
if (!identity)
|
|
479
|
+
return new Response(null, { status: 429, headers: bootstrapHeaders });
|
|
480
|
+
return Response.json(
|
|
481
|
+
{
|
|
482
|
+
enabled: true,
|
|
483
|
+
projectToken,
|
|
484
|
+
host,
|
|
485
|
+
...identity,
|
|
486
|
+
identified: !!userId,
|
|
487
|
+
expiresAt: Date.now() + 30_000,
|
|
488
|
+
},
|
|
489
|
+
{ headers: bootstrapHeaders },
|
|
490
|
+
);
|
|
491
|
+
}
|
|
492
|
+
|
|
168
493
|
/** Only trusted server callers can supply a user or app ID. */
|
|
169
494
|
export async function captureTelemetry(
|
|
170
495
|
event: TelemetryEvent,
|
|
@@ -238,25 +563,6 @@ export async function captureTelemetry(
|
|
|
238
563
|
.map((key) => [key, properties[key]]),
|
|
239
564
|
),
|
|
240
565
|
};
|
|
241
|
-
if (userId && anonymousId) {
|
|
242
|
-
const response = await fetch(`${host}/capture/`, {
|
|
243
|
-
method: "POST",
|
|
244
|
-
signal: AbortSignal.timeout(2000),
|
|
245
|
-
headers: { "Content-Type": "application/json" },
|
|
246
|
-
body: JSON.stringify({
|
|
247
|
-
api_key: token,
|
|
248
|
-
event: "$identify",
|
|
249
|
-
properties: {
|
|
250
|
-
distinct_id: identity,
|
|
251
|
-
$anon_distinct_id: await opaqueId(
|
|
252
|
-
`disposabl:${token}:anonymous:${anonymousId}`,
|
|
253
|
-
),
|
|
254
|
-
$ip: "0.0.0.0",
|
|
255
|
-
},
|
|
256
|
-
}),
|
|
257
|
-
});
|
|
258
|
-
if (!response.ok) return;
|
|
259
|
-
}
|
|
260
566
|
await fetch(`${host}/capture/`, {
|
|
261
567
|
method: "POST",
|
|
262
568
|
signal: AbortSignal.timeout(2000),
|
|
@@ -43,3 +43,5 @@ const result = await analytics.track("appsList", () => appsList());
|
|
|
43
43
|
Supply your own initialized `posthog` (or another sink); the SDK includes no project key or transport. Set `e2e: true` for E2E builds; `E2E_TELEMETRY_DISABLED=1` also disables capture in Node. Capture failures are ignored. Use field-style responses (the default) or `throwOnError: true` so the wrapper can detect failures. The wrapper cannot detect errors hidden by `responseStyle: "data"`. Only wrapped calls emit events. These owner-configured events are separate from any Disposabl platform usage telemetry; avoid enabling PostHog autocapture or sending request content in the sink.
|
|
44
44
|
|
|
45
45
|
`DO_NOT_TRACK=1` and the browser's `navigator.doNotTrack` setting disable capture. For an SDK generated from your own API, provide `operations: ["notesList", "notesCreate"] as const` with the fixed operation IDs from your generated contract. This replaces the default Disposabl platform operation list. Only identifiers containing letters, numbers, and underscores are accepted; never put user input into this allowlist. Server-side platform operation telemetry, when configured, is separate from this optional owner hook.
|
|
46
|
+
|
|
47
|
+
The hook also suppresses capture in Node development, test and CI environments, when `E2E_TELEMETRY_DISABLED` is set, or when `DISPOSABL_TELEMETRY_DISABLED=1`.
|
|
@@ -67,8 +67,13 @@ export function createSdkAnalytics<
|
|
|
67
67
|
config.enabled === false ||
|
|
68
68
|
config.environment !== "production" ||
|
|
69
69
|
config.e2e ||
|
|
70
|
-
env?.
|
|
71
|
-
env?.
|
|
70
|
+
env?.NODE_ENV === "test" ||
|
|
71
|
+
env?.NODE_ENV === "development" ||
|
|
72
|
+
env?.BUN_ENV === "test" ||
|
|
73
|
+
!!env?.CI ||
|
|
74
|
+
!!env?.E2E_TELEMETRY_DISABLED ||
|
|
75
|
+
env?.DISPOSABL_TELEMETRY_DISABLED === "1" ||
|
|
76
|
+
["1", "true"].includes(env?.DO_NOT_TRACK?.toLowerCase() ?? "") ||
|
|
72
77
|
(typeof navigator !== "undefined" && navigator.doNotTrack === "1") ||
|
|
73
78
|
!allowed.has(operation)
|
|
74
79
|
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: disposabl-app
|
|
3
|
-
description: Create, develop, and
|
|
3
|
+
description: Create, develop, deliver, and submit Disposabl apps, with preview status updates and verification on the requested platforms.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Build a Disposabl app
|
|
@@ -20,7 +20,7 @@ bun create disposabl-app@latest my-app --platforms web,android,mcp --features au
|
|
|
20
20
|
|
|
21
21
|
Use the requested platforms and features. Creation handles Disposabl login, required GitHub and Convex setup, and the app's scoped development environment. Resume interrupted setup in the same directory. Do not create a replacement Convex project or delete an app unless requested. Never print credentials.
|
|
22
22
|
|
|
23
|
-
The CLI is bundled with `create-disposabl-app
|
|
23
|
+
The CLI is bundled with `create-disposabl-app`. Commands below use that bundled CLI and work without a global install:
|
|
24
24
|
|
|
25
25
|
```sh
|
|
26
26
|
bunx --package create-disposabl-app@latest disposabl login status
|
|
@@ -37,6 +37,8 @@ Choose a visual direction suited to the product. Read the `frontend-design` skil
|
|
|
37
37
|
|
|
38
38
|
Read [delivery checks](references/delivery.md) before native builds or delivery repairs. Aim to show a usable web preview early; first native builds can take longer. Do not promise a build deadline.
|
|
39
39
|
|
|
40
|
+
For requested App Store or Google Play submission, read [store submissions](references/store-submissions.md). Build and verify the matching store artifacts and reviewer access, then follow the requested submission and release scope.
|
|
41
|
+
|
|
40
42
|
Prefer local development, builds, and verification whenever the toolchain is available. Do not push or start GitHub Actions merely to test changes. Use the existing release workflows for authorized publication.
|
|
41
43
|
|
|
42
44
|
## Testing
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# App Store and Google Play submissions
|
|
2
|
+
|
|
3
|
+
Use this workflow when the user requests store submission or release. Follow their chosen platforms, accounts, distribution timing, and build constraints. Prior authorization to submit or release remains effective; ask only for information, access, or a decision that is actually missing, or when a tool or legal boundary requires it.
|
|
4
|
+
|
|
5
|
+
## Match the existing app
|
|
6
|
+
|
|
7
|
+
Identify the exact App Store Connect (ASC) app record and Apple ID, bundle ID, team, and current release; identify the Play Console app record, package name, track, version code, and signing configuration. Reuse the existing listing when the identifiers and ownership match. Do not infer identity from the display name or an Expo project. If no matching record exists, create a new record only within the requested scope; explain that it is a new listing, not an update or migration of the existing app.
|
|
8
|
+
|
|
9
|
+
Compare the actual release artifact's identifier, version/build number, signing certificate and entitlements with the store record and authorized team. An ASC bundle ID cannot be changed after a build upload. A Play update needs the same package name, a higher version code, and the correct upload signing key; distinguish the upload certificate from the Play-held app signing certificate. Do not expose private keys or credentials. Stop and report a mismatch instead of uploading to a different listing or replacing signing identity. See [Apple app information](https://developer.apple.com/help/app-store-connect/reference/app-information/app-information/), [Play app updates](https://support.google.com/googleplay/android-developer/answer/9859350), and [Play App Signing](https://support.google.com/googleplay/android-developer/answer/9842756).
|
|
10
|
+
|
|
11
|
+
## Build, reviewer access, and evidence
|
|
12
|
+
|
|
13
|
+
Use the user's required build path. When local iOS builds are requested, create a signed device archive with local Xcode and export/upload through the supported App Store Connect path; do not use EAS cloud builds. A simulator build, ad-hoc signature, preview IPA, or keyless payments fixture is not a submission artifact. For Play, build the correctly signed release Android App Bundle (`.aab`); an APK proves neither an AAB upload nor Play delivery. Record source SHA, artifact digest, identifiers, versions, signing evidence, and the target deployment. Verify the release build on an appropriate device, including login, real requested features, saved data after relaunch, and the intended backend. Report any unverified behavior instead of claiming readiness.
|
|
14
|
+
|
|
15
|
+
If review requires login, provision a dedicated reviewer account for the actual app and review backend using a login method supported by the submitted build and backend. Give it only the permissions and resources needed to exercise the real submitted features; include any required roles, reachable backend, purchase access, and steps. Prepared credentials alone are not an account: register it, then verify login and those features on the submitted build, relaunch, and verify session and data before calling reviewer access ready. Keep credentials out of source, Git, skill files, logs, screenshots, and public chat; enter them only in the store's designated review-access fields via an authorized secure channel. Keep the account and backend usable through review. If Apple requires a subscription flow, follow its current guidance for a review account that can demonstrate it. Explain genuine limits and setup in review notes rather than presenting a mock as a working feature. See [Apple review information](https://developer.apple.com/help/app-review/before-submitting-for-review/complete-review) and [Google review access](https://support.google.com/googleplay/android-developer/answer/15191715).
|
|
16
|
+
|
|
17
|
+
Use truthful screenshots from the submitted app and supported devices; ensure metadata, privacy policy, age/content ratings, Apple privacy declarations, and Play Data safety reflect the actual app, backend, SDKs, and regional behavior. Do not invent data practices or claim unavailable features. Check [Apple screenshot specifications](https://developer.apple.com/help/app-store-connect/reference/app-information/screenshot-specifications), [Apple privacy details](https://developer.apple.com/app-store/submitting/), and [Play Data safety](https://support.google.com/googleplay/android-developer/answer/10787469).
|
|
18
|
+
|
|
19
|
+
## Payments and release states
|
|
20
|
+
|
|
21
|
+
For enabled digital purchases, verify the configured products, prices, store offerings, sandbox transaction, restore and provider synchronization against the intended app and environment. Distinguish local StoreKit configuration, Apple/Google sandbox, provider synchronization, and production fulfillment. A button, mock, or redirect is not proof of payment or credited balance.
|
|
22
|
+
|
|
23
|
+
For iOS website checkout, verify the actual US StoreKit storefront and purchase eligibility, website option, return flow and authoritative balance refresh. For non-US storefronts retain the applicable native in-app purchase path unless a verified regional entitlement or exception applies. Check the current [Apple review guidelines, section 3.1](https://developer.apple.com/app-store/review/guidelines/) and the app's payment configuration; do not assume a US exception applies worldwide. For Android, follow the current [Google Play payments policy](https://support.google.com/googleplay/android-developer/answer/9858738) and any applicable enrolled regional program; do not treat the iOS policy as Android authorization.
|
|
24
|
+
|
|
25
|
+
Track each platform separately: artifact built and signed; uploaded; processed and associated with the exact app/version; submitted for review; review outcome; and public or staged release. Upload or TestFlight availability is not App Review submission. Select the store's release mode consistent with the user's instructions and check whether approval triggers automatic publication. Confirm final state in the relevant console and report precise links, identifiers, and blockers. See [Apple submit an app](https://developer.apple.com/help/app-store-connect/manage-submissions-to-app-review/submit-an-app), [Apple release options](https://developer.apple.com/help/app-store-connect/manage-your-apps-availability/select-an-app-store-version-release-option), and [Play publishing overview](https://support.google.com/googleplay/android-developer/answer/9859654).
|
|
@@ -23,7 +23,7 @@ For an isolated preview or CI deployment, set `E2E_CONVEX_URL` and `E2E_CONVEX_S
|
|
|
23
23
|
|
|
24
24
|
The initial flows check the public web page, the dashboard's authentication boundary, an anonymous backend auth query, the API contract when enabled, and the mobile home screen. They do not create users or modify data. Add product-specific flows here as behavior changes, including login and saved-state checks using dedicated test users. Keep required flows deterministic; an agent can write and debug tests without adding model calls to their execution.
|
|
25
25
|
|
|
26
|
-
The
|
|
26
|
+
The opt-in account-deletion receipt flow runs through `python3 packages/tests/fixtures/billing-handoff-browser/run.py receipt` with `CONVEX_LOCAL_BINARY` and `PLAYWRIGHT_BROWSERS_PATH` set as documented in that fixture's README. It uses a fresh owned 3530/3531 backend and a synthetic account, downloads a private receipt, then clears that account's authentication. Retained logs, screenshots, database and receipt may contain synthetic session data; keep them private. This does not prove whole-account deletion.
|
|
27
27
|
|
|
28
28
|
The storage fallback flow (`flows/files.e2e.ts`) uses the same loopback/admin restriction to confirm R2 is not configured before uploading. It checks downloaded bytes, anonymous and cross-user rejection, and owner deletion, removing only its own new file. It makes no R2 requests and skips when R2 is fully configured.
|
|
29
29
|
|
|
@@ -71,3 +71,30 @@ Both `bun run test` and `bun run e2e ...` set `E2E_TELEMETRY_DISABLED=1`. Keep u
|
|
|
71
71
|
Upstream telemetry otherwise sends command/engine/runtime versions, environment categories, durations, test counts, error codes, and AI/cache usage to the maintainers' PostHog project. It excludes test titles, source, URLs, screenshots, prompts, credentials, and error messages. See [the event inventory](https://github.com/tester-army/e2e/blob/main/docs/telemetry.mdx) and [transport source](https://github.com/tester-army/e2e/blob/main/packages/e2e/src/telemetry/posthog.ts).
|
|
72
72
|
|
|
73
73
|
AI is optional. To add it later, read `bun run e2e guide setup` and configure a provider or the upstream Codex/Claude Code ACP adapter. Keep model-backed flows separate from the required deterministic suite; an AI key appearing in the environment must not silently change the build gate or start spending.
|
|
74
|
+
|
|
75
|
+
<!-- mobile-simulator-preflight:start -->
|
|
76
|
+
|
|
77
|
+
### Isolated iOS simulator acceptance preflight
|
|
78
|
+
|
|
79
|
+
For a disposable E2E-only simulator build, select a unique preview bundle ID and URL scheme, set `EXPO_NO_DOTENV=1`, `EXPO_PUBLIC_E2E=true`, `E2E_TELEMETRY_DISABLED=1`, and the two `EXPO_PUBLIC_CONVEX_*` URLs to the assigned `http://127.0.0.1:<port>` backend. Disable updates and payments in the fixture. Use an allowlisted environment with Expo telemetry disabled and no provider credentials. Keep the original app and its data. On macOS, create a disposable simulator-only entitlements plist with `application-identifier` and the sole `keychain-access-groups` entry both set to `local.<unique-preview-bundle-id>`. After Expo prebuild and pod installation, from `apps/mobile` the tested Xcode invocation is:
|
|
80
|
+
|
|
81
|
+
```sh
|
|
82
|
+
xcodebuild -workspace ios/Disposabl.xcworkspace -scheme Disposabl -configuration Release \
|
|
83
|
+
-sdk iphonesimulator -destination 'generic/platform=iOS Simulator' \
|
|
84
|
+
-derivedDataPath "$SIMULATOR_DERIVED" -jobs 2 CODE_SIGNING_ALLOWED=YES \
|
|
85
|
+
CODE_SIGNING_REQUIRED=YES CODE_SIGN_IDENTITY=- DEVELOPMENT_TEAM= \
|
|
86
|
+
CODE_SIGN_ENTITLEMENTS="$SIMULATOR_ENTITLEMENTS" build
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
This is a local simulator fixture, not a production signing recipe. Capture a build record JSON with exactly `source_revision`, `js_sha256`, `app_id`, `backend`, `site`, and Boolean `e2e`, `telemetry_disabled`, `updates_disabled`, `payments_disabled`. The SHA is of the finished `main.jsbundle`; record the actual build inputs, not intended ones. Run:
|
|
90
|
+
|
|
91
|
+
```sh
|
|
92
|
+
python3 packages/tests/helpers/mobile-simulator/preflight.py \
|
|
93
|
+
--app "$SIMULATOR_APP" --record "$BUILD_RECORD" --source "$SOURCE_CHECKOUT" \
|
|
94
|
+
--app-id "$PREVIEW_APP_ID" --group "local.$PREVIEW_APP_ID" \
|
|
95
|
+
--backend "$EXPO_PUBLIC_CONVEX_URL" --site "$EXPO_PUBLIC_CONVEX_SITE_URL" \
|
|
96
|
+
--hermesc "$SOURCE_CHECKOUT/apps/mobile/ios/Pods/hermes-engine/destroot/bin/hermesc"
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Preflight checks ARM64 simulator platform, linked simulator entitlement sections and identities, embedded URLs, disabled updates, JS hash and matching record. A record is an operator attestation: it cannot independently prove source provenance, E2E flags, payments or telemetry behavior. Retain the build logs and confirm the checkout and build inputs separately. A passing preflight does not establish installation or behavior. Xcode's separate codesign entitlement dictionary is not a substitute for inspecting the simulated Mach-O entitlement sections.
|
|
100
|
+
<!-- mobile-simulator-preflight:end -->
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { test } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { spawnSync } from "node:child_process";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
|
|
6
|
+
test("account deletion UI handles authentication and request states", () => {
|
|
7
|
+
for (const disabled of ["true", "false"]) {
|
|
8
|
+
const result = spawnSync(
|
|
9
|
+
process.execPath,
|
|
10
|
+
[
|
|
11
|
+
"test",
|
|
12
|
+
join(import.meta.dirname, "components/account-deletion.test.mjs"),
|
|
13
|
+
],
|
|
14
|
+
{
|
|
15
|
+
encoding: "utf8",
|
|
16
|
+
env: { ...process.env, TEST_AUTH_DISABLED: disabled },
|
|
17
|
+
},
|
|
18
|
+
);
|
|
19
|
+
assert.equal(result.status, 0, result.stdout + result.stderr);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { test } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { spawnSync } from "node:child_process";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
|
|
6
|
+
function probe(variables: Record<string, string>) {
|
|
7
|
+
const result = spawnSync(
|
|
8
|
+
process.execPath,
|
|
9
|
+
[
|
|
10
|
+
"--no-env-file",
|
|
11
|
+
"test",
|
|
12
|
+
join(import.meta.dirname, "helpers/auth-email-setup/probe.test.mjs"),
|
|
13
|
+
],
|
|
14
|
+
{
|
|
15
|
+
encoding: "utf8",
|
|
16
|
+
env: {
|
|
17
|
+
PATH: process.env.PATH,
|
|
18
|
+
HOME: process.env.HOME,
|
|
19
|
+
TMPDIR: process.env.TMPDIR,
|
|
20
|
+
NODE_ENV: "test",
|
|
21
|
+
CI: "1",
|
|
22
|
+
DO_NOT_TRACK: "1",
|
|
23
|
+
E2E_TELEMETRY_DISABLED: "1",
|
|
24
|
+
CONVEX_SITE_URL: "http://127.0.0.1:3481",
|
|
25
|
+
...variables,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
);
|
|
29
|
+
assert.equal(result.status, 0, result.stdout + result.stderr);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
test("email setup uses the built-in site URL without a sender", () => {
|
|
33
|
+
probe({ EXPECT_ORIGIN: "http://127.0.0.1:3481" });
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test("email setup uses a valid explicit origin", () => {
|
|
37
|
+
probe({
|
|
38
|
+
AUTH_EMAIL_ORIGIN: "https://mail.example.invalid",
|
|
39
|
+
EXPECT_ORIGIN: "https://mail.example.invalid",
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test("email setup rejects a malformed explicit origin", () => {
|
|
44
|
+
probe({ AUTH_EMAIL_ORIGIN: "localhost:5173", EXPECT_INVALID: "1" });
|
|
45
|
+
});
|