Abdulramon Jemil
Abdulramon Jemil
CCConvex Community
Created by Abdulramon Jemil on 9/7/2024 in #support-community
Unable to log in
GitHub suspended my account about 10 days ago for reasons I don't know, and I've reached out to them getting no correspondence whatsoever. Because of it, I'm not unable to log in to my Convex dashboard. Convex doesn't support any other login methods. What should I do?
1 replies
CCConvex Community
Created by Abdulramon Jemil on 8/23/2024 in #support-community
What's the name of the cookie used by Convex Auth?
I would like to know what name convex auth uses to keep track of session tokens. I like knowing how tools I use work so I can make modifications at any time. By logging into https://labs.convex.dev/auth-example, I noticed that login state works even when there are no cookies, and later found out that Convex auth uses localStorage by default unless when using @convex-dev/auth/nextjs. Anyways, I have something like the ff in localStorage:
{
theme: "system",
__convexAuthJWT_httpsadmiredsandpiper807convexcloud: "ey...some_JWT_stuff",
__convexAuthRefreshToken_httpsadmiredsandpiper807convexcloud: "some_refresh_token"
}
{
theme: "system",
__convexAuthJWT_httpsadmiredsandpiper807convexcloud: "ey...some_JWT_stuff",
__convexAuthRefreshToken_httpsadmiredsandpiper807convexcloud: "some_refresh_token"
}
1- Is there a documentation for the exact names used for the tokens similar to what Clerk has here: https://clerk.com/docs/deployments/clerk-cookies#strictly-necessary-application-cookies. It is always good to know about the magic done by the library, since I might want to read them and pass them around myself somewhere especially on the server. I know there are certain utilities for Next.js, but I still want to know. (Also, even though the chances of collision with my own set cookie/localstorage values is extremely low, it's not zero.) From the sample above, it's evident that the string is built from the cloud URL with some prefix. 2- Is there a documentation for how to verify such tokens manually similar to what clerk has here https://clerk.com/docs/backend-requests/handling/manual-jwt. 3- Are these names the same for localstorage and cookies (guess this can be answered by 1 above).
4 replies
CCConvex Community
Created by Abdulramon Jemil on 8/22/2024 in #support-community
Why not `ctx.db.query("table").withIndex(vectorIndex)`?
This is just out of curiosity, why not ctx.db.query("table").withIndex(vectorIndex) but instead ctx.vectorSearch()? Is it because we don't want to expose ctx.db in actions? In fact, why is there no ctx.db.query() in actions? Is there a reason for not allowing querying dB in actions? Seems to me like it should be fine since unlike mutations, determinism (or non-determinism) of the calling function (an action in this case) doesn't affect anything. Concerning the first question, we can just use Typescript to narrow down the indexes in the withIndex() of queries and mutations to non-vector indexes, while allowing all indexes in actions.
7 replies
CCConvex Community
Created by Abdulramon Jemil on 8/22/2024 in #support-community
Bad example in docs
In the vector search docs (https://docs.convex.dev/search/vector-search#using-a-separate-table-to-store-vectors), there is the following example:
export const fetchMovies = query({
args: {
ids: v.array(v.id("movieEmbeddings")),
},
handler: async (ctx, args) => {
const results = [];
for (const id of args.ids) {
const doc = await ctx.db
.query("movies")
.withIndex("by_embedding", (q) => q.eq("embeddingId", id))
.unique();
if (doc === null) {
continue;
}
results.push(doc);
}
return results;
},
});
export const fetchMovies = query({
args: {
ids: v.array(v.id("movieEmbeddings")),
},
handler: async (ctx, args) => {
const results = [];
for (const id of args.ids) {
const doc = await ctx.db
.query("movies")
.withIndex("by_embedding", (q) => q.eq("embeddingId", id))
.unique();
if (doc === null) {
continue;
}
results.push(doc);
}
return results;
},
});
This example uses await inside of a for loop, which I believe is from convex-demos/vector-search (https://github.com/get-convex/convex-demos/blob/d7e772bf8dcf694a075556c639a0c645b833e4a4/vector-search/convex/movies.ts#L110), and this is, in general a bad practice, and it becomes evident when there's a large number of ids to enumerate, resulting in very long response times. A better solution would be to use Promise.all and Array.prototype.filter as follows:
export const fetchMovies = query({
args: {
ids: v.array(v.id("movieEmbeddings"))
},
handler: async (ctx, args) => {
const results = await Promise.all(
args.ids.map((id) =>
ctx.db
.query("movies")
.withIndex("by_embedding", (q) => q.eq("embeddingId", id))
.unique()
)
)
return results.filter((result) => result !== null)
}
})
export const fetchMovies = query({
args: {
ids: v.array(v.id("movieEmbeddings"))
},
handler: async (ctx, args) => {
const results = await Promise.all(
args.ids.map((id) =>
ctx.db
.query("movies")
.withIndex("by_embedding", (q) => q.eq("embeddingId", id))
.unique()
)
)
return results.filter((result) => result !== null)
}
})
2 replies
CCConvex Community
Created by Abdulramon Jemil on 8/22/2024 in #support-community
How OIDC with Convex Auth works with HTTP actions endpoints
So when using convex auth, the authorization URL is the convex site URL available via CONVEX_SITE_URL system environment variable. From what I understand, specific endpoints defined by the OpenID spec are expected on such domain/URL (to conform to the spec). Examples of such endpoints are the /token and the /authorize. However, this same CONVEX_SITE_URL is used for HTTP actions, such that if I have an HTTP action at convex/token.ts, then the action is accessible by ${CONVEX_SITE_URL}/token (assuming I have it configured to work that way). Does this not conflict with the /token to be used for auth by convex auth as required by the OpenID spec?
13 replies