mirror of
https://github.com/documenso/documenso.git
synced 2026-07-27 18:35:05 +10:00
chore: merge main, resolve biome formatting conflicts
Merge origin/main into feat/external-2fa-codes. Resolve formatting conflicts caused by biome rollout; preserve both feature streams: PR's external 2FA token + signing-session 2FA proof additions plus main's RateLimit/RecipientExpired/signingReminders/date-auto-insert. In complete-document-with-token.ts, drop the duplicate early field-fetching block introduced when main moved that logic later with date auto-insert support; keep the EXTERNAL_TWO_FACTOR_AUTH check using derivedRecipientActionAuth.
This commit is contained in:
@@ -1,14 +1,9 @@
|
||||
import { ZEmailDomainSchema } from '@documenso/lib/types/email-domain';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { ZEmailDomainSchema } from '@documenso/lib/types/email-domain';
|
||||
export const domainRegex = /^(?!https?:\/\/)(?!www\.)([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
|
||||
|
||||
export const domainRegex =
|
||||
/^(?!https?:\/\/)(?!www\.)([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
|
||||
|
||||
export const ZDomainSchema = z
|
||||
.string()
|
||||
.regex(domainRegex, { message: 'Invalid domain name' })
|
||||
.toLowerCase();
|
||||
export const ZDomainSchema = z.string().regex(domainRegex, { message: 'Invalid domain name' }).toLowerCase();
|
||||
|
||||
export const ZCreateOrganisationEmailDomainRequestSchema = z.object({
|
||||
organisationId: z.string(),
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { zEmail } from '@documenso/lib/utils/zod';
|
||||
import { z } from 'zod';
|
||||
|
||||
export const ZCreateOrganisationEmailRequestSchema = z.object({
|
||||
emailDomainId: z.string(),
|
||||
emailName: z.string().min(1).max(100),
|
||||
email: z.string().email().toLowerCase(),
|
||||
email: zEmail().toLowerCase(),
|
||||
|
||||
// This does not need to be validated to be part of the domain.
|
||||
// replyTo: z.string().email().optional(),
|
||||
|
||||
@@ -6,6 +6,4 @@ export const ZDeclineLinkOrganisationAccountRequestSchema = z.object({
|
||||
|
||||
export const ZDeclineLinkOrganisationAccountResponseSchema = z.void();
|
||||
|
||||
export type TDeclineLinkOrganisationAccountRequest = z.infer<
|
||||
typeof ZDeclineLinkOrganisationAccountRequestSchema
|
||||
>;
|
||||
export type TDeclineLinkOrganisationAccountRequest = z.infer<typeof ZDeclineLinkOrganisationAccountRequestSchema>;
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import type { EmailDomainStatus } from '@prisma/client';
|
||||
import { Prisma } from '@prisma/client';
|
||||
|
||||
import { AppError, AppErrorCode } from '@documenso/lib/errors/app-error';
|
||||
import type { FindResultResponse } from '@documenso/lib/types/search-params';
|
||||
import { buildOrganisationWhereQuery } from '@documenso/lib/utils/organisations';
|
||||
import { prisma } from '@documenso/prisma';
|
||||
import type { EmailDomainStatus } from '@prisma/client';
|
||||
import { Prisma } from '@prisma/client';
|
||||
|
||||
import { authenticatedProcedure } from '../trpc';
|
||||
import {
|
||||
@@ -95,6 +94,7 @@ export const findOrganisationEmailDomains = async ({
|
||||
selector: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
lastVerifiedAt: true,
|
||||
_count: {
|
||||
select: {
|
||||
emails: true,
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { EmailDomainStatus } from '@prisma/client';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { ZEmailDomainManySchema } from '@documenso/lib/types/email-domain';
|
||||
import { ZFindResultResponse, ZFindSearchParamsSchema } from '@documenso/lib/types/search-params';
|
||||
import { EmailDomainStatus } from '@prisma/client';
|
||||
import { z } from 'zod';
|
||||
|
||||
export const ZFindOrganisationEmailDomainsRequestSchema = ZFindSearchParamsSchema.extend({
|
||||
organisationId: z.string(),
|
||||
@@ -18,6 +17,4 @@ export const ZFindOrganisationEmailDomainsResponseSchema = ZFindResultResponse.e
|
||||
),
|
||||
});
|
||||
|
||||
export type TFindOrganisationEmailDomainsResponse = z.infer<
|
||||
typeof ZFindOrganisationEmailDomainsResponseSchema
|
||||
>;
|
||||
export type TFindOrganisationEmailDomainsResponse = z.infer<typeof ZFindOrganisationEmailDomainsResponseSchema>;
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { Prisma } from '@prisma/client';
|
||||
|
||||
import { AppError, AppErrorCode } from '@documenso/lib/errors/app-error';
|
||||
import type { FindResultResponse } from '@documenso/lib/types/search-params';
|
||||
import { buildOrganisationWhereQuery } from '@documenso/lib/utils/organisations';
|
||||
import { prisma } from '@documenso/prisma';
|
||||
import { Prisma } from '@prisma/client';
|
||||
|
||||
import { authenticatedProcedure } from '../trpc';
|
||||
import {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import { ZOrganisationEmailManySchema } from '@documenso/lib/types/organisation-email';
|
||||
import { ZFindResultResponse, ZFindSearchParamsSchema } from '@documenso/lib/types/search-params';
|
||||
import { z } from 'zod';
|
||||
|
||||
export const ZFindOrganisationEmailsRequestSchema = ZFindSearchParamsSchema.extend({
|
||||
organisationId: z.string(),
|
||||
|
||||
@@ -52,6 +52,7 @@ export const getOrganisationAuthenticationPortal = async ({
|
||||
wellKnownUrl: true,
|
||||
autoProvisionUsers: true,
|
||||
allowedDomains: true,
|
||||
allowPersonalOrganisations: true,
|
||||
clientSecret: true,
|
||||
},
|
||||
},
|
||||
@@ -79,6 +80,7 @@ export const getOrganisationAuthenticationPortal = async ({
|
||||
wellKnownUrl: portal.wellKnownUrl,
|
||||
autoProvisionUsers: portal.autoProvisionUsers,
|
||||
allowedDomains: portal.allowedDomains,
|
||||
allowPersonalOrganisations: portal.allowPersonalOrganisations,
|
||||
clientSecretProvided: Boolean(portal.clientSecret),
|
||||
};
|
||||
};
|
||||
|
||||
+17
-18
@@ -1,27 +1,26 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import { OrganisationAuthenticationPortalSchema } from '@documenso/prisma/generated/zod/modelSchema/OrganisationAuthenticationPortalSchema';
|
||||
import { z } from 'zod';
|
||||
|
||||
export const ZGetOrganisationAuthenticationPortalRequestSchema = z.object({
|
||||
organisationId: z.string(),
|
||||
});
|
||||
|
||||
export const ZGetOrganisationAuthenticationPortalResponseSchema =
|
||||
OrganisationAuthenticationPortalSchema.pick({
|
||||
defaultOrganisationRole: true,
|
||||
enabled: true,
|
||||
clientId: true,
|
||||
wellKnownUrl: true,
|
||||
autoProvisionUsers: true,
|
||||
allowedDomains: true,
|
||||
}).extend({
|
||||
/**
|
||||
* Whether we have the client secret in the database.
|
||||
*
|
||||
* Do not expose the actual client secret.
|
||||
*/
|
||||
clientSecretProvided: z.boolean(),
|
||||
});
|
||||
export const ZGetOrganisationAuthenticationPortalResponseSchema = OrganisationAuthenticationPortalSchema.pick({
|
||||
defaultOrganisationRole: true,
|
||||
enabled: true,
|
||||
clientId: true,
|
||||
wellKnownUrl: true,
|
||||
autoProvisionUsers: true,
|
||||
allowedDomains: true,
|
||||
allowPersonalOrganisations: true,
|
||||
}).extend({
|
||||
/**
|
||||
* Whether we have the client secret in the database.
|
||||
*
|
||||
* Do not expose the actual client secret.
|
||||
*/
|
||||
clientSecretProvided: z.boolean(),
|
||||
});
|
||||
|
||||
export type TGetOrganisationAuthenticationPortalResponse = z.infer<
|
||||
typeof ZGetOrganisationAuthenticationPortalResponseSchema
|
||||
|
||||
@@ -32,10 +32,7 @@ type GetOrganisationEmailDomainOptions = {
|
||||
emailDomainId: string;
|
||||
};
|
||||
|
||||
export const getOrganisationEmailDomain = async ({
|
||||
userId,
|
||||
emailDomainId,
|
||||
}: GetOrganisationEmailDomainOptions) => {
|
||||
export const getOrganisationEmailDomain = async ({ userId, emailDomainId }: GetOrganisationEmailDomainOptions) => {
|
||||
const emailDomain = await prisma.emailDomain.findFirst({
|
||||
where: {
|
||||
id: emailDomainId,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import { ZEmailDomainSchema } from '@documenso/lib/types/email-domain';
|
||||
import { z } from 'zod';
|
||||
|
||||
export const ZGetOrganisationEmailDomainRequestSchema = z.object({
|
||||
emailDomainId: z.string(),
|
||||
@@ -8,6 +7,4 @@ export const ZGetOrganisationEmailDomainRequestSchema = z.object({
|
||||
|
||||
export const ZGetOrganisationEmailDomainResponseSchema = ZEmailDomainSchema;
|
||||
|
||||
export type TGetOrganisationEmailDomainResponse = z.infer<
|
||||
typeof ZGetOrganisationEmailDomainResponseSchema
|
||||
>;
|
||||
export type TGetOrganisationEmailDomainResponse = z.infer<typeof ZGetOrganisationEmailDomainResponseSchema>;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { linkOrganisationAccount } from '@documenso/ee/server-only/lib/link-organisation-account';
|
||||
import { assertRateLimit } from '@documenso/lib/server-only/rate-limit/rate-limit-middleware';
|
||||
import { linkOrgAccountRateLimit } from '@documenso/lib/server-only/rate-limit/rate-limits';
|
||||
|
||||
import { procedure } from '../trpc';
|
||||
import {
|
||||
@@ -15,6 +17,13 @@ export const linkOrganisationAccountRoute = procedure
|
||||
.mutation(async ({ input, ctx }) => {
|
||||
const { token } = input;
|
||||
|
||||
const rateLimitResult = await linkOrgAccountRateLimit.check({
|
||||
ip: ctx.metadata.requestMetadata.ipAddress ?? 'unknown',
|
||||
identifier: token,
|
||||
});
|
||||
|
||||
assertRateLimit(rateLimitResult);
|
||||
|
||||
await linkOrganisationAccount({
|
||||
token,
|
||||
requestMeta: ctx.metadata.requestMetadata,
|
||||
|
||||
@@ -61,17 +61,15 @@ export const updateOrganisationAuthenticationPortalRoute = authenticatedProcedur
|
||||
wellKnownUrl,
|
||||
autoProvisionUsers,
|
||||
allowedDomains,
|
||||
allowPersonalOrganisations,
|
||||
} = data;
|
||||
|
||||
if (
|
||||
enabled &&
|
||||
(!wellKnownUrl ||
|
||||
!clientId ||
|
||||
(!clientSecret && !organisation.organisationAuthenticationPortal.clientSecret))
|
||||
(!wellKnownUrl || !clientId || (!clientSecret && !organisation.organisationAuthenticationPortal.clientSecret))
|
||||
) {
|
||||
throw new AppError(AppErrorCode.INVALID_BODY, {
|
||||
message:
|
||||
'Client ID, client secret, and well known URL are required when authentication portal is enabled',
|
||||
message: 'Client ID, client secret, and well known URL are required when authentication portal is enabled',
|
||||
});
|
||||
}
|
||||
|
||||
@@ -104,6 +102,7 @@ export const updateOrganisationAuthenticationPortalRoute = authenticatedProcedur
|
||||
wellKnownUrl,
|
||||
autoProvisionUsers,
|
||||
allowedDomains,
|
||||
allowPersonalOrganisations,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
+2
-2
@@ -1,6 +1,5 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import OrganisationMemberRoleSchema from '@documenso/prisma/generated/zod/inputTypeSchemas/OrganisationMemberRoleSchema';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { domainRegex } from './create-organisation-email-domain.types';
|
||||
|
||||
@@ -14,6 +13,7 @@ export const ZUpdateOrganisationAuthenticationPortalRequestSchema = z.object({
|
||||
wellKnownUrl: z.union([z.string().url(), z.literal('')]),
|
||||
autoProvisionUsers: z.boolean(),
|
||||
allowedDomains: z.array(z.string().regex(domainRegex)),
|
||||
allowPersonalOrganisations: z.boolean(),
|
||||
}),
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user