@classic-homes/theme-mcp 0.1.8 → 0.1.9
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/dist/cli.js +1843 -204
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +55 -1
- package/dist/index.js +1843 -204
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11080,6 +11080,343 @@ var pattern_library_default = {
|
|
|
11080
11080
|
<FormField label="Message" type="textarea" name="message" />
|
|
11081
11081
|
<Button type="submit">Send Message</Button>
|
|
11082
11082
|
</form>`
|
|
11083
|
+
},
|
|
11084
|
+
{
|
|
11085
|
+
id: "mfa-verification-form",
|
|
11086
|
+
name: "MFA Verification Form",
|
|
11087
|
+
description: "Two-factor authentication code verification form",
|
|
11088
|
+
schema: "mfaVerifySchema",
|
|
11089
|
+
components: [
|
|
11090
|
+
"FormField",
|
|
11091
|
+
"OTPInput",
|
|
11092
|
+
"Button",
|
|
11093
|
+
"Checkbox",
|
|
11094
|
+
"useForm"
|
|
11095
|
+
],
|
|
11096
|
+
example: `<script lang="ts">
|
|
11097
|
+
import { OTPInput, Button, Checkbox, useForm, mfaVerifySchema } from '@classic-homes/theme-svelte';
|
|
11098
|
+
import { authApi } from '@classic-homes/auth/core';
|
|
11099
|
+
|
|
11100
|
+
export let mfaToken: string;
|
|
11101
|
+
export let onSuccess: () => void;
|
|
11102
|
+
|
|
11103
|
+
const form = useForm({
|
|
11104
|
+
schema: mfaVerifySchema,
|
|
11105
|
+
initialValues: { code: '', trustDevice: false },
|
|
11106
|
+
onSubmit: async (data) => {
|
|
11107
|
+
await authApi.verifyMFAChallenge({ mfaToken, code: data.code, trustDevice: data.trustDevice });
|
|
11108
|
+
onSuccess();
|
|
11109
|
+
},
|
|
11110
|
+
});
|
|
11111
|
+
</script>
|
|
11112
|
+
|
|
11113
|
+
<form onsubmit={form.handleSubmit} class="space-y-4">
|
|
11114
|
+
<OTPInput length={6} value={form.data.code} onValueChange={(v) => form.setField('code', v)} />
|
|
11115
|
+
<Checkbox checked={form.data.trustDevice} onCheckedChange={(v) => form.setField('trustDevice', v)}>
|
|
11116
|
+
Trust this device for 30 days
|
|
11117
|
+
</Checkbox>
|
|
11118
|
+
<Button type="submit" loading={form.isSubmitting} class="w-full">Verify</Button>
|
|
11119
|
+
</form>`
|
|
11120
|
+
},
|
|
11121
|
+
{
|
|
11122
|
+
id: "mfa-setup-form",
|
|
11123
|
+
name: "MFA Setup Form",
|
|
11124
|
+
description: "MFA enrollment form with QR code display and code verification",
|
|
11125
|
+
schema: "mfaSetupSchema",
|
|
11126
|
+
components: [
|
|
11127
|
+
"FormField",
|
|
11128
|
+
"OTPInput",
|
|
11129
|
+
"Button",
|
|
11130
|
+
"Card",
|
|
11131
|
+
"useForm"
|
|
11132
|
+
],
|
|
11133
|
+
example: `<script lang="ts">
|
|
11134
|
+
import { OTPInput, Button, Card, CardContent, useForm, mfaSetupSchema } from '@classic-homes/theme-svelte';
|
|
11135
|
+
import { authApi } from '@classic-homes/auth/core';
|
|
11136
|
+
import { onMount } from 'svelte';
|
|
11137
|
+
|
|
11138
|
+
let setupData: { qrCodeUrl: string; manualEntryKey: string } | null = null;
|
|
11139
|
+
|
|
11140
|
+
onMount(async () => {
|
|
11141
|
+
setupData = await authApi.setupMFA();
|
|
11142
|
+
});
|
|
11143
|
+
|
|
11144
|
+
const form = useForm({
|
|
11145
|
+
schema: mfaSetupSchema,
|
|
11146
|
+
initialValues: { code: '' },
|
|
11147
|
+
onSubmit: async (data) => {
|
|
11148
|
+
await authApi.verifyMFASetup(data.code);
|
|
11149
|
+
},
|
|
11150
|
+
});
|
|
11151
|
+
</script>
|
|
11152
|
+
|
|
11153
|
+
{#if setupData}
|
|
11154
|
+
<Card>
|
|
11155
|
+
<CardContent class="space-y-4">
|
|
11156
|
+
<img src={setupData.qrCodeUrl} alt="QR Code" class="mx-auto" />
|
|
11157
|
+
<form onsubmit={form.handleSubmit}>
|
|
11158
|
+
<OTPInput length={6} value={form.data.code} onValueChange={(v) => form.setField('code', v)} />
|
|
11159
|
+
<Button type="submit" loading={form.isSubmitting} class="w-full mt-4">Verify & Enable MFA</Button>
|
|
11160
|
+
</form>
|
|
11161
|
+
</CardContent>
|
|
11162
|
+
</Card>
|
|
11163
|
+
{/if}`
|
|
11164
|
+
},
|
|
11165
|
+
{
|
|
11166
|
+
id: "profile-update-form",
|
|
11167
|
+
name: "Profile Update Form",
|
|
11168
|
+
description: "User profile editing form",
|
|
11169
|
+
schema: "profileUpdateSchema",
|
|
11170
|
+
components: [
|
|
11171
|
+
"FormField",
|
|
11172
|
+
"Button",
|
|
11173
|
+
"useForm"
|
|
11174
|
+
],
|
|
11175
|
+
example: `<script lang="ts">
|
|
11176
|
+
import { FormField, Button, useForm, profileUpdateSchema } from '@classic-homes/theme-svelte';
|
|
11177
|
+
import { authApi } from '@classic-homes/auth/core';
|
|
11178
|
+
import { currentUser, authActions } from '@classic-homes/auth/svelte';
|
|
11179
|
+
|
|
11180
|
+
const form = useForm({
|
|
11181
|
+
schema: profileUpdateSchema,
|
|
11182
|
+
initialValues: {
|
|
11183
|
+
firstName: $currentUser?.firstName ?? '',
|
|
11184
|
+
lastName: $currentUser?.lastName ?? '',
|
|
11185
|
+
email: $currentUser?.email ?? '',
|
|
11186
|
+
},
|
|
11187
|
+
onSubmit: async (data) => {
|
|
11188
|
+
const updatedUser = await authApi.updateProfile(data);
|
|
11189
|
+
authActions.updateUser(updatedUser);
|
|
11190
|
+
},
|
|
11191
|
+
});
|
|
11192
|
+
</script>
|
|
11193
|
+
|
|
11194
|
+
<form onsubmit={form.handleSubmit} class="space-y-4">
|
|
11195
|
+
<FormField label="First Name" name="firstName" value={form.data.firstName} onValueChange={(v) => form.setField('firstName', v)} />
|
|
11196
|
+
<FormField label="Last Name" name="lastName" value={form.data.lastName} onValueChange={(v) => form.setField('lastName', v)} />
|
|
11197
|
+
<FormField label="Email" type="email" name="email" value={form.data.email} onValueChange={(v) => form.setField('email', v)} />
|
|
11198
|
+
<Button type="submit" loading={form.isSubmitting}>Save Changes</Button>
|
|
11199
|
+
</form>`
|
|
11200
|
+
},
|
|
11201
|
+
{
|
|
11202
|
+
id: "change-password-form",
|
|
11203
|
+
name: "Change Password Form",
|
|
11204
|
+
description: "Form for authenticated users to change their password",
|
|
11205
|
+
schema: "changePasswordSchema",
|
|
11206
|
+
components: [
|
|
11207
|
+
"FormField",
|
|
11208
|
+
"Button",
|
|
11209
|
+
"useForm"
|
|
11210
|
+
],
|
|
11211
|
+
example: `<script lang="ts">
|
|
11212
|
+
import { FormField, Button, useForm, changePasswordSchema } from '@classic-homes/theme-svelte';
|
|
11213
|
+
import { authApi } from '@classic-homes/auth/core';
|
|
11214
|
+
|
|
11215
|
+
const form = useForm({
|
|
11216
|
+
schema: changePasswordSchema,
|
|
11217
|
+
initialValues: { currentPassword: '', newPassword: '', confirmPassword: '' },
|
|
11218
|
+
onSubmit: async (data) => {
|
|
11219
|
+
await authApi.changePassword({ currentPassword: data.currentPassword, newPassword: data.newPassword });
|
|
11220
|
+
},
|
|
11221
|
+
});
|
|
11222
|
+
</script>
|
|
11223
|
+
|
|
11224
|
+
<form onsubmit={form.handleSubmit} class="space-y-4">
|
|
11225
|
+
<FormField label="Current Password" type="password" name="currentPassword" value={form.data.currentPassword} onValueChange={(v) => form.setField('currentPassword', v)} />
|
|
11226
|
+
<FormField label="New Password" type="password" name="newPassword" value={form.data.newPassword} onValueChange={(v) => form.setField('newPassword', v)} />
|
|
11227
|
+
<FormField label="Confirm Password" type="password" name="confirmPassword" value={form.data.confirmPassword} onValueChange={(v) => form.setField('confirmPassword', v)} />
|
|
11228
|
+
<Button type="submit" loading={form.isSubmitting}>Change Password</Button>
|
|
11229
|
+
</form>`
|
|
11230
|
+
},
|
|
11231
|
+
{
|
|
11232
|
+
id: "forgot-password-form",
|
|
11233
|
+
name: "Forgot Password Form",
|
|
11234
|
+
description: "Password reset request form",
|
|
11235
|
+
schema: "forgotPasswordSchema",
|
|
11236
|
+
components: [
|
|
11237
|
+
"FormField",
|
|
11238
|
+
"Button",
|
|
11239
|
+
"useForm"
|
|
11240
|
+
],
|
|
11241
|
+
example: `<script lang="ts">
|
|
11242
|
+
import { FormField, Button, useForm, forgotPasswordSchema } from '@classic-homes/theme-svelte';
|
|
11243
|
+
import { authApi } from '@classic-homes/auth/core';
|
|
11244
|
+
|
|
11245
|
+
let submitted = false;
|
|
11246
|
+
|
|
11247
|
+
const form = useForm({
|
|
11248
|
+
schema: forgotPasswordSchema,
|
|
11249
|
+
initialValues: { email: '' },
|
|
11250
|
+
onSubmit: async (data) => {
|
|
11251
|
+
await authApi.forgotPassword(data.email);
|
|
11252
|
+
submitted = true;
|
|
11253
|
+
},
|
|
11254
|
+
});
|
|
11255
|
+
</script>
|
|
11256
|
+
|
|
11257
|
+
{#if submitted}
|
|
11258
|
+
<p>Check your email for password reset instructions.</p>
|
|
11259
|
+
{:else}
|
|
11260
|
+
<form onsubmit={form.handleSubmit} class="space-y-4">
|
|
11261
|
+
<FormField label="Email" type="email" name="email" value={form.data.email} onValueChange={(v) => form.setField('email', v)} />
|
|
11262
|
+
<Button type="submit" loading={form.isSubmitting} class="w-full">Send Reset Link</Button>
|
|
11263
|
+
</form>
|
|
11264
|
+
{/if}`
|
|
11265
|
+
},
|
|
11266
|
+
{
|
|
11267
|
+
id: "reset-password-form",
|
|
11268
|
+
name: "Reset Password Form",
|
|
11269
|
+
description: "Set new password form using reset token",
|
|
11270
|
+
schema: "resetPasswordSchema",
|
|
11271
|
+
components: [
|
|
11272
|
+
"FormField",
|
|
11273
|
+
"Button",
|
|
11274
|
+
"useForm"
|
|
11275
|
+
],
|
|
11276
|
+
example: `<script lang="ts">
|
|
11277
|
+
import { FormField, Button, useForm, resetPasswordSchema } from '@classic-homes/theme-svelte';
|
|
11278
|
+
import { authApi } from '@classic-homes/auth/core';
|
|
11279
|
+
import { goto } from '$app/navigation';
|
|
11280
|
+
|
|
11281
|
+
export let token: string;
|
|
11282
|
+
|
|
11283
|
+
const form = useForm({
|
|
11284
|
+
schema: resetPasswordSchema,
|
|
11285
|
+
initialValues: { password: '', confirmPassword: '' },
|
|
11286
|
+
onSubmit: async (data) => {
|
|
11287
|
+
await authApi.resetPassword(token, data.password);
|
|
11288
|
+
goto('/login?message=password-reset');
|
|
11289
|
+
},
|
|
11290
|
+
});
|
|
11291
|
+
</script>
|
|
11292
|
+
|
|
11293
|
+
<form onsubmit={form.handleSubmit} class="space-y-4">
|
|
11294
|
+
<FormField label="New Password" type="password" name="password" value={form.data.password} onValueChange={(v) => form.setField('password', v)} />
|
|
11295
|
+
<FormField label="Confirm Password" type="password" name="confirmPassword" value={form.data.confirmPassword} onValueChange={(v) => form.setField('confirmPassword', v)} />
|
|
11296
|
+
<Button type="submit" loading={form.isSubmitting} class="w-full">Reset Password</Button>
|
|
11297
|
+
</form>`
|
|
11298
|
+
}
|
|
11299
|
+
],
|
|
11300
|
+
auth: [
|
|
11301
|
+
{
|
|
11302
|
+
id: "login-with-mfa",
|
|
11303
|
+
name: "Login with MFA Flow",
|
|
11304
|
+
description: "Complete login flow handling MFA challenge when required",
|
|
11305
|
+
components: [
|
|
11306
|
+
"AuthLayout",
|
|
11307
|
+
"FormField",
|
|
11308
|
+
"Button",
|
|
11309
|
+
"OTPInput",
|
|
11310
|
+
"useForm"
|
|
11311
|
+
],
|
|
11312
|
+
example: `<script lang="ts">
|
|
11313
|
+
import { AuthLayout, FormField, Button, OTPInput, useForm, loginSchema, mfaVerifySchema } from '@classic-homes/theme-svelte';
|
|
11314
|
+
import { authApi, isMfaChallengeResponse, getMfaToken } from '@classic-homes/auth/core';
|
|
11315
|
+
import { authActions } from '@classic-homes/auth/svelte';
|
|
11316
|
+
import { goto } from '$app/navigation';
|
|
11317
|
+
|
|
11318
|
+
let mfaRequired = false;
|
|
11319
|
+
let mfaToken = '';
|
|
11320
|
+
|
|
11321
|
+
const loginForm = useForm({
|
|
11322
|
+
schema: loginSchema,
|
|
11323
|
+
initialValues: { email: '', password: '' },
|
|
11324
|
+
onSubmit: async (data) => {
|
|
11325
|
+
const response = await authActions.login(data);
|
|
11326
|
+
if (isMfaChallengeResponse(response)) {
|
|
11327
|
+
mfaRequired = true;
|
|
11328
|
+
mfaToken = getMfaToken(response)!;
|
|
11329
|
+
} else {
|
|
11330
|
+
goto('/dashboard');
|
|
11331
|
+
}
|
|
11332
|
+
},
|
|
11333
|
+
});
|
|
11334
|
+
</script>
|
|
11335
|
+
|
|
11336
|
+
<AuthLayout logoSubtitle={mfaRequired ? 'Enter verification code' : 'Sign in'}>
|
|
11337
|
+
{#if mfaRequired}
|
|
11338
|
+
<OTPInput length={6} />
|
|
11339
|
+
<Button class="w-full mt-4">Verify</Button>
|
|
11340
|
+
{:else}
|
|
11341
|
+
<form onsubmit={loginForm.handleSubmit}>
|
|
11342
|
+
<FormField label="Email" type="email" name="email" />
|
|
11343
|
+
<FormField label="Password" type="password" name="password" />
|
|
11344
|
+
<Button type="submit" loading={loginForm.isSubmitting} class="w-full">Sign In</Button>
|
|
11345
|
+
</form>
|
|
11346
|
+
{/if}
|
|
11347
|
+
</AuthLayout>`
|
|
11348
|
+
},
|
|
11349
|
+
{
|
|
11350
|
+
id: "sso-login",
|
|
11351
|
+
name: "SSO Login Flow",
|
|
11352
|
+
description: "Single Sign-On authentication with redirect handling",
|
|
11353
|
+
components: [
|
|
11354
|
+
"AuthLayout",
|
|
11355
|
+
"Button"
|
|
11356
|
+
],
|
|
11357
|
+
example: `<script lang="ts">
|
|
11358
|
+
import { AuthLayout, Button } from '@classic-homes/theme-svelte';
|
|
11359
|
+
import { authApi } from '@classic-homes/auth/core';
|
|
11360
|
+
|
|
11361
|
+
function handleSSOLogin() {
|
|
11362
|
+
authApi.initiateSSOLogin({ redirectUrl: '/dashboard' });
|
|
11363
|
+
}
|
|
11364
|
+
</script>
|
|
11365
|
+
|
|
11366
|
+
<AuthLayout logoSubtitle="Sign in with your company account">
|
|
11367
|
+
<Button onclick={handleSSOLogin} class="w-full" variant="outline">Sign in with SSO</Button>
|
|
11368
|
+
</AuthLayout>`
|
|
11369
|
+
},
|
|
11370
|
+
{
|
|
11371
|
+
id: "session-management",
|
|
11372
|
+
name: "Session Management",
|
|
11373
|
+
description: "View and revoke active sessions",
|
|
11374
|
+
components: [
|
|
11375
|
+
"Card",
|
|
11376
|
+
"Button"
|
|
11377
|
+
],
|
|
11378
|
+
example: `<script lang="ts">
|
|
11379
|
+
import { Card, CardHeader, CardTitle, CardContent, Button } from '@classic-homes/theme-svelte';
|
|
11380
|
+
import { authApi } from '@classic-homes/auth/core';
|
|
11381
|
+
import type { Session } from '@classic-homes/auth/core';
|
|
11382
|
+
import { onMount } from 'svelte';
|
|
11383
|
+
|
|
11384
|
+
let sessions: Session[] = [];
|
|
11385
|
+
|
|
11386
|
+
onMount(async () => {
|
|
11387
|
+
const response = await authApi.getSessions();
|
|
11388
|
+
sessions = response.sessions;
|
|
11389
|
+
});
|
|
11390
|
+
|
|
11391
|
+
async function revokeSession(sessionId: string) {
|
|
11392
|
+
await authApi.revokeSession(sessionId);
|
|
11393
|
+
sessions = sessions.filter(s => s.id !== sessionId);
|
|
11394
|
+
}
|
|
11395
|
+
</script>
|
|
11396
|
+
|
|
11397
|
+
<Card>
|
|
11398
|
+
<CardHeader><CardTitle>Active Sessions</CardTitle></CardHeader>
|
|
11399
|
+
<CardContent>
|
|
11400
|
+
{#each sessions as session}
|
|
11401
|
+
<div class="flex items-center justify-between py-2 border-b">
|
|
11402
|
+
<div>
|
|
11403
|
+
<p class="font-medium">{session.deviceName}</p>
|
|
11404
|
+
<p class="text-sm text-muted-foreground">{session.location}</p>
|
|
11405
|
+
</div>
|
|
11406
|
+
{#if !session.isCurrent}
|
|
11407
|
+
<Button variant="ghost" size="sm" onclick={() => revokeSession(session.id)}>Revoke</Button>
|
|
11408
|
+
{/if}
|
|
11409
|
+
</div>
|
|
11410
|
+
{/each}
|
|
11411
|
+
</CardContent>
|
|
11412
|
+
</Card>`
|
|
11413
|
+
},
|
|
11414
|
+
{
|
|
11415
|
+
id: "protected-route",
|
|
11416
|
+
name: "Protected Route",
|
|
11417
|
+
description: "Route protection with auth guards in SvelteKit",
|
|
11418
|
+
components: [],
|
|
11419
|
+
example: "// +page.ts\nimport { requireAuth, requireRole, protectedLoad } from '@classic-homes/auth/svelte';\n\n// Simple auth requirement\nexport const load = requireAuth();\n\n// Role-based protection\nexport const load = requireRole('admin');\n\n// Custom protected load\nexport const load = protectedLoad(async (event, auth) => {\n const data = await fetchData(event.fetch, auth.user.id);\n return { user: auth.user, data };\n});"
|
|
11083
11420
|
}
|
|
11084
11421
|
]
|
|
11085
11422
|
};
|
|
@@ -11092,43 +11429,1479 @@ function registerLayoutResources(server) {
|
|
|
11092
11429
|
{
|
|
11093
11430
|
uri: uri.href,
|
|
11094
11431
|
mimeType: "application/json",
|
|
11095
|
-
text: JSON.stringify(patterns, null, 2)
|
|
11432
|
+
text: JSON.stringify(patterns, null, 2)
|
|
11433
|
+
}
|
|
11434
|
+
]
|
|
11435
|
+
}));
|
|
11436
|
+
server.resource("Layout Patterns", "patterns://layouts", async (uri) => ({
|
|
11437
|
+
contents: [
|
|
11438
|
+
{
|
|
11439
|
+
uri: uri.href,
|
|
11440
|
+
mimeType: "application/json",
|
|
11441
|
+
text: JSON.stringify(patterns.layouts, null, 2)
|
|
11442
|
+
}
|
|
11443
|
+
]
|
|
11444
|
+
}));
|
|
11445
|
+
server.resource("Form Patterns", "patterns://forms", async (uri) => ({
|
|
11446
|
+
contents: [
|
|
11447
|
+
{
|
|
11448
|
+
uri: uri.href,
|
|
11449
|
+
mimeType: "application/json",
|
|
11450
|
+
text: JSON.stringify(patterns.forms, null, 2)
|
|
11451
|
+
}
|
|
11452
|
+
]
|
|
11453
|
+
}));
|
|
11454
|
+
server.resource(
|
|
11455
|
+
"Pattern Details",
|
|
11456
|
+
new ResourceTemplate2("patterns://{id}", { list: void 0 }),
|
|
11457
|
+
async (uri, params) => {
|
|
11458
|
+
const id = params.id;
|
|
11459
|
+
const layout = patterns.layouts.find((l) => l.id === id);
|
|
11460
|
+
const form = patterns.forms.find((f) => f.id === id);
|
|
11461
|
+
const pattern = layout || form;
|
|
11462
|
+
if (!pattern) {
|
|
11463
|
+
return {
|
|
11464
|
+
contents: [
|
|
11465
|
+
{
|
|
11466
|
+
uri: uri.href,
|
|
11467
|
+
mimeType: "application/json",
|
|
11468
|
+
text: JSON.stringify({ error: `Pattern "${id}" not found` })
|
|
11469
|
+
}
|
|
11470
|
+
]
|
|
11471
|
+
};
|
|
11472
|
+
}
|
|
11473
|
+
return {
|
|
11474
|
+
contents: [
|
|
11475
|
+
{
|
|
11476
|
+
uri: uri.href,
|
|
11477
|
+
mimeType: "application/json",
|
|
11478
|
+
text: JSON.stringify(pattern, null, 2)
|
|
11479
|
+
}
|
|
11480
|
+
]
|
|
11481
|
+
};
|
|
11482
|
+
}
|
|
11483
|
+
);
|
|
11484
|
+
}
|
|
11485
|
+
|
|
11486
|
+
// src/data/schema-catalog.json
|
|
11487
|
+
var schema_catalog_default = {
|
|
11488
|
+
auth: [
|
|
11489
|
+
{
|
|
11490
|
+
name: "emailSchema",
|
|
11491
|
+
description: "Email validation",
|
|
11492
|
+
importPath: "@classic-homes/theme-svelte"
|
|
11493
|
+
},
|
|
11494
|
+
{
|
|
11495
|
+
name: "passwordSchema",
|
|
11496
|
+
description: "Strong password (8+ chars, mixed case, numbers, special)",
|
|
11497
|
+
importPath: "@classic-homes/theme-svelte"
|
|
11498
|
+
},
|
|
11499
|
+
{
|
|
11500
|
+
name: "loginPasswordSchema",
|
|
11501
|
+
description: "Simpler password validation for login",
|
|
11502
|
+
importPath: "@classic-homes/theme-svelte"
|
|
11503
|
+
},
|
|
11504
|
+
{
|
|
11505
|
+
name: "usernameSchema",
|
|
11506
|
+
description: "Username validation (3-30 chars, alphanumeric)",
|
|
11507
|
+
importPath: "@classic-homes/theme-svelte"
|
|
11508
|
+
},
|
|
11509
|
+
{
|
|
11510
|
+
name: "fullNameSchema",
|
|
11511
|
+
description: "Full name validation",
|
|
11512
|
+
importPath: "@classic-homes/theme-svelte"
|
|
11513
|
+
},
|
|
11514
|
+
{
|
|
11515
|
+
name: "phoneSchema",
|
|
11516
|
+
description: "Phone number validation",
|
|
11517
|
+
importPath: "@classic-homes/theme-svelte"
|
|
11518
|
+
},
|
|
11519
|
+
{
|
|
11520
|
+
name: "mfaCodeSchema",
|
|
11521
|
+
description: "MFA code validation (6 digits)",
|
|
11522
|
+
importPath: "@classic-homes/theme-svelte"
|
|
11523
|
+
},
|
|
11524
|
+
{
|
|
11525
|
+
name: "totpSecretSchema",
|
|
11526
|
+
description: "TOTP secret validation (Base32 encoded)",
|
|
11527
|
+
importPath: "@classic-homes/theme-svelte"
|
|
11528
|
+
},
|
|
11529
|
+
{
|
|
11530
|
+
name: "mfaVerifySchema",
|
|
11531
|
+
description: "MFA verification form schema (code + optional trust device)",
|
|
11532
|
+
importPath: "@classic-homes/theme-svelte"
|
|
11533
|
+
},
|
|
11534
|
+
{
|
|
11535
|
+
name: "mfaSetupSchema",
|
|
11536
|
+
description: "MFA setup form schema (code verification during setup)",
|
|
11537
|
+
importPath: "@classic-homes/theme-svelte"
|
|
11538
|
+
},
|
|
11539
|
+
{
|
|
11540
|
+
name: "loginSchema",
|
|
11541
|
+
description: "Complete login form schema",
|
|
11542
|
+
importPath: "@classic-homes/theme-svelte"
|
|
11543
|
+
},
|
|
11544
|
+
{
|
|
11545
|
+
name: "registerSchema",
|
|
11546
|
+
description: "Complete registration form schema",
|
|
11547
|
+
importPath: "@classic-homes/theme-svelte"
|
|
11548
|
+
},
|
|
11549
|
+
{
|
|
11550
|
+
name: "forgotPasswordSchema",
|
|
11551
|
+
description: "Forgot password form schema",
|
|
11552
|
+
importPath: "@classic-homes/theme-svelte"
|
|
11553
|
+
},
|
|
11554
|
+
{
|
|
11555
|
+
name: "resetPasswordSchema",
|
|
11556
|
+
description: "Reset password form schema",
|
|
11557
|
+
importPath: "@classic-homes/theme-svelte"
|
|
11558
|
+
},
|
|
11559
|
+
{
|
|
11560
|
+
name: "changePasswordSchema",
|
|
11561
|
+
description: "Change password form schema",
|
|
11562
|
+
importPath: "@classic-homes/theme-svelte"
|
|
11563
|
+
},
|
|
11564
|
+
{
|
|
11565
|
+
name: "profileUpdateSchema",
|
|
11566
|
+
description: "Profile update form schema (firstName, lastName, email, phone)",
|
|
11567
|
+
importPath: "@classic-homes/theme-svelte"
|
|
11568
|
+
},
|
|
11569
|
+
{
|
|
11570
|
+
name: "emailChangeSchema",
|
|
11571
|
+
description: "Email change form schema with password confirmation",
|
|
11572
|
+
importPath: "@classic-homes/theme-svelte"
|
|
11573
|
+
},
|
|
11574
|
+
{
|
|
11575
|
+
name: "userSchema",
|
|
11576
|
+
description: "User object validation schema",
|
|
11577
|
+
importPath: "@classic-homes/theme-svelte"
|
|
11578
|
+
},
|
|
11579
|
+
{
|
|
11580
|
+
name: "authTokensSchema",
|
|
11581
|
+
description: "Auth tokens validation (accessToken, refreshToken)",
|
|
11582
|
+
importPath: "@classic-homes/theme-svelte"
|
|
11583
|
+
},
|
|
11584
|
+
{
|
|
11585
|
+
name: "loginResponseSchema",
|
|
11586
|
+
description: "Login API response validation schema",
|
|
11587
|
+
importPath: "@classic-homes/theme-svelte"
|
|
11588
|
+
}
|
|
11589
|
+
],
|
|
11590
|
+
common: [
|
|
11591
|
+
{
|
|
11592
|
+
name: "nonEmptyString",
|
|
11593
|
+
description: "Non-empty string validation",
|
|
11594
|
+
importPath: "@classic-homes/theme-svelte"
|
|
11595
|
+
},
|
|
11596
|
+
{
|
|
11597
|
+
name: "trimmedString",
|
|
11598
|
+
description: "Trimmed string",
|
|
11599
|
+
importPath: "@classic-homes/theme-svelte"
|
|
11600
|
+
},
|
|
11601
|
+
{
|
|
11602
|
+
name: "urlSchema",
|
|
11603
|
+
description: "URL validation",
|
|
11604
|
+
importPath: "@classic-homes/theme-svelte"
|
|
11605
|
+
},
|
|
11606
|
+
{
|
|
11607
|
+
name: "slugSchema",
|
|
11608
|
+
description: "URL slug validation",
|
|
11609
|
+
importPath: "@classic-homes/theme-svelte"
|
|
11610
|
+
},
|
|
11611
|
+
{
|
|
11612
|
+
name: "positiveInt",
|
|
11613
|
+
description: "Positive integer validation",
|
|
11614
|
+
importPath: "@classic-homes/theme-svelte"
|
|
11615
|
+
},
|
|
11616
|
+
{
|
|
11617
|
+
name: "nonNegativeInt",
|
|
11618
|
+
description: "Non-negative integer",
|
|
11619
|
+
importPath: "@classic-homes/theme-svelte"
|
|
11620
|
+
},
|
|
11621
|
+
{
|
|
11622
|
+
name: "percentageSchema",
|
|
11623
|
+
description: "Percentage (0-100)",
|
|
11624
|
+
importPath: "@classic-homes/theme-svelte"
|
|
11625
|
+
},
|
|
11626
|
+
{
|
|
11627
|
+
name: "priceSchema",
|
|
11628
|
+
description: "Price validation",
|
|
11629
|
+
importPath: "@classic-homes/theme-svelte"
|
|
11630
|
+
},
|
|
11631
|
+
{
|
|
11632
|
+
name: "isoDateSchema",
|
|
11633
|
+
description: "ISO date string validation",
|
|
11634
|
+
importPath: "@classic-homes/theme-svelte"
|
|
11635
|
+
},
|
|
11636
|
+
{
|
|
11637
|
+
name: "futureDateSchema",
|
|
11638
|
+
description: "Future date validation",
|
|
11639
|
+
importPath: "@classic-homes/theme-svelte"
|
|
11640
|
+
},
|
|
11641
|
+
{
|
|
11642
|
+
name: "pastDateSchema",
|
|
11643
|
+
description: "Past date validation",
|
|
11644
|
+
importPath: "@classic-homes/theme-svelte"
|
|
11645
|
+
}
|
|
11646
|
+
],
|
|
11647
|
+
file: [
|
|
11648
|
+
{
|
|
11649
|
+
name: "maxFileSize",
|
|
11650
|
+
description: "File size limit validation",
|
|
11651
|
+
importPath: "@classic-homes/theme-svelte"
|
|
11652
|
+
},
|
|
11653
|
+
{
|
|
11654
|
+
name: "allowedFileTypes",
|
|
11655
|
+
description: "File type validation",
|
|
11656
|
+
importPath: "@classic-homes/theme-svelte"
|
|
11657
|
+
},
|
|
11658
|
+
{
|
|
11659
|
+
name: "imageFileSchema",
|
|
11660
|
+
description: "Image file validation",
|
|
11661
|
+
importPath: "@classic-homes/theme-svelte"
|
|
11662
|
+
}
|
|
11663
|
+
],
|
|
11664
|
+
api: [
|
|
11665
|
+
{
|
|
11666
|
+
name: "apiResponseSchema",
|
|
11667
|
+
description: "Standard API response schema",
|
|
11668
|
+
importPath: "@classic-homes/theme-svelte"
|
|
11669
|
+
},
|
|
11670
|
+
{
|
|
11671
|
+
name: "paginatedResponseSchema",
|
|
11672
|
+
description: "Paginated API response",
|
|
11673
|
+
importPath: "@classic-homes/theme-svelte"
|
|
11674
|
+
}
|
|
11675
|
+
],
|
|
11676
|
+
composables: [
|
|
11677
|
+
{
|
|
11678
|
+
name: "useForm",
|
|
11679
|
+
description: "Form state management composable with Zod validation, field tracking, and submission handling",
|
|
11680
|
+
importPath: "@classic-homes/theme-svelte",
|
|
11681
|
+
example: "const form = useForm({\n schema: loginSchema,\n initialValues: { email: '', password: '' },\n onSubmit: async (data) => { /* handle submit */ }\n});"
|
|
11682
|
+
},
|
|
11683
|
+
{
|
|
11684
|
+
name: "usePersistedForm",
|
|
11685
|
+
description: "Form composable with localStorage persistence for draft saving",
|
|
11686
|
+
importPath: "@classic-homes/theme-svelte",
|
|
11687
|
+
example: "const form = usePersistedForm('form-key', {\n schema: registerSchema,\n initialValues: { email: '', name: '' },\n onSubmit: async (data) => { /* handle submit */ }\n});"
|
|
11688
|
+
},
|
|
11689
|
+
{
|
|
11690
|
+
name: "useAsync",
|
|
11691
|
+
description: "Async operation state management with loading, error, and data states",
|
|
11692
|
+
importPath: "@classic-homes/theme-svelte",
|
|
11693
|
+
example: "const { execute, isLoading, error, data } = useAsync(async () => {\n return await fetchData();\n});"
|
|
11694
|
+
}
|
|
11695
|
+
]
|
|
11696
|
+
};
|
|
11697
|
+
|
|
11698
|
+
// src/resources/schemas.ts
|
|
11699
|
+
var schemas = schema_catalog_default;
|
|
11700
|
+
function registerSchemaResources(server) {
|
|
11701
|
+
server.resource("schemas://all", "schemas://all", async (uri) => ({
|
|
11702
|
+
contents: [
|
|
11703
|
+
{
|
|
11704
|
+
uri: uri.href,
|
|
11705
|
+
mimeType: "application/json",
|
|
11706
|
+
text: JSON.stringify(schemas, null, 2)
|
|
11707
|
+
}
|
|
11708
|
+
]
|
|
11709
|
+
}));
|
|
11710
|
+
server.resource("schemas://auth", "schemas://auth", async (uri) => ({
|
|
11711
|
+
contents: [
|
|
11712
|
+
{
|
|
11713
|
+
uri: uri.href,
|
|
11714
|
+
mimeType: "application/json",
|
|
11715
|
+
text: JSON.stringify(schemas.auth, null, 2)
|
|
11716
|
+
}
|
|
11717
|
+
]
|
|
11718
|
+
}));
|
|
11719
|
+
server.resource("schemas://common", "schemas://common", async (uri) => ({
|
|
11720
|
+
contents: [
|
|
11721
|
+
{
|
|
11722
|
+
uri: uri.href,
|
|
11723
|
+
mimeType: "application/json",
|
|
11724
|
+
text: JSON.stringify(schemas.common, null, 2)
|
|
11725
|
+
}
|
|
11726
|
+
]
|
|
11727
|
+
}));
|
|
11728
|
+
}
|
|
11729
|
+
|
|
11730
|
+
// src/resources/auth.ts
|
|
11731
|
+
import { ResourceTemplate as ResourceTemplate3 } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
11732
|
+
|
|
11733
|
+
// src/data/auth-catalog.json
|
|
11734
|
+
var auth_catalog_default = {
|
|
11735
|
+
version: "0.1.0",
|
|
11736
|
+
packageName: "@classic-homes/auth",
|
|
11737
|
+
description: "Authentication services and Svelte bindings for Classic Theme apps",
|
|
11738
|
+
subpackages: {
|
|
11739
|
+
core: {
|
|
11740
|
+
importPath: "@classic-homes/auth/core",
|
|
11741
|
+
description: "Framework-agnostic authentication core. Use this for direct API access or custom integrations.",
|
|
11742
|
+
modules: {
|
|
11743
|
+
config: {
|
|
11744
|
+
description: "Authentication configuration and initialization",
|
|
11745
|
+
functions: [
|
|
11746
|
+
{
|
|
11747
|
+
name: "initAuth",
|
|
11748
|
+
signature: "(config: AuthConfig) => void",
|
|
11749
|
+
description: "Initialize the auth system with configuration options",
|
|
11750
|
+
example: "import { initAuth } from '@classic-homes/auth/core';\n\ninitAuth({\n baseUrl: 'https://api.example.com',\n storage: localStorage,\n sso: {\n enabled: true,\n authorizeUrl: 'https://sso.example.com/authorize'\n }\n});"
|
|
11751
|
+
},
|
|
11752
|
+
{
|
|
11753
|
+
name: "getConfig",
|
|
11754
|
+
signature: "() => AuthConfig",
|
|
11755
|
+
description: "Get the current auth configuration"
|
|
11756
|
+
},
|
|
11757
|
+
{
|
|
11758
|
+
name: "isInitialized",
|
|
11759
|
+
signature: "() => boolean",
|
|
11760
|
+
description: "Check if auth has been initialized"
|
|
11761
|
+
},
|
|
11762
|
+
{
|
|
11763
|
+
name: "resetConfig",
|
|
11764
|
+
signature: "() => void",
|
|
11765
|
+
description: "Reset auth configuration to defaults"
|
|
11766
|
+
},
|
|
11767
|
+
{
|
|
11768
|
+
name: "getDefaultStorage",
|
|
11769
|
+
signature: "() => StorageAdapter",
|
|
11770
|
+
description: "Get the default storage adapter (localStorage with fallback)"
|
|
11771
|
+
},
|
|
11772
|
+
{
|
|
11773
|
+
name: "getStorage",
|
|
11774
|
+
signature: "() => StorageAdapter",
|
|
11775
|
+
description: "Get the configured storage adapter"
|
|
11776
|
+
},
|
|
11777
|
+
{
|
|
11778
|
+
name: "getFetch",
|
|
11779
|
+
signature: "() => typeof fetch",
|
|
11780
|
+
description: "Get the configured fetch function"
|
|
11781
|
+
}
|
|
11782
|
+
],
|
|
11783
|
+
types: [
|
|
11784
|
+
{
|
|
11785
|
+
name: "AuthConfig",
|
|
11786
|
+
description: "Configuration options for auth initialization",
|
|
11787
|
+
properties: [
|
|
11788
|
+
{ name: "baseUrl", type: "string", required: true, description: "Base URL for auth API endpoints" },
|
|
11789
|
+
{ name: "storage", type: "StorageAdapter", required: false, description: "Storage adapter for tokens" },
|
|
11790
|
+
{ name: "fetch", type: "typeof fetch", required: false, description: "Custom fetch implementation" },
|
|
11791
|
+
{ name: "sso", type: "SSOConfig", required: false, description: "SSO configuration" }
|
|
11792
|
+
]
|
|
11793
|
+
},
|
|
11794
|
+
{
|
|
11795
|
+
name: "SSOConfig",
|
|
11796
|
+
description: "SSO provider configuration",
|
|
11797
|
+
properties: [
|
|
11798
|
+
{ name: "enabled", type: "boolean", required: false, description: "Whether SSO is enabled" },
|
|
11799
|
+
{ name: "authorizeUrl", type: "string", required: false, description: "SSO authorization URL" }
|
|
11800
|
+
]
|
|
11801
|
+
},
|
|
11802
|
+
{
|
|
11803
|
+
name: "StorageAdapter",
|
|
11804
|
+
description: "Interface for token storage",
|
|
11805
|
+
properties: [
|
|
11806
|
+
{ name: "getItem", type: "(key: string) => string | null", required: true, description: "Get item from storage" },
|
|
11807
|
+
{ name: "setItem", type: "(key: string, value: string) => void", required: true, description: "Set item in storage" },
|
|
11808
|
+
{ name: "removeItem", type: "(key: string) => void", required: true, description: "Remove item from storage" }
|
|
11809
|
+
]
|
|
11810
|
+
}
|
|
11811
|
+
]
|
|
11812
|
+
},
|
|
11813
|
+
client: {
|
|
11814
|
+
description: "HTTP client utilities for API requests",
|
|
11815
|
+
functions: [
|
|
11816
|
+
{
|
|
11817
|
+
name: "api",
|
|
11818
|
+
signature: "{ get, post, put, delete }",
|
|
11819
|
+
description: "HTTP client object with methods for making API requests"
|
|
11820
|
+
},
|
|
11821
|
+
{
|
|
11822
|
+
name: "apiRequest",
|
|
11823
|
+
signature: "(url: string, options?: ApiRequestOptions) => Promise<Response>",
|
|
11824
|
+
description: "Make an authenticated API request"
|
|
11825
|
+
},
|
|
11826
|
+
{
|
|
11827
|
+
name: "extractData",
|
|
11828
|
+
signature: "<T>(response: { data: T } | T) => T",
|
|
11829
|
+
description: "Extract data from API response wrapper"
|
|
11830
|
+
},
|
|
11831
|
+
{
|
|
11832
|
+
name: "getAccessToken",
|
|
11833
|
+
signature: "() => string | null",
|
|
11834
|
+
description: "Get the stored access token"
|
|
11835
|
+
},
|
|
11836
|
+
{
|
|
11837
|
+
name: "getRefreshToken",
|
|
11838
|
+
signature: "() => string | null",
|
|
11839
|
+
description: "Get the stored refresh token"
|
|
11840
|
+
},
|
|
11841
|
+
{
|
|
11842
|
+
name: "getSessionToken",
|
|
11843
|
+
signature: "() => string | null",
|
|
11844
|
+
description: "Get the stored session token"
|
|
11845
|
+
},
|
|
11846
|
+
{
|
|
11847
|
+
name: "updateStoredTokens",
|
|
11848
|
+
signature: "(tokens: { accessToken?: string; refreshToken?: string; sessionToken?: string }) => void",
|
|
11849
|
+
description: "Update stored tokens"
|
|
11850
|
+
},
|
|
11851
|
+
{
|
|
11852
|
+
name: "clearStoredAuth",
|
|
11853
|
+
signature: "() => void",
|
|
11854
|
+
description: "Clear all stored authentication data"
|
|
11855
|
+
}
|
|
11856
|
+
],
|
|
11857
|
+
types: [
|
|
11858
|
+
{
|
|
11859
|
+
name: "ApiRequestOptions",
|
|
11860
|
+
description: "Options for API requests"
|
|
11861
|
+
},
|
|
11862
|
+
{
|
|
11863
|
+
name: "ApiResponse",
|
|
11864
|
+
description: "Standard API response wrapper"
|
|
11865
|
+
}
|
|
11866
|
+
]
|
|
11867
|
+
},
|
|
11868
|
+
api: {
|
|
11869
|
+
description: "Auth API client methods for all authentication endpoints",
|
|
11870
|
+
functions: [
|
|
11871
|
+
{
|
|
11872
|
+
name: "authApi.login",
|
|
11873
|
+
signature: "(credentials: LoginCredentials) => Promise<LoginResponse>",
|
|
11874
|
+
description: "Login with username and password",
|
|
11875
|
+
example: "import { authApi } from '@classic-homes/auth/core';\n\nconst response = await authApi.login({\n username: 'user@example.com',\n password: 'password'\n});\n\nif (response.requiresMFA) {\n // Handle MFA challenge\n} else {\n // Login success\n console.log(response.user);\n}"
|
|
11876
|
+
},
|
|
11877
|
+
{
|
|
11878
|
+
name: "authApi.logout",
|
|
11879
|
+
signature: "() => Promise<LogoutResponse>",
|
|
11880
|
+
description: "Logout the current user. Returns SSO logout URL if applicable."
|
|
11881
|
+
},
|
|
11882
|
+
{
|
|
11883
|
+
name: "authApi.register",
|
|
11884
|
+
signature: "(data: RegisterData) => Promise<RegisterResponse>",
|
|
11885
|
+
description: "Register a new user"
|
|
11886
|
+
},
|
|
11887
|
+
{
|
|
11888
|
+
name: "authApi.forgotPassword",
|
|
11889
|
+
signature: "(email: string) => Promise<void>",
|
|
11890
|
+
description: "Request a password reset email"
|
|
11891
|
+
},
|
|
11892
|
+
{
|
|
11893
|
+
name: "authApi.resetPassword",
|
|
11894
|
+
signature: "(token: string, newPassword: string) => Promise<void>",
|
|
11895
|
+
description: "Reset password with a token"
|
|
11896
|
+
},
|
|
11897
|
+
{
|
|
11898
|
+
name: "authApi.refreshToken",
|
|
11899
|
+
signature: "(refreshToken: string) => Promise<{ accessToken: string; refreshToken: string }>",
|
|
11900
|
+
description: "Refresh the access token"
|
|
11901
|
+
},
|
|
11902
|
+
{
|
|
11903
|
+
name: "authApi.initiateSSOLogin",
|
|
11904
|
+
signature: "(options?: { callbackUrl?: string; redirectUrl?: string }) => void",
|
|
11905
|
+
description: "Initiate SSO login by redirecting to the SSO provider"
|
|
11906
|
+
},
|
|
11907
|
+
{
|
|
11908
|
+
name: "authApi.getProfile",
|
|
11909
|
+
signature: "(customFetch?: typeof fetch) => Promise<User>",
|
|
11910
|
+
description: "Get the current user's profile"
|
|
11911
|
+
},
|
|
11912
|
+
{
|
|
11913
|
+
name: "authApi.updateProfile",
|
|
11914
|
+
signature: "(data: ProfileUpdateData) => Promise<User>",
|
|
11915
|
+
description: "Update the current user's profile"
|
|
11916
|
+
},
|
|
11917
|
+
{
|
|
11918
|
+
name: "authApi.changePassword",
|
|
11919
|
+
signature: "(data: ChangePasswordData) => Promise<void>",
|
|
11920
|
+
description: "Change the current user's password"
|
|
11921
|
+
},
|
|
11922
|
+
{
|
|
11923
|
+
name: "authApi.resendVerification",
|
|
11924
|
+
signature: "() => Promise<void>",
|
|
11925
|
+
description: "Resend email verification"
|
|
11926
|
+
},
|
|
11927
|
+
{
|
|
11928
|
+
name: "authApi.verifyEmail",
|
|
11929
|
+
signature: "(token: string) => Promise<{ message: string; user?: User }>",
|
|
11930
|
+
description: "Verify email with a token"
|
|
11931
|
+
},
|
|
11932
|
+
{
|
|
11933
|
+
name: "authApi.getSessions",
|
|
11934
|
+
signature: "(customFetch?: typeof fetch) => Promise<{ sessions: Session[]; total: number }>",
|
|
11935
|
+
description: "Get all active sessions"
|
|
11936
|
+
},
|
|
11937
|
+
{
|
|
11938
|
+
name: "authApi.revokeSession",
|
|
11939
|
+
signature: "(sessionId: string) => Promise<void>",
|
|
11940
|
+
description: "Revoke a specific session"
|
|
11941
|
+
},
|
|
11942
|
+
{
|
|
11943
|
+
name: "authApi.revokeAllSessions",
|
|
11944
|
+
signature: "() => Promise<void>",
|
|
11945
|
+
description: "Revoke all sessions except the current one"
|
|
11946
|
+
},
|
|
11947
|
+
{
|
|
11948
|
+
name: "authApi.getApiKeys",
|
|
11949
|
+
signature: "(customFetch?: typeof fetch) => Promise<{ apiKeys: ApiKey[] }>",
|
|
11950
|
+
description: "Get all API keys"
|
|
11951
|
+
},
|
|
11952
|
+
{
|
|
11953
|
+
name: "authApi.createApiKey",
|
|
11954
|
+
signature: "(data: CreateApiKeyRequest) => Promise<CreateApiKeyResponse>",
|
|
11955
|
+
description: "Create a new API key"
|
|
11956
|
+
},
|
|
11957
|
+
{
|
|
11958
|
+
name: "authApi.revokeApiKey",
|
|
11959
|
+
signature: "(keyId: string) => Promise<void>",
|
|
11960
|
+
description: "Revoke an API key"
|
|
11961
|
+
},
|
|
11962
|
+
{
|
|
11963
|
+
name: "authApi.updateApiKey",
|
|
11964
|
+
signature: "(keyId: string, data: { name: string }) => Promise<void>",
|
|
11965
|
+
description: "Update an API key's name"
|
|
11966
|
+
},
|
|
11967
|
+
{
|
|
11968
|
+
name: "authApi.getMFAStatus",
|
|
11969
|
+
signature: "() => Promise<MFAStatus>",
|
|
11970
|
+
description: "Get MFA status for the current user"
|
|
11971
|
+
},
|
|
11972
|
+
{
|
|
11973
|
+
name: "authApi.setupMFA",
|
|
11974
|
+
signature: "() => Promise<MFASetupResponse>",
|
|
11975
|
+
description: "Setup MFA (get QR code and backup codes)"
|
|
11976
|
+
},
|
|
11977
|
+
{
|
|
11978
|
+
name: "authApi.verifyMFASetup",
|
|
11979
|
+
signature: "(code: string) => Promise<void>",
|
|
11980
|
+
description: "Verify MFA setup with a code"
|
|
11981
|
+
},
|
|
11982
|
+
{
|
|
11983
|
+
name: "authApi.disableMFA",
|
|
11984
|
+
signature: "(password: string) => Promise<void>",
|
|
11985
|
+
description: "Disable MFA"
|
|
11986
|
+
},
|
|
11987
|
+
{
|
|
11988
|
+
name: "authApi.verifyMFAChallenge",
|
|
11989
|
+
signature: "(data: MFAChallengeData) => Promise<LoginResponse>",
|
|
11990
|
+
description: "Verify MFA challenge during login"
|
|
11991
|
+
},
|
|
11992
|
+
{
|
|
11993
|
+
name: "authApi.getDevices",
|
|
11994
|
+
signature: "(customFetch?: typeof fetch) => Promise<{ devices: Device[] }>",
|
|
11995
|
+
description: "Get all devices"
|
|
11996
|
+
},
|
|
11997
|
+
{
|
|
11998
|
+
name: "authApi.trustDevice",
|
|
11999
|
+
signature: "(deviceId: string) => Promise<void>",
|
|
12000
|
+
description: "Trust a device"
|
|
12001
|
+
},
|
|
12002
|
+
{
|
|
12003
|
+
name: "authApi.revokeDevice",
|
|
12004
|
+
signature: "(deviceId: string) => Promise<void>",
|
|
12005
|
+
description: "Revoke device trust"
|
|
12006
|
+
},
|
|
12007
|
+
{
|
|
12008
|
+
name: "authApi.removeDevice",
|
|
12009
|
+
signature: "(deviceId: string) => Promise<void>",
|
|
12010
|
+
description: "Remove a device completely"
|
|
12011
|
+
},
|
|
12012
|
+
{
|
|
12013
|
+
name: "authApi.approveDevice",
|
|
12014
|
+
signature: "(token: string) => Promise<{ message: string; device?: Device }>",
|
|
12015
|
+
description: "Approve a device with a token"
|
|
12016
|
+
},
|
|
12017
|
+
{
|
|
12018
|
+
name: "authApi.blockDevice",
|
|
12019
|
+
signature: "(token: string) => Promise<{ message: string; device?: Device }>",
|
|
12020
|
+
description: "Block a device with a token"
|
|
12021
|
+
},
|
|
12022
|
+
{
|
|
12023
|
+
name: "authApi.getPreferences",
|
|
12024
|
+
signature: "(customFetch?: typeof fetch) => Promise<UserPreferences>",
|
|
12025
|
+
description: "Get user preferences"
|
|
12026
|
+
},
|
|
12027
|
+
{
|
|
12028
|
+
name: "authApi.updatePreferences",
|
|
12029
|
+
signature: "(data: Partial<UserPreferences>) => Promise<void>",
|
|
12030
|
+
description: "Update user preferences"
|
|
12031
|
+
},
|
|
12032
|
+
{
|
|
12033
|
+
name: "authApi.getSSOAccounts",
|
|
12034
|
+
signature: "(customFetch?: typeof fetch) => Promise<LinkedAccount[]>",
|
|
12035
|
+
description: "Get SSO linked accounts"
|
|
12036
|
+
},
|
|
12037
|
+
{
|
|
12038
|
+
name: "authApi.unlinkSSOAccount",
|
|
12039
|
+
signature: "(provider: string, password?: string) => Promise<void>",
|
|
12040
|
+
description: "Unlink an SSO account"
|
|
12041
|
+
},
|
|
12042
|
+
{
|
|
12043
|
+
name: "authApi.linkSSOAccount",
|
|
12044
|
+
signature: "(provider?: string) => Promise<void>",
|
|
12045
|
+
description: "Link an SSO account (redirects to SSO provider)"
|
|
12046
|
+
},
|
|
12047
|
+
{
|
|
12048
|
+
name: "authApi.getSecurityEvents",
|
|
12049
|
+
signature: "(params?: { page?: number; limit?: number; type?: string }, customFetch?: typeof fetch) => Promise<{ events: SecurityEvent[]; pagination: Pagination }>",
|
|
12050
|
+
description: "Get security event history"
|
|
12051
|
+
},
|
|
12052
|
+
{
|
|
12053
|
+
name: "authApi.getApiKey",
|
|
12054
|
+
signature: "(keyId: string, customFetch?: typeof fetch) => Promise<ApiKey>",
|
|
12055
|
+
description: "Get details for a specific API key"
|
|
12056
|
+
},
|
|
12057
|
+
{
|
|
12058
|
+
name: "authApi.getMfaMethods",
|
|
12059
|
+
signature: "() => Promise<MfaMethodsStatus>",
|
|
12060
|
+
description: "Get available MFA methods and their status"
|
|
12061
|
+
},
|
|
12062
|
+
{
|
|
12063
|
+
name: "authApi.setupMfaMethod",
|
|
12064
|
+
signature: "(method: 'totp' | 'email') => Promise<MfaMethodSetupResponse>",
|
|
12065
|
+
description: "Setup a specific MFA method"
|
|
12066
|
+
},
|
|
12067
|
+
{
|
|
12068
|
+
name: "authApi.verifyMfaMethod",
|
|
12069
|
+
signature: "(method: 'totp' | 'email', code: string) => Promise<{ success: boolean; message: string; backupCodes?: string[] }>",
|
|
12070
|
+
description: "Verify and enable a specific MFA method"
|
|
12071
|
+
},
|
|
12072
|
+
{
|
|
12073
|
+
name: "authApi.disableMfaMethod",
|
|
12074
|
+
signature: "(method: 'totp' | 'email', options: { password?: string; code?: string }) => Promise<void>",
|
|
12075
|
+
description: "Disable a specific MFA method"
|
|
12076
|
+
},
|
|
12077
|
+
{
|
|
12078
|
+
name: "authApi.sendMfaEmailCode",
|
|
12079
|
+
signature: "() => Promise<{ success: boolean; email: string; message: string }>",
|
|
12080
|
+
description: "Send MFA verification code via email"
|
|
12081
|
+
},
|
|
12082
|
+
{
|
|
12083
|
+
name: "authApi.getSecurityOverview",
|
|
12084
|
+
signature: "(customFetch?: typeof fetch) => Promise<SecurityOverview>",
|
|
12085
|
+
description: "Get security overview with recent events and device counts"
|
|
12086
|
+
},
|
|
12087
|
+
{
|
|
12088
|
+
name: "authApi.getSecuritySummary",
|
|
12089
|
+
signature: "(customFetch?: typeof fetch) => Promise<SecuritySummary>",
|
|
12090
|
+
description: "Get security summary with score and recommendations"
|
|
12091
|
+
},
|
|
12092
|
+
{
|
|
12093
|
+
name: "authApi.getTrustedDevices",
|
|
12094
|
+
signature: "(customFetch?: typeof fetch) => Promise<{ devices: Device[]; total: number }>",
|
|
12095
|
+
description: "Get list of trusted devices"
|
|
12096
|
+
}
|
|
12097
|
+
]
|
|
12098
|
+
},
|
|
12099
|
+
service: {
|
|
12100
|
+
description: "Auth service with automatic store updates",
|
|
12101
|
+
functions: [
|
|
12102
|
+
{
|
|
12103
|
+
name: "AuthService",
|
|
12104
|
+
signature: "class",
|
|
12105
|
+
description: "Service class that wraps auth API and updates stores automatically",
|
|
12106
|
+
example: "import { authService } from '@classic-homes/auth/core';\n\n// Use the singleton instance\nconst response = await authService.login({\n username: 'user@example.com',\n password: 'password'\n});\n\n// Or create your own instance\nconst service = new AuthService({ storeUpdate: myStoreUpdateFn });"
|
|
12107
|
+
},
|
|
12108
|
+
{
|
|
12109
|
+
name: "authService",
|
|
12110
|
+
signature: "AuthService",
|
|
12111
|
+
description: "Singleton instance of AuthService"
|
|
12112
|
+
}
|
|
12113
|
+
],
|
|
12114
|
+
types: [
|
|
12115
|
+
{
|
|
12116
|
+
name: "LoginOptions",
|
|
12117
|
+
description: "Options for login operation",
|
|
12118
|
+
properties: [
|
|
12119
|
+
{ name: "updateStore", type: "boolean", required: false, description: "Whether to update auth store" }
|
|
12120
|
+
]
|
|
12121
|
+
},
|
|
12122
|
+
{
|
|
12123
|
+
name: "MFAVerifyOptions",
|
|
12124
|
+
description: "Options for MFA verification",
|
|
12125
|
+
properties: [
|
|
12126
|
+
{ name: "updateStore", type: "boolean", required: false, description: "Whether to update auth store" }
|
|
12127
|
+
]
|
|
12128
|
+
}
|
|
12129
|
+
]
|
|
12130
|
+
},
|
|
12131
|
+
guards: {
|
|
12132
|
+
description: "Type guards for auth responses",
|
|
12133
|
+
functions: [
|
|
12134
|
+
{
|
|
12135
|
+
name: "isMfaChallengeResponse",
|
|
12136
|
+
signature: "(response: LoginResponse) => boolean",
|
|
12137
|
+
description: "Check if a login response requires MFA verification",
|
|
12138
|
+
example: "import { authApi, isMfaChallengeResponse } from '@classic-homes/auth/core';\n\nconst response = await authApi.login(credentials);\n\nif (isMfaChallengeResponse(response)) {\n // Redirect to MFA verification\n const mfaToken = getMfaToken(response);\n} else {\n // Login complete\n}"
|
|
12139
|
+
},
|
|
12140
|
+
{
|
|
12141
|
+
name: "isLoginSuccessResponse",
|
|
12142
|
+
signature: "(response: LoginResponse) => boolean",
|
|
12143
|
+
description: "Check if a login response is a success (not MFA challenge)"
|
|
12144
|
+
},
|
|
12145
|
+
{
|
|
12146
|
+
name: "getMfaToken",
|
|
12147
|
+
signature: "(response: LoginResponse) => string | undefined",
|
|
12148
|
+
description: "Extract MFA token from a login response"
|
|
12149
|
+
},
|
|
12150
|
+
{
|
|
12151
|
+
name: "getAvailableMethods",
|
|
12152
|
+
signature: "(response: LoginResponse) => string[]",
|
|
12153
|
+
description: "Get available MFA methods from a login response"
|
|
12154
|
+
}
|
|
12155
|
+
]
|
|
12156
|
+
},
|
|
12157
|
+
jwt: {
|
|
12158
|
+
description: "JWT token utilities",
|
|
12159
|
+
functions: [
|
|
12160
|
+
{
|
|
12161
|
+
name: "decodeJWT",
|
|
12162
|
+
signature: "(token: string) => JWTPayload | null",
|
|
12163
|
+
description: "Decode a JWT token without verification",
|
|
12164
|
+
example: "import { decodeJWT, isTokenExpired } from '@classic-homes/auth/core';\n\nconst payload = decodeJWT(accessToken);\nif (payload && !isTokenExpired(accessToken)) {\n console.log('User ID:', payload.sub);\n console.log('Expires:', new Date(payload.exp * 1000));\n}"
|
|
12165
|
+
},
|
|
12166
|
+
{
|
|
12167
|
+
name: "isTokenExpired",
|
|
12168
|
+
signature: "(token: string) => boolean",
|
|
12169
|
+
description: "Check if a JWT token is expired"
|
|
12170
|
+
},
|
|
12171
|
+
{
|
|
12172
|
+
name: "getTokenRemainingTime",
|
|
12173
|
+
signature: "(token: string) => number",
|
|
12174
|
+
description: "Get remaining time in milliseconds until token expires"
|
|
12175
|
+
},
|
|
12176
|
+
{
|
|
12177
|
+
name: "getTokenExpiration",
|
|
12178
|
+
signature: "(token: string) => Date | null",
|
|
12179
|
+
description: "Get the expiration date of a token"
|
|
12180
|
+
},
|
|
12181
|
+
{
|
|
12182
|
+
name: "extractClaims",
|
|
12183
|
+
signature: "<T extends object>(token: string) => T | null",
|
|
12184
|
+
description: "Extract custom claims from a JWT token"
|
|
12185
|
+
}
|
|
12186
|
+
],
|
|
12187
|
+
types: [
|
|
12188
|
+
{
|
|
12189
|
+
name: "JWTPayload",
|
|
12190
|
+
description: "Standard JWT payload structure",
|
|
12191
|
+
properties: [
|
|
12192
|
+
{ name: "sub", type: "string", required: true, description: "Subject (user ID)" },
|
|
12193
|
+
{ name: "exp", type: "number", required: true, description: "Expiration timestamp" },
|
|
12194
|
+
{ name: "iat", type: "number", required: true, description: "Issued at timestamp" },
|
|
12195
|
+
{ name: "iss", type: "string", required: false, description: "Issuer" },
|
|
12196
|
+
{ name: "aud", type: "string | string[]", required: false, description: "Audience" }
|
|
12197
|
+
]
|
|
12198
|
+
}
|
|
12199
|
+
]
|
|
12200
|
+
}
|
|
12201
|
+
},
|
|
12202
|
+
types: [
|
|
12203
|
+
{
|
|
12204
|
+
name: "User",
|
|
12205
|
+
description: "User information",
|
|
12206
|
+
properties: [
|
|
12207
|
+
{ name: "id", type: "string", required: true, description: "User ID" },
|
|
12208
|
+
{ name: "username", type: "string", required: true, description: "Username" },
|
|
12209
|
+
{ name: "email", type: "string", required: true, description: "Email address" },
|
|
12210
|
+
{ name: "firstName", type: "string", required: false, description: "First name" },
|
|
12211
|
+
{ name: "lastName", type: "string", required: false, description: "Last name" },
|
|
12212
|
+
{ name: "phone", type: "string", required: false, description: "Phone number" },
|
|
12213
|
+
{ name: "role", type: "string", required: true, description: "Primary role" },
|
|
12214
|
+
{ name: "roles", type: "string[]", required: false, description: "All assigned roles" },
|
|
12215
|
+
{ name: "permissions", type: "string[]", required: true, description: "User permissions" },
|
|
12216
|
+
{ name: "isActive", type: "boolean", required: true, description: "Whether user is active" },
|
|
12217
|
+
{ name: "emailVerified", type: "boolean", required: true, description: "Whether email is verified" },
|
|
12218
|
+
{ name: "authMethod", type: "'password' | 'oauth' | 'both'", required: false, description: "Authentication method" },
|
|
12219
|
+
{ name: "ssoProfileUrl", type: "string", required: false, description: "SSO profile URL" },
|
|
12220
|
+
{ name: "createdAt", type: "string", required: true, description: "Creation timestamp" },
|
|
12221
|
+
{ name: "lastLoginAt", type: "string", required: false, description: "Last login timestamp" }
|
|
12222
|
+
]
|
|
12223
|
+
},
|
|
12224
|
+
{
|
|
12225
|
+
name: "AuthState",
|
|
12226
|
+
description: "Current authentication state",
|
|
12227
|
+
properties: [
|
|
12228
|
+
{ name: "accessToken", type: "string | null", required: true, description: "Current access token" },
|
|
12229
|
+
{ name: "refreshToken", type: "string | null", required: true, description: "Current refresh token" },
|
|
12230
|
+
{ name: "user", type: "User | null", required: true, description: "Current user" },
|
|
12231
|
+
{ name: "isAuthenticated", type: "boolean", required: true, description: "Whether user is authenticated" }
|
|
12232
|
+
]
|
|
12233
|
+
},
|
|
12234
|
+
{
|
|
12235
|
+
name: "LoginCredentials",
|
|
12236
|
+
description: "Login credentials",
|
|
12237
|
+
properties: [
|
|
12238
|
+
{ name: "username", type: "string", required: true, description: "Username or email" },
|
|
12239
|
+
{ name: "password", type: "string", required: true, description: "Password" }
|
|
12240
|
+
]
|
|
12241
|
+
},
|
|
12242
|
+
{
|
|
12243
|
+
name: "LoginResponse",
|
|
12244
|
+
description: "Response from login API",
|
|
12245
|
+
properties: [
|
|
12246
|
+
{ name: "accessToken", type: "string", required: true, description: "Access token" },
|
|
12247
|
+
{ name: "refreshToken", type: "string", required: true, description: "Refresh token" },
|
|
12248
|
+
{ name: "sessionToken", type: "string", required: false, description: "Session token" },
|
|
12249
|
+
{ name: "user", type: "User", required: true, description: "User info" },
|
|
12250
|
+
{ name: "expiresIn", type: "number", required: true, description: "Token expiration in seconds" },
|
|
12251
|
+
{ name: "requiresMFA", type: "boolean", required: false, description: "Whether MFA is required" },
|
|
12252
|
+
{ name: "mfaToken", type: "string", required: false, description: "MFA challenge token" },
|
|
12253
|
+
{ name: "availableMethods", type: "string[]", required: false, description: "Available MFA methods" }
|
|
12254
|
+
]
|
|
12255
|
+
},
|
|
12256
|
+
{
|
|
12257
|
+
name: "Session",
|
|
12258
|
+
description: "User session information",
|
|
12259
|
+
properties: [
|
|
12260
|
+
{ name: "id", type: "string", required: true, description: "Session ID" },
|
|
12261
|
+
{ name: "deviceName", type: "string", required: true, description: "Device name" },
|
|
12262
|
+
{ name: "browser", type: "string", required: true, description: "Browser info" },
|
|
12263
|
+
{ name: "location", type: "string", required: true, description: "Location" },
|
|
12264
|
+
{ name: "ipAddress", type: "string", required: true, description: "IP address" },
|
|
12265
|
+
{ name: "lastActivity", type: "string", required: true, description: "Last activity timestamp" },
|
|
12266
|
+
{ name: "isCurrent", type: "boolean", required: true, description: "Whether this is the current session" },
|
|
12267
|
+
{ name: "isTrusted", type: "boolean", required: true, description: "Whether device is trusted" },
|
|
12268
|
+
{ name: "createdAt", type: "string", required: true, description: "Session creation time" },
|
|
12269
|
+
{ name: "expiresAt", type: "string", required: true, description: "Session expiration time" }
|
|
12270
|
+
]
|
|
12271
|
+
},
|
|
12272
|
+
{
|
|
12273
|
+
name: "Device",
|
|
12274
|
+
description: "Device information",
|
|
12275
|
+
properties: [
|
|
12276
|
+
{ name: "id", type: "string", required: true, description: "Device ID" },
|
|
12277
|
+
{ name: "deviceFingerprint", type: "string", required: true, description: "Device fingerprint" },
|
|
12278
|
+
{ name: "deviceName", type: "string", required: true, description: "Device name" },
|
|
12279
|
+
{ name: "trusted", type: "boolean", required: true, description: "Whether device is trusted" },
|
|
12280
|
+
{ name: "status", type: "'active' | 'revoked'", required: true, description: "Device status" },
|
|
12281
|
+
{ name: "lastSeen", type: "string | null", required: false, description: "Last seen timestamp" },
|
|
12282
|
+
{ name: "createdAt", type: "string", required: true, description: "Creation timestamp" }
|
|
12283
|
+
]
|
|
12284
|
+
},
|
|
12285
|
+
{
|
|
12286
|
+
name: "ApiKey",
|
|
12287
|
+
description: "API key information",
|
|
12288
|
+
properties: [
|
|
12289
|
+
{ name: "id", type: "string", required: true, description: "API key ID" },
|
|
12290
|
+
{ name: "name", type: "string", required: true, description: "Key name" },
|
|
12291
|
+
{ name: "description", type: "string", required: false, description: "Key description" },
|
|
12292
|
+
{ name: "keyPreview", type: "string", required: true, description: "Partial key preview" },
|
|
12293
|
+
{ name: "permissions", type: "string[]", required: true, description: "Key permissions" },
|
|
12294
|
+
{ name: "isActive", type: "boolean", required: true, description: "Whether key is active" },
|
|
12295
|
+
{ name: "expiresAt", type: "string | null", required: false, description: "Expiration date" },
|
|
12296
|
+
{ name: "lastUsedAt", type: "string | null", required: false, description: "Last used timestamp" },
|
|
12297
|
+
{ name: "createdAt", type: "string", required: true, description: "Creation timestamp" }
|
|
12298
|
+
]
|
|
12299
|
+
},
|
|
12300
|
+
{
|
|
12301
|
+
name: "MFASetupResponse",
|
|
12302
|
+
description: "MFA setup response with QR code and backup codes",
|
|
12303
|
+
properties: [
|
|
12304
|
+
{ name: "qrCodeUrl", type: "string", required: true, description: "QR code image URL" },
|
|
12305
|
+
{ name: "manualEntryKey", type: "string", required: true, description: "Manual entry key for authenticator apps" },
|
|
12306
|
+
{ name: "backupCodes", type: "string[]", required: true, description: "One-time backup codes" },
|
|
12307
|
+
{ name: "instructions", type: "object", required: true, description: "Setup instructions" }
|
|
12308
|
+
]
|
|
12309
|
+
},
|
|
12310
|
+
{
|
|
12311
|
+
name: "MFAStatus",
|
|
12312
|
+
description: "MFA status for user",
|
|
12313
|
+
properties: [
|
|
12314
|
+
{ name: "enabled", type: "boolean", required: true, description: "Whether MFA is enabled" },
|
|
12315
|
+
{ name: "setupRequired", type: "boolean", required: true, description: "Whether MFA setup is required" }
|
|
12316
|
+
]
|
|
12317
|
+
},
|
|
12318
|
+
{
|
|
12319
|
+
name: "MfaMethodsStatus",
|
|
12320
|
+
description: "Available MFA methods and their status",
|
|
12321
|
+
properties: [
|
|
12322
|
+
{ name: "methods", type: "{ totp: { enabled: boolean; configured: boolean }; email: { enabled: boolean; configured: boolean } }", required: true, description: "Status of each MFA method" },
|
|
12323
|
+
{ name: "mfaRequired", type: "boolean", required: true, description: "Whether MFA is required overall" }
|
|
12324
|
+
]
|
|
12325
|
+
},
|
|
12326
|
+
{
|
|
12327
|
+
name: "MfaMethodSetupResponse",
|
|
12328
|
+
description: "Response from MFA method setup",
|
|
12329
|
+
properties: [
|
|
12330
|
+
{ name: "method", type: "'totp' | 'email'", required: true, description: "MFA method being set up" },
|
|
12331
|
+
{ name: "qrCodeUrl", type: "string", required: false, description: "QR code URL for TOTP" },
|
|
12332
|
+
{ name: "manualEntryKey", type: "string", required: false, description: "Manual entry key for TOTP" },
|
|
12333
|
+
{ name: "backupCodes", type: "string[]", required: false, description: "Backup codes for TOTP" },
|
|
12334
|
+
{ name: "email", type: "string", required: false, description: "Masked email for email method" },
|
|
12335
|
+
{ name: "message", type: "string", required: false, description: "Status message" }
|
|
12336
|
+
]
|
|
12337
|
+
},
|
|
12338
|
+
{
|
|
12339
|
+
name: "SecurityOverview",
|
|
12340
|
+
description: "Security overview for the user",
|
|
12341
|
+
properties: [
|
|
12342
|
+
{ name: "overview", type: "{ trustedDevicesCount: number; recentEventsCount: number }", required: true, description: "Security counts" },
|
|
12343
|
+
{ name: "recentEvents", type: "SecurityEvent[]", required: true, description: "Recent security events" },
|
|
12344
|
+
{ name: "devicesEndpoint", type: "string", required: true, description: "Endpoint for device management" }
|
|
12345
|
+
]
|
|
12346
|
+
},
|
|
12347
|
+
{
|
|
12348
|
+
name: "SecuritySummary",
|
|
12349
|
+
description: "Security summary with score and recommendations",
|
|
12350
|
+
properties: [
|
|
12351
|
+
{ name: "mfa", type: "{ enabled: boolean; recommended: boolean }", required: true, description: "MFA status" },
|
|
12352
|
+
{ name: "devices", type: "{ total: number; trusted: number; untrusted: number }", required: true, description: "Device counts" },
|
|
12353
|
+
{ name: "recentActivity", type: "{ period: string; events: Record<string, number>; totalEvents: number }", required: true, description: "Recent activity summary" },
|
|
12354
|
+
{ name: "securityScore", type: "{ score: number; level: string; recommendations: string[] }", required: true, description: "Security score and recommendations" }
|
|
12355
|
+
]
|
|
12356
|
+
},
|
|
12357
|
+
{
|
|
12358
|
+
name: "MFAChallengeData",
|
|
12359
|
+
description: "Data for MFA challenge verification",
|
|
12360
|
+
properties: [
|
|
12361
|
+
{ name: "mfaToken", type: "string", required: true, description: "MFA challenge token from login" },
|
|
12362
|
+
{ name: "code", type: "string", required: true, description: "MFA code from authenticator" },
|
|
12363
|
+
{ name: "method", type: "'totp' | 'email' | 'backup'", required: false, description: "MFA method" },
|
|
12364
|
+
{ name: "trustDevice", type: "boolean", required: false, description: "Whether to trust this device" }
|
|
12365
|
+
]
|
|
12366
|
+
},
|
|
12367
|
+
{
|
|
12368
|
+
name: "UserPreferences",
|
|
12369
|
+
description: "User preference settings",
|
|
12370
|
+
properties: [
|
|
12371
|
+
{ name: "emailNotifications", type: "boolean", required: true, description: "Email notifications enabled" },
|
|
12372
|
+
{ name: "securityAlerts", type: "boolean", required: true, description: "Security alerts enabled" },
|
|
12373
|
+
{ name: "loginNotifications", type: "boolean", required: true, description: "Login notifications enabled" },
|
|
12374
|
+
{ name: "suspiciousActivityAlerts", type: "boolean", required: true, description: "Suspicious activity alerts" },
|
|
12375
|
+
{ name: "passwordChangeNotifications", type: "boolean", required: true, description: "Password change notifications" },
|
|
12376
|
+
{ name: "mfaChangeNotifications", type: "boolean", required: true, description: "MFA change notifications" },
|
|
12377
|
+
{ name: "accountUpdates", type: "boolean", required: true, description: "Account updates enabled" },
|
|
12378
|
+
{ name: "systemMaintenance", type: "boolean", required: true, description: "System maintenance notifications" },
|
|
12379
|
+
{ name: "featureAnnouncements", type: "boolean", required: true, description: "Feature announcements" },
|
|
12380
|
+
{ name: "newsAndUpdates", type: "boolean", required: true, description: "News and updates" },
|
|
12381
|
+
{ name: "apiKeyExpiration", type: "boolean", required: true, description: "API key expiration alerts" },
|
|
12382
|
+
{ name: "apiUsageAlerts", type: "boolean", required: true, description: "API usage alerts" },
|
|
12383
|
+
{ name: "rateLimit", type: "boolean", required: true, description: "Rate limit notifications" },
|
|
12384
|
+
{ name: "dataExportReady", type: "boolean", required: true, description: "Data export ready notifications" },
|
|
12385
|
+
{ name: "reportGeneration", type: "boolean", required: true, description: "Report generation notifications" },
|
|
12386
|
+
{ name: "theme", type: "'light' | 'dark' | 'system'", required: true, description: "UI theme preference" },
|
|
12387
|
+
{ name: "language", type: "string", required: true, description: "Language preference" },
|
|
12388
|
+
{ name: "timezone", type: "string", required: true, description: "Timezone preference" },
|
|
12389
|
+
{ name: "dateFormat", type: "string", required: true, description: "Date format preference" },
|
|
12390
|
+
{ name: "timeFormat", type: "'12h' | '24h'", required: true, description: "Time format preference" },
|
|
12391
|
+
{ name: "advancedSettings", type: "Record<string, any> | null", required: false, description: "Advanced settings" }
|
|
12392
|
+
]
|
|
12393
|
+
},
|
|
12394
|
+
{
|
|
12395
|
+
name: "LinkedAccount",
|
|
12396
|
+
description: "SSO linked account",
|
|
12397
|
+
properties: [
|
|
12398
|
+
{ name: "id", type: "string", required: true, description: "Account ID" },
|
|
12399
|
+
{ name: "provider", type: "string", required: true, description: "SSO provider name" },
|
|
12400
|
+
{ name: "providerAccountId", type: "string", required: true, description: "Provider account ID" },
|
|
12401
|
+
{ name: "providerEmail", type: "string | null", required: false, description: "Provider email" },
|
|
12402
|
+
{ name: "isPrimary", type: "boolean", required: true, description: "Whether this is primary account" },
|
|
12403
|
+
{ name: "isVerified", type: "boolean", required: true, description: "Whether account is verified" },
|
|
12404
|
+
{ name: "createdAt", type: "string", required: true, description: "Link creation time" }
|
|
12405
|
+
]
|
|
12406
|
+
},
|
|
12407
|
+
{
|
|
12408
|
+
name: "SecurityEvent",
|
|
12409
|
+
description: "Security event log entry",
|
|
12410
|
+
properties: [
|
|
12411
|
+
{ name: "id", type: "string", required: true, description: "Event ID" },
|
|
12412
|
+
{ name: "eventType", type: "string", required: true, description: "Event type" },
|
|
12413
|
+
{ name: "description", type: "string", required: true, description: "Event description" },
|
|
12414
|
+
{ name: "severity", type: "'low' | 'medium' | 'high'", required: true, description: "Event severity" },
|
|
12415
|
+
{ name: "ipAddress", type: "string", required: false, description: "Source IP address" },
|
|
12416
|
+
{ name: "createdAt", type: "string", required: true, description: "Event timestamp" }
|
|
12417
|
+
]
|
|
12418
|
+
}
|
|
12419
|
+
]
|
|
12420
|
+
},
|
|
12421
|
+
svelte: {
|
|
12422
|
+
importPath: "@classic-homes/auth/svelte",
|
|
12423
|
+
description: "Svelte-specific bindings for authentication. Includes reactive stores and route guards.",
|
|
12424
|
+
modules: {
|
|
12425
|
+
stores: {
|
|
12426
|
+
description: "Reactive Svelte stores for auth state",
|
|
12427
|
+
functions: [
|
|
12428
|
+
{
|
|
12429
|
+
name: "authStore",
|
|
12430
|
+
signature: "Writable<AuthState>",
|
|
12431
|
+
description: "Main auth store containing current auth state",
|
|
12432
|
+
example: "import { authStore } from '@classic-homes/auth/svelte';\n\n// Subscribe to auth state changes\nauthStore.subscribe(state => {\n console.log('Authenticated:', state.isAuthenticated);\n console.log('User:', state.user);\n});\n\n// In Svelte component\n<script>\n import { authStore } from '@classic-homes/auth/svelte';\n</script>\n\n{#if $authStore.isAuthenticated}\n <p>Welcome, {$authStore.user.firstName}!</p>\n{/if}"
|
|
12433
|
+
},
|
|
12434
|
+
{
|
|
12435
|
+
name: "isAuthenticated",
|
|
12436
|
+
signature: "Readable<boolean>",
|
|
12437
|
+
description: "Derived store for authentication status",
|
|
12438
|
+
example: "import { isAuthenticated } from '@classic-homes/auth/svelte';\n\n// In Svelte component\n{#if $isAuthenticated}\n <Dashboard />\n{:else}\n <LoginForm />\n{/if}"
|
|
12439
|
+
},
|
|
12440
|
+
{
|
|
12441
|
+
name: "currentUser",
|
|
12442
|
+
signature: "Readable<User | null>",
|
|
12443
|
+
description: "Derived store for current user"
|
|
12444
|
+
},
|
|
12445
|
+
{
|
|
12446
|
+
name: "authActions",
|
|
12447
|
+
signature: "{ login, logout, refreshToken, updateUser, clearAuth }",
|
|
12448
|
+
description: "Auth action functions that update the store",
|
|
12449
|
+
example: "import { authActions } from '@classic-homes/auth/svelte';\n\nasync function handleLogin(credentials) {\n const response = await authActions.login(credentials);\n if (response.requiresMFA) {\n // Handle MFA\n }\n}\n\nfunction handleLogout() {\n await authActions.logout();\n}"
|
|
12450
|
+
}
|
|
12451
|
+
]
|
|
12452
|
+
},
|
|
12453
|
+
guards: {
|
|
12454
|
+
description: "SvelteKit route guards for protected pages",
|
|
12455
|
+
functions: [
|
|
12456
|
+
{
|
|
12457
|
+
name: "checkAuth",
|
|
12458
|
+
signature: "(fetch: typeof fetch) => Promise<AuthGuardResult>",
|
|
12459
|
+
description: "Check authentication status",
|
|
12460
|
+
example: "import { checkAuth } from '@classic-homes/auth/svelte';\n\nexport const load = async ({ fetch }) => {\n const auth = await checkAuth(fetch);\n return { user: auth.user };\n};"
|
|
12461
|
+
},
|
|
12462
|
+
{
|
|
12463
|
+
name: "requireAuth",
|
|
12464
|
+
signature: "(options?: AuthGuardOptions) => (event: LoadEvent) => Promise<AuthGuardResult>",
|
|
12465
|
+
description: "Guard that requires authentication",
|
|
12466
|
+
example: "import { requireAuth } from '@classic-homes/auth/svelte';\n\nexport const load = requireAuth({\n redirectTo: '/login'\n});"
|
|
12467
|
+
},
|
|
12468
|
+
{
|
|
12469
|
+
name: "requireRole",
|
|
12470
|
+
signature: "(roles: string | string[], options?: AuthGuardOptions) => (event: LoadEvent) => Promise<AuthGuardResult>",
|
|
12471
|
+
description: "Guard that requires specific role(s)",
|
|
12472
|
+
example: "import { requireRole } from '@classic-homes/auth/svelte';\n\n// Single role\nexport const load = requireRole('admin');\n\n// Multiple roles (any match)\nexport const load = requireRole(['admin', 'manager']);"
|
|
12473
|
+
},
|
|
12474
|
+
{
|
|
12475
|
+
name: "requirePermission",
|
|
12476
|
+
signature: "(permissions: string | string[], options?: AuthGuardOptions) => (event: LoadEvent) => Promise<AuthGuardResult>",
|
|
12477
|
+
description: "Guard that requires specific permission(s)",
|
|
12478
|
+
example: "import { requirePermission } from '@classic-homes/auth/svelte';\n\nexport const load = requirePermission('users:write');"
|
|
12479
|
+
},
|
|
12480
|
+
{
|
|
12481
|
+
name: "protectedLoad",
|
|
12482
|
+
signature: "<T>(loadFn: (event: LoadEvent, auth: AuthGuardResult) => Promise<T>, options?: AuthGuardOptions) => (event: LoadEvent) => Promise<T>",
|
|
12483
|
+
description: "Wrapper for load functions that require auth",
|
|
12484
|
+
example: "import { protectedLoad } from '@classic-homes/auth/svelte';\n\nexport const load = protectedLoad(async (event, auth) => {\n // Auth is guaranteed to be valid here\n const data = await fetchUserData(event.fetch, auth.user.id);\n return { user: auth.user, data };\n});"
|
|
12485
|
+
},
|
|
12486
|
+
{
|
|
12487
|
+
name: "createAuthGuard",
|
|
12488
|
+
signature: "(checkFn: (auth: AuthGuardResult) => boolean, options?: AuthGuardOptions) => (event: LoadEvent) => Promise<AuthGuardResult>",
|
|
12489
|
+
description: "Create a custom auth guard with your own check function"
|
|
12490
|
+
}
|
|
12491
|
+
],
|
|
12492
|
+
types: [
|
|
12493
|
+
{
|
|
12494
|
+
name: "AuthGuardOptions",
|
|
12495
|
+
description: "Options for auth guards",
|
|
12496
|
+
properties: [
|
|
12497
|
+
{ name: "redirectTo", type: "string", required: false, description: "URL to redirect to if auth fails (default: '/login')" },
|
|
12498
|
+
{ name: "returnTo", type: "boolean", required: false, description: "Whether to include return URL in redirect" }
|
|
12499
|
+
]
|
|
12500
|
+
},
|
|
12501
|
+
{
|
|
12502
|
+
name: "AuthGuardResult",
|
|
12503
|
+
description: "Result from auth guard check",
|
|
12504
|
+
properties: [
|
|
12505
|
+
{ name: "authenticated", type: "boolean", required: true, description: "Whether user is authenticated" },
|
|
12506
|
+
{ name: "user", type: "User | null", required: true, description: "Current user if authenticated" }
|
|
12507
|
+
]
|
|
12508
|
+
}
|
|
12509
|
+
]
|
|
12510
|
+
}
|
|
12511
|
+
}
|
|
12512
|
+
},
|
|
12513
|
+
testing: {
|
|
12514
|
+
importPath: "@classic-homes/auth/testing",
|
|
12515
|
+
description: "Test utilities for the auth package. Provides mocks, fixtures, and helpers for testing authentication flows.",
|
|
12516
|
+
modules: {
|
|
12517
|
+
fixtures: {
|
|
12518
|
+
description: "Pre-built test fixtures for users, tokens, and responses",
|
|
12519
|
+
functions: [
|
|
12520
|
+
{
|
|
12521
|
+
name: "mockUser",
|
|
12522
|
+
signature: "User",
|
|
12523
|
+
description: "Standard test user fixture"
|
|
12524
|
+
},
|
|
12525
|
+
{
|
|
12526
|
+
name: "mockAdminUser",
|
|
12527
|
+
signature: "User",
|
|
12528
|
+
description: "Admin user fixture with elevated permissions"
|
|
12529
|
+
},
|
|
12530
|
+
{
|
|
12531
|
+
name: "mockSSOUser",
|
|
12532
|
+
signature: "User",
|
|
12533
|
+
description: "SSO-authenticated user fixture"
|
|
12534
|
+
},
|
|
12535
|
+
{
|
|
12536
|
+
name: "mockMFAUser",
|
|
12537
|
+
signature: "User",
|
|
12538
|
+
description: "User with MFA enabled"
|
|
12539
|
+
},
|
|
12540
|
+
{
|
|
12541
|
+
name: "mockUnverifiedUser",
|
|
12542
|
+
signature: "User",
|
|
12543
|
+
description: "User with unverified email"
|
|
12544
|
+
},
|
|
12545
|
+
{
|
|
12546
|
+
name: "mockInactiveUser",
|
|
12547
|
+
signature: "User",
|
|
12548
|
+
description: "Inactive/disabled user"
|
|
12549
|
+
},
|
|
12550
|
+
{
|
|
12551
|
+
name: "createMockUser",
|
|
12552
|
+
signature: "(overrides?: Partial<User>) => User",
|
|
12553
|
+
description: "Create a custom mock user"
|
|
12554
|
+
},
|
|
12555
|
+
{
|
|
12556
|
+
name: "createMockUserWithRoles",
|
|
12557
|
+
signature: "(roles: string[], permissions?: string[]) => User",
|
|
12558
|
+
description: "Create a user with specific roles"
|
|
12559
|
+
},
|
|
12560
|
+
{
|
|
12561
|
+
name: "mockAccessToken",
|
|
12562
|
+
signature: "string",
|
|
12563
|
+
description: "Valid mock access token"
|
|
12564
|
+
},
|
|
12565
|
+
{
|
|
12566
|
+
name: "mockRefreshToken",
|
|
12567
|
+
signature: "string",
|
|
12568
|
+
description: "Valid mock refresh token"
|
|
12569
|
+
},
|
|
12570
|
+
{
|
|
12571
|
+
name: "mockExpiredToken",
|
|
12572
|
+
signature: "string",
|
|
12573
|
+
description: "Expired token for testing"
|
|
12574
|
+
},
|
|
12575
|
+
{
|
|
12576
|
+
name: "mockMFAToken",
|
|
12577
|
+
signature: "string",
|
|
12578
|
+
description: "MFA challenge token"
|
|
12579
|
+
},
|
|
12580
|
+
{
|
|
12581
|
+
name: "createMockJWT",
|
|
12582
|
+
signature: "(payload?: JWTPayloadOptions) => string",
|
|
12583
|
+
description: "Create a custom mock JWT"
|
|
12584
|
+
},
|
|
12585
|
+
{
|
|
12586
|
+
name: "mockLoginSuccess",
|
|
12587
|
+
signature: "LoginResponse",
|
|
12588
|
+
description: "Successful login response"
|
|
12589
|
+
},
|
|
12590
|
+
{
|
|
12591
|
+
name: "mockMFARequired",
|
|
12592
|
+
signature: "LoginResponse",
|
|
12593
|
+
description: "Login response requiring MFA"
|
|
12594
|
+
},
|
|
12595
|
+
{
|
|
12596
|
+
name: "mockMFASetup",
|
|
12597
|
+
signature: "MFASetupResponse",
|
|
12598
|
+
description: "MFA setup response with QR code"
|
|
12599
|
+
},
|
|
12600
|
+
{
|
|
12601
|
+
name: "mockSessions",
|
|
12602
|
+
signature: "Session[]",
|
|
12603
|
+
description: "Array of mock sessions"
|
|
12604
|
+
},
|
|
12605
|
+
{
|
|
12606
|
+
name: "mockDevices",
|
|
12607
|
+
signature: "Device[]",
|
|
12608
|
+
description: "Array of mock devices"
|
|
12609
|
+
},
|
|
12610
|
+
{
|
|
12611
|
+
name: "mockApiKeys",
|
|
12612
|
+
signature: "ApiKey[]",
|
|
12613
|
+
description: "Array of mock API keys"
|
|
12614
|
+
},
|
|
12615
|
+
{
|
|
12616
|
+
name: "mockSecurityEvents",
|
|
12617
|
+
signature: "SecurityEvent[]",
|
|
12618
|
+
description: "Array of mock security events"
|
|
12619
|
+
},
|
|
12620
|
+
{
|
|
12621
|
+
name: "mockUserPreferences",
|
|
12622
|
+
signature: "UserPreferences",
|
|
12623
|
+
description: "Mock user preferences"
|
|
12624
|
+
}
|
|
12625
|
+
]
|
|
12626
|
+
},
|
|
12627
|
+
mocks: {
|
|
12628
|
+
description: "Mock implementations for testing",
|
|
12629
|
+
functions: [
|
|
12630
|
+
{
|
|
12631
|
+
name: "MockStorageAdapter",
|
|
12632
|
+
signature: "class",
|
|
12633
|
+
description: "Mock storage adapter with call tracking",
|
|
12634
|
+
example: "import { MockStorageAdapter, createMockStorage } from '@classic-homes/auth/testing';\n\nconst storage = createMockStorage();\n\n// Use in auth init\ninitAuth({ baseUrl: 'https://api.test', storage });\n\n// Assert calls\nexpect(storage.getCalls('setItem')).toHaveLength(2);"
|
|
12635
|
+
},
|
|
12636
|
+
{
|
|
12637
|
+
name: "createMockStorage",
|
|
12638
|
+
signature: "(options?: MockStorageOptions) => MockStorageAdapter",
|
|
12639
|
+
description: "Create a mock storage adapter"
|
|
12640
|
+
},
|
|
12641
|
+
{
|
|
12642
|
+
name: "createMockStorageWithAuth",
|
|
12643
|
+
signature: "(tokens?: { accessToken?: string; refreshToken?: string }) => MockStorageAdapter",
|
|
12644
|
+
description: "Create storage pre-populated with auth tokens"
|
|
12645
|
+
},
|
|
12646
|
+
{
|
|
12647
|
+
name: "MockFetchInstance",
|
|
12648
|
+
signature: "class",
|
|
12649
|
+
description: "Mock fetch implementation with route handling",
|
|
12650
|
+
example: "import { createMockFetch, mockLoginSuccess } from '@classic-homes/auth/testing';\n\nconst mockFetch = createMockFetch();\nmockFetch.addRoute('POST', '/auth/login', { data: mockLoginSuccess });\n\n// Use in auth init\ninitAuth({ baseUrl: 'https://api.test', fetch: mockFetch.fetch });\n\n// Assert calls\nmockFetch.assertCalled('/auth/login');\nmockFetch.assertCalledWith('/auth/login', { body: { username: 'test' } });"
|
|
12651
|
+
},
|
|
12652
|
+
{
|
|
12653
|
+
name: "createMockFetch",
|
|
12654
|
+
signature: "(options?: MockFetchOptions) => MockFetchInstance",
|
|
12655
|
+
description: "Create a mock fetch instance"
|
|
12656
|
+
},
|
|
12657
|
+
{
|
|
12658
|
+
name: "createMockFetchWithRoutes",
|
|
12659
|
+
signature: "(routes: MockRoute[]) => MockFetchInstance",
|
|
12660
|
+
description: "Create mock fetch with pre-configured routes"
|
|
12661
|
+
},
|
|
12662
|
+
{
|
|
12663
|
+
name: "MockAuthStore",
|
|
12664
|
+
signature: "class",
|
|
12665
|
+
description: "Mock auth store for Svelte testing"
|
|
12666
|
+
},
|
|
12667
|
+
{
|
|
12668
|
+
name: "createMockAuthStore",
|
|
12669
|
+
signature: "(options?: MockAuthStoreOptions) => MockAuthStore",
|
|
12670
|
+
description: "Create a mock auth store"
|
|
12671
|
+
},
|
|
12672
|
+
{
|
|
12673
|
+
name: "createAuthenticatedMockStore",
|
|
12674
|
+
signature: "(user?: User) => MockAuthStore",
|
|
12675
|
+
description: "Create a mock store in authenticated state"
|
|
12676
|
+
}
|
|
12677
|
+
]
|
|
12678
|
+
},
|
|
12679
|
+
helpers: {
|
|
12680
|
+
description: "Test setup and assertion helpers",
|
|
12681
|
+
functions: [
|
|
12682
|
+
{
|
|
12683
|
+
name: "setupTestAuth",
|
|
12684
|
+
signature: "(options?: SetupTestAuthOptions) => TestAuthContext",
|
|
12685
|
+
description: "Complete test setup with all mocks configured",
|
|
12686
|
+
example: "import { describe, it, beforeEach, afterEach } from 'vitest';\nimport { setupTestAuth, mockUser, assertAuthenticated } from '@classic-homes/auth/testing';\nimport { authService } from '@classic-homes/auth/core';\n\ndescribe('Auth', () => {\n let ctx: TestAuthContext;\n\n beforeEach(() => {\n ctx = setupTestAuth();\n });\n\n afterEach(() => ctx.cleanup());\n\n it('handles login', async () => {\n const response = await authService.login({\n username: 'test@example.com',\n password: 'password'\n });\n\n assertAuthenticated(ctx.mockStore);\n ctx.mockFetch.assertCalled('/auth/login');\n });\n});"
|
|
12687
|
+
},
|
|
12688
|
+
{
|
|
12689
|
+
name: "quickSetupAuth",
|
|
12690
|
+
signature: "() => { cleanup: () => void }",
|
|
12691
|
+
description: "Minimal setup for quick tests"
|
|
12692
|
+
},
|
|
12693
|
+
{
|
|
12694
|
+
name: "withTestAuth",
|
|
12695
|
+
signature: "(testFn: (ctx: TestAuthContext) => Promise<void>) => () => Promise<void>",
|
|
12696
|
+
description: "Wrapper that handles setup and cleanup"
|
|
12697
|
+
},
|
|
12698
|
+
{
|
|
12699
|
+
name: "authScenarios",
|
|
12700
|
+
signature: "{ authenticated, unauthenticated, mfaRequired, tokenExpired, ... }",
|
|
12701
|
+
description: "Pre-configured test scenarios"
|
|
12702
|
+
},
|
|
12703
|
+
{
|
|
12704
|
+
name: "applyScenario",
|
|
12705
|
+
signature: "(ctx: TestAuthContext, scenario: AuthScenario) => void",
|
|
12706
|
+
description: "Apply a test scenario to the context"
|
|
12707
|
+
},
|
|
12708
|
+
{
|
|
12709
|
+
name: "configureMFAFlow",
|
|
12710
|
+
signature: "(mockFetch: MockFetchInstance) => void",
|
|
12711
|
+
description: "Configure mock fetch for MFA flow testing"
|
|
12712
|
+
},
|
|
12713
|
+
{
|
|
12714
|
+
name: "configureTokenRefresh",
|
|
12715
|
+
signature: "(mockFetch: MockFetchInstance) => void",
|
|
12716
|
+
description: "Configure mock fetch for token refresh testing"
|
|
12717
|
+
},
|
|
12718
|
+
{
|
|
12719
|
+
name: "configureSSOLogout",
|
|
12720
|
+
signature: "(mockFetch: MockFetchInstance) => void",
|
|
12721
|
+
description: "Configure mock fetch for SSO logout flow"
|
|
12722
|
+
},
|
|
12723
|
+
{
|
|
12724
|
+
name: "assertAuthenticated",
|
|
12725
|
+
signature: "(store: MockAuthStore) => void",
|
|
12726
|
+
description: "Assert that store is in authenticated state"
|
|
12727
|
+
},
|
|
12728
|
+
{
|
|
12729
|
+
name: "assertUnauthenticated",
|
|
12730
|
+
signature: "(store: MockAuthStore) => void",
|
|
12731
|
+
description: "Assert that store is in unauthenticated state"
|
|
12732
|
+
},
|
|
12733
|
+
{
|
|
12734
|
+
name: "assertHasPermissions",
|
|
12735
|
+
signature: "(store: MockAuthStore, permissions: string[]) => void",
|
|
12736
|
+
description: "Assert user has specific permissions"
|
|
12737
|
+
},
|
|
12738
|
+
{
|
|
12739
|
+
name: "assertHasRoles",
|
|
12740
|
+
signature: "(store: MockAuthStore, roles: string[]) => void",
|
|
12741
|
+
description: "Assert user has specific roles"
|
|
12742
|
+
},
|
|
12743
|
+
{
|
|
12744
|
+
name: "assertTokenValid",
|
|
12745
|
+
signature: "(token: string) => void",
|
|
12746
|
+
description: "Assert token is valid and not expired"
|
|
12747
|
+
},
|
|
12748
|
+
{
|
|
12749
|
+
name: "assertTokenExpired",
|
|
12750
|
+
signature: "(token: string) => void",
|
|
12751
|
+
description: "Assert token is expired"
|
|
12752
|
+
},
|
|
12753
|
+
{
|
|
12754
|
+
name: "assertRequiresMFA",
|
|
12755
|
+
signature: "(response: LoginResponse) => void",
|
|
12756
|
+
description: "Assert login response requires MFA"
|
|
12757
|
+
},
|
|
12758
|
+
{
|
|
12759
|
+
name: "assertApiCalled",
|
|
12760
|
+
signature: "(mockFetch: MockFetchInstance, endpoint: string, options?: AssertApiCalledOptions) => void",
|
|
12761
|
+
description: "Assert API endpoint was called"
|
|
12762
|
+
}
|
|
12763
|
+
],
|
|
12764
|
+
types: [
|
|
12765
|
+
{
|
|
12766
|
+
name: "TestAuthContext",
|
|
12767
|
+
description: "Context returned from setupTestAuth",
|
|
12768
|
+
properties: [
|
|
12769
|
+
{ name: "mockFetch", type: "MockFetchInstance", required: true, description: "Mock fetch instance" },
|
|
12770
|
+
{ name: "mockStorage", type: "MockStorageAdapter", required: true, description: "Mock storage adapter" },
|
|
12771
|
+
{ name: "mockStore", type: "MockAuthStore", required: true, description: "Mock auth store" },
|
|
12772
|
+
{ name: "cleanup", type: "() => void", required: true, description: "Cleanup function" }
|
|
12773
|
+
]
|
|
12774
|
+
},
|
|
12775
|
+
{
|
|
12776
|
+
name: "SetupTestAuthOptions",
|
|
12777
|
+
description: "Options for setupTestAuth",
|
|
12778
|
+
properties: [
|
|
12779
|
+
{ name: "authenticated", type: "boolean", required: false, description: "Start in authenticated state" },
|
|
12780
|
+
{ name: "user", type: "User", required: false, description: "User for authenticated state" },
|
|
12781
|
+
{ name: "tokens", type: "object", required: false, description: "Tokens for authenticated state" }
|
|
12782
|
+
]
|
|
12783
|
+
}
|
|
12784
|
+
]
|
|
12785
|
+
}
|
|
12786
|
+
}
|
|
12787
|
+
}
|
|
12788
|
+
}
|
|
12789
|
+
};
|
|
12790
|
+
|
|
12791
|
+
// src/resources/auth.ts
|
|
12792
|
+
var catalog2 = auth_catalog_default;
|
|
12793
|
+
function registerAuthResources(server) {
|
|
12794
|
+
server.resource("Auth Package", "auth://all", async (uri) => ({
|
|
12795
|
+
contents: [
|
|
12796
|
+
{
|
|
12797
|
+
uri: uri.href,
|
|
12798
|
+
mimeType: "application/json",
|
|
12799
|
+
text: JSON.stringify(catalog2, null, 2)
|
|
11096
12800
|
}
|
|
11097
12801
|
]
|
|
11098
12802
|
}));
|
|
11099
|
-
server.resource("
|
|
12803
|
+
server.resource("Auth Core", "auth://core", async (uri) => ({
|
|
11100
12804
|
contents: [
|
|
11101
12805
|
{
|
|
11102
12806
|
uri: uri.href,
|
|
11103
12807
|
mimeType: "application/json",
|
|
11104
|
-
text: JSON.stringify(
|
|
12808
|
+
text: JSON.stringify(
|
|
12809
|
+
{
|
|
12810
|
+
importPath: catalog2.subpackages.core.importPath,
|
|
12811
|
+
description: catalog2.subpackages.core.description,
|
|
12812
|
+
modules: catalog2.subpackages.core.modules,
|
|
12813
|
+
types: catalog2.subpackages.core.types
|
|
12814
|
+
},
|
|
12815
|
+
null,
|
|
12816
|
+
2
|
|
12817
|
+
)
|
|
11105
12818
|
}
|
|
11106
12819
|
]
|
|
11107
12820
|
}));
|
|
11108
|
-
server.resource("
|
|
12821
|
+
server.resource("Auth Svelte", "auth://svelte", async (uri) => ({
|
|
11109
12822
|
contents: [
|
|
11110
12823
|
{
|
|
11111
12824
|
uri: uri.href,
|
|
11112
12825
|
mimeType: "application/json",
|
|
11113
|
-
text: JSON.stringify(
|
|
12826
|
+
text: JSON.stringify(
|
|
12827
|
+
{
|
|
12828
|
+
importPath: catalog2.subpackages.svelte.importPath,
|
|
12829
|
+
description: catalog2.subpackages.svelte.description,
|
|
12830
|
+
modules: catalog2.subpackages.svelte.modules
|
|
12831
|
+
},
|
|
12832
|
+
null,
|
|
12833
|
+
2
|
|
12834
|
+
)
|
|
12835
|
+
}
|
|
12836
|
+
]
|
|
12837
|
+
}));
|
|
12838
|
+
server.resource("Auth Testing", "auth://testing", async (uri) => ({
|
|
12839
|
+
contents: [
|
|
12840
|
+
{
|
|
12841
|
+
uri: uri.href,
|
|
12842
|
+
mimeType: "application/json",
|
|
12843
|
+
text: JSON.stringify(
|
|
12844
|
+
{
|
|
12845
|
+
importPath: catalog2.subpackages.testing.importPath,
|
|
12846
|
+
description: catalog2.subpackages.testing.description,
|
|
12847
|
+
modules: catalog2.subpackages.testing.modules
|
|
12848
|
+
},
|
|
12849
|
+
null,
|
|
12850
|
+
2
|
|
12851
|
+
)
|
|
12852
|
+
}
|
|
12853
|
+
]
|
|
12854
|
+
}));
|
|
12855
|
+
server.resource("Auth Types", "auth://types", async (uri) => ({
|
|
12856
|
+
contents: [
|
|
12857
|
+
{
|
|
12858
|
+
uri: uri.href,
|
|
12859
|
+
mimeType: "application/json",
|
|
12860
|
+
text: JSON.stringify(
|
|
12861
|
+
{
|
|
12862
|
+
description: "TypeScript types exported from @classic-homes/auth/core",
|
|
12863
|
+
types: catalog2.subpackages.core.types
|
|
12864
|
+
},
|
|
12865
|
+
null,
|
|
12866
|
+
2
|
|
12867
|
+
)
|
|
12868
|
+
}
|
|
12869
|
+
]
|
|
12870
|
+
}));
|
|
12871
|
+
server.resource("Auth API", "auth://api", async (uri) => ({
|
|
12872
|
+
contents: [
|
|
12873
|
+
{
|
|
12874
|
+
uri: uri.href,
|
|
12875
|
+
mimeType: "application/json",
|
|
12876
|
+
text: JSON.stringify(
|
|
12877
|
+
{
|
|
12878
|
+
description: "Auth API client methods from @classic-homes/auth/core",
|
|
12879
|
+
api: catalog2.subpackages.core.modules.api
|
|
12880
|
+
},
|
|
12881
|
+
null,
|
|
12882
|
+
2
|
|
12883
|
+
)
|
|
11114
12884
|
}
|
|
11115
12885
|
]
|
|
11116
12886
|
}));
|
|
11117
12887
|
server.resource(
|
|
11118
|
-
"
|
|
11119
|
-
new
|
|
12888
|
+
"Auth Module",
|
|
12889
|
+
new ResourceTemplate3("auth://core/{module}", { list: void 0 }),
|
|
11120
12890
|
async (uri, params) => {
|
|
11121
|
-
const
|
|
11122
|
-
const
|
|
11123
|
-
const
|
|
11124
|
-
|
|
11125
|
-
|
|
12891
|
+
const moduleName = params.module;
|
|
12892
|
+
const modules = catalog2.subpackages.core.modules;
|
|
12893
|
+
const module = modules[moduleName];
|
|
12894
|
+
if (!module) {
|
|
12895
|
+
const availableModules = Object.keys(modules);
|
|
11126
12896
|
return {
|
|
11127
12897
|
contents: [
|
|
11128
12898
|
{
|
|
11129
12899
|
uri: uri.href,
|
|
11130
12900
|
mimeType: "application/json",
|
|
11131
|
-
text: JSON.stringify({
|
|
12901
|
+
text: JSON.stringify({
|
|
12902
|
+
error: `Module "${moduleName}" not found`,
|
|
12903
|
+
availableModules
|
|
12904
|
+
})
|
|
11132
12905
|
}
|
|
11133
12906
|
]
|
|
11134
12907
|
};
|
|
@@ -11138,193 +12911,44 @@ function registerLayoutResources(server) {
|
|
|
11138
12911
|
{
|
|
11139
12912
|
uri: uri.href,
|
|
11140
12913
|
mimeType: "application/json",
|
|
11141
|
-
text: JSON.stringify(
|
|
12914
|
+
text: JSON.stringify(module, null, 2)
|
|
11142
12915
|
}
|
|
11143
12916
|
]
|
|
11144
12917
|
};
|
|
11145
12918
|
}
|
|
11146
12919
|
);
|
|
11147
|
-
|
|
11148
|
-
|
|
11149
|
-
// src/data/schema-catalog.json
|
|
11150
|
-
var schema_catalog_default = {
|
|
11151
|
-
auth: [
|
|
11152
|
-
{
|
|
11153
|
-
name: "emailSchema",
|
|
11154
|
-
description: "Email validation",
|
|
11155
|
-
importPath: "@classic-homes/theme-svelte"
|
|
11156
|
-
},
|
|
11157
|
-
{
|
|
11158
|
-
name: "passwordSchema",
|
|
11159
|
-
description: "Strong password (8+ chars, mixed case, numbers, special)",
|
|
11160
|
-
importPath: "@classic-homes/theme-svelte"
|
|
11161
|
-
},
|
|
11162
|
-
{
|
|
11163
|
-
name: "loginPasswordSchema",
|
|
11164
|
-
description: "Simpler password validation for login",
|
|
11165
|
-
importPath: "@classic-homes/theme-svelte"
|
|
11166
|
-
},
|
|
11167
|
-
{
|
|
11168
|
-
name: "usernameSchema",
|
|
11169
|
-
description: "Username validation (3-30 chars, alphanumeric)",
|
|
11170
|
-
importPath: "@classic-homes/theme-svelte"
|
|
11171
|
-
},
|
|
11172
|
-
{
|
|
11173
|
-
name: "fullNameSchema",
|
|
11174
|
-
description: "Full name validation",
|
|
11175
|
-
importPath: "@classic-homes/theme-svelte"
|
|
11176
|
-
},
|
|
11177
|
-
{
|
|
11178
|
-
name: "phoneSchema",
|
|
11179
|
-
description: "Phone number validation",
|
|
11180
|
-
importPath: "@classic-homes/theme-svelte"
|
|
11181
|
-
},
|
|
11182
|
-
{
|
|
11183
|
-
name: "mfaCodeSchema",
|
|
11184
|
-
description: "MFA code validation (6 digits)",
|
|
11185
|
-
importPath: "@classic-homes/theme-svelte"
|
|
11186
|
-
},
|
|
11187
|
-
{
|
|
11188
|
-
name: "loginSchema",
|
|
11189
|
-
description: "Complete login form schema",
|
|
11190
|
-
importPath: "@classic-homes/theme-svelte"
|
|
11191
|
-
},
|
|
11192
|
-
{
|
|
11193
|
-
name: "registerSchema",
|
|
11194
|
-
description: "Complete registration form schema",
|
|
11195
|
-
importPath: "@classic-homes/theme-svelte"
|
|
11196
|
-
},
|
|
11197
|
-
{
|
|
11198
|
-
name: "forgotPasswordSchema",
|
|
11199
|
-
description: "Forgot password form schema",
|
|
11200
|
-
importPath: "@classic-homes/theme-svelte"
|
|
11201
|
-
},
|
|
11202
|
-
{
|
|
11203
|
-
name: "resetPasswordSchema",
|
|
11204
|
-
description: "Reset password form schema",
|
|
11205
|
-
importPath: "@classic-homes/theme-svelte"
|
|
11206
|
-
},
|
|
11207
|
-
{
|
|
11208
|
-
name: "changePasswordSchema",
|
|
11209
|
-
description: "Change password form schema",
|
|
11210
|
-
importPath: "@classic-homes/theme-svelte"
|
|
11211
|
-
}
|
|
11212
|
-
],
|
|
11213
|
-
common: [
|
|
11214
|
-
{
|
|
11215
|
-
name: "nonEmptyString",
|
|
11216
|
-
description: "Non-empty string validation",
|
|
11217
|
-
importPath: "@classic-homes/theme-svelte"
|
|
11218
|
-
},
|
|
11219
|
-
{
|
|
11220
|
-
name: "trimmedString",
|
|
11221
|
-
description: "Trimmed string",
|
|
11222
|
-
importPath: "@classic-homes/theme-svelte"
|
|
11223
|
-
},
|
|
11224
|
-
{
|
|
11225
|
-
name: "urlSchema",
|
|
11226
|
-
description: "URL validation",
|
|
11227
|
-
importPath: "@classic-homes/theme-svelte"
|
|
11228
|
-
},
|
|
11229
|
-
{
|
|
11230
|
-
name: "slugSchema",
|
|
11231
|
-
description: "URL slug validation",
|
|
11232
|
-
importPath: "@classic-homes/theme-svelte"
|
|
11233
|
-
},
|
|
11234
|
-
{
|
|
11235
|
-
name: "positiveInt",
|
|
11236
|
-
description: "Positive integer validation",
|
|
11237
|
-
importPath: "@classic-homes/theme-svelte"
|
|
11238
|
-
},
|
|
11239
|
-
{
|
|
11240
|
-
name: "nonNegativeInt",
|
|
11241
|
-
description: "Non-negative integer",
|
|
11242
|
-
importPath: "@classic-homes/theme-svelte"
|
|
11243
|
-
},
|
|
11244
|
-
{
|
|
11245
|
-
name: "percentageSchema",
|
|
11246
|
-
description: "Percentage (0-100)",
|
|
11247
|
-
importPath: "@classic-homes/theme-svelte"
|
|
11248
|
-
},
|
|
11249
|
-
{
|
|
11250
|
-
name: "priceSchema",
|
|
11251
|
-
description: "Price validation",
|
|
11252
|
-
importPath: "@classic-homes/theme-svelte"
|
|
11253
|
-
},
|
|
11254
|
-
{
|
|
11255
|
-
name: "isoDateSchema",
|
|
11256
|
-
description: "ISO date string validation",
|
|
11257
|
-
importPath: "@classic-homes/theme-svelte"
|
|
11258
|
-
},
|
|
11259
|
-
{
|
|
11260
|
-
name: "futureDateSchema",
|
|
11261
|
-
description: "Future date validation",
|
|
11262
|
-
importPath: "@classic-homes/theme-svelte"
|
|
11263
|
-
},
|
|
11264
|
-
{
|
|
11265
|
-
name: "pastDateSchema",
|
|
11266
|
-
description: "Past date validation",
|
|
11267
|
-
importPath: "@classic-homes/theme-svelte"
|
|
11268
|
-
}
|
|
11269
|
-
],
|
|
11270
|
-
file: [
|
|
11271
|
-
{
|
|
11272
|
-
name: "maxFileSize",
|
|
11273
|
-
description: "File size limit validation",
|
|
11274
|
-
importPath: "@classic-homes/theme-svelte"
|
|
11275
|
-
},
|
|
11276
|
-
{
|
|
11277
|
-
name: "allowedFileTypes",
|
|
11278
|
-
description: "File type validation",
|
|
11279
|
-
importPath: "@classic-homes/theme-svelte"
|
|
11280
|
-
},
|
|
11281
|
-
{
|
|
11282
|
-
name: "imageFileSchema",
|
|
11283
|
-
description: "Image file validation",
|
|
11284
|
-
importPath: "@classic-homes/theme-svelte"
|
|
11285
|
-
}
|
|
11286
|
-
],
|
|
11287
|
-
api: [
|
|
11288
|
-
{
|
|
11289
|
-
name: "apiResponseSchema",
|
|
11290
|
-
description: "Standard API response schema",
|
|
11291
|
-
importPath: "@classic-homes/theme-svelte"
|
|
11292
|
-
},
|
|
11293
|
-
{
|
|
11294
|
-
name: "paginatedResponseSchema",
|
|
11295
|
-
description: "Paginated API response",
|
|
11296
|
-
importPath: "@classic-homes/theme-svelte"
|
|
11297
|
-
}
|
|
11298
|
-
]
|
|
11299
|
-
};
|
|
11300
|
-
|
|
11301
|
-
// src/resources/schemas.ts
|
|
11302
|
-
var schemas = schema_catalog_default;
|
|
11303
|
-
function registerSchemaResources(server) {
|
|
11304
|
-
server.resource("schemas://all", "schemas://all", async (uri) => ({
|
|
11305
|
-
contents: [
|
|
11306
|
-
{
|
|
11307
|
-
uri: uri.href,
|
|
11308
|
-
mimeType: "application/json",
|
|
11309
|
-
text: JSON.stringify(schemas, null, 2)
|
|
11310
|
-
}
|
|
11311
|
-
]
|
|
11312
|
-
}));
|
|
11313
|
-
server.resource("schemas://auth", "schemas://auth", async (uri) => ({
|
|
11314
|
-
contents: [
|
|
11315
|
-
{
|
|
11316
|
-
uri: uri.href,
|
|
11317
|
-
mimeType: "application/json",
|
|
11318
|
-
text: JSON.stringify(schemas.auth, null, 2)
|
|
11319
|
-
}
|
|
11320
|
-
]
|
|
11321
|
-
}));
|
|
11322
|
-
server.resource("schemas://common", "schemas://common", async (uri) => ({
|
|
12920
|
+
server.resource("Auth Quick Reference", "auth://quick-reference", async (uri) => ({
|
|
11323
12921
|
contents: [
|
|
11324
12922
|
{
|
|
11325
12923
|
uri: uri.href,
|
|
11326
12924
|
mimeType: "application/json",
|
|
11327
|
-
text: JSON.stringify(
|
|
12925
|
+
text: JSON.stringify(
|
|
12926
|
+
{
|
|
12927
|
+
description: "Quick reference for common auth operations",
|
|
12928
|
+
initialization: {
|
|
12929
|
+
code: "import { initAuth } from '@classic-homes/auth/core';\n\ninitAuth({ baseUrl: 'https://api.example.com' });",
|
|
12930
|
+
description: "Initialize the auth system with your API base URL"
|
|
12931
|
+
},
|
|
12932
|
+
login: {
|
|
12933
|
+
code: "import { authApi, isMfaChallengeResponse } from '@classic-homes/auth/core';\n\nconst response = await authApi.login({ username: 'user@example.com', password: 'password' });\nif (isMfaChallengeResponse(response)) {\n // Handle MFA\n}",
|
|
12934
|
+
description: "Login with username and password, handling MFA if required"
|
|
12935
|
+
},
|
|
12936
|
+
svelteStore: {
|
|
12937
|
+
code: "import { isAuthenticated, currentUser, authActions } from '@classic-homes/auth/svelte';\n\n// In component\n{#if $isAuthenticated}\n <p>Welcome, {$currentUser.firstName}!</p>\n{/if}",
|
|
12938
|
+
description: "Use reactive Svelte stores for auth state"
|
|
12939
|
+
},
|
|
12940
|
+
routeProtection: {
|
|
12941
|
+
code: "import { requireAuth, requireRole } from '@classic-homes/auth/svelte';\n\n// In +page.ts or +layout.ts\nexport const load = requireAuth();\n// or\nexport const load = requireRole('admin');",
|
|
12942
|
+
description: "Protect SvelteKit routes with auth guards"
|
|
12943
|
+
},
|
|
12944
|
+
testing: {
|
|
12945
|
+
code: "import { setupTestAuth, mockUser, assertAuthenticated } from '@classic-homes/auth/testing';\n\nconst ctx = setupTestAuth();\n// Run tests\nctx.cleanup();",
|
|
12946
|
+
description: "Set up mocks for testing auth flows"
|
|
12947
|
+
}
|
|
12948
|
+
},
|
|
12949
|
+
null,
|
|
12950
|
+
2
|
|
12951
|
+
)
|
|
11328
12952
|
}
|
|
11329
12953
|
]
|
|
11330
12954
|
}));
|
|
@@ -11336,11 +12960,12 @@ function registerResources(server) {
|
|
|
11336
12960
|
registerTokenResources(server);
|
|
11337
12961
|
registerLayoutResources(server);
|
|
11338
12962
|
registerSchemaResources(server);
|
|
12963
|
+
registerAuthResources(server);
|
|
11339
12964
|
}
|
|
11340
12965
|
|
|
11341
12966
|
// src/tools/searchComponents.ts
|
|
11342
12967
|
import { z } from "zod";
|
|
11343
|
-
var
|
|
12968
|
+
var catalog3 = component_catalog_default;
|
|
11344
12969
|
var SearchComponentsSchema = z.object({
|
|
11345
12970
|
query: z.string().describe("Search query (component name, description, or functionality)"),
|
|
11346
12971
|
category: z.enum([
|
|
@@ -11366,7 +12991,7 @@ function registerSearchComponentsTool(server) {
|
|
|
11366
12991
|
const queryLower = query.toLowerCase().trim();
|
|
11367
12992
|
const isListAll = queryLower === "*" || queryLower === "all" || queryLower === "" || queryLower === "list" || queryLower === "list all";
|
|
11368
12993
|
const queryWords = queryLower.split(/\s+/).filter((word) => word.length > 0);
|
|
11369
|
-
const results =
|
|
12994
|
+
const results = catalog3.components.filter((component) => {
|
|
11370
12995
|
if (category && component.category !== category) {
|
|
11371
12996
|
return false;
|
|
11372
12997
|
}
|
|
@@ -11433,7 +13058,7 @@ function registerSearchComponentsTool(server) {
|
|
|
11433
13058
|
|
|
11434
13059
|
// src/tools/getComponentProps.ts
|
|
11435
13060
|
import { z as z2 } from "zod";
|
|
11436
|
-
var
|
|
13061
|
+
var catalog4 = component_catalog_default;
|
|
11437
13062
|
var GetComponentPropsSchema = z2.object({
|
|
11438
13063
|
componentName: z2.string().describe('Name of the component (e.g., "Button", "DashboardLayout")'),
|
|
11439
13064
|
includeExamples: z2.boolean().default(true).describe("Whether to include usage examples")
|
|
@@ -11445,11 +13070,11 @@ function registerGetComponentPropsTool(server) {
|
|
|
11445
13070
|
GetComponentPropsSchema.shape,
|
|
11446
13071
|
async (params) => {
|
|
11447
13072
|
const { componentName, includeExamples } = GetComponentPropsSchema.parse(params);
|
|
11448
|
-
const component =
|
|
13073
|
+
const component = catalog4.components.find(
|
|
11449
13074
|
(c) => c.name.toLowerCase() === componentName.toLowerCase()
|
|
11450
13075
|
);
|
|
11451
13076
|
if (!component) {
|
|
11452
|
-
const suggestions =
|
|
13077
|
+
const suggestions = catalog4.components.filter((c) => c.name.toLowerCase().includes(componentName.toLowerCase().slice(0, 3))).slice(0, 5).map((c) => c.name);
|
|
11453
13078
|
return {
|
|
11454
13079
|
content: [
|
|
11455
13080
|
{
|
|
@@ -11508,7 +13133,19 @@ var SuggestPatternSchema = z3.object({
|
|
|
11508
13133
|
// Form patterns
|
|
11509
13134
|
"login-form",
|
|
11510
13135
|
"registration-form",
|
|
11511
|
-
"contact-form"
|
|
13136
|
+
"contact-form",
|
|
13137
|
+
// MFA and password form patterns
|
|
13138
|
+
"mfa-verification-form",
|
|
13139
|
+
"mfa-setup-form",
|
|
13140
|
+
"profile-update-form",
|
|
13141
|
+
"change-password-form",
|
|
13142
|
+
"forgot-password-form",
|
|
13143
|
+
"reset-password-form",
|
|
13144
|
+
// Auth flow patterns
|
|
13145
|
+
"login-with-mfa",
|
|
13146
|
+
"sso-login",
|
|
13147
|
+
"session-management",
|
|
13148
|
+
"protected-route"
|
|
11512
13149
|
]).describe("The use case you need a pattern for"),
|
|
11513
13150
|
requirements: z3.array(z3.string()).optional().describe("Additional requirements or constraints")
|
|
11514
13151
|
});
|
|
@@ -11521,11 +13158,13 @@ function registerSuggestPatternTool(server) {
|
|
|
11521
13158
|
const { useCase, requirements } = SuggestPatternSchema.parse(params);
|
|
11522
13159
|
const layout = patterns2.layouts.find((l) => l.id === useCase || l.useCase === useCase);
|
|
11523
13160
|
const form = patterns2.forms.find((f) => f.id === useCase);
|
|
11524
|
-
const
|
|
13161
|
+
const auth = patterns2.auth?.find((a) => a.id === useCase);
|
|
13162
|
+
const pattern = layout || form || auth;
|
|
11525
13163
|
if (!pattern) {
|
|
11526
13164
|
const availablePatterns = [
|
|
11527
13165
|
...patterns2.layouts.map((l) => ({ id: l.id, type: "layout", name: l.name })),
|
|
11528
|
-
...patterns2.forms.map((f) => ({ id: f.id, type: "form", name: f.name }))
|
|
13166
|
+
...patterns2.forms.map((f) => ({ id: f.id, type: "form", name: f.name })),
|
|
13167
|
+
...patterns2.auth?.map((a) => ({ id: a.id, type: "auth", name: a.name })) || []
|
|
11529
13168
|
];
|
|
11530
13169
|
return {
|
|
11531
13170
|
content: [
|
|
@@ -11571,7 +13210,7 @@ function registerSuggestPatternTool(server) {
|
|
|
11571
13210
|
|
|
11572
13211
|
// src/tools/validateUsage.ts
|
|
11573
13212
|
import { z as z4 } from "zod";
|
|
11574
|
-
var
|
|
13213
|
+
var catalog5 = component_catalog_default;
|
|
11575
13214
|
var ValidateUsageSchema = z4.object({
|
|
11576
13215
|
componentName: z4.string().describe("Name of the component being used"),
|
|
11577
13216
|
props: z4.record(z4.unknown()).describe("Props being passed to the component"),
|
|
@@ -11584,7 +13223,7 @@ function registerValidateUsageTool(server) {
|
|
|
11584
13223
|
ValidateUsageSchema.shape,
|
|
11585
13224
|
async (params) => {
|
|
11586
13225
|
const { componentName, props, context } = ValidateUsageSchema.parse(params);
|
|
11587
|
-
const component =
|
|
13226
|
+
const component = catalog5.components.find(
|
|
11588
13227
|
(c) => c.name.toLowerCase() === componentName.toLowerCase()
|
|
11589
13228
|
);
|
|
11590
13229
|
if (!component) {
|
|
@@ -11883,7 +13522,7 @@ Example for ${pageType}Layout:
|
|
|
11883
13522
|
|
|
11884
13523
|
// src/prompts/componentUsage.ts
|
|
11885
13524
|
import { z as z7 } from "zod";
|
|
11886
|
-
var
|
|
13525
|
+
var catalog6 = component_catalog_default;
|
|
11887
13526
|
var ComponentUsageSchema = z7.object({
|
|
11888
13527
|
componentName: z7.string().describe("Name of the component (e.g., Button, Card, Select)"),
|
|
11889
13528
|
variant: z7.string().optional().describe("Desired variant (optional)"),
|
|
@@ -11899,7 +13538,7 @@ function registerComponentUsagePrompt(server) {
|
|
|
11899
13538
|
const componentName = parsed.componentName || "Button";
|
|
11900
13539
|
const variant = parsed.variant || "";
|
|
11901
13540
|
const useCase = parsed.useCase || "";
|
|
11902
|
-
const component =
|
|
13541
|
+
const component = catalog6.components.find(
|
|
11903
13542
|
(c) => c.name.toLowerCase() === componentName.toLowerCase()
|
|
11904
13543
|
);
|
|
11905
13544
|
let componentInfo = "";
|
|
@@ -11921,7 +13560,7 @@ ${component.examples.map((e) => `### ${e.title}
|
|
|
11921
13560
|
${e.code}
|
|
11922
13561
|
\`\`\``).join("\n\n")}`;
|
|
11923
13562
|
} else {
|
|
11924
|
-
componentInfo = `Component "${componentName}" not found in catalog. Available components: ${
|
|
13563
|
+
componentInfo = `Component "${componentName}" not found in catalog. Available components: ${catalog6.components.map((c) => c.name).join(", ")}`;
|
|
11925
13564
|
}
|
|
11926
13565
|
return {
|
|
11927
13566
|
messages: [
|