firstly 0.0.10 → 0.0.12

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 (112) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/esm/BaseEnum.d.ts +2 -0
  3. package/esm/BaseEnum.js +2 -0
  4. package/esm/FF_Fields.js +0 -1
  5. package/esm/ROUTES.d.ts +2 -2
  6. package/esm/ROUTES.js +10 -5
  7. package/esm/SqlDatabase/FF_LogToConsole.d.ts +1 -0
  8. package/esm/SqlDatabase/FF_LogToConsole.js +22 -16
  9. package/esm/api/index.d.ts +19 -21
  10. package/esm/api/index.js +72 -62
  11. package/esm/auth/{client/Auth.d.ts → AuthController.d.ts} +18 -25
  12. package/esm/auth/{client/Auth.js → AuthController.js} +48 -44
  13. package/esm/auth/{client/Entities.d.ts → Entities.d.ts} +4 -3
  14. package/esm/auth/{client/Entities.js → Entities.js} +7 -7
  15. package/esm/auth/README.md +0 -10
  16. package/esm/auth/index.d.ts +5 -149
  17. package/esm/auth/index.js +5 -316
  18. package/esm/auth/{AuthController.server.d.ts → server/AuthController.server.d.ts} +10 -10
  19. package/esm/auth/{AuthController.server.js → server/AuthController.server.js} +126 -164
  20. package/esm/auth/server/handleAuth.d.ts +2 -0
  21. package/esm/auth/server/handleAuth.js +140 -0
  22. package/esm/auth/server/helperDb.d.ts +10 -0
  23. package/esm/auth/server/helperDb.js +56 -0
  24. package/esm/auth/server/helperFirstly.d.ts +1 -0
  25. package/esm/auth/server/helperFirstly.js +8 -0
  26. package/esm/auth/server/helperOslo.d.ts +7 -0
  27. package/esm/auth/server/helperOslo.js +24 -0
  28. package/esm/auth/server/helperRemultServer.d.ts +5 -0
  29. package/esm/auth/server/helperRemultServer.js +44 -0
  30. package/esm/auth/{RoleHelpers.d.ts → server/helperRole.d.ts} +1 -1
  31. package/esm/auth/{RoleHelpers.js → server/helperRole.js} +1 -1
  32. package/esm/auth/server/index.d.ts +5 -0
  33. package/esm/auth/server/index.js +5 -0
  34. package/esm/auth/server/module.d.ts +238 -0
  35. package/esm/auth/server/module.js +184 -0
  36. package/esm/auth/{providers → server/providers}/github.d.ts +6 -5
  37. package/esm/auth/{providers → server/providers}/github.js +30 -21
  38. package/esm/auth/{providers/index.d.ts → server/providers/helperProvider.d.ts} +0 -2
  39. package/esm/auth/{providers/index.js → server/providers/helperProvider.js} +5 -6
  40. package/esm/auth/static/assets/{Page-BEFYPjis.d.ts → Page-Bb8bFlrP.d.ts} +1 -1
  41. package/esm/auth/static/assets/{Page-DtgkOCJs.js → Page-Bb8bFlrP.js} +1 -1
  42. package/esm/auth/static/assets/{Page-DtgkOCJs.d.ts → Page-BxomFlZ8.d.ts} +1 -1
  43. package/esm/auth/static/assets/{Page-BEFYPjis.js → Page-BxomFlZ8.js} +1 -1
  44. package/esm/auth/static/assets/Page-CaIYu0-y.d.ts +6 -0
  45. package/esm/auth/static/assets/Page-CaIYu0-y.js +19 -0
  46. package/esm/auth/static/assets/Page-MkYglNtu.css +1 -0
  47. package/esm/auth/static/assets/index-Bl0Bk5u0.d.ts +64 -0
  48. package/esm/auth/static/assets/index-Bl0Bk5u0.js +2 -0
  49. package/esm/auth/static/assets/{index-CR_3yNaJ.css → index-R27C_TlP.css} +1 -1
  50. package/esm/auth/static/index.html +2 -2
  51. package/esm/auth/types.d.ts +5 -0
  52. package/esm/bin/cmd.js +13 -22
  53. package/esm/cellsBuildor.js +6 -6
  54. package/esm/changeLog/index.d.ts +0 -36
  55. package/esm/changeLog/index.js +3 -43
  56. package/esm/changeLog/server/index.d.ts +36 -0
  57. package/esm/changeLog/server/index.js +42 -0
  58. package/esm/cron/{index.d.ts → server/index.d.ts} +1 -1
  59. package/esm/cron/server/index.js +103 -0
  60. package/esm/feedback/FeedbackController.js +3 -3
  61. package/esm/feedback/index.d.ts +0 -16
  62. package/esm/feedback/index.js +0 -11
  63. package/esm/feedback/server/index.d.ts +17 -0
  64. package/esm/feedback/server/index.js +13 -0
  65. package/esm/feedback/ui/DialogIssue.svelte +4 -2
  66. package/esm/feedback/ui/DialogIssues.svelte +13 -4
  67. package/esm/feedback/ui/DialogMilestones.svelte +1 -1
  68. package/esm/feedback/ui/Feedback.svelte +3 -1
  69. package/esm/helper.d.ts +0 -1
  70. package/esm/helper.js +3 -17
  71. package/esm/index.d.ts +3 -17
  72. package/esm/index.js +3 -4
  73. package/esm/mail/index.d.ts +2 -30
  74. package/esm/mail/index.js +2 -79
  75. package/esm/mail/server/index.d.ts +31 -0
  76. package/esm/mail/server/index.js +88 -0
  77. package/esm/storeItem.d.ts +4 -1
  78. package/esm/storeItem.js +8 -2
  79. package/esm/storeList.d.ts +5 -2
  80. package/esm/storeList.js +1 -1
  81. package/esm/sveltekit/server/index.d.ts +11 -0
  82. package/esm/sveltekit/server/index.js +21 -0
  83. package/esm/ui/Button.svelte +1 -1
  84. package/esm/ui/Clipboardable.svelte +5 -2
  85. package/esm/ui/Field.svelte +4 -1
  86. package/esm/ui/Loading.svelte +4 -1
  87. package/esm/ui/Tooltip.svelte +2 -2
  88. package/esm/ui/dialog/DialogForm.svelte +1 -1
  89. package/esm/ui/dialog/DialogPrimitive.svelte +1 -2
  90. package/esm/ui/dialog/dialog.d.ts +6 -3
  91. package/esm/ui/dialog/dialog.js +1 -1
  92. package/esm/ui/internals/FieldContainer.svelte +0 -1
  93. package/esm/ui/internals/Input.svelte +3 -1
  94. package/esm/ui/internals/Textarea.svelte +2 -2
  95. package/esm/vite/index.js +24 -25
  96. package/package.json +50 -38
  97. package/esm/auth/Adapter.d.ts +0 -10
  98. package/esm/auth/Adapter.js +0 -50
  99. package/esm/auth/client/index.d.ts +0 -7
  100. package/esm/auth/client/index.js +0 -7
  101. package/esm/auth/helper.d.ts +0 -6
  102. package/esm/auth/helper.js +0 -14
  103. package/esm/auth/providers/strava.d.ts +0 -30
  104. package/esm/auth/providers/strava.js +0 -60
  105. package/esm/auth/static/assets/Page-BGTO8LC5.css +0 -1
  106. package/esm/auth/static/assets/Page-Cfysx_UV.d.ts +0 -6
  107. package/esm/auth/static/assets/Page-Cfysx_UV.js +0 -18
  108. package/esm/auth/static/assets/index-QypqCYwC.d.ts +0 -63
  109. package/esm/auth/static/assets/index-QypqCYwC.js +0 -2
  110. package/esm/cron/index.js +0 -102
  111. package/esm/handle/index.d.ts +0 -7
  112. package/esm/handle/index.js +0 -40
