abckit 0.0.72 → 0.0.74

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.
@@ -10,19 +10,19 @@ declare const __VLS_export: <T extends ZodObjectOrWrapped>(__VLS_props: NonNulla
10
10
  dependencies?: Dependency<z.infer<T>>[];
11
11
  initialValues?: Partial<z.infer<T>>;
12
12
  } & {
13
- onSubmit?: ((event: z.core.output<T>) => any) | undefined;
13
+ onSubmit?: ((event: z.TypeOf<T>) => any) | undefined;
14
14
  }> & (typeof globalThis extends {
15
15
  __VLS_PROPS_FALLBACK: infer P;
16
16
  } ? P : {});
17
17
  expose: (exposed: {}) => void;
18
18
  attrs: any;
19
- slots: { [K in NonNullable<keyof z.core.output<T>>]?: ((props: {
19
+ slots: { [K in NonNullable<keyof z.TypeOf<T>>]?: ((props: {
20
20
  shape: unknown;
21
21
  fieldName: string;
22
22
  config: ConfigItem;
23
23
  }) => any) | undefined; } & {
24
24
  customAutoForm?: (props: {
25
- fields: { [key in keyof z.core.output<T>]: {
25
+ fields: { [key in keyof z.TypeOf<T>]: {
26
26
  shape: Shape;
27
27
  fieldName: string;
28
28
  config: ConfigItem;
@@ -33,7 +33,7 @@ declare const __VLS_export: <T extends ZodObjectOrWrapped>(__VLS_props: NonNulla
33
33
  shapes: { [key in keyof T]: Shape; };
34
34
  }) => any;
35
35
  };
36
- emit: (evt: "submit", event: z.core.output<T>) => void;
36
+ emit: (evt: "submit", event: z.TypeOf<T>) => void;
37
37
  }>) => import("vue").VNode & {
38
38
  __ctx?: Awaited<typeof __VLS_setup>;
39
39
  };
@@ -10,19 +10,19 @@ declare const __VLS_export: <T extends ZodObjectOrWrapped>(__VLS_props: NonNulla
10
10
  dependencies?: Dependency<z.infer<T>>[];
11
11
  initialValues?: Partial<z.infer<T>>;
12
12
  } & {
13
- onSubmit?: ((event: z.core.output<T>) => any) | undefined;
13
+ onSubmit?: ((event: z.TypeOf<T>) => any) | undefined;
14
14
  }> & (typeof globalThis extends {
15
15
  __VLS_PROPS_FALLBACK: infer P;
16
16
  } ? P : {});
17
17
  expose: (exposed: {}) => void;
18
18
  attrs: any;
19
- slots: { [K in NonNullable<keyof z.core.output<T>>]?: ((props: {
19
+ slots: { [K in NonNullable<keyof z.TypeOf<T>>]?: ((props: {
20
20
  shape: unknown;
21
21
  fieldName: string;
22
22
  config: ConfigItem;
23
23
  }) => any) | undefined; } & {
24
24
  customAutoForm?: (props: {
25
- fields: { [key in keyof z.core.output<T>]: {
25
+ fields: { [key in keyof z.TypeOf<T>]: {
26
26
  shape: Shape;
27
27
  fieldName: string;
28
28
  config: ConfigItem;
@@ -33,7 +33,7 @@ declare const __VLS_export: <T extends ZodObjectOrWrapped>(__VLS_props: NonNulla
33
33
  shapes: { [key in keyof T]: Shape; };
34
34
  }) => any;
35
35
  };
36
- emit: (evt: "submit", event: z.core.output<T>) => void;
36
+ emit: (evt: "submit", event: z.TypeOf<T>) => void;
37
37
  }>) => import("vue").VNode & {
38
38
  __ctx?: Awaited<typeof __VLS_setup>;
39
39
  };
@@ -1,6 +1,30 @@
1
1
  import type { Ref } from 'vue';
2
2
  import { type Dependency, type EnumValues } from './interface.js';
3
- export declare const injectDependencies: <T extends Ref<Dependency<Record<string, unknown>>[] | undefined, Dependency<Record<string, unknown>>[] | undefined> | null | undefined = Ref<Dependency<Record<string, unknown>>[] | undefined, Dependency<Record<string, unknown>>[] | undefined>>(fallback?: T | undefined) => T extends null ? Ref<Dependency<Record<string, unknown>>[] | undefined, Dependency<Record<string, unknown>>[] | undefined> | null : Ref<Dependency<Record<string, unknown>>[] | undefined, Dependency<Record<string, unknown>>[] | undefined>, provideDependencies: (contextValue: Ref<Dependency<Record<string, unknown>>[] | undefined, Dependency<Record<string, unknown>>[] | undefined>) => Ref<Dependency<Record<string, unknown>>[] | undefined, Dependency<Record<string, unknown>>[] | undefined>;
3
+ export declare const injectDependencies: <T extends Ref<Dependency<{
4
+ [x: string]: any;
5
+ }>[] | undefined, Dependency<{
6
+ [x: string]: any;
7
+ }>[] | undefined> | null | undefined = Ref<Dependency<{
8
+ [x: string]: any;
9
+ }>[] | undefined, Dependency<{
10
+ [x: string]: any;
11
+ }>[] | undefined>>(fallback?: T | undefined) => T extends null ? Ref<Dependency<{
12
+ [x: string]: any;
13
+ }>[] | undefined, Dependency<{
14
+ [x: string]: any;
15
+ }>[] | undefined> | null : Ref<Dependency<{
16
+ [x: string]: any;
17
+ }>[] | undefined, Dependency<{
18
+ [x: string]: any;
19
+ }>[] | undefined>, provideDependencies: (contextValue: Ref<Dependency<{
20
+ [x: string]: any;
21
+ }>[] | undefined, Dependency<{
22
+ [x: string]: any;
23
+ }>[] | undefined>) => Ref<Dependency<{
24
+ [x: string]: any;
25
+ }>[] | undefined, Dependency<{
26
+ [x: string]: any;
27
+ }>[] | undefined>;
4
28
  export default function useDependencies(fieldName: string): {
5
29
  isDisabled: Ref<boolean, boolean>;
6
30
  isHidden: Ref<boolean, boolean>;
@@ -21,7 +21,7 @@ z.ZodEffects<ChildType>): ChildType | null;
21
21
  * Get the type name of the lowest level Zod type.
22
22
  * This will unpack optionals, refinements, etc.
23
23
  */
24
- export declare function getBaseType(schema: z.ZodAny): any;
24
+ export declare function getBaseType(schema: z.ZodAny): "" | z.ZodFirstPartyTypeKind.ZodAny;
25
25
  /**
26
26
  * Search for a "ZodDefault" in the Zod stack and return its value.
27
27
  */
@@ -1,4 +1,27 @@
1
1
  import type { BetterAuthClientPlugin } from 'better-auth';
2
+ /**
3
+ * Synchronous platform check using window.Capacitor global
4
+ * Safe to call at build time (returns false when window is undefined)
5
+ */
6
+ export declare function isNativePlatform(): boolean;
7
+ export interface GetCapacitorAuthTokenOptions {
8
+ /**
9
+ * Prefix for storage keys
10
+ * @default 'better-auth'
11
+ */
12
+ storagePrefix?: string;
13
+ /**
14
+ * Cookie prefix used by better-auth
15
+ * @default 'better-auth'
16
+ */
17
+ cookiePrefix?: string;
18
+ }
19
+ /**
20
+ * Get the bearer token from Capacitor Preferences storage
21
+ * Useful for adding Authorization header to fetch requests in native apps
22
+ * @returns The bearer token or null if not found/not native
23
+ */
24
+ export declare function getCapacitorAuthToken(opts?: GetCapacitorAuthTokenOptions): Promise<string | null>;
2
25
  export interface CapacitorClientOptions {
3
26
  /**
4
27
  * Prefix for storage keys
@@ -1,4 +1,4 @@
1
- import { safeJSONParse } from "@better-auth/core/utils/json";
1
+ import { safeJSONParse } from "@better-auth/core/utils";
2
2
  import {
3
3
  parseSetCookieHeader,
4
4
  SECURE_COOKIE_PREFIX,
@@ -25,12 +25,30 @@ async function getAppMod() {
25
25
  }
26
26
  return _AppMod;
27
27
  }
28
- function isNativePlatform() {
28
+ export function isNativePlatform() {
29
29
  if (typeof window === "undefined")
30
30
  return false;
31
31
  const win = window;
32
32
  return win.Capacitor?.isNativePlatform?.() ?? false;
33
33
  }
34
+ export async function getCapacitorAuthToken(opts) {
35
+ if (!isNativePlatform())
36
+ return null;
37
+ const storagePrefix = opts?.storagePrefix || "better-auth";
38
+ const cookiePrefix = opts?.cookiePrefix || "better-auth";
39
+ const cookieName = `${storagePrefix}_cookie`;
40
+ try {
41
+ const { Preferences } = await getPreferencesMod();
42
+ const storedCookie = (await Preferences.get({ key: normalizeCookieName(cookieName) }))?.value;
43
+ if (!storedCookie)
44
+ return null;
45
+ const cookieData = JSON.parse(storedCookie);
46
+ const tokenKey = cookieData[`${SECURE_COOKIE_PREFIX}${cookiePrefix}.session_token`] ? `${SECURE_COOKIE_PREFIX}${cookiePrefix}.session_token` : `${cookiePrefix}.session_token`;
47
+ return cookieData[tokenKey]?.value || null;
48
+ } catch {
49
+ return null;
50
+ }
51
+ }
34
52
  let managersInitialized = false;
35
53
  async function initializeManagers() {
36
54
  if (managersInitialized || !isNativePlatform())
@@ -77,13 +95,8 @@ export function getCookie(cookie) {
77
95
  } catch {
78
96
  return "";
79
97
  }
80
- const toSend = Object.entries(parsed).reduce((acc, [key, value]) => {
81
- if (value.expires && new Date(value.expires) < /* @__PURE__ */ new Date()) {
82
- return acc;
83
- }
84
- return `${acc}; ${key}=${value.value}`;
85
- }, "");
86
- return toSend;
98
+ const validCookies = Object.entries(parsed).filter(([, value]) => !value.expires || new Date(value.expires) >= /* @__PURE__ */ new Date()).map(([key, value]) => `${key}=${value.value}`);
99
+ return validCookies.join("; ");
87
100
  }
88
101
  export function hasBetterAuthCookies(setCookieHeader, cookiePrefix) {
89
102
  const cookies = parseSetCookieHeader(setCookieHeader);
@@ -289,12 +302,19 @@ export function capacitorClient(opts) {
289
302
  const { Preferences } = await getPreferencesMod();
290
303
  const normalizedCookieName = normalizeCookieName(cookieName);
291
304
  const storedCookie = (await Preferences.get({ key: normalizedCookieName }))?.value;
292
- const cookie = getCookie(storedCookie || "{}");
305
+ let bearerToken = null;
306
+ try {
307
+ const cookieData = JSON.parse(storedCookie || "{}");
308
+ const prefixStr = Array.isArray(cookiePrefix) ? cookiePrefix[0] : cookiePrefix;
309
+ const tokenKey = cookieData[`${SECURE_COOKIE_PREFIX}${prefixStr}.session_token`] ? `${SECURE_COOKIE_PREFIX}${prefixStr}.session_token` : `${prefixStr}.session_token`;
310
+ bearerToken = cookieData[tokenKey]?.value || null;
311
+ } catch {
312
+ }
293
313
  options = options || {};
294
314
  options.credentials = "omit";
295
315
  options.headers = {
296
316
  ...options.headers,
297
- cookie
317
+ ...bearerToken ? { Authorization: `Bearer ${bearerToken}` } : {}
298
318
  };
299
319
  if (scheme) {
300
320
  options.headers = {
@@ -1,5 +1,5 @@
1
- export { capacitorClient, getCookie, getSetCookie, hasBetterAuthCookies, normalizeCookieName, parseSetCookieHeader, } from './client.js';
2
- export type { CapacitorClientOptions } from './client.js';
1
+ export { capacitorClient, getCapacitorAuthToken, getCookie, getSetCookie, hasBetterAuthCookies, isNativePlatform, normalizeCookieName, parseSetCookieHeader, } from './client.js';
2
+ export type { CapacitorClientOptions, GetCapacitorAuthTokenOptions } from './client.js';
3
3
  export { setupCapacitorFocusManager } from './focus-manager.js';
4
4
  export { setupCapacitorOnlineManager } from './online-manager.js';
5
5
  export * from './plugins/index.js';
@@ -1,8 +1,10 @@
1
1
  export {
2
2
  capacitorClient,
3
+ getCapacitorAuthToken,
3
4
  getCookie,
4
5
  getSetCookie,
5
6
  hasBetterAuthCookies,
7
+ isNativePlatform,
6
8
  normalizeCookieName,
7
9
  parseSetCookieHeader
8
10
  } from "./client.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "abckit",
3
3
  "type": "module",
4
- "version": "0.0.72",
4
+ "version": "0.0.74",
5
5
  "description": "Nuxt 4 module — UI components, auth, storage, GraphQL",
6
6
  "author": "productdevbook",
7
7
  "license": "MIT",
@@ -81,6 +81,7 @@
81
81
  "dist"
82
82
  ],
83
83
  "dependencies": {
84
+ "@better-auth/core": "^1.4.17",
84
85
  "class-variance-authority": "^0.7.1",
85
86
  "clsx": "^2.1.1",
86
87
  "consola": "^3.4.2",
@@ -89,7 +90,6 @@
89
90
  },
90
91
  "peerDependencies": {
91
92
  "@better-auth/oauth-provider": "^1.4.12",
92
- "better-auth-nuxt": "^0.0.2-beta.24",
93
93
  "@capacitor/android": "^8.0.1",
94
94
  "@capacitor/app": "^8.0.0",
95
95
  "@capacitor/browser": "^8.0.0",
@@ -132,6 +132,7 @@
132
132
  "apiful": "^4.0.1",
133
133
  "aws4fetch": "^1.0.20",
134
134
  "better-auth": "^1.4.12",
135
+ "better-auth-nuxt": "^0.0.2-beta.24",
135
136
  "capacitor-native-settings": "^7.0.2",
136
137
  "dataloader": "^2.2.3",
137
138
  "date-fns": "^4.1.0",
@@ -301,22 +302,22 @@
301
302
  }
302
303
  },
303
304
  "devDependencies": {
304
- "@antfu/eslint-config": "^7.0.0",
305
+ "@antfu/eslint-config": "^7.2.0",
305
306
  "@nuxt/eslint": "latest",
306
307
  "@nuxt/kit": "https://pkg.pr.new/@nuxt/kit@33005",
307
308
  "@nuxt/module-builder": "^1.0.2",
308
309
  "@nuxt/schema": "https://pkg.pr.new/@nuxt/schema@33005",
309
- "@types/node": "^25.0.8",
310
+ "@types/node": "^25.0.10",
310
311
  "@types/pg": "^8.16.0",
311
312
  "eslint": "^9.39.2",
312
- "nitro": "https://pkg.pr.new/nitrojs/nitro@99691fc",
313
+ "nitro": "3.0.1-alpha.2",
313
314
  "nuxt": "https://pkg.pr.new/nuxt@33005",
314
- "rolldown": "1.0.0-beta.60",
315
+ "rolldown": "1.0.0-rc.1",
315
316
  "shadcn-vue": "^2.4.3",
316
317
  "typescript": "^5.9.3",
317
- "vite-tsconfig-paths": "^6.0.4",
318
- "vue": "^3.5.26",
319
- "vue-tsc": "^3.2.2"
318
+ "vite-tsconfig-paths": "^6.0.5",
319
+ "vue": "^3.5.27",
320
+ "vue-tsc": "^3.2.4"
320
321
  },
321
322
  "resolutions": {
322
323
  "abckit": "workspace:*"
@@ -325,11 +326,9 @@
325
326
  "@nuxt/kit": "https://pkg.pr.new/@nuxt/kit@33005",
326
327
  "@nuxt/schema": "https://pkg.pr.new/@nuxt/schema@33005",
327
328
  "entities": "7.0.0",
328
- "nuxt": "https://pkg.pr.new/nuxt@33005"
329
- },
330
- "patchedDependencies": {
331
- "entities@7.0.0": "patches/entities@7.0.0.patch",
332
- "entities@7.0.0@7.0.0": "patches/entities@7.0.0.patch"
329
+ "nuxt": "https://pkg.pr.new/nuxt@33005",
330
+ "nitro": "3.0.1-alpha.2",
331
+ "vite": "8.0.0-beta.10"
333
332
  },
334
333
  "scripts": {
335
334
  "build": "nuxt-module-build build",