@iankibetsh/sh-core
Core JS layer for sh frameworks: API client, auth (bearer/cookie strategies), pinia stores, streamline, swal notifications and helpers. UI-library free.
1,203
| Install | |
|---|---|
npm install @iankibetsh/sh-core |
|
| Latest Version: | 1.0.3 |
| Vue: | 3 |
| License: | ISC |
| Last Updated: | Sep 22, 2026 |
| Links: | npm |
Maintainer: iankibetsh
@iankibetsh/sh-core
Core JS layer for the sh frameworks family. UI-library free (no Bootstrap, no Tailwind) — only sweetalert2 for notifications/dialogs. UI packages layer on top:
@iankibetsh/shframework(v6+) — Bootstrap 5 components (ShTable, ShForm, ...)@iankibetsh/sh-tailwind(planned) — Tailwind components
What's inside
- API client — single axios instance with request/response interceptors, configurable free (public) endpoints and central 401 handling.
shApis.doGet/doPost/doPut/doPatch/doDeletekeep the classic signatures. - Auth strategies —
bearer(default): token kept in memory + sessionStorage (tokenStorage: 'memory' | 'session' | 'local'). Existing v5 tokens in localStorage are migrated automatically on first request.cookie: Laravel Sanctum SPA mode — httpOnly session cookie set by the server, automatic CSRF (sanctum/csrf-cookie),withCredentials. No token ever stored in JS.
useAuth()composable —login,logout,fetchUser,isAllowedTo,user.- Pinia stores —
useUserStore(iduser-store),useAppStore(idsh-app). - Streamline —
useStreamline,getActionUrland the IndexedDB cache, built in (successor of@iankibetsh/vue-streamline). Auth rides on the shared client; no manual headers needed. - Notifications —
swalSuccess,swalError,swalHttpError,showToast,confirmAction,runPlainRequest. - Helpers —
shRepoaggregate,shStorage,formatDate/formatNumber, session timeout handling,v-if-user-candirective.
Install
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import { ShCore } from '@iankibetsh/sh-core'
const app = createApp(App)
app.use(createPinia())
app.use(ShCore, {
baseApiUrl: import.meta.env.VITE_APP_API_URL,
authMode: 'bearer', // or 'cookie' for Sanctum SPA
tokenStorage: 'session', // 'memory' | 'session' | 'local'
sessionTimeout: 400, // minutes
loginUrl: '/sh-auth',
streamlineUrl: '/api/streamline',
enableCache: true
})
Cookie (Sanctum SPA) mode
app.use(ShCore, {
baseApiUrl: 'https://api.example.test',
authMode: 'cookie',
csrfEndpoint: 'sanctum/csrf-cookie'
})
Backend requirements: SANCTUM_STATEFUL_DOMAINS includes the SPA host, session driver configured and supports_credentials: true in CORS config.
Migration notes (from shframework v5 core)
- Tokens move from localStorage
access_tokento sessionStorage (auto-migrated). sessionStorage is per-tab; passtokenStorage: 'local'if you need multi-tab continuity. doDelete(endpoint, data)now correctly sendsdataas the request body.- Session timer no longer starts on import; it starts when the plugin receives
sessionTimeoutor afterlogin().
Related Packages
@enso-ui/auth
Authentication pages, auth store helpers, and password-strength utilities for En...
11,552
0
lukk-nuxt
Nuxt module for lukk (first-party Laravel JWT auth) + useLukkFetch, an auth-awar...
2,402
0
nuxt-bearer-auth
Reusable Nuxt authentication module for bearer-token APIs with Redis sessions an...
1,593
0
Version History
| Version | Released | Vue | License |
|---|---|---|---|
| 1.0.3 | ^3.5 | ISC | |
| 1.0.2 | ^3.5 | ISC | |
| 1.0.1 | ^3.5 | ISC | |
| 1.0.0 | ^3.5 | ISC |