@temboplus/afloat 0.1.1 → 0.1.3
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/esm/_dnt.shims.d.ts +6 -0
- package/esm/_dnt.shims.d.ts.map +1 -0
- package/esm/_dnt.shims.js +61 -0
- package/esm/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/almost_equals.d.ts.map +1 -1
- package/{script/deps/jsr.io/@std/assert/1.0.10 → esm/deps/jsr.io/@std/assert/1.0.11}/array_includes.d.ts.map +1 -1
- package/{script/deps/jsr.io/@std/assert/1.0.10 → esm/deps/jsr.io/@std/assert/1.0.11}/assert.d.ts.map +1 -1
- package/{script/deps/jsr.io/@std/assert/1.0.10 → esm/deps/jsr.io/@std/assert/1.0.11}/assertion_error.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/equal.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/equals.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/exists.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/fail.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/false.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/greater.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/greater_or_equal.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/instance_of.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/is_error.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/less.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/less_or_equal.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/match.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/mod.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/not_equals.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/not_instance_of.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/not_match.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/not_strict_equals.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/object_match.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/rejects.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/strict_equals.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/string_includes.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/throws.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/unimplemented.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/unreachable.d.ts.map +1 -1
- package/esm/src/features/auth/contract.d.ts +14 -25
- package/esm/src/features/auth/contract.d.ts.map +1 -1
- package/esm/src/features/auth/contract.js +8 -15
- package/esm/src/features/auth/identity/contract.d.ts +30 -0
- package/esm/src/features/auth/identity/contract.d.ts.map +1 -0
- package/esm/src/features/auth/identity/contract.js +18 -0
- package/esm/src/features/auth/identity/repository.d.ts +22 -0
- package/esm/src/features/auth/identity/repository.d.ts.map +1 -0
- package/esm/src/features/auth/identity/repository.js +30 -0
- package/esm/src/features/auth/manager.d.ts +50 -27
- package/esm/src/features/auth/manager.d.ts.map +1 -1
- package/esm/src/features/auth/manager.js +105 -58
- package/esm/src/features/auth/profile/contract.d.ts +45 -0
- package/esm/src/features/auth/profile/contract.d.ts.map +1 -0
- package/esm/src/features/auth/profile/contract.js +16 -0
- package/esm/src/features/auth/profile/repository.d.ts +11 -0
- package/esm/src/features/auth/profile/repository.d.ts.map +1 -0
- package/esm/src/features/auth/profile/repository.js +21 -0
- package/esm/src/features/auth/repository.d.ts +1 -0
- package/esm/src/features/auth/repository.d.ts.map +1 -1
- package/esm/src/features/auth/repository.js +5 -22
- package/esm/src/features/auth/storage/client_store.d.ts +30 -0
- package/esm/src/features/auth/storage/client_store.d.ts.map +1 -0
- package/esm/src/features/auth/storage/client_store.js +46 -0
- package/esm/src/features/auth/storage/client_token_handler.d.ts +32 -0
- package/esm/src/features/auth/storage/client_token_handler.d.ts.map +1 -0
- package/esm/src/features/auth/storage/client_token_handler.js +36 -0
- package/esm/src/features/auth/storage/server_store.d.ts +24 -0
- package/esm/src/features/auth/storage/server_store.d.ts.map +1 -0
- package/esm/src/features/auth/storage/server_store.js +34 -0
- package/esm/src/features/auth/storage/server_token_handler.d.ts +35 -0
- package/esm/src/features/auth/storage/server_token_handler.d.ts.map +1 -0
- package/esm/src/features/auth/storage/server_token_handler.js +68 -0
- package/esm/src/features/auth/storage/types.d.ts +42 -0
- package/esm/src/features/auth/storage/types.d.ts.map +1 -0
- package/esm/src/features/auth/storage/types.js +1 -0
- package/esm/src/models/contact/derivatives/contact.d.ts +4 -0
- package/esm/src/models/contact/derivatives/contact.d.ts.map +1 -1
- package/esm/src/models/contact/derivatives/contact.js +6 -0
- package/package.json +4 -4
- package/script/_dnt.shims.d.ts +6 -0
- package/script/_dnt.shims.d.ts.map +1 -0
- package/script/_dnt.shims.js +65 -0
- package/script/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/almost_equals.d.ts.map +1 -1
- package/{esm/deps/jsr.io/@std/assert/1.0.10 → script/deps/jsr.io/@std/assert/1.0.11}/array_includes.d.ts.map +1 -1
- package/{esm/deps/jsr.io/@std/assert/1.0.10 → script/deps/jsr.io/@std/assert/1.0.11}/assert.d.ts.map +1 -1
- package/{esm/deps/jsr.io/@std/assert/1.0.10 → script/deps/jsr.io/@std/assert/1.0.11}/assertion_error.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/equal.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/equals.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/exists.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/fail.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/false.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/greater.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/greater_or_equal.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/instance_of.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/is_error.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/less.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/less_or_equal.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/match.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/mod.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/not_equals.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/not_instance_of.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/not_match.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/not_strict_equals.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/object_match.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/rejects.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/strict_equals.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/string_includes.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/throws.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/unimplemented.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.10 → 1.0.11}/unreachable.d.ts.map +1 -1
- package/script/src/features/auth/contract.d.ts +14 -25
- package/script/src/features/auth/contract.d.ts.map +1 -1
- package/script/src/features/auth/contract.js +9 -16
- package/script/src/features/auth/identity/contract.d.ts +30 -0
- package/script/src/features/auth/identity/contract.d.ts.map +1 -0
- package/script/src/features/auth/identity/contract.js +21 -0
- package/script/src/features/auth/identity/repository.d.ts +22 -0
- package/script/src/features/auth/identity/repository.d.ts.map +1 -0
- package/script/src/features/auth/identity/repository.js +34 -0
- package/script/src/features/auth/manager.d.ts +50 -27
- package/script/src/features/auth/manager.d.ts.map +1 -1
- package/script/src/features/auth/manager.js +128 -58
- package/script/src/features/auth/profile/contract.d.ts +45 -0
- package/script/src/features/auth/profile/contract.d.ts.map +1 -0
- package/script/src/features/auth/profile/contract.js +19 -0
- package/script/src/features/auth/profile/repository.d.ts +11 -0
- package/script/src/features/auth/profile/repository.d.ts.map +1 -0
- package/script/src/features/auth/profile/repository.js +25 -0
- package/script/src/features/auth/repository.d.ts +1 -0
- package/script/src/features/auth/repository.d.ts.map +1 -1
- package/script/src/features/auth/repository.js +6 -23
- package/script/src/features/auth/storage/client_store.d.ts +30 -0
- package/script/src/features/auth/storage/client_store.d.ts.map +1 -0
- package/script/src/features/auth/storage/client_store.js +51 -0
- package/script/src/features/auth/storage/client_token_handler.d.ts +32 -0
- package/script/src/features/auth/storage/client_token_handler.d.ts.map +1 -0
- package/script/src/features/auth/storage/client_token_handler.js +40 -0
- package/script/src/features/auth/storage/server_store.d.ts +24 -0
- package/script/src/features/auth/storage/server_store.d.ts.map +1 -0
- package/script/src/features/auth/storage/server_store.js +38 -0
- package/script/src/features/auth/storage/server_token_handler.d.ts +35 -0
- package/script/src/features/auth/storage/server_token_handler.d.ts.map +1 -0
- package/script/src/features/auth/storage/server_token_handler.js +72 -0
- package/script/src/features/auth/storage/types.d.ts +42 -0
- package/script/src/features/auth/storage/types.d.ts.map +1 -0
- package/script/src/features/auth/storage/types.js +2 -0
- package/script/src/models/contact/derivatives/contact.d.ts +4 -0
- package/script/src/models/contact/derivatives/contact.d.ts.map +1 -1
- package/script/src/models/contact/derivatives/contact.js +6 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LoginRepository = void 0;
|
|
4
|
+
const api_error_js_1 = require("../../../errors/api_error.js");
|
|
5
|
+
const index_js_1 = require("../../../shared/index.js");
|
|
6
|
+
const contract_js_1 = require("./contract.js");
|
|
7
|
+
/**
|
|
8
|
+
* Class representing the LoginRepository.
|
|
9
|
+
* Provides methods to retrieve user identity-related information.
|
|
10
|
+
*/
|
|
11
|
+
class LoginRepository extends index_js_1.BaseRepository {
|
|
12
|
+
/**
|
|
13
|
+
* Initializes an instance of LoginRepository.
|
|
14
|
+
*/
|
|
15
|
+
constructor() {
|
|
16
|
+
super("login", contract_js_1.identityContract);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Retrieves the user's login credentials.
|
|
20
|
+
* @returns A promise that resolves to the user's login credentials on success.
|
|
21
|
+
* @throws {APIError} If an error occurs while retrieving the credentials.
|
|
22
|
+
*/
|
|
23
|
+
async getIdentity(token) {
|
|
24
|
+
const headers = { token };
|
|
25
|
+
const result = await this.client.getUserCredentials({ headers });
|
|
26
|
+
if (result.status === 200)
|
|
27
|
+
return result.body;
|
|
28
|
+
throw new api_error_js_1.APIError({
|
|
29
|
+
message: "An error occurred while trying to get login credentials",
|
|
30
|
+
statusCode: 502,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.LoginRepository = LoginRepository;
|
|
@@ -1,69 +1,92 @@
|
|
|
1
|
-
import { User } from "../../models/index.js";
|
|
1
|
+
import type { User } from "../../models/index.js";
|
|
2
2
|
import type { Permission } from "../../models/permission.js";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Main authentication class that works in both client and server environments.
|
|
5
|
+
* Provides authentication functionality and user management.
|
|
5
6
|
*/
|
|
6
7
|
export declare class AfloatAuth {
|
|
8
|
+
/** Singleton instance */
|
|
7
9
|
private static _instance;
|
|
10
|
+
/** The auth store implementation */
|
|
11
|
+
private store;
|
|
12
|
+
/** The token handler implementation */
|
|
13
|
+
private tokenHandler;
|
|
8
14
|
/**
|
|
9
15
|
* Private constructor to prevent direct instantiation.
|
|
16
|
+
* @param {AuthStore} store - The auth store implementation to use
|
|
17
|
+
* @param {TokenHandler} tokenHandler - The token handler implementation to use
|
|
10
18
|
*/
|
|
11
19
|
private constructor();
|
|
20
|
+
/**
|
|
21
|
+
* Initializes AfloatAuth for client-side use.
|
|
22
|
+
* This should be called once at application startup in client environments.
|
|
23
|
+
* @returns {AfloatAuth} The singleton instance configured for client-side
|
|
24
|
+
*/
|
|
25
|
+
static initializeClient(): AfloatAuth;
|
|
26
|
+
/**
|
|
27
|
+
* Creates a new instance of AfloatAuth configured for server-side use.
|
|
28
|
+
* Initializes the user by fetching necessary data using the provided token.
|
|
29
|
+
* @param {string} token - Authentication token
|
|
30
|
+
* @returns {Promise<AfloatAuth>} A new instance configured for server-side
|
|
31
|
+
* @throws {Error} If token is invalid or required data cannot be fetched
|
|
32
|
+
*/
|
|
33
|
+
static initializeServer(token: string): Promise<AfloatAuth>;
|
|
12
34
|
/**
|
|
13
35
|
* Gets the singleton instance of AfloatAuth.
|
|
14
|
-
* @
|
|
36
|
+
* @throws {Error} If AfloatAuth hasn't been initialized
|
|
37
|
+
* @returns {AfloatAuth} The singleton instance
|
|
15
38
|
*/
|
|
16
39
|
static get instance(): AfloatAuth;
|
|
17
40
|
/**
|
|
18
|
-
*
|
|
41
|
+
* Gets the authentication repository instance.
|
|
19
42
|
* @private
|
|
20
|
-
* @returns {AuthRepository} The repository
|
|
43
|
+
* @returns {AuthRepository} The repository for auth operations
|
|
21
44
|
*/
|
|
22
45
|
private get repo();
|
|
23
46
|
/**
|
|
24
|
-
*
|
|
25
|
-
* @returns {string | undefined} The token
|
|
47
|
+
* Gets the current authentication token.
|
|
48
|
+
* @returns {string | undefined} The current token or undefined if not authenticated
|
|
26
49
|
*/
|
|
27
50
|
getUserToken(): string | undefined;
|
|
28
51
|
/**
|
|
29
|
-
* Gets the currently
|
|
30
|
-
* @returns {User | undefined} The current user
|
|
52
|
+
* Gets the currently authenticated user.
|
|
53
|
+
* @returns {User | undefined} The current user or undefined if not authenticated
|
|
31
54
|
*/
|
|
32
55
|
get currentUser(): User | undefined;
|
|
33
56
|
/**
|
|
34
|
-
* React hook
|
|
35
|
-
*
|
|
36
|
-
* @returns {User | undefined} The current user
|
|
57
|
+
* React hook for accessing the current user in client-side code.
|
|
58
|
+
* @throws {Error} If called in a server environment
|
|
59
|
+
* @returns {User | undefined} The current user or undefined if not authenticated
|
|
37
60
|
*/
|
|
38
61
|
useCurrentUser(): User | undefined;
|
|
39
62
|
/**
|
|
40
|
-
* Checks if the current user has
|
|
41
|
-
* @param {Permission} perm - The permission to check
|
|
42
|
-
* @returns {boolean}
|
|
63
|
+
* Checks if the current user has a specific permission.
|
|
64
|
+
* @param {Permission} perm - The permission to check
|
|
65
|
+
* @returns {boolean} True if the user has the permission, false otherwise
|
|
43
66
|
*/
|
|
44
67
|
checkPermission(perm: Permission): boolean;
|
|
45
68
|
/**
|
|
46
|
-
*
|
|
47
|
-
* @param {string} email - The user's email
|
|
48
|
-
* @param {string} password - The user's password
|
|
49
|
-
* @returns {Promise<User>}
|
|
50
|
-
* @throws Will throw an error if authentication fails
|
|
69
|
+
* Authenticates a user with email and password.
|
|
70
|
+
* @param {string} email - The user's email
|
|
71
|
+
* @param {string} password - The user's password
|
|
72
|
+
* @returns {Promise<User>} Promise resolving to the authenticated user
|
|
73
|
+
* @throws Will throw an error if authentication fails
|
|
51
74
|
*/
|
|
52
75
|
logIn(email: string, password: string): Promise<User>;
|
|
53
76
|
/**
|
|
54
|
-
*
|
|
55
|
-
* @param {string} current - The current password
|
|
56
|
-
* @param {string} updated - The new password
|
|
57
|
-
* @returns {Promise<boolean>}
|
|
58
|
-
* @throws Will throw an error if the
|
|
77
|
+
* Updates the user's password.
|
|
78
|
+
* @param {string} current - The current password
|
|
79
|
+
* @param {string} updated - The new password
|
|
80
|
+
* @returns {Promise<boolean>} Promise resolving to true if successful
|
|
81
|
+
* @throws Will throw an error if the password update fails
|
|
59
82
|
*/
|
|
60
83
|
resetPassword(current: string, updated: string): Promise<boolean>;
|
|
61
84
|
/**
|
|
62
|
-
* Logs out the current user
|
|
85
|
+
* Logs out the current user.
|
|
63
86
|
*/
|
|
64
87
|
logOut(): void;
|
|
65
88
|
/**
|
|
66
|
-
* Clears
|
|
89
|
+
* Clears all authentication data.
|
|
67
90
|
* @private
|
|
68
91
|
*/
|
|
69
92
|
private clearSavedData;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../../src/src/features/auth/manager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../../src/src/features/auth/manager.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAU7D;;;GAGG;AACH,qBAAa,UAAU;IACrB,yBAAyB;IACzB,OAAO,CAAC,MAAM,CAAC,SAAS,CAAa;IAErC,oCAAoC;IACpC,OAAO,CAAC,KAAK,CAAY;IAEzB,uCAAuC;IACvC,OAAO,CAAC,YAAY,CAAe;IAEnC;;;;OAIG;IACH,OAAO;IAKP;;;;OAIG;WACW,gBAAgB,IAAI,UAAU;IAU5C;;;;;;OAMG;WACiB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAwBxE;;;;OAIG;IACH,WAAkB,QAAQ,IAAI,UAAU,CAOvC;IAED;;;;OAIG;IACH,OAAO,KAAK,IAAI,GAEf;IAED;;;OAGG;IACH,YAAY,IAAI,MAAM,GAAG,SAAS;IAIlC;;;OAGG;IACH,IAAI,WAAW,IAAI,IAAI,GAAG,SAAS,CAElC;IAED;;;;OAIG;IACH,cAAc,IAAI,IAAI,GAAG,SAAS;IASlC;;;;OAIG;IACH,eAAe,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO;IAI1C;;;;;;OAMG;IACG,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ3D;;;;;;OAMG;IACG,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAMvE;;OAEG;IACH,MAAM,IAAI,IAAI;IAId;;;OAGG;IACH,OAAO,CAAC,cAAc;CAIvB"}
|
|
@@ -1,83 +1,173 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.AfloatAuth = void 0;
|
|
4
|
-
const
|
|
5
|
-
const middleware_1 = require("zustand/middleware");
|
|
27
|
+
const dntShim = __importStar(require("../../../_dnt.shims.js"));
|
|
6
28
|
const repository_js_1 = require("./repository.js");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
29
|
+
const client_store_js_1 = require("./storage/client_store.js");
|
|
30
|
+
const client_token_handler_js_1 = require("./storage/client_token_handler.js");
|
|
31
|
+
const server_store_js_1 = require("./storage/server_store.js");
|
|
32
|
+
const server_token_handler_js_1 = require("./storage/server_token_handler.js");
|
|
9
33
|
/**
|
|
10
|
-
*
|
|
34
|
+
* Main authentication class that works in both client and server environments.
|
|
35
|
+
* Provides authentication functionality and user management.
|
|
11
36
|
*/
|
|
12
37
|
class AfloatAuth {
|
|
13
38
|
/**
|
|
14
39
|
* Private constructor to prevent direct instantiation.
|
|
40
|
+
* @param {AuthStore} store - The auth store implementation to use
|
|
41
|
+
* @param {TokenHandler} tokenHandler - The token handler implementation to use
|
|
42
|
+
*/
|
|
43
|
+
constructor(store, tokenHandler) {
|
|
44
|
+
/** The auth store implementation */
|
|
45
|
+
Object.defineProperty(this, "store", {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
configurable: true,
|
|
48
|
+
writable: true,
|
|
49
|
+
value: void 0
|
|
50
|
+
});
|
|
51
|
+
/** The token handler implementation */
|
|
52
|
+
Object.defineProperty(this, "tokenHandler", {
|
|
53
|
+
enumerable: true,
|
|
54
|
+
configurable: true,
|
|
55
|
+
writable: true,
|
|
56
|
+
value: void 0
|
|
57
|
+
});
|
|
58
|
+
this.store = store;
|
|
59
|
+
this.tokenHandler = tokenHandler;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Initializes AfloatAuth for client-side use.
|
|
63
|
+
* This should be called once at application startup in client environments.
|
|
64
|
+
* @returns {AfloatAuth} The singleton instance configured for client-side
|
|
15
65
|
*/
|
|
16
|
-
|
|
66
|
+
static initializeClient() {
|
|
67
|
+
if (!this._instance) {
|
|
68
|
+
this._instance = new AfloatAuth((0, client_store_js_1.createClientStore)(), client_token_handler_js_1.ClientTokenHandler.instance);
|
|
69
|
+
}
|
|
70
|
+
return this._instance;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Creates a new instance of AfloatAuth configured for server-side use.
|
|
74
|
+
* Initializes the user by fetching necessary data using the provided token.
|
|
75
|
+
* @param {string} token - Authentication token
|
|
76
|
+
* @returns {Promise<AfloatAuth>} A new instance configured for server-side
|
|
77
|
+
* @throws {Error} If token is invalid or required data cannot be fetched
|
|
78
|
+
*/
|
|
79
|
+
static async initializeServer(token) {
|
|
80
|
+
if (!token) {
|
|
81
|
+
throw new Error("Token is required for server initialization");
|
|
82
|
+
}
|
|
83
|
+
const tokenHandler = new server_token_handler_js_1.ServerTokenHandler(token);
|
|
84
|
+
const store = new server_store_js_1.ServerStore();
|
|
85
|
+
try {
|
|
86
|
+
// Fetch and construct user data
|
|
87
|
+
const user = await tokenHandler.constructUser();
|
|
88
|
+
store.setUser(user);
|
|
89
|
+
// Create and initialize auth instance
|
|
90
|
+
return new AfloatAuth(store, tokenHandler);
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
if (error instanceof Error) {
|
|
94
|
+
throw new Error(`Failed to initialize server auth: ${error.message}`);
|
|
95
|
+
}
|
|
96
|
+
throw new Error("Failed to initialize server auth");
|
|
97
|
+
}
|
|
98
|
+
}
|
|
17
99
|
/**
|
|
18
100
|
* Gets the singleton instance of AfloatAuth.
|
|
19
|
-
* @
|
|
101
|
+
* @throws {Error} If AfloatAuth hasn't been initialized
|
|
102
|
+
* @returns {AfloatAuth} The singleton instance
|
|
20
103
|
*/
|
|
21
104
|
static get instance() {
|
|
22
|
-
|
|
105
|
+
if (!this._instance) {
|
|
106
|
+
throw new Error("AfloatAuth not initialized. Call initializeClient() or initializeServer() first");
|
|
107
|
+
}
|
|
108
|
+
return this._instance;
|
|
23
109
|
}
|
|
24
110
|
/**
|
|
25
|
-
*
|
|
111
|
+
* Gets the authentication repository instance.
|
|
26
112
|
* @private
|
|
27
|
-
* @returns {AuthRepository} The repository
|
|
113
|
+
* @returns {AuthRepository} The repository for auth operations
|
|
28
114
|
*/
|
|
29
115
|
get repo() {
|
|
30
116
|
return new repository_js_1.AuthRepository();
|
|
31
117
|
}
|
|
32
118
|
/**
|
|
33
|
-
*
|
|
34
|
-
* @returns {string | undefined} The token
|
|
119
|
+
* Gets the current authentication token.
|
|
120
|
+
* @returns {string | undefined} The current token or undefined if not authenticated
|
|
35
121
|
*/
|
|
36
122
|
getUserToken() {
|
|
37
|
-
return this.
|
|
123
|
+
return this.tokenHandler.getUserToken();
|
|
38
124
|
}
|
|
39
125
|
/**
|
|
40
|
-
* Gets the currently
|
|
41
|
-
* @returns {User | undefined} The current user
|
|
126
|
+
* Gets the currently authenticated user.
|
|
127
|
+
* @returns {User | undefined} The current user or undefined if not authenticated
|
|
42
128
|
*/
|
|
43
129
|
get currentUser() {
|
|
44
|
-
return store.
|
|
130
|
+
return this.store.getUser();
|
|
45
131
|
}
|
|
46
132
|
/**
|
|
47
|
-
* React hook
|
|
48
|
-
*
|
|
49
|
-
* @returns {User | undefined} The current user
|
|
133
|
+
* React hook for accessing the current user in client-side code.
|
|
134
|
+
* @throws {Error} If called in a server environment
|
|
135
|
+
* @returns {User | undefined} The current user or undefined if not authenticated
|
|
50
136
|
*/
|
|
51
137
|
useCurrentUser() {
|
|
52
|
-
|
|
138
|
+
if (typeof dntShim.dntGlobalThis === "undefined") {
|
|
139
|
+
throw new Error("useCurrentUser can only be called in browser environment");
|
|
140
|
+
}
|
|
141
|
+
return (0, client_store_js_1.useClientUser)();
|
|
53
142
|
}
|
|
54
143
|
/**
|
|
55
|
-
* Checks if the current user has
|
|
56
|
-
* @param {Permission} perm - The permission to check
|
|
57
|
-
* @returns {boolean}
|
|
144
|
+
* Checks if the current user has a specific permission.
|
|
145
|
+
* @param {Permission} perm - The permission to check
|
|
146
|
+
* @returns {boolean} True if the user has the permission, false otherwise
|
|
58
147
|
*/
|
|
59
148
|
checkPermission(perm) {
|
|
60
149
|
return this.currentUser?.can(perm) ?? false;
|
|
61
150
|
}
|
|
62
151
|
/**
|
|
63
|
-
*
|
|
64
|
-
* @param {string} email - The user's email
|
|
65
|
-
* @param {string} password - The user's password
|
|
66
|
-
* @returns {Promise<User>}
|
|
67
|
-
* @throws Will throw an error if authentication fails
|
|
152
|
+
* Authenticates a user with email and password.
|
|
153
|
+
* @param {string} email - The user's email
|
|
154
|
+
* @param {string} password - The user's password
|
|
155
|
+
* @returns {Promise<User>} Promise resolving to the authenticated user
|
|
156
|
+
* @throws Will throw an error if authentication fails
|
|
68
157
|
*/
|
|
69
158
|
async logIn(email, password) {
|
|
70
159
|
const user = await this.repo.logIn(email, password);
|
|
71
160
|
this.clearSavedData();
|
|
72
|
-
store.
|
|
161
|
+
this.store.setUser(user);
|
|
162
|
+
this.tokenHandler.setUserToken(user.token);
|
|
73
163
|
return user;
|
|
74
164
|
}
|
|
75
165
|
/**
|
|
76
|
-
*
|
|
77
|
-
* @param {string} current - The current password
|
|
78
|
-
* @param {string} updated - The new password
|
|
79
|
-
* @returns {Promise<boolean>}
|
|
80
|
-
* @throws Will throw an error if the
|
|
166
|
+
* Updates the user's password.
|
|
167
|
+
* @param {string} current - The current password
|
|
168
|
+
* @param {string} updated - The new password
|
|
169
|
+
* @returns {Promise<boolean>} Promise resolving to true if successful
|
|
170
|
+
* @throws Will throw an error if the password update fails
|
|
81
171
|
*/
|
|
82
172
|
async resetPassword(current, updated) {
|
|
83
173
|
await this.repo.updatePassword(current, updated);
|
|
@@ -85,38 +175,18 @@ class AfloatAuth {
|
|
|
85
175
|
return true;
|
|
86
176
|
}
|
|
87
177
|
/**
|
|
88
|
-
* Logs out the current user
|
|
178
|
+
* Logs out the current user.
|
|
89
179
|
*/
|
|
90
180
|
logOut() {
|
|
91
181
|
this.clearSavedData();
|
|
92
182
|
}
|
|
93
183
|
/**
|
|
94
|
-
* Clears
|
|
184
|
+
* Clears all authentication data.
|
|
95
185
|
* @private
|
|
96
186
|
*/
|
|
97
187
|
clearSavedData() {
|
|
98
|
-
store.
|
|
99
|
-
|
|
188
|
+
this.store.refresh();
|
|
189
|
+
this.tokenHandler.clearToken();
|
|
100
190
|
}
|
|
101
191
|
}
|
|
102
192
|
exports.AfloatAuth = AfloatAuth;
|
|
103
|
-
const initialState = { user: undefined };
|
|
104
|
-
const store = (0, zustand_1.create)((0, middleware_1.persist)((set, get) => ({
|
|
105
|
-
...initialState,
|
|
106
|
-
getUser: () => {
|
|
107
|
-
try {
|
|
108
|
-
const jsonUser = get().user;
|
|
109
|
-
if (jsonUser)
|
|
110
|
-
return index_js_1.User.fromJSON(jsonUser);
|
|
111
|
-
}
|
|
112
|
-
catch (_) {
|
|
113
|
-
console.log(_);
|
|
114
|
-
}
|
|
115
|
-
return undefined;
|
|
116
|
-
},
|
|
117
|
-
setUser: (user) => set({ user: user.toJSON() }),
|
|
118
|
-
refresh: () => set(initialState),
|
|
119
|
-
}), {
|
|
120
|
-
name: AUTH_STORE_SESSION_STORAGE_KEY,
|
|
121
|
-
storage: (0, middleware_1.createJSONStorage)(() => sessionStorage),
|
|
122
|
-
}));
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Profile API contract
|
|
4
|
+
*/
|
|
5
|
+
export declare const profileContract: {
|
|
6
|
+
getCurrentProfile: {
|
|
7
|
+
method: "GET";
|
|
8
|
+
path: "/me";
|
|
9
|
+
headers: z.ZodObject<{
|
|
10
|
+
token: z.ZodString;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
token: string;
|
|
13
|
+
}, {
|
|
14
|
+
token: string;
|
|
15
|
+
}>;
|
|
16
|
+
responses: {
|
|
17
|
+
200: z.ZodObject<{
|
|
18
|
+
id: z.ZodString;
|
|
19
|
+
firstName: z.ZodString;
|
|
20
|
+
lastName: z.ZodString;
|
|
21
|
+
displayName: z.ZodString;
|
|
22
|
+
phone: z.ZodString;
|
|
23
|
+
accountNo: z.ZodString;
|
|
24
|
+
email: z.ZodString;
|
|
25
|
+
}, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
26
|
+
id: string;
|
|
27
|
+
firstName: string;
|
|
28
|
+
lastName: string;
|
|
29
|
+
displayName: string;
|
|
30
|
+
phone: string;
|
|
31
|
+
accountNo: string;
|
|
32
|
+
email: string;
|
|
33
|
+
}, {
|
|
34
|
+
id: string;
|
|
35
|
+
firstName: string;
|
|
36
|
+
lastName: string;
|
|
37
|
+
displayName: string;
|
|
38
|
+
phone: string;
|
|
39
|
+
accountNo: string;
|
|
40
|
+
email: string;
|
|
41
|
+
}>;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../../../../src/src/features/auth/profile/contract.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAS1B,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.profileContract = void 0;
|
|
4
|
+
const core_1 = require("@ts-rest/core");
|
|
5
|
+
const index_js_1 = require("../../../models/index.js");
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
/**
|
|
8
|
+
* Profile API contract
|
|
9
|
+
*/
|
|
10
|
+
exports.profileContract = (0, core_1.initContract)().router({
|
|
11
|
+
getCurrentProfile: {
|
|
12
|
+
method: "GET",
|
|
13
|
+
path: "/me",
|
|
14
|
+
headers: zod_1.z.object({ token: zod_1.z.string() }),
|
|
15
|
+
responses: {
|
|
16
|
+
200: index_js_1.profileSchema,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Profile } from "../../../models/index.js";
|
|
2
|
+
import { BaseRepository } from "../../../shared/base_repository.js";
|
|
3
|
+
import { profileContract } from "./contract.js";
|
|
4
|
+
export declare class ProfileRepository extends BaseRepository<typeof profileContract> {
|
|
5
|
+
/**
|
|
6
|
+
* Initializes an instance of ProfileRepository.
|
|
7
|
+
*/
|
|
8
|
+
constructor();
|
|
9
|
+
getCurrentProfile(token: string): Promise<Profile>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../../../src/src/features/auth/profile/repository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEpE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,qBAAa,iBAAkB,SAAQ,cAAc,CAAC,OAAO,eAAe,CAAC;IAC3E;;OAEG;;IAKG,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAUzD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProfileRepository = void 0;
|
|
4
|
+
const base_repository_js_1 = require("../../../shared/base_repository.js");
|
|
5
|
+
const api_error_js_1 = require("../../../errors/api_error.js");
|
|
6
|
+
const contract_js_1 = require("./contract.js");
|
|
7
|
+
class ProfileRepository extends base_repository_js_1.BaseRepository {
|
|
8
|
+
/**
|
|
9
|
+
* Initializes an instance of ProfileRepository.
|
|
10
|
+
*/
|
|
11
|
+
constructor() {
|
|
12
|
+
super("profile", contract_js_1.profileContract);
|
|
13
|
+
}
|
|
14
|
+
async getCurrentProfile(token) {
|
|
15
|
+
const headers = { token };
|
|
16
|
+
const result = await this.client.getCurrentProfile({ headers });
|
|
17
|
+
if (result.status === 200)
|
|
18
|
+
return result.body;
|
|
19
|
+
throw new api_error_js_1.APIError({
|
|
20
|
+
message: "An error occurred while trying to get the current profile",
|
|
21
|
+
statusCode: 502,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.ProfileRepository = ProfileRepository;
|
|
@@ -26,5 +26,6 @@ export declare class AuthRepository extends BaseRepository<typeof authContract>
|
|
|
26
26
|
* @throws {APIError} If the current password is invalid or another error occurs during the update process.
|
|
27
27
|
*/
|
|
28
28
|
updatePassword(currentPassword: string, newPassword: string): Promise<boolean>;
|
|
29
|
+
getAccessList(token: string): Promise<string[]>;
|
|
29
30
|
}
|
|
30
31
|
//# sourceMappingURL=repository.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../../src/src/features/auth/repository.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../../src/src/features/auth/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAI7C;;;GAGG;AACH,qBAAa,cAAe,SAAQ,cAAc,CAAC,OAAO,YAAY,CAAC;IACrE;;OAEG;;IAKH;;;;;;OAMG;IACG,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAwB3D;;;;;;OAMG;IACG,cAAc,CAClB,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,OAAO,CAAC;IAkBb,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAStD"}
|
|
@@ -5,6 +5,7 @@ const index_js_1 = require("../../models/index.js");
|
|
|
5
5
|
const base_repository_js_1 = require("../../shared/base_repository.js");
|
|
6
6
|
const contract_js_1 = require("./contract.js");
|
|
7
7
|
const api_error_js_1 = require("../../errors/api_error.js");
|
|
8
|
+
const repository_js_1 = require("./identity/repository.js");
|
|
8
9
|
/**
|
|
9
10
|
* Class representing the AuthRepository.
|
|
10
11
|
* Provides methods to handle authentication-related operations, such as login and password updates.
|
|
@@ -33,7 +34,7 @@ class AuthRepository extends base_repository_js_1.BaseRepository {
|
|
|
33
34
|
});
|
|
34
35
|
}
|
|
35
36
|
if (result.status === 201) {
|
|
36
|
-
const repo = new LoginRepository();
|
|
37
|
+
const repo = new repository_js_1.LoginRepository();
|
|
37
38
|
const loginCredentials = await repo.getIdentity(result.body.token);
|
|
38
39
|
const user = new index_js_1.User({ ...result.body, loginCredentials });
|
|
39
40
|
return user;
|
|
@@ -67,32 +68,14 @@ class AuthRepository extends base_repository_js_1.BaseRepository {
|
|
|
67
68
|
statusCode: 502,
|
|
68
69
|
});
|
|
69
70
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Class representing the LoginRepository.
|
|
74
|
-
* Provides methods to retrieve user identity-related information.
|
|
75
|
-
*/
|
|
76
|
-
class LoginRepository extends base_repository_js_1.BaseRepository {
|
|
77
|
-
/**
|
|
78
|
-
* Initializes an instance of LoginRepository.
|
|
79
|
-
*/
|
|
80
|
-
constructor() {
|
|
81
|
-
super("login", contract_js_1.identityContract);
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Retrieves the user's login credentials.
|
|
85
|
-
* @returns A promise that resolves to the user's login credentials on success.
|
|
86
|
-
* @throws {APIError} If an error occurs while retrieving the credentials.
|
|
87
|
-
*/
|
|
88
|
-
async getIdentity(token) {
|
|
89
|
-
const headers = { token };
|
|
90
|
-
const result = await this.client.getUserCredentials({ headers });
|
|
71
|
+
async getAccessList(token) {
|
|
72
|
+
const result = await this.client.access({ headers: { token: token } });
|
|
91
73
|
if (result.status === 200)
|
|
92
74
|
return result.body;
|
|
93
75
|
throw new api_error_js_1.APIError({
|
|
94
|
-
message: "An error occurred while trying to get
|
|
76
|
+
message: "An error occurred while trying to get access list",
|
|
95
77
|
statusCode: 502,
|
|
96
78
|
});
|
|
97
79
|
}
|
|
98
80
|
}
|
|
81
|
+
exports.AuthRepository = AuthRepository;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { User } from "../../../models/user/index.js";
|
|
2
|
+
import { type StoreApi, type UseBoundStore } from "zustand";
|
|
3
|
+
import type { AuthStore } from "./types.js";
|
|
4
|
+
/** Type definition for the store's state */
|
|
5
|
+
type State = {
|
|
6
|
+
user: string | undefined;
|
|
7
|
+
};
|
|
8
|
+
/** Type definition for the store's actions */
|
|
9
|
+
interface Actions {
|
|
10
|
+
setUser: (user: User) => void;
|
|
11
|
+
getUser: () => User | undefined;
|
|
12
|
+
refresh: () => void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Creates and exports the Zustand store directly for reactive hooks
|
|
16
|
+
* @internal This should only be used by AfloatAuth
|
|
17
|
+
*/
|
|
18
|
+
export declare const clientStore: UseBoundStore<StoreApi<State & Actions>>;
|
|
19
|
+
/**
|
|
20
|
+
* Creates a client-side authentication store using Zustand.
|
|
21
|
+
* @returns {AuthStore} An implementation of AuthStore for client-side use
|
|
22
|
+
*/
|
|
23
|
+
export declare const createClientStore: () => AuthStore;
|
|
24
|
+
/**
|
|
25
|
+
* React hook to access the current user with reactive updates.
|
|
26
|
+
* @returns {User | undefined} The current user or undefined if not authenticated
|
|
27
|
+
*/
|
|
28
|
+
export declare const useClientUser: () => User | undefined;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=client_store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client_store.d.ts","sourceRoot":"","sources":["../../../../../src/src/features/auth/storage/client_store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAU,KAAK,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AAEpE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAK5C,4CAA4C;AAC5C,KAAK,KAAK,GAAG;IAAE,IAAI,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAE1C,8CAA8C;AAC9C,UAAU,OAAO;IACf,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAC9B,OAAO,EAAE,MAAM,IAAI,GAAG,SAAS,CAAC;IAChC,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,aAAa,CAAC,QAAQ,CAAC,KAAK,GAAG,OAAO,CAAC,CA2BhE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,QAAO,SAMpC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,aAAa,QAAO,IAAI,GAAG,SAEvC,CAAC"}
|