firstly 0.0.12 → 0.0.13
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 +8 -0
- package/esm/api/index.d.ts +1 -0
- package/esm/api/index.js +3 -1
- package/esm/auth/server/AuthController.server.d.ts +1 -1
- package/esm/auth/server/AuthController.server.js +19 -19
- package/esm/auth/server/handleGuard.d.ts +16 -0
- package/esm/auth/server/handleGuard.js +67 -0
- package/esm/auth/server/index.d.ts +3 -1
- package/esm/auth/server/index.js +3 -1
- package/esm/auth/server/module.d.ts +102 -83
- package/esm/auth/server/module.js +55 -42
- package/esm/auth/server/providers/github.d.ts +2 -1
- package/esm/auth/server/providers/github.js +1 -1
- package/esm/auth/static/assets/Page-BUfjaN-D.d.ts +5 -0
- package/esm/auth/static/assets/Page-BUfjaN-D.js +19 -0
- package/esm/auth/static/assets/Page-CJ58H1vl.css +1 -0
- package/esm/auth/static/assets/Page-CaDAqmBS.d.ts +5 -0
- package/esm/auth/static/assets/Page-CaDAqmBS.js +1 -0
- package/esm/auth/static/assets/Page-DhdZddzJ.d.ts +5 -0
- package/esm/auth/static/assets/Page-DhdZddzJ.js +1 -0
- package/esm/auth/static/assets/index-BDy4A_14.css +4 -0
- package/esm/auth/static/assets/index-D-Ztdt2o.d.ts +54 -0
- package/esm/auth/static/assets/index-D-Ztdt2o.js +2 -0
- package/esm/auth/static/index.html +11 -11
- package/esm/bin/cmd.js +119 -48
- package/esm/cellsBuildor.js +1 -1
- package/esm/common.d.ts +5 -0
- package/esm/common.js +8 -0
- package/esm/cron/server/index.js +1 -1
- package/esm/feedback/FeedbackController.js +1 -2
- package/esm/feedback/ui/DialogIssue.svelte +52 -56
- package/esm/feedback/ui/DialogIssues.svelte +71 -71
- package/esm/feedback/ui/DialogMilestones.svelte +22 -22
- package/esm/index.d.ts +2 -5
- package/esm/index.js +2 -8
- package/esm/mail/templates/DefaultMail.svelte +17 -17
- package/esm/storeItem.d.ts +1 -4
- package/esm/storeItem.js +1 -1
- package/esm/storeList.d.ts +1 -4
- package/esm/sveltekit/server/index.d.ts +3 -0
- package/esm/sveltekit/server/index.js +3 -0
- package/esm/ui/Button.svelte +33 -33
- package/esm/ui/Button.svelte.d.ts +2 -2
- package/esm/ui/Clipboardable.svelte +6 -6
- package/esm/ui/Clipboardable.svelte.d.ts +4 -4
- package/esm/ui/Field.svelte +139 -149
- package/esm/ui/Field.svelte.d.ts +2 -2
- package/esm/ui/FieldGroup.svelte +38 -38
- package/esm/ui/Grid.svelte +212 -222
- package/esm/ui/GridLoading.svelte +18 -22
- package/esm/ui/GridPaginate.svelte +38 -38
- package/esm/ui/Icon.svelte +50 -49
- package/esm/ui/Icon.svelte.d.ts +18 -18
- package/esm/ui/Loading.svelte +5 -5
- package/esm/ui/Tooltip.svelte +16 -16
- package/esm/ui/dialog/DialogForm.svelte +22 -22
- package/esm/ui/dialog/DialogManagement.svelte +74 -74
- package/esm/ui/dialog/DialogPrimitive.svelte +50 -50
- package/esm/ui/dialog/FormEditAction.svelte +34 -34
- package/esm/ui/dialog/dialog.d.ts +1 -4
- package/esm/ui/internals/FieldContainer.svelte +11 -11
- package/esm/ui/internals/FieldContainer.svelte.d.ts +3 -3
- package/esm/ui/internals/Input.svelte +25 -25
- package/esm/ui/internals/Input.svelte.d.ts +1 -1
- package/esm/ui/internals/Textarea.svelte +21 -21
- package/esm/ui/internals/Textarea.svelte.d.ts +2 -2
- package/esm/ui/internals/select/MultiSelectMelt.svelte +69 -73
- package/esm/ui/internals/select/SelectMelt.svelte +86 -86
- package/esm/ui/internals/select/SelectRadio.svelte +22 -22
- package/esm/ui/link/Link.svelte +14 -14
- package/esm/ui/link/Link.svelte.d.ts +3 -4
- package/esm/ui/link/LinkPlus.svelte +33 -35
- package/package.json +14 -18
- package/esm/auth/static/assets/Page-Bb8bFlrP.d.ts +0 -4
- package/esm/auth/static/assets/Page-Bb8bFlrP.js +0 -1
- package/esm/auth/static/assets/Page-BxomFlZ8.d.ts +0 -4
- package/esm/auth/static/assets/Page-BxomFlZ8.js +0 -1
- package/esm/auth/static/assets/Page-CaIYu0-y.d.ts +0 -6
- package/esm/auth/static/assets/Page-CaIYu0-y.js +0 -19
- package/esm/auth/static/assets/Page-MkYglNtu.css +0 -1
- package/esm/auth/static/assets/index-Bl0Bk5u0.d.ts +0 -64
- package/esm/auth/static/assets/index-Bl0Bk5u0.js +0 -2
- package/esm/auth/static/assets/index-R27C_TlP.css +0 -4
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import bcrypt from '
|
|
1
|
+
import bcrypt from 'bcryptjs';
|
|
2
2
|
import { EntityError, remult } from 'remult';
|
|
3
3
|
import { red } from '@kitql/helpers';
|
|
4
4
|
import { getRelativePackagePath } from '@kitql/internals';
|
|
5
|
+
import { building } from '$app/environment';
|
|
5
6
|
import { AuthController } from '..';
|
|
6
7
|
import { FF_Role } from '../..';
|
|
7
8
|
import { Module } from '../../api';
|
|
@@ -23,42 +24,44 @@ const buildUrlOrDefault = (base, userSetting, fallback) => {
|
|
|
23
24
|
export const getSafeOptions = () => {
|
|
24
25
|
const signUp = AUTH_OPTIONS.signUp ?? true;
|
|
25
26
|
const base = AUTH_OPTIONS.ui === false ? 'NO_BASE_PATH' : (AUTH_OPTIONS.ui?.paths?.base ?? '/ff/auth');
|
|
27
|
+
const ui = AUTH_OPTIONS.ui === false
|
|
28
|
+
? undefined
|
|
29
|
+
: {
|
|
30
|
+
paths: {
|
|
31
|
+
base,
|
|
32
|
+
sign_up: signUp ? buildUrlOrDefault(base, AUTH_OPTIONS.ui?.paths?.sign_up, 'sign-up') : false,
|
|
33
|
+
sign_in: buildUrlOrDefault(base, AUTH_OPTIONS.ui?.paths?.sign_in, 'sign-in'),
|
|
34
|
+
forgot_password: buildUrlOrDefault(base, AUTH_OPTIONS.ui?.paths?.forgot_password, 'forgot-password'),
|
|
35
|
+
reset_password: buildUrlOrDefault(base, AUTH_OPTIONS.ui?.paths?.reset_password, 'reset-password'),
|
|
36
|
+
verify_email: buildUrlOrDefault(base, AUTH_OPTIONS.ui?.paths?.verify_email, 'verify-email'),
|
|
37
|
+
},
|
|
38
|
+
strings: {
|
|
39
|
+
app_name: AUTH_OPTIONS.ui?.strings?.app_name ?? '',
|
|
40
|
+
email: AUTH_OPTIONS.ui?.strings?.email ?? 'Email',
|
|
41
|
+
email_placeholder: AUTH_OPTIONS.ui?.strings?.email_placeholder ?? 'Your email address',
|
|
42
|
+
password: AUTH_OPTIONS.ui?.strings?.password ?? 'Password',
|
|
43
|
+
password_placeholder: AUTH_OPTIONS.ui?.strings?.password_placeholder ?? 'Your password',
|
|
44
|
+
confirm: AUTH_OPTIONS.ui?.strings?.confirm ?? 'Confirm',
|
|
45
|
+
reset: AUTH_OPTIONS.ui?.strings?.reset ?? 'Reset',
|
|
46
|
+
btn_sign_up: AUTH_OPTIONS.ui?.strings?.btn_sign_up ?? 'Sign up',
|
|
47
|
+
btn_sign_in: AUTH_OPTIONS.ui?.strings?.btn_sign_in ?? 'Sign in',
|
|
48
|
+
forgot_password: AUTH_OPTIONS.ui?.strings?.forgot_password ?? 'Forgot your password?',
|
|
49
|
+
send_password_reset_instructions: AUTH_OPTIONS.ui?.strings?.send_password_reset_instructions ??
|
|
50
|
+
'Send password reset instructions',
|
|
51
|
+
back_to_sign_in: AUTH_OPTIONS.ui?.strings?.back_to_sign_in ?? 'Back to sign in',
|
|
52
|
+
},
|
|
53
|
+
images: {
|
|
54
|
+
main: AUTH_OPTIONS.ui?.images?.main ?? '',
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
if (AUTH_OPTIONS.debug && !building) {
|
|
58
|
+
authModuleRaw.log.info('ui', ui);
|
|
59
|
+
}
|
|
26
60
|
const firstlyData = {
|
|
27
61
|
module: 'auth',
|
|
28
62
|
debug: AUTH_OPTIONS.debug,
|
|
29
63
|
props: {
|
|
30
|
-
ui
|
|
31
|
-
? undefined
|
|
32
|
-
: {
|
|
33
|
-
paths: {
|
|
34
|
-
base,
|
|
35
|
-
sign_up: signUp
|
|
36
|
-
? buildUrlOrDefault(base, AUTH_OPTIONS.ui?.paths?.sign_up, 'sign-up')
|
|
37
|
-
: false,
|
|
38
|
-
sign_in: buildUrlOrDefault(base, AUTH_OPTIONS.ui?.paths?.sign_in, 'sign-in'),
|
|
39
|
-
forgot_password: buildUrlOrDefault(base, AUTH_OPTIONS.ui?.paths?.forgot_password, 'forgot-password'),
|
|
40
|
-
reset_password: buildUrlOrDefault(base, AUTH_OPTIONS.ui?.paths?.reset_password, 'reset-password'),
|
|
41
|
-
verify_email: buildUrlOrDefault(base, AUTH_OPTIONS.ui?.paths?.verify_email, 'verify-email'),
|
|
42
|
-
},
|
|
43
|
-
strings: {
|
|
44
|
-
app_name: AUTH_OPTIONS.ui?.strings?.app_name ?? '',
|
|
45
|
-
email: AUTH_OPTIONS.ui?.strings?.email ?? 'Email',
|
|
46
|
-
email_placeholder: AUTH_OPTIONS.ui?.strings?.email_placeholder ?? 'Your email address',
|
|
47
|
-
password: AUTH_OPTIONS.ui?.strings?.password ?? 'Password',
|
|
48
|
-
password_placeholder: AUTH_OPTIONS.ui?.strings?.password_placeholder ?? 'Your password',
|
|
49
|
-
confirm: AUTH_OPTIONS.ui?.strings?.confirm ?? 'Confirm',
|
|
50
|
-
reset: AUTH_OPTIONS.ui?.strings?.reset ?? 'Reset',
|
|
51
|
-
btn_sign_up: AUTH_OPTIONS.ui?.strings?.btn_sign_up ?? 'Sign up',
|
|
52
|
-
btn_sign_in: AUTH_OPTIONS.ui?.strings?.btn_sign_in ?? 'Sign in',
|
|
53
|
-
forgot_password: AUTH_OPTIONS.ui?.strings?.forgot_password ?? 'Forgot your password?',
|
|
54
|
-
send_password_reset_instructions: AUTH_OPTIONS.ui?.strings?.send_password_reset_instructions ??
|
|
55
|
-
'Send password reset instructions',
|
|
56
|
-
back_to_sign_in: AUTH_OPTIONS.ui?.strings?.back_to_sign_in ?? 'Back to sign in',
|
|
57
|
-
},
|
|
58
|
-
images: {
|
|
59
|
-
main: AUTH_OPTIONS.ui?.images?.main ?? '',
|
|
60
|
-
},
|
|
61
|
-
},
|
|
64
|
+
ui,
|
|
62
65
|
},
|
|
63
66
|
};
|
|
64
67
|
let uiStaticPath = AUTH_OPTIONS.uiStaticPath ?? '';
|
|
@@ -91,29 +94,33 @@ export const getSafeOptions = () => {
|
|
|
91
94
|
};
|
|
92
95
|
};
|
|
93
96
|
}
|
|
94
|
-
function
|
|
95
|
-
if (typeof
|
|
97
|
+
function validateInput({ identifier, password }) {
|
|
98
|
+
if (typeof identifier !== 'string' || identifier.length === 0) {
|
|
99
|
+
throw new EntityError({ message: 'Invalid identifier' });
|
|
100
|
+
}
|
|
101
|
+
if (typeof password !== 'string') {
|
|
96
102
|
throw new EntityError({ message: 'Invalid password' });
|
|
97
103
|
}
|
|
104
|
+
if (password.length < 6 || password.length > 255) {
|
|
105
|
+
throw new EntityError({ message: 'Password too short or too long!' });
|
|
106
|
+
}
|
|
98
107
|
}
|
|
99
108
|
function passwordHash(password) {
|
|
100
|
-
|
|
101
|
-
return bcrypt.hashSync(password, AUTH_OPTIONS.providers?.password?.settings?.bcrypt?.saltRounds ?? 10);
|
|
109
|
+
return bcrypt.hashSync(password, AUTH_OPTIONS.providers?.password?.algo?.bcrypt?.saltRounds ?? 10);
|
|
102
110
|
}
|
|
103
111
|
function passwordVerify(password, hash) {
|
|
104
112
|
return bcrypt.compareSync(password, hash);
|
|
105
113
|
}
|
|
106
114
|
return {
|
|
107
115
|
User: (AUTH_OPTIONS.customEntities?.User ?? FFAuthUser),
|
|
108
|
-
Session: (AUTH_OPTIONS.customEntities?.Session ??
|
|
109
|
-
FFAuthUserSession),
|
|
116
|
+
Session: (AUTH_OPTIONS.customEntities?.Session ?? FFAuthUserSession),
|
|
110
117
|
Account: (AUTH_OPTIONS.customEntities?.Account ?? FFAuthAccount),
|
|
111
118
|
signUp,
|
|
112
119
|
password: {
|
|
113
120
|
enabled: AUTH_OPTIONS.providers?.password ? true : false,
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
121
|
+
validateInput: AUTH_OPTIONS.providers?.password?.algo?.validateInput ?? validateInput,
|
|
122
|
+
hash: AUTH_OPTIONS.providers?.password?.algo?.hash ?? passwordHash,
|
|
123
|
+
verify: AUTH_OPTIONS.providers?.password?.algo?.verify ?? passwordVerify,
|
|
117
124
|
},
|
|
118
125
|
otp: { enabled: AUTH_OPTIONS.providers?.otp ? true : false },
|
|
119
126
|
verifiedMethod: AUTH_OPTIONS.verifiedMethod ?? 'auto',
|
|
@@ -126,6 +133,12 @@ export const getSafeOptions = () => {
|
|
|
126
133
|
cookieName: AUTH_OPTIONS.session?.COOKIE_NAME ?? 'firstly_auth_session',
|
|
127
134
|
},
|
|
128
135
|
providers: AUTH_OPTIONS.providers,
|
|
136
|
+
strings: {
|
|
137
|
+
resetPasswordSend: AUTH_OPTIONS.strings?.resetPasswordSend ?? 'Mail sent ! You can now close this window.',
|
|
138
|
+
anErrorOccurred: AUTH_OPTIONS.strings?.anErrorOccurred ?? 'An error occurred, contact the administrator.',
|
|
139
|
+
cannotSignUp: AUTH_OPTIONS.strings?.cannotSignUp ??
|
|
140
|
+
"You can't signup by yourself! Contact the administrator.",
|
|
141
|
+
},
|
|
129
142
|
};
|
|
130
143
|
};
|
|
131
144
|
export const authModuleRaw = new Module({
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { OAuth2Tokens } from 'arctic';
|
|
2
|
+
import { GitHub } from 'arctic';
|
|
2
3
|
import { type FFOAuth2Provider, type OAuth2UserInfo, type ProviderAuthorizationURLOptions } from '../module';
|
|
3
4
|
/**
|
|
4
5
|
* ## GitHub OAuth2 provider
|