abckit 0.0.52 → 0.0.54

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/module.d.mts CHANGED
@@ -28,21 +28,11 @@ interface SetupConfig {
28
28
  };
29
29
  }
30
30
  interface AuthClientOptions {
31
- /**
32
- * Base URL for Better Auth client
33
- * Required for Capacitor/mobile apps where the default URL is not http/https
34
- * @example 'https://api.example.com'
35
- */
36
- baseURL?: string;
37
- /**
38
- * Base path for Better Auth API endpoints
39
- * @default '/api/auth'
40
- */
41
- basePath?: string;
42
31
  /**
43
32
  * Enable Capacitor mode for mobile apps
44
- * When enabled, uses Bearer token auth with @capacitor/preferences storage
45
- * @default false
33
+ * Injects Capacitor plugin via better-auth:config:extend hook
34
+ * Uses Bearer token auth with @capacitor/preferences storage
35
+ * @default false (or true if MOBILE_BUILD env is set)
46
36
  */
47
37
  capacitor?: boolean;
48
38
  /**
@@ -197,8 +187,6 @@ declare module '@nuxt/schema' {
197
187
  abckit: {
198
188
  sentry: boolean;
199
189
  auth: {
200
- baseURL?: string;
201
- basePath?: string;
202
190
  capacitor?: boolean;
203
191
  oauthProvider?: boolean;
204
192
  };
package/dist/module.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { updateRuntimeConfig, addTypeTemplate, addServerScanDir, addRouteMiddleware, defineNuxtModule, createResolver } from '@nuxt/kit';
1
+ import { updateRuntimeConfig, addTypeTemplate, addServerScanDir, addPlugin, defineNuxtModule, createResolver } from '@nuxt/kit';
2
2
  import { defu } from 'defu';
3
3
  import { join } from 'node:path';
4
4
  import { networkInterfaces } from 'node:os';
@@ -28,6 +28,7 @@ function getModuleDependencies(nuxt) {
28
28
  const opts = nuxt.options.abckit;
29
29
  const isEnabled = createModuleChecker(opts);
30
30
  return {
31
+ "@onmax/nuxt-better-auth": { optional: false },
31
32
  "@nuxtjs/tailwindcss": { optional: !isEnabled("tailwindcss") },
32
33
  "notivue/nuxt": { optional: !isEnabled("notivue") },
33
34
  "@nuxt/icon": { optional: !isEnabled("icon") },
@@ -97,8 +98,8 @@ const ALIAS_PATHS = {
97
98
  "abckit/components": "./runtime/components",
98
99
  "abckit/shadcn": "./runtime/components/ui",
99
100
  "abckit/composables": "./runtime/composables",
100
- "abckit/middleware": "./runtime/middleware",
101
101
  "abckit/plugins": "./runtime/plugins",
102
+ "abckit/plugins/capacitor": "./runtime/plugins/capacitor-client",
102
103
  "abckit/graphql": "./runtime/graphql",
103
104
  "abckit/stores": "./runtime/stores",
104
105
  "abckit/utils": "./runtime/utils",
@@ -115,6 +116,9 @@ const NPM_TS_PATHS = {
115
116
  const H3_TYPE_TEMPLATE = `
116
117
  declare module 'nitro/h3' {
117
118
  interface H3EventContext {
119
+ /**
120
+ * @deprecated Use getUserSession(event) or requireUserSession(event) from nuxt-better-auth
121
+ */
118
122
  auth: {
119
123
  user: {
120
124
  id: string
@@ -124,7 +128,7 @@ declare module 'nitro/h3' {
124
128
  image?: string
125
129
  createdAt: Date
126
130
  updatedAt: Date
127
- role: string
131
+ role?: string
128
132
  }
129
133
  session: {
130
134
  id: string
@@ -141,8 +145,8 @@ declare module 'nitro/h3' {
141
145
  statusCode: number
142
146
  statusMessage: string
143
147
  }
144
- isPremium: boolean
145
- subscription: any | null
148
+ isPremium?: boolean
149
+ subscription?: any | null
146
150
  }
147
151
  }
148
152
 
@@ -169,9 +173,7 @@ async function setupRuntimeConfig(nuxt, options, isSentryEnabled) {
169
173
  nuxt.options.runtimeConfig.public.abckit = {
170
174
  sentry: isSentryEnabled,
171
175
  auth: {
172
- baseURL: isMobileBuild ? mobileBaseURL : nuxt.options.runtimeConfig.public.abckit?.auth?.baseURL ?? options.auth?.baseURL,
173
- basePath: nuxt.options.runtimeConfig.public.abckit?.auth?.basePath ?? options.auth?.basePath,
174
- capacitor: isMobileBuild,
176
+ capacitor: options.auth?.capacitor ?? isMobileBuild,
175
177
  oauthProvider: options.auth?.oauthProvider ?? false
176
178
  }
177
179
  };
@@ -298,9 +300,9 @@ function setupColorMode(nuxt) {
298
300
  }
299
301
  function setupRouting(nuxt, resolve) {
300
302
  addServerScanDir(resolve("./runtime/server"));
301
- addRouteMiddleware({
302
- name: "auth",
303
- path: resolve("./runtime/middleware/auth")
303
+ addPlugin({
304
+ src: resolve("./runtime/plugins/sentry-user.client"),
305
+ mode: "client"
304
306
  });
305
307
  nuxt.options.routeRules = nuxt.options.routeRules || {};
306
308
  nuxt.options.routeRules["/**"] = defu(nuxt.options.routeRules["/**"] || {}, { ssr: false });
@@ -328,6 +330,32 @@ function setupDevtools(nuxt) {
328
330
  enabled: false
329
331
  });
330
332
  }
333
+ function setupBetterAuth(nuxt, options, _resolve) {
334
+ const isCapacitor = options.auth?.capacitor ?? isMobileBuild;
335
+ nuxt.options["nuxt-better-auth"] = defu(nuxt.options["nuxt-better-auth"] || {}, {
336
+ clientOnly: isCapacitor,
337
+ redirects: {
338
+ login: "/auth/login",
339
+ guest: "/"
340
+ }
341
+ });
342
+ nuxt.hook("better-auth:config:extend", async (config) => {
343
+ const plugins = config.plugins || [];
344
+ const { adminClient } = await import('better-auth/client/plugins');
345
+ plugins.push(adminClient());
346
+ if (isCapacitor) {
347
+ const { capacitorClient } = await import('../dist/runtime/plugins/capacitor-client.js');
348
+ plugins.push(capacitorClient({
349
+ storagePrefix: "better-auth"
350
+ }));
351
+ }
352
+ if (options.auth?.oauthProvider) {
353
+ const { oauthProviderClient } = await import('@better-auth/oauth-provider/client');
354
+ plugins.push(oauthProviderClient());
355
+ }
356
+ config.plugins = plugins;
357
+ });
358
+ }
331
359
 
332
360
  const FEATURE_GROUPS = {
333
361
  core: {
@@ -475,8 +503,6 @@ const module$1 = defineNuxtModule({
475
503
  disk: false
476
504
  },
477
505
  auth: {
478
- baseURL: isMobileBuild ? mobileBaseURL : void 0,
479
- basePath: "/api/auth",
480
506
  capacitor: isMobileBuild
481
507
  },
482
508
  npm: false
@@ -512,6 +538,7 @@ const module$1 = defineNuxtModule({
512
538
  setupTypeScript(nuxt);
513
539
  setupColorMode(nuxt);
514
540
  setupRouting(nuxt, resolve);
541
+ setupBetterAuth(nuxt, options);
515
542
  }
516
543
  });
517
544
 
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Sentry user tracking plugin
3
+ * Sets user context in Sentry when authenticated
4
+ */
5
+ declare const _default: import("#app").Plugin<Record<string, unknown>> & import("#app").ObjectPlugin<Record<string, unknown>>;
6
+ export default _default;
@@ -0,0 +1,13 @@
1
+ import { defineNuxtPlugin, useRuntimeConfig } from "#app";
2
+ import { useUserSession } from "#imports";
3
+ import { watch } from "vue";
4
+ export default defineNuxtPlugin(() => {
5
+ const config = useRuntimeConfig();
6
+ if (!config.public.abckit?.sentry)
7
+ return;
8
+ const { user } = useUserSession();
9
+ watch(user, async (currentUser) => {
10
+ const Sentry = await import("@sentry/nuxt");
11
+ Sentry.setUser(currentUser ? { id: currentUser.id } : null);
12
+ }, { immediate: true });
13
+ });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "abckit",
3
3
  "type": "module",
4
- "version": "0.0.52",
4
+ "version": "0.0.54",
5
5
  "description": "Nuxt 4 module — UI components, auth, storage, GraphQL",
6
6
  "author": "productdevbook",
7
7
  "license": "MIT",
@@ -62,6 +62,10 @@
62
62
  "./colada": {
63
63
  "types": "./dist/runtime/colada.options.d.ts",
64
64
  "import": "./dist/runtime/colada.options.js"
65
+ },
66
+ "./plugins/capacitor": {
67
+ "types": "./dist/runtime/plugins/capacitor-client.d.ts",
68
+ "import": "./dist/runtime/plugins/capacitor-client.js"
65
69
  }
66
70
  },
67
71
  "types": "./dist/module.d.mts",
@@ -77,6 +81,7 @@
77
81
  },
78
82
  "peerDependencies": {
79
83
  "@better-auth/oauth-provider": "^1.4.12",
84
+ "@onmax/nuxt-better-auth": "^0.0.2-alpha.17",
80
85
  "@capacitor/android": "^8.0.1",
81
86
  "@capacitor/app": "^8.0.0",
82
87
  "@capacitor/browser": "^8.0.0",
@@ -154,6 +159,9 @@
154
159
  "@better-auth/oauth-provider": {
155
160
  "optional": true
156
161
  },
162
+ "@onmax/nuxt-better-auth": {
163
+ "optional": true
164
+ },
157
165
  "@capacitor/android": {
158
166
  "optional": true
159
167
  },