ADD CROSS DOMAIN SUPPORT
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "clients" ADD COLUMN "crossDomain" BOOLEAN NOT NULL DEFAULT false;
|
||||
@@ -171,6 +171,7 @@ model Client {
|
||||
organization Organization? @relation(fields: [organizationId], references: [id])
|
||||
organizationId String?
|
||||
cors String?
|
||||
crossDomain Boolean @default(false)
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @default(now()) @updatedAt
|
||||
|
||||
@@ -16,5 +16,8 @@ export async function getClientsByOrganizationSlug(organizationSlug: string) {
|
||||
include: {
|
||||
project: true,
|
||||
},
|
||||
orderBy: {
|
||||
createdAt: 'asc',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -18,11 +18,12 @@ export interface EventsQueuePayloadIncomingEvent {
|
||||
latitude: number | undefined;
|
||||
};
|
||||
headers: {
|
||||
origin: string | undefined;
|
||||
ua: string | undefined;
|
||||
};
|
||||
currentDeviceId: string;
|
||||
previousDeviceId: string;
|
||||
currentDeviceIdDeprecated: string;
|
||||
previousDeviceIdDeprecated: string;
|
||||
};
|
||||
}
|
||||
export interface EventsQueuePayloadCreateEvent {
|
||||
|
||||
@@ -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