create-disposabl-app 0.17.5 → 0.18.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.
- package/README.md +4 -0
- package/dist/disposabl.js +43 -10
- 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/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/build.ts +4 -0
- package/dist/templates/default/packages/cli/package.json +2 -1
- 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/disposabl-kit/server/release/clients.mjs +28 -1
- package/dist/templates/default/packages/disposabl-kit/server/release/verify-metadata.mjs +64 -0
- package/dist/templates/default/packages/sdk/README.md +2 -0
- package/dist/templates/default/packages/sdk/build.ts +8 -0
- package/dist/templates/default/packages/sdk/package.json +3 -2
- 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/dist/verify-metadata.mjs +64 -0
- package/package.json +3 -2
|
@@ -8,7 +8,10 @@ import {
|
|
|
8
8
|
import { makeFunctionReference, type Auth } from "convex/server";
|
|
9
9
|
import { getSessionUserId } from "./lib/functions";
|
|
10
10
|
import type { Id } from "../../backend/convex/_generated/dataModel";
|
|
11
|
-
import type {
|
|
11
|
+
import type {
|
|
12
|
+
ActionCtx,
|
|
13
|
+
MutationCtx,
|
|
14
|
+
} from "../../backend/convex/_generated/server";
|
|
12
15
|
import {
|
|
13
16
|
deleteThenForget,
|
|
14
17
|
r2Config,
|
|
@@ -73,17 +76,27 @@ async function owner(ctx: { auth: Auth }) {
|
|
|
73
76
|
if (!userId) throw new Error("Authentication required.");
|
|
74
77
|
return userId;
|
|
75
78
|
}
|
|
76
|
-
export
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
79
|
+
export type FileWriteGuard = (
|
|
80
|
+
ctx: ActionCtx | MutationCtx,
|
|
81
|
+
userId: string,
|
|
82
|
+
) => Promise<void>;
|
|
83
|
+
|
|
84
|
+
export const createRegister = (guard?: FileWriteGuard) =>
|
|
85
|
+
internalMutation({
|
|
86
|
+
args: {
|
|
87
|
+
filename: v.string(),
|
|
88
|
+
mediaType: v.string(),
|
|
89
|
+
size: v.number(),
|
|
90
|
+
location,
|
|
91
|
+
},
|
|
92
|
+
returns: v.id("files"),
|
|
93
|
+
handler: async (ctx, args) => {
|
|
94
|
+
const userId = await owner(ctx);
|
|
95
|
+
if (guard) await guard(ctx, userId);
|
|
96
|
+
return ctx.db.insert("files", { ...args, owner: userId });
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
export const register = createRegister();
|
|
87
100
|
export const getOwned = internalQuery({
|
|
88
101
|
args: { id: v.id("files") },
|
|
89
102
|
returns: fileValidator,
|
|
@@ -100,49 +113,52 @@ export const forget = internalMutation({
|
|
|
100
113
|
},
|
|
101
114
|
});
|
|
102
115
|
|
|
103
|
-
export const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
116
|
+
export const createUpload = (guard?: FileWriteGuard) =>
|
|
117
|
+
action({
|
|
118
|
+
args: { filename: v.string(), mediaType: v.string(), bytes: v.bytes() },
|
|
119
|
+
returns: v.id("files"),
|
|
120
|
+
handler: async (
|
|
121
|
+
ctx,
|
|
122
|
+
{ filename, mediaType, bytes },
|
|
123
|
+
): Promise<Id<"files">> => {
|
|
124
|
+
const userId = await owner(ctx);
|
|
125
|
+
if (guard) await guard(ctx, userId);
|
|
126
|
+
validateUpload(filename, mediaType, bytes);
|
|
127
|
+
const config = r2Config(env);
|
|
128
|
+
return (await registerWithRollback(
|
|
129
|
+
async (): Promise<FileRecord["location"]> => {
|
|
130
|
+
if (config) {
|
|
131
|
+
const loc = {
|
|
132
|
+
provider: "r2" as const,
|
|
133
|
+
key: crypto.randomUUID(),
|
|
134
|
+
account: config.account,
|
|
135
|
+
bucket: config.bucket,
|
|
136
|
+
};
|
|
137
|
+
await r2Write(loc, env, bytes, mediaType);
|
|
138
|
+
return loc;
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
provider: "convex",
|
|
142
|
+
storageId: await ctx.storage.store(
|
|
143
|
+
new Blob([bytes], { type: mediaType }),
|
|
144
|
+
),
|
|
121
145
|
};
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
),
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}),
|
|
139
|
-
(loc) =>
|
|
140
|
-
loc.provider === "r2"
|
|
141
|
-
? r2Delete(loc, env)
|
|
142
|
-
: ctx.storage.delete(loc.storageId),
|
|
143
|
-
)) as Id<"files">;
|
|
144
|
-
},
|
|
145
|
-
});
|
|
146
|
+
},
|
|
147
|
+
(loc) =>
|
|
148
|
+
ctx.runMutation(registerRef, {
|
|
149
|
+
filename: filename.trim(),
|
|
150
|
+
mediaType,
|
|
151
|
+
size: bytes.byteLength,
|
|
152
|
+
location: loc,
|
|
153
|
+
}),
|
|
154
|
+
(loc) =>
|
|
155
|
+
loc.provider === "r2"
|
|
156
|
+
? r2Delete(loc, env)
|
|
157
|
+
: ctx.storage.delete(loc.storageId),
|
|
158
|
+
)) as Id<"files">;
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
export const upload = createUpload();
|
|
146
162
|
async function resolve(ctx: ActionCtx, id: Id<"files">) {
|
|
147
163
|
const file = await ctx.runQuery(getRef, { id });
|
|
148
164
|
const url =
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
createOpenApi,
|
|
16
16
|
createPlatforms,
|
|
17
17
|
type ApiPolicy,
|
|
18
|
+
type AccountEligibility,
|
|
18
19
|
} from "./lib/platform-spec";
|
|
19
20
|
import { registerPageRoutes } from "./lib/static";
|
|
20
21
|
import { resend } from "../../backend/convex/emails";
|
|
@@ -24,7 +25,7 @@ import { desktopAuthPath, desktopAuthRedirect } from "../lib/desktop-auth";
|
|
|
24
25
|
|
|
25
26
|
export { tool } from "@convex-dev/mcp";
|
|
26
27
|
export type { McpServerOptions, McpUser, ToolCtx } from "@convex-dev/mcp";
|
|
27
|
-
export type { ApiPolicy } from "./lib/platform-spec";
|
|
28
|
+
export type { ApiPolicy, AccountEligibility } from "./lib/platform-spec";
|
|
28
29
|
|
|
29
30
|
const platforms = createPlatforms(modules);
|
|
30
31
|
if (
|
|
@@ -37,33 +38,60 @@ if (
|
|
|
37
38
|
export const platformSpec = platforms.spec;
|
|
38
39
|
|
|
39
40
|
const enabled = validatePlatforms(config.platforms);
|
|
40
|
-
|
|
41
|
-
(platform) => platform === "mcp" || platform === "api"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
41
|
+
function createMcp(eligibility?: AccountEligibility): McpServer | undefined {
|
|
42
|
+
return enabled.some((platform) => platform === "mcp" || platform === "api")
|
|
43
|
+
? new McpServer(components.mcp, {
|
|
44
|
+
name: "disposabl",
|
|
45
|
+
title: "Disposabl",
|
|
46
|
+
version: "1.0.0",
|
|
47
|
+
siteUrl: env.CONVEX_SITE_URL,
|
|
48
|
+
consentUrl: `${env.CONVEX_SITE_URL}/consent`,
|
|
49
|
+
scopes: {},
|
|
50
|
+
clientMetadataDocumentHosts: ["claude.ai"],
|
|
51
|
+
tools: eligibility
|
|
52
|
+
? createPlatforms(modules, eligibility).tools
|
|
53
|
+
: platforms.tools,
|
|
54
|
+
})
|
|
55
|
+
: undefined;
|
|
56
|
+
}
|
|
54
57
|
|
|
55
|
-
|
|
58
|
+
/** Protect issuance while retaining listing and revocation for existing grants. */
|
|
59
|
+
export function createMcpApi(eligibility?: AccountEligibility) {
|
|
60
|
+
const mcp = createMcp(eligibility);
|
|
61
|
+
if (!mcp) return {} as ReturnType<McpServer["api"]>;
|
|
62
|
+
const standard = mcp.api({ getUserId: getSessionUserId });
|
|
63
|
+
if (!eligibility) return standard;
|
|
64
|
+
const guarded = mcp.api({
|
|
65
|
+
getUserId: async (ctx) => {
|
|
66
|
+
const id = await getSessionUserId(ctx);
|
|
67
|
+
return id &&
|
|
68
|
+
(await eligibility(ctx as Parameters<AccountEligibility>[0], id))
|
|
69
|
+
? id
|
|
70
|
+
: null;
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
return {
|
|
74
|
+
...standard,
|
|
75
|
+
authorize: guarded.authorize,
|
|
76
|
+
createApiKey: guarded.createApiKey,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
56
79
|
export const {
|
|
57
80
|
getAuthRequest,
|
|
58
81
|
authorize,
|
|
59
82
|
listConnections,
|
|
60
83
|
revokeConnection,
|
|
61
84
|
createApiKey,
|
|
62
|
-
} =
|
|
63
|
-
mcp?.api({ getUserId: getSessionUserId }) ??
|
|
64
|
-
({} as ReturnType<McpServer["api"]>);
|
|
85
|
+
} = createMcpApi();
|
|
65
86
|
|
|
66
|
-
export default function createHttpRouter(
|
|
87
|
+
export default function createHttpRouter(
|
|
88
|
+
apiPolicy?: ApiPolicy,
|
|
89
|
+
eligibility?: AccountEligibility,
|
|
90
|
+
) {
|
|
91
|
+
const mcp = createMcp(eligibility);
|
|
92
|
+
const requestPlatforms = eligibility
|
|
93
|
+
? createPlatforms(modules, eligibility)
|
|
94
|
+
: platforms;
|
|
67
95
|
const http = httpRouter();
|
|
68
96
|
if (authenticationEnabled) {
|
|
69
97
|
if (
|
|
@@ -157,7 +185,7 @@ export default function createHttpRouter(apiPolicy?: ApiPolicy) {
|
|
|
157
185
|
const response =
|
|
158
186
|
method === "OPTIONS"
|
|
159
187
|
? new Response(null, { status: 204 })
|
|
160
|
-
: await
|
|
188
|
+
: await requestPlatforms.handleApi(
|
|
161
189
|
ctx,
|
|
162
190
|
request,
|
|
163
191
|
mcp.authenticate.bind(mcp),
|
|
@@ -47,9 +47,15 @@ export type ApiPolicy = {
|
|
|
47
47
|
) => boolean;
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
+
export type AccountEligibility = (
|
|
51
|
+
ctx: ToolCtx,
|
|
52
|
+
userId: string,
|
|
53
|
+
) => Promise<boolean>;
|
|
54
|
+
|
|
50
55
|
/** One opt-in produces the shared JSON contract and both transport adapters. */
|
|
51
56
|
export function createPlatforms(
|
|
52
57
|
modules: Record<string, Record<string, unknown>>,
|
|
58
|
+
eligibility?: AccountEligibility,
|
|
53
59
|
) {
|
|
54
60
|
const spec: Operation[] = [];
|
|
55
61
|
const tools: Record<string, ToolDefinition> = Object.create(null);
|
|
@@ -98,6 +104,8 @@ export function createPlatforms(
|
|
|
98
104
|
args,
|
|
99
105
|
returns: fn.returns,
|
|
100
106
|
handler: async (ctx, input, user) => {
|
|
107
|
+
if (eligibility && !(await eligibility(ctx, user.userId)))
|
|
108
|
+
throw new ConvexError("Account is unavailable.");
|
|
101
109
|
const startedAt = Date.now();
|
|
102
110
|
try {
|
|
103
111
|
const result = await runOperation(ctx, input, user);
|
|
@@ -186,6 +194,8 @@ export function createPlatforms(
|
|
|
186
194
|
)
|
|
187
195
|
)
|
|
188
196
|
return Response.json({ error: "forbidden" }, { status: 403 });
|
|
197
|
+
if (eligibility && !(await eligibility(ctx, user.userId)))
|
|
198
|
+
return Response.json({ error: "forbidden" }, { status: 403 });
|
|
189
199
|
const startedAt = Date.now();
|
|
190
200
|
const header = request.headers.get("X-Disposabl-Source");
|
|
191
201
|
const source = header === "cli" || header === "sdk" ? header : "api";
|
|
@@ -212,6 +222,13 @@ export function createPlatforms(
|
|
|
212
222
|
await record("success");
|
|
213
223
|
} catch (error) {
|
|
214
224
|
await record("error");
|
|
225
|
+
if (
|
|
226
|
+
!(error instanceof ConvexError) &&
|
|
227
|
+
!(error instanceof SyntaxError)
|
|
228
|
+
) {
|
|
229
|
+
console.error("platform_api_internal_error");
|
|
230
|
+
return Response.json({ error: "internal_error" }, { status: 500 });
|
|
231
|
+
}
|
|
215
232
|
throw error;
|
|
216
233
|
}
|
|
217
234
|
return new Response(
|
|
@@ -238,7 +255,14 @@ export function createPlatforms(
|
|
|
238
255
|
);
|
|
239
256
|
if (error instanceof SyntaxError)
|
|
240
257
|
return Response.json({ error: "invalid_request" }, { status: 400 });
|
|
241
|
-
|
|
258
|
+
const operation = spec.find((item) => item.path === url.pathname)!;
|
|
259
|
+
const header = request.headers.get("X-Disposabl-Source");
|
|
260
|
+
await scheduleTelemetry(ctx, "api_operation", {
|
|
261
|
+
source: header === "cli" || header === "sdk" ? header : "api",
|
|
262
|
+
operation: operation.name,
|
|
263
|
+
outcome: "error",
|
|
264
|
+
});
|
|
265
|
+
console.error("platform_api_internal_error");
|
|
242
266
|
return Response.json({ error: "internal_error" }, { status: 500 });
|
|
243
267
|
}
|
|
244
268
|
},
|