@getmicdrop/svelte-components 5.3.13 → 5.3.15
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/constants/formOptions.d.ts +9 -4
- package/dist/constants/formOptions.d.ts.map +1 -1
- package/dist/constants/formOptions.js +48 -26
- package/dist/forms/createFieldTracker.svelte.d.ts +41 -0
- package/dist/forms/createFieldTracker.svelte.d.ts.map +1 -0
- package/dist/forms/createFieldTracker.svelte.js +94 -0
- package/dist/forms/createFormStore.svelte.d.ts +47 -0
- package/dist/forms/createFormStore.svelte.d.ts.map +1 -0
- package/dist/forms/createFormStore.svelte.js +223 -0
- package/dist/forms/index.d.ts +61 -0
- package/dist/forms/index.d.ts.map +1 -0
- package/dist/forms/index.js +60 -0
- package/dist/index.d.ts +0 -10
- package/dist/index.js +5 -19
- package/dist/stores/auth.js +36 -123
- package/dist/stores/auth.spec.js +139 -447
- package/dist/stores/createFormStore.d.ts +77 -0
- package/dist/stores/createFormStore.d.ts.map +1 -0
- package/dist/stores/createFormStore.js +410 -0
- package/dist/stores/createFormStore.spec.d.ts +2 -0
- package/dist/stores/createFormStore.spec.d.ts.map +1 -0
- package/dist/stores/createFormStore.spec.js +540 -0
- package/dist/stores/index.d.ts +6 -0
- package/dist/stores/index.js +10 -0
- package/dist/telemetry.d.ts +21 -2
- package/dist/telemetry.d.ts.map +1 -1
- package/dist/telemetry.js +403 -358
- package/dist/utils/apiConfig.js +120 -50
- package/dist/utils/utils/utils.js +3 -323
- package/dist/utils/utils.js +644 -346
- package/package.json +77 -50
package/dist/index.js
CHANGED
|
@@ -216,22 +216,8 @@ export * from './constants/validation.js';
|
|
|
216
216
|
// Presets - Domain-to-color mappings for migration
|
|
217
217
|
export * from './presets/index.js';
|
|
218
218
|
|
|
219
|
-
// Utils / Actions
|
|
220
|
-
export { portal } from './utils/portal.js';
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
export
|
|
224
|
-
export * from './utils/imageValidation.js';
|
|
225
|
-
export * from './utils/apiConfig.js';
|
|
226
|
-
|
|
227
|
-
// Stores
|
|
228
|
-
export * from './stores/toaster.js';
|
|
229
|
-
export * from './stores/navigation.js';
|
|
230
|
-
export * from './stores/auth.js';
|
|
231
|
-
|
|
232
|
-
// Config & Telemetry
|
|
233
|
-
export * from './config.js';
|
|
234
|
-
export * from './telemetry.js';
|
|
235
|
-
|
|
236
|
-
// Design Tokens
|
|
237
|
-
export { typography } from './tokens/typography.js';
|
|
219
|
+
// Utils / Actions
|
|
220
|
+
export { portal } from './utils/portal.js';
|
|
221
|
+
|
|
222
|
+
// Design Tokens
|
|
223
|
+
export { typography } from './tokens/typography.js';
|
package/dist/stores/auth.js
CHANGED
|
@@ -1,123 +1,36 @@
|
|
|
1
|
-
import { writable
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
//
|
|
16
|
-
export const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
//
|
|
21
|
-
export const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
// Parse cookies helper
|
|
39
|
-
const parseCookies = () => {
|
|
40
|
-
if (typeof document === "undefined") return {};
|
|
41
|
-
return Object.fromEntries(
|
|
42
|
-
document.cookie
|
|
43
|
-
.split("; ")
|
|
44
|
-
.filter(c => c)
|
|
45
|
-
.map((c) => c.split("="))
|
|
46
|
-
.map(([k, v]) => [k, decodeURIComponent(v || "")])
|
|
47
|
-
);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
// Get token expiry from JWT
|
|
51
|
-
const getTokenExpiry = (token) => {
|
|
52
|
-
if (!token) return null;
|
|
53
|
-
try {
|
|
54
|
-
const decoded = jwtDecode(token);
|
|
55
|
-
return decoded.exp ? decoded.exp * 1000 : null; // Convert to milliseconds
|
|
56
|
-
} catch {
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
// Check if token is expired or about to expire (within 5 minutes)
|
|
62
|
-
export const isTokenExpiringSoon = (bufferMs = 5 * 60 * 1000) => {
|
|
63
|
-
const state = get(auth);
|
|
64
|
-
if (!state.tokenExpiry) return true;
|
|
65
|
-
return Date.now() >= (state.tokenExpiry - bufferMs);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
// Initialize the store from cookies
|
|
69
|
-
export const initializeAuthState = () => {
|
|
70
|
-
const cookies = parseCookies();
|
|
71
|
-
|
|
72
|
-
if (cookies.performer_token) {
|
|
73
|
-
const tokenExpiry = getTokenExpiry(cookies.performer_token);
|
|
74
|
-
|
|
75
|
-
setAuthState({
|
|
76
|
-
isAuthenticated: true,
|
|
77
|
-
token: cookies.performer_token,
|
|
78
|
-
refreshToken: cookies.performer_refresh_token || null,
|
|
79
|
-
userDetails: cookies.userDetails ? JSON.parse(cookies.userDetails) : null,
|
|
80
|
-
tokenExpiry,
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
// Update tokens after a refresh
|
|
86
|
-
export const updateTokens = (accessToken, refreshToken) => {
|
|
87
|
-
auth.update(state => ({
|
|
88
|
-
...state,
|
|
89
|
-
token: accessToken,
|
|
90
|
-
refreshToken: refreshToken || state.refreshToken,
|
|
91
|
-
tokenExpiry: getTokenExpiry(accessToken),
|
|
92
|
-
}));
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
// Update permissions
|
|
96
|
-
export const setPermissions = (permissions) => {
|
|
97
|
-
auth.update(state => ({
|
|
98
|
-
...state,
|
|
99
|
-
permissions,
|
|
100
|
-
}));
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
// Set user context
|
|
104
|
-
export const setContext = (context) => {
|
|
105
|
-
auth.update(state => ({
|
|
106
|
-
...state,
|
|
107
|
-
context,
|
|
108
|
-
}));
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
// Check if user has a specific permission
|
|
112
|
-
export const hasPermission = (category, permission) => {
|
|
113
|
-
const state = get(auth);
|
|
114
|
-
if (!state.permissions) return false;
|
|
115
|
-
|
|
116
|
-
// Performers have limited permissions by design
|
|
117
|
-
return state.permissions[category]?.[permission] ?? false;
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
// Get current permissions
|
|
121
|
-
export const getPermissions = () => {
|
|
122
|
-
return get(auth).permissions;
|
|
123
|
-
};
|
|
1
|
+
import { writable } from "svelte/store";
|
|
2
|
+
|
|
3
|
+
// Store to manage authentication state
|
|
4
|
+
export const auth = writable({
|
|
5
|
+
isAuthenticated: false,
|
|
6
|
+
token: null,
|
|
7
|
+
userDetails: null, // To store email and first name
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
// Function to set authentication state
|
|
11
|
+
export const setAuthState = (state) => {
|
|
12
|
+
auth.set(state);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// Function to clear the authentication state
|
|
16
|
+
export const clearAuthState = () => {
|
|
17
|
+
auth.set({ isAuthenticated: false, token: null, userDetails: null });
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// Initialize the store from cookies
|
|
21
|
+
export const initializeAuthState = () => {
|
|
22
|
+
const cookies = Object.fromEntries(
|
|
23
|
+
document.cookie
|
|
24
|
+
.split("; ")
|
|
25
|
+
.map((c) => c.split("="))
|
|
26
|
+
.map(([k, v]) => [k, decodeURIComponent(v)])
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
if (cookies.performer_token) {
|
|
30
|
+
setAuthState({
|
|
31
|
+
isAuthenticated: true,
|
|
32
|
+
token: cookies.performer_token,
|
|
33
|
+
userDetails: cookies.userDetails ? JSON.parse(cookies.userDetails) : null,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
};
|