@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
package/dist/vite.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/// <reference path="./host-declarations.d.ts" />
|
|
2
|
-
import {
|
|
3
|
-
import { n as ViteHubCliPluginMetadata } from "./cli-
|
|
2
|
+
import { U as ResolvedAuthViteConfig, w as AuthOptions } from "./types-BHSgxyvV.js";
|
|
3
|
+
import { n as ViteHubCliPluginMetadata } from "./cli-C5pAfY4x.js";
|
|
4
4
|
import { Plugin } from "vite";
|
|
5
|
-
//#region ../internal/src/inspect.d.ts
|
|
6
5
|
interface ViteHubDefinitionField {
|
|
7
6
|
label: string;
|
|
8
7
|
value: string;
|
|
@@ -52,6 +51,8 @@ interface ViteHubResourceSummary {
|
|
|
52
51
|
owner: string;
|
|
53
52
|
/** Absent when no id is known yet. */
|
|
54
53
|
source?: ViteHubResourceIdSource;
|
|
54
|
+
/** The resource is in the Wrangler config of a standalone Provider Output Worker, not in Nitro's. */
|
|
55
|
+
standalone?: boolean;
|
|
55
56
|
}
|
|
56
57
|
interface ViteHubInspectionContributor {
|
|
57
58
|
definitions?: readonly ViteHubDefinitionInspector[];
|
|
@@ -62,17 +63,11 @@ type ViteHubInspectionContributorFactory = () => ViteHubInspectionContributor |
|
|
|
62
63
|
interface ViteHubInspectionPluginMetadata {
|
|
63
64
|
inspect?: ViteHubInspectionContributor | ViteHubInspectionContributorFactory;
|
|
64
65
|
}
|
|
65
|
-
//#endregion
|
|
66
|
-
//#region src/config.d.ts
|
|
67
66
|
export declare function resolveAuthViteConfig(options?: AuthOptions, rootDir?: string, discovery?: {
|
|
68
67
|
serverDirs?: string[];
|
|
69
68
|
}): ResolvedAuthViteConfig | undefined;
|
|
70
|
-
//#endregion
|
|
71
|
-
//#region ../internal/src/deployment.d.ts
|
|
72
69
|
/** The host that ViteHub builds for: the `host` option of `vitehub()` and the value of `VITEHUB_HOST`. */
|
|
73
70
|
type ViteHubHost = "cloudflare" | "deno" | "netlify" | "node" | "vercel";
|
|
74
|
-
//#endregion
|
|
75
|
-
//#region ../internal/src/build/deployment-plan-output.d.ts
|
|
76
71
|
/**
|
|
77
72
|
* One set of host variables that the deployed app reads, as `deployment.json` lists it: a Server Env declaration, or
|
|
78
73
|
* a variable that a primitive reads itself, such as `VITEHUB_SECRET` or `BLOB_READ_WRITE_TOKEN`.
|
|
@@ -102,8 +97,6 @@ interface DeploymentEnvContext {
|
|
|
102
97
|
* Return names only, never values.
|
|
103
98
|
*/
|
|
104
99
|
type DeploymentEnvContribution = (context: DeploymentEnvContext) => readonly DeploymentEnvEntry[];
|
|
105
|
-
//#endregion
|
|
106
|
-
//#region ../internal/src/contributions.d.ts
|
|
107
100
|
/** Roots that ViteHub passes to every contribution factory. */
|
|
108
101
|
interface ContributionContext {
|
|
109
102
|
/** Vite root. */
|
|
@@ -112,9 +105,9 @@ interface ContributionContext {
|
|
|
112
105
|
projectRoot: string;
|
|
113
106
|
/** Server directories that the host forwards, for example Nuxt's `serverDir` and the server directories of layers. */
|
|
114
107
|
serverDirs?: readonly string[];
|
|
108
|
+
/** The flat list of Vite plugins, so a factory can read what sibling plugins declare. */
|
|
109
|
+
plugins?: readonly unknown[];
|
|
115
110
|
}
|
|
116
|
-
//#endregion
|
|
117
|
-
//#region src/vite.d.ts
|
|
118
111
|
export declare const AUTH_ABILITIES_ID = "#vitehub/auth/abilities";
|
|
119
112
|
export declare const AUTH_CLIENT_ID = "#vitehub/auth/client";
|
|
120
113
|
export declare const AUTH_DEFINITION_ID = "#vitehub/auth/definition";
|
|
@@ -162,4 +155,4 @@ interface InternalAuthModuleOptions {
|
|
|
162
155
|
}
|
|
163
156
|
export declare function writeNuxtAuthDefinition(root: string, config: ResolvedAuthViteConfig): Promise<string>;
|
|
164
157
|
export declare function hubAuth(options?: AuthOptions, internalOptions?: InternalAuthModuleOptions): AuthVitePlugin;
|
|
165
|
-
|
|
158
|
+
export {};
|
package/dist/vite.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { AUTH_ABILITIES_ID, AUTH_CLIENT_ID, AUTH_DEFINITION_ID, AUTH_SERVER_ID, AUTH_VITE_PLUGIN_NAME, createAuthNitroConfig, hubAuth, resolveAuthViteConfig, writeNuxtAuthDefinition };
|
|
1
|
+
export { t as AUTH_ABILITIES_ID, n as AUTH_CLIENT_ID, r as AUTH_DEFINITION_ID, i as AUTH_SERVER_ID, a as AUTH_VITE_PLUGIN_NAME, o as createAuthNitroConfig, s as hubAuth, l as resolveAuthViteConfig, c as writeNuxtAuthDefinition } from "./vite-D1xC9n1O.js";
|
package/dist/vue.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/// <reference path="./host-declarations.d.ts" />
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { n as AbilityErrorData } from "./ability-error-
|
|
2
|
+
import { a as AbilityRefusal, i as AbilityName, t as AbilityArgs } from "./abilities-3L1Y5Pnw.js";
|
|
3
|
+
import { S as AuthFor, _ as AuthDefinition } from "./types-BHSgxyvV.js";
|
|
4
|
+
import { n as AbilityErrorData } from "./ability-error-C1c30O6E.js";
|
|
5
5
|
import { BetterAuthClientOptions } from "better-auth";
|
|
6
6
|
import { ComputedRef, VNode } from "vue";
|
|
7
7
|
import { inferAdditionalFields } from "better-auth/client/plugins";
|
|
8
8
|
import { BetterFetchError, VueAuthClient, VueAuthClient as VueAuthClient$1, createAuthClient as createAuthClient$1 } from "better-auth/vue";
|
|
9
|
-
//#region src/nuxt-bridge.d.ts
|
|
10
9
|
/** The members of the Nuxt app that the composables read. */
|
|
11
10
|
type AuthNuxtApp = {
|
|
12
11
|
runWithContext<T>(run: () => T): T;
|
|
@@ -57,8 +56,6 @@ export declare function setSessionSeedResolver(resolver: ((read: boolean) => unk
|
|
|
57
56
|
* `undefined` outside a request.
|
|
58
57
|
*/
|
|
59
58
|
export declare function setRequestFetchResolver(resolver: (() => RequestFetch | undefined) | undefined): void;
|
|
60
|
-
//#endregion
|
|
61
|
-
//#region src/vue.d.ts
|
|
62
59
|
/**
|
|
63
60
|
* The members of a client that the composables read. Every Better Auth Vue client has them. `VueAuthClient<any>`
|
|
64
61
|
* rejects a client with a required additional field, because its `signUp.email()` needs that field.
|
|
@@ -181,7 +178,7 @@ type ServerFieldsClient<TOptions> = TOptions extends BetterAuthClientOptions ? V
|
|
|
181
178
|
* Auth Definition's `basePath` below the `app.baseURL` of the page, also when `NUXT_APP_BASE_URL` sets it at runtime.
|
|
182
179
|
*/
|
|
183
180
|
export declare const authClient: RegisteredAuthClient;
|
|
184
|
-
/** Provide the app's configured client to Auth composables and `<
|
|
181
|
+
/** Provide the app's configured client to Auth composables and `<AuthPermission>` in descendant components. */
|
|
185
182
|
export declare function provideAuthClient(client: AuthClientLike): void;
|
|
186
183
|
export declare function useAuthClient(): typeof authClient;
|
|
187
184
|
type ClientSession<Client extends AuthClientLike> = Client["$Infer"]["Session"];
|
|
@@ -271,79 +268,27 @@ export interface Ability {
|
|
|
271
268
|
* await authorize("posts.edit", loadedPost)
|
|
272
269
|
*/
|
|
273
270
|
export declare function useAbility(client?: AuthClientLike): Ability;
|
|
274
|
-
/**
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
* first, or a rest parameter.
|
|
278
|
-
*/
|
|
279
|
-
type CanArguments<Args extends unknown[]> = Args extends [] ? {
|
|
280
|
-
with?: never;
|
|
281
|
-
args?: never;
|
|
282
|
-
} : number extends Args["length"] ? {
|
|
283
|
-
with?: never;
|
|
284
|
-
args: Args;
|
|
285
|
-
} : Exclude<Args["length"], 0> extends 1 ? (0 extends Args["length"] ? {
|
|
286
|
-
with?: Args[0];
|
|
287
|
-
args?: never;
|
|
271
|
+
/** The rule arguments use the same tuple as the server check. */
|
|
272
|
+
type PermissionArguments<Args extends unknown[]> = [] extends Args ? {
|
|
273
|
+
args?: Args;
|
|
288
274
|
} : {
|
|
289
|
-
with: Args[0];
|
|
290
|
-
args?: never;
|
|
291
|
-
}) : {
|
|
292
|
-
with?: never;
|
|
293
275
|
args: Args;
|
|
294
276
|
};
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
* the data for the arguments loads.
|
|
298
|
-
*/
|
|
299
|
-
export type CanProps<Name extends AbilityName> = {
|
|
300
|
-
do: Name;
|
|
277
|
+
export type AuthPermissionProps<Name extends AbilityName> = {
|
|
278
|
+
check: Name;
|
|
301
279
|
pending?: boolean;
|
|
302
|
-
} &
|
|
303
|
-
|
|
304
|
-
export interface CanSlots<Name extends AbilityName> {
|
|
280
|
+
} & PermissionArguments<AbilityArgs<Name>>;
|
|
281
|
+
export interface AuthPermissionSlots<Name extends AbilityName> {
|
|
305
282
|
default?: () => VNode[];
|
|
283
|
+
allowed?: () => VNode[];
|
|
306
284
|
denied?: (refusal: AbilityRefusal<Name>) => VNode[];
|
|
307
285
|
}
|
|
308
|
-
|
|
309
|
-
export type CanComponent = <const Name extends AbilityName>(props: CanProps<Name>) => VNode & {
|
|
286
|
+
export type AuthPermissionComponent = <const Name extends AbilityName>(props: AuthPermissionProps<Name>) => VNode & {
|
|
310
287
|
__ctx?: {
|
|
311
|
-
props:
|
|
312
|
-
slots:
|
|
288
|
+
props: AuthPermissionProps<Name>;
|
|
289
|
+
slots: AuthPermissionSlots<Name>;
|
|
313
290
|
};
|
|
314
291
|
};
|
|
315
|
-
/**
|
|
316
|
-
|
|
317
|
-
* it refuses, and nothing while the session is unknown or `pending` is `true`.
|
|
318
|
-
*
|
|
319
|
-
* @example
|
|
320
|
-
* <Can do="posts.edit" :with="post">
|
|
321
|
-
* <button>Edit</button>
|
|
322
|
-
* <template #denied="{ code }">{{ code }}</template>
|
|
323
|
-
* </Can>
|
|
324
|
-
* <Can do="posts.move" :args="[from, to]">Move</Can>
|
|
325
|
-
*/
|
|
326
|
-
export declare const Can: CanComponent;
|
|
327
|
-
/** The slot of `<Cannot>`: its content, with the refusal, when the rule refuses. */
|
|
328
|
-
export interface CannotSlots<Name extends AbilityName> {
|
|
329
|
-
default?: (refusal: AbilityRefusal<Name>) => VNode[];
|
|
330
|
-
}
|
|
331
|
-
/** The type that vue-tsc reads for `<Cannot>`: the props of `<Can>`, and the refusal in the default slot. */
|
|
332
|
-
export type CannotComponent = <const Name extends AbilityName>(props: CanProps<Name>) => VNode & {
|
|
333
|
-
__ctx?: {
|
|
334
|
-
props: CanProps<Name>;
|
|
335
|
-
slots: CannotSlots<Name>;
|
|
336
|
-
};
|
|
337
|
-
};
|
|
338
|
-
/**
|
|
339
|
-
* The mirror of `<Can>`: shows its content, with the refusal, only when a rule from `shared/abilities.ts` refuses the
|
|
340
|
-
* visitor. It shows nothing when the rule allows, while the session is unknown, or while `pending` is `true`.
|
|
341
|
-
*
|
|
342
|
-
* @example
|
|
343
|
-
* <Cannot do="billing.upgrade" v-slot="{ code, details }">
|
|
344
|
-
* <UpgradeHint :code="code" :limit="details.limit" />
|
|
345
|
-
* </Cannot>
|
|
346
|
-
*/
|
|
347
|
-
export declare const Cannot: CannotComponent;
|
|
348
|
-
//#endregion
|
|
292
|
+
/** Render the allowed or denied slot. The default slot is shorthand for allowed. */
|
|
293
|
+
export declare const AuthPermission: AuthPermissionComponent;
|
|
349
294
|
export type { RequestFetch, VueAuthClient };
|
package/dist/vue.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { a as setRequestFetchResolver, i as setNuxtErrorFactory, n as setDefaultAuthBasePath, o as setSessionSeedResolver, r as setNuxtAppResolver, s as setSignOutHandler, t as authNuxtBridge } from "./nuxt-bridge-
|
|
1
|
+
import { n as checkAbility, t as AbilityError } from "./ability-error-BHhPkrZd.js";
|
|
2
|
+
import { i as resolveAuthMountPath } from "./application-path-zKi7NrvK.js";
|
|
3
|
+
import { a as setRequestFetchResolver, i as setNuxtErrorFactory, n as setDefaultAuthBasePath, o as setSessionSeedResolver, r as setNuxtAppResolver, s as setSignOutHandler, t as authNuxtBridge } from "./nuxt-bridge-pRyfYD5c.js";
|
|
4
4
|
import abilities from "#vitehub/auth/abilities";
|
|
5
5
|
import { computed, defineComponent, effectScope, getCurrentInstance, getCurrentScope, inject, onScopeDispose, onServerPrefetch, provide, shallowRef, watch } from "vue";
|
|
6
|
-
|
|
6
|
+
// src/vue.ts
|
|
7
7
|
const LOAD = Symbol.for("vitehub.auth.client.load");
|
|
8
8
|
const ON_LOAD = Symbol.for("vitehub.auth.client.on-load");
|
|
9
9
|
const OPTIONS = Symbol.for("vitehub.auth.client.options");
|
|
@@ -405,7 +405,7 @@ const authClient = createLazyAuthClient(async () => {
|
|
|
405
405
|
const { default: options } = await import("#vitehub/auth/client");
|
|
406
406
|
return withDefaultBasePath(options);
|
|
407
407
|
});
|
|
408
|
-
/** Provide the app's configured client to Auth composables and `<
|
|
408
|
+
/** Provide the app's configured client to Auth composables and `<AuthPermission>` in descendant components. */
|
|
409
409
|
function provideAuthClient(client) {
|
|
410
410
|
provide(authClientKey, client);
|
|
411
411
|
}
|
|
@@ -574,54 +574,30 @@ function useAbility(client = useAuthClient()) {
|
|
|
574
574
|
ready: computed(() => !state.value.isPending)
|
|
575
575
|
};
|
|
576
576
|
}
|
|
577
|
-
/** The
|
|
578
|
-
const
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
577
|
+
/** Render the allowed or denied slot. The default slot is shorthand for allowed. */
|
|
578
|
+
const AuthPermission = defineComponent({
|
|
579
|
+
name: "AuthPermission",
|
|
580
|
+
props: {
|
|
581
|
+
check: {
|
|
582
|
+
type: String,
|
|
583
|
+
required: true
|
|
584
|
+
},
|
|
585
|
+
args: {
|
|
586
|
+
type: Array,
|
|
587
|
+
default: () => []
|
|
588
|
+
},
|
|
589
|
+
pending: {
|
|
590
|
+
type: Boolean,
|
|
591
|
+
default: false
|
|
592
|
+
}
|
|
590
593
|
},
|
|
591
|
-
pending: {
|
|
592
|
-
type: Boolean,
|
|
593
|
-
default: false
|
|
594
|
-
}
|
|
595
|
-
};
|
|
596
|
-
/** The refusal of the rule that the props name. It follows the session, and is `undefined` while `pending` is `true`. */
|
|
597
|
-
function usePropsRefusal(props) {
|
|
598
|
-
const state = sessionState();
|
|
599
|
-
return computed(() => {
|
|
600
|
-
if (props.pending) return void 0;
|
|
601
|
-
const args = props.args ?? (props.with === void 0 ? [] : [props.with]);
|
|
602
|
-
return abilityRefusal(state.value, props.do, args);
|
|
603
|
-
});
|
|
604
|
-
}
|
|
605
|
-
/**
|
|
606
|
-
* Shows its content when a rule from `shared/abilities.ts` allows the visitor, the `#denied` slot with the refusal when
|
|
607
|
-
* it refuses, and nothing while the session is unknown or `pending` is `true`.
|
|
608
|
-
*
|
|
609
|
-
* @example
|
|
610
|
-
* <Can do="posts.edit" :with="post">
|
|
611
|
-
* <button>Edit</button>
|
|
612
|
-
* <template #denied="{ code }">{{ code }}</template>
|
|
613
|
-
* </Can>
|
|
614
|
-
* <Can do="posts.move" :args="[from, to]">Move</Can>
|
|
615
|
-
*/
|
|
616
|
-
const Can = defineComponent({
|
|
617
|
-
name: "Can",
|
|
618
|
-
props: abilityProps,
|
|
619
594
|
setup(props, { slots }) {
|
|
620
|
-
const
|
|
595
|
+
const state = sessionState();
|
|
596
|
+
const refusal = computed(() => props.pending ? void 0 : abilityRefusal(state.value, props.check, props.args));
|
|
621
597
|
return () => {
|
|
622
598
|
const value = refusal.value;
|
|
623
599
|
if (value === void 0) return null;
|
|
624
|
-
if (value === null) return slots.default?.();
|
|
600
|
+
if (value === null) return (slots.allowed ?? slots.default)?.();
|
|
625
601
|
return slots.denied?.({
|
|
626
602
|
code: value.code,
|
|
627
603
|
details: value.details
|
|
@@ -629,28 +605,4 @@ const Can = defineComponent({
|
|
|
629
605
|
};
|
|
630
606
|
}
|
|
631
607
|
});
|
|
632
|
-
|
|
633
|
-
* The mirror of `<Can>`: shows its content, with the refusal, only when a rule from `shared/abilities.ts` refuses the
|
|
634
|
-
* visitor. It shows nothing when the rule allows, while the session is unknown, or while `pending` is `true`.
|
|
635
|
-
*
|
|
636
|
-
* @example
|
|
637
|
-
* <Cannot do="billing.upgrade" v-slot="{ code, details }">
|
|
638
|
-
* <UpgradeHint :code="code" :limit="details.limit" />
|
|
639
|
-
* </Cannot>
|
|
640
|
-
*/
|
|
641
|
-
const Cannot = defineComponent({
|
|
642
|
-
name: "Cannot",
|
|
643
|
-
props: abilityProps,
|
|
644
|
-
setup(props, { slots }) {
|
|
645
|
-
const refusal = usePropsRefusal(props);
|
|
646
|
-
return () => {
|
|
647
|
-
const value = refusal.value;
|
|
648
|
-
return value ? slots.default?.({
|
|
649
|
-
code: value.code,
|
|
650
|
-
details: value.details
|
|
651
|
-
}) : null;
|
|
652
|
-
};
|
|
653
|
-
}
|
|
654
|
-
});
|
|
655
|
-
//#endregion
|
|
656
|
-
export { Can, Cannot, authClient, createAuthClient, defineAuthClient, loadAuthClient, onSignOut, provideAuthClient, setDefaultAuthBasePath, setNuxtAppResolver, setNuxtErrorFactory, setRequestFetchResolver, setSessionSeedResolver, setSignOutHandler, useAbility, useAuthClient, useUserSession };
|
|
608
|
+
export { AuthPermission, authClient, createAuthClient, defineAuthClient, loadAuthClient, onSignOut, provideAuthClient, setDefaultAuthBasePath, setNuxtAppResolver, setNuxtErrorFactory, setRequestFetchResolver, setSessionSeedResolver, setSignOutHandler, useAbility, useAuthClient, useUserSession };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vite-hub/auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Better Auth-powered authentication primitives and Vite integration for ViteHub.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"auth",
|
|
@@ -142,54 +142,59 @@
|
|
|
142
142
|
"./package.json": "./package.json"
|
|
143
143
|
},
|
|
144
144
|
"dependencies": {
|
|
145
|
-
"@noble/hashes": "^2.
|
|
146
|
-
"@types/node": "^24.19.
|
|
147
|
-
"@vite-hub/env": "0.
|
|
148
|
-
"@vite-hub/runtime": "0.
|
|
149
|
-
"@vite-hub/web-container": "0.
|
|
150
|
-
"better-auth": "^1.7.
|
|
145
|
+
"@noble/hashes": "^2.4.0",
|
|
146
|
+
"@types/node": "^24.19.2",
|
|
147
|
+
"@vite-hub/env": "0.5.1",
|
|
148
|
+
"@vite-hub/runtime": "0.5.1",
|
|
149
|
+
"@vite-hub/web-container": "0.5.1",
|
|
150
|
+
"better-auth": "^1.7.27",
|
|
151
151
|
"h3": "^2.0.8",
|
|
152
152
|
"nostics": "1.4.0",
|
|
153
153
|
"rou3": "^1.0.0",
|
|
154
|
-
"
|
|
154
|
+
"scule": "^1.3.0",
|
|
155
|
+
"unrouting": "^0.3.2",
|
|
156
|
+
"valibot": "^1.5.0",
|
|
157
|
+
"vue-router": "^5.5.1"
|
|
155
158
|
},
|
|
156
159
|
"devDependencies": {
|
|
157
|
-
"@better-auth/api-key": "1.7.
|
|
158
|
-
"@better-auth/oauth-provider": "^1.7.
|
|
159
|
-
"@better-auth/passkey": "1.7.
|
|
160
|
-
"@better-auth/stripe": "1.7.
|
|
161
|
-
"@cloudflare/workers-types": "^5.
|
|
160
|
+
"@better-auth/api-key": "1.7.27",
|
|
161
|
+
"@better-auth/oauth-provider": "^1.7.27",
|
|
162
|
+
"@better-auth/passkey": "1.7.27",
|
|
163
|
+
"@better-auth/stripe": "1.7.27",
|
|
164
|
+
"@cloudflare/workers-types": "^5.20261123.1",
|
|
162
165
|
"@types/json-schema": "^7.0.15",
|
|
163
166
|
"@types/mdast": "^4.0.4",
|
|
164
|
-
"@types/node": "^24.19.
|
|
165
|
-
"@vite-hub/agent": "0.
|
|
166
|
-
"@vite-hub/database": "0.
|
|
167
|
+
"@types/node": "^24.19.2",
|
|
168
|
+
"@vite-hub/agent": "0.5.1",
|
|
169
|
+
"@vite-hub/database": "0.5.1",
|
|
167
170
|
"@vite-hub/internal": "0.0.1",
|
|
168
|
-
"bun-types": "^1.4.
|
|
169
|
-
"
|
|
171
|
+
"bun-types": "^1.4.5",
|
|
172
|
+
"evlog": "2.37.1",
|
|
173
|
+
"happy-dom": "21.0.4",
|
|
170
174
|
"miniflare": "4.20260730.0",
|
|
171
175
|
"nitro": "^3.0.261103-rc",
|
|
172
176
|
"publint": "^0.3.25",
|
|
173
|
-
"stripe": "23.
|
|
177
|
+
"stripe": "23.2.0",
|
|
174
178
|
"typescript": "^6.0.3",
|
|
175
|
-
"undici": "8.
|
|
176
|
-
"vite": "^8.
|
|
177
|
-
"vite-plus": "^
|
|
178
|
-
"vitest": "
|
|
179
|
-
"vue": "3.5.
|
|
180
|
-
"drizzle-kit": "1.0.0-rc.
|
|
181
|
-
"drizzle-orm": "1.0.0-rc.
|
|
179
|
+
"undici": "8.13.1",
|
|
180
|
+
"vite": "^8.3.8",
|
|
181
|
+
"vite-plus": "^1.7.0",
|
|
182
|
+
"vitest": "5.1.0",
|
|
183
|
+
"vue": "3.5.46",
|
|
184
|
+
"drizzle-kit": "1.0.0-rc.6",
|
|
185
|
+
"drizzle-orm": "1.0.0-rc.6",
|
|
186
|
+
"postgres": "^3.4.9"
|
|
182
187
|
},
|
|
183
188
|
"peerDependencies": {
|
|
184
|
-
"@better-auth/oauth-provider": "^1.7.
|
|
189
|
+
"@better-auth/oauth-provider": "^1.7.27",
|
|
185
190
|
"@types/json-schema": "^7.0.15",
|
|
186
191
|
"@types/mdast": "^4.0.4",
|
|
187
|
-
"@vite-hub/agent": "0.
|
|
188
|
-
"@vite-hub/database": "0.
|
|
192
|
+
"@vite-hub/agent": "0.5.1",
|
|
193
|
+
"@vite-hub/database": "0.5.1",
|
|
189
194
|
"nitro": "3.0.261102-rc || ^3.0.261103-rc",
|
|
190
195
|
"vite": ">=8.0.0",
|
|
191
196
|
"vue": "^3.5.0",
|
|
192
|
-
"drizzle-orm": "1.0.0-rc.5 || ^1.0.0"
|
|
197
|
+
"drizzle-orm": "1.0.0-rc.5 || 1.0.0-rc.6 || ^1.0.0"
|
|
193
198
|
},
|
|
194
199
|
"peerDependenciesMeta": {
|
|
195
200
|
"@better-auth/oauth-provider": {
|
package/dist/shared-DRtfuFsV.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { t as authErrorDiagnostics } from "./error-diagnostics-Dymr-S_n.js";
|
|
2
|
-
//#region src/shared.ts
|
|
3
|
-
const defaultAuthBasePath = "/api/auth";
|
|
4
|
-
function normalizeAuthBasePath(value) {
|
|
5
|
-
const path = value?.trim() || defaultAuthBasePath;
|
|
6
|
-
if (!path.startsWith("/")) throw authErrorDiagnostics.AUTH_R0013({ message: "`defineAuth()` basePath must start with `/`." });
|
|
7
|
-
const normalized = path.replace(/\/+$/g, "");
|
|
8
|
-
if (!normalized) throw authErrorDiagnostics.AUTH_R0013({ message: "`defineAuth()` basePath must resolve to a non-empty path." });
|
|
9
|
-
return normalized;
|
|
10
|
-
}
|
|
11
|
-
//#endregion
|
|
12
|
-
export { normalizeAuthBasePath as t };
|