abckit 0.0.34 → 0.0.36
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.
|
@@ -21,12 +21,18 @@ async function initOfflineSession(isCapacitor) {
|
|
|
21
21
|
offlineChecked.value = true;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
+
function isCapacitorNative() {
|
|
25
|
+
if (typeof window === "undefined")
|
|
26
|
+
return false;
|
|
27
|
+
const cap = window.Capacitor;
|
|
28
|
+
return cap?.isNativePlatform?.() ?? false;
|
|
29
|
+
}
|
|
24
30
|
function getAuthClient() {
|
|
25
31
|
if (authClient)
|
|
26
32
|
return authClient;
|
|
27
33
|
const config = useRuntimeConfig();
|
|
28
34
|
const authConfig = config.public.abckit?.auth;
|
|
29
|
-
const isCapacitor = authConfig?.capacitor ??
|
|
35
|
+
const isCapacitor = authConfig?.capacitor ?? isCapacitorNative();
|
|
30
36
|
initOfflineSession(isCapacitor);
|
|
31
37
|
const plugins = [adminClient()];
|
|
32
38
|
if (authConfig?.oauthProvider) {
|
|
@@ -48,7 +54,7 @@ export function useAuth() {
|
|
|
48
54
|
const client = getAuthClient();
|
|
49
55
|
const session = client.useSession();
|
|
50
56
|
const config = useRuntimeConfig();
|
|
51
|
-
const isCapacitor = config.public.abckit?.auth?.capacitor ??
|
|
57
|
+
const isCapacitor = config.public.abckit?.auth?.capacitor ?? isCapacitorNative();
|
|
52
58
|
const isLoading = computed(() => {
|
|
53
59
|
if (session.value.isPending)
|
|
54
60
|
return true;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import { Preferences } from "@capacitor/preferences";
|
|
2
1
|
import { kFocusManager, kOnlineManager } from "better-auth/client";
|
|
2
|
+
let Preferences = null;
|
|
3
|
+
async function getPreferences() {
|
|
4
|
+
if (!Preferences) {
|
|
5
|
+
const mod = await import("@capacitor/preferences");
|
|
6
|
+
Preferences = mod.Preferences;
|
|
7
|
+
}
|
|
8
|
+
return Preferences;
|
|
9
|
+
}
|
|
3
10
|
class CapacitorFocusManager {
|
|
4
11
|
listeners = /* @__PURE__ */ new Set();
|
|
5
12
|
unsubscribe;
|
|
@@ -216,14 +223,16 @@ export function capacitorClient(opts) {
|
|
|
216
223
|
* Get stored cookie string for manual fetch requests
|
|
217
224
|
*/
|
|
218
225
|
getCookie: async () => {
|
|
219
|
-
const
|
|
226
|
+
const prefs = await getPreferences();
|
|
227
|
+
const result = await prefs.get({ key: cookieName });
|
|
220
228
|
return getCookieString(result?.value || "{}");
|
|
221
229
|
},
|
|
222
230
|
/**
|
|
223
231
|
* Get cached session data for offline use
|
|
224
232
|
*/
|
|
225
233
|
getCachedSession: async () => {
|
|
226
|
-
const
|
|
234
|
+
const prefs = await getPreferences();
|
|
235
|
+
const result = await prefs.get({ key: sessionCacheName });
|
|
227
236
|
if (!result?.value)
|
|
228
237
|
return null;
|
|
229
238
|
try {
|
|
@@ -236,8 +245,9 @@ export function capacitorClient(opts) {
|
|
|
236
245
|
* Clear all stored auth data
|
|
237
246
|
*/
|
|
238
247
|
clearStorage: async () => {
|
|
239
|
-
|
|
240
|
-
await
|
|
248
|
+
const prefs = await getPreferences();
|
|
249
|
+
await prefs.remove({ key: cookieName });
|
|
250
|
+
await prefs.remove({ key: sessionCacheName });
|
|
241
251
|
}
|
|
242
252
|
};
|
|
243
253
|
},
|
|
@@ -247,34 +257,35 @@ export function capacitorClient(opts) {
|
|
|
247
257
|
name: "Capacitor Auth",
|
|
248
258
|
hooks: {
|
|
249
259
|
async onSuccess(context) {
|
|
260
|
+
const prefs = await getPreferences();
|
|
250
261
|
const authToken = context.response.headers.get("set-auth-token");
|
|
251
262
|
if (authToken) {
|
|
252
|
-
const prevCookie = (await
|
|
263
|
+
const prevCookie = (await prefs.get({ key: cookieName }))?.value;
|
|
253
264
|
const tokenCookie = `${cookiePrefix}.session_token=${authToken}`;
|
|
254
265
|
const newCookie = mergeCookies(tokenCookie, prevCookie ?? void 0);
|
|
255
266
|
if (hasSessionCookieChanged(prevCookie ?? null, newCookie)) {
|
|
256
|
-
await
|
|
267
|
+
await prefs.set({ key: cookieName, value: newCookie });
|
|
257
268
|
store?.notify("$sessionSignal");
|
|
258
269
|
} else {
|
|
259
|
-
await
|
|
270
|
+
await prefs.set({ key: cookieName, value: newCookie });
|
|
260
271
|
}
|
|
261
272
|
}
|
|
262
273
|
const setCookie = context.response.headers.get("set-cookie");
|
|
263
274
|
if (setCookie) {
|
|
264
275
|
if (hasBetterAuthCookies(setCookie, cookiePrefix)) {
|
|
265
|
-
const prevCookie = (await
|
|
276
|
+
const prevCookie = (await prefs.get({ key: cookieName }))?.value;
|
|
266
277
|
const newCookie = mergeCookies(setCookie, prevCookie ?? void 0);
|
|
267
278
|
if (hasSessionCookieChanged(prevCookie ?? null, newCookie)) {
|
|
268
|
-
await
|
|
279
|
+
await prefs.set({ key: cookieName, value: newCookie });
|
|
269
280
|
store?.notify("$sessionSignal");
|
|
270
281
|
} else {
|
|
271
|
-
await
|
|
282
|
+
await prefs.set({ key: cookieName, value: newCookie });
|
|
272
283
|
}
|
|
273
284
|
}
|
|
274
285
|
}
|
|
275
286
|
if (context.request.url.toString().includes("/get-session")) {
|
|
276
287
|
if (context.data?.session || context.data?.user) {
|
|
277
|
-
await
|
|
288
|
+
await prefs.set({
|
|
278
289
|
key: sessionCacheName,
|
|
279
290
|
value: JSON.stringify(context.data)
|
|
280
291
|
});
|
|
@@ -283,7 +294,8 @@ export function capacitorClient(opts) {
|
|
|
283
294
|
}
|
|
284
295
|
},
|
|
285
296
|
async init(url, options) {
|
|
286
|
-
const
|
|
297
|
+
const prefs = await getPreferences();
|
|
298
|
+
const storedCookie = (await prefs.get({ key: cookieName }))?.value;
|
|
287
299
|
const cookie = getCookieString(storedCookie || "{}");
|
|
288
300
|
if (cookie) {
|
|
289
301
|
options = options || {};
|
|
@@ -293,8 +305,8 @@ export function capacitorClient(opts) {
|
|
|
293
305
|
};
|
|
294
306
|
}
|
|
295
307
|
if (url.includes("/sign-out")) {
|
|
296
|
-
await
|
|
297
|
-
await
|
|
308
|
+
await prefs.remove({ key: cookieName });
|
|
309
|
+
await prefs.remove({ key: sessionCacheName });
|
|
298
310
|
if (store?.atoms?.session) {
|
|
299
311
|
const currentSession = store.atoms.session.get();
|
|
300
312
|
store.atoms.session.set({
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "abckit",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.36",
|
|
5
5
|
"description": "Nuxt 4 module — UI components, auth, storage, GraphQL",
|
|
6
6
|
"author": "productdevbook",
|
|
7
7
|
"license": "MIT",
|
|
@@ -71,28 +71,17 @@
|
|
|
71
71
|
"files": [
|
|
72
72
|
"dist"
|
|
73
73
|
],
|
|
74
|
-
"scripts": {
|
|
75
|
-
"build": "nuxt-module-build build",
|
|
76
|
-
"prepack": "nuxt-module-build build",
|
|
77
|
-
"dev": "nuxt dev playground",
|
|
78
|
-
"dev:build": "nuxi build playground",
|
|
79
|
-
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
80
|
-
"lint": "eslint .",
|
|
81
|
-
"lint:fix": "eslint . --fix",
|
|
82
|
-
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
|
|
83
|
-
"release": "pnpm publish --no-git-checks --access public"
|
|
84
|
-
},
|
|
85
74
|
"dependencies": {
|
|
86
75
|
"@better-auth/oauth-provider": "^1.4.9",
|
|
87
|
-
"@capacitor/android": "
|
|
76
|
+
"@capacitor/android": "^8.0.0",
|
|
88
77
|
"@capacitor/app": "^8.0.0",
|
|
89
78
|
"@capacitor/browser": "^8.0.0",
|
|
90
|
-
"@capacitor/cli": "
|
|
79
|
+
"@capacitor/cli": "^8.0.0",
|
|
91
80
|
"@capacitor/core": "^8.0.0",
|
|
92
81
|
"@capacitor/device": "^8.0.0",
|
|
93
|
-
"@capacitor/geolocation": "^
|
|
82
|
+
"@capacitor/geolocation": "^8.0.0",
|
|
94
83
|
"@capacitor/haptics": "^8.0.0",
|
|
95
|
-
"@capacitor/ios": "
|
|
84
|
+
"@capacitor/ios": "^8.0.0",
|
|
96
85
|
"@capacitor/network": "^8.0.0",
|
|
97
86
|
"@capacitor/preferences": "^8.0.0",
|
|
98
87
|
"@capacitor/push-notifications": "^8.0.0",
|
|
@@ -177,6 +166,90 @@
|
|
|
177
166
|
"typescript": "^5.9.3",
|
|
178
167
|
"vue": "^3.5.26"
|
|
179
168
|
},
|
|
169
|
+
"peerDependencies": {
|
|
170
|
+
"@better-auth/oauth-provider": "^1.4.9",
|
|
171
|
+
"@capacitor/android": "^8.0.0",
|
|
172
|
+
"@capacitor/app": "^8.0.0",
|
|
173
|
+
"@capacitor/browser": "^8.0.0",
|
|
174
|
+
"@capacitor/cli": "^8.0.0",
|
|
175
|
+
"@capacitor/core": "^8.0.0",
|
|
176
|
+
"@capacitor/device": "^8.0.0",
|
|
177
|
+
"@capacitor/geolocation": "^8.0.0",
|
|
178
|
+
"@capacitor/haptics": "^8.0.0",
|
|
179
|
+
"@capacitor/ios": "^8.0.0",
|
|
180
|
+
"@capacitor/network": "^8.0.0",
|
|
181
|
+
"@capacitor/preferences": "^8.0.0",
|
|
182
|
+
"@capacitor/push-notifications": "^8.0.0",
|
|
183
|
+
"@capacitor/splash-screen": "^8.0.0",
|
|
184
|
+
"@capacitor/status-bar": "^8.0.0",
|
|
185
|
+
"@capgo/capacitor-social-login": "^8.2.5",
|
|
186
|
+
"@graphql-tools/utils": "^10.11.0",
|
|
187
|
+
"@ionic/vue": "^8.7.15",
|
|
188
|
+
"@nuxt/icon": "^2.1.1",
|
|
189
|
+
"@nuxt/scripts": "^0.13.2",
|
|
190
|
+
"@nuxtjs/color-mode": "^4.0.0",
|
|
191
|
+
"@nuxtjs/i18n": "^10.2.1",
|
|
192
|
+
"@nuxtjs/ionic": "^1.0.2",
|
|
193
|
+
"@nuxtjs/tailwindcss": "7.0.0-beta.1",
|
|
194
|
+
"@openfga/sdk": "^0.9.1",
|
|
195
|
+
"@pinia/colada": "^0.20.0",
|
|
196
|
+
"@pinia/colada-nuxt": "^0.3.0",
|
|
197
|
+
"@pinia/colada-plugin-auto-refetch": "^0.2.4",
|
|
198
|
+
"@pinia/nuxt": "^0.11.3",
|
|
199
|
+
"@polar-sh/sdk": "^0.42.1",
|
|
200
|
+
"@sentry/nuxt": "^10.32.1",
|
|
201
|
+
"@sindresorhus/slugify": "^3.0.0",
|
|
202
|
+
"@tailwindcss/typography": "^0.5.19",
|
|
203
|
+
"@tanstack/vue-table": "^8.21.3",
|
|
204
|
+
"@unovis/vue": "^1.6.2",
|
|
205
|
+
"@vee-validate/nuxt": "5.0.0-beta.0",
|
|
206
|
+
"@vueuse/core": "^14.1.0",
|
|
207
|
+
"@vueuse/nuxt": "^14.1.0",
|
|
208
|
+
"@vueuse/router": "^14.1.0",
|
|
209
|
+
"@vueuse/sound": "^2.1.3",
|
|
210
|
+
"apiful": "^4.0.0",
|
|
211
|
+
"aws4fetch": "^1.0.20",
|
|
212
|
+
"better-auth": "^1.4.9",
|
|
213
|
+
"capacitor-native-settings": "^7.0.2",
|
|
214
|
+
"class-variance-authority": "^0.7.1",
|
|
215
|
+
"clsx": "^2.1.1",
|
|
216
|
+
"consola": "^3.4.2",
|
|
217
|
+
"dataloader": "^2.2.3",
|
|
218
|
+
"date-fns": "^4.1.0",
|
|
219
|
+
"defu": "^6.1.4",
|
|
220
|
+
"drizzle-kit": "^0.31.8",
|
|
221
|
+
"drizzle-orm": "^0.45.1",
|
|
222
|
+
"drizzle-zod": "^0.8.3",
|
|
223
|
+
"embla-carousel-vue": "^8.6.0",
|
|
224
|
+
"graphql": "^16.12.0",
|
|
225
|
+
"graphql-config": "^5.1.5",
|
|
226
|
+
"graphql-scalars": "^1.25.0",
|
|
227
|
+
"graphql-yoga": "^5.18.0",
|
|
228
|
+
"h3": "^1.15.4",
|
|
229
|
+
"md-editor-v3": "^6.2.1",
|
|
230
|
+
"nitro-graphql": "^1.8.0",
|
|
231
|
+
"nitropack": "^2.12.9",
|
|
232
|
+
"notivue": "^2.4.5",
|
|
233
|
+
"nuxt": "^4.2.2",
|
|
234
|
+
"pg": "^8.16.3",
|
|
235
|
+
"pinia": "^3.0.4",
|
|
236
|
+
"pinia-plugin-persistedstate": "^4.7.1",
|
|
237
|
+
"reka-ui": "^2.7.0",
|
|
238
|
+
"tailwind-merge": "^3.4.0",
|
|
239
|
+
"tailwindcss": "^4.1.18",
|
|
240
|
+
"tw-animate-css": "^1.4.0",
|
|
241
|
+
"unstorage": "^1.17.3",
|
|
242
|
+
"uuid": "^13.0.0",
|
|
243
|
+
"vaul-vue": "^0.4.1",
|
|
244
|
+
"vee-validate": "5.0.0-beta.0",
|
|
245
|
+
"vite-tsconfig-paths": "^6.0.3",
|
|
246
|
+
"vue": "^3.5.26",
|
|
247
|
+
"vue-input-otp": "^0.3.2",
|
|
248
|
+
"vue-router": "^4.6.4",
|
|
249
|
+
"vue-sonner": "^2.0.9",
|
|
250
|
+
"vue-tsc": "^3.2.1",
|
|
251
|
+
"zod": "^4.2.1"
|
|
252
|
+
},
|
|
180
253
|
"resolutions": {
|
|
181
254
|
"abckit": "workspace:*"
|
|
182
255
|
},
|
|
@@ -186,5 +259,15 @@
|
|
|
186
259
|
"patchedDependencies": {
|
|
187
260
|
"entities@7.0.0": "patches/entities@7.0.0.patch",
|
|
188
261
|
"entities@7.0.0@7.0.0": "patches/entities@7.0.0.patch"
|
|
262
|
+
},
|
|
263
|
+
"scripts": {
|
|
264
|
+
"build": "nuxt-module-build build",
|
|
265
|
+
"dev": "nuxt dev playground",
|
|
266
|
+
"dev:build": "nuxi build playground",
|
|
267
|
+
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
268
|
+
"lint": "eslint .",
|
|
269
|
+
"lint:fix": "eslint . --fix",
|
|
270
|
+
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
|
|
271
|
+
"release": "pnpm publish --no-git-checks --access public"
|
|
189
272
|
}
|
|
190
|
-
}
|
|
273
|
+
}
|