firstly 0.0.13 → 0.0.14

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.
Files changed (104) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/esm/ROUTES.d.ts +2 -0
  3. package/esm/ROUTES.js +1 -0
  4. package/esm/api/index.d.ts +8 -0
  5. package/esm/auth/AuthController.d.ts +12 -23
  6. package/esm/auth/AuthController.js +12 -31
  7. package/esm/auth/server/AuthController.server.d.ts +11 -11
  8. package/esm/auth/server/AuthController.server.js +83 -18
  9. package/esm/auth/server/helperFirstly.d.ts +1 -1
  10. package/esm/auth/server/helperFirstly.js +1 -0
  11. package/esm/auth/server/module.d.ts +3 -6
  12. package/esm/auth/server/providers/github.d.ts +2 -1
  13. package/esm/auth/server/providers/github.js +1 -1
  14. package/esm/auth/static/assets/Page-B0XXxe0N.d.ts +6 -0
  15. package/esm/auth/static/assets/Page-B0XXxe0N.js +1 -0
  16. package/esm/auth/static/assets/Page-DdKMiUZn.d.ts +6 -0
  17. package/esm/auth/static/assets/Page-DdKMiUZn.js +20 -0
  18. package/esm/auth/static/assets/Page-UV_hqY7I.d.ts +6 -0
  19. package/esm/auth/static/assets/Page-UV_hqY7I.js +1 -0
  20. package/esm/auth/static/assets/Page-mK42zGEw.css +1 -0
  21. package/esm/auth/static/assets/index-C9jzxOBu.d.ts +151 -0
  22. package/esm/auth/static/assets/index-C9jzxOBu.js +42 -0
  23. package/esm/auth/static/index.html +2 -2
  24. package/esm/auth/types.d.ts +26 -3
  25. package/esm/bin/cmd.js +339 -139
  26. package/esm/feedback/FeedbackController.js +57 -51
  27. package/esm/feedback/server/index.d.ts +6 -15
  28. package/esm/feedback/server/index.js +4 -5
  29. package/esm/feedback/types.d.ts +14 -0
  30. package/esm/feedback/types.js +4 -0
  31. package/esm/feedback/ui/DialogIssue.svelte +78 -62
  32. package/esm/feedback/ui/DialogIssue.svelte.d.ts +20 -18
  33. package/esm/feedback/ui/DialogIssues.svelte +37 -28
  34. package/esm/feedback/ui/DialogIssues.svelte.d.ts +20 -18
  35. package/esm/feedback/ui/DialogMilestones.svelte +18 -12
  36. package/esm/feedback/ui/DialogMilestones.svelte.d.ts +18 -16
  37. package/esm/feedback/ui/Feedback.svelte +11 -9
  38. package/esm/feedback/ui/Feedback.svelte.d.ts +16 -14
  39. package/esm/mail/server/index.d.ts +9 -2
  40. package/esm/mail/server/index.js +3 -1
  41. package/esm/mail/templates/DefaultMail.svelte +64 -44
  42. package/esm/mail/templates/DefaultMail.svelte.d.ts +28 -26
  43. package/esm/server/index.d.ts +0 -0
  44. package/esm/server/index.js +1 -0
  45. package/esm/storeItem.d.ts +1 -1
  46. package/esm/storeList.d.ts +1 -1
  47. package/esm/sveltekit/server/index.d.ts +0 -9
  48. package/esm/ui/Button.svelte +79 -56
  49. package/esm/ui/Button.svelte.d.ts +34 -24
  50. package/esm/ui/Clipboardable.svelte +18 -11
  51. package/esm/ui/Clipboardable.svelte.d.ts +34 -23
  52. package/esm/ui/Field.svelte +189 -136
  53. package/esm/ui/Field.svelte.d.ts +13 -6
  54. package/esm/ui/FieldGroup.svelte +74 -53
  55. package/esm/ui/FieldGroup.svelte.d.ts +17 -6
  56. package/esm/ui/Grid.svelte +110 -86
  57. package/esm/ui/Grid.svelte.d.ts +17 -6
  58. package/esm/ui/GridLoading.svelte +10 -5
  59. package/esm/ui/GridLoading.svelte.d.ts +19 -17
  60. package/esm/ui/GridPaginate.svelte +30 -23
  61. package/esm/ui/GridPaginate.svelte.d.ts +21 -19
  62. package/esm/ui/Icon.svelte +67 -32
  63. package/esm/ui/Icon.svelte.d.ts +52 -43
  64. package/esm/ui/Loading.svelte +5 -3
  65. package/esm/ui/Loading.svelte.d.ts +29 -18
  66. package/esm/ui/Tooltip.svelte +22 -19
  67. package/esm/ui/Tooltip.svelte.d.ts +30 -20
  68. package/esm/ui/dialog/DialogForm.svelte +48 -41
  69. package/esm/ui/dialog/DialogForm.svelte.d.ts +18 -16
  70. package/esm/ui/dialog/DialogManagement.svelte.d.ts +22 -21
  71. package/esm/ui/dialog/DialogPrimitive.svelte +32 -26
  72. package/esm/ui/dialog/DialogPrimitive.svelte.d.ts +35 -25
  73. package/esm/ui/dialog/FormEditAction.svelte +20 -12
  74. package/esm/ui/dialog/FormEditAction.svelte.d.ts +13 -6
  75. package/esm/ui/dialog/dialog.d.ts +1 -1
  76. package/esm/ui/internals/FieldContainer.svelte +13 -6
  77. package/esm/ui/internals/FieldContainer.svelte.d.ts +37 -28
  78. package/esm/ui/internals/Input.svelte +110 -76
  79. package/esm/ui/internals/Input.svelte.d.ts +34 -32
  80. package/esm/ui/internals/Textarea.svelte +39 -31
  81. package/esm/ui/internals/Textarea.svelte.d.ts +31 -28
  82. package/esm/ui/internals/select/MultiSelectMelt.svelte +174 -126
  83. package/esm/ui/internals/select/MultiSelectMelt.svelte.d.ts +29 -27
  84. package/esm/ui/internals/select/SelectMelt.svelte +168 -133
  85. package/esm/ui/internals/select/SelectMelt.svelte.d.ts +34 -32
  86. package/esm/ui/internals/select/SelectRadio.svelte +17 -11
  87. package/esm/ui/internals/select/SelectRadio.svelte.d.ts +24 -22
  88. package/esm/ui/link/Link.svelte +11 -6
  89. package/esm/ui/link/Link.svelte.d.ts +31 -22
  90. package/esm/ui/link/LinkPlus.svelte +19 -16
  91. package/esm/ui/link/LinkPlus.svelte.d.ts +20 -18
  92. package/esm/vite/index.d.ts +2 -3
  93. package/esm/vite/index.js +33 -26
  94. package/package.json +5 -5
  95. package/esm/auth/static/assets/Page-BUfjaN-D.d.ts +0 -5
  96. package/esm/auth/static/assets/Page-BUfjaN-D.js +0 -19
  97. package/esm/auth/static/assets/Page-CJ58H1vl.css +0 -1
  98. package/esm/auth/static/assets/Page-CaDAqmBS.d.ts +0 -5
  99. package/esm/auth/static/assets/Page-CaDAqmBS.js +0 -1
  100. package/esm/auth/static/assets/Page-DhdZddzJ.d.ts +0 -5
  101. package/esm/auth/static/assets/Page-DhdZddzJ.js +0 -1
  102. package/esm/auth/static/assets/index-D-Ztdt2o.d.ts +0 -54
  103. package/esm/auth/static/assets/index-D-Ztdt2o.js +0 -2
  104. /package/esm/auth/static/assets/{index-BDy4A_14.css → index-DKWpA6v7.css} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # firstly
