firstly 0.0.7 → 0.0.9
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 +23 -0
- package/esm/BaseEnum.d.ts +2 -13
- package/esm/BaseEnum.js +0 -4
- package/esm/FF_Entity.js +20 -4
- package/esm/SqlDatabase/FF_LogToConsole.d.ts +4 -1
- package/esm/SqlDatabase/FF_LogToConsole.js +15 -8
- package/esm/api/index.d.ts +4 -4
- package/esm/api/index.js +13 -13
- package/esm/auth/Adapter.js +1 -9
- package/esm/auth/AuthController.server.d.ts +1 -2
- package/esm/auth/AuthController.server.js +21 -12
- package/esm/auth/RoleHelpers.d.ts +2 -2
- package/esm/auth/RoleHelpers.js +6 -4
- package/esm/auth/client/Auth.d.ts +11 -4
- package/esm/auth/client/Auth.js +14 -6
- package/esm/auth/{Entities.d.ts → client/Entities.d.ts} +4 -4
- package/esm/auth/{Entities.js → client/Entities.js} +33 -17
- package/esm/auth/client/index.d.ts +5 -0
- package/esm/auth/client/index.js +5 -0
- package/esm/auth/helper.d.ts +6 -1
- package/esm/auth/helper.js +11 -4
- package/esm/auth/index.d.ts +11 -11
- package/esm/auth/index.js +93 -78
- package/esm/auth/providers/github.js +2 -1
- package/esm/auth/providers/index.js +1 -1
- package/esm/auth/providers/strava.js +2 -1
- package/esm/auth/static/assets/{Page-RIbXHuZG.d.ts → Page-BEFYPjis.d.ts} +1 -1
- package/esm/auth/static/assets/{Page-RIbXHuZG.js → Page-BEFYPjis.js} +1 -1
- package/esm/auth/static/assets/Page-Cfysx_UV.d.ts +6 -0
- package/esm/auth/static/assets/Page-Cfysx_UV.js +18 -0
- package/esm/auth/static/assets/{Page-DBWJjlEQ.d.ts → Page-DtgkOCJs.d.ts} +1 -1
- package/esm/auth/static/assets/{Page-DBWJjlEQ.js → Page-DtgkOCJs.js} +1 -1
- package/esm/auth/static/assets/index-QypqCYwC.d.ts +63 -0
- package/esm/auth/static/assets/index-QypqCYwC.js +2 -0
- package/esm/auth/static/index.html +1 -1
- package/esm/auth/types.d.ts +7 -5
- package/esm/bin/cmd.js +28 -14
- package/esm/cellsBuildor.d.ts +5 -4
- package/esm/cellsBuildor.js +42 -17
- package/esm/changeLog/index.d.ts +23 -7
- package/esm/changeLog/index.js +24 -18
- package/esm/feedback/FeedbackController.d.ts +12 -3
- package/esm/feedback/FeedbackController.js +62 -13
- package/esm/feedback/index.d.ts +1 -0
- package/esm/feedback/ui/DialogIssue.svelte +26 -7
- package/esm/feedback/ui/DialogIssues.svelte +7 -2
- package/esm/handle/index.d.ts +1 -1
- package/esm/helper.js +3 -2
- package/esm/index.d.ts +10 -3
- package/esm/index.js +1 -1
- package/esm/mail/index.js +15 -10
- package/esm/storeList.d.ts +3 -1
- package/esm/storeList.js +20 -10
- package/esm/ui/Field.svelte +11 -13
- package/esm/ui/FieldGroup.svelte +4 -2
- package/esm/ui/Grid.svelte +90 -20
- package/esm/ui/Grid.svelte.d.ts +1 -0
- package/esm/ui/GridPaginate.svelte +12 -10
- package/esm/ui/GridPaginate.svelte.d.ts +1 -1
- package/esm/ui/dialog/DialogPrimitive.svelte +1 -5
- package/esm/ui/dialog/dialog.d.ts +10 -8
- package/esm/ui/dialog/dialog.js +9 -10
- package/esm/ui/internals/Input.svelte +10 -1
- package/esm/ui/link/LinkPlus.svelte +41 -29
- package/esm/vite/index.js +4 -1
- package/package.json +8 -8
- package/esm/auth/static/assets/Page-apb_xgZT.d.ts +0 -6
- package/esm/auth/static/assets/Page-apb_xgZT.js +0 -18
- package/esm/auth/static/assets/index-qfq98Nyd.d.ts +0 -63
- package/esm/auth/static/assets/index-qfq98Nyd.js +0 -2
package/esm/auth/helper.js
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { remult } from 'remult';
|
|
2
2
|
import { lucia } from '.';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Create or extend a session for a user.
|
|
5
|
+
* If you pass a session, it will extend it.
|
|
6
|
+
*/
|
|
7
|
+
export async function createOrExtendSession(userId, session) {
|
|
8
|
+
const sessionToUser = session ? session : await lucia.createSession(userId, {});
|
|
9
|
+
const sessionCookie = lucia.createSessionCookie(sessionToUser.id);
|
|
10
|
+
remult.context.setCookie(sessionCookie.name, sessionCookie.value, {
|
|
11
|
+
path: '/',
|
|
12
|
+
...sessionCookie.attributes,
|
|
13
|
+
});
|
|
7
14
|
}
|
package/esm/auth/index.d.ts
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
import type { OAuth2Provider as ArcticOAuth2Provider, OAuth2ProviderWithPKCE as ArcticOAuth2ProviderWithPKCE } from 'arctic';
|
|
2
2
|
import { Lucia, type SessionCookieOptions } from 'lucia';
|
|
3
3
|
import type { ClassType, UserInfo } from 'remult';
|
|
4
|
-
import { Log } from '@kitql/helpers';
|
|
5
4
|
import type { Module } from '../api';
|
|
6
5
|
import type { RecursivePartial, ResolvedType } from '../utils/types';
|
|
7
|
-
import { FFAuthAccount,
|
|
6
|
+
import { FFAuthAccount, FFAuthUser, FFAuthUserSession } from './client/Entities';
|
|
7
|
+
import { initRoleFromEnv } from './RoleHelpers';
|
|
8
8
|
import type { firstlyData, firstlyDataAuth } from './types';
|
|
9
9
|
export type { firstlyData };
|
|
10
|
-
export { FFAuthUser, FFAuthAccount, FFAuthProvider, FFAuthUserSession };
|
|
11
10
|
export type AuthorizationURLOptions = Record<string, {
|
|
12
11
|
scopes?: string[];
|
|
13
12
|
}>;
|
|
14
13
|
export type DynamicAuthorizationURLOptions<T extends FFOAuth2Provider[] = FFOAuth2Provider[]> = T extends Array<infer O> ? O extends FFOAuth2Provider ? {
|
|
15
14
|
[P in O['name']]: ReturnType<O['authorizationURLOptions']>;
|
|
16
15
|
} : never : never;
|
|
17
|
-
export declare const logAuth: Log;
|
|
18
|
-
export { FF_Auth_Role } from './Entities';
|
|
19
16
|
type OAuth2UserInfo = {
|
|
20
17
|
raw?: any;
|
|
21
18
|
providerUserId: string;
|
|
@@ -37,7 +34,9 @@ type AuthOptions<TUserEntity extends FFAuthUser = FFAuthUser, TSessionEntity ext
|
|
|
37
34
|
};
|
|
38
35
|
debug?: boolean;
|
|
39
36
|
ui?: false | RecursivePartial<firstlyDataAuth['ui']>;
|
|
40
|
-
/**
|
|
37
|
+
/** Usefull to overwrite where the static files are */
|
|
38
|
+
uiStaticPath?: string;
|
|
39
|
+
/** in secondes @default 30 days */
|
|
41
40
|
sessionExpiresIn?: number;
|
|
42
41
|
sessionCookie?: SessionCookieOptions;
|
|
43
42
|
defaultRedirect?: string;
|
|
@@ -61,6 +60,7 @@ type AuthOptions<TUserEntity extends FFAuthUser = FFAuthUser, TSessionEntity ext
|
|
|
61
60
|
email: string;
|
|
62
61
|
url: string;
|
|
63
62
|
}) => Promise<void>;
|
|
63
|
+
transformDbUserToClientUser?: (session: any, user: TUserEntity) => DatabaseUserAttributes;
|
|
64
64
|
providers?: {
|
|
65
65
|
demo?: {
|
|
66
66
|
name: string;
|
|
@@ -122,13 +122,16 @@ export declare const getSafeOptions: () => {
|
|
|
122
122
|
verifiedMethod: "email" | "auto" | "manual";
|
|
123
123
|
redirectUrl: string;
|
|
124
124
|
firstlyData: firstlyData;
|
|
125
|
+
transformDbUserToClientUser: (session: any, user: FFAuthUser) => DatabaseUserAttributes;
|
|
126
|
+
uiStaticPath: string;
|
|
125
127
|
};
|
|
126
128
|
/**
|
|
127
129
|
* To enable authentication in your app in a few lines of code.
|
|
128
130
|
* _Info: index: -777_
|
|
129
131
|
*/
|
|
130
132
|
export declare const auth: (o: AuthOptions) => Module;
|
|
131
|
-
export
|
|
133
|
+
export { initRoleFromEnv };
|
|
134
|
+
export declare let lucia: Lucia<Record<any, any>, UserInfo>;
|
|
132
135
|
declare module 'lucia' {
|
|
133
136
|
interface Register {
|
|
134
137
|
Lucia: typeof lucia;
|
|
@@ -138,10 +141,7 @@ declare module 'lucia' {
|
|
|
138
141
|
interface DatabaseSessionAttributes {
|
|
139
142
|
}
|
|
140
143
|
}
|
|
141
|
-
interface DatabaseUserAttributes {
|
|
142
|
-
id: string;
|
|
143
|
-
name: string;
|
|
144
|
-
roles: string[];
|
|
144
|
+
interface DatabaseUserAttributes extends UserInfo {
|
|
145
145
|
session: {
|
|
146
146
|
id: string;
|
|
147
147
|
expiresAt: Date;
|
package/esm/auth/index.js
CHANGED
|
@@ -2,33 +2,28 @@ import { redirect } from '@sveltejs/kit';
|
|
|
2
2
|
import { DEV } from 'esm-env';
|
|
3
3
|
import { Lucia, TimeSpan } from 'lucia';
|
|
4
4
|
import { remult } from 'remult';
|
|
5
|
-
import {
|
|
5
|
+
import { red } from '@kitql/helpers';
|
|
6
6
|
import { getRelativePackagePath, read } from '@kitql/internals';
|
|
7
|
-
import { env } from '$env/dynamic/private';
|
|
8
7
|
import { FF_Role } from '../';
|
|
9
8
|
import { RemultLuciaAdapter } from './Adapter';
|
|
10
9
|
import { AuthControllerServer } from './AuthController.server';
|
|
11
|
-
import { Auth } from './client';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
10
|
+
import { Auth, logAuth } from './client';
|
|
11
|
+
import { FF_Role_Auth, FFAuthAccount, FFAuthProvider, FFAuthUser, FFAuthUserSession, } from './client/Entities';
|
|
12
|
+
import { createOrExtendSession } from './helper';
|
|
14
13
|
import { initRoleFromEnv } from './RoleHelpers';
|
|
15
|
-
export { FFAuthUser, FFAuthAccount, FFAuthProvider, FFAuthUserSession };
|
|
16
|
-
export const logAuth = new Log('firstly | auth');
|
|
17
|
-
export { FF_Auth_Role } from './Entities';
|
|
18
14
|
export let AUTH_OPTIONS = { ui: {} };
|
|
19
15
|
const buildUrlOrDefault = (base, userSetting, fallback) => {
|
|
20
|
-
if (userSetting) {
|
|
21
|
-
return
|
|
16
|
+
if (userSetting === false) {
|
|
17
|
+
return false;
|
|
22
18
|
}
|
|
23
|
-
|
|
19
|
+
if (userSetting === undefined) {
|
|
20
|
+
return `${base}/${fallback}`;
|
|
21
|
+
}
|
|
22
|
+
return `${base}/${userSetting}`;
|
|
24
23
|
};
|
|
25
24
|
export const getSafeOptions = () => {
|
|
26
25
|
const signUp = AUTH_OPTIONS.signUp ?? true;
|
|
27
|
-
const base = AUTH_OPTIONS.ui === false ? 'NO_BASE_PATH' : AUTH_OPTIONS.ui?.paths?.base ?? '/ff/auth';
|
|
28
|
-
// const oAuths =
|
|
29
|
-
// AUTH_OPTIONS.providers?.oAuths?.map((o) => {
|
|
30
|
-
// return o.name
|
|
31
|
-
// }) ?? []
|
|
26
|
+
const base = AUTH_OPTIONS.ui === false ? 'NO_BASE_PATH' : (AUTH_OPTIONS.ui?.paths?.base ?? '/ff/auth');
|
|
32
27
|
const firstlyData = {
|
|
33
28
|
module: 'auth',
|
|
34
29
|
debug: AUTH_OPTIONS.debug,
|
|
@@ -48,6 +43,8 @@ export const getSafeOptions = () => {
|
|
|
48
43
|
email: AUTH_OPTIONS.ui?.strings?.email ?? 'Email',
|
|
49
44
|
email_placeholder: AUTH_OPTIONS.ui?.strings?.email_placeholder ?? 'Your email address',
|
|
50
45
|
password: AUTH_OPTIONS.ui?.strings?.password ?? 'Password',
|
|
46
|
+
confirm: AUTH_OPTIONS.ui?.strings?.confirm ?? 'Confirm',
|
|
47
|
+
reset: AUTH_OPTIONS.ui?.strings?.reset ?? 'Reset',
|
|
51
48
|
btn_sign_up: AUTH_OPTIONS.ui?.strings?.btn_sign_up ?? 'Sign up',
|
|
52
49
|
btn_sign_in: AUTH_OPTIONS.ui?.strings?.btn_sign_in ?? 'Sign in',
|
|
53
50
|
forgot_password: AUTH_OPTIONS.ui?.strings?.forgot_password ?? 'Forgot your password?',
|
|
@@ -58,11 +55,45 @@ export const getSafeOptions = () => {
|
|
|
58
55
|
},
|
|
59
56
|
},
|
|
60
57
|
};
|
|
58
|
+
let uiStaticPath = AUTH_OPTIONS.uiStaticPath ?? '';
|
|
59
|
+
if (!AUTH_OPTIONS.uiStaticPath) {
|
|
60
|
+
const installedFirstlyPath = getRelativePackagePath('firstly');
|
|
61
|
+
if (installedFirstlyPath) {
|
|
62
|
+
uiStaticPath = `${installedFirstlyPath}/esm/auth/static/`;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
61
65
|
let redirectUrl = AUTH_OPTIONS.defaultRedirect ?? '/';
|
|
62
66
|
if (!redirectUrl.startsWith('/')) {
|
|
63
67
|
logAuth.error(`Invalid redirect url ${red(redirectUrl)} (it should be a local one starting with /)`);
|
|
64
68
|
redirectUrl = '/';
|
|
65
69
|
}
|
|
70
|
+
let transformDbUserToClientUserToUse;
|
|
71
|
+
if (AUTH_OPTIONS.transformDbUserToClientUser) {
|
|
72
|
+
transformDbUserToClientUserToUse = AUTH_OPTIONS.transformDbUserToClientUser;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
// Need in src/app.d.ts this code to be able to have the correct transformDbUserToClientUser returned type.
|
|
76
|
+
// In the lib, let's force to this default
|
|
77
|
+
/**
|
|
78
|
+
* declare module 'remult' {
|
|
79
|
+
* export interface UserInfo {
|
|
80
|
+
* specificThing: string
|
|
81
|
+
* }
|
|
82
|
+
* }
|
|
83
|
+
*/
|
|
84
|
+
// @ts-ignore
|
|
85
|
+
transformDbUserToClientUserToUse = (session, user) => {
|
|
86
|
+
return {
|
|
87
|
+
id: user.id,
|
|
88
|
+
name: user.identifier,
|
|
89
|
+
roles: user.roles,
|
|
90
|
+
session: {
|
|
91
|
+
id: session.id,
|
|
92
|
+
expiresAt: session.expiresAt,
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
}
|
|
66
97
|
return {
|
|
67
98
|
User: AUTH_OPTIONS.customEntities?.User ?? FFAuthUser,
|
|
68
99
|
Session: AUTH_OPTIONS.customEntities?.Session ?? FFAuthUserSession,
|
|
@@ -73,6 +104,8 @@ export const getSafeOptions = () => {
|
|
|
73
104
|
verifiedMethod: AUTH_OPTIONS.verifiedMethod ?? 'auto',
|
|
74
105
|
redirectUrl,
|
|
75
106
|
firstlyData,
|
|
107
|
+
transformDbUserToClientUser: transformDbUserToClientUserToUse,
|
|
108
|
+
uiStaticPath,
|
|
76
109
|
};
|
|
77
110
|
};
|
|
78
111
|
/**
|
|
@@ -93,30 +126,51 @@ export const auth = (o) => {
|
|
|
93
126
|
Auth.signInOTPFn = AuthControllerServer.signInOTP;
|
|
94
127
|
Auth.verifyOtpFn = AuthControllerServer.verifyOtp;
|
|
95
128
|
Auth.signInOAuthGetUrlFn = AuthControllerServer.signInOAuthGetUrl;
|
|
129
|
+
const adapter = new RemultLuciaAdapter();
|
|
130
|
+
const defaultExpiresIn = 60 * 60 * 24 * 30; // 30 days
|
|
131
|
+
const sessionExpiresIn = new TimeSpan(AUTH_OPTIONS.sessionExpiresIn ?? defaultExpiresIn, 's');
|
|
132
|
+
lucia = new Lucia(adapter, {
|
|
133
|
+
sessionExpiresIn,
|
|
134
|
+
sessionCookie: {
|
|
135
|
+
name: AUTH_OPTIONS.sessionCookie?.name ?? 'firstly_auth_session',
|
|
136
|
+
expires: AUTH_OPTIONS.sessionCookie?.expires,
|
|
137
|
+
attributes: {
|
|
138
|
+
// set to `true` when using HTTPS
|
|
139
|
+
secure: !DEV,
|
|
140
|
+
...AUTH_OPTIONS.sessionCookie?.attributes,
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
getSessionAttributes: (attributes) => attributes,
|
|
144
|
+
getUserAttributes: (attributes) => attributes,
|
|
145
|
+
});
|
|
96
146
|
return {
|
|
97
147
|
name: 'auth',
|
|
98
148
|
index: -777,
|
|
99
149
|
entities: [oSafe.User, oSafe.Session, oSafe.Account],
|
|
100
150
|
controllers: [Auth],
|
|
101
151
|
initRequest: async (event) => {
|
|
102
|
-
//
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
152
|
+
// REMULT: storing user in local should probably be done in remult directly
|
|
153
|
+
if (event?.locals?.user) {
|
|
154
|
+
// console.log('initRequest OK')
|
|
155
|
+
remult.user = event.locals.user;
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
// console.log('initRequest WORK...')
|
|
159
|
+
// std session
|
|
160
|
+
const sessionId = event.cookies.get(lucia.sessionCookieName);
|
|
161
|
+
if (sessionId) {
|
|
162
|
+
const { session, user } = await lucia.validateSession(sessionId);
|
|
163
|
+
if (session && session.fresh) {
|
|
164
|
+
await createOrExtendSession(session.id, session);
|
|
165
|
+
}
|
|
166
|
+
remult.user = user ?? undefined;
|
|
167
|
+
if (event.locals) {
|
|
168
|
+
event.locals.user = user ?? undefined;
|
|
169
|
+
}
|
|
112
170
|
}
|
|
113
|
-
remult.user = user ?? undefined;
|
|
114
171
|
}
|
|
115
172
|
},
|
|
116
173
|
earlyReturn: async ({ event, resolve }) => {
|
|
117
|
-
// if (AUTH_OPTIONS.ui === false) {
|
|
118
|
-
// return { early: false }
|
|
119
|
-
// }
|
|
120
174
|
const oSafe = getSafeOptions();
|
|
121
175
|
if (event.url.pathname === oSafe.firstlyData.props.ui?.paths?.verify_email) {
|
|
122
176
|
const token = event.url.searchParams.get('token') ?? '';
|
|
@@ -138,19 +192,12 @@ export const auth = (o) => {
|
|
|
138
192
|
account.expiresAt = undefined;
|
|
139
193
|
account.lastVerifiedAt = new Date();
|
|
140
194
|
await remult.repo(oSafe.Account).save(account);
|
|
141
|
-
await
|
|
195
|
+
await createOrExtendSession(account.userId);
|
|
142
196
|
redirect(302, oSafe.redirectUrl);
|
|
143
197
|
}
|
|
144
|
-
// For lib author (us), it's good to have this local path.
|
|
145
|
-
let staticPath = './src/lib/auth/static/';
|
|
146
|
-
// For users, let's serve the static files from the installed package
|
|
147
|
-
const installedFirstlyPath = getRelativePackagePath('firstly');
|
|
148
|
-
if (installedFirstlyPath) {
|
|
149
|
-
staticPath = `${installedFirstlyPath}/esm/auth/static/`;
|
|
150
|
-
}
|
|
151
198
|
if (oSafe.firstlyData.props.ui?.paths?.base &&
|
|
152
199
|
event.url.pathname.startsWith(oSafe.firstlyData.props.ui.paths.base)) {
|
|
153
|
-
const content = read(`${
|
|
200
|
+
const content = read(`${oSafe.uiStaticPath}index.html`);
|
|
154
201
|
return {
|
|
155
202
|
early: true,
|
|
156
203
|
resolve: new Response(content + `<script>const firstlyData = ${JSON.stringify(oSafe.firstlyData)}</script>`, {
|
|
@@ -159,7 +206,7 @@ export const auth = (o) => {
|
|
|
159
206
|
};
|
|
160
207
|
}
|
|
161
208
|
if (event.url.pathname.startsWith('/api/static')) {
|
|
162
|
-
const content = read(`${
|
|
209
|
+
const content = read(`${oSafe.uiStaticPath}${event.url.pathname.replaceAll('/api/static/', '')}`);
|
|
163
210
|
if (content) {
|
|
164
211
|
const seg = event.url.pathname.split('.');
|
|
165
212
|
const map = {
|
|
@@ -250,7 +297,7 @@ export const auth = (o) => {
|
|
|
250
297
|
account.token = tokens.accessToken;
|
|
251
298
|
await remult.repo(oSafe.Account).save(account);
|
|
252
299
|
}
|
|
253
|
-
await
|
|
300
|
+
await createOrExtendSession(account.userId);
|
|
254
301
|
event.cookies.delete(`${keyState}_oauth_state`, { path: '/' });
|
|
255
302
|
event.cookies.delete(`code_verifier`, { path: '/' });
|
|
256
303
|
}
|
|
@@ -259,43 +306,11 @@ export const auth = (o) => {
|
|
|
259
306
|
return { early: false };
|
|
260
307
|
},
|
|
261
308
|
initApi: async () => {
|
|
262
|
-
await initRoleFromEnv(logAuth, oSafe.User,
|
|
263
|
-
await initRoleFromEnv(logAuth, oSafe.User,
|
|
309
|
+
await initRoleFromEnv(logAuth, oSafe.User, 'FF_ROLE_ADMIN', FF_Role.Admin);
|
|
310
|
+
await initRoleFromEnv(logAuth, oSafe.User, 'FF_ROLE_AUTH_ADMIN', FF_Role_Auth.Admin);
|
|
264
311
|
},
|
|
265
312
|
};
|
|
266
313
|
};
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
export
|
|
270
|
-
sessionExpiresIn: new TimeSpan(AUTH_OPTIONS.sessionExpiresIn ?? defaultExpiresIn, 's'),
|
|
271
|
-
sessionCookie: {
|
|
272
|
-
name: AUTH_OPTIONS.sessionCookie?.name ?? 'remult_auth_session',
|
|
273
|
-
expires: AUTH_OPTIONS.sessionCookie?.expires,
|
|
274
|
-
attributes: {
|
|
275
|
-
// set to `true` when using HTTPS
|
|
276
|
-
secure: !DEV,
|
|
277
|
-
...AUTH_OPTIONS.sessionCookie?.attributes,
|
|
278
|
-
},
|
|
279
|
-
},
|
|
280
|
-
getSessionAttributes: (attributes) => {
|
|
281
|
-
return {
|
|
282
|
-
...attributes,
|
|
283
|
-
};
|
|
284
|
-
},
|
|
285
|
-
getUserAttributes(attributes) {
|
|
286
|
-
// @ts-expect-error
|
|
287
|
-
delete attributes['createdAt'];
|
|
288
|
-
// @ts-expect-error
|
|
289
|
-
delete attributes['updatedAt'];
|
|
290
|
-
// to remove relations
|
|
291
|
-
for (const key in attributes) {
|
|
292
|
-
if (attributes[key] === undefined) {
|
|
293
|
-
delete attributes[key];
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
return attributes;
|
|
297
|
-
// return {
|
|
298
|
-
// ...attributes,
|
|
299
|
-
// }
|
|
300
|
-
},
|
|
301
|
-
});
|
|
314
|
+
export { initRoleFromEnv };
|
|
315
|
+
// Maybe moving this to /auth/server.ts would be better, people will be able to import from firstly all the time
|
|
316
|
+
export let lucia;
|
|
@@ -2,7 +2,8 @@ import { GitHub } from 'arctic';
|
|
|
2
2
|
import { remult } from 'remult';
|
|
3
3
|
import { env } from '$env/dynamic/private';
|
|
4
4
|
import { checkOAuthConfig } from '.';
|
|
5
|
-
import {
|
|
5
|
+
import {} from '../';
|
|
6
|
+
import { logAuth } from '../client';
|
|
6
7
|
//------------------------------
|
|
7
8
|
// For developers (future me ?), To do another OAuth2 provider:
|
|
8
9
|
// Replace GITHUB / Github / github
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { cyan, gray, green, italic, yellow } from '@kitql/helpers';
|
|
2
|
-
import { logAuth } from '..';
|
|
3
2
|
import { mask } from '../../formats/strings';
|
|
3
|
+
import { logAuth } from '../client';
|
|
4
4
|
export const checkOAuthConfig = (name, clientId, secret, urlForKeys, withThrow) => {
|
|
5
5
|
if (!clientId || !secret) {
|
|
6
6
|
const msg = `Wrong configuration for ${green(name)} provider.
|
|
@@ -2,7 +2,8 @@ import { Strava } from 'arctic';
|
|
|
2
2
|
import { remult } from 'remult';
|
|
3
3
|
import { env } from '$env/dynamic/private';
|
|
4
4
|
import { checkOAuthConfig } from '.';
|
|
5
|
-
import {
|
|
5
|
+
import {} from '../';
|
|
6
|
+
import { logAuth } from '../client';
|
|
6
7
|
/**
|
|
7
8
|
* ## Strava OAuth2 provider
|
|
8
9
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{S as l,b as d,a as f,d as i,h as m,M as p,t as u,n as r,z as h}from"./index-
|
|
1
|
+
import{S as l,b as d,a as f,d as i,h as m,M as p,t as u,n as r,z as h}from"./index-QypqCYwC.js";function c(s){let e;const n={c:function(){e=p("Hello from admin")},l:function(t){throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option")},m:function(t,o){u(t,e,o)},p:r,i:r,o:r,d:function(t){t&&h(e)}};return i("SvelteRegisterBlock",{block:n,id:c.name,type:"component",source:"",ctx:s}),n}function w(s,e){let{$$slots:n={},$$scope:a}=e;m("Page",n,[]);const t=[];return Object.keys(e).forEach(o=>{!~t.indexOf(o)&&o.slice(0,2)!=="$$"&&o!=="slot"&&console.warn(`<Page> was created with unknown prop '${o}'`)}),[]}class v extends l{constructor(e){super(e),d(this,e,w,c,f,{}),i("SvelteRegisterComponent",{component:this,tagName:"Page",options:e,id:c.name})}}export{v as default};
|