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