@open-core/identity 1.2.5 → 1.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/README.md CHANGED
@@ -1,76 +1,171 @@
1
- # @open-core/identity
2
-
3
- Enterprise-grade identity, authentication, and authorization plugin for the OpenCore Framework.
4
-
5
- ## Documentation Index
6
-
7
- - [Architecture & Dependency Injection](./docs/architecture.md) - Learn about constructor injection and DI.
8
- - [Authentication Modes](./docs/auth-modes.md) - Details on `local`, `credentials`, and `api` auth.
9
- - [Principal Modes](./docs/principal-modes.md) - Details on `roles`, `db`, and `api` authorization.
10
- - [Implementing Contracts](./docs/contracts.md) - How to build your own `IdentityStore` or `RoleStore`.
11
-
12
- ## Features
13
-
14
- - **Multi-Strategy Authentication**: Support for `local`, `credentials`, and `api` strategies.
15
- - **Hierarchical RBAC**: Rank-based authorization and permission merging.
16
- - **Constructor Injection**: Services are automatically available in your classes via DI.
17
- - **Stateless Architecture**: Decoupled persistence via implementable contracts.
18
-
19
- ## Quick Start (Constructor Injection)
20
-
21
- The recommended way to use the identity system is through **Constructor Injection**. The framework handles the lifecycle for you.
22
-
23
- ```ts
24
- import { Server } from "@open-core/framework";
25
- import { AccountService } from "@open-core/identity";
26
-
27
- @Server.Controller()
28
- export class MyController {
29
- // AccountService is automatically injected
30
- constructor(private readonly accounts: AccountService) {}
31
-
32
- @Server.OnNet("admin:ban")
33
- async handleBan(player: Server.Player, targetId: string) {
34
- await this.accounts.ban(targetId, { reason: "Policy violation" });
35
- }
36
- }
37
- ```
38
-
39
- ## Installation & Setup
40
-
41
- 1. **Implement your Store** (See [Contracts](./docs/contracts.md)):
42
- ```ts
43
- import { Identity, IdentityStore } from "@open-core/identity";
44
-
45
- class MyStore extends IdentityStore { /* ... */ }
46
-
47
- // Register it before installation
48
- Identity.setIdentityStore(MyStore);
49
- ```
50
-
51
- 2. **Install the Plugin**:
52
- ```ts
53
- Identity.install({
54
- auth: { mode: 'local', autoCreate: true },
55
- principal: {
56
- mode: 'roles',
57
- roles: {
58
- admin: { name: 'admin', rank: 100, permissions: ['*'] },
59
- user: { name: 'user', rank: 0, permissions: ['chat.use'] }
60
- }
61
- }
62
- });
63
- ```
64
-
65
- ## Exports
66
-
67
- The library only exports high-level components to keep your IDE suggestions clean:
68
- - `Identity`: The main namespace for installation and registration.
69
- - `AccountService`, `RoleService`: Public services for business logic.
70
- - `IdentityStore`, `RoleStore`: Abstract contracts for persistence.
71
- - `IDENTITY_OPTIONS`: Token for advanced DI usage.
72
- - All relevant types and interfaces.
73
-
74
- ## License
75
-
76
- MIT
1
+ # @open-core/identity
2
+
3
+ Enterprise-grade identity, authentication, and authorization plugin for the OpenCore Framework.
4
+
5
+ ## Documentation Index
6
+
7
+ - [Architecture & Dependency Injection](./docs/architecture.md) - Learn about constructor injection and DI.
8
+ - [Authentication Modes](./docs/auth-modes.md) - Details on `local`, `credentials`, and `api` auth.
9
+ - [Principal Modes](./docs/principal-modes.md) - Details on `roles`, `db`, and `api` authorization.
10
+ - [Implementing Contracts](./docs/contracts.md) - How to build your own `IdentityStore` or `RoleStore`.
11
+
12
+ ## Features
13
+
14
+ - **Multi-Strategy Authentication**: Support for `local`, `credentials`, and `api` strategies.
15
+ - **Hierarchical RBAC**: Rank-based authorization and permission merging.
16
+ - **Constructor Injection**: Services are automatically available in your classes via DI.
17
+ - **Stateless Architecture**: Decoupled persistence via implementable contracts.
18
+
19
+ ## Quick Start (Constructor Injection)
20
+
21
+ The recommended way to use the identity system is through **Constructor Injection**. The framework handles the lifecycle for you.
22
+
23
+ ```ts
24
+ import { Server } from "@open-core/framework";
25
+ import { AccountService } from "@open-core/identity";
26
+
27
+ @Server.Controller()
28
+ export class MyController {
29
+ // AccountService is automatically injected
30
+ constructor(private readonly accounts: AccountService) {}
31
+
32
+ @Server.OnNet("admin:ban")
33
+ async handleBan(player: Server.Player, targetId: string) {
34
+ await this.accounts.ban(targetId, { reason: "Policy violation" });
35
+ }
36
+ }
37
+ ```
38
+
39
+ ## Installation & Setup
40
+
41
+ 1. **Implement your Store** (See [Contracts](./docs/contracts.md)):
42
+
43
+ ```ts
44
+ import { Identity, IdentityStore } from "@open-core/identity";
45
+
46
+ class MyStore extends IdentityStore {
47
+ /* ... */
48
+ }
49
+
50
+ // Register it before installation
51
+ Identity.setIdentityStore(MyStore);
52
+ ```
53
+
54
+ 2. **Install the Plugin**:
55
+ ```ts
56
+ Identity.install({
57
+ auth: { mode: "local", autoCreate: true, primaryIdentifier: "license" },
58
+ principal: {
59
+ mode: "roles",
60
+ roles: {
61
+ admin: { name: "admin", rank: 100, permissions: ["*"] },
62
+ user: { name: "user", rank: 0, permissions: ["chat.use"] },
63
+ },
64
+ },
65
+ });
66
+ ```
67
+
68
+ ## Auth Strategies
69
+
70
+ All strategies are resolved through `AuthService`. Configure one mode and the framework
71
+ will inject the correct provider.
72
+
73
+ Quick summary:
74
+
75
+ - local: identifies by license/steam/discord, no form.
76
+ - credentials: username/password stored on your server.
77
+ - api: delegates to an external HTTP service.
78
+
79
+ ### Local (Identifiers)
80
+
81
+ What it is: authenticates using player identifiers (license/steam/discord).
82
+ Who it is for: servers that want automatic access without forms.
83
+
84
+ ```ts
85
+ Identity.install({
86
+ auth: {
87
+ mode: "local",
88
+ primaryIdentifier: "license",
89
+ autoCreate: true,
90
+ },
91
+ // ...
92
+ });
93
+ ```
94
+
95
+ ### Credentials (Username/Password)
96
+
97
+ What it is: login and registration with username/password stored on your server.
98
+ Who it is for: servers with custom UI or manual registration.
99
+
100
+ ```ts
101
+ Identity.install({
102
+ auth: {
103
+ mode: "credentials",
104
+ },
105
+ // ...
106
+ });
107
+ ```
108
+
109
+ ### API (External Service)
110
+
111
+ What it is: delegates all auth to an external HTTP service.
112
+ Who it is for: large networks with a centralized database or SSO.
113
+
114
+ ```ts
115
+ Identity.install({
116
+ auth: {
117
+ mode: "api",
118
+ primaryIdentifier: "license",
119
+ api: {
120
+ baseUrl: "https://auth.example.com",
121
+ authPath: "/auth",
122
+ registerPath: "/register",
123
+ sessionPath: "/session",
124
+ logoutPath: "/logout",
125
+ },
126
+ },
127
+ // ...
128
+ });
129
+ ```
130
+
131
+ ## Usage Example
132
+
133
+ ```ts
134
+ import { Server } from "@open-core/framework";
135
+ import { AuthService } from "@open-core/identity";
136
+
137
+ @Server.Controller()
138
+ export class AuthController {
139
+ constructor(private readonly auth: AuthService) {}
140
+
141
+ @Server.OnNet("auth:login")
142
+ async login(
143
+ player: Server.Player,
144
+ payload: { username: string; password: string },
145
+ ) {
146
+ return this.auth.authenticate(player, payload);
147
+ }
148
+
149
+ @Server.OnNet("auth:register")
150
+ async register(
151
+ player: Server.Player,
152
+ payload: { username: string; password: string },
153
+ ) {
154
+ return this.auth.register(player, payload);
155
+ }
156
+ }
157
+ ```
158
+
159
+ ## Exports
160
+
161
+ The library only exports high-level components to keep your IDE suggestions clean:
162
+
163
+ - `Identity`: The main namespace for installation and registration.
164
+ - `AccountService`, `RoleService`: Public services for business logic.
165
+ - `IdentityStore`, `RoleStore`: Abstract contracts for persistence.
166
+ - `IDENTITY_OPTIONS`: Token for advanced DI usage.
167
+ - All relevant types and interfaces.
168
+
169
+ ## License
170
+
171
+ MIT
@@ -0,0 +1,48 @@
1
+ import { Server } from "@open-core/framework/server";
2
+ import { IdentityAccount } from "./types";
3
+ /**
4
+ * Result structure for authentication operations.
5
+ */
6
+ export interface AuthResult {
7
+ /** Indicates if the operation was successful */
8
+ success: boolean;
9
+ /** The unique identifier for the authenticated account */
10
+ accountID?: string;
11
+ /** Error message if the operation failed */
12
+ error?: string;
13
+ /** Indicates if a new account was created during the process */
14
+ isNewAccount?: boolean;
15
+ /** Generic account Data type */
16
+ account?: IdentityAccount;
17
+ }
18
+ export declare abstract class AuthService {
19
+ /**
20
+ * Authenticates a player using the selected strategy.
21
+ *
22
+ * @param player - The framework player entity.
23
+ * @param credentials - Strategy-specific credentials.
24
+ * @returns A promise resolving to the authentication result.
25
+ */
26
+ abstract authenticate(player: Server.Player, credentials: Record<string, unknown>): Promise<AuthResult>;
27
+ /**
28
+ * Registers a new account for the player.
29
+ *
30
+ * @param player - The framework player entity.
31
+ * @param credentials - Strategy-specific registration data.
32
+ * @returns A promise resolving to the registration result.
33
+ */
34
+ abstract register(player: Server.Player, credentials: Record<string, unknown>): Promise<AuthResult>;
35
+ /**
36
+ * Validates if the player's current linked account session is still active.
37
+ *
38
+ * @param player - The framework player entity.
39
+ * @returns A promise resolving to the validation result.
40
+ */
41
+ abstract validateSession(player: Server.Player): Promise<AuthResult>;
42
+ /**
43
+ * Clears authentication state for the player.
44
+ *
45
+ * @param player - The framework player entity.
46
+ */
47
+ abstract logout(player: Server.Player): Promise<void>;
48
+ }
@@ -0,0 +1,2 @@
1
+ export class AuthService {
2
+ }
@@ -8,7 +8,7 @@ import type { IdentityAccount, IdentityRole } from "./types";
8
8
  *
