@wxn0brp/gate-warden 0.2.2 → 0.3.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/dist/mgr.d.ts CHANGED
@@ -1,9 +1,8 @@
1
- import { Id, Valthera } from "@wxn0brp/db";
1
+ import { Id, ValtheraCompatible } from "@wxn0brp/db-core";
2
2
  import { ABACRule, Role } from "./types/system.js";
3
- import { Remote } from "@wxn0brp/db/client/remote.js";
4
3
  declare class WardenManager {
5
4
  private db;
6
- constructor(valthera: string | Valthera | Remote);
5
+ constructor(db: ValtheraCompatible);
7
6
  changeRoleNameToId(name: string): Promise<Id>;
8
7
  addRole(role: Role): Promise<Role>;
9
8
  addACLRule(entityId: string, p: number, uid?: Id): Promise<void>;
package/dist/mgr.js CHANGED
@@ -1,8 +1,7 @@
1
- import { createDb } from "./createDb.js";
2
1
  class WardenManager {
3
2
  db;
4
- constructor(valthera) {
5
- this.db = createDb(valthera);
3
+ constructor(db) {
4
+ this.db = db;
6
5
  }
7
6
  async changeRoleNameToId(name) {
8
7
  return await this.db.findOne("roles", { name });
@@ -1,5 +1,5 @@
1
- import { Id } from "@wxn0brp/db";
2
- import { SearchOptions } from "@wxn0brp/db/types/searchOpts.js";
1
+ import { Id } from "@wxn0brp/db-core";
2
+ import { SearchOptions } from "@wxn0brp/db-core/types/searchOpts";
3
3
  export interface Role {
4
4
  _id: Id;
5
5
  name: string;
package/dist/user.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { Id, Valthera } from "@wxn0brp/db";
1
+ import { Id, ValtheraCompatible } from "@wxn0brp/db-core";
2
2
  import { User } from "./types/system.js";
3
3
  declare class UserManager<A = any> {
4
4
  private db;
5
- constructor(valthera: string | Valthera);
5
+ constructor(db: ValtheraCompatible);
6
6
  /**
7
7
  * Creates a new user
8
8
  * @param userData User data (_id is required)
package/dist/user.js CHANGED
@@ -1,8 +1,7 @@
1
- import { createDb } from "./createDb.js";
2
1
  class UserManager {
3
2
  db;
4
- constructor(valthera) {
5
- this.db = createDb(valthera);
3
+ constructor(db) {
4
+ this.db = db;
6
5
  }
7
6
  /**
8
7
  * Creates a new user
package/dist/warden.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { Valthera } from "@wxn0brp/db";
1
+ import { ValtheraCompatible } from "@wxn0brp/db-core";
2
2
  import { AccessResult } from "./types/system.js";
3
3
  declare class GateWarden<A = any> {
4
- debugLog: number;
5
4
  private db;
6
- constructor(valthera: string | Valthera, debugLog?: number);
5
+ debugLog: number;
6
+ constructor(db: ValtheraCompatible, debugLog?: number);
7
7
  hasAccess(userId: string, entityId: string, flag: number): Promise<AccessResult>;
8
8
  }
9
9
  export default GateWarden;
package/dist/warden.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { COLORS } from "./log.js";
2
- import { createDb } from "./createDb.js";
3
- import hasFieldsAdvanced from "@wxn0brp/db/utils/hasFieldsAdvanced.js";
2
+ import hasFieldsAdvanced from "@wxn0brp/db-core/utils/hasFieldsAdvanced";
4
3
  function logAccess(userId, entityId, via, debugLog) {
5
4
  if (debugLog < 1)
6
5
  return;
@@ -138,11 +137,11 @@ async function matchPermission(db, entityId, flag, user, debugLog) {
138
137
  return { granted: false, via: null };
139
138
  }
140
139
  class GateWarden {
141
- debugLog;
142
140
  db;
143
- constructor(valthera, debugLog = 0) {
141
+ debugLog;
142
+ constructor(db, debugLog = 0) {
143
+ this.db = db;
144
144
  this.debugLog = debugLog;
145
- this.db = createDb(valthera);
146
145
  }
147
146
  async hasAccess(userId, entityId, flag) {
148
147
  const user = await fetchUser(this.db, userId);
package/package.json CHANGED
@@ -1,20 +1,25 @@
1
1
  {
2
2
  "name": "@wxn0brp/gate-warden",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "author": "wxn0brP",
7
7
  "license": "MIT",
8
8
  "type": "module",
9
+ "description": "A simple and flexible access control library for Node.js.",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/wxn0brP/gate-warden.git"
13
+ },
14
+ "homepage": "https://github.com/wxn0brP/gate-warden",
9
15
  "devDependencies": {
10
- "@types/node": "^24.0.10",
11
- "@wxn0brp/db": "0.10.0",
12
- "source-map-support": "^0.5.21",
16
+ "@types/node": "^24.0.13",
13
17
  "tsc-alias": "^1.8.16",
14
- "typescript": "^5.8.3"
18
+ "typescript": "^5.8.3",
19
+ "@wxn0brp/db-core": ">0.0.1 <0.1.0"
15
20
  },
16
21
  "peerDependencies": {
17
- "@wxn0brp/db": ">=0.10.0"
22
+ "@wxn0brp/db-core": ">0.0.1 <0.1.0"
18
23
  },
19
24
  "files": [
20
25
  "dist"
@@ -28,5 +33,6 @@
28
33
  "types": "./*",
29
34
  "import": "./*"
30
35
  }
31
- }
36
+ },
37
+ "dependencies": {}
32
38
  }
@@ -1,3 +0,0 @@
1
- import { Valthera } from "@wxn0brp/db";
2
- import { Remote } from "@wxn0brp/db/client/remote.js";
3
- export declare function createDb(valthera: string | Valthera | Remote): Valthera;
package/dist/createDb.js DELETED
@@ -1,6 +0,0 @@
1
- import { Valthera, ValtheraAutoCreate } from "@wxn0brp/db";
2
- export function createDb(valthera) {
3
- if (valthera instanceof Valthera)
4
- return valthera;
5
- return ValtheraAutoCreate(valthera);
6
- }