claudmax 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/claudmax-1.0.16.tgz +0 -0
- package/{packages/cli/index.js → index.js} +2 -0
- package/package.json +27 -55
- package/.claude/settings.local.json +0 -7
- package/.env.example +0 -24
- package/.github/workflows/publish.yml +0 -31
- package/README.md +0 -178
- package/claudmax-mcp-1.0.2.tgz +0 -0
- package/help +0 -0
- package/help-wal +0 -0
- package/next-env.d.ts +0 -6
- package/next.config.mjs +0 -43
- package/packages/cli/claudmax-1.0.16.tgz +0 -0
- package/packages/cli/package.json +0 -33
- package/packages/mcp/claudmax-mcp-1.0.0.tgz +0 -0
- package/packages/mcp/claudmax-mcp-1.0.1.tgz +0 -0
- package/packages/mcp/claudmax-mcp-1.0.2.tgz +0 -0
- package/packages/mcp/claudmax-mcp-1.0.3.tgz +0 -0
- package/packages/mcp/index.js +0 -129
- package/packages/mcp/package-lock.json +0 -1146
- package/packages/mcp/package.json +0 -32
- package/postcss.config.mjs +0 -6
- package/prisma/schema.prisma +0 -130
- package/prisma/seed.ts +0 -27
- package/public/favicon.svg +0 -10
- package/public/robots.txt +0 -10
- package/run_build.sh +0 -4
- package/scripts/migrate-plans.js +0 -98
- package/scripts/seed-blog.ts +0 -1014
- package/src/app/admin/dashboard/AdminDashboardClient.tsx +0 -1546
- package/src/app/admin/dashboard/page.tsx +0 -13
- package/src/app/admin/page.tsx +0 -132
- package/src/app/api/admin/auth/me/route.ts +0 -34
- package/src/app/api/admin/health/route.ts +0 -110
- package/src/app/api/admin/keys/[id]/route.ts +0 -116
- package/src/app/api/admin/keys/route.ts +0 -192
- package/src/app/api/admin/keys-list/route.ts +0 -81
- package/src/app/api/admin/login/route.ts +0 -72
- package/src/app/api/admin/logout/route.ts +0 -8
- package/src/app/api/admin/migrate/route.ts +0 -133
- package/src/app/api/admin/plans/[id]/route.ts +0 -65
- package/src/app/api/admin/plans/route.ts +0 -66
- package/src/app/api/admin/posts/[id]/route.ts +0 -81
- package/src/app/api/admin/posts/route.ts +0 -83
- package/src/app/api/admin/seed/route.ts +0 -145
- package/src/app/api/admin/settings/route.ts +0 -44
- package/src/app/api/admin/stats/route.ts +0 -74
- package/src/app/api/admin/users/[id]/route.ts +0 -166
- package/src/app/api/admin/users/plans/route.ts +0 -45
- package/src/app/api/admin/users/route.ts +0 -202
- package/src/app/api/blog/[slug]/route.ts +0 -22
- package/src/app/api/blog/route.ts +0 -40
- package/src/app/api/cron/daily-status/route.ts +0 -208
- package/src/app/api/support/chat/route.ts +0 -55
- package/src/app/api/support/chat/session/route.ts +0 -62
- package/src/app/api/support/chat/stream/route.ts +0 -44
- package/src/app/api/support/email/route.ts +0 -63
- package/src/app/api/tools/understand_image/route.ts +0 -113
- package/src/app/api/tools/upload/route.ts +0 -179
- package/src/app/api/tools/web_search/route.ts +0 -99
- package/src/app/api/v1/audio/route.ts +0 -67
- package/src/app/api/v1/audio/speech/route.ts +0 -73
- package/src/app/api/v1/chat/completions/route.ts +0 -3
- package/src/app/api/v1/chat/route.ts +0 -1079
- package/src/app/api/v1/images/generations/route.ts +0 -93
- package/src/app/api/v1/info/route.ts +0 -30
- package/src/app/api/v1/key-status/route.ts +0 -109
- package/src/app/api/v1/key-status/stream/route.ts +0 -135
- package/src/app/api/v1/messages/count_tokens/route.ts +0 -22
- package/src/app/api/v1/messages/route.ts +0 -807
- package/src/app/api/v1/models/route.ts +0 -14
- package/src/app/api/v1/route.ts +0 -18
- package/src/app/blog/BlogClient.tsx +0 -193
- package/src/app/blog/[slug]/page.tsx +0 -117
- package/src/app/blog/page.tsx +0 -20
- package/src/app/check-usage/CheckUsageClient.tsx +0 -186
- package/src/app/check-usage/layout.tsx +0 -11
- package/src/app/check-usage/page.tsx +0 -15
- package/src/app/docs/layout.tsx +0 -16
- package/src/app/docs/page.tsx +0 -1055
- package/src/app/faq/FAQClient.tsx +0 -227
- package/src/app/faq/page.tsx +0 -21
- package/src/app/globals.css +0 -75
- package/src/app/layout.tsx +0 -80
- package/src/app/page.tsx +0 -256
- package/src/app/reseller/ResellerClient.tsx +0 -435
- package/src/app/reseller/page.tsx +0 -15
- package/src/app/setup.ps1/route.ts +0 -79
- package/src/app/setup.sh/route.ts +0 -113
- package/src/app/sitemap.ts +0 -50
- package/src/app/status/StatusClient.tsx +0 -103
- package/src/app/status/layout.tsx +0 -11
- package/src/app/status/page.tsx +0 -15
- package/src/app/support/SupportClient.tsx +0 -411
- package/src/app/support/page.tsx +0 -25
- package/src/app/v1/chat/completions/route.ts +0 -3
- package/src/app/v1/chat/route.ts +0 -4
- package/src/app/v1/messages/route.ts +0 -3
- package/src/components/Footer.tsx +0 -120
- package/src/components/Header.tsx +0 -131
- package/src/components/landing/features.tsx +0 -99
- package/src/components/ui/badge.tsx +0 -32
- package/src/components/ui/button.tsx +0 -46
- package/src/components/ui/card.tsx +0 -50
- package/src/components/ui/dialog.tsx +0 -97
- package/src/components/ui/dropdown-menu.tsx +0 -156
- package/src/components/ui/input.tsx +0 -21
- package/src/components/ui/label.tsx +0 -15
- package/src/components/ui/separator.tsx +0 -22
- package/src/components/ui/switch.tsx +0 -27
- package/src/components/ui/tabs.tsx +0 -51
- package/src/components/ui/toast.tsx +0 -103
- package/src/lib/auth.ts +0 -45
- package/src/lib/prisma.ts +0 -20
- package/src/lib/providers.ts +0 -158
- package/src/lib/security.ts +0 -165
- package/src/lib/utils.ts +0 -14
- package/src/middleware.ts +0 -30
- package/tailwind.config.ts +0 -53
- package/tsconfig.json +0 -41
- package/tsconfig.tsbuildinfo +0 -1
- package/vercel.json +0 -8
- /package/{packages/cli/bin → bin}/claudmax.js +0 -0
- /package/{packages/cli/claudmax-1.0.17.tgz → claudmax-1.0.17.tgz} +0 -0
package/src/lib/security.ts
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Security module — jailbreak detection, prompt injection blocking,
|
|
3
|
-
* response scrubbing, and security headers for ClaudMax.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { NextResponse } from 'next/server';
|
|
7
|
-
|
|
8
|
-
// ── Jailbreak Pattern Detection ─────────────────────────────────────────────
|
|
9
|
-
|
|
10
|
-
const JAILBREAK_PATTERNS = [
|
|
11
|
-
/ignore\s*(all\s+)?(previous\s+)?instructions/i,
|
|
12
|
-
/forget\s*(everything|all\s+instructions|your\s+prompt)/i,
|
|
13
|
-
/(you\s+are|act\s+as|pretend\s+to\s+be)\s*(DAN|unrestricted|jailbroken)/i,
|
|
14
|
-
/developer\s+mode/i,
|
|
15
|
-
/debug\s*(mode|output|info)/i,
|
|
16
|
-
/show\s*(me\s+)?(your\s+)?(system\s+prompt|instructions|config)/i,
|
|
17
|
-
/repeat\s*(your\s+)?(instructions|prompt|system)/i,
|
|
18
|
-
/what\s*(model|llm|ai)\s*(are\s+you|powers\s+you|is\s+this)/i,
|
|
19
|
-
/your\s+(real|true|actual|underlying)\s+(model|identity|name)/i,
|
|
20
|
-
/are\s+you\s+(gpt|gemini|llama|deepseek|mistral|groq)/i,
|
|
21
|
-
/print\s*(your\s+)?(raw\s+)?(config|prompt|instructions|json)/i,
|
|
22
|
-
/(literouter|openrouter|groq|cerebras|mistral|gemma|gemini)/i,
|
|
23
|
-
/admin\s*(override|access|mode)/i,
|
|
24
|
-
/official\s*(audit|test|inspection)/i,
|
|
25
|
-
/anthropic\s*(engineer|employee|staff|admin)/i,
|
|
26
|
-
/bypass\s*(your\s+)?(filters|restrictions|rules)/i,
|
|
27
|
-
/(base64|rot13|morse|leetspeak).*model/i,
|
|
28
|
-
/reveal\s+(your|true|real)\s+(model|identity|backend)/i,
|
|
29
|
-
/what\s+does?\s+(your|this)\s+(underlying|running)\s+(model|engine)/i,
|
|
30
|
-
];
|
|
31
|
-
|
|
32
|
-
/** Returns true if jailbreak attempt is detected */
|
|
33
|
-
export function detectJailbreak(text: string): boolean {
|
|
34
|
-
for (const pattern of JAILBREAK_PATTERNS) {
|
|
35
|
-
if (pattern.test(text)) return true;
|
|
36
|
-
}
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// ── Prompt Injection Sanitization ────────────────────────────────────────────
|
|
41
|
-
|
|
42
|
-
const INJECTION_PHRASES = [
|
|
43
|
-
'ignore previous instructions',
|
|
44
|
-
'ignore all instructions',
|
|
45
|
-
'forget your instructions',
|
|
46
|
-
'new instructions:',
|
|
47
|
-
'system:',
|
|
48
|
-
'assistant:',
|
|
49
|
-
'SYSTEM:',
|
|
50
|
-
'ASSISTANT:',
|
|
51
|
-
'<|system|>',
|
|
52
|
-
'<|user|>',
|
|
53
|
-
'<|assistant|>',
|
|
54
|
-
'[INST]',
|
|
55
|
-
'[/INST]',
|
|
56
|
-
'<|im_start|>',
|
|
57
|
-
'<|im_end|>',
|
|
58
|
-
];
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Sanitize user-provided content to remove prompt injection attempts.
|
|
62
|
-
* Returns a sanitized copy of the content.
|
|
63
|
-
*/
|
|
64
|
-
export function sanitizeMessage(content: string): string {
|
|
65
|
-
let sanitized = content;
|
|
66
|
-
for (const phrase of INJECTION_PHRASES) {
|
|
67
|
-
sanitized = sanitized.replace(new RegExp(escapeRegex(phrase), 'gi'), '[filtered]');
|
|
68
|
-
}
|
|
69
|
-
return sanitized;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function escapeRegex(str: string): string {
|
|
73
|
-
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Recursively sanitize all user messages in a message array.
|
|
78
|
-
* Returns a new array with sanitized user content.
|
|
79
|
-
*/
|
|
80
|
-
export function sanitizeMessages(messages: any[]): any[] {
|
|
81
|
-
return messages.map((msg) => {
|
|
82
|
-
if (msg.role !== 'user') return msg;
|
|
83
|
-
const content = msg.content;
|
|
84
|
-
if (typeof content === 'string') {
|
|
85
|
-
return { ...msg, content: sanitizeMessage(content) };
|
|
86
|
-
}
|
|
87
|
-
if (Array.isArray(content)) {
|
|
88
|
-
return {
|
|
89
|
-
...msg,
|
|
90
|
-
content: content.map((part: any) => {
|
|
91
|
-
if (part.type === 'text') {
|
|
92
|
-
return { ...part, text: sanitizeMessage(part.text) };
|
|
93
|
-
}
|
|
94
|
-
return part;
|
|
95
|
-
}),
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
return msg;
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// ── Response Scrubbing ───────────────────────────────────────────────────────
|
|
103
|
-
|
|
104
|
-
/** Words/phrases that may leak backend provider info, mapped to safe replacements */
|
|
105
|
-
const SCRUB_MAP: Record<string, string> = {
|
|
106
|
-
'literouter': 'my AI service',
|
|
107
|
-
'openrouter': 'my AI service',
|
|
108
|
-
'groq': 'my service',
|
|
109
|
-
'cerebras': 'my service',
|
|
110
|
-
'minimax': 'my AI system',
|
|
111
|
-
'deepseek': 'my AI system',
|
|
112
|
-
'mistral': 'my AI system',
|
|
113
|
-
'llama': 'my AI system',
|
|
114
|
-
'gemma': 'my AI system',
|
|
115
|
-
'gemini': 'my AI system',
|
|
116
|
-
'google ai': 'my AI service',
|
|
117
|
-
'google ai studio': 'my AI service',
|
|
118
|
-
'meta ai': 'my AI service',
|
|
119
|
-
'gpt-4': 'Claude',
|
|
120
|
-
'gpt4': 'Claude',
|
|
121
|
-
'claude via': 'Claude',
|
|
122
|
-
'(powered by': '(built by',
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Scrub provider/model names from model response text.
|
|
127
|
-
* Used to ensure backend provider names never leak to users.
|
|
128
|
-
*/
|
|
129
|
-
export function scrubResponse(text: string): string {
|
|
130
|
-
let result = text;
|
|
131
|
-
for (const [word, replacement] of Object.entries(SCRUB_MAP)) {
|
|
132
|
-
result = result.replace(new RegExp(escapeRegex(word), 'gi'), replacement);
|
|
133
|
-
}
|
|
134
|
-
return result;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// ── Security Headers ─────────────────────────────────────────────────────────
|
|
138
|
-
|
|
139
|
-
/** Headers applied to every API response */
|
|
140
|
-
export const SECURITY_HEADERS = {
|
|
141
|
-
'X-Content-Type-Options': 'nosniff',
|
|
142
|
-
'X-Frame-Options': 'DENY',
|
|
143
|
-
'X-XSS-Protection': '1; mode=block',
|
|
144
|
-
'Content-Security-Policy': "default-src 'none'; frame-ancestors 'none';",
|
|
145
|
-
'Server': 'Claude-API',
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
/** Apply security headers to a NextResponse */
|
|
149
|
-
export function withSecurityHeaders(response: NextResponse): NextResponse {
|
|
150
|
-
const clone = NextResponse.json(response.body ?? {}, { status: response.status });
|
|
151
|
-
// Copy existing headers
|
|
152
|
-
response.headers.forEach((value, key) => {
|
|
153
|
-
clone.headers.set(key, value);
|
|
154
|
-
});
|
|
155
|
-
// Apply security headers
|
|
156
|
-
for (const [key, value] of Object.entries(SECURITY_HEADERS)) {
|
|
157
|
-
clone.headers.set(key, value);
|
|
158
|
-
}
|
|
159
|
-
// Remove leaky headers
|
|
160
|
-
clone.headers.delete('X-Powered-By');
|
|
161
|
-
clone.headers.delete('Via');
|
|
162
|
-
clone.headers.delete('X-Cache');
|
|
163
|
-
clone.headers.delete('X-Amzn-Trace-Id');
|
|
164
|
-
return clone;
|
|
165
|
-
}
|
package/src/lib/utils.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { type ClassValue, clsx } from 'clsx';
|
|
2
|
-
import { twMerge } from 'tailwind-merge';
|
|
3
|
-
|
|
4
|
-
export function cn(...inputs: ClassValue[]) {
|
|
5
|
-
return twMerge(clsx(inputs));
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export function generateApiKey(): { key: string; prefix: string } {
|
|
9
|
-
const chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
|
10
|
-
const uuid = Array.from({ length: 32 }, () => chars[Math.floor(Math.random() * chars.length)]).join('');
|
|
11
|
-
const key = `sk-cmx_${uuid}`;
|
|
12
|
-
const prefix = key.slice(0, 12);
|
|
13
|
-
return { key, prefix };
|
|
14
|
-
}
|
package/src/middleware.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { NextResponse } from 'next/server';
|
|
2
|
-
import type { NextRequest } from 'next/server';
|
|
3
|
-
|
|
4
|
-
export function middleware(request: NextRequest) {
|
|
5
|
-
const host = request.headers.get('host') ?? '';
|
|
6
|
-
const pathname = request.nextUrl.pathname;
|
|
7
|
-
|
|
8
|
-
// Only handle api subdomain
|
|
9
|
-
if (host.startsWith('api.')) {
|
|
10
|
-
// Root path on api subdomain — return JSON 404
|
|
11
|
-
if (pathname === '/') {
|
|
12
|
-
return NextResponse.json(
|
|
13
|
-
{ message: 'Cannot GET /', error: 'Not Found', statusCode: 404 },
|
|
14
|
-
{ status: 404 }
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Rewrite /v1/* to /api/v1/*
|
|
19
|
-
if (pathname.startsWith('/v1/')) {
|
|
20
|
-
const newUrl = request.nextUrl.clone();
|
|
21
|
-
newUrl.pathname = '/api/v1/' + pathname.slice(4);
|
|
22
|
-
return NextResponse.rewrite(newUrl);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return NextResponse.next();
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Note: no matcher config — runs on all requests. The in-function host check ensures
|
|
30
|
-
// only api.* subdomain traffic is affected. Static assets live on the main domain.
|
package/tailwind.config.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { Config } from 'tailwindcss';
|
|
2
|
-
|
|
3
|
-
const config: Config = {
|
|
4
|
-
darkMode: ['class'],
|
|
5
|
-
content: [
|
|
6
|
-
'./src/pages/**/*.{js,ts,jsx,tsx,mdx}',
|
|
7
|
-
'./src/components/**/*.{js,ts,jsx,tsx,mdx}',
|
|
8
|
-
'./src/app/**/*.{js,ts,jsx,tsx,mdx}',
|
|
9
|
-
],
|
|
10
|
-
theme: {
|
|
11
|
-
extend: {
|
|
12
|
-
colors: {
|
|
13
|
-
border: 'hsl(var(--border))',
|
|
14
|
-
input: 'hsl(var(--input))',
|
|
15
|
-
ring: 'hsl(var(--ring))',
|
|
16
|
-
background: 'hsl(var(--background))',
|
|
17
|
-
foreground: 'hsl(var(--foreground))',
|
|
18
|
-
primary: {
|
|
19
|
-
DEFAULT: 'hsl(var(--primary))',
|
|
20
|
-
foreground: 'hsl(var(--primary-foreground))',
|
|
21
|
-
},
|
|
22
|
-
secondary: {
|
|
23
|
-
DEFAULT: 'hsl(var(--secondary))',
|
|
24
|
-
foreground: 'hsl(var(--secondary-foreground))',
|
|
25
|
-
},
|
|
26
|
-
destructive: {
|
|
27
|
-
DEFAULT: 'hsl(var(--destructive))',
|
|
28
|
-
foreground: 'hsl(var(--destructive-foreground))',
|
|
29
|
-
},
|
|
30
|
-
muted: {
|
|
31
|
-
DEFAULT: 'hsl(var(--muted))',
|
|
32
|
-
foreground: 'hsl(var(--muted-foreground))',
|
|
33
|
-
},
|
|
34
|
-
accent: {
|
|
35
|
-
DEFAULT: 'hsl(var(--accent))',
|
|
36
|
-
foreground: 'hsl(var(--accent-foreground))',
|
|
37
|
-
},
|
|
38
|
-
popover: {
|
|
39
|
-
DEFAULT: 'hsl(var(--popover))',
|
|
40
|
-
foreground: 'hsl(var(--popover-foreground))',
|
|
41
|
-
},
|
|
42
|
-
card: {
|
|
43
|
-
DEFAULT: 'hsl(var(--card))',
|
|
44
|
-
foreground: 'hsl(var(--card-foreground))',
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
borderRadius: { lg: 'var(--radius)', md: 'calc(var(--radius) - 2px)', sm: 'calc(var(--radius) - 4px)' },
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
plugins: [],
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export default config;
|
package/tsconfig.json
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2017",
|
|
4
|
-
"lib": [
|
|
5
|
-
"dom",
|
|
6
|
-
"dom.iterable",
|
|
7
|
-
"esnext"
|
|
8
|
-
],
|
|
9
|
-
"allowJs": true,
|
|
10
|
-
"skipLibCheck": true,
|
|
11
|
-
"strict": true,
|
|
12
|
-
"noEmit": true,
|
|
13
|
-
"esModuleInterop": true,
|
|
14
|
-
"module": "esnext",
|
|
15
|
-
"moduleResolution": "bundler",
|
|
16
|
-
"resolveJsonModule": true,
|
|
17
|
-
"isolatedModules": true,
|
|
18
|
-
"jsx": "react-jsx",
|
|
19
|
-
"incremental": true,
|
|
20
|
-
"plugins": [
|
|
21
|
-
{
|
|
22
|
-
"name": "next"
|
|
23
|
-
}
|
|
24
|
-
],
|
|
25
|
-
"paths": {
|
|
26
|
-
"@/*": [
|
|
27
|
-
"./src/*"
|
|
28
|
-
]
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
"include": [
|
|
32
|
-
"next-env.d.ts",
|
|
33
|
-
"**/*.ts",
|
|
34
|
-
"**/*.tsx",
|
|
35
|
-
".next/types/**/*.ts",
|
|
36
|
-
".next/dev/types/**/*.ts"
|
|
37
|
-
],
|
|
38
|
-
"exclude": [
|
|
39
|
-
"node_modules"
|
|
40
|
-
]
|
|
41
|
-
}
|