package/package.json CHANGED
@@ -1,8 +1,10 @@
1
1
  {
2
2
  "name": "firstly",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "type": "module",
5
5
  "description": "Firstly, an opinionated Remult setup!",
6
+ "funding": "https://github.com/sponsors/jycouet",
7
+ "homepage": "https://firstly.fun/",
6
8
  "repository": {
7
9
  "type": "git",
8
10
  "url": "https://github.com/jycouet/firstly",
@@ -14,46 +16,44 @@
14
16
  },
15
17
  "peerDependencies": {
16
18
  "@sveltejs/kit": ">=1.0.0 <3.0.0",
17
- "remult": "0.27.20",
19
+ "remult": "2.7.29",
18
20
  "svelte": ">=4.2.18"
19
21
  },
20
22
  "dependencies": {
21
- "@clack/prompts": "^0.7.0",
23
+ "@clack/prompts": "0.7.0",
22
24
  "@kitql/internals": "0.9.9",
23
- "@mdi/js": "^7.4.47",
24
- "@melt-ui/svelte": "^0.83.0",
25
- "@types/nodemailer": "^6.4.15",
26
- "arctic": "^1.8.0",
27
- "clsx": "^2.1.1",
28
- "cron": "^3.1.7",
29
- "daisyui": "^4.12.10",
30
- "esm-env": "^1.0.0",
31
- "lucia": "^3.2.0",
32
- "nodemailer": "^6.9.13",
33
- "oslo": "1.2.1",
34
- "svelty-email": "^0.0.11",
35
- "tailwind-merge": "^2.3.0",
36
- "tailwindcss": "^3.4.3",
37
- "vite": "^5.4.1",
38
- "vite-plugin-kit-routes": "^0.6.10",
39
- "vite-plugin-stripper": "^0.5.4"
25
+ "@mdi/js": "7.4.47",
26
+ "@melt-ui/svelte": "0.86.3",
27
+ "@oslojs/crypto": "1.0.1",
28
+ "@oslojs/encoding": "1.1.0",
29
+ "@oslojs/otp": "1.1.0",
30
+ "@types/nodemailer": "6.4.14",
31
+ "arctic": "3.5.0",
32
+ "bcrypt": "5.1.1",
33
+ "clsx": "2.1.1",
34
+ "cron": "3.1.7",
35
+ "daisyui": "4.12.14",
36
+ "esm-env": "1.0.0",
37
+ "nodemailer": "6.9.14",
38
+ "svelty-email": "0.0.11",
39
+ "tailwind-merge": "2.3.0",
40
+ "tailwindcss": "3.4.4",
41
+ "vite": "5.4.1",
42
+ "vite-plugin-kit-routes": "0.8.3",
43
+ "vite-plugin-stripper": "0.5.4"
40
44
  },
41
45
  "sideEffects": false,
42
46
  "bin": "./esm/bin/cmd.js",
43
47
  "exports": {
44
48
  ".": {
45
49
  "types": "./esm/index.d.ts",
46
- "default": "./esm/index.js",
47
- "svelte": "./esm/index.js"
50
+ "svelte": "./esm/index.js",
51
+ "default": "./esm/index.js"
48
52
  },
49
53
  "./api": {
50
54
  "types": "./esm/api/index.d.ts",
51
55
  "default": "./esm/api/index.js"
52
56
  },
53
- "./handle": {
54
- "types": "./esm/handle/index.d.ts",
55
- "default": "./esm/handle/index.js"
56
- },
57
57
  "./vite": {
58
58
  "types": "./esm/vite/index.d.ts",
59
59
  "default": "./esm/vite/index.js"
@@ -69,29 +69,41 @@
69
69
  "types": "./esm/auth/index.d.ts",
70
70
  "default": "./esm/auth/index.js"
71
71
  },
72
- "./auth/client": {
73
- "types": "./esm/auth/client/index.d.ts",
74
- "default": "./esm/auth/client/index.js"
72
+ "./auth/server": {
73
+ "types": "./esm/auth/server/index.d.ts",
74
+ "default": "./esm/auth/server/index.js"
75
+ },
76
+ "./changeLog": {
77
+ "types": "./esm/changeLog/index.d.ts",
78
+ "default": "./esm/changeLog/index.js"
75
79
  },
76
- "./auth/providers": {
77
- "types": "./esm/auth/providers/index.d.ts",
78
- "default": "./esm/auth/providers/index.js"
80
+ "./changeLog/server": {
81
+ "types": "./esm/changeLog/server/index.d.ts",
82
+ "default": "./esm/changeLog/server/index.js"
83
+ },
84
+ "./cron/server": {
85
+ "types": "./esm/cron/server/index.d.ts",
86
+ "default": "./esm/cron/server/index.js"
79
87
  },
80
88
  "./feedback": {
81
89
  "types": "./esm/feedback/index.d.ts",
82
90
  "default": "./esm/feedback/index.js"
83
91
  },
84
- "./changeLogs": {
85
- "types": "./esm/changeLogs/index.d.ts",
86
- "default": "./esm/changeLogs/index.js"
92
+ "./feedback/server": {
93
+ "types": "./esm/feedback/server/index.d.ts",
94
+ "default": "./esm/feedback/server/index.js"
87
95
  },
88
96
  "./mail": {
89
97
  "types": "./esm/mail/index.d.ts",
90
98
  "default": "./esm/mail/index.js"
91
99
  },
92
- "./cron": {
93
- "types": "./esm/cron/index.d.ts",
94
- "default": "./esm/cron/index.js"
100
+ "./mail/server": {
101
+ "types": "./esm/mail/server/index.d.ts",
102
+ "default": "./esm/mail/server/index.js"
103
+ },
104
+ "./sveltekit/server": {
105
+ "types": "./esm/sveltekit/server/index.d.ts",
106
+ "default": "./esm/sveltekit/server/index.js"
95
107
  }
96
108
  },
97
109
  "keywords": [
@@ -1,10 +0,0 @@
1
- import type { Adapter, DatabaseSession, DatabaseUser } from 'lucia';
2
- export declare class RemultLuciaAdapter implements Adapter {
3
- getSessionAndUser(sessionId: string): Promise<[session: DatabaseSession | null, user: DatabaseUser | null]>;
4
- getUserSessions(userId: string): Promise<DatabaseSession[]>;
5
- setSession(session: DatabaseSession): Promise<void>;
6
- updateSessionExpiration(sessionId: string, expiresAt: Date): Promise<void>;
7
- deleteSession(sessionId: string): Promise<void>;
8
- deleteUserSessions(userId: string): Promise<void>;
9
- deleteExpiredSessions(): Promise<void>;
10
- }
@@ -1,50 +0,0 @@
1
- import { remult } from 'remult';
2
- import { getSafeOptions } from './index.js';
3
- export class RemultLuciaAdapter {
4
- async getSessionAndUser(sessionId) {
5
- const oSafe = getSafeOptions();
6
- const session = await remult.repo(oSafe.Session).findId(sessionId);
7
- if (session) {
8
- const user = await remult.repo(oSafe.User).findId(session.userId);
9
- if (user) {
10
- return [
11
- { ...session, attributes: {} },
12
- { ...user, attributes: oSafe.transformDbUserToClientUser(session, user) },
13
- ];
14
- }
15
- }
16
- return [null, null];
17
- }
18
- async getUserSessions(userId) {
19
- const oSafe = getSafeOptions();
20
- return (await remult.repo(oSafe.Session).find({ where: { userId } })).map((s) => {
21
- return { ...s, attributes: {} };
22
- });
23
- }
24
- async setSession(session) {
25
- const oSafe = getSafeOptions();
26
- await remult.repo(oSafe.Session).insert(session);
27
- }
28
- async updateSessionExpiration(sessionId, expiresAt) {
29
- const oSafe = getSafeOptions();
30
- await remult.repo(oSafe.Session).update(sessionId, { expiresAt });
31
- }
32
- async deleteSession(sessionId) {
33
- const oSafe = getSafeOptions();
34
- await remult.repo(oSafe.Session).delete(sessionId);
35
- }
36
- async deleteUserSessions(userId) {
37
- const oSafe = getSafeOptions();
38
- const all = await remult.repo(oSafe.Session).find({ where: { userId } });
39
- for (const s of all) {
40
- await remult.repo(oSafe.Session).delete(s);
41
- }
42
- }
43
- async deleteExpiredSessions() {
44
- const oSafe = getSafeOptions();
45
- const all = await remult.repo(oSafe.Session).find({ where: { expiresAt: { $lt: new Date() } } });
46
- for (const s of all) {
47
- await remult.repo(oSafe.Session).delete(s);
48
- }
49
- }
50
- }
@@ -1,7 +0,0 @@
1
- import { Log } from '@kitql/helpers';
2
- import { Auth } from './Auth';
3
- import { FFAuthAccount, FFAuthProvider, FFAuthUser, FFAuthUserSession } from './Entities';
4
- export declare const logAuth: Log;
5
- export { FF_Role_Auth } from './Entities';
6
- export { Auth };
7
- export { FFAuthUser, FFAuthAccount, FFAuthProvider, FFAuthUserSession };
@@ -1,7 +0,0 @@
1
- import { Log } from '@kitql/helpers';
2
- import { Auth } from './Auth';
3
- import { FFAuthAccount, FFAuthProvider, FFAuthUser, FFAuthUserSession } from './Entities';
4
- export const logAuth = new Log('firstly | auth');
5
- export { FF_Role_Auth } from './Entities';
6
- export { Auth };
7
- export { FFAuthUser, FFAuthAccount, FFAuthProvider, FFAuthUserSession };
@@ -1,6 +0,0 @@
1
- import type { Session } from 'lucia';
2
- /**
3
- * Create or extend a session for a user.
4
- * If you pass a session, it will extend it.
5
- */
6
- export declare function createOrExtendSession(userId: string, session?: Session): Promise<void>;
@@ -1,14 +0,0 @@
1
- import { remult } from 'remult';
2
- import { lucia } from '.';
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
- });
14
- }
@@ -1,30 +0,0 @@
1
- import { Strava } from 'arctic';
2
- import { type FFOAuth2Provider } from '../';
3
- /**
4
- * ## Strava OAuth2 provider
5
- *
6
- * 1. Get your **id** & **secret** from [Strava (direct link)](https://www.strava.com/settings/api).
7
- * 2. In Strava, set your callback url to
8
- * - [ ] dev: `http://localhost:5173/api/auth_callback`
9
- * - [ ] prod: `https://MY_SUPER_SITE/api/auth_callback`
10
- * 3. In your project add a `.env` file with the following:
11
- * ```bash
12
- * STRAVA_CLIENT_ID = 'your-client-id'
13
- * STRAVA_CLIENT_SECRET = 'your-client-secret'
14
- * # STRAVA_REDIRECT_URI = '' # optional, will default to "${origin}/api/auth_callback"
15
- * ```
16
- * 4. In your frontend, under a button click call something like:
17
- * ```ts
18
- * async function oauth() {
19
- * window.location.href = await Auth.signInOAuthGetUrl({ provider: 'strava', redirect: window.location.pathname })
20
- * }
21
- * ```
22
- * 5. Enjoy 🥳
23
- */
24
- export declare function strava(options?: {
25
- STRAVA_CLIENT_ID?: string;
26
- STRAVA_CLIENT_SECRET?: string;
27
- STRAVA_REDIRECT_URI?: string;
28
- authorizationURLOptions?: ReturnType<FFOAuth2Provider<'strava', Strava>['authorizationURLOptions']>;
29
- log?: boolean;
30
- }): FFOAuth2Provider<'strava', Strava>;
@@ -1,60 +0,0 @@
1
- import { Strava } from 'arctic';
2
- import { remult } from 'remult';
3
- import { env } from '$env/dynamic/private';
4
- import { checkOAuthConfig } from '.';
5
- import {} from '../';
6
- import { logAuth } from '../client';
7
- /**
8
- * ## Strava OAuth2 provider
9
- *
10
- * 1. Get your **id** & **secret** from [Strava (direct link)](https://www.strava.com/settings/api).
11
- * 2. In Strava, set your callback url to
12
- * - [ ] dev: `http://localhost:5173/api/auth_callback`
13
- * - [ ] prod: `https://MY_SUPER_SITE/api/auth_callback`
14
- * 3. In your project add a `.env` file with the following:
15
- * ```bash
16
- * STRAVA_CLIENT_ID = 'your-client-id'
17
- * STRAVA_CLIENT_SECRET = 'your-client-secret'
18
- * # STRAVA_REDIRECT_URI = '' # optional, will default to "${origin}/api/auth_callback"
19
- * ```
20
- * 4. In your frontend, under a button click call something like:
21
- * ```ts
22
- * async function oauth() {
23
- * window.location.href = await Auth.signInOAuthGetUrl({ provider: 'strava', redirect: window.location.pathname })
24
- * }
25
- * ```
26
- * 5. Enjoy 🥳
27
- */
28
- export function strava(options) {
29
- const name = 'strava';
30
- const clientID = options?.STRAVA_CLIENT_ID ?? env.STRAVA_CLIENT_ID ?? '';
31
- const secret = options?.STRAVA_CLIENT_SECRET ?? env.STRAVA_CLIENT_SECRET ?? '';
32
- const urlForKeys = 'https://www.strava.com/settings/api';
33
- checkOAuthConfig(name, clientID, secret, urlForKeys, false);
34
- return {
35
- name,
36
- isPKCE: false,
37
- getArcticProvider: () => {
38
- const redirectURI = options?.STRAVA_REDIRECT_URI ??
39
- env.STRAVA_REDIRECT_URI ??
40
- `${remult.context.url.origin}/api/auth_callback`;
41
- checkOAuthConfig(name, clientID, secret, urlForKeys, true);
42
- return new Strava(clientID, secret, redirectURI);
43
- },
44
- authorizationURLOptions: () => {
45
- return options?.authorizationURLOptions ?? { scopes: [] };
46
- },
47
- getUserInfo: async (tokens) => {
48
- const res = await fetch('https://www.strava.com/api/v3/athlete', {
49
- headers: {
50
- Authorization: `Bearer ${tokens.accessToken}`,
51
- },
52
- });
53
- const user = await res.json();
54
- if (options?.log) {
55
- logAuth.info(`user`, user);
56
- }
57
- return { raw: user, providerUserId: String(user.id), nameOptions: [user.login] };
58
- },
59
- };
60
- }
@@ -1 +0,0 @@
1
- form.s-KT008SdmQprk,form.s-N0DaQgJ_T5_C,form.s-85Tmcm64bnMI{display:flex;flex-direction:column}.message.s-85Tmcm64bnMI:empty{display:none}.message.s-85Tmcm64bnMI{background:var(--pico-muted-border-color);padding:var(--pico-form-element-spacing-vertical) var(--pico-form-element-spacing-horizontal);border-radius:var(--pico-border-radius);margin-bottom:calc(var(--pico-typography-spacing-vertical) * 2)}.message.error.s-85Tmcm64bnMI{background:var(--pico-del-color);color:#4c1513}form.s-FRwn6sVlvC6z{display:flex;flex-direction:column}.message.s-FRwn6sVlvC6z:empty{display:none}.message.s-FRwn6sVlvC6z{background:var(--pico-muted-border-color);padding:var(--pico-form-element-spacing-vertical) var(--pico-form-element-spacing-horizontal);border-radius:var(--pico-border-radius);margin-bottom:calc(var(--pico-typography-spacing-vertical) * 2)}.message.error.s-FRwn6sVlvC6z{background:var(--pico-del-color);color:#4c1513}.wrapper.s-NO-a_LAEXXH5{min-height:100vh;display:flex;justify-content:center;align-items:center;margin:0 auto}.form.s-NO-a_LAEXXH5{padding:1rem;max-width:360px;width:100%}.form-footer.s-NO-a_LAEXXH5{margin-top:1rem;display:flex;flex-direction:column;justify-content:center;align-items:center}.fallback.s-NO-a_LAEXXH5{display:flex;justify-content:center;align-items:center}
@@ -1,6 +0,0 @@
1
- export { Ca as default };
2
- declare class Ca extends Ye {
3
- set firstlyData(e: void);
4
- get firstlyData(): void;
5
- }
6
- import { S as Ye } from "./index-QypqCYwC.js";