9
9
  * @public
10
10
  */
11
- export declare abstract class IdentityStore {
11
+ export declare abstract class IdentityStore<TId = any, TLinkedId = any, TRoleId = any> {
12
12
  /**
13
13
  * Retrieves an account by its primary connection identifier.
14
14
  *
@@ -16,13 +16,20 @@ export declare abstract class IdentityStore {
16
16
  * @returns A promise resolving to the account or null if not found.
17
17
  */
18
18
  abstract findByIdentifier(identifier: string): Promise<IdentityAccount | null>;
19
+ /**
20
+ * Retrieves an account by its unique numeric or internal ID.
21
+ *
22
+ * @param id - The internal account identifier (database ID).
23
+ * @returns A promise resolving to the account or null if not found.
24
+ */
25
+ abstract findById(id: TId): Promise<IdentityAccount | null>;
19
26
  /**
20
27
  * Retrieves an account by its linked stable ID.
21
28
  *
22
29
  * @param linkedId - The stable ID (e.g., a UUID).
23
30
  * @returns A promise resolving to the account or null if not found.
24
31
  */
25
- abstract findByLinkedId(linkedId: string): Promise<IdentityAccount | null>;
32
+ abstract findByLinkedId(linkedId: TLinkedId): Promise<IdentityAccount | null>;
26
33
  /**
27
34
  * Retrieves an account by its unique username.
28
35
  *
@@ -30,6 +37,19 @@ export declare abstract class IdentityStore {
30
37
  * @returns A promise resolving to the account or null if not found.
31
38
  */
32
39
  abstract findByUsername(username: string): Promise<IdentityAccount | null>;
40
+ /**
41
+ * Retrieves all accounts that are currently banned.
42
+ *
43
+ * @returns A promise resolving to an array of banned accounts.
44
+ */
45
+ abstract findBanned(): Promise<IdentityAccount[]>;
46
+ /**
47
+ * Retrieves all accounts assigned to a specific role.
48
+ *
49
+ * @param roleId - The role identifier.
50
+ * @returns A promise resolving to an array of accounts.
51
+ */
52
+ abstract findByRole(roleId: TRoleId): Promise<IdentityAccount[]>;
33
53
  /**
34
54
  * Persists a new identity account.
35
55
  *
@@ -37,7 +57,7 @@ export declare abstract class IdentityStore {
37
57
  * @returns A promise resolving to the fully created account object.
38
58
  */
39
59
  abstract create(data: Omit<IdentityAccount, "id"> & {
40
- id?: string | number;
60
+ id?: TId;
41
61
  passwordHash?: string;
42
62
  }): Promise<IdentityAccount>;
43
63
  /**
@@ -46,7 +66,7 @@ export declare abstract class IdentityStore {
46
66
  * @param id - The internal account ID.
47
67
  * @param data - Partial object containing fields to update.
48
68
  */
49
- abstract update(id: string | number, data: Partial<Omit<IdentityAccount, "id">>): Promise<void>;
69
+ abstract update(id: TId, data: Partial<Omit<IdentityAccount, "id">>): Promise<void>;
50
70
  /**
51
71
  * Prohibits or allows an account from connecting.
52
72
  *
@@ -55,7 +75,7 @@ export declare abstract class IdentityStore {
55
75
  * @param reason - Optional explanation for the ban.
56
76
  * @param expiresAt - Optional expiration timestamp.
57
77
  */
58
- abstract setBan(id: string | number, banned: boolean, reason?: string, expiresAt?: Date | null): Promise<void>;
78
+ abstract setBan(id: TId, banned: boolean, reason?: string, expiresAt?: Date | null): Promise<void>;
59
79
  }
60
80
  /**
61
81
  * Persistence contract for security roles.
@@ -65,14 +85,35 @@ export declare abstract class IdentityStore {
65
85
  *
66
86
  * @public
67
87
  */
68
- export declare abstract class RoleStore {
88
+ export declare abstract class RoleStore<TId = any> {
69
89
  /**
70
90
  * Retrieves a role definition by its technical identifier.
71
91
  *
72
92
  * @param id - Technical identifier (e.g., 'admin' or 1).
73
93
  * @returns A promise resolving to the role or null if not found.
74
94
  */
75
- abstract findById(id: string | number): Promise<IdentityRole | null>;
95
+ abstract findById(id: TId): Promise<IdentityRole | null>;
96
+ abstract findByName(name: string): Promise<IdentityRole | null>;
97
+ /**
98
+ * Retrieves a role by its hierarchical rank.
99
+ *
100
+ * @param rank - The numeric rank to search for.
101
+ * @returns A promise resolving to the role or null if not found.
102
+ */
103
+ abstract findByRank(rank: number): Promise<IdentityRole | null>;
104
+ /**
105
+ * Retrieves all roles that grant a specific permission.
106
+ *
107
+ * @param permission - The permission string to search for.
108
+ * @returns A promise resolving to an array of roles.
109
+ */
110
+ abstract findByPermission(permission: string): Promise<IdentityRole[]>;
111
+ /**
112
+ * Retrieves all registered roles in the system.
113
+ *
114
+ * @returns A promise resolving to an array of all roles.
115
+ */
116
+ abstract findAll(): Promise<IdentityRole[]>;
76
117
  /**
77
118
  * Resolves the default role for newly connected accounts.
78
119
  *
@@ -86,7 +127,7 @@ export declare abstract class RoleStore {
86
127
  * @returns A promise resolving to the fully created role object.
87
128
  */
88
129
  abstract create(role: Omit<IdentityRole, "id"> & {
89
- id?: string | number;
130
+ id?: TId;
90
131
  }): Promise<IdentityRole>;
91
132
  /**
92
133
  * Updates an existing role definition.
@@ -94,11 +135,11 @@ export declare abstract class RoleStore {
94
135
  * @param id - Technical identifier of the role to update.
95
136
  * @param role - Partial role object containing the fields to modify.
96
137
  */
97
- abstract update(id: string | number, role: Partial<Omit<IdentityRole, "id">>): Promise<void>;
138
+ abstract update(id: TId, role: Partial<Omit<IdentityRole, "id">>): Promise<void>;
98
139
  /**
99
140
  * Removes a role from the system.
100
141
  *
101
142
  * @param id - Technical identifier of the role to delete.
102
143
  */
103
- abstract delete(id: string | number): Promise<void>;
144
+ abstract delete(id: TId): Promise<void>;
104
145
  }
package/dist/index.d.ts CHANGED
@@ -37,8 +37,8 @@ export declare namespace Identity {
37
37
  /**
38
38
  * Installs the Identity plugin into the OpenCore Framework.
39
39
  *
40
- * This function registers the necessary Authentication and Principal providers
41
- * into the framework's SPI via `Server.setAuthProvider` and `Server.setPrincipalProvider`.
40
+ * This function registers the necessary Authentication service and Principal provider
41
+ * into the framework's SPI via dependency injection and `Server.setPrincipalProvider`.
42
42
  *
43
43
  * @param options - Configuration options for the identity system.
44
44
  *
package/dist/index.js CHANGED
@@ -1,8 +1,9 @@
1
- import { Server } from "@open-core/framework";
1
+ import { Server } from "@open-core/framework/server";
2
2
  import { IDENTITY_OPTIONS } from "./tokens";
3
3
  import { LocalAuthProvider as LocalAuthImpl } from "./providers/auth/local-auth.provider";
4
4
  import { CredentialsAuthProvider as CredentialsAuthImpl } from "./providers/auth/credentials-auth.provider";
5
5
  import { ApiAuthProvider as ApiAuthImpl } from "./providers/auth/api-auth.provider";
6
+ import { AuthService } from "./auth.service";
6
7
  import { IdentityPrincipalProvider as PrincipalProviderImpl } from "./providers/principal/local-principal.provider";
7
8
  import { ApiPrincipalProvider as ApiPrincipalImpl } from "./providers/principal/api-principal.provider";
8
9
  import { AccountService as AccountServiceImpl } from "./services/account.service";
@@ -28,7 +29,10 @@ export var Identity;
28
29
  const container = globalThis.oc_container;
29
30
  if (!container)
30
31
  throwContainerError();
32
+ // Unregister existing if any and register new singleton
33
+ container.unregister(IdentityStoreContract);
31
34
  container.registerSingleton(IdentityStoreContract, store);
35
+ console.log(`[OpenCore-Identity] IdentityStore registered: ${store.name}`);
32
36
  }
33
37
  Identity.setIdentityStore = setIdentityStore;
34
38
  /**
@@ -41,18 +45,20 @@ export var Identity;
41
45
  const container = globalThis.oc_container;
42
46
  if (!container)
43
47
  throwContainerError();
48
+ container.unregister(RoleStoreContract);
44
49
  container.registerSingleton(RoleStoreContract, store);
50
+ console.log(`[OpenCore-Identity] RoleStore registered: ${store.name}`);
45
51
  }
46
52
  Identity.setRoleStore = setRoleStore;
47
53
  function throwContainerError() {
48
54
  throw new Error("[OpenCore-Identity] Global container (globalThis.oc_container) not found. " +
49
- "Ensure the framework is initialized before installing plugins.");
55
+ "Ensure the framework is installed.");
50
56
  }
51
57
  /**
52
58
  * Installs the Identity plugin into the OpenCore Framework.
53
59
  *
54
- * This function registers the necessary Authentication and Principal providers
55
- * into the framework's SPI via `Server.setAuthProvider` and `Server.setPrincipalProvider`.
60
+ * This function registers the necessary Authentication service and Principal provider
61
+ * into the framework's SPI via dependency injection and `Server.setPrincipalProvider`.
56
62
  *
57
63
  * @param options - Configuration options for the identity system.
58
64
  *
@@ -80,23 +86,76 @@ export var Identity;
80
86
  // Register Internal Services (concrete classes as tokens)
81
87
  container.registerSingleton(AccountServiceImpl);
82
88
  container.registerSingleton(RoleServiceImpl);
83
- // Configure Auth SPI based on mode
89
+ // Configure Auth Service based on mode
84
90
  if (options.auth.mode === "api") {
85
- Server.setAuthProvider(ApiAuthImpl);
91
+ if (!options.auth.api?.baseUrl) {
92
+ throw new Error("[OpenCore-Identity] In 'api' auth mode, 'auth.api.baseUrl' is required.");
93
+ }
94
+ container.registerSingleton(AuthService, ApiAuthImpl);
86
95
  }
87
96
  else if (options.auth.mode === "credentials") {
88
- Server.setAuthProvider(CredentialsAuthImpl);
97
+ container.registerSingleton(AuthService, CredentialsAuthImpl);
89
98
  }
90
99
  else {
91
- Server.setAuthProvider(LocalAuthImpl);
100
+ container.registerSingleton(AuthService, LocalAuthImpl);
92
101
  }
93
102
  // Configure Principal SPI based on mode
94
103
  if (options.principal.mode === "api") {
104
+ if (!options.principal.api?.baseUrl) {
105
+ throw new Error("[OpenCore-Identity] In 'api' principal mode, 'principal.api.baseUrl' is required.");
106
+ }
95
107
  Server.setPrincipalProvider(ApiPrincipalImpl);
108
+ if (options.principal.defaultRole && typeof options.principal.defaultRole !== "string") {
109
+ throw new Error("[OpenCore-Identity] In 'api' principal mode, 'defaultRole' must be a string (the ID returned by the API).");
110
+ }
96
111
  }
97
112
  else {
98
113
  Server.setPrincipalProvider(PrincipalProviderImpl);
114
+ // Handle default role auto-creation or validation
115
+ const defaultRole = options.principal.defaultRole;
116
+ if (typeof defaultRole === "object") {
117
+ const roles = options.principal.roles || {};
118
+ const defaultId = "default_auto";
119
+ // Inject the role into the configuration if it doesn't exist
120
+ if (!roles[defaultId]) {
121
+ options.principal.roles = {
122
+ ...roles,
123
+ [defaultId]: { ...defaultRole, id: defaultId },
124
+ };
125
+ options.principal.defaultRole = defaultId;
126
+ console.log(`[OpenCore-Identity] Default role '${defaultId}' created from configuration.`);
127
+ }
128
+ }
99
129
  }
130
+ // Handle onReady and waitFor
131
+ const runInitialization = async () => {
132
+ // 1. Wait for dependencies if specified
133
+ if (options.hooks?.waitFor) {
134
+ const waits = Array.isArray(options.hooks.waitFor)
135
+ ? options.hooks.waitFor
136
+ : [options.hooks.waitFor];
137
+ try {
138
+ await Promise.all(waits);
139
+ }
140
+ catch (err) {
141
+ console.error("[OpenCore-Identity] Error waiting for dependencies in 'waitFor':", err);
142
+ return;
143
+ }
144
+ }
145
+ // 2. Execute onReady hook
146
+ if (options.hooks?.onReady) {
147
+ const accountService = container.resolve(AccountServiceImpl);
148
+ const roleService = container.resolve(RoleServiceImpl);
149
+ try {
150
+ await options.hooks.onReady({ accounts: accountService, roles: roleService, container });
151
+ }
152
+ catch (err) {
153
+ console.error("[OpenCore-Identity] Error in onReady hook:", err);
154
+ }
155
+ }
156
+ };
157
+ // Execute the async flow without blocking the main install call
158
+ runInitialization();
100
159
  }
101
160
  Identity.install = install;
102
161
  })(Identity || (Identity = {}));
@@ -1,25 +1,23 @@
1
- import { Server } from "@open-core/framework";
1
+ import { Server } from "@open-core/framework/server";
2
2
  import type { IdentityOptions } from "../../types";
3
+ import { AuthResult, AuthService } from "../../auth.service";
3
4
  /**
4
5
  * Authentication provider that delegates logic to an external HTTP API.
5
6
  *
6
- * This provider implements the framework's {@link Server.AuthProviderContract} by
7
- * performing network requests to a remote authentication service. It is suitable
8
- * for environments with a centralized user database or SSO.
7
+ * This provider performs HTTP requests to a remote authentication service.
8
+ * It is suitable for environments with a centralized user database or SSO.
9
9
  *
10
10
  * @injectable
11
11
  * @public
12
12
  */
13
- export declare class ApiAuthProvider extends Server.AuthProviderContract {
13
+ export declare class ApiAuthProvider extends AuthService {
14
14
  private readonly options;
15
- private readonly http;
16
15
  /**
17
16
  * Initializes a new instance of the ApiAuthProvider.
18
17
  *
19
18
  * @param options - Identity system configuration options.
20
- * @param http - Framework HTTP service for remote communication.
21
19
  */
22
- constructor(options: IdentityOptions, http: Server.HttpService);
20
+ constructor(options: IdentityOptions);
23
21
  /**
24
22
  * Authenticates a player by sending credentials to the external API.
25
23
  *
@@ -27,7 +25,7 @@ export declare class ApiAuthProvider extends Server.AuthProviderContract {
27
25
  * @param credentials - Authentication data (e.g., tokens, external IDs).
28
26
  * @returns A promise resolving to the remote authentication result.
29
27
  */
30
- authenticate(player: Server.Player, credentials: Record<string, unknown>): Promise<Server.AuthResult>;
28
+ authenticate(player: Server.Player, credentials: Record<string, unknown>): Promise<AuthResult>;
31
29
  /**
32
30
  * Registers a player identity via the external API.
33
31
  *
@@ -35,18 +33,21 @@ export declare class ApiAuthProvider extends Server.AuthProviderContract {
35
33
  * @param credentials - Registration data.
36
34
  * @returns A promise resolving to the remote registration result.
37
35
  */
38
- register(player: Server.Player, credentials: Record<string, unknown>): Promise<Server.AuthResult>;
36
+ register(player: Server.Player, credentials: Record<string, unknown>): Promise<AuthResult>;
39
37
  /**
40
38
  * Validates the player's remote session.
41
39
  *
42
40
  * @param player - The framework player entity.
43
41
  * @returns A promise resolving to the remote session validation result.
44
42
  */
45
- validateSession(player: Server.Player): Promise<Server.AuthResult>;
43
+ validateSession(player: Server.Player): Promise<AuthResult>;
46
44
  /**
47
45
  * Notifies the external API that the player has logged out.
48
46
  *
49
47
  * @param player - The framework player entity.
50
48
  */
51
49
  logout(player: Server.Player): Promise<void>;
50
+ private requestAuth;
51
+ private resolveUrl;
52
+ private getAbortSignal;
52
53
  }