@lobb-js/lobb-ext-auth 0.1.67 → 0.2.2

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 (86) hide show
  1. package/.vscode/settings.json +5 -0
  2. package/CHANGELOG.md +90 -31
  3. package/README.md +1 -1
  4. package/extensions/auth/collections/activityFeed.ts +53 -0
  5. package/extensions/auth/collections/collections.ts +43 -0
  6. package/extensions/auth/collections/sessions.ts +34 -0
  7. package/extensions/auth/collections/users.ts +44 -0
  8. package/extensions/auth/config/extensionConfigSchema.ts +47 -0
  9. package/extensions/auth/config/permissionsAction/create.ts +20 -0
  10. package/extensions/auth/config/permissionsAction/delete.ts +3 -0
  11. package/extensions/auth/config/permissionsAction/read.ts +10 -0
  12. package/extensions/auth/config/permissionsAction/update.ts +20 -0
  13. package/extensions/auth/database/init.ts +51 -0
  14. package/extensions/auth/database/migrations.ts +3 -0
  15. package/extensions/auth/database/utils.ts +36 -0
  16. package/extensions/auth/index.ts +19 -0
  17. package/extensions/auth/meta/meta.ts +11 -0
  18. package/extensions/auth/openapi.ts +469 -0
  19. package/extensions/auth/studio/tests/login.spec.ts +34 -0
  20. package/extensions/auth/studio/tests/package.json +1 -0
  21. package/extensions/auth/studio/tests/playwright.config.cjs +27 -0
  22. package/extensions/auth/tests/collections/extend_users_collection.test.ts +61 -0
  23. package/extensions/auth/tests/configs/auth.ts +73 -0
  24. package/extensions/auth/tests/configs/auth_no_roles.ts +65 -0
  25. package/extensions/auth/tests/configs/auth_public_full_access.ts +69 -0
  26. package/extensions/auth/tests/configs/auth_with_different_admin_creds.ts +81 -0
  27. package/extensions/auth/tests/configs/auth_with_extend_users.ts +81 -0
  28. package/extensions/auth/tests/configs/auth_with_refresh_token.ts +86 -0
  29. package/extensions/auth/tests/configs/auth_with_short_access_token_only.ts +95 -0
  30. package/extensions/auth/tests/configs/auth_with_short_time_refresh_token.ts +86 -0
  31. package/extensions/auth/tests/configs/social_blog.ts +156 -0
  32. package/extensions/auth/tests/controllers/change_password.test.ts +113 -0
  33. package/extensions/auth/tests/controllers/dashboardAccessRoles.test.ts +29 -0
  34. package/extensions/auth/tests/controllers/login.test.ts +101 -0
  35. package/extensions/auth/tests/controllers/logout.test.ts +89 -0
  36. package/extensions/auth/tests/controllers/me.test.ts +272 -0
  37. package/extensions/auth/tests/controllers/register.test.ts +45 -0
  38. package/extensions/auth/tests/database/db.test.ts +64 -0
  39. package/extensions/auth/tests/database/differentAdminCreds.test.ts +51 -0
  40. package/extensions/auth/tests/middlewares/adminAuthGuard.test.ts +157 -0
  41. package/extensions/auth/tests/middlewares/publicAllowBasic.test.ts +137 -0
  42. package/extensions/auth/tests/middlewares/publicPreventBasic.test.ts +108 -0
  43. package/extensions/auth/tests/socialBlog.test.ts +253 -0
  44. package/extensions/auth/tests/utils/addArticles.ts +22 -0
  45. package/extensions/auth/tests/utils/addSocialBlogArticles.ts +52 -0
  46. package/extensions/auth/tests/utils/data/articles.ts +65 -0
  47. package/extensions/auth/tests/utils/data/socialBlogArticles.ts +56 -0
  48. package/extensions/auth/utils.ts +17 -0
  49. package/extensions/auth/workflows/baseWorkflow.ts +159 -0
  50. package/extensions/auth/workflows/hashHandlerWorkflows.ts +29 -0
  51. package/extensions/auth/workflows/index.ts +29 -0
  52. package/extensions/auth/workflows/meAliasWorkflows.ts +48 -0
  53. package/extensions/auth/workflows/policiesWorkflows.ts +240 -0
  54. package/extensions/auth/workflows/utils.ts +306 -0
  55. package/lobb.ts +108 -0
  56. package/package.json +33 -6
  57. package/public/public/vite.svg +1 -0
  58. package/scripts/postpublish.sh +12 -0
  59. package/scripts/prepublish.sh +17 -0
  60. package/studio/app.html +12 -0
  61. package/studio/routes/+layout.svelte +7 -0
  62. package/studio/routes/+layout.ts +1 -0
  63. package/studio/routes/[...path]/+page.svelte +6 -0
  64. package/svelte.config.js +23 -7
  65. package/todo.md +37 -0
  66. package/tsconfig.app.json +3 -3
  67. package/tsconfig.json +9 -10
  68. package/vite.config.ts +4 -8
  69. package/.env +0 -1
  70. package/components.json +0 -16
  71. package/index.html +0 -13
  72. package/src/app.css +0 -124
  73. package/src/main.ts +0 -14
  74. /package/{src → extensions/auth/studio}/auth.ts +0 -0
  75. /package/{src → extensions/auth/studio}/index.ts +0 -0
  76. /package/{src → extensions/auth/studio}/lib/components/pages/loginPage/index.svelte +0 -0
  77. /package/{src → extensions/auth/studio}/lib/components/pages/settings/index.svelte +0 -0
  78. /package/{src → extensions/auth/studio}/lib/components/pages/settings/pages/activityFeed.svelte +0 -0
  79. /package/{src → extensions/auth/studio}/lib/components/pages/settings/pages/rolesAndPermissions.svelte +0 -0
  80. /package/{src → extensions/auth/studio}/lib/components/pages/settings/pages/users.svelte +0 -0
  81. /package/{src → extensions/auth/studio}/lib/components/pages/userSettings/components/account.svelte +0 -0
  82. /package/{src → extensions/auth/studio}/lib/components/pages/userSettings/components/profile.svelte +0 -0
  83. /package/{src → extensions/auth/studio}/lib/components/pages/userSettings/index.svelte +0 -0
  84. /package/{src → extensions/auth/studio}/lib/index.ts +0 -0
  85. /package/{src → extensions/auth/studio}/lib/utils.ts +0 -0
  86. /package/{src → extensions/auth/studio}/onStartup.ts +0 -0
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
@@ -0,0 +1,12 @@
1
+ #!/bin/bash
2
+
3
+ # Postpublish script for @lobb-js/lobb-ext-auth
4
+ # Reverts package.json exports and cleans dist to avoid uncommitted changes
5
+
6
+ echo "📝 Reverting package.json exports to development mode..."
7
+ jq '."exports"["./studio"] = "./extensions/auth/studio/index.ts"' package.json > package.json.tmp && mv package.json.tmp package.json
8
+
9
+ echo "🧹 Cleaning dist directory..."
10
+ rm -rf dist
11
+
12
+ echo "✅ Postpublish complete"
@@ -0,0 +1,17 @@
1
+ #!/bin/bash
2
+
3
+ # Prepublish script for @lobb-js/lobb-ext-auth
4
+ # Builds the studio package and updates exports for publishing
5
+
6
+ echo "📦 Building studio package..."
7
+ bun run package
8
+
9
+ if [ $? -ne 0 ]; then
10
+ echo "❌ Build failed"
11
+ exit 1
12
+ fi
13
+
14
+ echo "📝 Updating package.json exports for publishing..."
15
+ jq '."exports"["./studio"] = {"svelte": "./dist/index.js", "types": "./dist/index.d.ts"}' package.json > package.json.tmp && mv package.json.tmp package.json
16
+
17
+ echo "✅ Prepublish complete"
@@ -0,0 +1,12 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <link rel="icon" href="%sveltekit.assets%/vite.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
7
+ %sveltekit.head%
8
+ </head>
9
+ <body data-sveltekit-preload-data="hover">
10
+ <div style="display: contents">%sveltekit.body%</div>
11
+ </body>
12
+ </html>
@@ -0,0 +1,7 @@
1
+ <script lang="ts">
2
+ import "@lobb-js/studio/app.css";
3
+
4
+ let { children } = $props();
5
+ </script>
6
+
7
+ {@render children()}
@@ -0,0 +1 @@
1
+ export const ssr = false;
@@ -0,0 +1,6 @@
1
+ <script lang="ts">
2
+ import { Studio } from "@lobb-js/studio";
3
+ import { env } from "$env/dynamic/public";
4
+ </script>
5
+
6
+ <Studio lobbUrl={env.PUBLIC_LOBB_URL} />
package/svelte.config.js CHANGED
@@ -1,8 +1,24 @@
1
- import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'
1
+ import adapter from '@sveltejs/adapter-node';
2
2
 
