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
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
--- a/src/components/google/_generated/component.ts
|
|
2
|
+
+++ b/src/components/google/_generated/component.ts
|
|
3
|
+
@@ -28,7 +28,7 @@
|
|
4
|
+
"mutation",
|
|
5
|
+
"internal",
|
|
6
|
+
{ stateHash: string; ticketCodeHash: string },
|
|
7
|
+
- null | { encryptedPayload: string },
|
|
8
|
+
+ null | { encryptedPayload: string; authorizationStartedAt?: number },
|
|
9
|
+
Name
|
|
10
|
+
>;
|
|
11
|
+
createAuthorizationRequest: FunctionReference<
|
|
12
|
+
--- a/src/lib/oauth/callback.ts
|
|
13
|
+
+++ b/src/lib/oauth/callback.ts
|
|
14
|
+
@@ -265,6 +265,7 @@
|
|
15
|
+
|
|
16
|
+
/** What every component's claimed authorization request has in common. */
|
|
17
|
+
export type ClaimedRequest = {
|
|
18
|
+
+ authorizationStartedAt?: number;
|
|
19
|
+
stateHash: string;
|
|
20
|
+
redirectTo: string;
|
|
21
|
+
callbackUrl: string;
|
|
22
|
+
@@ -277,6 +278,7 @@
|
|
23
|
+
|
|
24
|
+
/** The fields of a new ticket, for `mintTicket` to store. */
|
|
25
|
+
export type MintedTicket = {
|
|
26
|
+
+ authorizationStartedAt?: number;
|
|
27
|
+
ticketCodeHash: string;
|
|
28
|
+
encryptedPayload: string;
|
|
29
|
+
};
|
|
30
|
+
@@ -430,6 +432,7 @@
|
|
31
|
+
|
|
32
|
+
const ticketCode = generateRandomToken();
|
|
33
|
+
await options.mintTicket(authRequest, {
|
|
34
|
+
+ ...(authRequest.authorizationStartedAt === undefined ? {} : { authorizationStartedAt: authRequest.authorizationStartedAt }),
|
|
35
|
+
ticketCodeHash: await sha256Hex(ticketCode),
|
|
36
|
+
encryptedPayload: await encryptTicketPayload(
|
|
37
|
+
ticketCode,
|
|
38
|
+
--- a/src/lib/oauth/dbHelpers.ts
|
|
39
|
+
+++ b/src/lib/oauth/dbHelpers.ts
|
|
40
|
+
@@ -58,7 +58,7 @@
|
|
41
|
+
Doc extends AuthorizationRequestContract,
|
|
42
|
+
>(
|
|
43
|
+
ctx: MutationCtx,
|
|
44
|
+
- fields: Omit<WithoutSystemFields<Doc>, "callbackUrl" | "expiresAt">,
|
|
45
|
+
+ fields: Omit<WithoutSystemFields<Doc>, "callbackUrl" | "expiresAt" | "authorizationStartedAt">,
|
|
46
|
+
): Promise<{ callbackUrl: string }> {
|
|
47
|
+
// System env vars are only visible inside components on backends with
|
|
48
|
+
// convex/convex-backend@64c163a (July 2026); cloud always has it,
|
|
49
|
+
@@ -76,6 +76,7 @@
|
|
50
|
+
await ctx.db.insert("authorizationRequests", {
|
|
51
|
+
...fields,
|
|
52
|
+
callbackUrl,
|
|
53
|
+
+ authorizationStartedAt: Date.now(),
|
|
54
|
+
expiresAt: Date.now() + AUTHORIZATION_REQUEST_TTL_MS,
|
|
55
|
+
});
|
|
56
|
+
return { callbackUrl };
|
|
57
|
+
@@ -159,7 +160,7 @@
|
|
58
|
+
stateHash: string;
|
|
59
|
+
match?: (ticket: Doc) => boolean;
|
|
60
|
+
},
|
|
61
|
+
-): Promise<{ encryptedPayload: string } | null> {
|
|
62
|
+
+): Promise<{ encryptedPayload: string; authorizationStartedAt?: number } | null> {
|
|
63
|
+
// The same assertion as in claimAuthorizationRequest, for the same reason.
|
|
64
|
+
const ticket = (await ctx.db
|
|
65
|
+
.query("tickets")
|
|
66
|
+
@@ -181,5 +182,5 @@
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
await ctx.db.delete("tickets", ticket._id);
|
|
70
|
+
- return { encryptedPayload: ticket.encryptedPayload };
|
|
71
|
+
+ return { encryptedPayload: ticket.encryptedPayload, ...(ticket.authorizationStartedAt === undefined ? {} : { authorizationStartedAt: ticket.authorizationStartedAt }) };
|
|
72
|
+
}
|
|
73
|
+
--- a/src/lib/oauth/providerFunctions.ts
|
|
74
|
+
+++ b/src/lib/oauth/providerFunctions.ts
|
|
75
|
+
@@ -48,7 +48,7 @@
|
|
76
|
+
*/
|
|
77
|
+
const createRequestArgs = v
|
|
78
|
+
.object(authorizationRequestFields)
|
|
79
|
+
- .omit("callbackUrl", "expiresAt");
|
|
80
|
+
+ .omit("callbackUrl", "expiresAt", "authorizationStartedAt");
|
|
81
|
+
|
|
82
|
+
/** The fields of a claimed request that is still live. */
|
|
83
|
+
const claimedRequestFields = v
|
|
84
|
+
@@ -121,6 +121,7 @@
|
|
85
|
+
redirectTo: claimed.doc.redirectTo,
|
|
86
|
+
callbackUrl: claimed.doc.callbackUrl,
|
|
87
|
+
codeVerifier: claimed.doc.codeVerifier,
|
|
88
|
+
+ ...(claimed.doc.authorizationStartedAt === undefined ? {} : { authorizationStartedAt: claimed.doc.authorizationStartedAt }),
|
|
89
|
+
};
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
@@ -137,7 +138,7 @@
|
|
93
|
+
ticketCodeHash: v.string(),
|
|
94
|
+
stateHash: v.string(),
|
|
95
|
+
},
|
|
96
|
+
- returns: v.union(v.null(), v.object({ encryptedPayload: v.string() })),
|
|
97
|
+
+ returns: v.union(v.null(), v.object({ encryptedPayload: v.string(), authorizationStartedAt: v.optional(v.number()) })),
|
|
98
|
+
handler: async (ctx, args) =>
|
|
99
|
+
await dbHelpers.claimTicket<SharedTicketDocument>(ctx, args),
|
|
100
|
+
});
|
|
101
|
+
--- a/src/lib/oauth/redemption.ts
|
|
102
|
+
+++ b/src/lib/oauth/redemption.ts
|
|
103
|
+
@@ -144,7 +144,9 @@
|
|
104
|
+
claimTicket: (
|
|
105
|
+
ctx: MutationCtx,
|
|
106
|
+
args: { ticketCodeHash: string; stateHash: string },
|
|
107
|
+
- ) => Promise<{ encryptedPayload: string } | null>;
|
|
108
|
+
+ ) => Promise<{ encryptedPayload: string; authorizationStartedAt?: number } | null>;
|
|
109
|
+
+ /** Optional server-side consumer; undefined marks legacy tickets. */
|
|
110
|
+
+ checkAuthorizationStart?: (ctx: MutationCtx, profile: Profile, startedAt: number | undefined) => Promise<void>;
|
|
111
|
+
/** Map what the provider attested to the account profile. */
|
|
112
|
+
profile: (payload: Payload) => Profile;
|
|
113
|
+
}) {
|
|
114
|
+
@@ -176,6 +178,8 @@
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
+ await options.checkAuthorizationStart?.(ctx, profile, ticket.authorizationStartedAt);
|
|
119
|
+
+
|
|
120
|
+
// The same redemption flow serves a first sign-in and a return visit, so
|
|
121
|
+
// resolve the identity to pick a path. This handler is a mutation, so the
|
|
122
|
+
// lookup and the write it decides on are one transaction.
|
|
123
|
+
--- a/src/lib/oauth/schema.ts
|
|
124
|
+
+++ b/src/lib/oauth/schema.ts
|
|
125
|
+
@@ -24,6 +24,8 @@
|
|
126
|
+
* ignores the parameters.
|
|
127
|
+
*/
|
|
128
|
+
codeVerifier: v.string(),
|
|
129
|
+
+ /** Server time at original authorization start; absent on legacy records. */
|
|
130
|
+
+ authorizationStartedAt: v.optional(v.number()),
|
|
131
|
+
/** The callback rejects requests older than this. */
|
|
132
|
+
expiresAt: v.number(),
|
|
133
|
+
};
|
|
134
|
+
@@ -41,6 +43,8 @@
|
|
135
|
+
* or server that initiated the flow.
|
|
136
|
+
*/
|
|
137
|
+
stateHash: v.string(),
|
|
138
|
+
+ /** Inherited from the claimed request, never from a client. */
|
|
139
|
+
+ authorizationStartedAt: v.optional(v.number()),
|
|
140
|
+
/**
|
|
141
|
+
* sha256 of the server-minted ticket code. The raw value appears only
|
|
142
|
+
* in the callback redirect URL and is never stored.
|
|
143
|
+
--- a/src/methods/google/server.ts
|
|
144
|
+
+++ b/src/methods/google/server.ts
|
|
145
|
+
@@ -5,6 +5,7 @@
|
|
146
|
+
* @module
|
|
147
|
+
*/
|
|
148
|
+
import { Infer, v } from "convex/values";
|
|
149
|
+
+import type { GenericMutationCtx, GenericDataModel } from "convex/server";
|
|
150
|
+
import type { UserCallbacks } from "../../lib/types.ts";
|
|
151
|
+
import type { AuthCore } from "../../server/setup.ts";
|
|
152
|
+
import { buildStartSignIn } from "../../lib/oauth/authorize.ts";
|
|
153
|
+
@@ -70,6 +71,8 @@
|
|
154
|
+
* for open-redirect prevention.
|
|
155
|
+
*/
|
|
156
|
+
allowedRedirectOrigins: string[];
|
|
157
|
+
+ /** Server-only pre-sign-in check; undefined is legacy authorization proof. */
|
|
158
|
+
+ checkAuthorizationStart?: (ctx: GenericMutationCtx<GenericDataModel>, profile: GoogleProfile, startedAt: number | undefined) => Promise<void>;
|
|
159
|
+
/** Optional signed state envelope for a shared callback. */
|
|
160
|
+
authorizationState?: (state: string) => Promise<string>;
|
|
161
|
+
};
|
|
162
|
+
@@ -136,6 +139,7 @@
|
|
163
|
+
>({
|
|
164
|
+
providerName: PROVIDER_NAME,
|
|
165
|
+
authMutation,
|
|
166
|
+
+ checkAuthorizationStart: options.checkAuthorizationStart,
|
|
167
|
+
claimTicket: (ctx, args) =>
|
|
168
|
+
ctx.runMutation(options.component.provider.claimTicket, args),
|
|
169
|
+
profile: (payload) => normalizeGoogleProfile(payload.claims),
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
--- a/src/components/apple/_generated/component.ts
|
|
2
|
+
+++ b/src/components/apple/_generated/component.ts
|
|
3
|
+
@@ -28,7 +28,7 @@
|
|
4
|
+
"mutation",
|
|
5
|
+
"internal",
|
|
6
|
+
{ stateHash: string; ticketCodeHash: string },
|
|
7
|
+
- null | { encryptedPayload: string },
|
|
8
|
+
+ null | { encryptedPayload: string; authorizationStartedAt?: number },
|
|
9
|
+
Name
|
|
10
|
+
>;
|
|
11
|
+
createAuthorizationRequest: FunctionReference<
|
|
12
|
+
--- a/src/components/github/_generated/component.ts
|
|
13
|
+
+++ b/src/components/github/_generated/component.ts
|
|
14
|
+
@@ -28,7 +28,7 @@
|
|
15
|
+
"mutation",
|
|
16
|
+
"internal",
|
|
17
|
+
{ stateHash: string; ticketCodeHash: string },
|
|
18
|
+
- null | { encryptedPayload: string },
|
|
19
|
+
+ null | { encryptedPayload: string; authorizationStartedAt?: number },
|
|
20
|
+
Name
|
|
21
|
+
>;
|
|
22
|
+
createAuthorizationRequest: FunctionReference<
|
|
23
|
+
--- a/src/components/oauth/_generated/component.ts
|
|
24
|
+
+++ b/src/components/oauth/_generated/component.ts
|
|
25
|
+
@@ -28,7 +28,7 @@
|
|
26
|
+
"mutation",
|
|
27
|
+
"internal",
|
|
28
|
+
{ providerName: string; stateHash: string; ticketCodeHash: string },
|
|
29
|
+
- null | { encryptedPayload: string },
|
|
30
|
+
+ null | { encryptedPayload: string; authorizationStartedAt?: number },
|
|
31
|
+
Name
|
|
32
|
+
>;
|
|
33
|
+
createAuthorizationRequest: FunctionReference<
|
|
34
|
+
--- a/src/components/oauth/provider.ts
|
|
35
|
+
+++ b/src/components/oauth/provider.ts
|
|
36
|
+
@@ -57,6 +57,7 @@
|
|
37
|
+
redirectTo: v.string(),
|
|
38
|
+
callbackUrl: v.string(),
|
|
39
|
+
codeVerifier: v.string(),
|
|
40
|
+
+ authorizationStartedAt: v.optional(v.number()),
|
|
41
|
+
tokenEndpoint: v.string(),
|
|
42
|
+
userInfoEndpoints: v.optional(v.record(v.string(), v.string())),
|
|
43
|
+
issuers: v.optional(v.array(v.string())),
|
|
44
|
+
@@ -80,6 +81,7 @@
|
|
45
|
+
redirectTo: doc.redirectTo,
|
|
46
|
+
callbackUrl: doc.callbackUrl,
|
|
47
|
+
codeVerifier: doc.codeVerifier,
|
|
48
|
+
+ ...(doc.authorizationStartedAt === undefined ? {} : { authorizationStartedAt: doc.authorizationStartedAt }),
|
|
49
|
+
tokenEndpoint: doc.tokenEndpoint,
|
|
50
|
+
userInfoEndpoints: doc.userInfoEndpoints,
|
|
51
|
+
issuers: doc.issuers,
|
|
52
|
+
@@ -99,6 +101,7 @@
|
|
53
|
+
stateHash: v.string(),
|
|
54
|
+
ticketCodeHash: v.string(),
|
|
55
|
+
encryptedPayload: v.string(),
|
|
56
|
+
+ authorizationStartedAt: v.optional(v.number()),
|
|
57
|
+
},
|
|
58
|
+
returns: v.null(),
|
|
59
|
+
handler: async (ctx, args) =>
|
|
60
|
+
@@ -120,6 +123,7 @@
|
|
61
|
+
v.null(),
|
|
62
|
+
v.object({
|
|
63
|
+
encryptedPayload: v.string(),
|
|
64
|
+
+ authorizationStartedAt: v.optional(v.number()),
|
|
65
|
+
}),
|
|
66
|
+
),
|
|
67
|
+
handler: async (ctx, args) =>
|
|
68
|
+
--- a/src/components/password/_generated/component.ts
|
|
69
|
+
+++ b/src/components/password/_generated/component.ts
|
|
70
|
+
@@ -24,6 +24,7 @@
|
|
71
|
+
export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
72
|
+
{
|
|
73
|
+
public: {
|
|
74
|
+
+ eraseUserPasswords: FunctionReference<"mutation", "internal", { userId: string }, { complete: boolean; deleted: number }, Name>;
|
|
75
|
+
setPassword: FunctionReference<
|
|
76
|
+
"mutation",
|
|
77
|
+
"internal",
|
|
78
|
+
--- a/src/components/password/public.ts
|
|
79
|
+
+++ b/src/components/password/public.ts
|
|
80
|
+
@@ -68,6 +68,7 @@
|
|
81
|
+
ctx,
|
|
82
|
+
{ userId, password, minimumLength },
|
|
83
|
+
): Promise<SetPasswordResult> => {
|
|
84
|
+
+ if (await erasedUser(ctx, userId)) throw new Error("Password account is unavailable.");
|
|
85
|
+
const userError = validateNewPassword(password, minimumLength);
|
|
86
|
+
if (userError !== null) {
|
|
87
|
+
return { success: false, userError };
|
|
88
|
+
@@ -103,6 +104,7 @@
|
|
89
|
+
args: { userId: v.string(), password: v.string() },
|
|
90
|
+
returns: verifyPasswordResult,
|
|
91
|
+
handler: async (ctx, { userId, password }): Promise<VerifyPasswordResult> => {
|
|
92
|
+
+ if (await erasedUser(ctx, userId)) return { success: false, userError: { error: "INVALID_CREDENTIALS" } };
|
|
93
|
+
const status = await rateLimiter.limit(ctx, "verifyPassword", {
|
|
94
|
+
key: userId,
|
|
95
|
+
});
|
|
96
|
+
@@ -158,3 +160,20 @@
|
|
97
|
+
.withIndex("by_userId", (q) => q.eq("userId", userId))
|
|
98
|
+
.unique();
|
|
99
|
+
}
|
|
100
|
+
+
|
|
101
|
+
+/** App-server-only bounded erasure; tombstone prevents old-user recreation. */
|
|
102
|
+
+export const eraseUserPasswords = mutation({
|
|
103
|
+
+ args: { userId: v.string() },
|
|
104
|
+
+ returns: v.object({ complete: v.boolean(), deleted: v.number() }),
|
|
105
|
+
+ handler: async (ctx, { userId }) => {
|
|
106
|
+
+ if (!userId) throw new Error("Missing user ID.");
|
|
107
|
+
+ if (!(await erasedUser(ctx, userId)))
|
|
108
|
+
+ await ctx.db.insert("erasedUsers", { userId, erasedAt: Date.now() });
|
|
109
|
+
+ const rows = await ctx.db.query("passwords").withIndex("by_userId", q => q.eq("userId", userId)).take(101);
|
|
110
|
+
+ for (const row of rows.slice(0, 100)) await ctx.db.delete("passwords", row._id);
|
|
111
|
+
+ return { complete: rows.length <= 100, deleted: Math.min(rows.length, 100) };
|
|
112
|
+
+ },
|
|
113
|
+
+});
|
|
114
|
+
+async function erasedUser(ctx: QueryCtx, userId: string) {
|
|
115
|
+
+ return await ctx.db.query("erasedUsers").withIndex("by_userId", q => q.eq("userId", userId)).unique();
|
|
116
|
+
+}
|
|
117
|
+
--- a/src/components/password/schema.ts
|
|
118
|
+
+++ b/src/components/password/schema.ts
|
|
119
|
+
@@ -2,6 +2,7 @@
|
|
120
|
+
import { v } from "convex/values";
|
|
121
|
+
|
|
122
|
+
export default defineSchema({
|
|
123
|
+
+ erasedUsers: defineTable({userId: v.string(), erasedAt: v.number()}).index("by_userId", ["userId"]),
|
|
124
|
+
passwords: defineTable({
|
|
125
|
+
userId: v.string(),
|
|
126
|
+
passwordHashPHC: v.string(), // format: https://github.com/C2SP/C2SP/blob/main/phc-strings.md
|