firstly 0.0.14 → 0.0.16-next.0
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/CHANGELOG.md +16 -0
- package/esm/ROUTES.d.ts +10 -2
- package/esm/ROUTES.js +5 -1
- package/esm/auth/Entities.js +1 -0
- package/esm/auth/server/AuthController.server.js +2 -1
- package/esm/auth/server/handleAuth.js +2 -1
- package/esm/auth/server/handleGuard.d.ts +10 -4
- package/esm/auth/server/handleGuard.js +8 -41
- package/esm/auth/server/module.d.ts +29 -1
- package/esm/auth/server/module.js +4 -1
- package/esm/auth/static/assets/{Page-UV_hqY7I.d.ts → Page-BgIgl-Te.d.ts} +2 -2
- package/esm/auth/static/assets/{Page-UV_hqY7I.js → Page-BgIgl-Te.js} +1 -1
- package/esm/auth/static/assets/{Page-DdKMiUZn.d.ts → Page-HDnoBhpE.d.ts} +2 -2
- package/esm/auth/static/assets/{Page-DdKMiUZn.js → Page-HDnoBhpE.js} +5 -5
- package/esm/auth/static/assets/{Page-B0XXxe0N.d.ts → Page-f5pC21Yg.d.ts} +2 -2
- package/esm/auth/static/assets/{Page-B0XXxe0N.js → Page-f5pC21Yg.js} +1 -1
- package/esm/auth/static/assets/{index-C9jzxOBu.js → index-DAjei0Ie.js} +2 -2
- package/esm/auth/static/index.html +4 -4
- package/esm/auth/types.d.ts +1 -0
- package/esm/bin/cmd.js +16 -16
- package/esm/changeLog/server/index.d.ts +1 -1
- package/esm/changeLog/server/index.js +1 -1
- package/esm/cron/server/index.d.ts +1 -1
- package/esm/cron/server/index.js +1 -1
- package/esm/feedback/server/index.d.ts +1 -1
- package/esm/feedback/server/index.js +1 -1
- package/esm/helper.d.ts +1 -1
- package/esm/helper.js +4 -3
- package/esm/index.d.ts +5 -3
- package/esm/index.js +5 -3
- package/esm/mail/server/index.d.ts +2 -2
- package/esm/mail/server/index.js +7 -4
- package/esm/server/index.d.ts +49 -0
- package/esm/server/index.js +109 -1
- package/esm/svelte/FF_Cell.svelte +104 -0
- package/esm/svelte/FF_Cell.svelte.d.ts +24 -0
- package/esm/svelte/FF_Cell_Caption.svelte +20 -0
- package/esm/svelte/FF_Cell_Caption.svelte.d.ts +24 -0
- package/esm/svelte/FF_Cell_Display.svelte +61 -0
- package/esm/svelte/FF_Cell_Display.svelte.d.ts +22 -0
- package/esm/svelte/FF_Cell_Edit.svelte +104 -0
- package/esm/svelte/FF_Cell_Edit.svelte.d.ts +25 -0
- package/esm/svelte/FF_Cell_Error.svelte +20 -0
- package/esm/svelte/FF_Cell_Error.svelte.d.ts +24 -0
- package/esm/svelte/FF_Cell_Hint.svelte +20 -0
- package/esm/svelte/FF_Cell_Hint.svelte.d.ts +24 -0
- package/esm/svelte/FF_Config.svelte +29 -0
- package/esm/svelte/FF_Config.svelte.d.ts +9 -0
- package/esm/svelte/FF_Display.svelte +51 -0
- package/esm/svelte/FF_Display.svelte.d.ts +22 -0
- package/esm/svelte/FF_Edit.svelte +104 -0
- package/esm/svelte/FF_Edit.svelte.d.ts +25 -0
- package/esm/svelte/FF_Error.svelte +23 -0
- package/esm/svelte/FF_Error.svelte.d.ts +22 -0
- package/esm/svelte/FF_Field.svelte +62 -0
- package/esm/svelte/FF_Field.svelte.d.ts +22 -0
- package/esm/svelte/FF_Form.svelte +156 -0
- package/esm/svelte/FF_Form.svelte.d.ts +30 -0
- package/esm/svelte/FF_Grid.svelte +257 -0
- package/esm/svelte/FF_Grid.svelte.d.ts +31 -0
- package/esm/svelte/FF_Hint.svelte +21 -0
- package/esm/svelte/FF_Hint.svelte.d.ts +22 -0
- package/esm/svelte/FF_Label.svelte +23 -0
- package/esm/svelte/FF_Label.svelte.d.ts +22 -0
- package/esm/svelte/FF_Layout.svelte +62 -0
- package/esm/svelte/FF_Layout.svelte.d.ts +24 -0
- package/esm/svelte/FF_Repo.svelte.d.ts +69 -0
- package/esm/svelte/FF_Repo.svelte.js +170 -0
- package/esm/svelte/actions/intersection.d.ts +6 -0
- package/esm/svelte/actions/intersection.js +17 -0
- package/esm/svelte/class/SP.svelte.d.ts +61 -0
- package/esm/svelte/class/SP.svelte.js +412 -0
- package/esm/svelte/customField.d.ts +69 -0
- package/esm/svelte/customField.js +4 -0
- package/esm/svelte/dialog/DialogManagement.svelte +101 -0
- package/esm/svelte/dialog/DialogManagement.svelte.d.ts +18 -0
- package/esm/svelte/dialog/DialogPrimitive.svelte +157 -0
- package/esm/svelte/dialog/DialogPrimitive.svelte.d.ts +38 -0
- package/esm/svelte/dialog/dialog.d.ts +58 -0
- package/esm/svelte/dialog/dialog.js +130 -0
- package/esm/svelte/ff_Config.svelte.d.ts +91 -0
- package/esm/svelte/ff_Config.svelte.js +111 -0
- package/esm/svelte/firstly.css +14 -0
- package/esm/svelte/helpers/debounce.d.ts +1 -0
- package/esm/svelte/helpers/debounce.js +7 -0
- package/esm/svelte/helpers.d.ts +29 -0
- package/esm/svelte/helpers.js +38 -0
- package/esm/svelte/index.d.ts +32 -0
- package/esm/svelte/index.js +29 -0
- package/esm/svelte/tryCatch.d.ts +12 -0
- package/esm/svelte/tryCatch.js +18 -0
- package/esm/sveltekit/server/index.d.ts +1 -1
- package/esm/sveltekit/server/index.js +1 -1
- package/esm/ui/Field.svelte +1 -1
- package/esm/ui/Grid.svelte +8 -2
- package/esm/ui/Grid2.svelte +354 -0
- package/esm/ui/Grid2.svelte.d.ts +58 -0
- package/esm/ui/GridLoading.svelte +33 -8
- package/esm/ui/GridLoading.svelte.d.ts +1 -0
- package/esm/ui/GridPaginate.svelte +0 -3
- package/esm/ui/GridPaginate.svelte.d.ts +0 -1
- package/esm/ui/GridPaginate2.svelte +25 -0
- package/esm/ui/GridPaginate2.svelte.d.ts +7 -0
- package/esm/ui/dialog/dialog.d.ts +3 -1
- package/esm/ui/dialog/dialog.js +2 -0
- package/esm/ui/link/LinkPlus.svelte +8 -6
- package/package.json +28 -13
- package/esm/api/index.d.ts +0 -49
- package/esm/api/index.js +0 -109
- /package/esm/auth/static/assets/{index-C9jzxOBu.d.ts → index-DAjei0Ie.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# firstly
|
|
2
2
|
|
|
3
|
+
## 0.0.16-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#102](https://github.com/jycouet/firstly/pull/102)
|
|
8
|
+
[`f0effb9`](https://github.com/jycouet/firstly/commit/f0effb9e2dfa3f1c3070bc27c498d7f1e1ed877d)
|
|
9
|
+
Thanks [@jycouet](https://github.com/jycouet)! - Prepare JYC 016
|
|
10
|
+
|
|
11
|
+
## 0.0.15
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#98](https://github.com/jycouet/firstly/pull/98)
|
|
16
|
+
[`0d708f6`](https://github.com/jycouet/firstly/commit/0d708f605dc9d2943730f68ebf99c1d2f8a49926)
|
|
17
|
+
Thanks [@jycouet](https://github.com/jycouet)! - prepare JYC 0.0.15
|
|
18
|
+
|
|
3
19
|
## 0.0.14
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/esm/ROUTES.d.ts
CHANGED
|
@@ -33,7 +33,11 @@ declare const AllObjs: {
|
|
|
33
33
|
}) => string;
|
|
34
34
|
"/": string;
|
|
35
35
|
"/auth": string;
|
|
36
|
-
"/demo/
|
|
36
|
+
"/demo/FF_Cell": string;
|
|
37
|
+
"/demo/FF_Form_Grid": string;
|
|
38
|
+
"/demo/FF_Layout": string;
|
|
39
|
+
"/demo/FF_Layout/grid": string;
|
|
40
|
+
"/demo/FF_Simple": string;
|
|
37
41
|
"/mail": string;
|
|
38
42
|
"/ui/dialog": string;
|
|
39
43
|
"/ui/enum": string;
|
|
@@ -72,7 +76,11 @@ export type KIT_ROUTES = {
|
|
|
72
76
|
PAGES: {
|
|
73
77
|
'/': never;
|
|
74
78
|
'/auth': never;
|
|
75
|
-
'/demo/
|
|
79
|
+
'/demo/FF_Cell': never;
|
|
80
|
+
'/demo/FF_Form_Grid': never;
|
|
81
|
+
'/demo/FF_Layout': never;
|
|
82
|
+
'/demo/FF_Layout/grid': never;
|
|
83
|
+
'/demo/FF_Simple': never;
|
|
76
84
|
'/mail': never;
|
|
77
85
|
'/ui/dialog': never;
|
|
78
86
|
'/ui/enum': never;
|
package/esm/ROUTES.js
CHANGED
|
@@ -10,7 +10,11 @@
|
|
|
10
10
|
const PAGES = {
|
|
11
11
|
"/": `/`,
|
|
12
12
|
"/auth": `/auth`,
|
|
13
|
-
"/demo/
|
|
13
|
+
"/demo/FF_Cell": `/demo/FF_Cell`,
|
|
14
|
+
"/demo/FF_Form_Grid": `/demo/FF_Form_Grid`,
|
|
15
|
+
"/demo/FF_Layout": `/demo/FF_Layout`,
|
|
16
|
+
"/demo/FF_Layout/grid": `/demo/FF_Layout/grid`,
|
|
17
|
+
"/demo/FF_Simple": `/demo/FF_Simple`,
|
|
14
18
|
"/mail": `/mail`,
|
|
15
19
|
"/ui/dialog": `/ui/dialog`,
|
|
16
20
|
"/ui/enum": `/ui/enum`,
|
package/esm/auth/Entities.js
CHANGED
|
@@ -252,9 +252,10 @@ export class AuthControllerServer {
|
|
|
252
252
|
const validPassword = oSafe.password.verify(password ?? '', existingAccount?.hashPassword ?? '');
|
|
253
253
|
if (validPassword) {
|
|
254
254
|
const session = await ff_createSession(existingAccount.userId);
|
|
255
|
+
const user = await repo(oSafe.User).findId(existingAccount.userId);
|
|
255
256
|
return {
|
|
256
257
|
message: 'ok',
|
|
257
|
-
user: oSafe.transformDbUserToClientUser(session,
|
|
258
|
+
user: oSafe.transformDbUserToClientUser(session, user),
|
|
258
259
|
};
|
|
259
260
|
}
|
|
260
261
|
authModuleRaw.log.error({ email, passwordLength: password.length });
|
|
@@ -31,7 +31,8 @@ export const handleAuth = async ({ event, resolve }) => {
|
|
|
31
31
|
}
|
|
32
32
|
if (oSafe.firstlyData.props.ui?.paths?.base &&
|
|
33
33
|
event.url.pathname.startsWith(oSafe.firstlyData.props.ui.paths.base)) {
|
|
34
|
-
|
|
34
|
+
let content = read(`${oSafe.uiStaticPath}index.html`) ?? '';
|
|
35
|
+
content = content?.replaceAll('<!--PLACE_HERE_HEAD-->', oSafe.ui?.customHtmlHead ?? '');
|
|
35
36
|
return new Response(content + `<script>const firstlyData = ${JSON.stringify(oSafe.firstlyData)}</script>`, {
|
|
36
37
|
headers: { 'content-type': 'text/html' },
|
|
37
38
|
});
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { type Handle } from '@sveltejs/kit';
|
|
2
2
|
export type RouteGuardConfig = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Routes that require authentication (e.g. `{ path: '/app*' }`)
|
|
5
|
+
*/
|
|
6
|
+
guard: {
|
|
7
|
+
path: string;
|
|
8
|
+
}[];
|
|
9
|
+
/**
|
|
10
|
+
* Where to redirect when authentication is required but user is not logged in
|
|
11
|
+
*/
|
|
12
|
+
login: string;
|
|
7
13
|
/**
|
|
8
14
|
* We need this import
|
|
9
15
|
*
|
|
@@ -1,67 +1,34 @@
|
|
|
1
1
|
import {} from '@sveltejs/kit';
|
|
2
2
|
import { remult } from 'remult';
|
|
3
|
-
/**
|
|
4
|
-
* Checks if a path matches a pattern that may include wildcards
|
|
5
|
-
* @param path The actual path to check
|
|
6
|
-
* @param pattern The pattern that may include wildcards (*)
|
|
7
|
-
*/
|
|
8
3
|
function pathMatchesPattern(path, pattern) {
|
|
9
4
|
// Convert the pattern to a regex
|
|
10
5
|
const regexPattern = pattern.replace(/\//g, '\\/').replace(/\*/g, '.*');
|
|
11
6
|
const regex = new RegExp(`^${regexPattern}$`);
|
|
12
7
|
return regex.test(path);
|
|
13
8
|
}
|
|
14
|
-
/**
|
|
15
|
-
* Checks if a path matches any of the patterns in the array
|
|
16
|
-
*/
|
|
17
9
|
function pathMatchesAnyPattern(path, patterns) {
|
|
18
|
-
return patterns.some((pattern) => pathMatchesPattern(path, pattern));
|
|
10
|
+
return patterns.some((pattern) => pathMatchesPattern(path, pattern.path));
|
|
19
11
|
}
|
|
20
12
|
/**
|
|
21
13
|
* Creates a handle function with the provided route guard configuration
|
|
22
14
|
*/
|
|
23
15
|
export function handleGuard(config) {
|
|
24
16
|
return async ({ event, resolve }) => {
|
|
25
|
-
const
|
|
26
|
-
const fullUrl = event.url.pathname + event.url.search;
|
|
17
|
+
const pathname = event.url.pathname;
|
|
27
18
|
const isAuthenticated = !!remult.user;
|
|
28
|
-
|
|
29
|
-
const isAnonymousRoute = config.anonymous ? pathMatchesAnyPattern(path, config.anonymous) : false;
|
|
30
|
-
// Check if the path is in the authenticated routes
|
|
31
|
-
const isAuthenticatedRoute = pathMatchesAnyPattern(path, config.authenticated);
|
|
32
|
-
// Check if the current path is the login page
|
|
33
|
-
const isLoginPage = path === config.redirectToLogin || path === config.redirectToLogin.replace(/\/$/, '');
|
|
34
|
-
// Create login URL with redirect parameter
|
|
35
|
-
const createLoginUrl = (returnUrl) => {
|
|
36
|
-
const encodedReturnUrl = encodeURIComponent(returnUrl);
|
|
37
|
-
const separator = config.redirectToLogin.includes('?') ? '&' : '?';
|
|
38
|
-
return `${config.redirectToLogin}${separator}redirect=${encodedReturnUrl}`;
|
|
39
|
-
};
|
|
40
|
-
// Handle root path
|
|
41
|
-
if (path === config.redirectToLogin) {
|
|
42
|
-
if (isAuthenticated) {
|
|
43
|
-
config.redirect(302, config.redirectAuthenticated);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
// Only redirect if we're not already on the login page
|
|
47
|
-
if (!isLoginPage) {
|
|
48
|
-
config.redirect(302, config.redirectToLogin);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
19
|
+
const isAuthenticatedRoute = pathMatchesAnyPattern(pathname, config.guard);
|
|
52
20
|
// If user is not authenticated and tries to access an authenticated route
|
|
53
21
|
if (!isAuthenticated && isAuthenticatedRoute) {
|
|
54
22
|
// Redirect to login with the current URL as the redirect target
|
|
55
23
|
// Only redirect if we're not already on the login page
|
|
24
|
+
const isLoginPage = pathname === config.login || pathname === config.login.replace(/\/$/, '');
|
|
56
25
|
if (!isLoginPage) {
|
|
57
|
-
|
|
26
|
+
const encodedReturnUrl = encodeURIComponent(pathname + event.url.search);
|
|
27
|
+
const separator = config.login.includes('?') ? '&' : '?';
|
|
28
|
+
const loginUrl = `${config.login}${separator}redirect=${encodedReturnUrl}`;
|
|
29
|
+
config.redirect(302, loginUrl);
|
|
58
30
|
}
|
|
59
31
|
}
|
|
60
|
-
// If user is authenticated and tries to access an anonymous-only route
|
|
61
|
-
// Only check if anonymous routes are defined
|
|
62
|
-
if (config.anonymous && isAuthenticated && isAnonymousRoute) {
|
|
63
|
-
config.redirect(302, config.redirectAuthenticated);
|
|
64
|
-
}
|
|
65
32
|
return resolve(event);
|
|
66
33
|
};
|
|
67
34
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { OAuth2Tokens } from 'arctic';
|
|
2
2
|
import type { ClassType, UserInfo } from 'remult';
|
|
3
|
-
import { Module } from '../../
|
|
3
|
+
import { Module } from '../../server';
|
|
4
4
|
import type { RecursivePartial } from '../../utils/types';
|
|
5
5
|
import { FFAuthAccount, FFAuthUser, FFAuthUserSession } from '../Entities';
|
|
6
6
|
import type { FirstlyData, FirstlyDataAuth, ProviderAuthorizationURLOptions } from '../types';
|
|
@@ -236,6 +236,34 @@ export declare const getSafeOptions: <TUserEntity extends FFAuthUser = FFAuthUse
|
|
|
236
236
|
anErrorOccurred: string;
|
|
237
237
|
cannotSignUp: string;
|
|
238
238
|
};
|
|
239
|
+
ui: {
|
|
240
|
+
readonly paths: {
|
|
241
|
+
readonly base: string;
|
|
242
|
+
readonly sign_up: string | false;
|
|
243
|
+
readonly sign_in: string | false;
|
|
244
|
+
readonly forgot_password: string | false;
|
|
245
|
+
readonly reset_password: string | false;
|
|
246
|
+
readonly verify_email: string | false;
|
|
247
|
+
};
|
|
248
|
+
readonly strings: {
|
|
249
|
+
readonly app_name: string;
|
|
250
|
+
readonly email: string;
|
|
251
|
+
readonly email_placeholder: string;
|
|
252
|
+
readonly password: string;
|
|
253
|
+
readonly password_placeholder: string;
|
|
254
|
+
readonly confirm: string;
|
|
255
|
+
readonly reset: string;
|
|
256
|
+
readonly btn_sign_up: string;
|
|
257
|
+
readonly btn_sign_in: string;
|
|
258
|
+
readonly forgot_password: string;
|
|
259
|
+
readonly send_password_reset_instructions: string;
|
|
260
|
+
readonly back_to_sign_in: string;
|
|
261
|
+
};
|
|
262
|
+
readonly images: {
|
|
263
|
+
readonly main: string;
|
|
264
|
+
};
|
|
265
|
+
readonly customHtmlHead: string;
|
|
266
|
+
} | undefined;
|
|
239
267
|
};
|
|
240
268
|
export declare const authModuleRaw: Module;
|
|
241
269
|
/**
|
|
@@ -5,7 +5,7 @@ import { getRelativePackagePath } from '@kitql/internals';
|
|
|
5
5
|
import { building } from '$app/environment';
|
|
6
6
|
import { AuthController } from '..';
|
|
7
7
|
import { FF_Role } from '../..';
|
|
8
|
-
import { Module } from '../../
|
|
8
|
+
import { Module } from '../../server';
|
|
9
9
|
import { FF_Role_Auth, FFAuthAccount, FFAuthUser, FFAuthUserSession } from '../Entities';
|
|
10
10
|
import { AuthControllerServer } from './AuthController.server';
|
|
11
11
|
import { validateSessionToken } from './helperDb';
|
|
@@ -53,6 +53,8 @@ export const getSafeOptions = () => {
|
|
|
53
53
|
images: {
|
|
54
54
|
main: AUTH_OPTIONS.ui?.images?.main ?? '',
|
|
55
55
|
},
|
|
56
|
+
customHtmlHead: AUTH_OPTIONS.ui?.customHtmlHead ??
|
|
57
|
+
'<title>Auth</title><link rel="icon" href="https://firstly.fun/favicon.svg" />',
|
|
56
58
|
};
|
|
57
59
|
if (AUTH_OPTIONS.debug && !building) {
|
|
58
60
|
authModuleRaw.log.info('ui', ui);
|
|
@@ -139,6 +141,7 @@ export const getSafeOptions = () => {
|
|
|
139
141
|
cannotSignUp: AUTH_OPTIONS.strings?.cannotSignUp ??
|
|
140
142
|
"You can't signup by yourself! Contact the administrator.",
|
|
141
143
|
},
|
|
144
|
+
ui,
|
|
142
145
|
};
|
|
143
146
|
};
|
|
144
147
|
export const authModuleRaw = new Module({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{v as r,x as l,aa as o,J as m,K as p,M as u,O as d,P as f,R as g}from"./index-
|
|
1
|
+
import{v as r,x as l,aa as o,J as m,K as p,M as u,O as d,P as f,R as g}from"./index-DAjei0Ie.js";d();a[f]="src/lib/modules/storage/Page.svelte";function a(e,s){r(new.target),l(s,!1,a);var t=o("Hello from files");return m(e,t),p({...u()})}g(a);export{a as default};
|