3
- /** @type {import("@sveltejs/vite-plugin-svelte").SvelteConfig} */
4
- export default {
5
- // Consult https://svelte.dev/docs#compile-time-svelte-preprocess
6
- // for more information about preprocessors
7
- preprocess: vitePreprocess(),
8
- }
3
+ /** @type {import('@sveltejs/kit').Config} */
4
+ const config = {
5
+ kit: {
6
+ adapter: adapter(),
7
+ paths: {
8
+ base: '/studio'
9
+ },
10
+ files: {
11
+ lib: 'studio/lib',
12
+ routes: 'studio/routes',
13
+ appTemplate: 'studio/app.html',
14
+ assets: 'public',
15
+ hooks: {
16
+ server: 'studio/hooks.server',
17
+ client: 'studio/hooks.client',
18
+ },
19
+ params: 'studio/params',
20
+ }
21
+ }
22
+ };
23
+
24
+ export default config;
package/todo.md ADDED
@@ -0,0 +1,37 @@
1
+ # high priority
2
+
3
+ - remove the `dashboard_access_roles` and just put it in the specific role in the `roles` property
4
+ - currently we have the payloadGuard. you can later implement the `recordGuard`
5
+ for `update` and `delete`
6
+ - implement rotating refresh token mechanism
7
+ - you can implement the firebase adapter and get all other adapters
8
+ - check `https://passkeys.dev/`. the new standart to abandon passwords
9
+ - prevent any one from creating a user with the admin role
10
+
11
+ # low priority
12
+
13
+ - add basic authentication in lobb. or at least make something like it. where
14
+ you have a users.json file and those will be the users without creating a
15
+ users or anything like that. its much simpler for simpler usage
16
+ - the collection_name property in the refresh_token property default value in
17
+ the schema doent work. its similar to the issue of the auth collection name.
18
+ although Im adding a default value to that property. but its value is
19
+ undefined for some reason. investigate it
20
+ - remove keep only the user id in the payload of the access and refresh tokens
21
+ - rotational refresh tokens where the refresh token is changes every time its
22
+ used to refresh an access token
23
+ - prepare the views directory for extensions in a better way. now there is a way
24
+ to view all component you have in an isolated manner. and when you run
25
+ `npm run build` it will generate a js compiled version of the svelte
26
+ component.
27
+ - for now you need to import the main css file in all of the components in order
28
+ for tailwind stuff to be indluded in the main style.css. but in the future you
29
+ should import all component in an index file and include the main css there
30
+ and force vite to create seperate chunks for each imported svelte compoenent
31
+ there. so that you dont get one bundle because you need them seperated
32
+ - change the views from svelte files into directories that holds index.svelte
33
+ files. (this is better because maybe in the future you want to modularize or
34
+ split your code or have other files. so they will all be organized inside that
35
+ directory and you dont need to have a svelte file and then have a directory
36
+ with the same name of that file to hold all the imports of that svelte file.
37
+ its better to have them all stored in one directory)
package/tsconfig.app.json CHANGED
@@ -19,9 +19,9 @@
19
19
  "moduleDetection": "force",
