π¨ The ultimate agentic social media scheduling tool π€
TypeScript nextjsopen-sourceopen-source-social-media-scheduling-toolosspostiz-cloudpostiz-hostedredisscheduling-toolsocial-media-scheduling-tooltypescript
feat: claude dynamic registration
Nevo Davideabac3d3dc9a
diff --git a/.env.example b/.env.exampleindex 7a5128488..51ac5c369 100644--- a/.env.example+++ b/.env.example@@ -103,6 +103,13 @@ OPENAI_API_KEY=""# OAuth client configured for the ChatGPT app. Only this client can receive# verified user email claims for ChatGPT Enterprise domain restrictions.OPENAI_OAUTH_CLIENT_ID=""+# MCP OAuth Dynamic Client Registration (RFC 7591) redirect-domain allowlist.+# When set (comma separated), POST /oauth/register only accepts redirect_uris+# whose host matches a listed domain or one of its subdomains; unset or empty+# means any client can self-register. Example locks DCR to the claude.ai+# connector (note: also blocks localhost callbacks, e.g. Claude Code -+# those clients can use the API-key /mcp/:id endpoints instead).+# DCR_VERIFIED_DOMAINS="claude.ai,claude.com"NEXT_PUBLIC_DISCORD_SUPPORT=""NEXT_PUBLIC_POLOTNO=""# NOT_SECURED=falsediff --git a/apps/backend/src/api/routes/oauth.controller.ts b/apps/backend/src/api/routes/oauth.controller.tsindex 1d2c5e957..9076b75b5 100644--- a/apps/backend/src/api/routes/oauth.controller.ts+++ b/apps/backend/src/api/routes/oauth.controller.ts@@ -3,6 +3,7 @@ import {Controller,Get,Headers,+ HttpCode,HttpException,HttpStatus,Post,@@ -15,16 +16,29 @@ import { GetOrgFromRequest } from '@gitroom/nestjs-libraries/user/org.from.requeimport { User, Organization } from '@prisma/client';import { AuthorizeOAuthQueryDto, ApproveOAuthDto } from '@gitroom/nestjs-libraries/dtos/oauth/authorize-oauth.dto';import { TokenExchangeDto } from '@gitroom/nestjs-libraries/dtos/oauth/token-exchange.dto';+import { RegisterClientDto } from '@gitroom/nestjs-libraries/dtos/oauth/register-client.dto';@ApiTags('OAuth')@Controller('/oauth')export class OAuthController {constructor(private _oauthService: OAuthService) {}+ // Dynamic Client Registration (RFC 7591), used by MCP clients like Claude+ @Post('/register')+ @HttpCode(201)+ async register(@Body() body: RegisterClientDto) {+ return this._oauthService.registerDynamicClient(body);+ }+@Get('/authorize')async authorize(@Query() query: AuthorizeOAuthQueryDto) {const app = await this._oauthService.validateAuthorizationRequest(- query.client_id+ query.client_id,+ {+ redirectUri: query.redirect_uri,+ codeChallenge: query.code_challenge,+ codeChallengeMethod: query.code_challenge_method,+ });return {@@ -51,7 +65,9 @@ export class OAuthController {return this._oauthService.exchangeCodeForToken(body.code,body.client_id,- body.client_secret+ body.client_secret,+ body.code_verifier,+ body.redirect_uri);}@@ -78,11 +94,20 @@ export class OAuthAuthorizedController {@GetOrgFromRequest() org: Organization) {const app = await this._oauthService.validateAuthorizationRequest(- body.client_id+ body.client_id,+ {+ redirectUri: body.redirect_uri,+ codeChallenge: body.code_challenge,+ codeChallengeMethod: body.code_challenge_method,+ });+ // Dynamic clients redirect to their validated redirect_uri,+ // static apps keep using the one stored on the app+ const redirectTarget = app.dynamic ? body.redirect_uri! : app.redirectUrl;+if (body.action === 'deny') {- const redirectUrl = new URL(app.redirectUrl);+ const redirectUrl = new URL(redirectTarget);redirectUrl.searchParams.set('error', 'access_denied');if (body.state) {redirectUrl.searchParams.set('state', body.state);@@ -93,10 +118,17 @@ export class OAuthAuthorizedController {const code = await this._oauthService.createAuthorizationCode(app.id,user.id,- org.id+ org.id,+ app.dynamic+ ? {+ codeChallenge: body.code_challenge,+ codeChallengeMethod: body.code_challenge_method,+ redirectUri: body.redirect_uri,+ }+ : undefined);- const redirectUrl = new URL(app.redirectUrl);+ const redirectUrl = new URL(redirectTarget);redirectUrl.searchParams.set('code', code);if (body.state) {redirectUrl.searchParams.set('state', body.state);diff --git a/apps/frontend/src/app/(app)/oauth/authorize/page.tsx b/apps/frontend/src/app/(app)/oauth/authorize/page.tsxindex 14d203d8c..29c2ce128 100644--- a/apps/frontend/src/app/(app)/oauth/authorize/page.tsx+++ b/apps/frontend/src/app/(app)/oauth/authorize/page.tsx@@ -16,6 +16,9 @@ export default function OAuthAuthorizePage() {const clientId = searchParams.get('client_id');const responseType = searchParams.get('response_type');const state = searchParams.get('state');+ const redirectUri = searchParams.get('redirect_uri');+ const codeChallenge = searchParams.get('code_challenge');+ const codeChallengeMethod = searchParams.get('code_challenge_method');useEffect(() => {if (!clientId || !responseType) {@@ -33,6 +36,11 @@ export default function OAuthAuthorizePage() {client_id: clientId,response_type: responseType,...(state ? { state } : {}),+ ...(redirectUri ? { redirect_uri: redirectUri } : {}),+ ...(codeChallenge ? { code_challenge: codeChallenge } : {}),+ ...(codeChallengeMethod+ ? { code_challenge_method: codeChallengeMethod }+ : {}),});fetch(`/oauth/authorize?${params}`)@@ -49,7 +57,7 @@ export default function OAuthAuthorizePage() {setError('Failed to validate OAuth request');setLoading(false);});- }, [clientId, responseType, state]);+ }, [clientId, responseType, state, redirectUri, codeChallenge, codeChallengeMethod]);const handleAction = useCallback(async (action: 'approve' | 'deny') => {@@ -62,6 +70,11 @@ export default function OAuthAuthorizePage() {client_id: clientId,state,action,+ ...(redirectUri ? { redirect_uri: redirectUri } : {}),+ ...(codeChallenge ? { code_challenge: codeChallenge } : {}),+ ...(codeChallengeMethod+ ? { code_challenge_method: codeChallengeMethod }+ : {}),}),})).json();@@ -74,7 +87,7 @@ export default function OAuthAuthorizePage() {setSubmitting(false);}},- [clientId, state]+ [clientId, state, redirectUri, codeChallenge, codeChallengeMethod]);if (loading) {diff --git a/libraries/nestjs-libraries/src/chat/start.mcp.ts b/libraries/nestjs-libraries/src/chat/start.mcp.tsindex 0090ffb7f..0099162c2 100644--- a/libraries/nestjs-libraries/src/chat/start.mcp.ts+++ b/libraries/nestjs-libraries/src/chat/start.mcp.ts@@ -158,12 +158,13 @@ export const startMcp = async (app: INestApplication) => {issuer: oauthResource,authorization_endpoint: `${process.env.FRONTEND_URL}/oauth/authorize`,token_endpoint: `${process.env.NEXT_PUBLIC_OVERRIDE_BACKEND_URL || process.env.NEXT_PUBLIC_BACKEND_URL}/oauth/token`,+ registration_endpoint: `${process.env.NEXT_PUBLIC_OVERRIDE_BACKEND_URL || process.env.NEXT_PUBLIC_BACKEND_URL}/oauth/register`,...(enableOidcEmailClaims && {userinfo_endpoint: `${process.env.NEXT_PUBLIC_OVERRIDE_BACKEND_URL || process.env.NEXT_PUBLIC_BACKEND_URL}/oauth/userinfo`,}),response_types_supported: ['code'],grant_types_supported: ['authorization_code'],- token_endpoint_auth_methods_supported: ['client_secret_post'],+ token_endpoint_auth_methods_supported: ['client_secret_post', 'none'],code_challenge_methods_supported: ['S256'],scopes_supported: oauthScopes,});@@ -189,10 +190,11 @@ export const startMcp = async (app: INestApplication) => {issuer: oauthResource,authorization_endpoint: `${process.env.FRONTEND_URL}/oauth/authorize`,token_endpoint: `${process.env.NEXT_PUBLIC_OVERRIDE_BACKEND_URL || process.env.NEXT_PUBLIC_BACKEND_URL}/oauth/token`,+ registration_endpoint: `${process.env.NEXT_PUBLIC_OVERRIDE_BACKEND_URL || process.env.NEXT_PUBLIC_BACKEND_URL}/oauth/register`,userinfo_endpoint: `${process.env.NEXT_PUBLIC_OVERRIDE_BACKEND_URL || process.env.NEXT_PUBLIC_BACKEND_URL}/oauth/userinfo`,response_types_supported: ['code'],grant_types_supported: ['authorization_code'],- token_endpoint_auth_methods_supported: ['client_secret_post'],+ token_endpoint_auth_methods_supported: ['client_secret_post', 'none'],code_challenge_methods_supported: ['S256'],scopes_supported: oauthScopes,subject_types_supported: ['public'],diff --git a/libraries/nestjs-libraries/src/database/prisma/oauth/oauth.repository.ts b/libraries/nestjs-libraries/src/database/prisma/oauth/oauth.repository.tsindex 0d20110ee..50663d7fc 100644--- a/libraries/nestjs-libraries/src/database/prisma/oauth/oauth.repository.ts+++ b/libraries/nestjs-libraries/src/database/prisma/oauth/oauth.repository.ts@@ -59,6 +59,39 @@ export class OAuthRepository {});}+ createDynamicApp(data: {+ name: string;+ redirectUrl: string;+ redirectUris: string;+ clientId: string;+ clientSecret?: string;+ tokenEndpointAuthMethod: string;+ }) {+ return this._oauthApp.model.oAuthApp.create({+ data: {+ name: data.name,+ redirectUrl: data.redirectUrl,+ redirectUris: data.redirectUris,+ clientId: data.clientId,+ clientSecret: data.clientSecret,+ tokenEndpointAuthMethod: data.tokenEndpointAuthMethod,+ dynamic: true,+ },+ });+ }++ // Dynamic clients register before the consent screen, so abandoned flows+ // leave orphan rows; prune the ones no user ever authorized+ deleteStaleDynamicApps(olderThan: Date) {+ return this._oauthApp.model.oAuthApp.deleteMany({+ where: {+ dynamic: true,+ createdAt: { lt: olderThan },+ authorizations: { none: {} },+ },+ });+ }+async updateApp(orgId: string,data: {@@ -128,6 +161,9 @@ export class OAuthRepository {organizationId: string;authorizationCode: string;codeExpiresAt: Date;+ codeChallenge?: string;+ codeChallengeMethod?: string;+ redirectUri?: string;}) {return this._oauthAuth.model.oAuthAuthorization.upsert({where: {@@ -143,10 +179,16 @@ export class OAuthRepository {organizationId: data.organizationId,authorizationCode: data.authorizationCode,codeExpiresAt: data.codeExpiresAt,+ codeChallenge: data.codeChallenge || null,+ codeChallengeMethod: data.codeChallengeMethod || null,+ redirectUri: data.redirectUri || null,},update: {authorizationCode: data.authorizationCode,codeExpiresAt: data.codeExpiresAt,+ codeChallenge: data.codeChallenge || null,+ codeChallengeMethod: data.codeChallengeMethod || null,+ redirectUri: data.redirectUri || null,accessToken: null,revokedAt: null,},@@ -177,6 +219,9 @@ export class OAuthRepository {accessToken: encryptedToken,authorizationCode: null,codeExpiresAt: null,+ codeChallenge: null,+ codeChallengeMethod: null,+ redirectUri: null,},});}diff --git a/libraries/nestjs-libraries/src/database/prisma/oauth/oauth.service.ts b/libraries/nestjs-libraries/src/database/prisma/oauth/oauth.service.tsindex fbb0c29df..ea18333f7 100644--- a/libraries/nestjs-libraries/src/database/prisma/oauth/oauth.service.ts+++ b/libraries/nestjs-libraries/src/database/prisma/oauth/oauth.service.ts@@ -2,9 +2,11 @@ import { HttpException, HttpStatus, Injectable } from '@nestjs/common';import { OAuthRepository } from '@gitroom/nestjs-libraries/database/prisma/oauth/oauth.repository';import { CreateOAuthAppDto } from '@gitroom/nestjs-libraries/dtos/oauth/create-oauth-app.dto';import { UpdateOAuthAppDto } from '@gitroom/nestjs-libraries/dtos/oauth/update-oauth-app.dto';+import { RegisterClientDto } from '@gitroom/nestjs-libraries/dtos/oauth/register-client.dto';import { makeId } from '@gitroom/nestjs-libraries/services/make.is';import { AuthService } from '@gitroom/helpers/auth/auth.service';import { extractBearerToken } from '@gitroom/nestjs-libraries/chat/oauth-types';+import { createHash } from 'crypto';const openAiOAuthClientId = () =>process.env.OPENAI_OAUTH_CLIENT_ID?.trim();@@ -85,18 +87,145 @@ export class OAuthService {return { clientSecret: newSecret };}- async validateAuthorizationRequest(clientId: string) {+ // Domains allowed to receive DCR redirect_uris, from the+ // DCR_VERIFIED_DOMAINS env (comma separated). An empty list+ // means open registration (self-hosted default)+ private verifiedDomainList() {+ return (process.env.DCR_VERIFIED_DOMAINS || '')+ .split(',')+ .map((domain) => domain.trim().toLowerCase())+ .filter(Boolean);+ }++ async registerDynamicClient(dto: RegisterClientDto) {+ const redirectUris = dto.redirect_uris.map((uri) => uri.trim());+ for (const uri of redirectUris) {+ let parsed: URL;+ try {+ parsed = new URL(uri);+ } catch {+ throw new HttpException(+ { error: 'invalid_redirect_uri', error_description: `Invalid redirect_uri: ${uri}` },+ HttpStatus.BAD_REQUEST+ );+ }+ const isLoopback = ['localhost', '127.0.0.1', '[::1]'].includes(parsed.hostname);+ if (parsed.protocol !== 'https:' && !isLoopback) {+ throw new HttpException(+ { error: 'invalid_redirect_uri', error_description: 'redirect_uris must use https (http is allowed for loopback only)' },+ HttpStatus.BAD_REQUEST+ );+ }+ }++ const verifiedDomains = this.verifiedDomainList();+ if (verifiedDomains.length) {+ for (const uri of redirectUris) {+ const host = new URL(uri).hostname.toLowerCase();+ const isVerified = verifiedDomains.some(+ (domain) => host === domain || host.endsWith('.' + domain)+ );+ if (!isVerified) {+ throw new HttpException(+ {+ error: 'invalid_redirect_uri',+ error_description: `redirect_uri host "${host}" is not a verified domain`,+ },+ HttpStatus.BAD_REQUEST+ );+ }+ }+ }++ if (dto.grant_types?.length && !dto.grant_types.includes('authorization_code')) {+ throw new HttpException(+ { error: 'invalid_client_metadata', error_description: 'Only the authorization_code grant type is supported' },+ HttpStatus.BAD_REQUEST+ );+ }++ // Registration happens before consent, so abandoned flows leave orphan+ // clients behind; opportunistically prune the ones nobody ever authorized+ this._oauthRepository+ .deleteStaleDynamicApps(new Date(Date.now() - 30 * 24 * 60 * 60 * 1000))+ .catch(() => {});++ const isPublicClient = dto.token_endpoint_auth_method === 'none';+ const clientId = 'pcd_' + makeId(32);+ const clientSecret = isPublicClient ? undefined : 'pcs_' + makeId(48);++ const app = await this._oauthRepository.createDynamicApp({+ name: dto.client_name?.trim().slice(0, 100) || 'MCP Client',+ redirectUrl: redirectUris[0],+ redirectUris: JSON.stringify(redirectUris),+ clientId,+ clientSecret: clientSecret && AuthService.fixedEncryption(clientSecret),+ tokenEndpointAuthMethod: isPublicClient ? 'none' : 'client_secret_post',+ });++ return {+ client_id: clientId,+ ...(clientSecret ? { client_secret: clientSecret, client_secret_expires_at: 0 } : {}),+ client_id_issued_at: Math.floor(app.createdAt.getTime() / 1000),+ client_name: app.name,+ redirect_uris: redirectUris,+ token_endpoint_auth_method: isPublicClient ? 'none' : 'client_secret_post',+ grant_types: ['authorization_code'],+ response_types: ['code'],+ scope: 'mcp:read mcp:write',+ };+ }++ async validateAuthorizationRequest(+ clientId: string,+ options?: {+ redirectUri?: string;+ codeChallenge?: string;+ codeChallengeMethod?: string;+ }+ ) {const app = await this._oauthRepository.getAppByClientId(clientId);if (!app) {throw new HttpException('Invalid client_id', HttpStatus.BAD_REQUEST);}++ // Dynamically registered clients must use their registered redirect_uris+ // and PKCE; statically registered apps keep the existing lenient flow+ if (app.dynamic) {+ const registered: string[] = JSON.parse(app.redirectUris || '[]');+ if (!options?.redirectUri || !registered.includes(options.redirectUri)) {+ throw new HttpException('Invalid redirect_uri', HttpStatus.BAD_REQUEST);+ }+ if (app.tokenEndpointAuthMethod === 'none' && !options?.codeChallenge) {+ throw new HttpException(+ 'code_challenge is required for this client',+ HttpStatus.BAD_REQUEST+ );+ }+ if (+ options?.codeChallenge &&+ options?.codeChallengeMethod &&+ options.codeChallengeMethod !== 'S256'+ ) {+ throw new HttpException(+ 'Only the S256 code_challenge_method is supported',+ HttpStatus.BAD_REQUEST+ );+ }+ }+return app;}async createAuthorizationCode(oauthAppId: string,userId: string,- organizationId: string+ organizationId: string,+ pkce?: {+ codeChallenge?: string;+ codeChallengeMethod?: string;+ redirectUri?: string;+ }) {const code = makeId(32);const encryptedCode = AuthService.fixedEncryption(code);@@ -108,6 +237,9 @@ export class OAuthService {organizationId,authorizationCode: encryptedCode,codeExpiresAt,+ codeChallenge: pkce?.codeChallenge,+ codeChallengeMethod: pkce?.codeChallengeMethod,+ redirectUri: pkce?.redirectUri,});return code;@@ -116,7 +248,9 @@ export class OAuthService {async exchangeCodeForToken(code: string,clientId: string,- clientSecret: string+ clientSecret?: string,+ codeVerifier?: string,+ redirectUri?: string) {const app = await this._oauthRepository.getAppByClientId(clientId);if (!app) {@@ -126,11 +260,20 @@ export class OAuthService {);}- if (app.clientSecret !== AuthService.fixedEncryption(clientSecret)) {- throw new HttpException(- { error: 'invalid_client' },- HttpStatus.UNAUTHORIZED- );+ // Public clients (dynamic registration with token_endpoint_auth_method=none)+ // authenticate with PKCE instead of a client secret+ const isPublicClient = app.dynamic && app.tokenEndpointAuthMethod === 'none';+ if (!isPublicClient) {+ if (+ !clientSecret ||+ !app.clientSecret ||+ app.clientSecret !== AuthService.fixedEncryption(clientSecret)+ ) {+ throw new HttpException(+ { error: 'invalid_client' },+ HttpStatus.UNAUTHORIZED+ );+ }}const encryptedCode = AuthService.fixedEncryption(code);@@ -149,6 +292,29 @@ export class OAuthService {);}+ if (auth.codeChallenge) {+ if (!codeVerifier) {+ throw new HttpException(+ { error: 'invalid_grant', error_description: 'code_verifier is required' },+ HttpStatus.BAD_REQUEST+ );+ }+ const hashed = createHash('sha256').update(codeVerifier).digest('base64url');+ if (hashed !== auth.codeChallenge) {+ throw new HttpException(+ { error: 'invalid_grant', error_description: 'Invalid code_verifier' },+ HttpStatus.BAD_REQUEST+ );+ }+ }++ if (auth.redirectUri && redirectUri !== auth.redirectUri) {+ throw new HttpException(+ { error: 'invalid_grant', error_description: 'redirect_uri does not match the authorization request' },+ HttpStatus.BAD_REQUEST+ );+ }+const token = 'pos_' + makeId(40);const encryptedToken = AuthService.fixedEncryption(token);const {diff --git a/libraries/nestjs-libraries/src/database/prisma/schema.prisma b/libraries/nestjs-libraries/src/database/prisma/schema.prismaindex 629637450..a0c7ca154 100644--- a/libraries/nestjs-libraries/src/database/prisma/schema.prisma+++ b/libraries/nestjs-libraries/src/database/prisma/schema.prisma@@ -847,41 +847,48 @@ model mastra_workflow_snapshot {}model OAuthApp {- id String @id @default(uuid())- organizationId String- name String- description String?- pictureId String?- redirectUrl String- clientId String @unique- clientSecret String- createdAt DateTime @default(now())- updatedAt DateTime @updatedAt- deletedAt DateTime?- organization Organization @relation(fields: [organizationId], references: [id])- picture Media? @relation(fields: [pictureId], references: [id])- authorizations OAuthAuthorization[]+ id String @id @default(uuid())+ organizationId String?+ name String+ description String?+ pictureId String?+ redirectUrl String+ redirectUris String?+ clientId String @unique+ clientSecret String?+ dynamic Boolean @default(false)+ tokenEndpointAuthMethod String?+ createdAt DateTime @default(now())+ updatedAt DateTime @updatedAt+ deletedAt DateTime?+ organization Organization? @relation(fields: [organizationId], references: [id])+ picture Media? @relation(fields: [pictureId], references: [id])+ authorizations OAuthAuthorization[]@@unique([organizationId, deletedAt])@@index([clientId])@@index([organizationId])@@index([deletedAt])+ @@index([dynamic])}model OAuthAuthorization {- id String @id @default(uuid())- oauthAppId String- userId String- organizationId String- accessToken String?- authorizationCode String?- codeExpiresAt DateTime?- revokedAt DateTime?- createdAt DateTime @default(now())- updatedAt DateTime @updatedAt- oauthApp OAuthApp @relation(fields: [oauthAppId], references: [id])- user User @relation(fields: [userId], references: [id])- organization Organization @relation(fields: [organizationId], references: [id])+ id String @id @default(uuid())+ oauthAppId String+ userId String+ organizationId String+ accessToken String?+ authorizationCode String?+ codeExpiresAt DateTime?+ codeChallenge String?+ codeChallengeMethod String?+ redirectUri String?+ revokedAt DateTime?+ createdAt DateTime @default(now())+ updatedAt DateTime @updatedAt+ oauthApp OAuthApp @relation(fields: [oauthAppId], references: [id])+ user User @relation(fields: [userId], references: [id])+ organization Organization @relation(fields: [organizationId], references: [id])@@unique([oauthAppId, userId, organizationId])@@index([accessToken])diff --git a/libraries/nestjs-libraries/src/dtos/oauth/authorize-oauth.dto.ts b/libraries/nestjs-libraries/src/dtos/oauth/authorize-oauth.dto.tsindex 137257da8..87e3e6458 100644--- a/libraries/nestjs-libraries/src/dtos/oauth/authorize-oauth.dto.ts+++ b/libraries/nestjs-libraries/src/dtos/oauth/authorize-oauth.dto.ts@@ -13,6 +13,24 @@ export class AuthorizeOAuthQueryDto {@IsString()@IsOptional()state?: string;++ @IsString()+ @IsOptional()+ redirect_uri?: string;++ @IsString()+ @IsOptional()+ code_challenge?: string;++ // Not validated with IsIn: static clients may send arbitrary values that+ // were always ignored; only dynamic clients get S256 enforced (in the service)+ @IsString()+ @IsOptional()+ code_challenge_method?: string;++ @IsString()+ @IsOptional()+ scope?: string;}export class ApproveOAuthDto {@@ -28,4 +46,18 @@ export class ApproveOAuthDto {@IsDefined()@IsIn(['approve', 'deny'])action: 'approve' | 'deny';++ @IsString()+ @IsOptional()+ redirect_uri?: string;++ @IsString()+ @IsOptional()+ code_challenge?: string;++ // Not validated with IsIn: static clients may send arbitrary values that+ // were always ignored; only dynamic clients get S256 enforced (in the service)+ @IsString()+ @IsOptional()+ code_challenge_method?: string;}diff --git a/libraries/nestjs-libraries/src/dtos/oauth/register-client.dto.ts b/libraries/nestjs-libraries/src/dtos/oauth/register-client.dto.tsnew file mode 100644index 000000000..6ee2defe2--- /dev/null+++ b/libraries/nestjs-libraries/src/dtos/oauth/register-client.dto.ts@@ -0,0 +1,49 @@+import {+ ArrayNotEmpty,+ IsArray,+ IsDefined,+ IsOptional,+ IsString,+ IsUrl,+} from 'class-validator';++export class RegisterClientDto {+ @IsArray()+ @ArrayNotEmpty()+ @IsUrl(+ { require_tld: false, require_protocol: true, protocols: ['http', 'https'] },+ { each: true }+ )+ @IsDefined()+ redirect_uris: string[];++ @IsString()+ @IsOptional()+ client_name?: string;++ @IsString()+ @IsOptional()+ client_uri?: string;++ @IsString()+ @IsOptional()+ logo_uri?: string;++ @IsString()+ @IsOptional()+ token_endpoint_auth_method?: string;++ @IsArray()+ @IsString({ each: true })+ @IsOptional()+ grant_types?: string[];++ @IsArray()+ @IsString({ each: true })+ @IsOptional()+ response_types?: string[];++ @IsString()+ @IsOptional()+ scope?: string;+}diff --git a/libraries/nestjs-libraries/src/dtos/oauth/token-exchange.dto.ts b/libraries/nestjs-libraries/src/dtos/oauth/token-exchange.dto.tsindex 6a436eed3..36a3c22bf 100644--- a/libraries/nestjs-libraries/src/dtos/oauth/token-exchange.dto.ts+++ b/libraries/nestjs-libraries/src/dtos/oauth/token-exchange.dto.ts@@ -1,4 +1,4 @@-import { IsDefined, IsString } from 'class-validator';+import { IsDefined, IsOptional, IsString } from 'class-validator';export class TokenExchangeDto {@IsString()@@ -13,7 +13,17 @@ export class TokenExchangeDto {@IsDefined()client_id: string;+ // Optional to allow PKCE-only public clients (dynamic registration);+ // the service still enforces it for confidential clients@IsString()- @IsDefined()- client_secret: string;+ @IsOptional()+ client_secret?: string;++ @IsString()+ @IsOptional()+ code_verifier?: string;++ @IsString()+ @IsOptional()+ redirect_uri?: string;}