Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

chore: Add logo field to OAuth app schema and update related code

Kiran K5cf4095d27bd
diff --git a/apps/web/app/api/oauth-apps/authorized/route.ts b/apps/web/app/api/oauth-apps/authorized/route.ts
index 9951cda7c1..6ef707040b 100644
--- a/apps/web/app/api/oauth-apps/authorized/route.ts
+++ b/apps/web/app/api/oauth-apps/authorized/route.ts
@@ -18,6 +18,7 @@ export const GET = withWorkspace(
name: true,
developer: true,
website: true,
+ logo: true,
},
},
user: {
@@ -36,6 +37,7 @@ export const GET = withWorkspace(
name: app.oAuthApp.name,
developer: app.oAuthApp.developer,
website: app.oAuthApp.website,
+ logo: app.oAuthApp.logo,
user: {
id: app.user.id,
name: app.user.name,
diff --git a/apps/web/app/api/oauth/userinfo/route.ts b/apps/web/app/api/oauth/userinfo/route.ts
index d057e7d878..a2ffce0947 100644
--- a/apps/web/app/api/oauth/userinfo/route.ts
+++ b/apps/web/app/api/oauth/userinfo/route.ts
@@ -43,6 +43,7 @@ export async function GET(req: NextRequest) {
id: user.id,
email: user.email,
name: user.name,
+ image: user.image,
};
return NextResponse.json(userInfo);
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/integrations/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/integrations/page-client.tsx
index e5ab9371f1..cd45632677 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/integrations/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/integrations/page-client.tsx
@@ -5,7 +5,13 @@ import { OAuthAuthorizedAppProps } from "@/lib/types";
import { useDeleteAppModal } from "@/ui/modals/delete-oauth-app-modal";
import EmptyState from "@/ui/shared/empty-state";
import { Delete } from "@/ui/shared/icons";
-import { Button, LoadingSpinner, Popover, TokenAvatar } from "@dub/ui";
+import {
+ BlurImage,
+ Button,
+ LoadingSpinner,
+ Popover,
+ TokenAvatar,
+} from "@dub/ui";
import { Key } from "@dub/ui/src/icons";
import { fetcher, formatDate } from "@dub/utils";
import { MoreVertical } from "lucide-react";
@@ -77,7 +83,17 @@ const AppRow = (app: OAuthAuthorizedAppProps) => {
<DeleteAppModal />
<div className="relative grid grid-cols-5 items-center px-5 py-3 sm:px-10">
<div className="col-span-3 flex items-center space-x-3">
- <TokenAvatar id={app.name} />
+ {app.logo ? (
+ <BlurImage
+ src={app.logo}
+ alt={`Logo for ${app.name}`}
+ className="h-10 w-10 rounded-full border border-gray-200"
+ width={20}
+ height={20}
+ />
+ ) : (
+ <TokenAvatar id={app.clientId} />
+ )}
<div className="flex flex-col space-y-px">
<p className="font-semibold text-gray-700">{app.name}</p>
<div className="flex items-center gap-x-2">
diff --git a/apps/web/lib/api/oauth/constants.ts b/apps/web/lib/api/oauth/constants.ts
index 79ce693bae..26a7922c68 100644
--- a/apps/web/lib/api/oauth/constants.ts
+++ b/apps/web/lib/api/oauth/constants.ts
@@ -42,5 +42,5 @@ export const OAUTH_SCOPE_DESCRIPTIONS = {
"analytics.read": "Read access to analytics and events",
"domains.read": "Read access to domains",
"domains.write": "Read and Write access to domains",
- "user.read": "Read access to your profile (name and email)",
+ "user.read": "Read your name, email and profile image",
};
diff --git a/apps/web/lib/zod/schemas/oauth.ts b/apps/web/lib/zod/schemas/oauth.ts
index 01edf2762b..fb2cb8d822 100644
--- a/apps/web/lib/zod/schemas/oauth.ts
+++ b/apps/web/lib/zod/schemas/oauth.ts
@@ -55,12 +55,11 @@ export const authorizeRequestSchema = z.object({
response_type: z.string().refine((responseType) => responseType === "code", {
message: "response_type must be 'code'",
}),
- state: z.string().max(255).optional(),
+ state: z.string().max(1024).optional(),
scope: z
.string()
- .max(255)
.nullable()
- .transform((scope) => [...new Set(scope?.split(","))] ?? [])
+ .transform((scope) => [...new Set(scope?.split(/[,\s]/).filter(Boolean))])
.refine(
(scopes) => {
return scopes.every((scope) => OAUTH_SCOPES.includes(scope));
@@ -71,7 +70,7 @@ export const authorizeRequestSchema = z.object({
),
// PKCE flow
- code_challenge: z.string().max(128).optional(),
+ code_challenge: z.string().max(190).optional(),
code_challenge_method: z.string(z.enum(["plain", "S256"])).optional(),
});
@@ -84,7 +83,7 @@ export const authCodeExchangeSchema = z.object({
redirect_uri: z.string().url({ message: "redirect_uri must be a valid URL" }),
// PKCE flow
- code_verifier: z.string().max(255).optional(),
+ code_verifier: z.string().max(190).optional(),
});
// Schema for OAuth2.0 token refresh request
@@ -120,5 +119,6 @@ export const oAuthAuthorizedAppSchema = z
name: true,
developer: true,
website: true,
+ logo: true,
}),
);