20
20
  "baseUrl": ".",
21
21
  "paths": {
22
- "$lib": ["./src/lib"],
23
- "$lib/*": ["./src/lib/*"]
22
+ "$lib": ["./studio/lib"],
23
+ "$lib/*": ["./studio/lib/*"]
24
24
  }
25
25
  },
26
- "include": ["src/**/*.ts", "src/**/*.js", "src/**/*.svelte"]
26
+ "include": ["studio/**/*.ts", "studio/**/*.js", "studio/**/*.svelte"]
27
27
  }
package/tsconfig.json CHANGED
@@ -1,14 +1,13 @@
1
1
  {
2
- "files": [],
3
- "references": [
4
- { "path": "./tsconfig.app.json" },
5
- { "path": "./tsconfig.node.json" }
6
- ],
2
+ "extends": "./.svelte-kit/tsconfig.json",
7
3
  "compilerOptions": {
8
- "baseUrl": ".",
9
- "paths": {
10
- "$lib": ["./src/lib"],
11
- "$lib/*": ["./src/lib/*"]
12
- }
4
+ "allowJs": true,
5
+ "checkJs": true,
6
+ "esModuleInterop": true,
7
+ "forceConsistentCasingInFileNames": true,
8
+ "resolveJsonModule": true,
9
+ "skipLibCheck": true,
10
+ "sourceMap": true,
11
+ "strict": true
13
12
  }
14
13
  }
