@vite-hub/auth 0.4.1 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -8
- package/dist/{abilities-CbmTAoS_.d.ts → abilities-3L1Y5Pnw.d.ts} +2 -4
- package/dist/abilities.d.ts +1 -1
- package/dist/abilities.js +1 -2
- package/dist/{ability-error-IeZQBr_-.js → ability-error-BHhPkrZd.js} +3 -5
- package/dist/{ability-error-DcgChwCN.d.ts → ability-error-C1c30O6E.d.ts} +1 -5
- package/dist/access-pages-BwImVHN_.js +94 -0
- package/dist/{admin-claim-code-CDipqeAU.js → admin-claim-code-C3X_U43x.js} +1 -2
- package/dist/agent.d.ts +1 -3
- package/dist/agent.js +5 -6
- package/dist/{application-path-DuTpfGFj.js → application-path-zKi7NrvK.js} +1 -2
- package/dist/{auth-instance-CmDogt4D.js → auth-instance-_J7R9Qs1.js} +239 -50
- package/dist/{cli-ubYJpAL_.d.ts → cli-C5pAfY4x.d.ts} +1 -6
- package/dist/cli.d.ts +2 -4
- package/dist/cli.js +3 -4
- package/dist/{console-runtime-D2ai-Et5.d.ts → console-runtime-BP1ZKJB0.d.ts} +13 -13
- package/dist/{console-runtime-_LrpyCYY.js → console-runtime-vc3JQEuq.js} +72 -40
- package/dist/console-runtime.d.ts +2 -2
- package/dist/console-runtime.js +1 -2
- package/dist/{console-types-CmmnKGMx.js → console-types-51lkf0lk.js} +1 -2
- package/dist/console.d.ts +1 -5
- package/dist/console.js +2 -3
- package/dist/{database-options-DpOVjUti.js → database-options-DQ-8qYMl.js} +2 -3
- package/dist/{database-schema-options-Sk-1Bvyu.js → database-schema-options-CkSeU9V3.js} +2 -3
- package/dist/database.d.ts +1 -3
- package/dist/database.js +5 -6
- package/dist/{definition-BCaLA9kW.js → definition-MDGMNKrK.js} +20 -18
- package/dist/{error-diagnostics-Dymr-S_n.js → error-diagnostics-BssJr_2t.js} +9 -4
- package/dist/{events-DCfuicoo.js → events-DZqMiae_.js} +4 -6
- package/dist/forward.d.ts +1 -3
- package/dist/forward.js +2 -3
- package/dist/index.d.ts +4 -7
- package/dist/index.js +4 -3
- package/dist/internal/server.d.ts +4 -4
- package/dist/internal/server.js +5 -5
- package/dist/{invariant-D8_xBqmZ.js → invariant-Dj2R1eMr.js} +2 -3
- package/dist/{mcp-config-DRRlCAWN.js → mcp-config-C7srUMIZ.js} +2 -3
- package/dist/{mcp-token-CpxLyl_p.js → mcp-token--KuLYEub.js} +7 -18
- package/dist/mcp.d.ts +0 -4
- package/dist/mcp.js +4 -5
- package/dist/{members-DdlsS8kJ.js → members-D3_Q5XJb.js} +10 -14
- package/dist/nitro-kit-Bg4xUZAI.js +43 -0
- package/dist/{nuxt-bridge-Cl988STZ.js → nuxt-bridge-pRyfYD5c.js} +1 -2
- package/dist/nuxt.d.ts +31 -24
- package/dist/nuxt.js +336 -18
- package/dist/{object-Da1zyPCR.js → object-CAK6UYR5.js} +1 -2
- package/dist/own-access-C22hSIuF.d.ts +18 -0
- package/dist/own-access-DQgqxTbI.js +30 -0
- package/dist/{page-tools-shared-l4eyj53D.js → page-tools-shared-CtoKaNQZ.js} +1 -2
- package/dist/{presets-CHndEv5i.d.ts → presets-C6AtiRdI.d.ts} +0 -2
- package/dist/presets.d.ts +1 -1
- package/dist/presets.js +2 -3
- package/dist/{request-z6DHHmrb.js → request-Dpq7GO8B.js} +2 -4
- package/dist/runtime/console.d.ts +1 -1
- package/dist/runtime/console.js +2 -2
- package/dist/runtime/empty-abilities.d.ts +1 -3
- package/dist/runtime/empty-abilities.js +1 -2
- package/dist/runtime/empty-client.d.ts +0 -2
- package/dist/runtime/empty-client.js +1 -2
- package/dist/runtime/empty-definition.d.ts +1 -3
- package/dist/runtime/empty-definition.js +1 -2
- package/dist/runtime/nuxt.d.ts +1 -3
- package/dist/runtime/nuxt.js +1 -2
- package/dist/runtime/server.d.ts +3 -2
- package/dist/runtime/server.js +27 -19
- package/dist/runtime/vue-nuxt.d.ts +0 -2
- package/dist/runtime/vue-nuxt.js +74 -33
- package/dist/{runtime-state-ojQCzKOc.js → runtime-state-DtKUfxKq.js} +1 -2
- package/dist/schema.d.ts +71 -23
- package/dist/schema.js +6 -5
- package/dist/{server-BM-RSf1T.d.ts → server-CFWlYQJb.d.ts} +7 -14
- package/dist/{server-BG_MFd4q.js → server-D4Hi4TBI.js} +51 -33
- package/dist/{server-C8TlOrSy.d.ts → server-DCsgxFPP.d.ts} +9 -14
- package/dist/server.d.ts +2 -2
- package/dist/server.js +2 -2
- package/dist/{session-cookies-DVzjOKc7.js → session-cookies-1FMcMnRh.js} +6 -8
- package/dist/{set-cookie-DmqWq6kj.js → set-cookie-DkqM1kvj.js} +3 -5
- package/dist/{table-specs-DbXyaXWs.d.ts → table-specs-BLm_Zlss.d.ts} +255 -3
- package/dist/{table-specs-CURphR3n.js → table-specs-jw0jjU6l.js} +43 -44
- package/dist/test.d.ts +2 -4
- package/dist/test.js +3 -4
- package/dist/{types-CruflEFI.d.ts → types-BHSgxyvV.d.ts} +50 -11
- package/dist/{vite-Dy0Xhq4H.js → vite-D1xC9n1O.js} +365 -152
- package/dist/vite.d.ts +7 -14
- package/dist/vite.js +1 -2
- package/dist/vue.d.ts +17 -72
- package/dist/vue.js +25 -73
- package/package.json +35 -30
- package/dist/shared-DRtfuFsV.js +0 -12
|
@@ -1,17 +1,4 @@
|
|
|
1
|
-
import { t as authErrorDiagnostics } from "./error-diagnostics-
|
|
2
|
-
//#region src/table-specs.ts
|
|
3
|
-
const requiredString = {
|
|
4
|
-
type: "string",
|
|
5
|
-
required: true
|
|
6
|
-
};
|
|
7
|
-
const optionalString = { type: "string" };
|
|
8
|
-
const optionalDate = { type: "date" };
|
|
9
|
-
const optionalBoolean = { type: "boolean" };
|
|
10
|
-
const userReference = {
|
|
11
|
-
model: "user",
|
|
12
|
-
field: "id",
|
|
13
|
-
onDelete: "cascade"
|
|
14
|
-
};
|
|
1
|
+
import { t as authErrorDiagnostics } from "./error-diagnostics-BssJr_2t.js";
|
|
15
2
|
/**
|
|
16
3
|
* The Better Auth core tables, with the fields of the plugins that ViteHub ships: `admin()` (`user.role`, bans, and
|
|
17
4
|
* `session.impersonatedBy`), the `jwt()` and `oauthProvider()` tables of `mcpOAuth()`, the tables of
|
|
@@ -599,14 +586,14 @@ const authPluginSchemas = {
|
|
|
599
586
|
index: true,
|
|
600
587
|
defaultValue: "default"
|
|
601
588
|
},
|
|
602
|
-
name:
|
|
603
|
-
start:
|
|
589
|
+
name: { type: "string" },
|
|
590
|
+
start: { type: "string" },
|
|
604
591
|
referenceId: {
|
|
605
592
|
type: "string",
|
|
606
593
|
required: true,
|
|
607
594
|
index: true
|
|
608
595
|
},
|
|
609
|
-
prefix:
|
|
596
|
+
prefix: { type: "string" },
|
|
610
597
|
key: {
|
|
611
598
|
type: "string",
|
|
612
599
|
required: true,
|
|
@@ -617,7 +604,7 @@ const authPluginSchemas = {
|
|
|
617
604
|
bigint: true
|
|
618
605
|
},
|
|
619
606
|
refillAmount: { type: "number" },
|
|
620
|
-
lastRefillAt:
|
|
607
|
+
lastRefillAt: { type: "date" },
|
|
621
608
|
enabled: {
|
|
622
609
|
type: "boolean",
|
|
623
610
|
defaultValue: true
|
|
@@ -640,8 +627,8 @@ const authPluginSchemas = {
|
|
|
640
627
|
defaultValue: 0
|
|
641
628
|
},
|
|
642
629
|
remaining: { type: "number" },
|
|
643
|
-
lastRequest:
|
|
644
|
-
expiresAt:
|
|
630
|
+
lastRequest: { type: "date" },
|
|
631
|
+
expiresAt: { type: "date" },
|
|
645
632
|
createdAt: {
|
|
646
633
|
type: "date",
|
|
647
634
|
required: true
|
|
@@ -650,45 +637,51 @@ const authPluginSchemas = {
|
|
|
650
637
|
type: "date",
|
|
651
638
|
required: true
|
|
652
639
|
},
|
|
653
|
-
permissions:
|
|
654
|
-
metadata:
|
|
640
|
+
permissions: { type: "string" },
|
|
641
|
+
metadata: { type: "string" }
|
|
655
642
|
} } } },
|
|
656
|
-
lastLoginMethod: { fields: { user: { lastLoginMethod:
|
|
643
|
+
lastLoginMethod: { fields: { user: { lastLoginMethod: { type: "string" } } } },
|
|
657
644
|
phoneNumber: { fields: { user: {
|
|
658
645
|
phoneNumber: {
|
|
659
646
|
type: "string",
|
|
660
647
|
unique: true
|
|
661
648
|
},
|
|
662
|
-
phoneNumberVerified:
|
|
649
|
+
phoneNumberVerified: { type: "boolean" }
|
|
663
650
|
} } },
|
|
664
651
|
stripe: {
|
|
665
652
|
fields: {
|
|
666
|
-
user: { stripeCustomerId:
|
|
667
|
-
organization: { stripeCustomerId:
|
|
653
|
+
user: { stripeCustomerId: { type: "string" } },
|
|
654
|
+
organization: { stripeCustomerId: { type: "string" } }
|
|
668
655
|
},
|
|
669
656
|
tables: { subscription: { fields: {
|
|
670
|
-
plan:
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
657
|
+
plan: {
|
|
658
|
+
type: "string",
|
|
659
|
+
required: true
|
|
660
|
+
},
|
|
661
|
+
referenceId: {
|
|
662
|
+
type: "string",
|
|
663
|
+
required: true
|
|
664
|
+
},
|
|
665
|
+
stripeCustomerId: { type: "string" },
|
|
666
|
+
stripeSubscriptionId: { type: "string" },
|
|
674
667
|
status: {
|
|
675
668
|
type: "string",
|
|
676
669
|
defaultValue: "incomplete"
|
|
677
670
|
},
|
|
678
|
-
periodStart:
|
|
679
|
-
periodEnd:
|
|
680
|
-
trialStart:
|
|
681
|
-
trialEnd:
|
|
671
|
+
periodStart: { type: "date" },
|
|
672
|
+
periodEnd: { type: "date" },
|
|
673
|
+
trialStart: { type: "date" },
|
|
674
|
+
trialEnd: { type: "date" },
|
|
682
675
|
cancelAtPeriodEnd: {
|
|
683
676
|
type: "boolean",
|
|
684
677
|
defaultValue: false
|
|
685
678
|
},
|
|
686
|
-
cancelAt:
|
|
687
|
-
canceledAt:
|
|
688
|
-
endedAt:
|
|
679
|
+
cancelAt: { type: "date" },
|
|
680
|
+
canceledAt: { type: "date" },
|
|
681
|
+
endedAt: { type: "date" },
|
|
689
682
|
seats: { type: "number" },
|
|
690
|
-
billingInterval:
|
|
691
|
-
stripeScheduleId:
|
|
683
|
+
billingInterval: { type: "string" },
|
|
684
|
+
stripeScheduleId: { type: "string" }
|
|
692
685
|
} } }
|
|
693
686
|
},
|
|
694
687
|
twoFactor: {
|
|
@@ -702,12 +695,19 @@ const authPluginSchemas = {
|
|
|
702
695
|
required: true,
|
|
703
696
|
index: true
|
|
704
697
|
},
|
|
705
|
-
backupCodes:
|
|
698
|
+
backupCodes: {
|
|
699
|
+
type: "string",
|
|
700
|
+
required: true
|
|
701
|
+
},
|
|
706
702
|
userId: {
|
|
707
703
|
type: "string",
|
|
708
704
|
required: true,
|
|
709
705
|
index: true,
|
|
710
|
-
references:
|
|
706
|
+
references: {
|
|
707
|
+
model: "user",
|
|
708
|
+
field: "id",
|
|
709
|
+
onDelete: "cascade"
|
|
710
|
+
}
|
|
711
711
|
},
|
|
712
712
|
verified: {
|
|
713
713
|
type: "boolean",
|
|
@@ -717,7 +717,7 @@ const authPluginSchemas = {
|
|
|
717
717
|
type: "number",
|
|
718
718
|
defaultValue: 0
|
|
719
719
|
},
|
|
720
|
-
lockedUntil:
|
|
720
|
+
lockedUntil: { type: "date" }
|
|
721
721
|
} } }
|
|
722
722
|
},
|
|
723
723
|
username: { fields: { user: {
|
|
@@ -725,7 +725,7 @@ const authPluginSchemas = {
|
|
|
725
725
|
type: "string",
|
|
726
726
|
unique: true
|
|
727
727
|
},
|
|
728
|
-
displayUsername:
|
|
728
|
+
displayUsername: { type: "string" }
|
|
729
729
|
} } }
|
|
730
730
|
};
|
|
731
731
|
function sameField(left, right) {
|
|
@@ -767,5 +767,4 @@ function authSchemaError(detail) {
|
|
|
767
767
|
function authSqlName(name) {
|
|
768
768
|
return name.replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2").replace(/([a-z\d])([A-Z])/g, "$1_$2").toLowerCase();
|
|
769
769
|
}
|
|
770
|
-
//#endregion
|
|
771
770
|
export { resolveAuthTableSpecs as i, authSqlName as n, authTableSpecs as r, authPluginSchemas as t };
|
package/dist/test.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as AuthDefinition } from "./types-BHSgxyvV.js";
|
|
2
2
|
import { Session, User } from "better-auth";
|
|
3
|
-
//#region src/test.d.ts
|
|
4
3
|
/** The user to sign in. Auth creates it when no user has this email. Other fields, such as `role`, go to the new user. */
|
|
5
4
|
export interface SignInTestUser {
|
|
6
5
|
email?: string;
|
|
@@ -22,5 +21,4 @@ export interface TestSignIn {
|
|
|
22
21
|
* request. It sends no email and calls no provider. A Definition with the `stateless()` preset has no database, so it
|
|
23
22
|
* fails with `AUTH_TEST_SIGN_IN_STATELESS`.
|
|
24
23
|
*/
|
|
25
|
-
export declare function signIn(user?: SignInTestUser, definition?: AuthDefinition): Promise<TestSignIn>;
|
|
26
|
-
//#endregion
|
|
24
|
+
export declare function signIn(user?: SignInTestUser, definition?: AuthDefinition): Promise<TestSignIn>;
|
package/dist/test.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import {
|
|
1
|
+
import { s as resolveDefaultDefinition, t as authForRequest } from "./auth-instance-_J7R9Qs1.js";
|
|
2
|
+
import { t as authErrorDiagnostics } from "./error-diagnostics-BssJr_2t.js";
|
|
3
3
|
import { testUtils } from "better-auth/plugins";
|
|
4
|
-
|
|
4
|
+
// src/test.ts
|
|
5
5
|
/**
|
|
6
6
|
* Signs in a user of the app's Auth Definition and returns the session cookie. It writes the user and the session to the
|
|
7
7
|
* Auth database, as a real sign-in does, so `requireAuth()`, `useAuth().api.getSession()`, and abilities accept the
|
|
@@ -21,5 +21,4 @@ async function signIn(user = {}, definition = resolveDefaultDefinition()) {
|
|
|
21
21
|
user: saved
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
//#endregion
|
|
25
24
|
export { signIn };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { t as AuthPreset } from "./presets-
|
|
2
|
-
import {
|
|
1
|
+
import { t as AuthPreset } from "./presets-C6AtiRdI.js";
|
|
2
|
+
import { i as AuthSchemaOptions } from "./table-specs-BLm_Zlss.js";
|
|
3
3
|
import { AccessAuthorizationContext, AccessAuthorize, AccessAuthorizeResult, AnonymousAccessAuthorizationContext, AnonymousAccessAuthorize, Duration } from "@vite-hub/runtime";
|
|
4
4
|
import { ViteHubContext as ViteHubContext$1 } from "@vite-hub/runtime/internal/h3";
|
|
5
5
|
import { Auth, BetterAuthOptions, DBAdapter, Session, User } from "better-auth";
|
|
6
6
|
import { EnvDatabase } from "@vite-hub/env/database";
|
|
7
|
-
//#region src/events.d.ts
|
|
8
7
|
declare const authEventTypes: readonly ["user.signed_up", "user.signed_in", "user.signed_out", "sign_in.failed", "session.revoked", "user.banned", "user.unbanned", "user.role_changed", "user.updated", "user.removed", "impersonation.started", "impersonation.stopped", "oauth.consent_granted", "oauth.consent_revoked", "organization.member_added", "organization.member_removed", "organization.member_role_changed"];
|
|
9
8
|
type AuthEventType = typeof authEventTypes[number];
|
|
10
9
|
type AuthEventActor = "system" | `user:${string}`;
|
|
@@ -86,8 +85,23 @@ declare function createDatabaseAuthEventStore(options: {
|
|
|
86
85
|
db: EnvDatabase;
|
|
87
86
|
retention?: AuthEventRetention | false;
|
|
88
87
|
}): AuthEventStore;
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
/** Who may open a page: signed-in users (`user`) or signed-out visitors (`guest`). */
|
|
89
|
+
type AuthPageMode = "guest" | "user";
|
|
90
|
+
/**
|
|
91
|
+
* The `auth` key of `definePageMeta()` in Nuxt. `'user'` or `true` sends visitors without a session to the login
|
|
92
|
+
* page. `'guest'` sends signed-in users away, for example from the login page. `false` turns the guard off.
|
|
93
|
+
*/
|
|
94
|
+
type AuthPageMeta = boolean | AuthPageMode | {
|
|
95
|
+
only?: AuthPageMode;
|
|
96
|
+
/** Where to send the visitor instead of the configured redirect. */
|
|
97
|
+
redirectTo?: string;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* `access.pages`: the Nuxt pages that the page guard protects, by route pattern, such as `'/dashboard/**'`. A key has
|
|
101
|
+
* static segments, `:name`, and a last `**`. `'user'` and `'guest'` work as in `definePageMeta({ auth })`. `false`
|
|
102
|
+
* removes the guard of a wider pattern from the matching pages.
|
|
103
|
+
*/
|
|
104
|
+
type AuthPages = Record<`/${string}`, AuthPageMode | false>;
|
|
91
105
|
type AuthConsoleValue = string | number | boolean | null | string[] | number[];
|
|
92
106
|
type AuthConsoleFieldType = "string" | "number" | "boolean" | "date" | "string[]" | "number[]" | "json";
|
|
93
107
|
type AuthConsoleAction = "ban" | "unban" | "remove" | "revokeSession" | "revokeSessions" | "setRole" | "editField" | "impersonate" | "revokeConsent";
|
|
@@ -279,6 +293,7 @@ interface AuthConsoleHostUserInput {
|
|
|
279
293
|
/** A live session of a user that holds a host role, with the user's roles. */
|
|
280
294
|
interface AuthConsoleHostSession extends AuthConsoleSession {
|
|
281
295
|
roles: string[];
|
|
296
|
+
guest: boolean;
|
|
282
297
|
}
|
|
283
298
|
interface AuthConsoleAgent {
|
|
284
299
|
id: string;
|
|
@@ -363,8 +378,6 @@ type AuthConsoleMutation = {
|
|
|
363
378
|
id: string;
|
|
364
379
|
};
|
|
365
380
|
declare const authConsoleActionNames: readonly AuthConsoleAction[];
|
|
366
|
-
//#endregion
|
|
367
|
-
//#region src/types.d.ts
|
|
368
381
|
declare global {
|
|
369
382
|
namespace ViteHub {
|
|
370
383
|
interface AuthRuntimeEnv extends Record<string, unknown> {}
|
|
@@ -373,7 +386,7 @@ declare global {
|
|
|
373
386
|
}
|
|
374
387
|
}
|
|
375
388
|
type AuthRuntimeOption = "baseURL" | "secret" | "secrets";
|
|
376
|
-
type AuthReservedOption = AuthRuntimeOption | "events" | "console" | "access" | "adminClaim" | "basePath" | "database" | "deleteAccount" | "preset" | "route" | "runtime" | "secondaryStorage";
|
|
389
|
+
type AuthReservedOption = AuthRuntimeOption | "events" | "console" | "access" | "adminClaim" | "basePath" | "components" | "database" | "deleteAccount" | "preset" | "route" | "runtime" | "secondaryStorage";
|
|
377
390
|
type AuthBetterAuthOptions = Omit<BetterAuthOptions, AuthReservedOption | "session"> & {
|
|
378
391
|
session?: AuthSessionOptions;
|
|
379
392
|
};
|
|
@@ -486,11 +499,22 @@ interface AuthAccessConfiguration {
|
|
|
486
499
|
* user from an `auth: 'guest'` page. Default: `"/"`.
|
|
487
500
|
*/
|
|
488
501
|
afterSignIn?: string;
|
|
502
|
+
/**
|
|
503
|
+
* Nuxt pages that the page guard protects, by route pattern: `'user'`, `'guest'`, or `false`, such as
|
|
504
|
+
* `{ '/dashboard/**': 'user', '/login': 'guest' }`. The most specific pattern wins, and `definePageMeta({ auth })` of
|
|
505
|
+
* a page wins over all patterns. Vite apps without Nuxt ignore it.
|
|
506
|
+
*/
|
|
507
|
+
pages?: AuthPages;
|
|
489
508
|
}
|
|
490
509
|
/** The Better Auth adapter of `authDatabase()`. `vitehubDatabase` names the app Database that holds the Auth tables. */
|
|
491
510
|
type AuthAppDatabase = ((options: BetterAuthOptions) => DBAdapter<BetterAuthOptions>) & {
|
|
492
511
|
readonly vitehubDatabase: string;
|
|
493
512
|
};
|
|
513
|
+
/** `components` of `defineAuth()`: how the Nuxt module names the Auth components. */
|
|
514
|
+
interface AuthComponentsOptions {
|
|
515
|
+
/** Prepended to each component name, such as `"Custom"` for `<CustomAuthPermission>`. */
|
|
516
|
+
prefix?: string;
|
|
517
|
+
}
|
|
494
518
|
interface AuthViteHubOptions {
|
|
495
519
|
/** Ignore `VITEHUB_ADMIN_CLAIM` for this Auth Definition. Independent Console Auth sets this to `false`. */
|
|
496
520
|
adminClaim?: false;
|
|
@@ -505,6 +529,16 @@ interface AuthViteHubOptions {
|
|
|
505
529
|
console?: AuthConsoleOptions;
|
|
506
530
|
access?: AuthAccessConfiguration;
|
|
507
531
|
basePath?: string;
|
|
532
|
+
/**
|
|
533
|
+
* The names that the Nuxt module gives `<AuthPermission>`. A prefix keeps it apart from an app component of the same name.
|
|
534
|
+
* The prefix follows Nuxt's component prefix rules, as the prefix of `components: [{ path, prefix }]` does: words that the
|
|
535
|
+
* name starts with are dropped, so `MyAuth` gives `<MyAuthPermission>` and `Auth` changes nothing. The Vite
|
|
536
|
+
* plugin reads it at build time, so write it as an inline string literal. The module registers `<AuthPermission>` only
|
|
537
|
+
* when the app has `shared/abilities.ts`. Vite apps without Nuxt ignore it.
|
|
538
|
+
*
|
|
539
|
+
* @example { prefix: "Custom" } // <CustomAuthPermission>
|
|
540
|
+
*/
|
|
541
|
+
components?: AuthComponentsOptions;
|
|
508
542
|
/**
|
|
509
543
|
* `authDatabase()` from `vite-hub/auth/database` keeps users and sessions in the app Database. Return another Better
|
|
510
544
|
* Auth adapter from the Definition callback. `"memory"` keeps them in the memory of one server process,
|
|
@@ -552,8 +586,14 @@ interface ResolvedAuthViteConfig {
|
|
|
552
586
|
};
|
|
553
587
|
/** `access.afterSignIn`. Set only when the Definition has it. */
|
|
554
588
|
afterSignIn?: string;
|
|
589
|
+
/** `access.pages`. Set only when the Definition has it. */
|
|
590
|
+
pages?: AuthPages;
|
|
555
591
|
};
|
|
556
592
|
basePath: string;
|
|
593
|
+
/** `components` of the Definition, which the Nuxt module reads at build time. Set only when the Definition has a prefix. */
|
|
594
|
+
components?: {
|
|
595
|
+
prefix: string;
|
|
596
|
+
};
|
|
557
597
|
/**
|
|
558
598
|
* The app Database that `authDatabase()` names, which gets the Better Auth tables, and the plugins and additional fields
|
|
559
599
|
* of the Definition that add tables and columns. `false` without the call.
|
|
@@ -568,7 +608,7 @@ interface ResolvedAuthViteConfig {
|
|
|
568
608
|
rootDir: string;
|
|
569
609
|
route: false | string;
|
|
570
610
|
}
|
|
571
|
-
type AuthBetterAuthRuntimeOptions<TOptions extends AuthDefinitionInput = AuthDefinitionInput> = (TOptions extends AuthDefinitionResolver<infer TResolved> ? Omit<TResolved, AuthRuntimeOption | "events" | "console" | "access" | "adminClaim" | "database" | "deleteAccount" | "preset" | "route" | "runtime" | "secondaryStorage"> : Omit<TOptions, AuthRuntimeOption | "events" | "console" | "access" | "adminClaim" | "database" | "deleteAccount" | "preset" | "route" | "runtime" | "secondaryStorage">) & AuthRuntimeOptions & BetterAuthOptions;
|
|
611
|
+
type AuthBetterAuthRuntimeOptions<TOptions extends AuthDefinitionInput = AuthDefinitionInput> = (TOptions extends AuthDefinitionResolver<infer TResolved> ? Omit<TResolved, AuthRuntimeOption | "events" | "console" | "access" | "adminClaim" | "components" | "database" | "deleteAccount" | "preset" | "route" | "runtime" | "secondaryStorage"> : Omit<TOptions, AuthRuntimeOption | "events" | "console" | "access" | "adminClaim" | "components" | "database" | "deleteAccount" | "preset" | "route" | "runtime" | "secondaryStorage">) & AuthRuntimeOptions & BetterAuthOptions;
|
|
572
612
|
type AuthRequest = Pick<Request, "body" | "headers" | "method" | "signal" | "url">;
|
|
573
613
|
/**
|
|
574
614
|
* A Web Request, or a request event with Standard Context properties, such as an H3 2 event in a ViteHub app.
|
|
@@ -584,5 +624,4 @@ type RegisteredAuth<TRegistry = ViteHub.AuthRegistry> = TRegistry extends {
|
|
|
584
624
|
} ? AuthFor<TDefinition> : ViteHubAuth;
|
|
585
625
|
/** `false` turns Auth off. `server/auth.ts` turns it on, and `defineAuth()` holds every Auth option. */
|
|
586
626
|
type AuthOptions = false;
|
|
587
|
-
|
|
588
|
-
export { AuthConsoleEventUser as $, AuthRuntimeOnlyOptions as A, AuthEventMetadata as At, RegisteredAuth as B, AuthOptions as C, authConsoleEventGroups as Ct, AuthResolvedDefinitionOptions as D, AuthEventAggregates as Dt, AuthReservedOption as E, AuthEventActor as Et, AuthSessionRefreshContext as F, AuthEventWindow as Ft, AuthConsoleActivity as G, ResolvedAuthViteConfig as H, AuthSessionRefreshFields as I, AuthEventsConfiguration as It, AuthConsoleCapability as J, AuthConsoleActivityQuery as K, AuthSignInConfiguration as L, createDatabaseAuthEventStore as Lt, AuthRuntimeOptions as M, AuthEventRetention as Mt, AuthSessionOptions as N, AuthEventStore as Nt, AuthRuntimeContext as O, AuthEventCounts as Ot, AuthSessionRefresh as P, AuthEventType as Pt, AuthConsoleEventGroup as Q, AuthViteHubOptions as R, defaultAuthEventRetention as Rt, AuthGuardedHandler as S, authConsoleActionNames as St, AuthRequestInput as T, AuthEvent as Tt, ViteHubAuth as U, ResolvedAuthAccessRoute as V, AuthConsoleAction as W, AuthConsoleDescription as X, AuthConsoleColumn as Y, AuthConsoleEvent as Z, AuthDefinitionInput as _, AuthConsoleSession as _t, AuthAccessPolicy as a, AuthConsoleHostUserInput as at, AuthDeleteAccountOptions as b, AuthConsoleUserDetail as bt, AuthAccessRouteConfiguration as c, AuthConsoleMutation as ct, AuthAnonymousGuardedHandler as d, AuthConsoleOrganizationDetail as dt, AuthConsoleField as et, AuthAppDatabase as f, AuthConsoleOverview as ft, AuthDefinition as g, AuthConsoleRoles as gt, AuthBetterAuthRuntimeOptions as h, AuthConsoleQuery as ht, AuthAccessConfiguration as i, AuthConsoleHostSession as it, AuthRuntimeOption as j, AuthEventPage as jt, AuthRuntimeEnv as k, AuthEventListInput as kt, AuthAnonymousAuthorization as l, AuthConsoleOptions as lt, AuthBetterAuthOptions as m, AuthConsolePolicy as mt, AuthAccessAuthorize as n, AuthConsoleFieldType as nt, AuthAccessPolicyContext as o, AuthConsoleImpersonation as ot, AuthAuthorization as p, AuthConsolePage as pt, AuthConsoleAgent as q, AuthAccessAuthorizeResult as r, AuthConsoleHostOptions as rt, AuthAccessRoute as s, AuthConsoleList as st, AuthAccessAuthorizationContext as t, AuthConsoleFieldPolicy as tt, AuthAnonymousAuthorize as u, AuthConsoleOrganization as ut, AuthDefinitionOptions as v, AuthConsoleSessionUser as vt, AuthRequest as w, AuthDevice as wt, AuthFor as x, AuthConsoleValue as xt, AuthDefinitionResolver as y, AuthConsoleUser as yt, DiscoveredAuthDefinition as z };
|
|
627
|
+
export { AuthConsoleEventGroup as $, AuthRuntimeEnv as A, AuthEventActor as At, DiscoveredAuthDefinition as B, AuthEventsConfiguration as Bt, AuthGuardedHandler as C, authConsoleActionNames as Ct, AuthReservedOption as D, AuthPages as Dt, AuthRequestInput as E, AuthPageMode as Et, AuthSessionRefresh as F, AuthEventPage as Ft, AuthConsoleAction as G, ResolvedAuthAccessRoute as H, defaultAuthEventRetention as Ht, AuthSessionRefreshContext as I, AuthEventRetention as It, AuthConsoleAgent as J, AuthConsoleActivity as K, AuthSessionRefreshFields as L, AuthEventStore as Lt, AuthRuntimeOption as M, AuthEventCounts as Mt, AuthRuntimeOptions as N, AuthEventListInput as Nt, AuthResolvedDefinitionOptions as O, AuthDevice as Ot, AuthSessionOptions as P, AuthEventMetadata as Pt, AuthConsoleEvent as Q, AuthSignInConfiguration as R, AuthEventType as Rt, AuthFor as S, AuthConsoleValue as St, AuthRequest as T, AuthPageMeta as Tt, ResolvedAuthViteConfig as U, RegisteredAuth as V, createDatabaseAuthEventStore as Vt, ViteHubAuth as W, AuthConsoleColumn as X, AuthConsoleCapability as Y, AuthConsoleDescription as Z, AuthDefinition as _, AuthConsoleRoles as _t, AuthAccessPolicy as a, AuthConsoleHostSession as at, AuthDefinitionResolver as b, AuthConsoleUser as bt, AuthAccessRouteConfiguration as c, AuthConsoleList as ct, AuthAnonymousGuardedHandler as d, AuthConsoleOrganization as dt, AuthConsoleEventUser as et, AuthAppDatabase as f, AuthConsoleOrganizationDetail as ft, AuthComponentsOptions as g, AuthConsoleQuery as gt, AuthBetterAuthRuntimeOptions as h, AuthConsolePolicy as ht, AuthAccessConfiguration as i, AuthConsoleHostOptions as it, AuthRuntimeOnlyOptions as j, AuthEventAggregates as jt, AuthRuntimeContext as k, AuthEvent as kt, AuthAnonymousAuthorization as l, AuthConsoleMutation as lt, AuthBetterAuthOptions as m, AuthConsolePage as mt, AuthAccessAuthorize as n, AuthConsoleFieldPolicy as nt, AuthAccessPolicyContext as o, AuthConsoleHostUserInput as ot, AuthAuthorization as p, AuthConsoleOverview as pt, AuthConsoleActivityQuery as q, AuthAccessAuthorizeResult as r, AuthConsoleFieldType as rt, AuthAccessRoute as s, AuthConsoleImpersonation as st, AuthAccessAuthorizationContext as t, AuthConsoleField as tt, AuthAnonymousAuthorize as u, AuthConsoleOptions as ut, AuthDefinitionInput as v, AuthConsoleSession as vt, AuthOptions as w, authConsoleEventGroups as wt, AuthDeleteAccountOptions as x, AuthConsoleUserDetail as xt, AuthDefinitionOptions as y, AuthConsoleSessionUser as yt, AuthViteHubOptions as z, AuthEventWindow as zt };
|