@temboplus/afloat 0.1.5 → 0.1.6
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/src/features/auth/manager.d.ts +0 -2
- package/esm/src/features/auth/manager.d.ts.map +1 -1
- package/esm/src/features/auth/manager.js +8 -6
- package/package.json +1 -1
- package/script/src/features/auth/manager.d.ts +0 -2
- package/script/src/features/auth/manager.d.ts.map +1 -1
- package/script/src/features/auth/manager.js +8 -6
|
@@ -5,8 +5,6 @@ import type { Permission } from "../../models/permission.js";
|
|
|
5
5
|
* Provides authentication functionality and user management.
|
|
6
6
|
*/
|
|
7
7
|
export declare class AfloatAuth {
|
|
8
|
-
/** Singleton instance */
|
|
9
|
-
private static _instance;
|
|
10
8
|
/** The auth store implementation */
|
|
11
9
|
private store;
|
|
12
10
|
/** The token handler implementation */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../../src/src/features/auth/manager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../../src/src/features/auth/manager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAY7D;;;GAGG;AACH,qBAAa,UAAU;IACrB,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;IAyBxE;;;;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;IAIlC;;;;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"}
|
|
@@ -3,6 +3,7 @@ import { createClientStore, useClientUser, } from "./storage/client_store.js";
|
|
|
3
3
|
import { ClientTokenHandler } from "./storage/client_token_handler.js";
|
|
4
4
|
import { ServerStore } from "./storage/server_store.js";
|
|
5
5
|
import { ServerTokenHandler } from "./storage/server_token_handler.js";
|
|
6
|
+
let _instance = null;
|
|
6
7
|
/**
|
|
7
8
|
* Main authentication class that works in both client and server environments.
|
|
8
9
|
* Provides authentication functionality and user management.
|
|
@@ -37,10 +38,10 @@ export class AfloatAuth {
|
|
|
37
38
|
* @returns {AfloatAuth} The singleton instance configured for client-side
|
|
38
39
|
*/
|
|
39
40
|
static initializeClient() {
|
|
40
|
-
if (!
|
|
41
|
-
|
|
41
|
+
if (!_instance) {
|
|
42
|
+
_instance = new AfloatAuth(createClientStore(), ClientTokenHandler.instance);
|
|
42
43
|
}
|
|
43
|
-
return
|
|
44
|
+
return _instance;
|
|
44
45
|
}
|
|
45
46
|
/**
|
|
46
47
|
* Creates a new instance of AfloatAuth configured for server-side use.
|
|
@@ -60,7 +61,8 @@ export class AfloatAuth {
|
|
|
60
61
|
const user = await tokenHandler.constructUser();
|
|
61
62
|
store.setUser(user);
|
|
62
63
|
// Create and initialize auth instance
|
|
63
|
-
|
|
64
|
+
_instance = new AfloatAuth(store, tokenHandler);
|
|
65
|
+
return _instance;
|
|
64
66
|
}
|
|
65
67
|
catch (error) {
|
|
66
68
|
if (error instanceof Error) {
|
|
@@ -75,10 +77,10 @@ export class AfloatAuth {
|
|
|
75
77
|
* @returns {AfloatAuth} The singleton instance
|
|
76
78
|
*/
|
|
77
79
|
static get instance() {
|
|
78
|
-
if (!
|
|
80
|
+
if (!_instance) {
|
|
79
81
|
throw new Error("AfloatAuth not initialized. Call initializeClient() or initializeServer() first");
|
|
80
82
|
}
|
|
81
|
-
return
|
|
83
|
+
return _instance;
|
|
82
84
|
}
|
|
83
85
|
/**
|
|
84
86
|
* Gets the authentication repository instance.
|
package/package.json
CHANGED
|
@@ -5,8 +5,6 @@ import type { Permission } from "../../models/permission.js";
|
|
|
5
5
|
* Provides authentication functionality and user management.
|
|
6
6
|
*/
|
|
7
7
|
export declare class AfloatAuth {
|
|
8
|
-
/** Singleton instance */
|
|
9
|
-
private static _instance;
|
|
10
8
|
/** The auth store implementation */
|
|
11
9
|
private store;
|
|
12
10
|
/** The token handler implementation */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../../src/src/features/auth/manager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../../src/src/features/auth/manager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAY7D;;;GAGG;AACH,qBAAa,UAAU;IACrB,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;IAyBxE;;;;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;IAIlC;;;;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"}
|
|
@@ -6,6 +6,7 @@ const client_store_js_1 = require("./storage/client_store.js");
|
|
|
6
6
|
const client_token_handler_js_1 = require("./storage/client_token_handler.js");
|
|
7
7
|
const server_store_js_1 = require("./storage/server_store.js");
|
|
8
8
|
const server_token_handler_js_1 = require("./storage/server_token_handler.js");
|
|
9
|
+
let _instance = null;
|
|
9
10
|
/**
|
|
10
11
|
* Main authentication class that works in both client and server environments.
|
|
11
12
|
* Provides authentication functionality and user management.
|
|
@@ -40,10 +41,10 @@ class AfloatAuth {
|
|
|
40
41
|
* @returns {AfloatAuth} The singleton instance configured for client-side
|
|
41
42
|
*/
|
|
42
43
|
static initializeClient() {
|
|
43
|
-
if (!
|
|
44
|
-
|
|
44
|
+
if (!_instance) {
|
|
45
|
+
_instance = new AfloatAuth((0, client_store_js_1.createClientStore)(), client_token_handler_js_1.ClientTokenHandler.instance);
|
|
45
46
|
}
|
|
46
|
-
return
|
|
47
|
+
return _instance;
|
|
47
48
|
}
|
|
48
49
|
/**
|
|
49
50
|
* Creates a new instance of AfloatAuth configured for server-side use.
|
|
@@ -63,7 +64,8 @@ class AfloatAuth {
|
|
|
63
64
|
const user = await tokenHandler.constructUser();
|
|
64
65
|
store.setUser(user);
|
|
65
66
|
// Create and initialize auth instance
|
|
66
|
-
|
|
67
|
+
_instance = new AfloatAuth(store, tokenHandler);
|
|
68
|
+
return _instance;
|
|
67
69
|
}
|
|
68
70
|
catch (error) {
|
|
69
71
|
if (error instanceof Error) {
|
|
@@ -78,10 +80,10 @@ class AfloatAuth {
|
|
|
78
80
|
* @returns {AfloatAuth} The singleton instance
|
|
79
81
|
*/
|
|
80
82
|
static get instance() {
|
|
81
|
-
if (!
|
|
83
|
+
if (!_instance) {
|
|
82
84
|
throw new Error("AfloatAuth not initialized. Call initializeClient() or initializeServer() first");
|
|
83
85
|
}
|
|
84
|
-
return
|
|
86
|
+
return _instance;
|
|
85
87
|
}
|
|
86
88
|
/**
|
|
87
89
|
* Gets the authentication repository instance.
|