@open-core/identity 1.2.4 → 1.2.5

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.
@@ -33,10 +33,11 @@ export declare abstract class IdentityStore {
33
33
  /**
34
34
  * Persists a new identity account.
35
35
  *
36
- * @param data - Initial account properties.
36
+ * @param data - Initial account properties (ID is optional as it's usually handled by the store).
37
37
  * @returns A promise resolving to the fully created account object.
38
38
  */
39
- abstract create(data: Partial<IdentityAccount> & {
39
+ abstract create(data: Omit<IdentityAccount, "id"> & {
40
+ id?: string | number;
40
41
  passwordHash?: string;
41
42
  }): Promise<IdentityAccount>;
42
43
  /**
@@ -45,7 +46,7 @@ export declare abstract class IdentityStore {
45
46
  * @param id - The internal account ID.
46
47
  * @param data - Partial object containing fields to update.
47
48
  */
48
- abstract update(id: string | number, data: Partial<IdentityAccount>): Promise<void>;
49
+ abstract update(id: string | number, data: Partial<Omit<IdentityAccount, "id">>): Promise<void>;
49
50
  /**
50
51
  * Prohibits or allows an account from connecting.
51
52
  *
@@ -79,11 +80,21 @@ export declare abstract class RoleStore {
79
80
  */
80
81
  abstract getDefaultRole(): Promise<IdentityRole>;
81
82
  /**
82
- * Creates or updates a role definition.
83
+ * Persists a new security role definition.
83
84
  *
84
- * @param role - The complete role object.
85
+ * @param role - Initial role properties. ID can be provided or left to the store.
86
+ * @returns A promise resolving to the fully created role object.
85
87
  */
86
- abstract save(role: IdentityRole): Promise<void>;
88
+ abstract create(role: Omit<IdentityRole, "id"> & {
89
+ id?: string | number;
90
+ }): Promise<IdentityRole>;
91
+ /**
92
+ * Updates an existing role definition.
93
+ *
94
+ * @param id - Technical identifier of the role to update.
95
+ * @param role - Partial role object containing the fields to modify.
96
+ */
97
+ abstract update(id: string | number, role: Partial<Omit<IdentityRole, "id">>): Promise<void>;
87
98
  /**
88
99
  * Removes a role from the system.
89
100
  *
@@ -96,6 +96,8 @@ let CredentialsAuthProvider = class CredentialsAuthProvider extends Server.AuthP
96
96
  passwordHash,
97
97
  identifier: primaryIdentifier,
98
98
  roleId: this.options.principal.defaultRole || "user",
99
+ customPermissions: [],
100
+ isBanned: false,
99
101
  });
100
102
  const accountIdStr = String(account.id);
101
103
  player.linkAccount(accountIdStr);
@@ -115,6 +115,8 @@ let LocalAuthProvider = class LocalAuthProvider extends Server.AuthProviderContr
115
115
  account = await this.store.create({
116
116
  identifier: identifierValue,
117
117
  roleId: "user",
118
+ customPermissions: [],
119
+ isBanned: false,
118
120
  });
119
121
  isNew = true;
120
122
  }
@@ -1,5 +1,5 @@
1
1
  import { IdentityStore } from "../contracts";
2
- import type { IdentityAccount, IdentityOptions } from "../types";
2
+ import type { IdentityAccount } from "../types";
3
3
  /**
4
4
  * High-level service for managing identity accounts and security policies.
5
5
  *
@@ -11,8 +11,7 @@ import type { IdentityAccount, IdentityOptions } from "../types";
11
11
  */
12
12
  export declare class AccountService {
13
13
  private readonly store;
14
- private readonly options;
15
- constructor(store: IdentityStore, options: IdentityOptions);
14
+ constructor(store: IdentityStore);
16
15
  /**
17
16
  * Retrieves an account by its unique numeric or internal ID.
18
17
  *
@@ -27,6 +26,24 @@ export declare class AccountService {
27
26
  * @returns A promise resolving to the account or null if not found.
28
27
  */
29
28
  findByLinkedId(linkedId: string): Promise<IdentityAccount | null>;
29
+ /**
30
+ * Persists a new identity account.
31
+ *
32
+ * @param data - Initial account properties. ID can be provided or left to the store.
33
+ * @returns A promise resolving to the fully created account object.
34
+ */
35
+ create(data: Omit<IdentityAccount, "id"> & {
36
+ id?: string | number;
37
+ passwordHash?: string;
38
+ }): Promise<IdentityAccount>;
39
+ /**
40
+ * Updates an existing account's metadata or status.
41
+ *
42
+ * @param id - The internal account ID.
43
+ * @param data - Partial object containing fields to update.
44
+ * @returns A promise that resolves when the update is complete.
45
+ */
46
+ update(id: string | number, data: Partial<Omit<IdentityAccount, "id">>): Promise<void>;
30
47
  /**
31
48
  * Assigns a security role to an account.
32
49
  *
@@ -7,11 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  var __metadata = (this && this.__metadata) || function (k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
- var __param = (this && this.__param) || function (paramIndex, decorator) {
11
- return function (target, key) { decorator(target, key, paramIndex); }
12
- };
13
- import { injectable, inject } from "tsyringe";
14
- import { IDENTITY_OPTIONS } from "../tokens";
10
+ import { injectable } from "tsyringe";
15
11
  import { IdentityStore } from "../contracts";
16
12
  /**
17
13
  * High-level service for managing identity accounts and security policies.
@@ -23,9 +19,8 @@ import { IdentityStore } from "../contracts";
23
19
  * @injectable
24
20
  */
25
21
  let AccountService = class AccountService {
26
- constructor(store, options) {
22
+ constructor(store) {
27
23
  this.store = store;
28
- this.options = options;
29
24
  }
30
25
  /**
31
26
  * Retrieves an account by its unique numeric or internal ID.
@@ -45,6 +40,25 @@ let AccountService = class AccountService {
45
40
  async findByLinkedId(linkedId) {
46
41
  return this.store.findByLinkedId(linkedId);
47
42
  }
43
+ /**
44
+ * Persists a new identity account.
45
+ *
46
+ * @param data - Initial account properties. ID can be provided or left to the store.
47
+ * @returns A promise resolving to the fully created account object.
48
+ */
49
+ async create(data) {
50
+ return this.store.create(data);
51
+ }
52
+ /**
53
+ * Updates an existing account's metadata or status.
54
+ *
55
+ * @param id - The internal account ID.
56
+ * @param data - Partial object containing fields to update.
57
+ * @returns A promise that resolves when the update is complete.
58
+ */
59
+ async update(id, data) {
60
+ await this.store.update(id, data);
61
+ }
48
62
  /**
49
63
  * Assigns a security role to an account.
50
64
  *
@@ -52,7 +66,7 @@ let AccountService = class AccountService {
52
66
  * @param roleId - Technical identifier of the role to assign.
53
67
  */
54
68
  async assignRole(accountId, roleId) {
55
- await this.store.update(accountId, { roleId });
69
+ await this.update(accountId, { roleId });
56
70
  }
57
71
  /**
58
72
  * Grants a custom permission override to an account.
@@ -115,7 +129,6 @@ let AccountService = class AccountService {
115
129
  };
116
130
  AccountService = __decorate([
117
131
  injectable(),
118
- __param(1, inject(IDENTITY_OPTIONS)),
119
- __metadata("design:paramtypes", [IdentityStore, Object])
132
+ __metadata("design:paramtypes", [IdentityStore])
120
133
  ], AccountService);
121
134
  export { AccountService };
@@ -1,5 +1,5 @@
1
1
  import { RoleStore } from "../contracts";
2
- import type { IdentityOptions, IdentityRole } from "../types";
2
+ import type { IdentityRole } from "../types";
3
3
  /**
4
4
  * High-level service for managing security roles and their associated permissions.
5
5
  *
@@ -12,21 +12,16 @@ import type { IdentityOptions, IdentityRole } from "../types";
12
12
  */
13
13
  export declare class RoleService {
14
14
  private readonly store;
15
- private readonly options;
16
- /**
17
- * Initializes a new instance of the RoleService.
18
- *
19
- * @param store - Persistence layer for role definitions.
20
- * @param options - Identity system configuration options.
21
- */
22
- constructor(store: RoleStore, options: IdentityOptions);
15
+ constructor(store: RoleStore);
23
16
  /**
24
17
  * Persists a new security role definition.
25
18
  *
26
- * @param role - The complete role definition to create.
27
- * @returns A promise that resolves when the role is saved.
19
+ * @param role - The initial role properties (ID is optional).
20
+ * @returns A promise resolving to the created role.
28
21
  */
29
- create(role: IdentityRole): Promise<void>;
22
+ create(role: Omit<IdentityRole, "id"> & {
23
+ id?: string | number;
24
+ }): Promise<IdentityRole>;
30
25
  /**
31
26
  * Updates an existing role's rank or permissions.
32
27
  *
@@ -7,11 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  var __metadata = (this && this.__metadata) || function (k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
- var __param = (this && this.__param) || function (paramIndex, decorator) {
11
- return function (target, key) { decorator(target, key, paramIndex); }
12
- };
13
- import { injectable, inject } from "tsyringe";
14
- import { IDENTITY_OPTIONS } from "../tokens";
10
+ import { injectable } from "tsyringe";
15
11
  import { RoleStore } from "../contracts";
16
12
  /**
17
13
  * High-level service for managing security roles and their associated permissions.
@@ -24,24 +20,17 @@ import { RoleStore } from "../contracts";
24
20
  * @injectable
25
21
  */
26
22
  let RoleService = class RoleService {
27
- /**
28
- * Initializes a new instance of the RoleService.
29
- *
30
- * @param store - Persistence layer for role definitions.
31
- * @param options - Identity system configuration options.
32
- */
33
- constructor(store, options) {
23
+ constructor(store) {
34
24
  this.store = store;
35
- this.options = options;
36
25
  }
37
26
  /**
38
27
  * Persists a new security role definition.
39
28
  *
40
- * @param role - The complete role definition to create.
41
- * @returns A promise that resolves when the role is saved.
29
+ * @param role - The initial role properties (ID is optional).
30
+ * @returns A promise resolving to the created role.
42
31
  */
43
32
  async create(role) {
44
- await this.store.save(role);
33
+ return this.store.create(role);
45
34
  }
46
35
  /**
47
36
  * Updates an existing role's rank or permissions.
@@ -51,13 +40,7 @@ let RoleService = class RoleService {
51
40
  * @returns A promise that resolves when the update is complete.
52
41
  */
53
42
  async update(id, data) {
54
- const existing = await this.store.findById(id);
55
- if (!existing)
56
- return;
57
- await this.store.save({
58
- ...existing,
59
- ...data,
60
- });
43
+ await this.store.update(id, data);
61
44
  }
62
45
  /**
63
46
  * Permanently removes a role definition from the system.
@@ -81,7 +64,6 @@ let RoleService = class RoleService {
81
64
  };
82
65
  RoleService = __decorate([
83
66
  injectable(),
84
- __param(1, inject(IDENTITY_OPTIONS)),
85
- __metadata("design:paramtypes", [RoleStore, Object])
67
+ __metadata("design:paramtypes", [RoleStore])
86
68
  ], RoleService);
87
69
  export { RoleService };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-core/identity",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
4
4
  "description": "Enterprise-grade identity, authentication, and authorization plugin for OpenCore Framework",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",