@meeovi/auth 1.0.2 → 1.0.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meeovi/auth",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Authentication for M Framework.",
5
5
  "license": "ISC",
6
6
  "author": "",
@@ -25,6 +25,7 @@
25
25
  "vue-router": "^4.6.4"
26
26
  },
27
27
  "devDependencies": {
28
+ "@types/node": "^25.0.9",
28
29
  "@types/uuid": "^10.0.0"
29
30
  }
30
31
  }
@@ -0,0 +1,7 @@
1
+
2
+ export function normalizeTrailingSlash(path: string) {
3
+ if (path !== '/' && path.endsWith('/')) {
4
+ return path.replace(/\/+$/, '') || '/';
5
+ }
6
+ return null;
7
+ }
@@ -0,0 +1,8 @@
1
+
2
+ export function isSeller(user: any): boolean {
3
+ return !!(user && user.role === 'seller');
4
+ }
5
+
6
+ export function isSellerRoute(path: string): boolean {
7
+ return path.startsWith('/dashboard/');
8
+ }
@@ -0,0 +1,18 @@
1
+
2
+ export interface Session {
3
+ id: string;
4
+ date_created: string;
5
+ }
6
+
7
+ export function ensureSession(getCookie: (name: string) => any, setCookie: (name: string, value: string) => void, generateId: () => string) {
8
+ const session = getCookie('session');
9
+
10
+ if (!session) {
11
+ const newSession: Session = {
12
+ id: generateId(),
13
+ date_created: new Date().toISOString(),
14
+ };
15
+
16
+ setCookie('session', JSON.stringify(newSession));
17
+ }
18
+ }