Skip to content

Commit 1549cd8

Browse files
authored
Merge pull request #2459 from trycompai/main
[comp] Production Deploy
2 parents 26d7676 + f38dd50 commit 1549cd8

4 files changed

Lines changed: 86 additions & 2 deletions

File tree

apps/api/src/integration-platform/controllers/admin-integrations.controller.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ export class AdminIntegrationsController {
6969
credentialUpdatedAt: credential?.updatedAt,
7070
clientIdHint: credential?.clientIdHint,
7171
clientSecretHint: credential?.clientSecretHint,
72+
encryptedClientId: credential?.encryptedClientId,
73+
encryptedClientSecret: credential?.encryptedClientSecret,
7274
existingCustomSettings:
7375
(credential as { customSettings?: Record<string, unknown> } | undefined)
7476
?.customSettings || undefined,

apps/app/src/app/(app)/[orgId]/admin/integrations/components/IntegrationCard.tsx

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
} from '@trycompai/design-system/icons';
1212
import Image from 'next/image';
1313
import { useState } from 'react';
14+
import { View, ViewOff } from '@trycompai/design-system/icons';
1415

1516
interface AdditionalOAuthSetting {
1617
id: string;
@@ -38,6 +39,8 @@ export interface Integration {
3839
credentialUpdatedAt?: string;
3940
clientIdHint?: string;
4041
clientSecretHint?: string;
42+
decryptedClientId?: string;
43+
decryptedClientSecret?: string;
4144
existingCustomSettings?: Record<string, unknown>;
4245
setupInstructions?: string;
4346
createAppUrl?: string;
@@ -152,6 +155,13 @@ export function IntegrationCard({
152155
)}
153156
</div>
154157

158+
{integration.hasCredentials && integration.decryptedClientId && (
159+
<CardCredentialsSummary
160+
clientId={integration.decryptedClientId}
161+
clientSecret={integration.decryptedClientSecret}
162+
/>
163+
)}
164+
155165
{integration.authType === 'oauth2' && (
156166
<OAuthConfig
157167
integration={integration}
@@ -355,6 +365,42 @@ function OAuthConfig({
355365
);
356366
}
357367

368+
function CardCredentialsSummary({
369+
clientId,
370+
clientSecret,
371+
}: {
372+
clientId: string;
373+
clientSecret?: string;
374+
}) {
375+
const [showSecret, setShowSecret] = useState(false);
376+
377+
return (
378+
<div className="space-y-1.5 rounded-lg bg-muted p-3">
379+
<div className="flex items-center gap-2">
380+
<span className="w-16 shrink-0 text-xs text-muted-foreground">Client ID</span>
381+
<code className="min-w-0 truncate rounded border bg-background px-2 py-0.5 text-xs select-all">
382+
{clientId}
383+
</code>
384+
</div>
385+
{clientSecret && (
386+
<div className="flex items-center gap-2">
387+
<span className="w-16 shrink-0 text-xs text-muted-foreground">Secret</span>
388+
<code className="min-w-0 truncate rounded border bg-background px-2 py-0.5 text-xs select-all">
389+
{showSecret ? clientSecret : `${'•'.repeat(Math.min(clientSecret.length, 20))}${clientSecret.slice(-4)}`}
390+
</code>
391+
<button
392+
type="button"
393+
className="shrink-0 text-muted-foreground hover:text-foreground"
394+
onClick={() => setShowSecret(!showSecret)}
395+
>
396+
{showSecret ? <ViewOff size={14} /> : <View size={14} />}
397+
</button>
398+
</div>
399+
)}
400+
</div>
401+
);
402+
}
403+
358404
function CredentialsDisplay({
359405
clientIdHint,
360406
clientSecretHint,

apps/app/src/app/(app)/[orgId]/admin/integrations/page.tsx

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use client';
22

33
import { api } from '@/lib/api-client';
4+
import { decrypt, type EncryptedData } from '@/lib/encryption';
45
import {
56
Button,
67
Card,
@@ -19,6 +20,34 @@ import { useState } from 'react';
1920
import useSWR from 'swr';
2021
import { IntegrationCard, type Integration } from './components/IntegrationCard';
2122

23+
interface ApiIntegration extends Integration {
24+
encryptedClientId?: EncryptedData;
25+
encryptedClientSecret?: EncryptedData;
26+
}
27+
28+
async function decryptIntegrations(integrations: ApiIntegration[]): Promise<Integration[]> {
29+
return Promise.all(
30+
integrations.map(async (integration) => {
31+
if (!integration.hasCredentials || !integration.encryptedClientId) {
32+
return integration;
33+
}
34+
35+
try {
36+
const [decryptedClientId, decryptedClientSecret] = await Promise.all([
37+
decrypt(integration.encryptedClientId),
38+
integration.encryptedClientSecret
39+
? decrypt(integration.encryptedClientSecret)
40+
: Promise.resolve(undefined),
41+
]);
42+
43+
return { ...integration, decryptedClientId, decryptedClientSecret };
44+
} catch {
45+
return integration;
46+
}
47+
}),
48+
);
49+
}
50+
2251
export default function AdminIntegrationsPage() {
2352
const [searchQuery, setSearchQuery] = useState('');
2453

@@ -28,9 +57,10 @@ export default function AdminIntegrationsPage() {
2857
isLoading,
2958
mutate,
3059
} = useSWR<Integration[]>('admin-integrations', async () => {
31-
const response = await api.get<Integration[]>('/v1/admin/integrations');
60+
const response = await api.get<ApiIntegration[]>('/v1/admin/integrations');
3261
if (response.error) throw new Error(response.error);
33-
return response.data || [];
62+
const raw = response.data || [];
63+
return decryptIntegrations(raw);
3464
});
3565

3666
const filteredIntegrations = integrations?.filter((i) => {

packages/docs/openapi.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21289,6 +21289,11 @@
2128921289
"description": "Whether member is active",
2129021290
"example": true
2129121291
},
21292+
"deactivated": {
21293+
"type": "boolean",
21294+
"description": "Whether member is deactivated",
21295+
"example": false
21296+
},
2129221297
"fleetDmLabelId": {
2129321298
"type": "object",
2129421299
"description": "FleetDM label ID for member devices",
@@ -21313,6 +21318,7 @@
2131321318
"department",
2131421319
"jobTitle",
2131521320
"isActive",
21321+
"deactivated",
2131621322
"fleetDmLabelId",
2131721323
"user"
2131821324
]

0 commit comments

Comments
 (0)