package/vite.config.ts CHANGED
@@ -1,12 +1,8 @@
1
- import { defineConfig } from "vite";
2
- import { svelte } from "@sveltejs/vite-plugin-svelte";
1
+ import { sveltekit } from '@sveltejs/kit/vite';
2
+ import { defineConfig } from 'vite';
3
3
  import tailwindcss from "@tailwindcss/vite";
4
+ import { lobbStudioPlugins } from '@lobb-js/studio/vite-plugins';
4
5
 
5
- // https://vite.dev/config/
6
6
  export default defineConfig({
7
- base: '/studio',
8
- plugins: [
9
- tailwindcss(),
10
- svelte(),
11
- ],
7
+ plugins: [tailwindcss(), sveltekit(), ...lobbStudioPlugins()],
12
8
  });
package/.env DELETED
@@ -1 +0,0 @@
1
- NGROK_AUTHTOKEN=2NBFGwIM5SqpEcyRnR0k2Kh6Dm4_6a69urL1RTUc6zqfqaZ4R
package/components.json DELETED
@@ -1,16 +0,0 @@
1
- {
2
- "$schema": "https://shadcn-svelte.com/schema.json",
3
- "tailwind": {
4
- "css": "src/app.css",
5
- "baseColor": "slate"
6
- },
7
- "aliases": {
8
- "components": "$lib/components",
9
- "utils": "$lib/utils",
10
- "ui": "$lib/components/ui",
11
- "hooks": "$lib/hooks",
12
- "lib": "$lib"
13
- },
14
- "typescript": true,
15
- "registry": "https://shadcn-svelte.com/registry"
16
- }
package/index.html DELETED
@@ -1,13 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <title>Lobb Studio</title>
8
- </head>
9
- <body>
10
- <div id="app"></div>
11
- <script type="module" src="/src/main.ts"></script>
12
- </body>
13
- </html>
package/src/app.css DELETED
@@ -1,124 +0,0 @@
1
- @import "tailwindcss";
2
-
3
- @import "tw-animate-css";
4
-
5
- @source "../../../../packages";
6
- @source "../node_modules/@lobb-js";
7
-
8
- @custom-variant dark (&:is(.dark *));
9
-
10
- :root {
11
- --radius: 0.625rem;
12
- --background: oklch(1 0 0);
13
- --foreground: oklch(0.129 0.042 264.695);
14
- --card: oklch(1 0 0);
15
- --card-foreground: oklch(0.129 0.042 264.695);
16
- --popover: oklch(1 0 0);
17
- --popover-foreground: oklch(0.129 0.042 264.695);
18
- --primary: oklch(0.208 0.042 265.755);
19
- --primary-foreground: oklch(0.984 0.003 247.858);
20
- --secondary: oklch(0.968 0.007 247.896);
21
- --secondary-foreground: oklch(0.208 0.042 265.755);
22
- --muted: oklch(0.968 0.007 247.896);
23
- --muted-foreground: oklch(0.554 0.046 257.417);
24
- --accent: oklch(0.968 0.007 247.896);
25
- --accent-foreground: oklch(0.208 0.042 265.755);
26
- --destructive: oklch(0.577 0.245 27.325);
27
- --border: oklch(0.929 0.013 255.508);
28
- --input: oklch(0.929 0.013 255.508);
29
- --ring: oklch(0.704 0.04 256.788);
30
- --chart-1: oklch(0.646 0.222 41.116);
31
- --chart-2: oklch(0.6 0.118 184.704);
32
- --chart-3: oklch(0.398 0.07 227.392);
33
- --chart-4: oklch(0.828 0.189 84.429);
34
- --chart-5: oklch(0.769 0.188 70.08);
35
- --sidebar: oklch(0.984 0.003 247.858);
36
- --sidebar-foreground: oklch(0.129 0.042 264.695);
37
- --sidebar-primary: oklch(0.208 0.042 265.755);
38
- --sidebar-primary-foreground: oklch(0.984 0.003 247.858);
39
- --sidebar-accent: oklch(0.968 0.007 247.896);
40
- --sidebar-accent-foreground: oklch(0.208 0.042 265.755);
41
- --sidebar-border: oklch(0.929 0.013 255.508);
42
- --sidebar-ring: oklch(0.704 0.04 256.788);
43
- }
44
-
45
- .dark {
46
- --background: oklch(0.129 0.042 264.695);
47
- --foreground: oklch(0.984 0.003 247.858);
48
- --card: oklch(0.208 0.042 265.755);
49
- --card-foreground: oklch(0.984 0.003 247.858);
50
- --popover: oklch(0.208 0.042 265.755);
51
- --popover-foreground: oklch(0.984 0.003 247.858);
52
- --primary: oklch(0.929 0.013 255.508);
53
- --primary-foreground: oklch(0.208 0.042 265.755);
54
- --secondary: oklch(0.279 0.041 260.031);
55
- --secondary-foreground: oklch(0.984 0.003 247.858);
56
- --muted: oklch(0.279 0.041 260.031);
57
- --muted-foreground: oklch(0.704 0.04 256.788);
58
- --accent: oklch(0.279 0.041 260.031);
59
- --accent-foreground: oklch(0.984 0.003 247.858);
60
- --destructive: oklch(0.704 0.191 22.216);
61
- --border: oklch(1 0 0 / 10%);
62
- --input: oklch(1 0 0 / 15%);
63
- --ring: oklch(0.551 0.027 264.364);
64
- --chart-1: oklch(0.488 0.243 264.376);
65
- --chart-2: oklch(0.696 0.17 162.48);
66
- --chart-3: oklch(0.769 0.188 70.08);
67
- --chart-4: oklch(0.627 0.265 303.9);
68
- --chart-5: oklch(0.645 0.246 16.439);
69
- --sidebar: oklch(0.208 0.042 265.755);
70
- --sidebar-foreground: oklch(0.984 0.003 247.858);
71
- --sidebar-primary: oklch(0.488 0.243 264.376);
72
- --sidebar-primary-foreground: oklch(0.984 0.003 247.858);
73
- --sidebar-accent: oklch(0.279 0.041 260.031);
74
- --sidebar-accent-foreground: oklch(0.984 0.003 247.858);
75
- --sidebar-border: oklch(1 0 0 / 10%);
76
- --sidebar-ring: oklch(0.551 0.027 264.364);
77
- }
78
-
79
- @theme inline {
80
- --radius-sm: calc(var(--radius) - 4px);
81
- --radius-md: calc(var(--radius) - 2px);
82
- --radius-lg: var(--radius);
83
- --radius-xl: calc(var(--radius) + 4px);
84
- --color-background: var(--background);
85
- --color-foreground: var(--foreground);
86
- --color-card: var(--card);
87
- --color-card-foreground: var(--card-foreground);
88
- --color-popover: var(--popover);
89
- --color-popover-foreground: var(--popover-foreground);
90
- --color-primary: var(--primary);
91
- --color-primary-foreground: var(--primary-foreground);
92
- --color-secondary: var(--secondary);
93
- --color-secondary-foreground: var(--secondary-foreground);
94
- --color-muted: var(--muted);
95
- --color-muted-foreground: var(--muted-foreground);
96
- --color-accent: var(--accent);
97
- --color-accent-foreground: var(--accent-foreground);
98
- --color-destructive: var(--destructive);
99
- --color-border: var(--border);
100
- --color-input: var(--input);
101
- --color-ring: var(--ring);
102
- --color-chart-1: var(--chart-1);
103
- --color-chart-2: var(--chart-2);
104
- --color-chart-3: var(--chart-3);
105
- --color-chart-4: var(--chart-4);
106
- --color-chart-5: var(--chart-5);
107
- --color-sidebar: var(--sidebar);
108
- --color-sidebar-foreground: var(--sidebar-foreground);
109
- --color-sidebar-primary: var(--sidebar-primary);
110
- --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
111
- --color-sidebar-accent: var(--sidebar-accent);
112
- --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
113
- --color-sidebar-border: var(--sidebar-border);
114
- --color-sidebar-ring: var(--sidebar-ring);
115
- }
116
-
117
- @layer base {
118
- * {
119
- @apply border-border outline-ring/50;
120
- }
121
- body {
122
- @apply bg-background text-foreground;
123
- }
124
- }
package/src/main.ts DELETED
@@ -1,14 +0,0 @@
1
- import "./app.css";
2
-
3
- import { mount } from "svelte";
4
- import { Studio } from "@lobb-js/studio";
5
- import { extension } from "./index";
6
-
7
- const app = mount(Studio, {
8
- target: document.getElementById("app")!,
9
- props: {
10
- extensions: [extension],
11
- },
12
- });
13
-
14
- export default app;
File without changes
File without changes
File without changes
File without changes
File without changes