2
2
 
3
+ ## 0.0.14
4
+
5
+ ### Patch Changes
6
+
7
+ - [#85](https://github.com/jycouet/firstly/pull/85)
8
+ [`993f733`](https://github.com/jycouet/firstly/commit/993f73374591f134d76e30f8b5e4402b4d3112d0)
9
+ Thanks [@jycouet](https://github.com/jycouet)! - prepare JYC 014
10
+
3
11
  ## 0.0.13
4
12
 
5
13
  ### Patch Changes
package/esm/ROUTES.d.ts CHANGED
@@ -33,6 +33,7 @@ declare const AllObjs: {
33
33
  }) => string;
34
34
  "/": string;
35
35
  "/auth": string;
36
+ "/demo/task": string;
36
37
  "/mail": string;
37
38
  "/ui/dialog": string;
38
39
  "/ui/enum": string;
@@ -71,6 +72,7 @@ export type KIT_ROUTES = {
71
72
  PAGES: {
72
73
  '/': never;
73
74
  '/auth': never;
75
+ '/demo/task': never;
74
76
  '/mail': never;
75
77
  '/ui/dialog': never;
76
78
  '/ui/enum': never;
package/esm/ROUTES.js CHANGED
@@ -10,6 +10,7 @@
10
10
  const PAGES = {
11
11
  "/": `/`,
12
12
  "/auth": `/auth`,
13
+ "/demo/task": `/demo/task`,
13
14
  "/mail": `/mail`,
14
15
  "/ui/dialog": `/ui/dialog`,
15
16
  "/ui/enum": `/ui/enum`,
@@ -28,6 +28,14 @@ export declare class Module {
28
28
  type Options = RemultServerOptions<RequestEvent<Partial<Record<string, string>>, string | null>> & {
29
29
  modules?: Module[] | undefined;
30
30
  };
31
+ declare module 'remult' {
32
+ interface RemultContext {
33
+ request: RequestEvent;
34
+ setHeaders(headers: Record<string, string>): void;
35
+ setCookie(...args: Parameters<RequestEvent['cookies']['set']>): void;
36
+ deleteCookie(...args: Parameters<RequestEvent['cookies']['delete']>): void;
37
+ }
38
+ }
31
39
  export declare let entities: ClassType<any>[];
32
40
  /**
33
41
  * it's basically `remultSveltekit` with the `modules` option
@@ -1,53 +1,42 @@
1
- import type { ProviderConfigured } from './server/module';
1
+ import type { AuthServerAbstraction, ProviderConfigured } from './types';
2
2
  export declare class AuthController {
3
3
  #private;
4
- static _setAbstraction(impl: {
5
- signOut: any;
6
- signInDemo: any;
7
- invite: any;
8
- signUpPassword: any;
9
- signInPassword: any;
10
- forgotPassword: any;
11
- resetPassword: any;
12
- signInOTP: any;
13
- verifyOtp: any;
14
- signInOAuthGetUrl: any;
15
- }): void;
4
+ static _setAbstraction(impl: AuthServerAbstraction): void;
16
5
  /**
17
6
  * Sign out the current user
18
7
  */
19
- static signOut(): Promise<any>;
8
+ static signOut(): Promise<import("./types").AuthResponse>;
20
9
  /**
21
10
  * Sign in with a demo account
22
11
  * _(The easiest way to demo & test your application)_
23
12
  */
24
- static signInDemo(name: string): Promise<any>;
13
+ static signInDemo(name: string): Promise<import("./types").AuthResponse>;
25
14
  /**
26
15
  * This is for login / password authentication Invite someone
27
16
  */
28
- static invite(email: string): Promise<any>;
17
+ static invite(email: string): Promise<import("./types").AuthResponse>;
29
18
  /**
30
19
  * This is for login / password authentication SignUp
31
20
  */
32
- static signUpPassword(email: string, password: string): Promise<any>;
21
+ static signUpPassword(email: string, password: string): Promise<import("./types").AuthResponse>;
33
22
  /**
34
23
  * This is for login / password authentication SignIn
35
24
  */
36
- static signInPassword(email: string, password: string): Promise<any>;
25
+ static signInPassword(email: string, password: string): Promise<import("./types").AuthResponse>;
37
26
  /**
38
27
  * Forgot your password ? Send a mail to reset it.
39
28
  */
40
- static forgotPassword(email: string): Promise<any>;
29
+ static forgotPassword(email: string): Promise<import("./types").AuthResponse>;
41
30
  /**
42
31
  * Reset your password with a token
43
32
  */
44
- static resetPassword(token: string, password: string): Promise<any>;
33
+ static resetPassword(token: string, password: string): Promise<import("./types").AuthResponse>;
45
34
  /** OTP */
46
- static signInOTP(email: string): Promise<any>;
35
+ static signInOTP(email: string): Promise<import("./types").AuthResponse>;
47
36
  /**
48
37
  * Verify the OTP code
49
38
  */
50
- static verifyOtp(email: string, otp: string): Promise<any>;
39
+ static verifyOtp(email: string, otp: string): Promise<import("./types").AuthResponse>;
51
40
  /** OAUTH */
52
41
  /**
53
42
  * The the url to redirect to for the OAuth provider
@@ -65,5 +54,5 @@ export declare class AuthController {
65
54
  provider: T;
66
55
  options?: ProviderConfigured[T];
67
56
  redirect?: string;
68
- }): Promise<any>;
57
+ }): Promise<string>;
69
58
  }
@@ -7,82 +7,63 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  import { BackendMethod } from 'remult';
8
8
  import { FF_Role_Auth } from './Entities';
9
9
  export class AuthController {
10
- // Private static fields
11
- static #signOutFn;
12
- static #signInDemoFn;
13
- static #inviteFn;
14
- static #signUpPasswordFn;
15
- static #signInPasswordFn;
16
- static #forgotPasswordFn;
17
- static #resetPasswordFn;
18
- static #signInOTPFn;
19
- static #verifyOtpFn;
20
- static #signInOAuthGetUrlFn;
10
+ static #server;
21
11
  // Internal setter method that can be used by the module
22
12
  static _setAbstraction(impl) {
23
- this.#signOutFn = impl.signOut;
24
- this.#signInDemoFn = impl.signInDemo;
25
- this.#inviteFn = impl.invite;
26
- this.#signUpPasswordFn = impl.signUpPassword;
27
- this.#signInPasswordFn = impl.signInPassword;
28
- this.#forgotPasswordFn = impl.forgotPassword;
29
- this.#resetPasswordFn = impl.resetPassword;
30
- this.#signInOTPFn = impl.signInOTP;
31
- this.#verifyOtpFn = impl.verifyOtp;
32
- this.#signInOAuthGetUrlFn = impl.signInOAuthGetUrl;
13
+ this.#server = impl;
33
14
  }
34
15
  /**
35
16
  * Sign out the current user
36
17
  */
37
18
  static async signOut() {
38
- return await AuthController.#signOutFn();
19
+ return await AuthController.#server.signOut();
39
20
  }
40
21
  /**
41
22
  * Sign in with a demo account
42
23
  * _(The easiest way to demo & test your application)_
43
24
  */
44
25
  static async signInDemo(name) {
45
- return await AuthController.#signInDemoFn(name);
26
+ return await AuthController.#server.signInDemo(name);
46
27
  }
47
28
  /**
48
29
  * This is for login / password authentication Invite someone
49
30
  */
50
31
  static async invite(email) {
51
- return await AuthController.#inviteFn(email);
32
+ return await AuthController.#server.invite(email);
52
33
  }
53
34
  /**
54
35
  * This is for login / password authentication SignUp
55
36
  */
56
37
  static async signUpPassword(email, password) {
57
- return await AuthController.#signUpPasswordFn(email, password);
38
+ return await AuthController.#server.signUpPassword(email, password);
58
39
  }
59
40
  /**
60
41
  * This is for login / password authentication SignIn
61
42
  */
62
43
  static async signInPassword(email, password) {
63
- return await AuthController.#signInPasswordFn(email, password);
44
+ return await AuthController.#server.signInPassword(email, password);
64
45
  }
65
46
  /**
66
47
  * Forgot your password ? Send a mail to reset it.
67
48
  */
68
49
  static async forgotPassword(email) {
69
- return await AuthController.#forgotPasswordFn(email);
50
+ return await AuthController.#server.forgotPassword(email);
70
51
  }
71
52
  /**
72
53
  * Reset your password with a token
73
54
  */
74
55
  static async resetPassword(token, password) {
75
- return await AuthController.#resetPasswordFn(token, password);
56
+ return await AuthController.#server.resetPassword(token, password);
76
57
  }
77
58
  /** OTP */
78
59
  static async signInOTP(email) {
79
- return await AuthController.#signInOTPFn(email);
60
+ return await AuthController.#server.signInOTP(email);
80
61
  }
81
62
  /**
82
63
  * Verify the OTP code
83
64
  */
84
65
  static async verifyOtp(email, otp) {
85
- return await AuthController.#verifyOtpFn(email, otp);
66
+ return await AuthController.#server.verifyOtp(email, otp);
86
67
  }
87
68
  /** OAUTH */
88
69
  /**
@@ -98,7 +79,7 @@ export class AuthController {
98
79
  * _(popup example should work too, and a nice example/componant would be appreciated)_
99
80
  */
100
81
  static async signInOAuthGetUrl(o) {
101
- return await AuthController.#signInOAuthGetUrlFn(o);
82
+ return await AuthController.#server.signInOAuthGetUrl(o);
102
83
  }
103
84
  }
104
85
  __decorate([
@@ -1,42 +1,42 @@
1
- import { type ProviderConfigured } from './module.js';
1
+ import type { AuthResponse, ProviderConfigured } from '../types.js';
2
2
  export declare class AuthControllerServer {
3
3
  /**
4
4
  * Sign out the current user
5
5
  */
6
- static signOut(): Promise<void>;
6
+ static signOut(): Promise<AuthResponse>;
7
7
  /**
8
8
  * Sign in with a demo account
9
9
  * _(The easiest way to demo & test your application)_
10
10
  */
11
- static signInDemo(name: string): Promise<string>;
11
+ static signInDemo(name: string): Promise<AuthResponse>;
12
12
  /**
13
13
  * This is for login / password authentication invite
14
14
  */
15
- static invite(emailParam: string): Promise<"Mail sent !" | "Demo Mail sent !" | "ok">;
15
+ static invite(emailParam: string): Promise<AuthResponse>;
16
16
  /**
17
17
  * This is for login / password authentication SignUp
18
18
  * _(The first param `email` can be "anything")_
19
19
  */
20
- static signUpPassword(emailParam: string, password: string): Promise<string>;
20
+ static signUpPassword(emailParam: string, password: string): Promise<AuthResponse>;
21
21
  /**
22
22
  * This is for login / password authentication SignIn
23
23
  * _(The first param `email` can be "anything")_
24
24
  */
25
- static signInPassword(emailParam: string, password: string): Promise<string>;
25
+ static signInPassword(emailParam: string, password: string): Promise<AuthResponse>;
26
26
  /**
27
27
  * Forgot your password ? Send a mail to reset it.
28
28
  */
29
- static forgotPassword(emailParam: string): Promise<string>;
29
+ static forgotPassword(emailParam: string): Promise<AuthResponse>;
30
30
  /**
31
31
  * Reset your password with a token
32
32
  */
33
- static resetPassword(token: string, password: string): Promise<string>;
33
+ static resetPassword(token: string, password: string): Promise<AuthResponse>;
34
34
  /** OTP */
35
- static signInOTP(emailParam: string): Promise<"Mail sent !" | "Hum, something went wrong !">;
35
+ static signInOTP(emailParam: string): Promise<AuthResponse>;
36
36
  /**
37
37
  * Verify the OTP code
38
38
  */
39
- static verifyOtp(emailParam: string, otp: string): Promise<string>;
39
+ static verifyOtp(emailParam: string, otp: string): Promise<AuthResponse>;
40
40
  /** OAUTH */
41
41
  /**
42
42
  * The the url to redirect to for the OAuth provider
@@ -54,5 +54,5 @@ export declare class AuthControllerServer {
54
54
  provider: T;
55
55
  options?: ProviderConfigured[T];
56
56
  redirect?: string;
57
- }): Promise<any>;
57
+ }): Promise<string>;
58
58
  }
@@ -2,8 +2,7 @@ import { decodeHex, encodeHexLowerCase } from '@oslojs/encoding';
2
2
  import { createTOTPKeyURI, generateTOTP, verifyTOTPWithGracePeriod } from '@oslojs/otp';
3
3
  import { generateState } from 'arctic';
4
4
  import { EntityError, remult, repo } from 'remult';
5
- import { green, magenta, yellow } from '@kitql/helpers';
6
- import { sendMail } from '../../mail/server/index.js';
5
+ import { gray, green, magenta, red, yellow } from '@kitql/helpers';
7
6
  import { FFAuthProvider } from '../Entities.js';
8
7
  import { invalidateSession } from './helperDb.js';
9
8
  import { ff_createSession } from './helperFirstly.js';
@@ -11,6 +10,25 @@ import { createDate, generateAndEncodeToken } from './helperOslo.js';
11
10
  import { deleteSessionTokenCookie, setOAuthStateCookie, setRedirectCookie, } from './helperRemultServer.js';
12
11
  import { mergeRoles } from './helperRole.js';
13
12
  import { AUTH_OPTIONS, authModuleRaw, getSafeOptions } from './module.js';
13
+ const getSendMail = () => {
14
+ if (!remult.context.sendMail) {
15
+ authModuleRaw.log.error(`Missing ${green(`remult.context`)}.${red(`sendMail`)}`);
16
+ authModuleRaw.log.error('');
17
+ authModuleRaw.log.error(gray('Add this to your modules:'));
18
+ authModuleRaw.log.error('import { mail } from "firstly/mail/server"');
19
+ authModuleRaw.log.error('');
20
+ authModuleRaw.log.error('{');
21
+ authModuleRaw.log.error(` modules: [`);
22
+ authModuleRaw.log.error(` mail({`);
23
+ authModuleRaw.log.error(` // options`);
24
+ authModuleRaw.log.error(` })`);
25
+ authModuleRaw.log.error(` ]`);
26
+ authModuleRaw.log.error('}');
27
+ authModuleRaw.log.error('');
28
+ throw new EntityError({ message: 'Error: Contact your administrator.' });
29
+ }
30
+ return remult.context.sendMail;
31
+ };
14
32
  export class AuthControllerServer {
15
33
  /**
16
34
  * Sign out the current user
@@ -20,6 +38,10 @@ export class AuthControllerServer {
20
38
  await invalidateSession(remult.user?.session.id);
21
39
  }
22
40
  deleteSessionTokenCookie();
41
+ return {
42
+ message: 'signed out',
43
+ user: undefined,
44
+ };
23
45
  }
24
46
  /**
25
47
  * Sign in with a demo account
@@ -43,8 +65,11 @@ export class AuthControllerServer {
43
65
  const r = mergeRoles(user.roles, account.roles);
44
66
  user.roles = r.roles;
45
67
  await repo(oSafe.User).save(user);
46
- await ff_createSession(user.id);
47
- return `You're in with ${name} demo account!`;
68
+ const session = await ff_createSession(user.id);
69
+ return {
70
+ message: `You're in with demo account!`,
71
+ user: oSafe.transformDbUserToClientUser(session, user),
72
+ };
48
73
  }
49
74
  /**
50
75
  * This is for login / password authentication invite
@@ -81,9 +106,13 @@ export class AuthControllerServer {
81
106
  if (AUTH_OPTIONS?.invitationSend) {
82
107
  await AUTH_OPTIONS?.invitationSend({ email, url });
83
108
  authModuleRaw.log.success(`${green('[custom]')}${magenta('[invitationSend]')} (${yellow(url)})`);
84
- return 'Mail sent !';
109
+ return {
110
+ message: 'Mail sent !',
111
+ user: remult.user,
112
+ };
85
113
  }
86
114
  else {
115
+ const sendMail = getSendMail();
87
116
  await sendMail('invitationSend', {
88
117
  to: email,
89
118
  subject: 'Invitation',
@@ -106,10 +135,16 @@ export class AuthControllerServer {
106
135
  },
107
136
  });
108
137
  authModuleRaw.log.success(`${magenta('[invitationSend]')} (${yellow(url)})`);
109
- return 'Demo Mail sent !';
138
+ return {
139
+ message: 'Demo Mail sent !',
140
+ user: remult.user,
141
+ };
110
142
  }
111
143
  }
112
- return 'ok';
144
+ return {
145
+ message: 'ok',
146
+ user: remult.user,
147
+ };
113
148
  }
114
149
  /**
115
150
  * This is for login / password authentication SignUp
@@ -156,7 +191,11 @@ export class AuthControllerServer {
156
191
  identifier: email,
157
192
  });
158
193
  if (user) {
159
- await ff_createSession(user.id);
194
+ const session = await ff_createSession(user.id);
195
+ return {
196
+ message: 'ok',
197
+ user: oSafe.transformDbUserToClientUser(session, user),
198
+ };
160
199
  }
161
200
  }
162
201
  else {
@@ -166,6 +205,7 @@ export class AuthControllerServer {
166
205
  authModuleRaw.log.success(`${green('[custom]')}${magenta('[verifyMailSend]')} (${yellow(url)})`);
167
206
  }
168
207
  else {
208
+ const sendMail = getSendMail();
169
209
  await sendMail('verifyMailSend', {
170
210
  to: email,
171
211
  subject: 'Wecome',
@@ -186,7 +226,10 @@ export class AuthControllerServer {
186
226
  authModuleRaw.log.success(`${magenta('[verifyMailSend]')} (${yellow(url)})`);
187
227
  }
188
228
  }
189
- return 'ok';
229
+ return {
230
+ message: 'ok',
231
+ user: remult.user,
232
+ };
190
233
  }
191
234
  /**
192
235
  * This is for login / password authentication SignIn
@@ -208,8 +251,11 @@ export class AuthControllerServer {
208
251
  if (existingAccount) {
209
252
  const validPassword = oSafe.password.verify(password ?? '', existingAccount?.hashPassword ?? '');
210
253
  if (validPassword) {
211
- await ff_createSession(existingAccount.userId);
212
- return 'ok';
254
+ const session = await ff_createSession(existingAccount.userId);
255
+ return {
256
+ message: 'ok',
257
+ user: oSafe.transformDbUserToClientUser(session, existingAccount.user),
258
+ };
213
259
  }
214
260
  authModuleRaw.log.error({ email, passwordLength: password.length });
215
261
  throw new EntityError({ message: 'Incorrect username or password' });
@@ -241,9 +287,13 @@ export class AuthControllerServer {
241
287
  if (AUTH_OPTIONS.providers?.password?.mail?.reset?.send) {
242
288
  await AUTH_OPTIONS.providers?.password.mail.reset.send({ email, url });
243
289
  authModuleRaw.log.success(`${green('[custom]')}${magenta('[resetPasswordSend]')} (${yellow(url)})`);
244
- return oSafe.strings.resetPasswordSend;
290
+ return {
291
+ message: oSafe.strings.resetPasswordSend,
292
+ user: remult.user,
293
+ };
245
294
  }
246
295
  else {
296
+ const sendMail = getSendMail();
247
297
  await sendMail('resetPasswordSend', {
248
298
  to: email,
249
299
  subject: 'Reset your password',
@@ -266,7 +316,10 @@ export class AuthControllerServer {
266
316
  },
267
317
  });
268
318
  authModuleRaw.log.success(`${magenta('[resetPasswordSend]')} (${yellow(url)})`);
269
- return `Demo | ${oSafe.strings.resetPasswordSend}`;
319
+ return {
320
+ message: `Demo | ${oSafe.strings.resetPasswordSend}`,
321
+ user: remult.user,
322
+ };
270
323
  }
271
324
  }
272
325
  throw new EntityError({ message: oSafe.strings.anErrorOccurred });
@@ -301,7 +354,10 @@ export class AuthControllerServer {
301
354
  account.lastVerifiedAt = new Date();
302
355
  await repo(oSafe.Account).save(account);
303
356
  await ff_createSession(account.userId);
304
- return 'reseted';
357
+ return {
358
+ message: 'reseted',
359
+ user: remult.user,
360
+ };
305
361
  }
306
362
  /** OTP */
307
363
  static async signInOTP(emailParam) {
@@ -338,12 +394,18 @@ export class AuthControllerServer {
338
394
  await repo(oSafe.Account).save(account);
339
395
  await AUTH_OPTIONS.providers.otp?.send({ name: email, otp, uri });
340
396
  authModuleRaw.log.success(`name: ${yellow(email)}, otp: ${yellow(otp)}, uri: ${yellow(uri)}`);
341
- return 'Mail sent !';
397
+ return {
398
+ message: 'Mail sent !',
399
+ user: remult.user,
400
+ };
342
401
  }
343
402
  else {
344
403
  authModuleRaw.log.error(`You need to provide a otp.send hook in the auth options!`);
345
404
  }
346
- return 'Hum, something went wrong !';
405
+ return {
406
+ message: 'Hum, something went wrong !',
407
+ user: remult.user,
408
+ };
347
409
  }
348
410
  /**
349
411
  * Verify the OTP code
@@ -378,8 +440,11 @@ export class AuthControllerServer {
378
440
  account.token = undefined;
379
441
  account.expiresAt = undefined;
380
442
  await repo(oSafe.Account).save(account);
381
- await ff_createSession(account.userId);
382
- return 'verified';
443
+ const session = await ff_createSession(account.userId);
444
+ return {
445
+ message: 'verified',
446
+ user: oSafe.transformDbUserToClientUser(session, user),
447
+ };
383
448
  }
384
449
  /** OAUTH */
385
450
  /**
@@ -1 +1 @@
1
- export declare const ff_createSession: (userId: string) => Promise<void>;
1
+ export declare const ff_createSession: (userId: string) => Promise<import("..").FFAuthUserSession>;
@@ -5,4 +5,5 @@ export const ff_createSession = async (userId) => {
5
5
  const token = generateToken();
6
6
  const session = await createSession(token, userId);
7
7
  setSessionTokenCookie(token, session.expiresAt);
8
+ return session;
8
9
  };
@@ -3,11 +3,8 @@ import type { ClassType, UserInfo } from 'remult';
3
3
  import { Module } from '../../api';
4
4
  import type { RecursivePartial } from '../../utils/types';
5
5
  import { FFAuthAccount, FFAuthUser, FFAuthUserSession } from '../Entities';
6
- import type { firstlyData, firstlyDataAuth } from '../types';
6
+ import type { FirstlyData, FirstlyDataAuth, ProviderAuthorizationURLOptions } from '../types';
7
7
  import { initRoleFromEnv } from './helperRole';
8
- export type { firstlyData };
9
- export type ProviderConfigured = Record<string, ProviderAuthorizationURLOptions>;
10
- export type ProviderAuthorizationURLOptions = string[];
11
8
  export type OAuth2UserInfo = {
12
9
  raw?: any;
13
10
  providerUserId: string;
@@ -27,7 +24,7 @@ type AuthOptions<TUserEntity extends FFAuthUser = FFAuthUser, TSessionEntity ext
27
24
  Account?: ClassType<TAccountEntity>;
28
25
  };
29
26
  debug?: boolean;
30
- ui?: false | RecursivePartial<firstlyDataAuth['ui']>;
27
+ ui?: false | RecursivePartial<FirstlyDataAuth['ui']>;
31
28
  strings?: {
32
29
  resetPasswordSend?: string;
33
30
  anErrorOccurred?: string;
@@ -155,7 +152,7 @@ export declare const getSafeOptions: <TUserEntity extends FFAuthUser = FFAuthUse
155
152
  };
156
153
  verifiedMethod: "email" | "auto" | "manual";
157
154
  redirectUrl: string;
158
- firstlyData: firstlyData;
155
+ firstlyData: FirstlyData;
159
156
  transformDbUserToClientUser: (session: TSessionEntity, user: TUserEntity) => UserInfo;
160
157
  uiStaticPath: string;
161
158
  session: {
@@ -1,6 +1,7 @@
1
1
  import type { OAuth2Tokens } from 'arctic';
2
2
  import { GitHub } from 'arctic';
3
- import { type FFOAuth2Provider, type OAuth2UserInfo, type ProviderAuthorizationURLOptions } from '../module';
3
+ import type { ProviderAuthorizationURLOptions } from '../../types';
4
+ import { type FFOAuth2Provider, type OAuth2UserInfo } from '../module';
4
5
  /**
5
6
  * ## GitHub OAuth2 provider
6
7
  *
@@ -1,7 +1,7 @@
1
1
  import { GitHub } from 'arctic';
2
2
  import { remult } from 'remult';
3
3
  import { env } from '$env/dynamic/private';
4
- import { authModuleRaw, } from '../module';
4
+ import { authModuleRaw } from '../module';
5
5
  import { checkOAuthConfig } from './helperProvider';
6
6
  //------------------------------
7
7
  // For developers (future me ?), To do another OAuth2 provider:
@@ -0,0 +1,6 @@
1
+ export { a as default };
2
+ declare function a(e: any, s: any): any;
3
+ declare namespace a {
4
+ let ______13017: string;
5
+ export { ______13017 as __@$@13017 };
6
+ }
@@ -0,0 +1 @@
1
+ import{v as r,x as l,aa as m,J as o,K as d,M as n,O as p,P as u,R as i}from"./index-C9jzxOBu.js";p();a[u]="src/lib/modules/admin/Page.svelte";function a(e,s){r(new.target),l(s,!1,a);var t=m("Hello from admin");return o(e,t),d({...n()})}i(a);export{a as default};
@@ -0,0 +1,6 @@
1
+ export { Q as default };
2
+ declare function Q(n: any, e: any): any;
3
+ declare namespace Q {
4
+ let ______13017: string;
5
+ export { ______13017 as __@$@13017 };
6
+ }