ADD CROSS DOMAIN SUPPORT
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
import { clerkClient } from '@clerk/fastify';
|
||||
|
||||
import { db, getProjectById } from '@openpanel/db';
|
||||
import { cacheable } from '@openpanel/redis';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { randomUUID } from 'crypto';
|
||||
import crypto from 'crypto';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { hashPassword, stripTrailingSlash } from '@openpanel/common';
|
||||
@@ -14,6 +14,7 @@ export const clientRouter = createTRPCRouter({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
cors: z.string().nullable(),
|
||||
crossDomain: z.boolean().optional(),
|
||||
})
|
||||
)
|
||||
.mutation(({ input }) => {
|
||||
@@ -24,6 +25,7 @@ export const clientRouter = createTRPCRouter({
|
||||
data: {
|
||||
name: input.name,
|
||||
cors: input.cors ?? null,
|
||||
crossDomain: input.crossDomain,
|
||||
},
|
||||
});
|
||||
}),
|
||||
@@ -34,11 +36,12 @@ export const clientRouter = createTRPCRouter({
|
||||
projectId: z.string(),
|
||||
organizationSlug: z.string(),
|
||||
cors: z.string().nullable(),
|
||||
crossDomain: z.boolean().optional(),
|
||||
type: z.enum(['read', 'write', 'root']).optional(),
|
||||
})
|
||||
)
|
||||
.mutation(async ({ input }) => {
|
||||
const secret = randomUUID();
|
||||
const secret = `sec_${crypto.randomBytes(10).toString('hex')}`;
|
||||
const data: Prisma.ClientCreateArgs['data'] = {
|
||||
organizationSlug: input.organizationSlug,
|
||||
organizationId: input.organizationSlug,
|
||||
@@ -47,6 +50,7 @@ export const clientRouter = createTRPCRouter({
|
||||
type: input.type ?? 'write',
|
||||
cors: input.cors ? stripTrailingSlash(input.cors) : null,
|
||||
secret: await hashPassword(secret),
|
||||
crossDomain: input.crossDomain ?? false,
|
||||
};
|
||||
|
||||
const client = await db.client.create({ data });
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { randomUUID } from 'crypto';
|
||||
import crypto from 'crypto';
|
||||
import type { z } from 'zod';
|
||||
|
||||
import { hashPassword, slug, stripTrailingSlash } from '@openpanel/common';
|
||||
import { hashPassword, stripTrailingSlash } from '@openpanel/common';
|
||||
import { db, getId, getOrganizationBySlug, getUserById } from '@openpanel/db';
|
||||
import type { ProjectType } from '@openpanel/db';
|
||||
import { zOnboardingProject } from '@openpanel/validation';
|
||||
@@ -66,7 +66,7 @@ export const onboardingRouter = createTRPCRouter({
|
||||
},
|
||||
});
|
||||
|
||||
const secret = randomUUID();
|
||||
const secret = `sec_${crypto.randomBytes(10).toString('hex')}`;
|
||||
const client = await db.client.create({
|
||||
data: {
|
||||
name: `${project.name} Client`,
|
||||
|
||||
Reference in New Issue
Block a user