@lobb-js/lobb-ext-auth 0.4.1 → 0.5.0

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/README.md CHANGED
@@ -1 +1,2 @@
1
1
  # @lobb-js/lobb-ext-auth
2
+
@@ -1,9 +1,30 @@
1
1
  import type { Workflow } from "@lobb-js/core";
2
2
  import type { Context } from "hono";
3
- import type { User } from "../config/extensionConfigSchema.ts";
3
+ import type { ExtensionConfig, User } from "../config/extensionConfigSchema.ts";
4
4
  import { generateRandomId, getBearerToken } from "../utils.ts";
5
5
  import { verify } from "argon2";
6
6
 
7
+ export function getBaseWorkflows(_extensionConfig: ExtensionConfig): Workflow[] {
8
+ return [
9
+ {
10
+ name: "auth_preventAdminUserDeletion",
11
+ eventName: "core.store.preDeleteOne",
12
+ handler: async (input, ctx) => {
13
+ if (input.collectionName !== "auth_users") return;
14
+ if (input.triggeredBy !== "API") return;
15
+
16
+ if (Number(input.id) === 1) {
17
+ throw new ctx.LobbError({
18
+ code: "FORBIDDEN",
19
+ message: "The admin user cannot be deleted.",
20
+ });
21
+ }
22
+ },
23
+ },
24
+ ...baseWorkflows,
25
+ ];
26
+ }
27
+
7
28
  export const baseWorkflows: Workflow[] = [
8
29
  {
9
30
  name: "auth_BearerTokenHandler",
@@ -2,10 +2,10 @@ import type { Workflow } from "@lobb-js/core";
2
2
  import type { ExtensionConfig } from "../config/extensionConfigSchema.ts";
3
3
  import { getPoliciesWorkflows } from "./policiesWorkflows.ts";
4
4
  import { meAliasWorkflows } from "./meAliasWorkflows.ts";
5
- import { baseWorkflows } from "./baseWorkflow.ts";
5
+ import { getBaseWorkflows } from "./baseWorkflow.ts";
6
6
  export function getWorkflows(extensionConfig: ExtensionConfig): Workflow[] {
7
7
  return [
8
- ...baseWorkflows,
8
+ ...getBaseWorkflows(extensionConfig),
9
9
 
10
10
  // TODO: think about putting the below workflows above at the beggining
11
11
  // this will give us the ability to specify which roles have the ability to login, register etc
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobb-js/lobb-ext-auth",
3
- "version": "0.4.1",
3
+ "version": "0.5.0",
4
4
  "license": "UNLICENSED",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -33,12 +33,12 @@
33
33
  "package": "svelte-package --input extensions/auth/studio"
34
34
  },
35
35
  "dependencies": {
36
- "@lobb-js/core": "^0.21.0",
36
+ "@lobb-js/core": "^0.22.0",
37
37
  "argon2": "^0.40.3",
38
38
  "hono": "^4.7.0"
39
39
  },
40
40
  "devDependencies": {
41
- "@lobb-js/studio": "^0.15.0",
41
+ "@lobb-js/studio": "^0.16.0",
42
42
  "@lucide/svelte": "^0.563.1",
43
43
  "@playwright/test": "^1.58.2",
44
44
  "@sveltejs/adapter-node": "^5.5.4",